/* Drop — visual system
   Canvas: cool paper gray. Colour is reserved for categories: each box is filled with its own hue.
   Type: Bricolage Grotesque for titles and the date, the phone's own font for note text.
   Scales: 7 type sizes (rem, follow the iPhone's text-size setting), 4/8 spacing, 5 radii, 2 shadows. */

@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage-latin.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage-latin-ext.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C0, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* type scale: 12 / 13 / 15 / 17 / 20 / 24 / 34 at default text size */
  --t-xs: .706rem;
  --t-sm: .765rem;
  --t-md: .882rem;
  --t-base: 1rem;
  --t-lg: 1.176rem;
  --t-xl: 1.412rem;
  --t-2xl: 2rem;
  /* spacing */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  /* radius: inner = outer − padding */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px; --r-2xl: 28px; --r-full: 999px;
  /* motion: ease-out for things arriving, ease-in for things leaving */
  --ease-out: cubic-bezier(.25, .8, .25, 1);
  --ease-in: cubic-bezier(.5, 0, .75, 0);
  --spring: cubic-bezier(.2, .9, .3, 1.12);
  --d-tap: 80ms; --d-fast: 160ms; --d-base: 240ms; --d-slow: 320ms;

  --canvas: #F3F4F6;
  --surface: #FDFDFE;
  --ink: #16181C;
  --ink-2: #41464D;
  --ink-3: #6A6F76;
  --line: rgba(22, 24, 28, .08);
  --line-2: rgba(22, 24, 28, .18);
  --press: rgba(22, 24, 28, .06);
  --glass: rgba(253, 253, 254, .78);
  --glass-line: rgba(22, 24, 28, .08);
  --on-ink: #FDFDFE;
  --chip: #E9EBEE;
  --chip-ink: #41464D;
  --warn-bg: #FFF0D2;
  --warn-ink: #7A4800;
  --danger-bg: #FFE3E3;
  --danger-ink: #A5221B;
  --scrim: rgba(12, 14, 18, .34);
  --e1: 0 1px 2px rgba(16, 20, 30, .05), 0 3px 10px rgba(16, 20, 30, .05);
  --e2: 0 14px 36px rgba(16, 20, 30, .13), 0 3px 10px rgba(16, 20, 30, .06);
  --display: 'Bricolage', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --text: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #111215;
    --surface: #1C1D21;
    --ink: #F2F3F5;
    --ink-2: #BEC2C9;
    --ink-3: #868B93;
    --line: rgba(255, 255, 255, .08);
    --line-2: rgba(255, 255, 255, .18);
    --press: rgba(255, 255, 255, .07);
    --glass: rgba(32, 33, 38, .8);
    --glass-line: rgba(255, 255, 255, .09);
    --on-ink: #111215;
    --chip: #2A2C31;
    --chip-ink: #C8CBD1;
    --warn-bg: #3A2A0B;
    --warn-ink: #F6C56B;
    --danger-bg: #431A1A;
    --danger-ink: #FFACA6;
    --scrim: rgba(0, 0, 0, .56);
    --e1: 0 1px 2px rgba(0, 0, 0, .3), 0 3px 10px rgba(0, 0, 0, .25);
    --e2: 0 14px 36px rgba(0, 0, 0, .5), 0 3px 10px rgba(0, 0, 0, .3);
  }
}

/* Text size follows the iPhone's Dynamic Type setting (1rem = body text), small sizes included.
   Zooming is switched off entirely (index.html), like a native app. */
html { font-size: 17px; }
@supports (font: -apple-system-body) {
  @media (hover: none) and (pointer: coarse) { html { font: -apple-system-body; } }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--canvas); color: var(--ink); -webkit-text-size-adjust: 100%; overscroll-behavior: none; -webkit-font-smoothing: antialiased; }
