/* CoAgent: screen and paper (after emoqi).
   屏 (screen): where the agent works. Black, pixel type for labels.
   纸 (paper): what it wrote down. Off-white notched cards with black ink.
   Loaded last: it re-points the tokens every older layer reads, then lays
   out the shell (top bar with five places, conversation rail, thread,
   agent rail). Pixel type is Fusion Pixel 12px (OFL, fonts/OFL.txt) and
   is only set at 12 or 24px so it stays crisp. Content the person reads
   or recognises (answers, code, pictures, avatars) keeps its own type and
   colour. */

@font-face {
  font-family: "Fusion Pixel";
  src: url("../fonts/fusion-pixel-12px-mono-zh_hans.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  --sp-top-h: 52px;
  --sp-bar-h: 0px;
  --sp-px: "Fusion Pixel", "PingFang SC", "Microsoft YaHei", ui-monospace, monospace;
  --sp-tick: steps(4, end);
  --sp-notch-s: polygon(3px 0, calc(100% - 3px) 0, calc(100% - 3px) 3px, 100% 3px, 100% calc(100% - 3px), calc(100% - 3px) calc(100% - 3px), calc(100% - 3px) 100%, 3px 100%, 3px calc(100% - 3px), 0 calc(100% - 3px), 0 3px, 3px 3px);
  --sp-notch-l: polygon(0 8px, 4px 8px, 4px 4px, 8px 4px, 8px 0, calc(100% - 8px) 0, calc(100% - 8px) 4px, calc(100% - 4px) 4px, calc(100% - 4px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) calc(100% - 4px), calc(100% - 8px) calc(100% - 4px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 4px), 4px calc(100% - 4px), 4px calc(100% - 8px), 0 calc(100% - 8px));
  --sp-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='discrete' tableValues='0 0 0 .1 .2'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

  /* paper ink, the same in both materials: a paper card on the black
     screen and the paper stage itself read alike */
  --sp-paper: #e9e7e1;
  --sp-paper-ink: #0b0b0b;
  --sp-paper-ink-2: #3a3936;
  --sp-paper-ink-3: #75726c;
  --sp-paper-edge: rgba(0, 0, 0, .2);

  /* square everything: the shapes are emoqi's, not rounded app chrome */
  --radius-sm: 0; --radius: 0; --radius-lg: 0; --radius-xl: 0;
  --radius-bubble: 0; --radius-pill: 0;
  --shadow-float: none; --shadow-veil: none; --shadow-window: none;
}

/* ---------- the screen: black stage (dark, and system in a dark OS) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground-deep: #000; --ground: #000;
  --surface: #000; --surface-raised: #0e0e0e; --surface-sunken: #080808;
  --text: #f1f1f1; --text-strong: #fff;
  --muted: rgba(255, 255, 255, .68); --faint: rgba(255, 255, 255, .46);
  --accent: #ff5630; --accent-ink: #000;
  --accent-weak: rgba(255, 86, 48, .14);
  --focus-ring: rgba(255, 86, 48, .55);
  --bubble-mine: rgba(255, 255, 255, .08); --bubble-mine-text: #fff;
  --success: #7ee2a0; --warning: #ffd23f; --danger: #ff6b5b;
  --hairline: rgba(255, 255, 255, .16); --hairline-strong: rgba(255, 255, 255, .42);
  --code-bg: #0b0b0b;
  --scrim: rgba(0, 0, 0, .62);
  --shadow-pop: 4px 4px 0 rgba(255, 255, 255, .14);
  --ui_border: rgba(255, 255, 255, .16);
  --ui_hover: rgba(255, 255, 255, .07);
  --ui_selected: rgba(255, 255, 255, .13);
  --sp-fill: rgba(255, 255, 255, .07);
  --sp-fill-2: rgba(255, 255, 255, .14);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --ground-deep: #000; --ground: #000;
    --surface: #000; --surface-raised: #0e0e0e; --surface-sunken: #080808;
    --text: #f1f1f1; --text-strong: #fff;
    --muted: rgba(255, 255, 255, .68); --faint: rgba(255, 255, 255, .46);
    --accent: #ff5630; --accent-ink: #000;
    --accent-weak: rgba(255, 86, 48, .14);
    --focus-ring: rgba(255, 86, 48, .55);
    --bubble-mine: rgba(255, 255, 255, .08); --bubble-mine-text: #fff;
    --success: #7ee2a0; --warning: #ffd23f; --danger: #ff6b5b;
    --hairline: rgba(255, 255, 255, .16); --hairline-strong: rgba(255, 255, 255, .42);
    --code-bg: #0b0b0b;
    --scrim: rgba(0, 0, 0, .62);
    --shadow-pop: 4px 4px 0 rgba(255, 255, 255, .14);
    --ui_border: rgba(255, 255, 255, .16);
    --ui_hover: rgba(255, 255, 255, .07);
    --ui_selected: rgba(255, 255, 255, .13);
    --sp-fill: rgba(255, 255, 255, .07);
    --sp-fill-2: rgba(255, 255, 255, .14);
  }
}

/* ---------- the paper stage (light, and system in a light OS) ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --ground-deep: #dedcd5; --ground: #e9e7e1;
  --surface: #e9e7e1; --surface-raised: #f3f1ec; --surface-sunken: #dfddd6;
  --text: #0b0b0b; --text-strong: #000;
  --muted: #3a3936; --faint: #75726c;
  --accent: #d63c14; --accent-ink: #fff;
  --accent-weak: rgba(214, 60, 20, .12);
  --focus-ring: rgba(214, 60, 20, .45);
  --bubble-mine: rgba(0, 0, 0, .06); --bubble-mine-text: #0b0b0b;
  --success: #17703c; --warning: #8a6200; --danger: #c22a16;
  --hairline: rgba(0, 0, 0, .2); --hairline-strong: rgba(0, 0, 0, .52);
  --code-bg: #dfddd6;
  --scrim: rgba(20, 20, 18, .4);
  --shadow-pop: 4px 4px 0 rgba(0, 0, 0, .12);
  --ui_border: rgba(0, 0, 0, .2);
  --ui_hover: rgba(0, 0, 0, .06);
  --ui_selected: rgba(0, 0, 0, .12);
  --sp-fill: rgba(0, 0, 0, .06);
  --sp-fill-2: rgba(0, 0, 0, .12);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    color-scheme: light;
    --ground-deep: #dedcd5; --ground: #e9e7e1;
    --surface: #e9e7e1; --surface-raised: #f3f1ec; --surface-sunken: #dfddd6;
    --text: #0b0b0b; --text-strong: #000;
    --muted: #3a3936; --faint: #75726c;
    --accent: #d63c14; --accent-ink: #fff;
    --accent-weak: rgba(214, 60, 20, .12);
    --focus-ring: rgba(214, 60, 20, .45);
    --bubble-mine: rgba(0, 0, 0, .06); --bubble-mine-text: #0b0b0b;
    --success: #17703c; --warning: #8a6200; --danger: #c22a16;
    --hairline: rgba(0, 0, 0, .2); --hairline-strong: rgba(0, 0, 0, .52);
    --code-bg: #dfddd6;
    --scrim: rgba(20, 20, 18, .4);
    --shadow-pop: 4px 4px 0 rgba(0, 0, 0, .12);
    --ui_border: rgba(0, 0, 0, .2);
    --ui_hover: rgba(0, 0, 0, .06);
    --ui_selected: rgba(0, 0, 0, .12);
    --sp-fill: rgba(0, 0, 0, .06);
    --sp-fill-2: rgba(0, 0, 0, .12);
  }
}
:root[data-theme="light"] body { background: var(--sp-grain), var(--ground); }
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] body { background: var(--sp-grain), var(--ground); }
}

body { background: var(--ground); }
::selection { background: var(--accent); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* pixel labels: chrome only, never content */
.sp_brand_name, .sp_place .nav-label, .workspace_search, .rail_label, .rail_tool,
.rail_agent_model, .rail_facts dt, .taskbar-head h2, .taskbar-label, .sp_rail_head .nav-label,
.sp_rail_foot .nav-label, .side-section-title {
  font-family: var(--sp-px); font-size: 12px; line-height: 1.5; font-weight: 400;
  letter-spacing: 0; -webkit-font-smoothing: none;
}

/* ---------- shell ---------- */
.app { flex-direction: column; }
.frame { flex: 1; min-height: 0; }

.sp_topbar {
  flex: none; position: relative; z-index: 35; /* under modals (40), toasts, the palette */
  height: var(--sp-top-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 12px 0 10px;
  background: var(--ground);
  border-bottom: 1px solid var(--hairline);
}
.sp_brand { display: flex; align-items: center; gap: 10px; flex: none; min-width: 0; }
.sp_brand .sidebar-toggle { display: inline-flex; }
/* the top bar owns the rail toggle; the old in-page restore button would be a second one */
.sidebar_restore, body.sidebar-collapsed .sidebar_restore { display: none !important; }
.sp_mark { width: 12px; height: 12px; background: var(--accent); flex: none; clip-path: var(--sp-notch-s); }
body.is-running .sp_mark, .sp_topbar:has(.has_activity) .sp_mark { animation: sp_blink 1.4s steps(1, end) infinite; }
.sp_brand_name { color: var(--text-strong); text-transform: uppercase; }

.side-nav.sp_places {
  flex-direction: row; gap: 2px; padding: 0;
  margin: 0 auto; align-self: stretch; align-items: stretch;
}
.nav-row.sp_place {
  width: auto; height: auto; padding: 0 14px; gap: 8px;
  border-radius: 0; color: var(--muted);
  border-bottom: 2px solid transparent; border-top: 2px solid transparent;
}
.nav-row.sp_place svg { width: 14px; height: 14px; color: currentColor; stroke-width: 1.8; }
.nav-row.sp_place:hover { background: var(--ui_hover); color: var(--text-strong); }
.nav-row.sp_place.is-active { background: transparent; color: var(--text-strong); border-bottom-color: var(--text-strong); }
.nav-row.sp_place.is-active svg { color: var(--accent); }

.sp_top_tools { display: flex; align-items: center; gap: 8px; flex: none; }
.nav-row.workspace_search {
  width: 220px; height: 36px; padding: 0 10px; gap: 8px;
  border: 2px solid var(--hairline-strong); border-radius: 0; color: var(--faint);
}
.nav-row.workspace_search:hover { border-color: var(--text); color: var(--text); background: transparent; }
.nav-row.workspace_search kbd { margin-left: auto; font: inherit; color: var(--faint); background: none; border: 0; }

.sidebar-foot.sp_account {
  position: relative; display: flex; align-items: center; gap: 6px;
  padding: 0; margin: 0; border: 0; background: none;
}
.sp_account .user-row { height: 36px; width: auto; padding: 0 6px; gap: 8px; border-radius: 0; border: 2px solid transparent; }
.sp_account .user-row:hover { border-color: var(--hairline-strong); background: transparent; }
.sp_account .user-avatar { border-radius: 0; }
.sp_account .presence-strip:empty { display: none; }
.sp_account .user-menu {
  position: absolute; top: calc(100% + 8px); right: 0; bottom: auto; left: auto;
  width: 280px; z-index: 90;
  background: var(--surface-raised); border: 2px solid var(--hairline-strong); border-radius: 0;
  box-shadow: var(--shadow-pop);
}

/* ---------- left rail: conversations ---------- */
.sidebar { background: var(--ground); border-right: 1px solid var(--hairline); }
.sp_rail_head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 4px; flex: none; }
.sp_rail_head #newConversationBtn {
  flex: 1; height: 36px; padding: 0 12px; gap: 8px; justify-content: center;
  background: var(--text-strong); color: var(--ground); border: 0; border-radius: 0; font-weight: 400;
  clip-path: var(--sp-notch-s);
}
.sp_rail_head #newConversationBtn svg { color: currentColor; width: 12px; height: 12px; }
.sp_rail_head #newConversationBtn:hover { background: var(--accent); color: var(--accent-ink); }
.sp_rail_head #newConversationBtn:active { transform: translateY(2px); }
.sp_rail_head .icon-btn, .sp_brand .icon-btn {
  width: 36px; height: 36px; border-radius: 0; border: 2px solid var(--hairline-strong);
}
.sp_rail_head .icon-btn:hover, .sp_brand .icon-btn:hover { background: var(--text-strong); color: var(--ground); border-color: var(--text-strong); }
.sp_rail_foot { flex: none; display: flex; flex-direction: column; gap: 2px; padding: 8px; border-top: 1px solid var(--hairline); }
.sp_rail_foot .nav-row { height: 32px; border-radius: 0; color: var(--muted); }
.sp_rail_foot .nav-row:hover { color: var(--text-strong); }

