/* Workspace v1 stylesheet. Paper look, phone first, tablet at 768px and up. */

/* ---------- fonts (self-hosted) ---------- */
@font-face { font-family: 'Caveat'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/caveat-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Caveat'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/caveat-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Caveat'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/caveat-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Caveat'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/caveat-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Patrick Hand'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/patrick-hand-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/archivo-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/archivo-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/archivo-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Archivo'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/archivo-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/ibm-plex-sans-latin-700-normal.woff2') format('woff2'); }

/* ---------- tokens ---------- */
:root {
  --font-ui: 'Archivo', system-ui, sans-serif;
  --font-hand: 'Caveat', cursive;
  --hand-scale: 1.3;
  --hand-weight: 500;

  --paper: #f4f0e6;
  --sheet: #fffdf8;
  --sheet-2: #f8f4ea;
  --ink: #1d1a15;
  --ink-2: #4d463c;
  --ink-3: #7d7569;
  --rule: #d8d0c0;
  --rule-2: #e7e0d2;
  --line: #cfc6b5;
  --focus: #2b5d8f;
  --danger: #a8352b;
  --danger-bg: #fbe9e6;
  --warn: #b7791f;
  --warn-bg: #fdf1dc;
  --good: #2f7a44;
  --good-bg: #e6f3e9;
  --shadow: 0 1px 2px rgba(29, 26, 21, .06), 0 6px 18px rgba(29, 26, 21, .07);
  --shadow-lg: 0 8px 30px rgba(29, 26, 21, .18);
  --radius: 10px;

  /* color palette: bg, border, ink */
  --c-paper-bg: #fffdf8; --c-paper-bd: #cfc6b5; --c-paper-ink: #1d1a15;
  --c-yellow-bg: #fff3b0; --c-yellow-bd: #d9c25a; --c-yellow-ink: #4a3d05;
  --c-peach-bg: #ffe0c7; --c-peach-bd: #e3a978; --c-peach-ink: #5a3212;
  --c-rose-bg: #fcd9dc; --c-rose-bd: #e39aa2; --c-rose-ink: #5e1f27;
  --c-lilac-bg: #e6dcf7; --c-lilac-bd: #b39bdc; --c-lilac-ink: #35215a;
  --c-sky-bg: #d6e8f7; --c-sky-bd: #8fb6da; --c-sky-ink: #16334f;
  --c-mint-bg: #d3f0e1; --c-mint-bd: #82c4a2; --c-mint-ink: #123d29;
  --c-sage-bg: #e2e8d5; --c-sage-bd: #a9b88b; --c-sage-ink: #2f3a1e;
  --c-sand-bg: #f0e6d2; --c-sand-bd: #c7b48a; --c-sand-ink: #4a3a1a;
  --c-slate-bg: #e0e2e6; --c-slate-bd: #9aa1ad; --c-slate-ink: #23272e;
}

html[data-theme="dark"] {
  --paper: #1c1a17;
  --sheet: #26231f;
  --sheet-2: #2d2925;
  --ink: #efe9dc;
  --ink-2: #cfc7b8;
  --ink-3: #9c9486;
  --rule: #4a443b;
  --rule-2: #38332d;
  --line: #55503f;
  --focus: #8db8e6;
  --danger: #f0867b;
  --danger-bg: #3d221f;
  --warn: #e6b45a;
  --warn-bg: #3b2f18;
  --good: #7ccb92;
  --good-bg: #1f3325;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, .6);

  --c-paper-bg: #2c2823; --c-paper-bd: #5a5346; --c-paper-ink: #efe9dc;
  --c-yellow-bg: #4a4016; --c-yellow-bd: #9c8a2e; --c-yellow-ink: #f6e9a3;
  --c-peach-bg: #4e3320; --c-peach-bd: #a7683f; --c-peach-ink: #f8d7bd;
  --c-rose-bg: #4c2528; --c-rose-bd: #a5555e; --c-rose-ink: #f7cfd3;
  --c-lilac-bg: #342b4a; --c-lilac-bd: #7a63a8; --c-lilac-ink: #e1d5f5;
  --c-sky-bg: #1f3245; --c-sky-bd: #4f7ba6; --c-sky-ink: #cfe2f5;
  --c-mint-bg: #1c3a2b; --c-mint-bd: #45876a; --c-mint-ink: #c9eed9;
  --c-sage-bg: #2f3624; --c-sage-bd: #6f7f52; --c-sage-ink: #dde5cc;
  --c-sand-bg: #3d3324; --c-sand-bd: #8a7549; --c-sand-ink: #eedfc4;
  --c-slate-bg: #2b2f36; --c-slate-bd: #5f6774; --c-slate-ink: #dde0e5;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --paper: #1c1a17; --sheet: #26231f; --sheet-2: #2d2925; --ink: #efe9dc; --ink-2: #cfc7b8; --ink-3: #9c9486;
    --rule: #4a443b; --rule-2: #38332d; --line: #55503f; --focus: #8db8e6; --danger: #f0867b; --danger-bg: #3d221f;
    --warn: #e6b45a; --warn-bg: #3b2f18; --good: #7ccb92; --good-bg: #1f3325;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.35); --shadow-lg: 0 8px 30px rgba(0,0,0,.6);
    --c-paper-bg: #2c2823; --c-paper-bd: #5a5346; --c-paper-ink: #efe9dc;
    --c-yellow-bg: #4a4016; --c-yellow-bd: #9c8a2e; --c-yellow-ink: #f6e9a3;
    --c-peach-bg: #4e3320; --c-peach-bd: #a7683f; --c-peach-ink: #f8d7bd;
    --c-rose-bg: #4c2528; --c-rose-bd: #a5555e; --c-rose-ink: #f7cfd3;
    --c-lilac-bg: #342b4a; --c-lilac-bd: #7a63a8; --c-lilac-ink: #e1d5f5;
    --c-sky-bg: #1f3245; --c-sky-bd: #4f7ba6; --c-sky-ink: #cfe2f5;
    --c-mint-bg: #1c3a2b; --c-mint-bd: #45876a; --c-mint-ink: #c9eed9;
    --c-sage-bg: #2f3624; --c-sage-bd: #6f7f52; --c-sage-ink: #dde5cc;
    --c-sand-bg: #3d3324; --c-sand-bd: #8a7549; --c-sand-ink: #eedfc4;
    --c-slate-bg: #2b2f36; --c-slate-bd: #5f6774; --c-slate-ink: #dde0e5;
  }
}