body { font-family: var(--text); font-size: var(--t-base); overflow: hidden; -webkit-tap-highlight-color: transparent; }
/* scrolling only: no pinch-zoom, no double-tap zoom */
html, body { touch-action: pan-x pan-y; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; position: relative; }
button:focus-visible, .card:focus-visible, a:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: var(--r-md); }
svg { display: block; }
[hidden] { display: none !important; }

#app { position: fixed; left: 0; right: 0; top: 0; height: 100%; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- header ---------- */
#top { position: relative; z-index: 4; display: flex; align-items: flex-end; gap: var(--s2); padding: calc(env(safe-area-inset-top) + var(--s4)) var(--s4) var(--s4) var(--s5); transition: box-shadow var(--d-base) var(--ease-out); }
#app.scrolled #top, #app.scrolled-main #top, #app.scrolled-feed #top { box-shadow: 0 1px 0 var(--line); }
.today { margin-right: auto; display: flex; flex-direction: column; min-width: 0; }
.today .d1 { font-family: var(--display); font-size: var(--t-2xl); line-height: 1; font-weight: 720; letter-spacing: -.028em; font-variation-settings: 'opsz' 96; }
.today .d2 { font-size: var(--t-md); font-weight: 500; color: var(--ink-3); margin-top: var(--s1); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); background: var(--surface); flex: none; box-shadow: var(--e1); transition: transform var(--d-tap) ease; }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 20px; height: 20px; }
.ghost-pill { min-height: 32px; padding: 0 var(--s3); border-radius: var(--r-full); font-size: var(--t-sm); font-weight: 600; background: var(--warn-bg); color: var(--warn-ink); align-self: center; }
.ghost-pill::after { content: ''; position: absolute; inset: -6px -2px; }
.sync-pill { align-self: center; display: inline-flex; align-items: center; gap: var(--s2); min-height: 32px; padding: 0 var(--s3); border-radius: var(--r-full); font-size: var(--t-sm); font-weight: 600; background: var(--chip); color: var(--ink-2); }
.sync-pill.err { background: var(--danger-bg); color: var(--danger-ink); }
.sync-pill::after { content: ''; position: absolute; inset: -6px -2px; }

/* ---------- board ---------- */
#board { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0 var(--s3) calc(var(--composer-h, 110px) + var(--s6)); scroll-padding-bottom: calc(var(--composer-h, 110px) + var(--s5)); }
/* scroll-edge: content fades out under the header instead of being cut off */
#top::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: var(--s5); background: linear-gradient(var(--canvas), color-mix(in srgb, var(--canvas) 0%, transparent)); opacity: 0; pointer-events: none; transition: opacity var(--d-base) var(--ease-out); }
#app.scrolled #top::after, #app.scrolled-main #top::after, #app.scrolled-feed #top::after { opacity: 1; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
@media (min-width: 720px) and (max-width: 999px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #board, #top { padding-left: max(var(--s4), calc(50% - 470px)); padding-right: max(var(--s4), calc(50% - 470px)); }
  #composer { padding-left: max(var(--s3), calc(50% - 360px)) !important; padding-right: max(var(--s3), calc(50% - 360px)) !important; }
}

