/* Lumi web prototype. Tokens are per theme × scheme; components read tokens only. */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB",
    "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --rail-width: 384px;
  --column: 760px;
  --page: 20px;
  --radius-group: 22px;
  --radius-small: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 220ms;
}

/* ---------- Themes ---------- */

html[data-theme="island"][data-scheme="light"] {
  --canvas: #F3F8FA; --chat: #EDF3F7; --card: rgba(255,255,255,.88); --card-solid: #FFFFFF;
  --ink: #293448; --muted: #5E6A7D; --faint: #A7B0BD; --line: rgba(41,52,72,.10); --divider: #D6DEE5;
  --accent: #4E559B; --on-accent: #FFFFFF; --primary: #293448; --on-primary: #FFFFFF;
  --user: #CDEFEA; --assistant: #FCFEFF; --composer: #FFFFFF; --code: #EEF3F6; --code-ink: #3B4A6B;
  --control: #E9EFF3; --tile: #E3ECF6; --tile-ink: #3E4E6A;
  --glow-a: rgba(170,230,226,.55); --glow-b: rgba(206,198,242,.50);
  --danger: #B23A48; --danger-fill: rgba(178,58,72,.10); --success: #27704C; --moon: #6A60A6;
  --shadow: rgba(60,70,110,.10); --seg-track: rgba(41,52,72,.07); --seg-thumb: rgba(255,255,255,.92);
  --id-l: .54; --id-c: .105;
}
html[data-theme="island"][data-scheme="dark"] {
  --canvas: #282A36; --chat: #23242F; --card: rgba(52,55,70,.82); --card-solid: #313343;
  --ink: #F8F8F2; --muted: #B4B6CC; --faint: #6F7290; --line: rgba(248,248,242,.10); --divider: rgba(248,248,242,.12);
  --accent: #BD93F9; --on-accent: #1E1F29; --primary: #BD93F9; --on-primary: #1E1F29;
  --user: #3A334D; --assistant: #333545; --composer: #313343; --code: #1F2029; --code-ink: #8BE9FD;
  --control: #3C3F52; --tile: #3A3D52; --tile-ink: #F8F8F2;
  --glow-a: rgba(139,233,253,.10); --glow-b: rgba(189,147,249,.14);
  --danger: #FF7B7B; --danger-fill: rgba(255,85,85,.16); --success: #50FA7B; --moon: #BD93F9;
  --shadow: rgba(0,0,0,.40); --seg-track: rgba(248,248,242,.08); --seg-thumb: rgba(248,248,242,.16);
  --id-l: .80; --id-c: .085;
}
html[data-theme="glow"][data-scheme="light"] {
  --canvas: #FBFAF8; --chat: #F3F3F0; --card: rgba(255,255,255,.88); --card-solid: #FFFFFF;
  --ink: #1F232A; --muted: #6A6E78; --faint: #A4A7AF; --line: rgba(31,35,42,.08); --divider: #D6D9DE;
  --accent: #2A6AA6; --on-accent: #FFFFFF; --primary: #1F232A; --on-primary: #FFFFFF;
  --user: #DCE9F7; --assistant: #FFFFFF; --composer: #FFFFFF; --code: #F3F3F0; --code-ink: #3B4A5C;
  --control: #F1F0EE; --tile: #E8EBFA; --tile-ink: #3A4050;
  --glow-a: rgba(255,212,192,.60); --glow-b: rgba(214,204,244,.55);
  --danger: #B23A48; --danger-fill: rgba(178,58,72,.10); --success: #27704C; --moon: #6A60A6;
  --shadow: rgba(80,60,115,.12); --seg-track: rgba(31,35,42,.06); --seg-thumb: rgba(255,255,255,.92);
  --id-l: .54; --id-c: .105;
}
html[data-theme="glow"][data-scheme="dark"] {
  --canvas: #0F1014; --chat: #0B0C0F; --card: rgba(27,29,35,.82); --card-solid: #1A1C21;
  --ink: #F1F2F5; --muted: #A0A5AF; --faint: #60656F; --line: rgba(255,255,255,.10); --divider: #363B44;
  --accent: #8EC2F2; --on-accent: #0F1014; --primary: #F1F2F5; --on-primary: #0F1014;
  --user: #1D4470; --assistant: #1B1D22; --composer: #1B1D22; --code: #121317; --code-ink: #A8CBEF;
  --control: #262930; --tile: #222A3D; --tile-ink: #E4E7EE;
  --glow-a: rgba(63,32,23,.95); --glow-b: rgba(34,31,85,.95);
  --danger: #F0959E; --danger-fill: rgba(240,149,158,.16); --success: #8FD3AE; --moon: #BCB4F0;
  --shadow: rgba(0,0,0,.40); --seg-track: rgba(255,255,255,.07); --seg-thumb: rgba(255,255,255,.16);
  --id-l: .80; --id-c: .085;
}
html[data-theme="ocean"][data-scheme="light"] {
  --canvas: #F7F9FB; --chat: #EEF2F6; --card: rgba(248,251,254,.80); --card-solid: #F8FBFE;
  --ink: #1F2630; --muted: #454E5B; --faint: #9AA6B4; --line: rgba(31,38,48,.10); --divider: #D2DAE3;
  --accent: #3F6F9E; --on-accent: #FFFFFF; --primary: #1F2630; --on-primary: #FFFFFF;
  --user: #BDDCF4; --assistant: #DFE3E7; --composer: #F8FBFE; --code: #E6ECF2; --code-ink: #2D4F73;
  --control: #E4EBF2; --tile: #DCE6F0; --tile-ink: #2C3A4C;
  --glow-a: rgba(150,196,232,.50); --glow-b: rgba(120,176,204,.38);
  --danger: #B23A48; --danger-fill: rgba(178,58,72,.10); --success: #27704C; --moon: #5E6A9E;
  --shadow: rgba(40,70,100,.12); --seg-track: rgba(31,38,48,.07); --seg-thumb: rgba(255,255,255,.92);
  --id-l: .52; --id-c: .092;
}
html[data-theme="ocean"][data-scheme="dark"] {
  --canvas: #08141F; --chat: #07111B; --card: rgba(23,43,61,.74); --card-solid: #122231;
  --ink: #EAF3FA; --muted: #97AEC1; --faint: #587487; --line: rgba(168,212,242,.12); --divider: rgba(156,196,228,.18);
  --accent: #7AD0F0; --on-accent: #04121C; --primary: #7AD0F0; --on-primary: #04121C;
  --user: #19567B; --assistant: #172D42; --composer: rgba(24,47,69,.94); --code: #0D1C2B; --code-ink: #9AD6F0;
  --control: #1C3449; --tile: #173A55; --tile-ink: #EAF3FA;
  --glow-a: rgba(42,130,170,.45); --glow-b: rgba(15,90,102,.42);
  --danger: #F0959E; --danger-fill: rgba(240,149,158,.16); --success: #8FD3AE; --moon: #EBD196;
  --shadow: rgba(0,0,0,.45); --seg-track: rgba(168,212,242,.09); --seg-thumb: rgba(168,212,242,.18);
  --id-l: .82; --id-c: .072;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.5 var(--font);
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { display: block; }

.app {
  display: grid;
  grid-template-columns: var(--rail-width) 1fr;
  height: 100dvh;
}

/* ---------- Rail (home) ---------- */

.rail {
  position: relative;
  display: flex; flex-direction: column;
  min-width: 0; height: 100dvh;
  background:
    radial-gradient(115% 44% at 0% 0%, var(--glow-a), transparent 64%),
    radial-gradient(90% 40% at 100% 3%, var(--glow-b), transparent 62%),
    var(--canvas);
  border-right: 1px solid var(--line);
}
.rail-head {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  gap: 8px; padding: 12px var(--page) 10px;
}
.brand-button { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; }
.brand-mark { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block; }
.brand-ring { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.brand-ring.is-running { border: 2px solid transparent; border-top-color: var(--accent); border-right-color: color-mix(in srgb, var(--accent) 35%, transparent); animation: spin 1.6s linear infinite; }
.brand-badge {
  position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; background: var(--card-solid); color: var(--muted);
  box-shadow: 0 0 0 1px var(--line);
}
.brand-badge.is-count { background: #E0A43A; color: #2A1B00; font-size: 11px; font-weight: 700; right: -4px; top: -4px; bottom: auto; min-width: 18px; padding: 0 4px; width: auto; border-radius: 9px; }

.segmented {
  justify-self: center; position: relative; display: grid; grid-template-columns: 1fr 1fr;
  padding: 3px; border-radius: 999px; background: var(--seg-track); min-width: 220px;
}
.segmented-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px;
  background: var(--seg-thumb); box-shadow: 0 1px 4px var(--shadow);
  transition: transform var(--dur) var(--ease);
}
.segmented[data-index="1"] .segmented-thumb { transform: translateX(100%); }
.segmented button { position: relative; z-index: 1; height: 34px; padding: 0 14px; font-size: 14px; font-weight: 500; color: var(--muted); border-radius: 999px; }
.segmented button[aria-selected="true"] { color: var(--ink); }

.round-button {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
}
.round-button > span {
  width: 37px; height: 37px; display: grid; place-items: center; border-radius: 50%;
  background: var(--card-solid); box-shadow: 0 0 0 .5px var(--line), 0 2px 8px var(--shadow);
}
.round-button:hover > span { background: color-mix(in srgb, var(--card-solid) 88%, var(--ink)); }

.rail-body { flex: 1; overflow-y: auto; padding: 0 var(--page) 32px; overscroll-behavior: contain; }
.rail-sub-head {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 6px 12px 10px;
}
.rail-sub-head h2 { margin: 0; text-align: center; font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.search {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px 0 14px;
  border-radius: var(--radius-small); background: var(--card); margin-bottom: 8px;
}
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; height: 44px; }
.search input::placeholder { color: var(--faint); }
.search .clear { width: 40px; height: 40px; display: grid; place-items: center; color: var(--faint); border-radius: 50%; }
.search kbd { font: 11px var(--mono); color: var(--faint); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; margin-right: 8px; }
.search.has-value kbd, .search:not(.has-value) .clear { display: none; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.row { -webkit-touch-callout: none; }

.list-card { background: var(--card); border-radius: var(--radius-group); overflow: hidden; }
.row {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 70px; padding: 14px 14px; text-align: left; user-select: none;
  transition: background-color 120ms;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: 68px; right: 0; height: 1px;
  background: var(--divider); transform: scaleY(.5); transform-origin: top;
}
.row:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.row:active { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.row.is-selected { background: color-mix(in srgb, var(--accent) 11%, transparent); }
.row.is-deleting { opacity: .6; pointer-events: none; }
.row.is-dim { opacity: .85; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-title { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 16px; }
.row-title .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chevron { color: var(--faint); flex: none; }
.row-more {
  position: absolute; right: 36px; top: 50%; translate: 0 -50%; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); opacity: 0; background: var(--card-solid);
  box-shadow: 0 0 0 .5px var(--line);
}
.row:hover .row-more, .row:focus-within .row-more { opacity: 1; }
@media (hover: none) { .row-more { display: none; } }

.unread { width: 6px; height: 6px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 80%, transparent); flex: none; }
.state-text { font-size: 13px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }

.tile {
  position: relative; flex: none; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; background: var(--tile); color: var(--tile-ink);
}
.tile.lg { width: 76px; height: 76px; border-radius: 22px; }
.tile.md { width: 46px; height: 46px; border-radius: 13px; }
.tile svg { width: 58%; height: 58%; }
.tile.is-bot { color: oklch(var(--id-l) var(--id-c) var(--h, 252)); }
.tile.is-waiting, .tile.is-paused { opacity: .55; }
.tile .badge {
  position: absolute; right: -4px; bottom: -4px; width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center; background: var(--card-solid); color: var(--muted);
  box-shadow: 0 0 0 1.5px var(--canvas);
}
.tile .badge.moon { color: var(--moon); }
.group-mark { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 6px; }
.group-mark i { width: 11px; height: 11px; border-radius: 4px; background: oklch(var(--id-l) var(--id-c) var(--h)); opacity: .9; }
.group-mark i.empty { background: color-mix(in srgb, var(--card) 60%, transparent); }

.footer-links { display: flex; justify-content: center; gap: 20px; margin-top: 24px; }
.footer-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 13px; color: var(--muted); }
.footer-link:hover { color: var(--ink); }
.scope-bar { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; margin: 4px 0 10px; }
.scope-bar .grow { flex: 1; }

.empty { display: grid; place-items: center; text-align: center; gap: 8px; padding: 48px 0; color: var(--muted); }
.empty-card { display: grid; justify-items: center; gap: 14px; padding: 28px 20px; background: var(--card); border-radius: 26px; }
.empty-card h3, .empty-state h3 { margin: 0; font-size: 20px; font-weight: 600; color: var(--ink); }
.empty-state { display: grid; justify-items: center; gap: 16px; padding-top: 22vh; }

/* ---------- Buttons ---------- */

.btn-primary {
  min-height: 46px; padding: 0 22px; border-radius: 999px; font-weight: 600;
  background: var(--primary); color: var(--on-primary);
}
.btn-primary:disabled { background: var(--control); color: var(--muted); }
.btn-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 0 22px; border-radius: 999px;
  font-weight: 600; background: var(--card-solid); box-shadow: 0 0 0 .5px var(--line), 0 3px 10px var(--shadow);
}
.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; background: var(--control); color: var(--ink);
}
.chip:disabled { color: var(--faint); }
.text-btn { color: var(--accent); font-weight: 500; min-height: 44px; padding: 0 8px; border-radius: 10px; }
.text-btn:disabled { color: var(--faint); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

/* ---------- Pane (chat) ---------- */

.pane { position: relative; display: flex; flex-direction: column; min-width: 0; height: 100dvh; background: var(--chat); }
.pane-placeholder { flex: 1; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--muted); font-size: 13px; }
.pane-placeholder img { width: 72px; height: 72px; border-radius: 50%; opacity: .9; }