html[data-font="patrick"] { --font-hand: 'Patrick Hand', cursive; --hand-scale: 1.15; --hand-weight: 400; }
html[data-font="plex"] { --font-hand: 'IBM Plex Sans', system-ui, sans-serif; --hand-scale: 1; --hand-weight: 400; }
html[data-home-font="plex"] { --font-ui: 'IBM Plex Sans', system-ui, sans-serif; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Only body carries overflow-x so it propagates to the viewport; html and body must never become scroll containers. */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; overflow-x: hidden; overflow-y: visible;
  background: var(--paper); color: var(--ink);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.4;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-ui); font-weight: 600; line-height: 1.2; }
p { margin: 0; }
[hidden] { display: none !important; }
.noscript { padding: 2rem; text-align: center; }

.boot-splash { min-height: 100dvh; display: grid; place-items: center; }
.boot-mark { width: 64px; height: 64px; border: 2px solid var(--ink); border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 30px; background: var(--sheet); }

/* handwriting: anything the user writes */
.hand, .hand input, .hand textarea, .hand [contenteditable], input.hand, textarea.hand {
  font-family: var(--font-hand); font-weight: var(--hand-weight);
  font-size: calc(1rem * var(--hand-scale)); line-height: 1.35;
}
.hand-lg { font-size: calc(1.25rem * var(--hand-scale)); }