/* Category boxes: each filled with its own colour (vars set inline). */
.card {
  --ink-t2: color-mix(in srgb, var(--ink-t) 88%, var(--fill));
  position: relative; background: var(--fill); color: var(--ink-t);
  border-radius: var(--r-xl); padding: var(--s4); min-height: 124px; min-width: 0; text-align: left; cursor: pointer;
  outline: 0 solid transparent; outline-offset: 3px;
  transition: transform var(--d-tap) ease, outline-color var(--d-base);
}
.card:active { transform: scale(.975); }
.card.wide { grid-column: 1 / -1; min-height: 0; }
.card h3 { margin: 0 0 var(--s2); display: flex; align-items: baseline; gap: var(--s2); min-width: 0; font-family: var(--display); font-size: var(--t-base); font-weight: 660; letter-spacing: -.012em; line-height: 1.2; font-variation-settings: 'opsz' 28; }
.card.wide h3 { font-size: var(--t-lg); margin-bottom: var(--s3); }
.card h3 .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .cnt { margin-left: auto; font-family: var(--text); font-size: var(--t-sm); font-weight: 650; color: var(--ink-t2); font-variant-numeric: tabular-nums; }
.card .empty { color: var(--ink-t2); font-size: var(--t-md); }
.l3 { font-size: var(--t-md); line-height: 1.4; color: var(--ink-t2); white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.l1 { font-size: var(--t-md); line-height: 1.6; color: var(--ink-t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l1 .circ { display: inline-block; width: .7em; height: .7em; border: 1.6px solid var(--ink-t2); border-radius: 50%; margin-right: var(--s2); vertical-align: -1px; opacity: .55; }
.card .chip { margin-right: var(--s1); background: color-mix(in srgb, var(--surface) 62%, transparent); color: var(--ink-t); }
.card .chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.card .chip.danger { background: var(--danger-bg); color: var(--danger-ink); }

/* Coming up: a small timeline — when on the left, what on the right. */
.tl { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: var(--s4); row-gap: var(--s2); align-items: baseline; }
.tl-when { font-size: var(--t-sm); font-weight: 650; color: var(--ink-t); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-when.danger { color: var(--danger-ink); }
.tl-when .tm { font-weight: 500; color: var(--ink-t2); }
.tl-what { font-size: var(--t-md); color: var(--ink-t); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-what .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: var(--s2); vertical-align: 1px; }
.tl-more { grid-column: 2; font-size: var(--t-sm); color: var(--ink-t2); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot.sm { width: 7px; height: 7px; margin-right: var(--s1); vertical-align: 1px; }
.chip { font-size: var(--t-xs); line-height: 1.6; font-weight: 600; padding: 0 var(--s2); border-radius: var(--r-full); margin-right: var(--s2); white-space: nowrap; display: inline-block; background: var(--chip); color: var(--chip-ink); vertical-align: 1px; font-variant-numeric: tabular-nums; }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip.danger { background: var(--danger-bg); color: var(--danger-ink); }
.chip.past { background: transparent; color: var(--ink-3); padding-left: 0; }
.pulse { animation: pulse 420ms var(--ease-out); }
@keyframes pulse { 40% { transform: scale(1.03); } }

.banner { background: var(--surface); border-radius: var(--r-xl); padding: var(--s1) var(--s1) var(--s1) var(--s4); margin-bottom: var(--s3); display: flex; align-items: center; gap: var(--s2); font-size: var(--t-md); color: var(--ink-2); min-height: 56px; box-shadow: var(--e1); }
.banner .grow { flex: 1; line-height: 1.35; padding: var(--s2) 0; }
.banner button.act { font-weight: 650; min-height: 36px; padding: 0 var(--s4); border-radius: var(--r-full); background: var(--ink); color: var(--on-ink); }
.banner button.act::after { content: ''; position: absolute; inset: -4px; }
.banner button.x { color: var(--ink-3); width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.banner svg { width: 18px; height: 18px; flex: none; }
.banner > svg { color: var(--ink-3); }

/* ---------- all notes ---------- */
.feed-title { margin: var(--s6) var(--s1) 0; font-family: var(--display); font-size: var(--t-xl); font-weight: 700; letter-spacing: -.022em; font-variation-settings: 'opsz' 48; }
.day {
  position: sticky; top: 0; z-index: 3; margin: 0 calc(var(--s3) * -1); padding: var(--s3) var(--s4) var(--s2) var(--s5);
  font-family: var(--display); font-size: var(--t-md); font-weight: 620; color: var(--ink-2);
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.more-btn { display: block; margin: var(--s4) auto var(--s1); min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-full); font-size: var(--t-md); font-weight: 600; background: var(--surface); color: var(--ink-2); box-shadow: var(--e1); }

/* Grouped lists (all notes, category pages, settings) */
.list { background: var(--surface); border-radius: var(--r-xl); overflow: hidden; box-shadow: var(--e1); }
.row { position: relative; display: flex; gap: var(--s3); padding: var(--s3) var(--s4); align-items: flex-start; transition: background-color var(--d-fast); }
.row + .row::before { content: ''; position: absolute; top: 0; left: var(--s4); right: 0; height: 1px; background: var(--line); }
.row:has(.bar) + .row::before { left: 32px; }
.row .bar { width: 4px; border-radius: 2px; align-self: stretch; flex: none; margin: 2px 0; }
.row .rt { flex: 1; min-width: 0; font-size: var(--t-base); line-height: 1.4; overflow-wrap: anywhere; cursor: pointer; border-radius: var(--r-sm); }
.row .tx { white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.row.open .tx { display: block; }
.row.done .tx { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); margin-top: var(--s1); font-size: var(--t-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.meta .cn { font-weight: 650; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 1.7px solid var(--line-2); flex: none; margin-top: 1px; display: grid; place-items: center; color: var(--on-ink); transition: background-color var(--d-fast), border-color var(--d-fast), transform var(--d-tap); }
.check::after { content: ''; position: absolute; inset: -10px; }
.check:active { transform: scale(.86); }
.check svg { width: 14px; height: 14px; opacity: 0; }
.row.done .check { background: var(--ink-3); border-color: var(--ink-3); }
.row.done .check svg { opacity: 1; }
.acts { display: flex; gap: var(--s2); margin-top: var(--s3); flex-wrap: wrap; }
.acts button, .btn { position: relative; min-height: 40px; padding: 0 var(--s4); border-radius: var(--r-full); font-size: var(--t-md); font-weight: 600; background: var(--chip); color: var(--ink); display: inline-flex; align-items: center; gap: var(--s2); text-decoration: none; transition: transform var(--d-tap), filter var(--d-fast); }
.acts button::after, .btn::after { content: ''; position: absolute; inset: -2px; }
.acts button:active, .btn:active { transform: scale(.95); }
.acts button.del, .btn.del { color: var(--danger-ink); background: var(--danger-bg); }
.acts button.primary, .btn.primary, button.primary { background: var(--ink); color: var(--on-ink); }
.edit-ta { width: 100%; font: inherit; font-size: var(--t-base); line-height: 1.4; border: 1.5px solid var(--line-2); border-radius: var(--r-md); padding: var(--s2) var(--s3); background: var(--canvas); color: var(--ink); resize: vertical; min-height: 96px; outline: none; }
.edit-ta:focus { border-color: var(--ink-3); }

/* ---------- composer: a floating glass bar ---------- */
#composer { position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; flex-direction: column; align-items: stretch; padding: 0 var(--s2) calc(env(safe-area-inset-bottom) + var(--s2)); pointer-events: none; }
#composer > * { pointer-events: auto; }
body.kb #composer { padding-bottom: var(--s2); }
.glass {
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--r-2xl); padding: var(--s1); box-shadow: var(--e2);
  -webkit-backdrop-filter: blur(26px) saturate(1.8); backdrop-filter: blur(26px) saturate(1.8);
}
#pills { display: flex; gap: var(--s2); overflow-x: auto; padding: var(--s2) var(--s2) var(--s3); scrollbar-width: none; }
#pills::-webkit-scrollbar { display: none; }
.pill { flex: none; position: relative; min-height: 36px; padding: 0 var(--s3); border-radius: var(--r-full); font-size: var(--t-md); font-weight: 550; background: var(--chip); color: var(--ink-2); border: 1.5px solid transparent; transition: transform var(--d-tap); }
.pill:active { transform: scale(.94); }
.pill .f { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: inherit; transition: width 350ms var(--ease-out); }
.pill::after { content: ''; position: absolute; inset: -4px -3px; }
.pill .l { position: relative; display: inline-flex; align-items: center; gap: var(--s1); }
.pill .l svg { width: 13px; height: 13px; }
.pill.ghost { border-style: dashed; border-color: var(--line-2); background: transparent; }
.box { display: flex; gap: var(--s1); align-items: flex-end; }
#ta { flex: 1; min-width: 0; font: inherit; font-size: var(--t-base); line-height: 1.4; color: var(--ink); background: transparent; border: 0; padding: 10px var(--s2) 10px var(--s3); resize: none; outline: none; height: 44px; min-height: 44px; max-height: 9em; overflow-y: auto; -webkit-appearance: none; transition: height 220ms var(--ease-out), min-height 280ms var(--ease-out); }
#ta::placeholder { color: var(--ink-3); }
#composer.focused #ta { min-height: 7.5em; max-height: 40vh; }
#send { width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: var(--on-ink); flex: none; display: grid; place-items: center; transition: transform var(--d-tap), background-color var(--d-base), color var(--d-base); }
#composer:not(.has-text) #send { background: var(--chip); color: var(--ink-3); }
#send:active { transform: scale(.9); }
#send svg { width: 20px; height: 20px; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 var(--s1); border-radius: var(--r-full); font-size: var(--t-xs); font-weight: 700; line-height: 20px; text-align: center; background: var(--surface); color: var(--ink); box-shadow: var(--e1); font-variant-numeric: tabular-nums; }
#preview { display: flex; flex-direction: column; gap: 2px; margin: var(--s1) var(--s1) 0; padding: var(--s1) 0 2px; border-top: 1px solid var(--line); }
.prow, .prow-out { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); padding: var(--s1) var(--s2); border-radius: var(--r-md); min-width: 0; min-height: 28px; }
.prow.cur { background: var(--press); }
.prow .pn { font-weight: 650; white-space: nowrap; }
.prow .pt { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.prow .chip { margin-right: 0; }
/* loading placeholder while the AI decides (instead of a spinner) */
.skel { display: inline-block; width: 64px; height: .9em; border-radius: var(--r-full); background: linear-gradient(90deg, var(--chip) 0%, var(--line-2) 50%, var(--chip) 100%); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; flex: none; }
.skel.dotk { width: 8px; height: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.think { width: 12px; height: 12px; border-radius: 50%; border: 1.6px solid var(--ink-3); border-top-color: transparent; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.sorting { align-self: flex-start; display: inline-flex; align-items: center; gap: var(--s2); margin: 0 0 var(--s2) var(--s1); min-height: 32px; padding: 0 var(--s3); border-radius: var(--r-full); font-size: var(--t-sm); font-weight: 550; color: var(--ink-2); background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--e1); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }

#toast { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(100% + var(--s3)); background: var(--ink); color: var(--on-ink); border-radius: var(--r-full); min-height: 44px; padding: var(--s1) 6px var(--s1) var(--s4); font-size: var(--t-md); font-weight: 550; display: flex; gap: var(--s3); align-items: center; max-width: calc(100% - var(--s6)); white-space: nowrap; z-index: 5; box-shadow: var(--e2); }
#toast .tm { overflow: hidden; text-overflow: ellipsis; padding-right: var(--s2); }
#toast button { font-weight: 700; color: var(--ink); background: var(--on-ink); min-height: 32px; padding: 0 var(--s3); border-radius: var(--r-full); }
#toast button::after { content: ''; position: absolute; inset: -6px -4px; }

.fly { position: fixed; z-index: 60; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--t-md); font-weight: 500; padding: var(--s2) var(--s3); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--e2); pointer-events: none; transition: transform 420ms var(--ease-out), opacity 420ms var(--ease-out); }

/* ---------- pages (category, settings, check) ---------- */
/* Leaving uses ease-in, arriving ease-out; visibility switches only after the slide. */
#sheet { position: absolute; inset: 0; z-index: 30; background: var(--canvas); display: flex; flex-direction: column; transform: translateX(104%); transition: transform 280ms var(--ease-in), visibility 0s linear 280ms; visibility: hidden; box-shadow: -12px 0 40px rgba(0, 0, 0, .08); }
#sheet.open { transform: none; visibility: visible; transition: transform var(--d-slow) var(--ease-out), visibility 0s; }
#sheet.hero-mode, #sheet.dragging { transition: none !important; }
#sheet { touch-action: pan-y; }
#sheet.hero-mode { transform: none; visibility: visible; }
.hero { background: var(--fill, transparent); color: var(--ink-t, var(--ink)); padding-bottom: var(--s4); border-radius: 0 0 var(--r-2xl) var(--r-2xl); --ink-t2: color-mix(in srgb, var(--ink-t, var(--ink)) 88%, var(--fill, var(--canvas))); }
.hero.plain { padding-bottom: var(--s1); }
.shead { display: flex; align-items: center; gap: var(--s2); padding: calc(env(safe-area-inset-top) + var(--s2)) var(--s3) var(--s1); }
.shead .sp { flex: 1; }
.hero .icon-btn { background: color-mix(in srgb, var(--surface) 55%, transparent); color: inherit; box-shadow: none; }
.hero.plain .icon-btn { background: var(--surface); color: var(--ink-2); box-shadow: var(--e1); }
.htitle { margin: var(--s2) var(--s5) 0; font-family: var(--display); font-size: var(--t-2xl); font-weight: 720; letter-spacing: -.028em; line-height: 1.05; font-variation-settings: 'opsz' 72; overflow-wrap: anywhere; }
.hsub { margin: var(--s1) var(--s5) 0; font-size: var(--t-md); color: var(--ink-t2, var(--ink-3)); font-weight: 500; }
.sbody { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: var(--s4) var(--s3) calc(env(safe-area-inset-bottom) + var(--s6)); }
.sec { margin: var(--s5) var(--s2) var(--s2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-3); display: flex; align-items: center; gap: var(--s2); }
.sec:first-child { margin-top: var(--s1); }
.sec button { color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; min-height: 44px; }
.note-intro { margin: 0 var(--s2) var(--s4); color: var(--ink-2); font-size: var(--t-md); line-height: 1.45; }
.setting { padding: var(--s4); font-size: var(--t-base); }
.setting + .setting { border-top: 1px solid var(--line); }
.setting p { margin: 0 0 var(--s3); color: var(--ink-2); font-size: var(--t-md); line-height: 1.45; }
.setting p:last-child { margin-bottom: 0; }
.setting .btns { display: flex; gap: var(--s2); flex-wrap: wrap; }
.setting code { display: block; font-size: var(--t-xs); word-break: break-all; background: var(--canvas); border-radius: var(--r-md); padding: var(--s3); margin: 0 0 var(--s3); color: var(--ink-2); }
.crow { position: relative; display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); min-height: 52px; font-size: var(--t-base); width: 100%; text-align: left; transition: background-color var(--d-fast); }
.crow + .crow::before { content: ''; position: absolute; top: 0; left: 46px; right: 0; height: 1px; background: var(--line); }
.crow .sw { width: 18px; height: 18px; border-radius: 6px; flex: none; }
.crow .cnt { margin-left: auto; color: var(--ink-3); font-size: var(--t-md); font-variant-numeric: tabular-nums; }
.crow svg { width: 18px; height: 18px; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.small { font-size: var(--t-sm); }

/* ---------- picker (bottom sheet) ---------- */
#picker { position: absolute; inset: 0; z-index: 40; background: var(--scrim); display: flex; align-items: flex-end; }
.panel { width: 100%; max-height: 78%; overflow-y: auto; background: var(--surface); border-radius: var(--r-2xl) var(--r-2xl) 0 0; padding: var(--s2) var(--s4) calc(env(safe-area-inset-bottom) + var(--s4)); }
.panel .grab { position: relative; width: 36px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto var(--s4); touch-action: none; }
.panel .grab::after { content: ''; position: absolute; inset: -16px -80px; }
.panel h4 { touch-action: none; }
.panel h4 { margin: 0 var(--s1) var(--s4); font-family: var(--display); font-size: var(--t-lg); font-weight: 680; letter-spacing: -.015em; }
.opts { display: flex; flex-wrap: wrap; gap: var(--s2); }
.opt { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-full); background: var(--fill, var(--chip)); color: var(--ink-t, var(--ink)); font-size: var(--t-md); font-weight: 600; transition: transform var(--d-tap); }
.opt:active { transform: scale(.95); }
.opt.cur { box-shadow: inset 0 0 0 2px var(--mid, var(--ink)); }
.opt svg { width: 14px; height: 14px; }
.menu-item { display: block; width: 100%; text-align: left; padding: var(--s3) var(--s2); min-height: 52px; font-size: var(--t-base); font-weight: 500; }
.menu-item + .menu-item { border-top: 1px solid var(--line); }
.menu-item.del { color: var(--danger-ink); }

/* ---------- unlock ---------- */
#login { position: absolute; inset: 0; z-index: 50; background: var(--canvas); display: grid; place-items: center; padding: var(--s5); }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: var(--s3); }
.login-card h1 { margin: var(--s5) 0 0; font-family: var(--display); font-size: var(--t-2xl); font-weight: 740; letter-spacing: -.035em; line-height: 1; font-variation-settings: 'opsz' 96; }
.login-card p { margin: 0 0 var(--s3); font-size: var(--t-base); }
.login-card input { font: inherit; font-size: var(--t-base); min-height: 52px; padding: 0 var(--s4); border-radius: var(--r-lg); border: 1.5px solid transparent; background: var(--surface); color: var(--ink); outline: none; box-shadow: var(--e1); }
.login-card input:focus { border-color: var(--line-2); }
.login-card button { min-height: 52px; border-radius: var(--r-lg); font-size: var(--t-base); }
.msg { color: var(--danger-ink); font-size: var(--t-md); min-height: 20px; line-height: 1.4; margin: 0; }
.logo-mark { display: grid; grid-template-columns: 32px 32px; gap: var(--s1); }
.logo-mark span { display: block; height: 32px; border-radius: 10px; }
.logo-mark span:nth-child(1) { grid-column: 1 / -1; height: 24px; background: #EE5F35; }
.logo-mark span:nth-child(2) { background: #7366E6; }
.logo-mark span:nth-child(3) { background: #16A27A; }

/* ---------- big screens (Mac, iPad landscape): boxes on the left, all notes on the right ---------- */
@media (min-width: 1000px) {
  :root { --feed-w: clamp(360px, 30vw, 460px); }
  #top { padding: var(--s6) var(--s6) var(--s5) var(--s7); }
  .today { flex-direction: row; align-items: baseline; gap: var(--s3); }
  .today .d1 { font-size: calc(var(--t-2xl) * 1.24); }
  .today .d2 { font-size: var(--t-lg); margin-top: 0; }
  #board { display: grid; grid-template-columns: minmax(0, 1fr) var(--feed-w); overflow: hidden; padding: 0; }
  #main { overflow-y: auto; min-height: 0; padding: 2px var(--s6) calc(var(--composer-h, 110px) + var(--s7)) var(--s7); overscroll-behavior: contain; }
  #feed { overflow-y: auto; min-height: 0; padding: 0 var(--s5) var(--s7); border-left: 1px solid var(--line); overscroll-behavior: contain; }
  .feed-title { margin: var(--s1) var(--s1) 0; }
  .day { margin: 0 calc(var(--s5) * -1); padding: var(--s3) var(--s6) var(--s2); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--s4); }
  .card { min-height: 156px; padding: var(--s5); border-radius: var(--r-2xl); }
  .card h3 { font-size: var(--t-lg); margin-bottom: var(--s3); }
  .card.wide h3 { font-size: var(--t-xl); }
  .tl { row-gap: var(--s2); column-gap: var(--s5); }
  #composer { right: var(--feed-w); align-items: center; padding: 0 var(--s7) var(--s5); }
  #composer .glass { width: 100%; max-width: 720px; }
  #composer.focused #ta { min-height: 6.5em; }
  .sorting { align-self: center; }
  #sheet { left: auto; width: min(500px, 100%); border-left: 1px solid var(--line); box-shadow: -24px 0 70px rgba(0, 0, 0, .14); }
  #picker { align-items: center; justify-content: center; }
  .panel { max-width: 460px; border-radius: var(--r-2xl); padding-bottom: var(--s5); }
  .panel .grab { display: none; }
}
@media (hover: hover) and (pointer: fine) {
  .card:hover { filter: brightness(.985) saturate(1.06); }
  .row:hover { background: color-mix(in srgb, var(--press) 60%, transparent); }
  .pill:hover, .acts button:hover, .btn:hover, .icon-btn:hover { filter: brightness(.96); }
  .crow:hover { background: var(--press); }
  ::-webkit-scrollbar { width: 10px; }
  ::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
  ::-webkit-scrollbar-track { background: transparent; }
}

/* ---------- motion: everything that comes in also goes out ---------- */
.collapse { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 220ms var(--ease-in), opacity 180ms var(--ease-in); }
.collapse.show { grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows 280ms var(--ease-out), opacity 220ms var(--ease-out); }
.collapse > .ci { overflow: hidden; min-height: 0; }
.collapse:not(.show) > .ci { visibility: hidden; transition: visibility 0s 220ms; }

@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.94); } }
@keyframes popOut { to { opacity: 0; transform: translateY(8px) scale(.94); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px) scale(.95); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 12px) scale(.95); } }
@keyframes scrimIn { from { opacity: 0; } }
@keyframes scrimOut { to { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }
@keyframes cardOut { to { opacity: 0; transform: translateY(16px) scale(.97); } }
@keyframes loginOut { to { opacity: 0; transform: scale(1.04); } }

#toast.entering { animation: toastIn 280ms var(--ease-out); }
#toast.leaving { animation: toastOut 200ms var(--ease-in) forwards; pointer-events: none; }
.sorting.entering, #unsureBtn.entering, #syncPill.entering { animation: popIn 260ms var(--ease-out); }
.sorting.leaving, #unsureBtn.leaving, #syncPill.leaving { animation: popOut 180ms var(--ease-in) forwards; }
#picker.entering { animation: scrimIn 220ms var(--ease-out); }
#picker.entering .panel { animation: sheetUp 300ms var(--ease-out); }
#picker.leaving { animation: scrimOut 220ms var(--ease-in) forwards; pointer-events: none; }
#picker.leaving .panel { animation: sheetDown 220ms var(--ease-in) forwards; }
#login.entering { animation: scrimIn 280ms var(--ease-out); }
#login.leaving { animation: loginOut 320ms var(--ease-in) forwards; pointer-events: none; }
@media (min-width: 1000px) {
  #picker.entering .panel { animation: cardIn 280ms var(--ease-out); }
  #picker.leaving .panel { animation: cardOut 200ms var(--ease-in) forwards; }
}

/* ---------- accessibility fallbacks ---------- */
@media (prefers-reduced-transparency: reduce) {
  .glass, .sorting { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .day { background: var(--canvas); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --ink-3: var(--ink-2); --line: var(--line-2); --glass: var(--surface); }
  .card { --ink-t2: var(--ink-t); }
  .glass, .sorting { -webkit-backdrop-filter: none; backdrop-filter: none; border-color: var(--line-2); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
