:root {
  --paper: #f5f3ee; --card: #ffffff; --ink: #1b1a17; --ink-2: #3b3934; --mute: #6e6a62; --faint: #a19c92;
  --rule: #e3dfd5; --line: #eeebe4; --chip: #ebe8e0; --press: #1b1a17; --press-ink: #ffffff; --link: #1f4e8c;
  --imm: #b3261e; --imm-bg: #fbeceb; --urg: #9a5a00; --urg-bg: #fbf0de;
  --imp: #1f4e8c; --imp-bg: #e8eef8; --wait: #66727a; --wait-bg: #eef0f1;
  --ok: #2b7a4b; --ok-bg: #e4f1e8; --spark: #0b7a70; --spark-bg: #e2f2ef; --spark-ink: #ffffff; --panel: #fbfaf7; --flash: #fff1b8; --scrim: rgba(20, 20, 18, .42);
  --shadow: 0 1px 2px rgba(27, 26, 23, .05);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --tabs-h: 61px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121316; --card: #1c1e22; --ink: #eceae4; --ink-2: #d2cfc8; --mute: #9b978f; --faint: #6c6963;
    --rule: #2d3036; --line: #262930; --chip: #272a2f; --press: #eceae4; --press-ink: #121316; --link: #8db4ec;
    --imm: #ef7067; --imm-bg: #3a1f1d; --urg: #e6a845; --urg-bg: #362916;
    --imp: #82abe8; --imp-bg: #1c2a3e; --wait: #939da4; --wait-bg: #24282c;
    --ok: #62c08a; --ok-bg: #173024; --spark: #5cc8bc; --spark-bg: #13302d; --spark-ink: #0b1d1b; --panel: #17191d; --flash: #3d3610; --scrim: rgba(0, 0, 0, .6);
    --shadow: none;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--safe-t) + 16px); scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }
body { margin: 0; background: var(--paper); color: var(--ink); -webkit-font-smoothing: antialiased;
       font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.serif { font-family: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
[hidden] { display: none !important; }

[data-tier="immediate"] { --tier: var(--imm); --tier-bg: var(--imm-bg); }
[data-tier="urgent"] { --tier: var(--urg); --tier-bg: var(--urg-bg); }
[data-tier="important"] { --tier: var(--imp); --tier-bg: var(--imp-bg); }
[data-tier="wait"] { --tier: var(--wait); --tier-bg: var(--wait-bg); }

main { max-width: 640px; margin: 0 auto; padding: calc(var(--safe-t) + 22px) 16px calc(var(--safe-b) + 104px); }

/* ---------- headings and notices ---------- */
.masthead { margin: 0 0 16px; }
.kicker { margin: 0; font-size: 12.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--mute); }
h1 { font-size: 34px; line-height: 1.1; font-weight: 600; letter-spacing: -0.015em; margin: 2px 0 6px; }
.byline { margin: 0; color: var(--mute); font-size: 14px; }
.notice { margin: 0 0 10px; padding: 11px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--rule);
          font-size: 14.5px; color: var(--ink-2); }
.notice.warn { background: var(--imm-bg); border-color: transparent; color: var(--imm); }
.notice.busy { display: flex; gap: 10px; align-items: center; }
.notice a { font-weight: 600; margin-left: 6px; }
.spin { flex: 0 0 auto; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--rule); border-top-color: var(--ink);
        animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- summary card ---------- */