/* ---------- shell ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.page-head { padding: calc(env(safe-area-inset-top) + 18px) 16px 8px; max-width: 980px; width: 100%; margin: 0 auto; }
.page-title-btn {
  all: unset; display: flex; align-items: center; gap: 8px; cursor: pointer; border-radius: 8px; padding: 2px 4px; margin-left: -4px;
}
.page-title-btn:focus-visible { outline: 2px solid var(--focus); }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.page-title-btn .chev { width: 18px; height: 18px; opacity: .55; }
.page-sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.page-head .rule { border: 0; border-top: 1.5px solid var(--ink); margin: 12px 0 0; opacity: .85; }
.page-body { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); min-width: 0; }

.crumb {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 60%, transparent);
  pointer-events: none;
}
.crumb-btn {
  pointer-events: auto; box-sizing: border-box;
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 6px 8px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--sheet);
  font-family: var(--font-ui); font-size: 12.5px; color: var(--ink-2); box-shadow: var(--shadow); white-space: nowrap; overflow: hidden;
}
.crumb-btn .seg-btn { background: none; border: 0; padding: 4px 6px; margin: 0; border-radius: 999px; color: inherit; font: inherit; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.crumb-btn .seg-btn:hover { background: var(--sheet-2); }
.crumb-btn .seg-btn:focus-visible { outline: 2px solid var(--focus); }
.crumb-btn .seg-btn:active { transform: translateY(1px); }
.crumb-btn b { color: var(--ink); font-weight: 600; }
.crumb-btn .dot { opacity: .45; }
.crumb-btn .detail { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.crumb-btn .ver { padding-right: 6px; }
.crumb-btn .home-ico { width: 14px; height: 14px; flex: none; }

/* ---------- home ---------- */
.home-head { padding-top: calc(env(safe-area-inset-top) + 28px); }
.home-title { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.home-sub { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.home-grid { display: grid; gap: 12px; grid-template-columns: 1fr; margin-top: 14px; }
.home-card {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: 14px; min-width: 0;
  background: var(--sheet); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.home-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--card-accent, var(--rule)); }
.home-card:focus-visible { outline: 2px solid var(--focus); }
.home-card:active { transform: translateY(1px); }
.home-card .hc-text { flex: 1; min-width: 0; }
.home-card .hc-name { font-weight: 600; font-size: 17px; }
.home-card .hc-desc { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.home-card .hc-badge { font-size: 11px; color: var(--ink-3); border: 1px solid var(--rule); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.home-card .hc-ico { width: 26px; height: 26px; flex: none; opacity: .85; }
.home-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }

/* ---------- buttons / forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border: 1.5px solid var(--ink); border-radius: 8px; background: var(--sheet); color: var(--ink);
  font-family: var(--font-ui); font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.ghost { border-color: var(--rule); color: var(--ink-2); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.xs { min-height: 26px; padding: 2px 8px; font-size: 11.5px; border-radius: 6px; }
.btn.block { width: 100%; }
.btn.icon { padding: 6px; min-width: 40px; }
.btn.sm.icon { min-width: 32px; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row.end { justify-content: flex-end; }
.btn-row.between { justify-content: space-between; }

.field { display: block; margin: 10px 0; min-width: 0; }
.field > span, .label { display: block; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: 4px; }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; min-width: 0; padding: 8px 10px; background: var(--sheet); border: 1.5px solid var(--rule); border-radius: 8px; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus, [contenteditable]:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.field textarea { min-height: 88px; resize: vertical; }
.field.hand input, .field.hand textarea { font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1rem * var(--hand-scale)); }
.field.ruled textarea {
  background-image: repeating-linear-gradient(transparent, transparent calc(1.5em * var(--hand-scale) - 1px), var(--rule-2) calc(1.5em * var(--hand-scale) - 1px), var(--rule-2) calc(1.5em * var(--hand-scale)));
  line-height: calc(1.5em * var(--hand-scale)); background-attachment: local;
}
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline > span { margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
.help { font-size: 12px; color: var(--ink-3); }
.err-msg { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.ok-msg { background: var(--good-bg); color: var(--good); border: 1px solid var(--good); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }

/* color swatches */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--rule); padding: 0; background: var(--sw-bg); position: relative; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--ink); }
.swatch:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- sheets / cards ---------- */
.sheet {
  background: var(--sheet); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0;
}
.sheet.soft { border-color: var(--rule); box-shadow: none; }
.sheet + .sheet { margin-top: 12px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sheet-head h3 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); flex: 1; min-width: 0; }
.sheet-head .meta { font-size: 12px; color: var(--ink-3); }
.stack { display: grid; gap: 12px; }
.section-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.section-bar .spacer { flex: 1; }
.empty { color: var(--ink-3); font-size: 14px; padding: 16px 4px; text-align: center; }
.empty.hand { font-size: calc(1.1rem * var(--hand-scale)); }

/* color chip classes (used on cards, tags, notes) */
.c-paper { --cbg: var(--c-paper-bg); --cbd: var(--c-paper-bd); --cink: var(--c-paper-ink); }
.c-yellow { --cbg: var(--c-yellow-bg); --cbd: var(--c-yellow-bd); --cink: var(--c-yellow-ink); }
.c-peach { --cbg: var(--c-peach-bg); --cbd: var(--c-peach-bd); --cink: var(--c-peach-ink); }
.c-rose { --cbg: var(--c-rose-bg); --cbd: var(--c-rose-bd); --cink: var(--c-rose-ink); }
.c-lilac { --cbg: var(--c-lilac-bg); --cbd: var(--c-lilac-bd); --cink: var(--c-lilac-ink); }
.c-sky { --cbg: var(--c-sky-bg); --cbd: var(--c-sky-bd); --cink: var(--c-sky-ink); }
.c-mint { --cbg: var(--c-mint-bg); --cbd: var(--c-mint-bd); --cink: var(--c-mint-ink); }
.c-sage { --cbg: var(--c-sage-bg); --cbd: var(--c-sage-bd); --cink: var(--c-sage-ink); }
.c-sand { --cbg: var(--c-sand-bg); --cbd: var(--c-sand-bd); --cink: var(--c-sand-ink); }
.c-slate { --cbg: var(--c-slate-bg); --cbd: var(--c-slate-bd); --cink: var(--c-slate-ink); }

