/* Direction A: Stream */

:root {
  --paper: #F2F4FA;
  --rail: #E8EBF5;
  --sheet: #FFFFFF;
  --sunk: #E9ECF5;
  --line: #D9DDEA;
  --ink: #161A35;
  --ink-2: #545B7A;
  --ink-3: #8D93AB;
  --you: #5530F0;
  --you-hover: #4522E0;
  --you-ink: #FFFFFF;
  --you-soft: #ECE7FF;
  --you-soft-ink: #3B1CC0;
  --airi: #C81E64;
  --airi-soft: #FCE7EF;
  --mark: #FFE36E;
  --mark-ink: #161A35;
  --add-bg: #E2F5E8;
  --add-ink: #0F5A2B;
  --code-bg: #EEF0F8;
  --t-var: #7A2FC2;
  --t-fn: #1F48C4;
  --t-str: #A02A5E;
  --t-op: #5A6180;
  --t-id: #116240;
  --scrim: rgba(22, 26, 53, .32);
  --shadow-lift: 0 18px 48px -18px rgba(30, 24, 90, .28), 0 2px 6px rgba(30, 24, 90, .06);
  --ring: 0 0 0 3px color-mix(in srgb, var(--you) 35%, transparent);

  --ui: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --read: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --mock-h: calc(44px + env(safe-area-inset-top));
  --safe-b: env(safe-area-inset-bottom);
  --gutter: 16px;
  --ease-pop: cubic-bezier(.34, 1.5, .64, 1);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #0E1222;
  --rail: #0B0F1D;
  --sheet: #171C30;
  --sunk: #20263F;
  --line: #2B3252;
  --ink: #E9ECF7;
  --ink-2: #A6ADC8;
  --ink-3: #6C7493;
  --you: #6347FA;
  --you-hover: #7258FF;
  --you-ink: #FFFFFF;
  --you-soft: #282352;
  --you-soft-ink: #C9BEFF;
  --airi: #FF7AAB;
  --airi-soft: #3A1A2C;
  --mark: rgba(255, 214, 80, .32);
  --mark-ink: #FFF3C4;
  --add-bg: #12301F;
  --add-ink: #8FE3AE;
  --code-bg: #10142A;
  --t-var: #D3A6FF;
  --t-fn: #8FB0FF;
  --t-str: #FF9CC6;
  --t-op: #A6ADC8;
  --t-id: #7FE0B0;
  --scrim: rgba(4, 6, 16, .6);
  --shadow-lift: 0 24px 60px -20px rgba(0, 0, 0, .7), 0 2px 8px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

:root.shot { --mock-h: env(safe-area-inset-top); }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.45;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; flex: none; }
ol, ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }

:focus-visible { outline: 2px solid var(--you); outline-offset: 2px; border-radius: 8px; }
textarea:focus-visible, input:focus-visible { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

kbd {
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink-2);
  background: var(--sheet);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 3px 6px;
  white-space: nowrap;
}

code { font-family: var(--mono); }
.hash { font-family: var(--mono); font-size: .88em; color: var(--ink-2); letter-spacing: -.01em; }

/* ---------- Mock switcher ---------- */
.mockbar {
  position: fixed; inset: 0 0 auto 0; z-index: 90;
  height: var(--mock-h);
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 2px;
  background: var(--rail);
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
  overflow-x: auto;
  scrollbar-width: none;
}
.mockbar::-webkit-scrollbar { display: none; }
.mockbar-label { color: var(--ink-2); padding: 0 8px 0 4px; white-space: nowrap; display: none; }
.mockbar a {
  flex: 1 0 auto;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 36px; padding: 0 8px; border-radius: 10px;
  color: var(--ink-2); white-space: nowrap; font-weight: 500;
}
.mockbar a b { font-weight: 700; color: var(--ink-3); }
.mockbar a[aria-current="true"] { background: var(--sheet); color: var(--ink); }
.mockbar a[aria-current="true"] b { color: var(--you); }
.shot .mockbar { display: none; }

/* ---------- App frame (phone first) ---------- */
.app { padding-top: var(--mock-h); }

.rail, .side { display: none; }

.stream-col, .agent-col {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 max(var(--gutter), env(safe-area-inset-right)) calc(40px + var(--safe-b)) max(var(--gutter), env(safe-area-inset-left));
}
.agent-col { display: none; }

body[data-view="agent"] .stream-col { display: none; }
body[data-view="agent"] .agent-col { display: block; }

.mobile-only { }