.list-item { border-radius: 0; border-left: 2px solid transparent; }
.list-item:hover { background: var(--ui_hover); }
.list-item.is-active { background: var(--ui_selected); border-left-color: var(--accent); }
.list-item.is-active .name { color: var(--text-strong); }
.list-item.is-active .sub { color: var(--muted); }
.list-item .dot { border-radius: 0; animation: sp_blink 1.4s steps(1, end) infinite; }

/* usage brings its own layout: the conversation rail steps aside. Settings
   is a dialog over the page underneath, so that page keeps its rail. */
:root[data-place="usage"] .sidebar { display: none; }

/* ---------- thread column ---------- */
.main { background: var(--surface); }
.view-head { border-bottom: 1px solid var(--hairline); background: var(--surface); }
.view-head .icon-btn { border-radius: 0; }
.view-head .icon-btn[aria-expanded="true"] { color: var(--accent); }

.composer-box {
  border-radius: 0; border: 2px solid var(--hairline-strong);
  background: var(--surface-raised); box-shadow: none;
}
.composer-box:focus-within { border-color: var(--text-strong); box-shadow: 4px 4px 0 var(--ui_selected); }
.send-key { border-radius: 0; background: var(--text-strong); color: var(--ground); clip-path: var(--sp-notch-s); }
.send-key:hover { background: var(--accent); color: var(--accent-ink); }
.composer::before { display: none; }