.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--cbg, var(--sheet-2)); color: var(--cink, var(--ink-2)); border: 1px solid var(--cbd, var(--rule)); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.tag.late { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.tag.good { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.tag.plain { background: transparent; }

.row-card {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  background: var(--sheet); border: 1.5px solid var(--rule); border-left: 6px solid var(--cbd, var(--rule)); border-radius: 8px; padding: 10px 12px; min-width: 0;
}
button.row-card { cursor: pointer; }
.row-card:focus-visible { outline: 2px solid var(--focus); }
.row-card .rc-main { flex: 1; min-width: 0; }
.row-card .rc-title { font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1.05rem * var(--hand-scale)); line-height: 1.25; overflow-wrap: anywhere; }
.row-card .rc-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-card .rc-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.progress { height: 6px; background: var(--rule-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ink); width: var(--pct, 0%); border-radius: 999px; transition: width .25s; }
.pct { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(29, 26, 21, .35); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; }
.modal {
  width: 100%; max-width: 640px; max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain;
  background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 14px 14px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg);
}
.modal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.modal-head h2 { font-size: 18px; flex: 1; min-width: 0; }
.modal-foot { display: flex; gap: 8px; justify-content: space-between; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.modal-foot .right { display: flex; gap: 8px; margin-left: auto; }
@media (min-width: 768px) {
  .modal-bg { align-items: center; padding: 20px; }
  .modal { border-radius: 14px; padding: 18px 20px; }
}

/* ---------- section switcher menu ---------- */
.menu { position: fixed; z-index: 60; background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; }
.menu button { all: unset; display: flex; align-items: center; gap: 10px; width: 100%; box-sizing: border-box; padding: 9px 10px; border-radius: 7px; font-size: 14px; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--sheet-2); outline: none; }
.menu button.current { font-weight: 600; }
.menu button svg { width: 18px; height: 18px; opacity: .8; }
.menu .sep { border-top: 1px solid var(--rule); margin: 6px 4px; }
.menu-bg { position: fixed; inset: 0; z-index: 59; }

/* ---------- login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 14px; padding: 22px 20px; box-shadow: var(--shadow); }
.login-mark { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.login-mark .boot-mark { width: 40px; height: 40px; font-size: 20px; border-radius: 9px; }
.login-mark h1 { font-size: 22px; }
.login-card .hint { font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1.05rem * var(--hand-scale)); color: var(--ink-2); margin-bottom: 8px; }
.login-foot { margin-top: 14px; font-size: 11.5px; color: var(--ink-3); text-align: center; }

/* ---------- calendar ---------- */
.cal-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.cal-nav .cal-label { flex: 1; text-align: center; font-weight: 600; font-size: 17px; min-width: 0; }
.seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; }
.seg button { all: unset; cursor: pointer; padding: 7px 12px; font-size: 13px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.month { border: 1.5px solid var(--ink); border-radius: var(--radius); background: var(--sheet); overflow: hidden; }
.month-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1.5px solid var(--ink); }
.month-dow span { text-align: center; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 6px 0; font-weight: 600; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.month-cell {
  all: unset; box-sizing: border-box; cursor: pointer; min-height: 62px; padding: 4px; border-right: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2);
  display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow: hidden;
}
.month-cell:nth-child(7n) { border-right: 0; }
.month-cell:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.month-cell.other { color: var(--ink-3); background: var(--sheet-2); }
.month-cell.today .dnum { background: var(--ink); color: var(--paper); }
.month-cell.selected { box-shadow: inset 0 0 0 2px var(--ink); }
.dnum { font-size: 12px; font-weight: 600; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.pip { height: 6px; border-radius: 3px; background: var(--cbd, var(--rule)); }
.pip-row { display: flex; gap: 2px; flex-wrap: wrap; }
.pip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cbd, var(--rule)); }
.cell-ev { font-size: 10.5px; line-height: 1.2; padding: 1px 4px; border-radius: 4px; background: var(--cbg); color: var(--cink); border-left: 3px solid var(--cbd); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(.8rem * var(--hand-scale)); }
@media (min-width: 768px) { .month-cell { min-height: 96px; } }

.day-list { margin-top: 12px; }
.day-list h3 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; }