.summary { background: var(--card); border: 1px solid var(--rule); border-radius: 18px; padding: 16px 16px 14px; margin: 0 0 14px; box-shadow: var(--shadow); }
.sum-line { margin: 0; font-size: 16px; color: var(--ink-2); display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sum-line .big { font-size: 30px; line-height: 1; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.sum-line.clear .big { color: var(--ok); }
.meter { height: 6px; border-radius: 99px; background: var(--chip); overflow: hidden; margin: 12px 0 6px; }
.meter .fill { height: 100%; width: 0; border-radius: 99px; background: var(--ok); transition: width .35s ease; }
.sum-sub { margin: 0 0 12px; font-size: 13px; color: var(--mute); }
.jump { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.jump .tj { display: flex; flex-direction: column; gap: 1px; padding: 8px 9px 7px; border-radius: 10px; background: var(--tier-bg);
            color: var(--tier); line-height: 1.15; min-width: 0; }
.jump a.tj:hover { text-decoration: none; filter: brightness(.97); }
.jump .tj .n { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.jump .tj .l { font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jump .tj.zero { background: var(--chip); color: var(--faint); }

/* ---------- venture chips ---------- */
.filters { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 6px; padding: 2px 16px 8px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--rule); background: var(--card); border-radius: 999px;
        padding: 6px 13px; font-size: 14px; min-height: 36px; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--press); border-color: var(--press); color: var(--press-ink); }

/* ---------- section headings ---------- */
h2.sect { display: flex; align-items: baseline; gap: 8px; margin: 26px 0 10px; font-size: 13px; line-height: 1.3; font-weight: 700;
          letter-spacing: .08em; text-transform: uppercase; color: var(--tier, var(--mute)); }
h2.sect .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tier, var(--mute)); flex: 0 0 auto; align-self: center; }
h2.sect .why { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 13px; color: var(--mute); }
h2.sect .count { margin-left: auto; color: var(--mute); font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; }

/* ---------- calendar ---------- */
.day { background: var(--card); border: 1px solid var(--rule); border-radius: 16px; padding: 2px 16px; box-shadow: var(--shadow); }
.ev { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.ev:first-child { border-top: 0; }
.ev .t { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; padding-top: 1px; }
.ev .t.later { font-weight: 600; font-size: 13px; color: var(--mute); padding-top: 3px; white-space: nowrap; }
.ev .x { font-size: 15.5px; line-height: 1.4; }
.ev .pill { margin-left: 6px; vertical-align: 1px; }
.ev .links { display: flex; flex-direction: column; gap: 2px; margin-top: 5px; }
.ev .links a { font-size: 14px; display: flex; gap: 6px; align-items: baseline; }
.ev .links a::before { content: "↳"; color: var(--faint); }
.day .sub { padding: 12px 0 0; border-top: 1px solid var(--line); font-size: 12px; font-weight: 700; letter-spacing: .08em;
            text-transform: uppercase; color: var(--mute); }
.day .sub + .ev { border-top: 0; padding-top: 6px; }

/* ---------- item cards ---------- */
.item { position: relative; background: var(--card); border: 1px solid var(--rule); border-radius: 16px; padding: 15px 16px 13px 19px;
        margin: 0 0 12px; box-shadow: inset 3px 0 0 var(--tier), var(--shadow); }
.item .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 6px; }
.item .v { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--mute); margin-right: 2px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; line-height: 1.4; padding: 1px 8px; border-radius: 999px; background: var(--chip); color: var(--ink-2); }
.pill.age { background: var(--imm-bg); color: var(--imm); }
.pill.st-open { background: var(--urg-bg); color: var(--urg); }
.pill.st-revisit { background: var(--imm-bg); color: var(--imm); }
.pill.st-closed { background: var(--chip); color: var(--mute); }
.item h3 { font-size: 18px; line-height: 1.3; font-weight: 650; margin: 0 0 6px; letter-spacing: -0.005em; }
.item .body { margin: 0 0 12px; font-size: 15.5px; color: var(--ink-2); }
.item .do { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--tier-bg); font-size: 15px; font-weight: 500; line-height: 1.4; }
.item .do b { color: var(--tier); font-weight: 700; margin-right: 6px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { flex: 1 1 140px; min-height: 46px; padding: 9px 14px; border-radius: 12px; border: 1.5px solid var(--rule); background: var(--card);
          font-size: 15px; font-weight: 600; line-height: 1.25; transition: transform .08s ease, background .15s ease; }
.choice:hover { border-color: var(--faint); }
.choice:active { transform: scale(.98); }
.choice[aria-pressed="true"] { background: var(--press); border-color: var(--press); color: var(--press-ink); }
.choice[aria-pressed="true"]::before { content: "✓ "; }
.item .foot { margin-top: 10px; font-size: 13px; color: var(--mute); }
.foot-row { display: flex; align-items: center; gap: 12px; }
.foot-row .src { flex: 1 1 auto; min-width: 0; }
.foot-links { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 16px; margin-top: 2px; }
.foot-links a { font-weight: 600; font-size: 14px; padding: 4px 0; }
.drop { flex: 0 0 auto; border: 1px dashed var(--rule); background: transparent; color: var(--mute); border-radius: 999px;
        padding: 4px 12px; font-size: 13px; min-height: 32px; }
.drop:hover { color: var(--ink); border-color: var(--faint); }
.drop[aria-pressed="true"] { border-style: solid; background: var(--press); color: var(--press-ink); border-color: var(--press); }

/* answered: one quiet line */
.item.done { padding: 12px 14px 12px 17px; box-shadow: inset 3px 0 0 var(--ok), var(--shadow); background: var(--card); }
.done-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; }
.tick { width: 26px; height: 26px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; font-size: 14px; font-weight: 700; }
.done-row .dt { font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--ink-2); }
.done-row .dc { font-size: 13.5px; color: var(--mute); }
.done-row .dc b { color: var(--ok); font-weight: 600; }
.textbtn { border: 0; background: none; color: var(--link); font-size: 14px; font-weight: 600; padding: 8px 4px; min-height: 40px; }