/* ---------- Header ---------- */
.top {
  display: flex; align-items: flex-end; gap: 12px;
  padding: 18px 0 14px;
}
.top-title { flex: 1; min-width: 0; }
.now-word {
  font-size: 48px;
  line-height: .95;
  font-weight: 700;
  font-variation-settings: "wdth" 84, "opsz" 96;
  letter-spacing: -.03em;
}
.page-h {
  font-size: 36px; line-height: 1; font-weight: 700;
  font-variation-settings: "wdth" 84, "opsz" 72;
  letter-spacing: -.015em;
}
.top-date { color: var(--ink-2); font-size: 15px; margin-top: 6px; }
.top-actions { display: flex; gap: 4px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 44px; height: 44px; border-radius: 14px;
  color: var(--ink);
}
.icon-btn:hover { background: var(--sunk); }
.search-btn-text, .search-btn kbd { display: none; }

.ic-sun { display: none; }
:root[data-theme="dark"] .ic-sun { display: block; }
:root[data-theme="dark"] .ic-moon { display: none; }

/* ---------- Composer: the bold thing ---------- */
.composer { position: relative; z-index: 2; margin-bottom: 20px; }
.composer-box {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--sheet);
  border-radius: 26px;
  padding: 8px 8px 8px 20px;
  box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow .2s var(--ease-out);
}
.composer-box:focus-within { box-shadow: 0 0 0 2px var(--you), 0 10px 30px -12px color-mix(in srgb, var(--you) 45%, transparent); }
.composer-input {
  flex: 1; min-width: 0;
  border: 0; background: none; resize: none;
  font-family: var(--read);
  font-size: 18px; line-height: 1.4;
  padding: 12px 0;
  min-height: 52px; max-height: 40vh;
  color: var(--ink);
}
.composer-input::placeholder { color: var(--ink-2); }
.composer-send {
  display: inline-flex; align-items: center; gap: 6px;
  height: 52px; padding: 0 20px 0 16px;
  border-radius: 999px;
  background: var(--you); color: var(--you-ink);
  font-weight: 650; font-size: 16px;
  transition: transform .15s var(--ease-out), background .15s;
}
.composer-send:hover { background: var(--you-hover); }
.composer-send:active { transform: scale(.95); }
.composer-send svg { width: 18px; height: 18px; }
.composer-hint { color: var(--ink-2); font-size: 14px; padding: 10px 4px 0 20px; }
.hint-idle, .hint-active { display: none; }
.composer-hint kbd { font-size: 11px; padding: 2px 5px; }

/* ---------- Continue card and pins ---------- */
.continue, .peek {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--sheet);
  border-radius: 24px;
  padding: 16px 18px 14px;
  margin-bottom: 22px;
}
@media (hover: hover) { .continue:hover, .peek:hover { box-shadow: 0 0 0 1px var(--line); } }
.continue-label { color: var(--ink-2); font-size: 14px; font-weight: 500; }
.continue-title, .peek-title {
  font-size: 22px; line-height: 1.15; font-weight: 680;
  font-variation-settings: "wdth" 88;
  letter-spacing: -.01em;
  margin-top: 2px;
}
.continue-meta { color: var(--ink-2); font-size: 14px; }
.next-step {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 10px;
  background: var(--you-soft); color: var(--you-soft-ink);
  border-radius: 14px; padding: 10px 14px;
  font-family: var(--read); font-size: 16px; line-height: 1.35;
}
.ns-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; margin-top: 5px; flex: none; }
.ns-label { font-family: var(--ui); font-weight: 700; margin-right: 6px; }

.section-h {
  display: flex; align-items: center; gap: 8px;
  font-size: 17px; font-weight: 680;
}
.section-h svg { width: 18px; height: 18px; color: var(--ink-2); }

.pins { margin-bottom: 24px; }
.pins-row {
  display: flex; gap: 10px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 10px calc(-1 * var(--gutter)) 0; padding: 0 var(--gutter) 4px;
  scrollbar-width: none;
}
.pins-row::-webkit-scrollbar { display: none; }
.pins-row li { flex: 0 0 auto; scroll-snap-align: start; scroll-margin-left: var(--gutter); }
.pin {
  display: flex; align-items: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--sheet);
  white-space: nowrap;
}
.pin-title { font-weight: 600; font-size: 15.5px; }
.pin-sub { display: none; }

/* ---------- Stream ---------- */
.stream-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.count-pill {
  background: var(--you-soft); color: var(--you-soft-ink);
  font-weight: 650; font-size: 14px;
  padding: 3px 10px; border-radius: 999px;
}
.text-link {
  margin-left: auto;
  color: var(--you); font-weight: 650;
  min-height: 44px; display: inline-flex; align-items: center; padding: 0 4px;
}
:root[data-theme="dark"] .text-link { color: var(--you-soft-ink); }
.text-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.feed { display: flex; flex-direction: column; gap: 10px; }