.week { display: grid; gap: 10px; grid-template-columns: 1fr; }
.week-day { background: var(--sheet); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 8px 10px 10px; min-width: 0; }
.week-day.today { border-width: 2px; }
.week-day .wd-head { display: flex; align-items: baseline; gap: 8px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; border-bottom: 1px solid var(--rule); padding-bottom: 4px; margin-bottom: 6px; }
.week-day .wd-head .num { font-size: 15px; }
.week-day .wd-head .add { margin-left: auto; }
.week-day.today .wd-head .num { background: var(--ink); color: var(--paper); border-radius: 50%; width: 24px; height: 24px; display: inline-grid; place-items: center; }
.week-day .ruled { min-height: 52px; background-image: repeating-linear-gradient(transparent, transparent 27px, var(--rule-2) 27px, var(--rule-2) 28px); }
.ev-line { display: flex; align-items: center; gap: 8px; min-height: 28px; padding: 0 2px; border-radius: 4px; width: 100%; text-align: left; background: none; border: 0; min-width: 0; }
.ev-line:focus-visible { outline: 2px solid var(--focus); }
.ev-line .ev-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cbd); flex: none; border: 1px solid var(--cink); opacity: .9; }
.ev-line .ev-time { font-size: 11px; color: var(--ink-3); flex: none; font-variant-numeric: tabular-nums; }
.ev-line .ev-title { font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1rem * var(--hand-scale)); line-height: 1.2; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-line .ev-kind { font-size: 10px; color: var(--ink-3); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; flex: none; }
@media (min-width: 768px) {
  .week { grid-template-columns: repeat(2, 1fr); }
  .week .week-day:last-child:nth-child(odd) { grid-column: span 2; }
}
@media (min-width: 1100px) { .week { grid-template-columns: repeat(7, 1fr); } .week .week-day:last-child:nth-child(odd) { grid-column: auto; } }

/* ---------- action lists ---------- */
.week-summary { display: flex; align-items: center; gap: 10px; }
.week-summary .progress { flex: 1; }
.alist { background: var(--sheet); border: 1.5px solid var(--ink); border-left: 8px solid var(--cbd); border-radius: var(--radius); padding: 10px 12px; }
.alist-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.alist-head .al-title { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; font-family: var(--font-hand); font-weight: 600; font-size: calc(1.15rem * var(--hand-scale)); overflow-wrap: anywhere; }
.alist-head .pct { flex: none; }
.aitem { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--rule-2); min-width: 0; }
.aitem:last-of-type { border-bottom: 0; }
.aitem input[type=checkbox] { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.aitem .ai-main { flex: 1; min-width: 0; }
.aitem .ai-text { font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1.05rem * var(--hand-scale)); line-height: 1.25; overflow-wrap: anywhere; background: none; border: 0; padding: 0; text-align: left; width: 100%; color: inherit; }
.aitem.done .ai-text { text-decoration: line-through; color: var(--ink-3); }
.aitem .ai-meta { font-size: 11.5px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }
.aitem .ai-meta .over { color: var(--danger); }
.quick-add { display: flex; gap: 6px; margin-top: 8px; }
.quick-add input { flex: 1; min-width: 0; padding: 8px 10px; border: 0; border-bottom: 1.5px solid var(--rule); background: transparent; border-radius: 0; }
.quick-add input:focus { outline: none; border-bottom-color: var(--ink); }
@media (min-width: 768px) { .alists { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; } .alist + .alist { margin-top: 0; } }