/* can wait: one card, compact rows */
.waitlist { background: var(--card); border: 1px solid var(--rule); border-radius: 16px; padding: 0 16px; box-shadow: var(--shadow); }
.witem { padding: 13px 0 12px; border-top: 1px solid var(--line); }
.witem:first-child { border-top: 0; }
.witem .v { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--mute); }
.witem h3 { font-size: 15.5px; line-height: 1.3; font-weight: 650; margin: 2px 0 3px; }
.witem p { margin: 0; font-size: 14px; color: var(--mute); line-height: 1.45; }
.witem .wsrc { margin-top: 4px; font-size: 12.5px; }
.witem .wsrc a { font-weight: 600; margin-left: 8px; }

.calm { color: var(--mute); margin: 26px 0; text-align: center; }
.sincebox { margin: 26px 0 0; padding: 14px 16px; border-radius: 14px; background: var(--ok-bg); font-size: 14px; color: var(--ink-2); }
.sincebox b { display: block; color: var(--ok); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }

.flash { animation: flash 1.8s ease-out; }
@keyframes flash { 0%, 35% { background-color: var(--flash); } 100% { background-color: var(--card); } }

/* ---------- decisions ---------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--press); color: var(--press-ink);
          border: 0; border-radius: 12px; padding: 11px 20px; font-size: 15.5px; font-weight: 600; min-height: 46px; text-decoration: none; }
.button:hover { text-decoration: none; opacity: .92; }
.button.wide { width: 100%; }
.button.soft { background: var(--card); color: var(--ink); border: 1.5px solid var(--rule); }
.button:disabled { opacity: .5; cursor: default; }
#recOpen { margin: 0 0 12px; background: var(--card); color: var(--ink); border: 1.5px solid var(--rule); }
#recOpen::before { content: "+"; font-size: 20px; line-height: 1; font-weight: 400; margin-right: 2px; }
.search-row { display: flex; gap: 8px; margin: 0 0 10px; }
.search { flex: 1; min-width: 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); padding: 9px 12px; font-size: 16px; min-height: 44px; }
.seg { display: inline-flex; flex: 0 0 auto; padding: 3px; border-radius: 12px; background: var(--chip); }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 6px 13px; font-size: 14px; font-weight: 600; color: var(--mute); min-height: 38px; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

.month { margin: 22px 0 8px; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.dec { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; margin: 0 0 8px; box-shadow: var(--shadow); }
.dec > summary { list-style: none; cursor: pointer; padding: 13px 16px 12px; border-radius: 14px; }
.dec > summary::-webkit-details-marker { display: none; }
.dec .dmeta { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--mute); margin-bottom: 4px; }
.dec .dmeta .pill { margin-left: auto; }
.dec .dmeta .chev { width: 16px; height: 16px; color: var(--faint); transition: transform .15s ease; flex: 0 0 auto; }
.dec[open] .dmeta .chev { transform: rotate(180deg); }
.dec .dtitle { display: block; font-size: 16px; font-weight: 650; line-height: 1.3; }
.dec .ddecided { display: block; margin-top: 3px; font-size: 15px; color: var(--ink-2); line-height: 1.4; }
.dec .ddecided::before { content: "→ "; color: var(--faint); }
.dec .intoday { display: inline-block; margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--link); }
.dbody { padding: 0 16px 14px; }
.dbody dl { margin: 0; padding-top: 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 96px 1fr; gap: 8px 10px; font-size: 14.5px; }
.dbody dt { color: var(--mute); }
.dbody dd { margin: 0; }
.dacts { display: flex; gap: 8px; margin-top: 12px; }
.small { border: 1.5px solid var(--rule); background: var(--card); border-radius: 10px; padding: 6px 14px; font-size: 14px; font-weight: 600; min-height: 38px; }

/* ---------- settings ---------- */
.group { margin: 0 0 22px; }
.group > h2 { margin: 0 0 8px 4px; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.list { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; box-shadow: var(--shadow); }
.srow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--line); min-height: 52px; }
.srow:first-child { border-top: 0; }
.srow .k { font-size: 15.5px; min-width: 0; overflow-wrap: anywhere; }
.srow .k small { display: block; color: var(--mute); font-size: 13px; }
.srow .val { color: var(--mute); font-size: 14.5px; text-align: right; flex: 0 0 auto; }
.srow .val.ok { color: var(--ok); font-weight: 600; }
.srow .val.bad { color: var(--imm); font-weight: 600; }
.srow a.act, .srow button.act { border: 0; background: none; padding: 0; color: var(--link); font-size: 15.5px; font-weight: 600; }
.prose { padding: 14px 16px; font-size: 14.5px; color: var(--ink-2); }
.prose p { margin: 0 0 10px; }
.prose p:last-child { margin: 0; }