.cap {
  display: flex; justify-content: flex-end; align-items: flex-end; gap: 10px;
}
.cap time { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; padding-bottom: 6px; order: -1; white-space: nowrap; }
.cap .bubble, .quote {
  max-width: 82%;
  background: var(--you); color: var(--you-ink);
  border-radius: 20px 6px 20px 20px;
  padding: 11px 16px 12px;
  font-family: var(--read);
  font-size: 17px; line-height: 1.38;
  overflow-wrap: anywhere;
}
.bubble-link {
  display: inline;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.bubble-link svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }

.cap.is-new { animation: drop .55s var(--ease-pop) both; transform-origin: top right; }
.cap.is-new time { animation: fade-in .4s .25s both; }
.landed { display: inline-flex; align-items: center; gap: 3px; }
.landed svg { width: 14px; height: 14px; color: var(--you); }
:root[data-theme="dark"] .landed svg { color: var(--you-soft-ink); }

@keyframes drop {
  0% { opacity: 0; transform: translateY(-34px) scale(.9); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.airi { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; }
.avatar {
  flex: none;
  width: 34px; height: 34px; border-radius: 12px 12px 12px 4px;
  background: var(--airi); color: #fff;
  display: grid; place-items: center;
  font-weight: 760; font-size: 16px;
  font-variation-settings: "wdth" 80;
}
:root[data-theme="dark"] .avatar { color: #2A0A18; }
.airi-body { min-width: 0; max-width: 86%; }
.airi-name { font-weight: 680; color: var(--airi); font-size: 14px; margin-bottom: 4px; }
.airi-name span { color: var(--ink-2); font-weight: 500; margin-left: 4px; }
.airi .bubble, .airi-reply {
  background: var(--sheet);
  border-radius: 6px 20px 20px 20px;
  padding: 12px 16px 13px;
  font-family: var(--read);
  font-size: 16px; line-height: 1.45;
}
.airi-actions, .quick-replies { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border-radius: 999px;
  background: var(--sheet);
  box-shadow: inset 0 0 0 1.5px var(--line);
  font-family: var(--ui); font-weight: 600; font-size: 15px;
}
.chip:hover { box-shadow: inset 0 0 0 1.5px var(--you); }
.airi-reply .chip { background: var(--paper); }

.typing { display: inline-flex; gap: 4px; padding: 16px 18px !important; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
.airi.is-new { animation: fade-up .35s var(--ease-out) both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Agent thread ---------- */
.agent-top { align-items: center; }
.back-btn { margin-left: -10px; }
.sort-tally {
  display: flex; flex-direction: column; gap: 10px;
  margin: 2px 0 22px;
  font-size: 15px; color: var(--ink-2);
}
.tally-text b { color: var(--ink); font-weight: 650; }
.tally-bar { display: flex; gap: 4px; }
.tally-bar i { flex: 1; height: 8px; border-radius: 4px; background: var(--ink); }
.tally-bar i.left { background: none; box-shadow: inset 0 0 0 1.5px var(--ink-3); }

.thread { display: flex; flex-direction: column; gap: 22px; }
.thread > .airi { margin-top: 0; }
.pair { display: flex; flex-direction: column; gap: 8px; }
.pair .quote {
  align-self: flex-end;
  background: var(--you-soft); color: var(--you-soft-ink);
  font-size: 15px; padding: 9px 14px 10px;
}
.airi-reply { position: relative; margin-left: 44px; max-width: calc(100% - 44px); }
.airi-reply::before {
  content: "A";
  position: absolute; left: -44px; top: 0;
  width: 34px; height: 34px; border-radius: 12px 12px 12px 4px;
  background: var(--airi-soft); color: var(--airi);
  display: grid; place-items: center;
  font-family: var(--ui); font-weight: 760; font-size: 15px;
}
.airi-reply.ask::before { background: var(--airi); color: #fff; }
:root[data-theme="dark"] .airi-reply.ask::before { color: #2A0A18; }

.note-pill {
  display: inline;
  padding: 1px 7px 2px 5px;
  border-radius: 8px;
  background: var(--sunk);
  font-family: var(--ui); font-weight: 650; font-size: 15px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.note-pill svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 3px; color: var(--ink-2); }
.note-pill:hover { box-shadow: inset 0 0 0 1px var(--ink-3); }

.summary {
  margin: 10px 0 0; padding: 10px 14px;
  border-left: 3px solid var(--airi-soft);
  color: var(--ink-2); font-size: 15px;
}
:root[data-theme="dark"] .summary { border-left-color: color-mix(in srgb, var(--airi) 50%, transparent); }

/* Diff */
.diff {
  margin-top: 12px;
  border-radius: 16px;
  background: var(--paper);
  overflow: hidden;
}
.diff-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 6px; }
.diff-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.diff-file { font-family: var(--mono); font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.diff-msg { font-family: var(--ui); font-size: 14px; font-weight: 600; line-height: 1.3; }
.undo-btn {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 44px; padding: 0 16px 0 12px;
  border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-family: var(--ui); font-weight: 650; font-size: 15px;
  transition: transform .15s var(--ease-out);
}
.undo-btn:active { transform: scale(.95); }
.undo-btn svg { width: 18px; height: 18px; }
.diff.is-undone .undo-btn { background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.diff.is-undone .undo-btn svg { transform: scaleX(-1); }

.diff-body {
  margin: 0; padding: 4px 0 8px;
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
  white-space: normal; overflow-wrap: anywhere;
}
.dl { display: block; white-space: pre-wrap; min-height: 1.6em; padding: 0 14px 0 8px; transition: background .25s, color .25s, opacity .25s; }
.dl i { display: inline-block; width: 1.6ch; font-style: normal; color: var(--ink-3); user-select: none; }
.dl.add { background: var(--add-bg); color: var(--add-ink); }
.dl.add i { color: var(--add-ink); }
.diff.is-undone .dl.add { background: transparent; color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.diff.is-undone .dl.add i { color: var(--ink-3); }
.diff-foot { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; border-top: 1px solid var(--line); }
.diff-state { flex: 1; min-width: 0; font-size: 14px; line-height: 1.35; color: var(--ink-2); }
.after-sort { display: none; }
body[data-view="agent"] .rail-count .js-inbox-count { display: none; }
body[data-view="agent"] .rail-count .after-sort { display: inline; }
.state-undone { display: none; }
.diff.is-undone .state-live { display: none; }
.diff.is-undone .state-undone { display: inline; }

/* ---------- Editor ---------- */
.editor {
  position: fixed; z-index: 40;
  left: 0; right: 0; bottom: 0;
  top: calc(var(--mock-h) + 12px);
  background: var(--sheet);
  border-radius: 28px 28px 0 0;
  display: flex; flex-direction: column;
  transform: translateY(104%);
  visibility: hidden;
  transition: transform .42s var(--ease-out), visibility 0s .42s;
}
body[data-view="editor"] .editor { transform: none; visibility: visible; transition: transform .42s var(--ease-out); }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
.ed-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 2px max(8px, env(safe-area-inset-right)) 2px max(8px, env(safe-area-inset-left));
}
.ed-where { flex: 1; color: var(--ink-2); font-weight: 600; font-size: 15px; }
.ed-actions { display: flex; }
.ic-close-d { display: none; }
.ed-scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px max(20px, env(safe-area-inset-right)) calc(48px + var(--safe-b)) max(20px, env(safe-area-inset-left));
}
.ed-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.tag {
  font-size: 14px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  background: var(--sunk); color: var(--ink-2);
}
.tag::before { content: "#"; opacity: .6; margin-right: 1px; }
.ed-edited { color: var(--ink-2); font-size: 14px; margin-left: 4px; }

.ed-next {
  display: flex; align-items: center; gap: 12px;
  background: var(--you-soft); color: var(--you-soft-ink);
  border-radius: 16px; padding: 10px 14px;
  min-height: 52px;
  font-family: var(--read); font-size: 16px; line-height: 1.35;
  margin-bottom: 24px; cursor: pointer;
}
.ed-next input { border-color: var(--you) !important; }
.ed-next:has(input:checked) > span { text-decoration: line-through; opacity: .7; }

input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  flex: none;
  width: 22px; height: 22px; margin: 0;
  border-radius: 7px;
  border: 2px solid var(--ink-3);
  background: var(--sheet);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s var(--ease-pop);
}
input[type="checkbox"]:checked {
  background: var(--you) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
  border-color: var(--you);
}
input[type="checkbox"]:active { transform: scale(.88); }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--you); outline-offset: 2px; }

.md { font-family: var(--read); font-size: 17px; line-height: 1.6; max-width: 68ch; }
.md p { margin: 0 0 14px; }
.md strong { font-weight: 750; }
.md-h1, .md-h2 { font-family: var(--ui); position: relative; }
.md-h1 {
  font-size: 30px; line-height: 1.12; font-weight: 700;
  font-variation-settings: "wdth" 92, "opsz" 48;
  letter-spacing: -.015em;
  margin: 0 0 14px;
}
.md-h2 {
  font-size: 21px; line-height: 1.25; font-weight: 680;
  font-variation-settings: "wdth" 90;
  margin: 26px 0 8px;
}
.mk { color: var(--ink-3); font-weight: 450; margin-right: .3em; font-variation-settings: "wdth" 100; }
.md-h1 .mk { font-size: .7em; vertical-align: .12em; }
.md-h2 .mk { font-size: .8em; }
.md-h2.is-caret {
  margin-left: -10px; margin-right: -10px; padding: 2px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--you-soft) 70%, transparent);
}
.md-h2.is-caret .mk { color: var(--you); font-size: 1em; font-family: var(--mono); font-weight: 500; }
:root[data-theme="dark"] .md-h2.is-caret .mk { color: var(--you-soft-ink); }
.caret {
  display: inline-block; width: 2px; height: 1.1em; margin-left: 1px;
  background: var(--you); vertical-align: -.15em;
  animation: caret 1.05s steps(1) infinite;
}
:root[data-theme="dark"] .caret { background: var(--you-soft-ink); }
@keyframes caret { 50% { opacity: 0; } }

.md-tasks { margin: 0 0 12px; }
.md-tasks label { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 9px 0; cursor: pointer; }
.md-tasks input { margin-top: 2px; }
.md-tasks input:checked + span { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--ink-3); }

.md code, .ed-foot code {
  font-size: .86em;
  background: var(--sunk);
  border-radius: 6px;
  padding: .12em .4em;
}
.md-code {
  margin: 4px 0 16px;
  background: var(--code-bg);
  border-radius: 14px;
  padding: 10px 16px;
  font-family: var(--mono); font-size: 14px; line-height: 1.65;
}
.md-code .fence { display: block; color: var(--ink-3); }
@media (max-width: 1023px) {
  .md-code { margin-left: -20px; margin-right: -20px; border-radius: 0; padding: 10px 16px; font-size: 13px; }
}
.md-code pre { margin: 0; overflow-x: auto; }
.md-code pre code { background: none; padding: 0; font-size: inherit; border-radius: 0; }
.t-var { color: var(--t-var); }
.t-fn { color: var(--t-fn); }
.t-str { color: var(--t-str); }
.t-op { color: var(--t-op); }
.t-id { color: var(--t-id); }

.ed-foot { margin-top: 30px; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.ed-foot code { font-size: 13px; overflow-wrap: anywhere; }

/* ---------- Capture sheet (phone) ---------- */
.capture-sheet {
  position: fixed; z-index: 50;
  left: 0; right: 0; bottom: 0;
  top: calc(var(--mock-h) + 12px);
  background: var(--sheet);
  border-radius: 28px 28px 0 0;
  transform: translateY(104%);
  visibility: hidden;
  transition: transform .38s var(--ease-out), visibility 0s .38s;
}
body[data-view="capture"] .capture-sheet { transform: none; visibility: visible; transition: transform .38s var(--ease-out); }
.cap-form {
  height: 100%; overflow: hidden;
  display: flex; flex-direction: column;
  padding: 6px max(16px, env(safe-area-inset-right)) calc(16px + var(--safe-b)) max(16px, env(safe-area-inset-left));
}
.cap-head { display: flex; align-items: center; justify-content: space-between; }
.text-btn {
  min-height: 44px; padding: 0 10px; margin-left: -10px;
  display: inline-flex; align-items: center;
  font-weight: 600; color: var(--ink-2);
}
.text-btn:hover { color: var(--ink); }
.cap-dest {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--you-soft); color: var(--you-soft-ink);
  font-weight: 650; font-size: 14px;
  padding: 6px 12px 6px 10px; border-radius: 999px;
}
.cap-dest svg { width: 17px; height: 17px; }
.cap-input {
  display: block; width: 100%;
  border: 0; resize: none;
  margin-top: 14px;
  background: var(--you-soft);
  color: var(--ink);
  border-radius: 26px 8px 26px 26px;
  font-family: var(--read);
  font-size: 24px; line-height: 1.32;
  padding: 18px 20px;
  min-height: 150px;
  caret-color: var(--you);
  box-shadow: inset 0 0 0 2px var(--you);
}
.cap-input::placeholder { color: var(--ink-3); }
.cap-foot { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.cap-hint { color: var(--ink-2); font-size: 15px; padding: 0 4px; }
.capture-big {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 60px; border-radius: 20px;
  background: var(--you); color: var(--you-ink);
  font-size: 19px; font-weight: 700;
  transition: transform .15s var(--ease-out), background .15s;
}
.capture-big:hover { background: var(--you-hover); }
.capture-big:active { transform: scale(.97); }
.cap-below {
  flex: 1; min-height: 0; overflow: hidden;
  margin-top: 26px;
  -webkit-mask-image: linear-gradient(#000 40%, transparent);
  mask-image: linear-gradient(#000 40%, transparent);
}
.cap-below-h { color: var(--ink-2); font-size: 14px; font-weight: 600; margin: 0 0 10px; }
.feed-mini { gap: 8px; }
.feed-mini .cap .bubble { font-size: 15px; padding: 9px 14px 10px; background: var(--you-soft); color: var(--you-soft-ink); }

/* ---------- Search (phone: full screen) ---------- */
.search {
  position: fixed; z-index: 60;
  inset: var(--mock-h) 0 0 0;
  background: var(--paper);
  display: none;
}
body[data-view="search"] .search { display: block; animation: fade-in .18s both; }
.palette { height: 100%; display: flex; flex-direction: column; }
.search-bar {
  display: flex; align-items: center; gap: 10px;
  margin: 12px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  padding: 0 6px 0 16px;
  height: 56px; border-radius: 18px;
  background: var(--sheet);
  box-shadow: 0 0 0 2px var(--you);
}
.search-bar > svg { color: var(--ink-2); }
.search-bar input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; background: none;
  font-size: 18px; font-weight: 500;
  -webkit-appearance: none; appearance: none;
}
.search-bar input::-webkit-search-cancel-button { display: none; }
.search-cancel { margin-left: 0; color: var(--you); }
:root[data-theme="dark"] .search-cancel { color: var(--you-soft-ink); }
.search-esc { display: none; }

.results {
  flex: 1; overflow-y: auto;
  padding: 4px max(16px, env(safe-area-inset-right)) calc(24px + var(--safe-b)) max(16px, env(safe-area-inset-left));
}
.res-group { margin-top: 14px; }
.res-h { font-size: 14px; font-weight: 650; color: var(--ink-2); padding: 0 12px 6px; }
.res {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 12px;
  border-radius: 16px;
  cursor: pointer;
}
.res:hover { background: var(--sunk); }
.res[aria-selected="true"] { background: var(--sheet); box-shadow: inset 0 0 0 1.5px var(--you); }
.res-ic { width: 36px; height: 36px; border-radius: 11px; background: var(--sunk); display: grid; place-items: center; color: var(--ink-2); flex: none; }
.res-ic svg { width: 18px; height: 18px; }
.res[aria-selected="true"] .res-ic { background: var(--you); color: var(--you-ink); }
.res-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.res-title { font-weight: 650; font-size: 16.5px; line-height: 1.25; }
.res-meta { color: var(--ink-2); font-size: 14px; }
.res-snip { font-family: var(--read); color: var(--ink-2); font-size: 15px; line-height: 1.4; }
.res kbd { flex: none; }
.res-empty { color: var(--ink-2); padding: 20px 12px; font-family: var(--read); }
mark { background: var(--mark); color: var(--mark-ink); border-radius: 4px; padding: 0 2px; margin: 0 -1px; }
.palette-foot { display: none; }

/* ---------- Scrim and toast ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 30;
  background: var(--scrim);
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
body[data-view="editor"] .scrim,
body[data-view="capture"] .scrim { opacity: 1; pointer-events: auto; }

.toast {
  position: fixed; z-index: 100;
  left: 50%; bottom: calc(18px + var(--safe-b));
  transform: translate(-50%, 140%);
  width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 4px;
  padding: 6px 6px 6px 18px;
  border-radius: 18px;
  background: var(--ink); color: var(--paper);
  font-size: 15px; font-weight: 500;
  box-shadow: var(--shadow-lift);
  opacity: 0; visibility: hidden;
  transition: transform .35s var(--ease-pop), opacity .2s, visibility 0s .35s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; transition: transform .35s var(--ease-pop), opacity .2s; }
.toast-action {
  min-height: 44px; padding: 0 14px; border-radius: 12px;
  font-weight: 700; color: #C9BEFF;
  white-space: nowrap;
}
:root[data-theme="dark"] .toast-action { color: #4522E0; }
.toast-action:hover { background: color-mix(in srgb, var(--paper) 12%, transparent); }
.toast-action[hidden] { display: none; }

/* ---------- Desktop ---------- */
@media (min-width: 1024px) {
  .mockbar-label { display: inline; }
  .mockbar { justify-content: center; gap: 4px; }
  .mockbar a { flex: 0 0 auto; padding: 0 12px; }

  .app {
    height: 100dvh;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr) 420px;
  }
  .app > * { min-height: 0; overflow-y: auto; }
  .mobile-only { display: none !important; }

  .rail {
    display: flex; flex-direction: column;
    background: var(--rail);
    padding: 22px 14px 18px;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; font-size: 19px; font-weight: 740; font-variation-settings: "wdth" 85; margin-bottom: 22px; }
  .brand-mark { width: 22px; height: 22px; background: var(--you); border-radius: 8px 3px 8px 8px; }
  .rail-nav { display: flex; flex-direction: column; gap: 2px; }
  .rail-link {
    display: flex; align-items: center; gap: 10px;
    height: 40px; padding: 0 10px; border-radius: 12px;
    font-weight: 550; color: var(--ink-2);
  }
  .rail-link svg { width: 19px; height: 19px; }
  .rail-link:hover { background: color-mix(in srgb, var(--sheet) 60%, transparent); color: var(--ink); }
  .rail-link[aria-current="page"] { background: var(--sheet); color: var(--ink); font-weight: 650; }
  .rail-link kbd { margin-left: auto; background: transparent; }
  .rail-count { margin-left: auto; background: var(--you); color: var(--you-ink); font-size: 12px; font-weight: 700; min-width: 22px; height: 22px; border-radius: 999px; display: grid; place-items: center; padding: 0 6px; }
  .rail-h { font-size: 14px; font-weight: 650; color: var(--ink-2); padding: 0 10px; margin: 28px 0 6px; }
  .rail-pins { display: flex; flex-direction: column; gap: 2px; }
  .rail-pin { display: flex; flex-direction: column; gap: 1px; padding: 9px 10px; border-radius: 12px; }
  .rail-pin:hover { background: color-mix(in srgb, var(--sheet) 60%, transparent); }
  .rail-pin-title { font-weight: 600; font-size: 15px; line-height: 1.25; }
  .rail-pin-sub { font-family: var(--read); font-size: 13.5px; color: var(--ink-2); line-height: 1.35; }
  .rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
  .rail-theme { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: 12px; color: var(--ink-2); font-weight: 550; }
  .rail-theme:hover { background: color-mix(in srgb, var(--sheet) 60%, transparent); color: var(--ink); }
  .rail-sync { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding: 0 10px; }
  .dot { width: 7px; height: 7px; border-radius: 50%; background: #2DAE63; }

  .stream-col, .agent-col { max-width: none; width: 100%; margin: 0; padding: 0 48px 60px; }
  .stream-col > *, .agent-col > * { max-width: 660px; margin-left: auto; margin-right: auto; }
  .top { padding: 34px 0 20px; }
  .now-word { font-size: 64px; }
  .theme-btn { display: none; }
  .search-btn {
    padding: 0 8px 0 14px; height: 44px; border-radius: 14px;
    background: var(--sheet); box-shadow: 0 0 0 1px var(--line);
    color: var(--ink-2); gap: 10px;
  }
  .search-btn:hover { background: var(--sheet); color: var(--ink); }
  .search-btn svg { width: 18px; height: 18px; }
  .search-btn-text, .search-btn kbd { display: inline; }
  .search-btn-text { font-weight: 500; padding-right: 40px; }

  .composer { margin-bottom: 34px; }
  .composer-box { border-radius: 28px; padding: 10px 10px 10px 24px; }
  .composer-input { font-size: 19px; }
  .hint-idle { display: inline; }

  .feed { gap: 12px; }
  .cap .bubble { max-width: 72%; }
  .cap time { min-width: 3.2em; text-align: right; }

  /* Side panels */
  .side { display: block; padding: 34px 32px 40px 8px; }
  .side-agent { display: none; }
  .peek { padding: 22px 24px 20px; margin-bottom: 30px; }
  .peek-title { font-size: 24px; }
  .peek-body { font-family: var(--read); font-size: 16px; line-height: 1.55; margin-top: 12px; color: var(--ink); }
  .peek-tasks { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; font-family: var(--read); font-size: 15px; }
  .peek-task { display: flex; align-items: center; gap: 10px; }
  .peek-task .box, .live-list .box { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--ink-3); display: grid; place-items: center; flex: none; }
  .peek-task.done { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--ink-3); }
  .peek-task.done .box, .live-list .done .box { background: var(--you); border-color: var(--you); color: #fff; }
  .peek-task .box svg, .live-list .box svg { width: 13px; height: 13px; }
  .peek-open { margin-top: 16px; display: inline-flex; align-items: center; gap: 8px; font-weight: 650; color: var(--you); }
  :root[data-theme="dark"] .peek-open { color: var(--you-soft-ink); }

  .steps .section-h { margin: 0 0 8px 4px; }
  .step { display: flex; align-items: flex-start; gap: 12px; padding: 10px 4px; cursor: pointer; border-radius: 12px; }
  .step input { margin-top: 1px; }
  .step-text { font-family: var(--read); font-size: 16px; line-height: 1.35; display: flex; flex-direction: column; gap: 2px; }
  .step-note { font-family: var(--ui); color: var(--ink-2); font-size: 13.5px; }
  .step:has(input:checked) .step-text { text-decoration: line-through; color: var(--ink-2); }

  /* Capture on desktop: the composer itself opens up */
  .capture-sheet { display: none; }
  body[data-view="capture"] .scrim { opacity: 0; pointer-events: none; }
  body[data-view="capture"] .composer-input { min-height: 132px; font-size: 21px; }
  body[data-view="capture"] .composer-box { box-shadow: 0 0 0 2px var(--you), 0 24px 60px -24px color-mix(in srgb, var(--you) 55%, transparent); }
  body[data-view="capture"] .hint-idle { display: none; }
  body[data-view="capture"] .hint-active { display: inline; }
  body[data-view="capture"] .feed,
  body[data-view="capture"] .stream-head,
  body[data-view="capture"] .side-now { opacity: .38; transition: opacity .25s; }

  /* Editor as third column */
  body[data-view="editor"] .app { grid-template-columns: 264px 460px minmax(0, 1fr); }
  body[data-view="editor"] .side-now { display: none; }
  body[data-view="editor"] .stream-col { padding: 0 28px 60px; }
  body[data-view="editor"] .now-word { font-size: 52px; }
  body[data-view="editor"] .search-btn-text { padding-right: 0; }
  body[data-view="editor"] .scrim { opacity: 0; pointer-events: none; }
  .editor {
    position: static; transform: none; visibility: visible;
    border-radius: 0; display: none;
    box-shadow: -1px 0 0 var(--line);
    overflow: hidden;
    transition: none;
  }
  body[data-view="editor"] .editor { display: flex; animation: slide-in .35s var(--ease-out) both; }
  @keyframes slide-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
  .grabber { display: none; }
  .ic-close-m { display: none; }
  .ic-close-d { display: block; }
  .ed-bar { padding: 14px 22px 0; }
  .ed-scroll { padding: 18px 56px 60px; }
  .ed-scroll > * { max-width: 680px; }
  .md { font-size: 17.5px; }
  .md-h1 { font-size: 38px; }
  .md-h1 .mk, .md-h2 .mk { position: absolute; right: 100%; margin-right: .45em; }
  .md-h2.is-caret .mk { position: static; margin-right: .3em; }
  .md-h2.is-caret { margin-left: -12px; padding-left: 12px; }

  /* Agent */
  body[data-view="agent"] .stream-col { display: none; }
  body[data-view="agent"] .side-now { display: none; }
  body[data-view="agent"] .side-agent { display: block; }
  .back-btn { display: none; }
  .agent-top { padding-top: 34px; }
  .page-h { font-size: 52px; }
  .thread { gap: 26px; }
  .pair .quote { max-width: 70%; }

  .live-note { background: var(--sheet); border-radius: 24px; padding: 20px 22px; margin-bottom: 30px; }
  .live-list { margin-top: 12px; display: flex; flex-direction: column; font-family: var(--read); font-size: 16px; }
  .live-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; max-height: 40px; overflow: hidden; transition: max-height .35s var(--ease-out), opacity .25s, padding .35s; }
  .live-list li.done { color: var(--ink-2); text-decoration: line-through; }
  .live-list .from-airi::after { content: "added by Airi"; margin-left: auto; font-family: var(--ui); font-size: 13px; color: var(--airi); }
  .live-list.is-undone .from-airi { max-height: 0; opacity: 0; padding: 0; }
  .live-foot { margin-top: 10px; font-size: 13.5px; color: var(--ink-2); }

  .commits .section-h { margin: 0 0 6px 2px; }
  .commit { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 6px 0 6px 2px; border-bottom: 1px solid var(--line); }
  .commit:last-child { border-bottom: 0; }
  .commit .text-btn { margin: 0; color: var(--you); }
  :root[data-theme="dark"] .commit .text-btn { color: var(--you-soft-ink); }
  .commit-msg { font-size: 14.5px; line-height: 1.3; }
  .commit.is-undone .commit-msg { text-decoration: line-through; color: var(--ink-2); }
  .commits-foot { margin-top: 14px; color: var(--ink-2); font-size: 14px; line-height: 1.5; font-family: var(--read); }

  /* Search becomes a command palette */
  .search {
    inset: 0; background: var(--scrim);
    padding-top: calc(var(--mock-h) + 11vh);
  }
  .palette {
    height: auto; max-height: 70vh;
    width: min(680px, calc(100% - 48px));
    margin: 0 auto;
    background: var(--sheet);
    border-radius: 24px;
    box-shadow: var(--shadow-lift);
    overflow: hidden;
    animation: palette-in .2s var(--ease-out) both;
  }
  @keyframes palette-in { from { opacity: 0; transform: translateY(-8px) scale(.985); } to { opacity: 1; transform: none; } }
  .search-bar { margin: 0; height: 64px; border-radius: 0; box-shadow: none; padding: 0 18px 0 22px; border-bottom: 1px solid var(--line); background: transparent; }
  .search-bar input { font-size: 20px; }
  .search-cancel { display: none; }
  .search-esc { display: inline; }
  .results { padding: 4px 10px 12px; }
  .res { min-height: 52px; padding: 8px 12px; border-radius: 14px; }
  .res[aria-selected="true"] { background: var(--you-soft); box-shadow: none; }
  .res-group { margin-top: 10px; }
  .toast { left: auto; right: 32px; bottom: 28px; transform: translateY(140%); }
  .toast.show { transform: none; }
  .palette-foot {
    display: flex; gap: 18px;
    padding: 12px 22px;
    border-top: 1px solid var(--line);
    font-size: 13px; color: var(--ink-2);
  }
}

@media (min-width: 1280px) {
  .app { grid-template-columns: 272px minmax(0, 1fr) 440px; }
  body[data-view="editor"] .app { grid-template-columns: 272px 480px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .caret { animation: none; }
}