/* ---------- projects ---------- */
.proj-grid { display: grid; gap: 10px; }
@media (min-width: 768px) { .proj-grid { grid-template-columns: 1fr 1fr; } }
.proj-card { display: flex; flex-direction: column; gap: 6px; text-align: left; background: var(--sheet); border: 1.5px solid var(--ink); border-top: 8px solid var(--cbd); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; min-width: 0; }
.proj-card:focus-visible { outline: 2px solid var(--focus); }
.proj-card .pc-code { font-size: 11px; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.proj-card .pc-name { font-family: var(--font-hand); font-weight: 600; font-size: calc(1.2rem * var(--hand-scale)); line-height: 1.2; overflow-wrap: anywhere; }
.proj-card .pc-dates { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }
.proj-card .pc-foot { display: flex; align-items: center; gap: 8px; }
.proj-card .pc-foot .progress { flex: 1; }
.proj-box { border: 1.5px solid var(--ink); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
.proj-box .label { margin-bottom: 2px; }
.proj-box .val { font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1.05rem * var(--hand-scale)); white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.4em; }
.proj-box .val.muted { color: var(--ink-3); }

/* ---------- quick capture ---------- */
.cap-list { display: grid; gap: 8px; }
@media (min-width: 768px) { .cap-list { grid-template-columns: 1fr 1fr; } }
.editor-bar { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; position: sticky; top: 0; z-index: 5; background: var(--sheet); padding: 6px 0; border-bottom: 1px solid var(--rule); margin-bottom: 8px; }
.editor-bar .btn { min-height: 34px; padding: 4px 9px; }
.editor-bar select { padding: 6px 8px; border: 1.5px solid var(--rule); border-radius: 7px; background: var(--sheet); font-size: 13px; }
.editor {
  min-height: 55vh; padding: 6px 4px; outline: none; font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1.05rem * var(--hand-scale));
  line-height: calc(1.6em); background-image: repeating-linear-gradient(transparent, transparent calc(1.6em - 1px), var(--rule-2) calc(1.6em - 1px), var(--rule-2) 1.6em); background-attachment: local;
  overflow-wrap: anywhere;
}
.editor:empty::before { content: attr(data-placeholder); color: var(--ink-3); }
.editor p, .editor div { margin: 0; }
.editor h1 { font-size: 1.7em; line-height: 1.6em; margin: 0; } .editor h2 { font-size: 1.4em; line-height: 1.6em; margin: 0; } .editor h3 { font-size: 1.2em; line-height: 1.6em; margin: 0; }
.editor ul, .editor ol { margin: 0; padding-left: 1.4em; }
.editor blockquote { margin: 0; padding-left: .8em; border-left: 3px solid var(--rule); color: var(--ink-2); }
.editor hr { border: 0; border-top: 1.5px solid var(--ink); margin: .4em 0; }
.fs-1 { font-size: .7em; } .fs-2 { font-size: .85em; } .fs-3 { font-size: 1em; } .fs-4 { font-size: 1.2em; } .fs-5 { font-size: 1.45em; } .fs-6 { font-size: 1.75em; } .fs-7 { font-size: 2.1em; }
.cap-title { width: 100%; border: 0; border-bottom: 1.5px solid var(--ink); background: transparent; padding: 6px 2px; font-family: var(--font-hand); font-weight: 600; font-size: calc(1.3rem * var(--hand-scale)); margin-bottom: 6px; }
.cap-title:focus { outline: none; }
.cap-status { font-size: 11.5px; color: var(--ink-3); }

/* ---------- notes ---------- */
.notes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; transition: filter .25s; }
@media (min-width: 540px) { .notes-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .notes-grid { grid-template-columns: repeat(4, 1fr); } }
.notes-grid.blurred { filter: blur(4px) saturate(.8); pointer-events: none; user-select: none; }
.sticky {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 130px; padding: 10px 11px 12px;
  background: var(--cbg); color: var(--cink); border: 1px solid var(--cbd); border-radius: 3px 3px 14px 3px;
  box-shadow: 1px 2px 6px rgba(29, 26, 21, .15); position: relative; transform: rotate(var(--tilt, 0deg)); min-width: 0; overflow: hidden;
}
.sticky::after { content: ''; position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; background: linear-gradient(135deg, transparent 50%, rgba(0, 0, 0, .12) 50%); border-radius: 0 0 14px 0; }
.sticky:focus-visible { outline: 2px solid var(--focus); }
.sticky .st-title { font-family: var(--font-hand); font-weight: 600; font-size: calc(1.1rem * var(--hand-scale)); line-height: 1.2; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sticky .st-date { font-size: 10.5px; opacity: .7; }
.sticky .st-body { font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(.9rem * var(--hand-scale)); line-height: 1.25; opacity: .85; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; white-space: pre-wrap; }
.sticky .st-pin { position: absolute; top: 6px; right: 8px; width: 14px; height: 14px; opacity: .7; }
.sticky.new { border-style: dashed; background: var(--sheet); color: var(--ink-3); align-items: center; justify-content: center; font-size: 14px; }
.note-open { background: var(--cbg); color: var(--cink); border: 1px solid var(--cbd); border-radius: 3px 3px 18px 3px; padding: 14px 16px 18px; box-shadow: var(--shadow-lg); }
.note-open .n-title { width: 100%; background: transparent; border: 0; border-bottom: 1px solid var(--cbd); font-family: var(--font-hand); font-weight: 600; font-size: calc(1.4rem * var(--hand-scale)); padding: 4px 0; color: inherit; }
.note-open .n-body { width: 100%; background: transparent; border: 0; min-height: 40vh; resize: vertical; font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1.1rem * var(--hand-scale)); line-height: 1.5; color: inherit; padding: 6px 0; }
.note-open .n-title:focus, .note-open .n-body:focus { outline: none; }
.note-open .n-meta { font-size: 11.5px; opacity: .7; margin-top: 4px; }
.modal.note-modal { background: transparent; border: 0; box-shadow: none; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); }
.modal.note-modal .note-open .btn { border-color: var(--cink); color: var(--cink); background: transparent; }
.modal.note-modal .note-open .btn.primary { background: var(--cink); color: var(--cbg); }