/* ---------- Spark ---------- */
.ask { display: none; align-items: center; gap: 5px; border: 0; background: none; padding: 6px 0; min-height: 34px; color: var(--spark); font-size: 14px; font-weight: 600; }
body.has-spark .ask { display: inline-flex; }
.ask svg, .who svg, .starter svg { width: 15px; height: 15px; fill: currentColor; flex: 0 0 auto; }
.witem .wsrc .ask { margin-left: 8px; padding: 0; min-height: 0; font-size: 12.5px; vertical-align: baseline; }
.sstate { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 13.5px; color: var(--mute); }
.sstate::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.sstate.waking::before { background: var(--urg); }
.sstate.down::before { background: var(--imm); }
.starters { display: flex; flex-direction: column; gap: 8px; margin: 0 0 6px; }
.starters:empty { display: none; }
.starter { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid var(--rule); background: var(--card);
           border-radius: 14px; padding: 11px 14px; min-height: 48px; font-size: 15px; line-height: 1.3; box-shadow: var(--shadow); }
.starter svg { color: var(--spark); }
.starter:hover { border-color: var(--faint); }
.chats .crow { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; padding: 12px 16px; min-height: 56px; }
.chats .crow:first-child { border-top: 0; }
.crow .ct { flex: 1 1 auto; min-width: 0; }
.crow .cti { display: block; font-size: 15.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow .cf { display: block; font-size: 13px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.crow .cw { flex: 0 0 auto; font-size: 13px; color: var(--mute); font-variant-numeric: tabular-nums; }
.sparknote { margin: 18px 4px 0; font-size: 13px; color: var(--mute); line-height: 1.5; }

.chatbar { position: sticky; top: 0; z-index: 4; display: grid; grid-template-columns: minmax(84px, auto) minmax(0, 1fr) minmax(84px, auto); align-items: center; gap: 4px;
           margin: calc(-1 * (var(--safe-t) + 22px)) -16px 12px; padding: calc(var(--safe-t) + 6px) 6px 6px;
           background: var(--paper); background: color-mix(in srgb, var(--paper) 88%, transparent);
           -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--rule); }
.back { display: inline-flex; align-items: center; gap: 2px; border: 0; background: none; color: var(--link); font-size: 15.5px; font-weight: 600; padding: 8px 6px; min-height: 44px; justify-self: start; }
.back svg, .iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { justify-self: end; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--mute); border-radius: 12px; }
.iconbtn:hover { color: var(--imm); }
.focus { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: 11px 14px 11px 17px; margin: 0 0 16px;
         box-shadow: inset 3px 0 0 var(--tier, var(--spark)), var(--shadow); }