.chat-head {
  position: relative; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  min-height: 56px; padding: 6px 12px;
  background: color-mix(in srgb, var(--chat) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px);
  border-bottom: 1px solid var(--line);
}
.chat-head .left, .chat-head .right { display: flex; align-items: center; gap: 4px; }
.chat-head .right { justify-content: flex-end; }
.chat-title { display: flex; align-items: center; gap: 4px; }
.chat-title > button:first-child { max-width: min(46vw, 320px); padding: 8px 10px; border-radius: 12px; font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title > button:first-child:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.crew { position: relative; width: 44px; height: 44px; }
.crew .tile { position: absolute; width: 20px; height: 20px; border-radius: 6px; }
.crew .tile:first-child { left: 8px; top: 9px; z-index: 1; box-shadow: 0 0 0 1.5px var(--chat); }
.crew .tile:last-child { left: 17px; top: 16px; width: 17px; height: 17px; }
.back-btn { display: none; }

.status-strip {
  display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 8px 16px 0; padding: 0 6px 0 14px;
  border-radius: 999px; background: color-mix(in srgb, var(--card-solid) 70%, transparent);
  box-shadow: 0 0 0 .5px var(--line); font-size: 13px; color: color-mix(in srgb, var(--ink) 80%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  align-self: center; width: min(calc(100% - 32px), var(--column));
}
.status-strip .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-strip .moon { color: var(--moon); }

.thread { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; }
.column { width: min(100%, var(--column)); margin: 0 auto; padding: 16px var(--page) 20px; display: flex; flex-direction: column; }
.chat-empty { display: grid; justify-items: center; gap: 14px; padding: 96px 0 40px; text-align: center; }
.chat-empty h3 { margin: 0; font-size: 20px; font-weight: 600; }
.chat-empty p { margin: 0; font-size: 13px; color: var(--muted); }

.item { margin-top: 16px; }
.item:first-child { margin-top: 0; }
.item.user { align-self: flex-end; max-width: calc(100% - 48px); display: flex; flex-direction: column; align-items: flex-end; }
.item.assistant { align-self: flex-start; max-width: calc(100% - 32px); }
.bubble { padding: 10px 14px; border-radius: 20px; line-height: 1.6; overflow-wrap: anywhere; }
.item.user .bubble { background: var(--user); white-space: pre-wrap; }
.item.assistant .bubble { background: var(--assistant); }
html[data-bubble="asymmetric"] .item.user .bubble { border-top-right-radius: 6px; }
html[data-bubble="asymmetric"] .item.assistant .bubble { border-top-left-radius: 6px; }
.bubble.is-sending { opacity: .75; }

.delivery { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 11px; color: var(--muted); min-height: 28px; }
.delivery .warn { color: var(--danger); }
.delivery button { font-weight: 600; color: var(--ink); min-height: 44px; margin: -8px 0; padding: 0 2px; }
.delivery button:disabled { color: var(--faint); }

.center-meta { align-self: center; margin-top: 20px; font-size: 11px; color: var(--muted); text-align: center; }
.center-link {
  align-self: center; margin-top: 4px; min-height: 44px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); padding: 0 10px; border-radius: 12px;
}
.center-link:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.center-link .tile { width: 18px; height: 18px; border-radius: 5px; }

.dots { display: inline-flex; gap: 5px; padding: 14px 16px; border-radius: 20px; background: var(--assistant); }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: breathe 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }

.progress { width: calc(100% - 32px); max-width: 620px; background: var(--assistant); border-radius: 18px; overflow: hidden; }
.progress-head { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 10px 14px; text-align: left; }
.progress-head .grow { flex: 1; min-width: 0; }
.progress-head .title { font-size: 15px; font-weight: 600; }
.progress-head .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.progress-head .caret { color: var(--faint); transition: rotate var(--dur) var(--ease); }
.progress[data-open="true"] .caret { rotate: 90deg; }
.step { display: flex; align-items: baseline; gap: 8px; width: 100%; min-height: 40px; padding: 8px 14px 8px 42px; text-align: left; border-top: 1px solid var(--line); font-size: 14px; }
.step .when { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.step .dur { margin-left: auto; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.step-detail { margin: 0 14px 12px 42px; }

.approval { width: calc(100% - 32px); max-width: 560px; background: var(--assistant); border-radius: 20px; padding: 16px; }
.approval h4 { margin: 0 0 4px; font-size: 17px; font-weight: 600; }
.approval p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.55; }
.approval .actions { display: flex; gap: 10px; margin-top: 14px; }
.approval .actions button { flex: 1; min-height: 44px; border-radius: 999px; font-weight: 600; }
.approval .cancel { background: var(--control); }
.approval .confirm { background: var(--primary); color: var(--on-primary); }
.approval .result { margin-top: 10px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

/* Markdown */
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 21px; }
.md li + li { margin-top: 6px; }
.md h1, .md h2, .md h3 { margin: 16px 0 4px; font-weight: 600; }
.md h1 { font-size: 18px; } .md h2 { font-size: 17px; } .md h3 { font-size: 16px; }
.md blockquote { margin: 0 0 12px; padding-left: 12px; border-left: 2px solid var(--line); color: var(--muted); }
.md code { font: inherit; color: var(--code-ink); }
.md pre, .code {
  margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; background: var(--code); overflow-x: auto;
  font: 14px/1.5 var(--mono); letter-spacing: -.35px; color: var(--ink); white-space: pre;
}
.md pre code { color: inherit; font: inherit; }
.md a { color: var(--accent); }
.md .table { overflow-x: auto; margin: 0 0 12px; border-radius: 12px; background: var(--code); }
.md table { border-collapse: collapse; font-size: 15px; min-width: 100%; }
.md th, .md td { padding: 8px 10px; text-align: left; white-space: nowrap; }
.md th { font-weight: 600; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.md tr:nth-child(even) td { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.code .add { color: var(--success); } .code .del { color: var(--danger); }

/* Composer */
.dock { width: min(100%, var(--column)); margin: 0 auto; padding: 0 var(--page) calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
.surface { background: var(--assistant); border-radius: 18px; box-shadow: 0 0 0 .5px var(--line); }
.goal { display: flex; align-items: flex-start; gap: 8px; padding: 8px 6px 8px 14px; }
.goal .grow { flex: 1; min-width: 0; text-align: left; min-height: 44px; }
.goal .status { font-size: 11px; font-weight: 600; color: var(--muted); }
.goal .text { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.goal .stop { min-width: 44px; min-height: 44px; font-size: 13px; color: var(--muted); }
.suggest button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 14px; text-align: left; border-radius: 18px; }
.suggest button[aria-selected="true"], .suggest button:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.suggest .cmd { font-weight: 600; } .suggest .desc { font-size: 11px; color: var(--muted); }
.composer-note { font-size: 11px; color: var(--muted); padding: 0 18px; }

.composer {
  position: relative; background: var(--composer); border-radius: 26px;
  box-shadow: 0 0 0 .5px var(--line), 0 6px 20px var(--shadow); padding: 2px 0;
  transition: box-shadow 160ms;
}
.composer:focus-within { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent), 0 6px 20px var(--shadow); }
.composer.is-disabled { opacity: .7; }
.drafts { display: flex; gap: 8px; padding: 10px 14px 4px; overflow-x: auto; }
.draft-img { position: relative; flex: none; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; background: var(--control); }
.draft-img img { width: 100%; height: 100%; object-fit: cover; }
.draft-img button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer-row .icon-btn { width: 40px; height: 44px; border-radius: 12px; color: var(--muted); flex: none; }
.composer-row .icon-btn:disabled { color: var(--faint); }
.composer-row .attach { margin-left: 4px; }
.composer textarea {
  flex: 1; min-width: 0; resize: none; border: 0; outline: 0; background: transparent;
  padding: 11px 4px; line-height: 22px; max-height: calc(22px * 5 + 22px); min-height: 44px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer textarea[readonly] { color: var(--ink); }
.send { width: 44px; height: 44px; display: grid; place-items: center; margin-right: 4px; flex: none; }
.send > span { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); transition: background 120ms; }
.send:disabled > span { background: var(--control); color: var(--faint); }
.mic.is-recording { color: var(--accent); }
.voice-hint { min-height: 16px; text-align: center; font-size: 11px; color: var(--muted); display: flex; justify-content: center; align-items: center; gap: 6px; }
.voice-hint .bars { display: inline-flex; gap: 2px; align-items: center; height: 10px; }
.voice-hint .bars i { width: 2px; background: var(--accent); border-radius: 1px; animation: bar 0.9s ease-in-out infinite; }
.voice-hint .bars i:nth-child(2) { animation-delay: .1s; } .voice-hint .bars i:nth-child(3) { animation-delay: .2s; } .voice-hint .bars i:nth-child(4) { animation-delay: .3s; }
.caret-live { display: inline-block; width: 2px; height: 1em; background: var(--accent); vertical-align: -2px; animation: blink 1s steps(2) infinite; }

.drop-hint {
  position: absolute; inset: 0; z-index: 5; display: none; place-items: center; font-weight: 600; color: var(--accent);
  background: color-mix(in srgb, var(--chat) 85%, transparent); border: 2px dashed color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 18px; margin: 10px;
}
.pane.is-dropping .drop-hint { display: grid; }

/* ---------- Layer: menus, alerts, sheets ---------- */

.layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.layer > * { pointer-events: auto; }
.scrim { position: fixed; inset: 0; background: rgba(10,12,20,.32); animation: fade 180ms ease-out; }
.menu {
  position: fixed; min-width: 232px; max-width: 300px; padding: 6px; border-radius: 14px;
  background: var(--card-solid); box-shadow: 0 0 0 .5px var(--line), 0 12px 36px var(--shadow), 0 2px 6px var(--shadow);
  animation: pop 160ms var(--ease);
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border-radius: 9px; text-align: left; font-size: 15px; }
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: color-mix(in srgb, var(--ink) 6%, transparent); outline: none; }
.menu-item .ico { width: 20px; display: grid; place-items: center; color: var(--muted); }
.menu-item .grow { flex: 1; }
.menu-item.danger, .menu-item.danger .ico { color: var(--danger); }
.menu-item:disabled { color: var(--faint); }
.menu-item:disabled .ico { color: var(--faint); }
.menu-item .check-trail { width: 20px; flex: none; color: var(--accent); }
.menu-sep { height: 1px; margin: 4px 8px; background: var(--line); }
.menu-title { padding: 6px 12px 2px; font-size: 12px; color: var(--muted); }

.alert {
  position: fixed; left: 50%; top: 50%; translate: -50% -50%; width: min(320px, calc(100vw - 48px));
  background: var(--card-solid); border-radius: 18px; padding: 20px 18px 14px; text-align: center;
  box-shadow: 0 20px 60px var(--shadow); animation: pop 180ms var(--ease);
}
.alert h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.alert p { margin: 0; font-size: 13px; color: var(--muted); }
.alert .actions { display: flex; gap: 10px; margin-top: 18px; }
.alert .actions button { flex: 1; min-height: 44px; border-radius: 12px; font-weight: 600; background: var(--control); }
.alert .actions .danger { color: var(--danger); background: var(--danger-fill); }

.sheet {
  position: fixed; left: 50%; top: 50%; translate: -50% -50%;
  width: min(560px, calc(100vw - 32px)); height: min(86dvh, 760px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--canvas); border-radius: 22px; box-shadow: 0 30px 80px var(--shadow);
  animation: rise 220ms var(--ease);
}
.sheet-head { display: grid; grid-template-columns: 96px 1fr 96px; align-items: center; min-height: 56px; padding: 4px 8px; }
.sheet-head h2 { margin: 0; text-align: center; font-size: 17px; font-weight: 600; }
.sheet-head .left { justify-self: start; display: flex; align-items: center; }
.sheet-head .right { justify-self: end; }
.sheet-body { flex: 1; overflow-y: auto; padding: 8px var(--page) 28px; display: flex; flex-direction: column; gap: 26px; }
.sheet-page { animation: slide-in 220ms var(--ease); }

.group-title { margin: 0 0 8px 16px; font-size: 13px; font-weight: 500; color: var(--muted); }
.group-card { background: var(--card-solid); border-radius: var(--radius-group); box-shadow: 0 0 0 .5px var(--line), 0 2px 10px color-mix(in srgb, var(--shadow) 60%, transparent); overflow: hidden; }
.group-foot { margin: 8px 16px 0; font-size: 13px; color: var(--muted); }
.set-row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 62px; padding: 12px 16px; text-align: left; }
.set-row + .set-row::before { content: ""; position: absolute; top: 0; left: 66px; right: 0; height: 1px; background: var(--line); }
.set-row:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.set-row .ico { width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--control); }
.set-row .title { flex: 1; min-width: 0; }
.set-row .value { color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }

.select-row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 10px 16px; text-align: left; }
.select-row + .select-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); }
.select-row.has-lead + .select-row.has-lead::before { left: 76px; }
.select-row:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.select-row .label { flex: 1; min-width: 0; text-align: left; }
.select-row .check { width: 20px; flex: none; color: var(--accent); }
.select-row .lead { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: none; }

.notice-card { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 22px; background: var(--card); box-shadow: 0 0 0 .5px var(--line); }
.notice-card .grow { flex: 1; }
.notice-card b { display: block; font-weight: 500; }
.notice-card span { font-size: 13px; color: var(--muted); }

.todo-row { position: relative; display: flex; align-items: flex-start; gap: 12px; min-height: 52px; padding: 14px 16px; }
.todo-row + .todo-row::before { content: ""; position: absolute; top: 0; left: 44px; right: 0; height: 1px; background: var(--line); }
.todo-mark { width: 18px; height: 18px; margin-top: 3px; flex: none; border-radius: 50%; border: 1.5px solid var(--faint); display: grid; place-items: center; }
.todo-mark.completed { background: var(--success); border-color: var(--success); color: var(--card-solid); }
.todo-mark.in_progress { border-color: var(--accent); }
.todo-mark.in_progress::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: breathe 1.6s ease-in-out infinite; }
.todo-text { flex: 1; min-width: 0; }
.todo-row.canceled .todo-text { color: var(--muted); text-decoration: line-through; }
.todo-state { font-size: 11px; color: var(--muted); padding: 2px 8px; border-radius: 999px; background: var(--control); white-space: nowrap; }
.todo-state.in_progress { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.wake-row { position: relative; display: flex; align-items: flex-start; gap: 8px; padding: 12px 6px 12px 16px; }
.wake-row + .wake-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); }
.wake-row .grow { flex: 1; min-width: 0; text-align: left; }
.wake-row .when { font-size: 16px; }
.wake-row .what { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.toast {
  position: fixed; left: 50%; bottom: 28px; translate: -50% 20px; z-index: 80; opacity: 0; pointer-events: none;
  max-width: calc(100vw - 48px); padding: 10px 16px; border-radius: 999px; font-size: 13px;
  background: var(--ink); color: var(--canvas); transition: opacity 180ms, translate 180ms var(--ease);
}
.toast.is-on { opacity: 1; translate: -50% 0; }


/* ---------- Motion ---------- */

.spin { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1.6px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; flex: none; }
.spin.lg { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes bar { 0%, 100% { height: 3px; } 50% { height: 10px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
@keyframes rise { from { opacity: 0; translate: -50% calc(-50% + 16px); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .spin { border-style: dotted; border-right-color: currentColor; }
}

/* ---------- Narrow: one page at a time ---------- */

@media (max-width: 899px) {
  :root { --page: 16px; }
  .app { grid-template-columns: 1fr; }
  .rail { border-right: 0; }
  .app.has-chat .rail { display: none; }
  .app:not(.has-chat) .pane { display: none; }
  .back-btn { display: grid; }
  .segmented { min-width: 0; }
  .segmented button { padding: 0 10px; }
  .sheet { left: 0; top: auto; bottom: 0; translate: none; width: 100vw; height: 94dvh; border-radius: 22px 22px 0 0; animation: rise-m 240ms var(--ease); }
  @keyframes rise-m { from { transform: translateY(40px); opacity: 0; } }
  .row-more { display: none; }
}