/* ---------- meetings ---------- */
.meet-detail .m-block { border: 1.5px solid var(--ink); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
.meet-detail .m-block .label { margin-bottom: 2px; }
.meet-detail .m-block .val { font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1.05rem * var(--hand-scale)); white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.4em; }
.meet-detail .m-block .val.muted { color: var(--ink-3); }
.follow { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--rule-2); }
.follow:last-child { border-bottom: 0; }
.follow input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--ink); flex: none; }
.follow .f-main { flex: 1; min-width: 0; }
.follow .f-text { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1.05rem * var(--hand-scale)); overflow-wrap: anywhere; }
.follow.done .f-text { text-decoration: line-through; color: var(--ink-3); }
.follow .f-meta { font-size: 11.5px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- settings / admin ---------- */
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt { all: unset; box-sizing: border-box; cursor: pointer; border: 1.5px solid var(--rule); border-radius: 8px; padding: 10px; text-align: center; font-size: 13px; }
.opt[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opt:focus-visible { outline: 2px solid var(--focus); }
.opt .sample { display: block; font-size: 22px; line-height: 1.2; }
.opt .sample.caveat { font-family: 'Caveat'; font-weight: 500; font-size: 26px; }
.opt .sample.patrick { font-family: 'Patrick Hand'; }
.opt .sample.plex { font-family: 'IBM Plex Sans'; font-size: 18px; }
.opt .sample.archivo { font-family: 'Archivo'; font-weight: 600; font-size: 18px; }
.sec-color-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--rule-2); }
.sec-color-row .name { flex: 1; font-size: 14px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 6px 6px; border-bottom: 1.5px solid var(--ink); }
.table td { padding: 8px 6px; border-bottom: 1px solid var(--rule-2); vertical-align: top; overflow-wrap: anywhere; }
.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { border: 1.5px solid var(--ink); border-radius: 8px; padding: 8px 10px; }
.stat b { display: block; font-size: 22px; font-weight: 700; }
.stat span { font-size: 11px; color: var(--ink-3); letter-spacing: .05em; text-transform: uppercase; }
.pill-ok { color: var(--good); } .pill-bad { color: var(--danger); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(70px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; background: var(--ink); color: var(--paper); padding: 9px 14px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- utilities ---------- */
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.mt { margin-top: 12px; } .mt-s { margin-top: 6px; } .mb { margin-bottom: 12px; }
.flex { display: flex; align-items: center; gap: 8px; min-width: 0; }
.flex .grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- calendar: year view ---------- */
.year-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .year-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .year-grid { grid-template-columns: repeat(4, 1fr); } }
.mini-month { background: var(--sheet); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 8px 8px 10px; min-width: 0; }
.mini-month.current { box-shadow: inset 0 0 0 1.5px var(--ink); }
.mm-name { all: unset; cursor: pointer; display: flex; align-items: center; gap: 6px; width: 100%; box-sizing: border-box; font-family: var(--font-ui); font-weight: 600; font-size: 13px; padding: 2px 2px 6px; border-bottom: 1px solid var(--rule); margin-bottom: 4px; }
.mm-name:focus-visible { outline: 2px solid var(--focus); }
.mm-count { margin-left: auto; font-size: 10px; font-weight: 500; color: var(--ink-3); border: 1px solid var(--rule); border-radius: 999px; padding: 0 6px; }
.mm-dow { display: grid; grid-template-columns: repeat(7, 1fr); }
.mm-dow span { text-align: center; font-size: 9px; color: var(--ink-3); font-weight: 600; }
.mm-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.yd { all: unset; box-sizing: border-box; cursor: pointer; text-align: center; font-family: var(--font-ui); font-size: 10.5px; line-height: 20px; height: 20px; border-radius: 4px; position: relative; }
.yd.out { cursor: default; }
.yd.has::after { content: ''; position: absolute; left: 50%; bottom: 1px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--ink); }
.yd.today { background: var(--ink); color: var(--paper); font-weight: 700; }
.yd.today.has::after { background: var(--paper); }
.yd:focus-visible { outline: 2px solid var(--focus); }
@media (min-width: 900px) { .yd { font-size: 11.5px; line-height: 24px; height: 24px; } }