/* ---------- right rail: the agent ---------- */
.taskbar.agent_rail { width: 320px; background: var(--ground); border-left: 1px solid var(--hairline); }
.agent_rail .taskbar-head { height: 44px; margin: 0; padding: 0 8px 0 16px; border-bottom: 1px solid var(--hairline); }
.agent_rail .taskbar-head h2 { color: var(--faint); text-transform: uppercase; }
.agent_rail .taskbar-head .icon-btn { border-radius: 0; }
.agent_rail .taskbar-body { padding: 12px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }

.rail_card { border: 1px solid var(--hairline); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.rail_label { color: var(--faint); text-transform: uppercase; }
.taskbar-label.rail_label { margin: 4px 0 -4px; padding: 0; }

.rail_agent_head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rail_avatar {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  background: var(--agent-accent, var(--accent)); color: #000;
  font-family: var(--sp-px); font-size: 24px; line-height: 1; -webkit-font-smoothing: none;
  clip-path: var(--sp-notch-s);
}
.rail_agent_id { display: flex; flex-direction: column; min-width: 0; }
.rail_agent_name { font-size: 15px; font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail_agent_model { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail_agent_desc { font-size: 13px; line-height: 1.55; color: var(--muted); margin: 0; }
.rail_tools_box > summary { list-style: none; cursor: pointer; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.rail_tools_box > summary::-webkit-details-marker { display: none; }
.rail_tools_box > summary::before { content: "+"; width: 12px; color: var(--faint); }
.rail_tools_box[open] > summary::before { content: "-"; }
.rail_tools_box > summary:hover { color: var(--text-strong); }
.rail_tools { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.rail_tool { padding: 1px 6px; border: 1px solid var(--hairline-strong); color: var(--muted); white-space: nowrap; }

.rail_facts { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.rail_facts > div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.rail_facts dt { color: var(--faint); }
.rail_facts dd { margin: 0; min-width: 0; }
.rail_facts .ws-pill {
  display: block; padding: 0; border: 0; background: none; border-radius: 0;
  font-size: 13px; color: var(--text); white-space: normal; overflow-wrap: anywhere;
}

.agent_rail .task-card { border-radius: 0; border: 1px solid var(--hairline); background: transparent; box-shadow: none; }
.agent_rail .task-card .btn { border-radius: 0; }
.agent_rail .badge.live { border-radius: 0; }
.agent_rail #taskbarEmpty { color: var(--faint); font-size: 13px; }

/* ---------- small parts the whole page shares ---------- */
/* emoqi has no rounded chrome. Older layers hard-code radii in dozens of
   places, so one rule squares the interface; pictures, avatars and the
   mascot are content and keep their own shape. */
body :not(img, video, canvas, svg, svg *, .user-avatar, .user-avatar *, .presence-avatar, [class*="mascot"], [class*="mascot"] *, [class*="cam-"], [class*="cam-"] *) {
  border-radius: 0 !important;
}
.composer-input:focus-visible, .composer-input:focus { outline: none; }

@keyframes sp_blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* ---------- narrower screens ---------- */
@media (max-width: 1200px) {
  .taskbar.agent_rail {
    position: fixed; top: var(--sp-top-h); right: 0; bottom: var(--sp-bar-h);
    width: min(340px, 92vw); z-index: 33; box-shadow: -6px 0 0 var(--ui_selected);
  }
}
@media (max-width: 900px) {
  .sidebar, body.sidebar-collapsed .sidebar { top: var(--sp-top-h); bottom: var(--sp-bar-h); }
  .nav-row.workspace_search { width: 36px; padding: 0; justify-content: center; }
  .nav-row.workspace_search span, .nav-row.workspace_search kbd { display: none; }
}
@media (max-width: 760px) {
  :root { --sp-bar-h: 56px; }
  .side-nav.sp_places {
    position: fixed; left: 0; right: 0; bottom: 0; height: var(--sp-bar-h); z-index: 35;
    margin: 0; justify-content: space-around;
    background: var(--ground); border-top: 1px solid var(--hairline);
  }
  .nav-row.sp_place { flex-direction: column; justify-content: center; gap: 2px; padding: 0 6px; border-top-width: 0; }
  .nav-row.sp_place.is-active { border-bottom-color: transparent; box-shadow: inset 0 2px 0 var(--text-strong); }
  .frame { padding-bottom: var(--sp-bar-h); }
  .sp_account .user-name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sp_mark, .list-item .dot { animation: none !important; }
}

/* =====================================================================
   Step 2: the run on the screen, the answer on paper.
   A turn is one block; each model round sits in it under a numbered
   divider. Reasoning is a trace that folds itself once thinking ends.
   Tool calls are pixel-labelled chips; their detail opens on paper. The
   answer the turn ends with is set down on a paper card.
   ===================================================================== */

/* tool-call palette, re-pointed at the screen (chips) and paper (dialog) */
:root[data-theme] {
  --call-ink: var(--text);
  --call-ink-strong: var(--text-strong);
  --call-line: var(--hairline-strong);
  --call-line-strong: var(--text-strong);
  --call-fill: transparent;
  --call-fill-hover: var(--sp-fill);
  --call-fill-open: var(--sp-fill-2);
  --call-glow: 255, 86, 48;
  --call-blue: var(--text);
  --call-purple: var(--text);
  --call-fail: var(--danger);
  --call-fail-soft: color-mix(in srgb, var(--danger) 12%, transparent);
  --call-pending-line: var(--warning);
  --call-pending-fill: color-mix(in srgb, var(--warning) 10%, transparent);
  --call-pending-ink: var(--warning);
  --call-result-ink: var(--muted);
  --call-panel: var(--sp-paper);
  --call-panel-line: var(--sp-paper-edge);
  --call-section: rgba(0, 0, 0, .03);
  --call-section-line: rgba(0, 0, 0, .14);
  --call-divider: rgba(0, 0, 0, .12);
  --call-dash: rgba(0, 0, 0, .22);
  --call-text: var(--sp-paper-ink-2);
  --call-text-strong: var(--sp-paper-ink);
  --call-text-faint: var(--sp-paper-ink-3);
  --call-raw-fill: rgba(0, 0, 0, .04);
  --call-scrim: rgba(0, 0, 0, .62);
  --call-shadow: 8px 8px 0 rgba(0, 0, 0, .35);
  --call-inset: transparent;
}

/* paper ink for anything set on paper: markdown inside reads as print */
.sp_answer, .call-panel, .ask-card {
  --text: var(--sp-paper-ink); --text-strong: #000;
  --muted: var(--sp-paper-ink-2); --faint: var(--sp-paper-ink-3);
  --hairline: rgba(0, 0, 0, .16); --hairline-strong: rgba(0, 0, 0, .4);
  --inset: rgba(0, 0, 0, .06); --code-bg: rgba(0, 0, 0, .05);
  --surface: transparent; --surface-raised: rgba(255, 255, 255, .5);
  --surface-sunken: rgba(0, 0, 0, .06); --ground: transparent;
  --accent: #d63c14; --accent-ink: #fff;
  --success: #17703c; --warning: #8a6200; --danger: #c22a16;
  color-scheme: light;
}

/* ---------- a turn and its rounds ---------- */
.msg.assistant .msg-author { font-family: var(--sp-px); font-size: 12px; font-weight: 400; color: var(--accent); -webkit-font-smoothing: none; }
.sp_round { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sp_round:empty { display: none; }
.sp_round_divider { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; color: var(--faint); }
.sp_round_divider::before, .sp_round_divider::after { content: ""; border-top: 1px dashed var(--hairline); }
.sp_round_divider::before { flex: 0 0 14px; }
.sp_round_divider::after { flex: 1; }
.sp_round_label { font-family: var(--sp-px); font-size: 12px; line-height: 1.5; -webkit-font-smoothing: none; }

/* narration between tool rounds stays on the screen, a step quieter */
.msg.assistant .sp_round > .msg-content:not(.sp_answer) { color: var(--muted); }

/* ---------- the reasoning trace ---------- */
.msg .reasoning {
  margin: 0; padding: 2px 0 2px 12px; background: none; border: 0;
  border-left: 2px solid var(--hairline-strong);
}
.msg .reasoning > summary {
  font-family: var(--sp-px); font-size: 12px; line-height: 1.5; color: var(--faint);
  -webkit-font-smoothing: none; list-style: none; cursor: pointer; padding: 0; background: none;
  display: flex; align-items: center; gap: 0; border: 0; box-shadow: none; letter-spacing: 0;
}
.msg .reasoning > summary::after { display: none; }
.msg .reasoning > summary::before {
  content: "+"; display: inline-block; flex: none; width: 14px; height: auto; margin: 0;
  background: none; box-shadow: none; transform: none; animation: none; color: var(--faint);
}
.msg .reasoning[open] > summary::before { content: "-"; transform: none; }
.msg .reasoning.is-live { border-left-color: var(--accent); }
.msg .reasoning.is-live > summary { color: var(--text); }
.msg .reasoning.is-live > summary::before {
  content: ""; width: 8px; height: 8px; margin-right: 6px; background: var(--accent); box-shadow: none;
  animation: sp_blink 1.4s steps(1, end) infinite;
}
.msg .reasoning > summary:hover { color: var(--text-strong); }
.msg .reasoning-body { font-size: 13px; line-height: 1.65; color: var(--muted); padding: 6px 0 2px; background: none; border: 0; }

/* ---------- the activity line: a blinking block caret, pixel label ---------- */
.activity { gap: 8px; color: var(--muted); }
.activity .activity-glyph {
  width: 8px; height: 14px; border: 0; border-radius: 0; background: var(--activity-color, var(--accent));
  animation: sp_blink 1s steps(1, end) infinite;
}
.activity .activity-glyph::before, .activity .activity-glyph::after { display: none; }
.activity-label, .activity-time { font-family: var(--sp-px); font-size: 12px; line-height: 1.5; -webkit-font-smoothing: none; }
.activity-time { color: var(--faint); }

/* ---------- tool chips ---------- */
.call-chip {
  font-family: var(--mono); padding: 3px 10px 3px 8px; gap: 8px;
  border-width: 1px; box-shadow: none !important; transform: none !important;
  transition: background-color 120ms steps(2, end), border-color 120ms steps(2, end);
}
.call-chip:hover { border-color: var(--text-strong); }
.call-glyph { color: var(--accent); }
.call-name { font-family: var(--sp-px); font-size: 12px; -webkit-font-smoothing: none; color: var(--text-strong); font-weight: 400; }
.call-subject { color: var(--muted); }
.call-mark { color: var(--success); }
.call-chip.failed { border-color: var(--danger); }
.call-chip.running { border-style: dashed; }
.call-chip.running .call-glyph { animation: sp_blink 1s steps(1, end) infinite; }
.call-chip.running::after { display: none; }
.call-time { font-family: var(--sp-px); font-size: 12px; color: var(--faint); -webkit-font-smoothing: none; }

/* who let it through */
.call-approval {
  flex: none; padding: 0 6px; border: 1px solid currentColor;
  font-family: var(--sp-px); font-size: 12px; line-height: 18px; -webkit-font-smoothing: none;
  color: var(--muted); white-space: nowrap;
}
.call-approval[data-state="person"], .call-approval[data-state="approved"] { color: var(--success); }
.call-approval[data-state="auto"] { color: var(--warning); }
.call-approval[data-state="failed"] { color: var(--warning); }
.call-approval[data-state="rejected"], .call-approval[data-state="person_rejected"] { color: var(--danger); }
.call-approval[data-state="running"], .call-approval[data-state="waiting"] { animation: sp_blink 1.4s steps(1, end) infinite; }
.call-approval[data-state="waiting"] { color: var(--accent); }

/* the call's detail opens on paper */
.call-panel { background: var(--sp-grain), var(--sp-paper); border: 0; clip-path: var(--sp-notch-l); color: var(--sp-paper-ink); }
.call-title, .call-section-head, .call-meta, .call-status, .call-raw-size {
  font-family: var(--sp-px); font-size: 12px; -webkit-font-smoothing: none; font-weight: 400;
}
.call-title { font-size: 24px; line-height: 1.25; color: #000; }

/* ---------- the answer, on paper ---------- */
.msg.assistant .msg-content.sp_answer {
  max-width: 76ch; padding: 20px 24px 22px;
  background: var(--sp-grain), var(--sp-paper); color: var(--sp-paper-ink);
  clip-path: var(--sp-notch-l);
}
/* printed once, as the run sets it down; a redrawn history just shows it */
.msg.assistant .msg-content.sp_answer.is-fresh { animation: sp_print .28s steps(7, end) backwards; }
.sp_answer .code-block, .sp_answer pre { background: rgba(0, 0, 0, .05); border-color: rgba(0, 0, 0, .16); }
.sp_answer a { color: #d63c14; }
@keyframes sp_print { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }

/* on the paper stage a paper card needs an edge to stand off the page */
:root[data-theme="light"] .msg.assistant .msg-content.sp_answer { background: var(--sp-grain), #f6f4ef; box-shadow: none; outline: 1px solid rgba(0, 0, 0, .14); outline-offset: -1px; }
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] .msg.assistant .msg-content.sp_answer { background: var(--sp-grain), #f6f4ef; outline: 1px solid rgba(0, 0, 0, .14); outline-offset: -1px; }
}

/* the person's own words: an outlined box on the screen, not a bubble */
.msg.user .msg-content, .msg.user.mine .msg-content {
  background: var(--sp-fill); color: var(--text); border: 1px solid var(--hairline-strong);
}
.msg.user.mine .msg-content .md a { color: var(--text-strong); }
.msg.user.mine .msg-content code { background: var(--sp-fill-2); }
.msg.user.mine .code-block { background: var(--sp-fill); border-color: var(--hairline); }
.msg.user.mine .code-head { color: var(--muted); border-color: var(--hairline); }
.msg.user.mine .code-copy { color: var(--muted); }

/* copy, fork, retry: under the answer, square buttons */
.msg-actions { gap: 2px; }
.msg-action { border: 1px solid transparent; }
.msg-action:hover { border-color: var(--hairline-strong); background: transparent; color: var(--text-strong); }

/* ---------- status lines: retries, compaction, a cut-off answer ---------- */
.notice-card {
  display: flex; align-items: center; gap: 8px; padding: 2px 0; background: none; border: 0;
  font-family: var(--sp-px); font-size: 12px; line-height: 1.5; -webkit-font-smoothing: none; color: var(--muted);
}
.notice-card::before { content: ""; flex: none; width: 8px; height: 8px; background: var(--faint); }
.notice-card.retry { color: var(--warning); background: none; border: 0; }
.notice-card.retry::before { background: var(--warning); animation: sp_blink 1.4s steps(1, end) infinite; }
.notice-card.truncated { color: var(--danger); background: none; border: 0; }
.notice-card.truncated::before { background: var(--danger); }
.incomplete_notice { border: 1px dashed var(--warning); background: none; }

/* ---------- a question for the person: on paper, it is theirs to read ---------- */
.ask-card {
  background: var(--sp-grain), var(--sp-paper); color: var(--sp-paper-ink);
  border: 0; clip-path: var(--sp-notch-l); padding: 18px 20px; box-shadow: none;
  animation: sp_print .24s steps(6, end) backwards;
}
.ask-card h3 {
  font-family: var(--sp-px); font-size: 12px; font-weight: 400; -webkit-font-smoothing: none;
  color: #d63c14; text-transform: uppercase; display: flex; align-items: center; gap: 8px;
}
.ask-card h3::before { content: ""; width: 8px; height: 8px; background: #d63c14; animation: sp_blink 1.4s steps(1, end) infinite; }
.ask-card pre { background: rgba(0, 0, 0, .06); border: 1px solid rgba(0, 0, 0, .16); color: var(--sp-paper-ink); }
.ask-card .risk { color: #8a6200; }
.ask-card .btn { border: 2px solid var(--sp-paper-ink); background: transparent; color: var(--sp-paper-ink); }
.ask-card .btn:hover { background: var(--sp-paper-ink); color: var(--sp-paper); }
.ask-card .btn.approve, .ask-card .btn.primary { background: var(--sp-paper-ink); color: var(--sp-paper); clip-path: var(--sp-notch-s); }
.ask-card .btn.approve:hover, .ask-card .btn.primary:hover { background: #d63c14; border-color: #d63c14; color: #fff; }
.ask-card .btn .key { background: none; border: 1px solid currentColor; color: inherit; }
.ask-card .input { border: 2px solid rgba(0, 0, 0, .4); background: transparent; color: var(--sp-paper-ink); }

/* ---------- a sub-agent at work, inside the chip that spawned it ---------- */
.subagent-panel { border-top: 0; border-left: 2px solid var(--hairline-strong); margin: 4px 0 0 6px; padding: 4px 0 4px 12px; }
.subagent-panel:not(.is-done) { border-left-color: var(--accent); }
.subagent-title { font-family: var(--sp-px); font-size: 12px; font-weight: 400; -webkit-font-smoothing: none; color: var(--text-strong); }
.subagent-step-name { font-family: var(--sp-px); font-size: 12px; -webkit-font-smoothing: none; }
.subagent-step-detail { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .msg.assistant .msg-content.sp_answer, .ask-card { animation: none; }
  .activity .activity-glyph, .msg .reasoning.is-live > summary::before, .call-chip.running .call-glyph,
  .call-approval[data-state="running"], .call-approval[data-state="waiting"], .notice-card.retry::before, .ask-card h3::before { animation: none; }
}

/* =====================================================================
   Step 3: the agent rail's model card. Context as a striped bar that
   fills in steps, a tick where the run folds its history, and the
   numbers a p/cost score is made of, in pixel type.
   ===================================================================== */
.rail_row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.rail_ctx_pct { font-family: var(--sp-px); font-size: 24px; line-height: 1; color: var(--text-strong); -webkit-font-smoothing: none; }
.rail_ctx_bar { position: relative; height: 12px; border: 1px solid var(--hairline-strong); overflow: hidden; }
.rail_ctx_fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  background: repeating-linear-gradient(90deg, var(--text-strong) 0 6px, transparent 6px 8px);
  transition: width .5s steps(8, end);
}
.rail_ctx_bar.is-warm .rail_ctx_fill { background: repeating-linear-gradient(90deg, var(--warning) 0 6px, transparent 6px 8px); }
.rail_ctx_bar.is-danger .rail_ctx_fill { background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 8px); }
.rail_ctx_mark { position: absolute; top: -1px; bottom: -1px; width: 2px; margin-left: -1px; background: var(--accent); }
.rail_ctx_line { font-family: var(--sp-px); font-size: 12px; line-height: 1.5; color: var(--faint); -webkit-font-smoothing: none; }
.rail_stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin: 2px 0 0; }
.rail_stats > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rail_stats dt { font-family: var(--sp-px); font-size: 12px; line-height: 1.5; color: var(--faint); -webkit-font-smoothing: none; }
.rail_stats dd { margin: 0; font-family: var(--sp-px); font-size: 24px; line-height: 1.1; color: var(--text-strong); -webkit-font-smoothing: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail_stats dd.is-live { color: var(--accent); }
.rail_ledger {
  align-self: flex-start; height: 28px; padding: 0 10px; background: none; color: var(--muted);
  border: 1px dashed var(--hairline-strong);
  font-family: var(--sp-px); font-size: 12px; -webkit-font-smoothing: none; cursor: pointer;
}
.rail_ledger:hover { border-style: solid; border-color: var(--text-strong); color: var(--text-strong); }
@media (prefers-reduced-motion: reduce) { .rail_ctx_fill { transition: none; } }

/* =====================================================================
   Step 4a: settings as a dialog (幻依's settings dialog) over the page it
   was opened from. Tabs run across the top instead of down a sidebar;
   the panel is the screen, framed in a 2px edge, on a dark scrim.
   ===================================================================== */
body.settings-open #settingsView {
  position: fixed; inset: var(--sp-top-h) 0 var(--sp-bar-h) 0; z-index: 34; /* under the top bar and its menus (35); a confirm (40) opens above it */
  display: flex; flex-direction: column; align-items: center;
  padding: 28px 24px; background: rgba(0, 0, 0, .72);
  animation: sp_scrim_in .16s steps(3, end);
}
body.settings-open #settingsView > .settings_topbar,
body.settings-open #settingsView > .settings-body {
  width: min(1080px, 100%); background: var(--surface); border: 2px solid var(--hairline-strong);
}
body.settings-open #settingsView > .settings_topbar {
  flex: none; padding: 18px 20px 14px; border-bottom: 0; align-items: center;
}
body.settings-open #settingsView > .settings-body {
  flex: 1; min-height: 0; display: flex; flex-direction: column; border-top: 1px solid var(--hairline);
}
body.settings-open #settingsView .settings_eyebrow { font-family: var(--sp-px); font-size: 12px; font-weight: 400; letter-spacing: 0; -webkit-font-smoothing: none; margin-bottom: 4px; }
body.settings-open #settingsView #settingsTitle { font-family: var(--sp-px); font-size: 24px; font-weight: 400; letter-spacing: 0; -webkit-font-smoothing: none; }
body.settings-open #settingsView .settings_topbar_copy > p { margin-top: 4px; }
body.settings-open #settingsView .settings_close {
  min-height: 32px; border: 2px solid var(--hairline-strong); background: none; color: var(--text);
  font-family: var(--sp-px); font-size: 12px; font-weight: 400; -webkit-font-smoothing: none;
}
body.settings-open #settingsView .settings_close:hover { background: var(--text-strong); color: var(--ground); border-color: var(--text-strong); }

/* the tab row */
body.settings-open #settingsView .settings-nav {
  flex-direction: row; align-items: stretch; gap: 0; flex: none;
  padding: 0 12px; overflow-x: auto; overflow-y: hidden;
  border-right: 0; border-bottom: 1px solid var(--hairline); background: var(--surface);
  scrollbar-width: none;
}
body.settings-open #settingsView .settings-nav::-webkit-scrollbar { display: none; }
body.settings-open #settingsView .settings_account,
body.settings-open #settingsView .settings_group_label { display: none; }
body.settings-open #settingsView .settings_group { display: flex; flex-direction: row; gap: 0; }
body.settings-open #settingsView .settings_group + .settings_group { border-left: 1px solid var(--hairline); margin-left: 6px; padding-left: 6px; }
body.settings-open #settingsView .settings_group[hidden] { display: none; }
body.settings-open #settingsView .settings-link {
  width: auto; height: 42px; padding: 0 12px; gap: 8px; white-space: nowrap;
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
}
body.settings-open #settingsView .settings-link .settings-label,
body.settings-open #settingsView .settings-link { font-family: var(--sp-px); font-size: 12px; font-weight: 400; -webkit-font-smoothing: none; }
body.settings-open #settingsView .settings-link:hover { color: var(--text-strong); background: var(--ui_hover); }
body.settings-open #settingsView .settings-link.is-active { color: var(--text-strong); background: none; border-bottom-color: var(--text-strong); box-shadow: none; }
body.settings-open #settingsView .settings-link.is-active .settings-icon { color: var(--accent); }
body.settings-open #settingsView .settings-link[hidden] { display: none; }
body.settings-open #settingsView .settings-content { flex: 1; min-height: 0; overflow-y: auto; }
body.settings-open #settingsView .settings_content_kicker { font-family: var(--sp-px); font-size: 12px; -webkit-font-smoothing: none; letter-spacing: 0; color: var(--accent); }

@keyframes sp_scrim_in { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 760px) {
  body.settings-open #settingsView { padding: 0; }
  body.settings-open #settingsView > .settings_topbar,
  body.settings-open #settingsView > .settings-body { border-width: 0; }
  body.settings-open #settingsView .settings_topbar_copy > p { display: none; }
}
@media (prefers-reduced-motion: reduce) { body.settings-open #settingsView { animation: none; } }

/* =====================================================================
   Step 4b: documents, files and usage. What people read sits on paper
   (document cards, the editor, a file's preview); what they scan stays
   on the screen (the file list, the usage numbers in pixel type).
   ===================================================================== */
#documentView .editor-split, #fileView .file-preview, .documents_browser_card {
  --text: var(--sp-paper-ink); --text-strong: #000;
  --muted: var(--sp-paper-ink-2); --faint: var(--sp-paper-ink-3);
  --hairline: rgba(0, 0, 0, .16); --hairline-strong: rgba(0, 0, 0, .4);
  --inset: rgba(0, 0, 0, .06); --code-bg: rgba(0, 0, 0, .05);
  --surface: var(--sp-paper); --surface-raised: #f3f1ec; --surface-sunken: rgba(0, 0, 0, .06);
  --ground: var(--sp-paper);
  --accent: #d63c14; --accent-ink: #fff;
  color-scheme: light; color: var(--sp-paper-ink);
}

/* the document: one sheet of paper on the screen */
#documentView .editor-split { margin: 16px; background: var(--sp-grain), var(--sp-paper); clip-path: var(--sp-notch-l); min-height: 0; }
#documentView .editor, #documentView .editor-preview { background: transparent; }
#documentView .editor-split > * + * { border-left: 1px dashed rgba(0, 0, 0, .22); }
#fileView .file-preview { margin: 16px; background: var(--sp-grain), var(--sp-paper); clip-path: var(--sp-notch-l); }
#fileView .file-preview img, #fileView .file-preview video { clip-path: none; }

/* document cards: emoqi's note cards */
.documents_browser_card {
  background: var(--sp-grain), var(--sp-paper); border: 0; clip-path: var(--sp-notch-l); box-shadow: none;
  transition: transform .12s steps(2, end);
}
.documents_browser_card:hover { transform: translateY(-2px); background: var(--sp-grain), #f3f1ec; }
.documents_browser_card.is-selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.documents_browser_card .fb-icon { color: #d63c14; }

/* the file list: square tiles on the screen */
#filesView .fb-item { border: 1px solid var(--hairline); background: transparent; box-shadow: none; }
#filesView .fb-item:hover { border-color: var(--hairline-strong); background: var(--ui_hover); }
#filesView .fb-item.is-selected { border-color: var(--accent); background: var(--accent-weak); }
.fb-crumbs, .fb-status, #documents_browser_count { font-family: var(--sp-px); font-size: 12px; -webkit-font-smoothing: none; }
.fb-crumbs button, .fb-crumbs a { font: inherit; }

/* usage: numbers in pixel type, bars that fill in steps */
.usage-section-title { font-family: var(--sp-px); font-size: 12px; font-weight: 400; color: var(--faint); text-transform: uppercase; -webkit-font-smoothing: none; letter-spacing: 0; }
.usage-tile { border: 1px solid var(--hairline); background: transparent; box-shadow: none; }
.usage-tile-label { font-family: var(--sp-px); font-size: 12px; color: var(--faint); -webkit-font-smoothing: none; }
.usage-tile-value { font-family: var(--sp-px); font-size: 24px; font-weight: 400; line-height: 1.2; color: var(--text-strong); -webkit-font-smoothing: none; letter-spacing: 0; }
.usage-bar-track { height: 10px; background: transparent; border: 1px solid var(--hairline-strong); }
.usage-bar-fill { background: repeating-linear-gradient(90deg, var(--text-strong) 0 6px, transparent 6px 8px); transition: width .5s steps(8, end); }
.usage-bar-name, .usage-bar-value { font-family: var(--sp-px); font-size: 12px; -webkit-font-smoothing: none; }

/* every page head: a pixel kicker line under the screen's edge */
#documents_browser_view .view-head, #filesView .view-head, #usageView .view-head, #documentView .view-head, #fileView .view-head { border-bottom: 1px solid var(--hairline); }
#usageTitle { font-family: var(--sp-px); font-size: 24px; font-weight: 400; -webkit-font-smoothing: none; letter-spacing: 0; }
@media (max-width: 760px) {
  #documentView .editor-split, #fileView .file-preview { margin: 8px; }
}
@media (prefers-reduced-motion: reduce) { .documents_browser_card, .usage-bar-fill { transition: none; } }