.focus .fl { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.focus .ft { font-size: 15.5px; font-weight: 650; line-height: 1.3; margin: 2px 0 0; }
.focus a { display: inline-block; margin-top: 4px; font-size: 13.5px; font-weight: 600; }
#focusStarters { margin-top: 4px; }

.thread { display: flex; flex-direction: column; gap: 16px; }
.thread:empty { display: none; }
.msg.me { align-self: flex-end; max-width: 86%; background: var(--press); color: var(--press-ink); border-radius: 18px 18px 5px 18px;
          padding: 10px 14px; font-size: 15.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.spark { align-self: stretch; min-width: 0; }
.who { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--spark); }
.thinking { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 15px; color: var(--mute); }
.thinking .spin, .steps .spin { width: 14px; height: 14px; border-top-color: var(--spark); }
.steps { list-style: none; margin: 0 0 10px; padding: 0; font-size: 13.5px; color: var(--mute); }
.steps li { display: flex; align-items: center; gap: 8px; padding: 2px 0; line-height: 1.35; }
.steps li::before { content: "✓"; flex: 0 0 14px; text-align: center; color: var(--ok); font-weight: 700; }
.steps li.now { color: var(--ink-2); }
.steps li.now::before { content: none; }
details.used { margin: 0 0 8px; font-size: 13px; color: var(--mute); }
details.used > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; }
details.used > summary::-webkit-details-marker { display: none; }
details.used > summary::after { content: "›"; font-size: 15px; line-height: 1; transition: transform .15s ease; }
details.used[open] > summary::after { transform: rotate(90deg); }
details.used .steps { margin: 2px 0 6px; }
.md { font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; }
.md p { margin: 0 0 10px; white-space: pre-wrap; }
.md .h { font-weight: 700; margin: 14px 0 6px; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 0 0 4px; }
.md code { font: 14px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--chip); padding: 1px 5px; border-radius: 5px; }
.md .tablewrap { overflow-x: auto; margin: 0 0 12px; -webkit-overflow-scrolling: touch; }
.md table { border-collapse: collapse; font-size: 14px; line-height: 1.4; }
.md th, .md td { border: 1px solid var(--rule); padding: 6px 9px; text-align: left; vertical-align: top; }
.md th { background: var(--chip); font-weight: 650; }
.md > :last-child { margin-bottom: 0; }
.draft { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; margin: 2px 0 12px; overflow: hidden; box-shadow: var(--shadow); }
.draft-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 14px; border-bottom: 1px solid var(--line);
              font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.draft pre { margin: 0; padding: 12px 14px 14px; font: inherit; font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.copy { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--rule); background: var(--card); color: var(--ink); border-radius: 10px; letter-spacing: 0; text-transform: none;
        padding: 5px 12px; min-height: 36px; font-size: 13.5px; font-weight: 600; }
.copy:hover { border-color: var(--faint); }
.copy.done { color: var(--ok); }
.msg-acts { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.msg-acts .note { font-size: 13px; color: var(--mute); }
.msg-err { margin: 6px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--imm-bg); color: var(--imm); font-size: 14.5px; }

#view-spark { padding-bottom: 64px; }
.composer { position: fixed; z-index: 5; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); display: flex; align-items: flex-end; gap: 8px;
            padding: 8px max(12px, calc(50% - 308px)); border-top: 1px solid var(--rule);
            background: var(--paper); background: color-mix(in srgb, var(--paper) 90%, transparent);
            -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px); }
.composer textarea { flex: 1 1 auto; min-width: 0; resize: none; min-height: 44px; max-height: 160px; border: 1px solid var(--rule); border-radius: 22px;
                     background: var(--card); padding: 10px 16px; font-size: 16px; line-height: 1.4; }
.composer textarea:focus-visible { outline: 2px solid var(--spark); outline-offset: 0; }
.send { flex: 0 0 auto; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--spark); color: var(--spark-ink); display: grid; place-items: center; }
.send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.send .i-stop { display: none; fill: currentColor; stroke: none; }
.send.stop { background: var(--press); color: var(--press-ink); }
.send.stop .i-stop { display: block; }
.send.stop .i-send { display: none; }
body.kb .tabs { display: none; }
body.kb .composer { bottom: var(--kb, 0px); }
.sheet .primary.danger { background: var(--imm); border-color: var(--imm); color: #fff; }
.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

/* ---------- tab bar ---------- */
.tabs { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 132px);
        justify-content: center; padding: 4px 8px calc(var(--safe-b) + 4px); border-top: 1px solid var(--rule);
        background: var(--paper); background: color-mix(in srgb, var(--paper) 86%, transparent);
        -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px); }
.tabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none;
               padding: 6px 4px 4px; min-height: 52px; color: var(--faint); font-size: 11px; font-weight: 600; letter-spacing: .01em; }
.tabs button[aria-current="page"] { color: var(--ink); }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.badge { position: absolute; top: 3px; left: calc(50% + 7px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
         background: var(--imm); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; text-align: center; }

/* ---------- toast ---------- */
.toast { position: fixed; z-index: 8; left: 50%; bottom: calc(var(--safe-b) + 74px); transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
         display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px);
         background: var(--press); color: var(--press-ink); border-radius: 12px; padding: 10px 14px; font-size: 14.5px;
         box-shadow: 0 6px 24px rgba(0, 0, 0, .18); transition: opacity .18s ease, transform .18s ease; }
.toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 4px 2px; }

/* ---------- sheets ---------- */
.modal { position: fixed; inset: 0; z-index: 9; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 480px; border-radius: 20px 20px 0 0; padding: 22px 18px calc(18px + var(--safe-b));
         max-height: 92vh; overflow-y: auto; }
@media (min-width: 600px) { .modal { align-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { font-size: 23px; font-weight: 600; margin: 0 0 6px; }
.sheet-note { font-size: 14.5px; color: var(--mute); margin: 0 0 14px; }
.sheet label { display: block; font-size: 13px; font-weight: 600; color: var(--mute); margin: 12px 0 5px; }
.sheet input, .sheet select { width: 100%; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper);
                              font-size: 16px; padding: 11px 12px; min-height: 46px; }
.sheet .row { display: flex; gap: 8px; margin-top: 18px; }
.sheet .row button { flex: 1; border-radius: 12px; padding: 10px 14px; min-height: 48px; font-size: 15.5px; font-weight: 600; }
.sheet .primary { background: var(--press); color: var(--press-ink); border: 1.5px solid var(--press); }
.sheet .ghost { background: transparent; border: 1.5px solid var(--rule); }
.sheet .ghost:disabled { opacity: .6; }
.sheet .skip { display: block; margin: 12px auto 0; background: none; border: 0; color: var(--mute); font-size: 15px; padding: 8px 12px; min-height: 40px; }
.wa-qr { display: block; width: 264px; max-width: 100%; margin: 4px auto 12px; padding: 10px; background: #fff; border-radius: 8px; }  /* white: phones can't read a QR code on a dark background */

/* ---------- gates: signed out, connect, first build ---------- */
.gate { max-width: 420px; margin: 0 auto; padding: calc(var(--safe-t) + 18vh) 24px 40px; text-align: center; }
.gate .mark { width: 64px; height: 64px; border-radius: 15px; margin: 0 auto 22px; display: block; }
.gate h1 { font-size: 30px; margin-bottom: 10px; }
.gate p { color: var(--mute); margin: 0 auto 24px; max-width: 330px; }
.gate .gate-wait { margin-top: 10vh; }
.gate .spin { margin: 0 auto 16px; width: 22px; height: 22px; }

/* ---------- phones: sign-in code and home-screen steps ---------- */
.sheet-note.center { text-align: center; }
.qr { width: 248px; max-width: 100%; margin: 4px auto 10px; border-radius: 12px; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px var(--rule); }  /* white: phones can't read a QR code on a dark background */
.qr svg { display: block; width: 100%; height: auto; }
.qr-left { margin: 0 0 10px; text-align: center; font-size: 14.5px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.qr-warn { margin: 0; text-align: center; font-size: 13px; color: var(--mute); }
.qr-code { margin: 0 0 6px; text-align: center; font-size: 14.5px; color: var(--ink-2); }
.qr-code strong { font: 700 17px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; color: var(--ink); white-space: nowrap; }
.gate .or { display: flex; align-items: center; gap: 12px; margin: 22px 0 16px; color: var(--faint); font-size: 13px; }
.gate .or::before, .gate .or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
.codeform { text-align: left; }
.codeform label { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 0 0 8px; }
.code-row { display: flex; gap: 8px; }
.code-in { flex: 1 1 auto; min-width: 0; min-height: 48px; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); padding: 10px 14px;
           font: 600 18px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; }
.code-in::placeholder { color: var(--faint); font-weight: 400; }
.code-row .button { flex: 0 0 auto; min-height: 48px; }
.gate .code-msg { margin: 8px 0 0; min-height: 0; color: var(--imm); font-size: 14px; text-align: left; max-width: none; }
.gate .code-msg:empty { display: none; }
.gate .code-hint { margin: 10px 0 0; font-size: 13px; text-align: left; max-width: none; }
.qr-ok { text-align: center; padding: 10px 0 2px; }
.qr-ok .tick { width: 56px; height: 56px; margin: 0 auto 10px; font-size: 26px; }
.qr-ok p { margin: 0 0 6px; font-size: 17px; font-weight: 650; }
.how { border: 1px solid var(--rule); border-radius: 12px; padding: 12px 14px 10px; margin: 12px 0 0; }
.how.mine { border-color: var(--spark); box-shadow: inset 3px 0 0 var(--spark); }
.how h3 { margin: 0 0 6px; font-size: 15px; font-weight: 650; }
.how ol { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.45; }
.how li { margin: 0 0 4px; }

/* ---------- wide screens: a top bar, and Spark docked beside the brief ---------- */
.brand { display: none; }
@keyframes pulse { 0% { box-shadow: inset 0 0 0 2px var(--spark); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
@media (min-width: 1080px) {
  :root { --top-h: 60px; --panel-w: clamp(400px, 33vw, 500px); }
  html { scroll-padding-top: calc(var(--top-h) + 16px); }
  .tabs { top: 0; bottom: auto; height: var(--top-h); padding: 0 20px; border-top: 0; border-bottom: 1px solid var(--rule);
          grid-auto-columns: auto; justify-content: start; align-items: center; gap: 4px; }
  .brand { display: flex; align-items: center; gap: 10px; margin-right: 22px; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
  .brand img { width: 30px; height: 30px; border-radius: 8px; }
  .tabs button { flex-direction: row; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 10px; font-size: 14.5px; color: var(--mute); }
  .tabs button:hover { background: var(--chip); color: var(--ink); }
  .tabs button[aria-current="page"] { background: var(--chip); color: var(--ink); }
  .tabs svg { width: 20px; height: 20px; }
  .badge { position: static; margin-left: 2px; }
  #tabSpark { display: none !important; }
  main { padding-top: calc(var(--top-h) + 30px); padding-bottom: 72px; }
  .gate { padding-top: 18vh; }
  .toast { bottom: 28px; }
  h1 { font-size: 38px; }

  body.docked main#app { max-width: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); }
  body.docked main#app > section:not(#view-spark) { grid-column: 1; grid-row: 1; width: 100%; max-width: 760px; justify-self: center;
                                                    padding: calc(var(--top-h) + 30px) 36px 72px; }
  body.docked #view-spark { grid-column: 2; grid-row: 1; align-self: start; position: sticky; top: var(--top-h); margin-top: var(--top-h);
                            height: calc(100vh - var(--top-h)); height: calc(100dvh - var(--top-h)); display: flex; flex-direction: column;
                            padding: 0; background: var(--panel); border-left: 1px solid var(--rule); }
  body.docked #view-spark.pulse { animation: pulse 1.4s ease-out; }
  body.docked #sparkHome, body.docked #sparkChat { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 22px 20px; }
  body.docked #sparkHome { padding-top: 26px; }
  body.docked #sparkHome .masthead h1 { font-size: 28px; }
  body.docked .chatbar { margin: 0 -22px 16px; padding: 8px 8px; }
  body.docked .composer { position: static; flex: 0 0 auto; padding: 12px 16px 16px; background: var(--panel); -webkit-backdrop-filter: none; backdrop-filter: none; }
  body.docked .msg.me { max-width: 88%; }
  body.docked .starter { min-height: 44px; padding: 9px 13px; font-size: 14.5px; }
}

@media (max-width: 360px) {
  h1 { font-size: 30px; }
  .jump { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item h3 { font-size: 17px; }
}
@media print {
  .tabs, .composer, #view-spark, .ask, .filters, .search-row, #recOpen, .choices, .drop, .toast, .modal, #view-more, .summary .jump { display: none !important; }
  main { padding: 0; max-width: none; }
  section#view-log[hidden], section#view-today[hidden] { display: block !important; }
  #view-log { break-before: page; }
  body { font-size: 11pt; background: #fff; }
  .item, .dec, .day, .waitlist, .summary { box-shadow: none; break-inside: avoid; }
}