/* ---------- calendar: day view ---------- */
.day-card { background: var(--sheet); border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 12px 14px; }
.day-card.today { border-width: 2px; }
.day-block { display: grid; gap: 6px; }
.day-line { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; background: var(--cbg); color: var(--cink); border: 1px solid var(--cbd); border-left: 6px solid var(--cbd); border-radius: 8px; padding: 8px 10px; min-width: 0; cursor: pointer; }
.day-line:focus-visible { outline: 2px solid var(--focus); }
.dl-time { flex: none; font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 64px; padding-top: 4px; opacity: .85; }
.dl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dl-title { font-family: var(--font-hand); font-weight: var(--hand-weight); font-size: calc(1.15rem * var(--hand-scale)); line-height: 1.2; overflow-wrap: anywhere; }
.dl-meta { font-size: 11.5px; opacity: .8; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.wd-open { all: unset; cursor: pointer; display: inline-flex; align-items: baseline; gap: 8px; font: inherit; color: inherit; border-radius: 4px; }
.wd-open:focus-visible { outline: 2px solid var(--focus); }

/* ---------- templates ---------- */
.tpl-grid { display: grid; gap: 10px; }
@media (min-width: 768px) { .tpl-grid { grid-template-columns: 1fr 1fr; } }
.tpl-card { background: var(--sheet); border: 1.5px solid var(--ink); border-top: 8px solid var(--cbd); border-radius: var(--radius); padding: 10px 12px 12px; min-width: 0; }
.tpl-title { font-weight: 600; font-size: 16px; }
.tpl-desc { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.tpl-preview { margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--rule); border-radius: 8px; background: var(--sheet-2); color: var(--ink-2); font-size: calc(.95rem * var(--hand-scale)); line-height: 1.3; }
.tpl-line { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-line + .tpl-line { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--rule-2); }

/* ---------- sketch (freehand ink) ---------- */
.sk-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 600px) { .sk-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .sk-grid { grid-template-columns: repeat(4, 1fr); } }
.sk-card { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; gap: 6px; background: var(--sheet); border: 1.5px solid var(--ink); border-top: 8px solid var(--cbd); border-radius: var(--radius); padding: 8px; min-width: 0; }
.sk-card:focus-visible { outline: 2px solid var(--focus); }
.sk-card:active { transform: translateY(1px); }
.sk-thumb-wrap { width: 100%; aspect-ratio: 4 / 5; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; background: var(--cbg, var(--sheet)); display: flex; }
.sk-thumb { width: 100%; height: 100%; display: block; }
.sk-title { font-weight: 600; font-size: calc(1.05rem * var(--hand-scale)); line-height: 1.2; overflow-wrap: anywhere; padding: 0 2px; }
.sk-meta { font-size: 11px; color: var(--ink-3); padding: 0 2px 2px; }

.sk-sheet { padding: 10px 10px 14px; }
.ink-bar { flex-direction: column; align-items: stretch; gap: 6px; }
.ink-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ink-sep { width: 1px; height: 22px; background: var(--rule); margin: 0 2px; }
.ink-bar .btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.ink-bar select { padding: 6px 8px; border: 1.5px solid var(--rule); border-radius: 7px; background: var(--sheet); font-size: 13px; }
.ink-colors { display: flex; gap: 6px; }
.ink-sw { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--rule); padding: 0; background: var(--sw); }
.ink-sw[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--ink); }
.ink-sw:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
html[data-theme="dark"] .ink-sw[style*="#1d1a15"] { background: #efe9dc; }
.ink-widths { display: flex; gap: 4px; }
.ink-w { min-width: 34px; padding: 4px 8px; }
.ink-w i { display: block; width: 16px; height: var(--w, 3px); border-radius: 999px; background: currentColor; }

.ink-wrap {
  position: relative; width: 100%; margin-top: 4px; border: 1.5px solid var(--ink); border-radius: 6px; overflow: hidden;
  background-color: var(--cbg, var(--sheet)); --unit: 40px; --grid-ink: rgba(29, 26, 21, .16);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
html[data-theme="dark"] .ink-wrap { --grid-ink: rgba(239, 233, 220, .16); }
.ink-wrap.paper-ruled { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--unit) - 1px), var(--grid-ink) calc(var(--unit) - 1px), var(--grid-ink) var(--unit)); }
.ink-wrap.paper-grid { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--unit) - 1px), var(--grid-ink) calc(var(--unit) - 1px), var(--grid-ink) var(--unit)), repeating-linear-gradient(to right, transparent 0, transparent calc(var(--unit) - 1px), var(--grid-ink) calc(var(--unit) - 1px), var(--grid-ink) var(--unit)); }
.ink-wrap.paper-dots { background-image: radial-gradient(var(--grid-ink) 1.2px, transparent 1.4px); background-size: var(--unit) var(--unit); background-position: calc(var(--unit) / 2) calc(var(--unit) / 2); }
.sk-thumb-wrap.paper-ruled { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 7px, var(--rule-2) 7px, var(--rule-2) 8px); }
.sk-thumb-wrap.paper-grid { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 7px, var(--rule-2) 7px, var(--rule-2) 8px), repeating-linear-gradient(to right, transparent 0, transparent 7px, var(--rule-2) 7px, var(--rule-2) 8px); }
.ink-canvas { display: block; touch-action: none; cursor: crosshair; }
.ink-canvas.erasing { cursor: cell; }
