/* ============================================================
   Agentic Coding 方法论演示 — 样式
   浅色极简 · mono 终端 · 参考 batonlink www 的 bl-term 观感
   ============================================================ */

:root {
  --bg: #f7f7f6;
  --bg-soft: #fbfbfa;
  --card: #ffffff;
  --border: #e6e6e2;
  --border-strong: #d6d6d0;
  --fg: #17171a;
  --muted: #6b6b73;
  --muted-2: #9a9aa2;
  --primary: #4f46e5;
  --primary-soft: #eef0fe;
  --accent: #0e9f6e; /* tool / ok green */
  --amber: #d97706;
  --red: #dc2626;
  --add-bg: rgba(14, 159, 110, 0.12);
  --add-fg: #087443;
  --del-bg: rgba(220, 38, 38, 0.1);
  --del-fg: #b42318;

  --mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas,
    "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Microsoft YaHei", sans-serif;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(17, 17, 26, 0.04),
    0 12px 32px -12px rgba(17, 17, 26, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.soft-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.6;
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: linear-gradient(to bottom, black, transparent 80%);
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Site header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: saturate(1.4) blur(8px);
  background: rgba(247, 247, 246, 0.82);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.brand small {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.8rem;
}
.nav {
  display: flex;
  gap: 4px;
  font-size: 0.8rem;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
}
.nav a:hover {
  color: var(--fg);
  background: rgba(0, 0, 0, 0.04);
}

/* ---------- Hero ---------- */
.hero {
  padding: 52px 0 44px;
  text-align: center;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 500;
}
.badge .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.hero h1 {
  margin: 22px auto 0;
  max-width: 18ch;
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 650;
}
.hero p.lead {
  margin: 18px auto 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: 1.08rem;
}

/* methodology pipeline */
.pipeline {
  margin: 34px auto 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 6px;
  max-width: 900px;
}
.pipe-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 1px 1px rgba(17, 17, 26, 0.03);
}
.pipe-chip .n {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 5px;
  padding: 1px 5px;
}
.pipe-arrow {
  color: var(--muted-2);
  font-size: 0.9rem;
}

/* ---------- Phase section ---------- */
.phase {
  padding: 60px 0;
  border-top: 1px solid var(--border);
}
.phase-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
}
.phase-index {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--mono);
  color: var(--muted-2);
  font-size: 0.8rem;
}
.phase-index b {
  color: var(--primary);
  font-size: 1rem;
}
.phase-head h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
  font-weight: 640;
}
.phase-head p.desc {
  margin: 0;
  max-width: 72ch;
  color: var(--muted);
}

/* ---------- Deck: one fixed-height window per phase ---------- */
/* multiple 幕 share one window and swap in place (crossfade); a pill bar
   below auto-advances with a progress fill and supports click-to-jump. */
.deck { position: relative; }
.deck-window {
  position: relative;
  height: clamp(645px, 90vh, 840px);
}
.deck-stage {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.deck-stage[data-active] {
  opacity: 1;
  pointer-events: auto;
}
/* the 幕's window fills the fixed height; its body scrolls internally */
.deck-stage > .terminal,
.deck-stage > .gui-app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* pills */
.deck-pills {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  padding: 0 8px;
}
.deck-pillbar {
  display: inline-flex;
  gap: 4px;
  max-width: 100%;
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 5px;
  box-shadow: var(--shadow);
  scrollbar-width: none;
}
.deck-pillbar::-webkit-scrollbar { display: none; }
.deck-pill {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 10px;
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: 0.77rem;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s ease;
}
.deck-pill:hover { color: var(--fg); }
.deck-pill[data-done] { color: var(--fg); }
.deck-pill[aria-selected="true"] { background: var(--fg); color: #fff; }
.deck-pill > :not(.deck-pill-progress) { position: relative; z-index: 1; }
.deck-pill-progress {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(255, 255, 255, 0.16);
  transform: scaleX(0);
  transform-origin: left;
}
.pl-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pl-dot.pm { background: #4f46e5; }
.pl-dot.tl { background: #0e9f6e; }
.pl-dot.eng { background: #d97706; }
.pl-dot.qa { background: #db2777; }
.pl-dot.oncall { background: #0891b2; }
.deck-pill[aria-selected="true"] .pl-dot { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25); }
.pl-n {
  font-family: var(--mono);
  font-size: 0.64rem;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0 5px;
  color: var(--muted);
}
.deck-pill[aria-selected="true"] .pl-n {
  background: rgba(255, 255, 255, 0.18);
  border-color: transparent;
  color: #fff;
}

/* caption: active 幕's role + handoff + rule-tag */
.deck-caption { margin-top: 14px; }
.deck-cap-item {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.deck-cap-item[data-active] { display: flex; }
.deck-cap-item .role-chip,
.deck-cap-item .handoff,
.deck-cap-item .rule-tag { align-self: center; }
/* role badge — 每一幕「谁的 Agent」 */
.role-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 999px;
  padding: 5px 13px 5px 6px;
  font-size: 0.84rem;
  box-shadow: 0 1px 1px rgba(17, 17, 26, 0.03);
}
.role-chip .av {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
}
.role-chip b { font-weight: 650; }
.role-chip .of { color: var(--muted); }
.role-chip.pm .av { background: #4f46e5; }
.role-chip.tl .av { background: #0e9f6e; }
.role-chip.eng .av { background: #d97706; }
.role-chip.oncall .av { background: #0891b2; }
.role-chip.owner .av { background: #8250df; }
.role-chip.qa .av { background: #db2777; }

.handoff {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  color: var(--muted-2);
}
.handoff .via {
  font-family: var(--mono);
  color: var(--primary);
}

.rule-tag {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 0.76rem;
  color: var(--muted);
  background: var(--bg-soft);
}
.rule-tag b {
  color: var(--fg);
  font-weight: 600;
}

.act-stage {
  display: grid;
  gap: 20px;
}

/* ---------- Terminal ---------- */
.terminal {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fff, #fcfcfb);
}
.term-bar .tb-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--border-strong);
}
.term-bar .tb-title {
  margin-left: 6px;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
}
.term-bar .tb-replay {
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 7px;
  padding: 3px 9px;
  font-size: 0.72rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s, border-color 0.15s;
}
.term-bar .tb-replay:hover {
  color: var(--fg);
  border-color: var(--border-strong);
}
.term-body {
  font-family: var(--mono);
  font-size: 0.83rem;
  line-height: 1.72;
  padding: 18px 20px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: auto; /* instant bottom-tracking during streaming */
}
.term-body::-webkit-scrollbar { width: 8px; }
.term-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
}

/* rows */
.t-row { animation: fade-up 0.34s ease both; }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.t-label {
  margin-top: 14px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.t-row:first-child.t-label { margin-top: 0; }

.t-user { color: var(--fg); word-break: break-word; }
.t-user .prompt { color: var(--primary); font-weight: 600; }

.t-think {
  color: var(--muted);
  font-style: italic;
}
.t-think .glyph { color: var(--muted-2); font-style: normal; }

.t-dim { color: var(--muted); }
.t-ok { color: var(--add-fg); font-weight: 600; }

/* tool call */
.t-tool {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--fg);
}
.t-tool .glyph {
  color: var(--accent);
  flex-shrink: 0;
}
.t-tool .spin {
  color: var(--accent);
  display: inline-block;
  width: 1ch;
}
.t-tool .tname { font-weight: 600; }
.t-tool .targ { color: var(--muted); word-break: break-all; }
.t-result {
  color: var(--muted);
  padding-left: 22px;
}
.t-result .arrow { color: var(--muted-2); }
.t-result b { color: var(--fg); font-weight: 600; }

/* paste block */
.t-paste {
  margin: 6px 0;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  color: var(--fg);
  white-space: pre-wrap;
  position: relative;
  animation: paste-in 0.5s ease both;
}
.t-paste .chip {
  position: absolute;
  top: -9px;
  right: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 0.64rem;
  font-weight: 600;
  border-radius: 5px;
  padding: 1px 7px;
  letter-spacing: 0.03em;
}
@keyframes paste-in {
  from { background: #dcdefb; }
  to { background: var(--primary-soft); }
}

/* output block */
.t-out { color: var(--fg); }
.t-out .o-h { font-weight: 700; margin-top: 4px; }
.t-out .o-p { color: var(--muted); }
.t-out .o-li { color: var(--fg); padding-left: 4px; }
.t-out .o-li .b { color: var(--accent); }
.t-out .o-q {
  color: var(--fg);
  border-left: 2px solid var(--amber);
  padding-left: 10px;
  margin: 2px 0;
}
.t-out .o-sub,
.g-out .go-sub {
  font-weight: 600;
  color: var(--primary);
  margin-top: 6px;
  font-size: 0.82rem;
}
/* acceptance criteria — boxed checklist, echoed in s6 */
.t-out .o-ac,
.g-out .go-ac {
  color: var(--fg);
  border-left: 2px solid var(--accent);
  background: var(--add-bg);
  border-radius: 0 6px 6px 0;
  padding: 3px 10px;
  margin: 2px 0;
}
.t-out .o-code,
.g-out .o-code,
.gh-body .o-code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  padding: 0 5px;
}

/* file write */
.t-file {
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.t-file .f-head {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  color: var(--fg);
  display: flex;
  gap: 7px;
}
.t-file .f-head .glyph { color: var(--primary); }
.t-file .f-body {
  padding: 8px 12px;
  color: var(--muted);
  white-space: pre-wrap;
}
.t-file .f-body .fl { display: block; animation: fade-up 0.2s ease both; }

/* diff */
.t-diff {
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.t-diff .d-head {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  display: flex;
  gap: 7px;
}
.t-diff .d-head .glyph { color: var(--muted); }
.t-diff .dl {
  display: block;
  padding: 0 12px;
  white-space: pre-wrap;
  animation: fade-up 0.16s ease both;
}
.t-diff .dl.add { background: var(--add-bg); color: var(--add-fg); }
.t-diff .dl.del { background: var(--del-bg); color: var(--del-fg); }
.t-diff .dl.ctx { color: var(--muted); }

/* cli output */
.t-cli .c-cmd { color: var(--fg); }
.t-cli .c-cmd .dollar { color: var(--accent); font-weight: 600; }
.t-cli .c-out {
  margin: 4px 0 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--bg-soft);
  white-space: pre-wrap;
  color: var(--muted);
}
.t-cli .c-out .cl { display: block; animation: fade-up 0.16s ease both; }
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.status-dot.ok { background: var(--accent); }
.status-dot.warn { background: var(--amber); }
.status-dot.crit { background: var(--red); }
.tag-ok { color: var(--add-fg); font-weight: 600; }
.tag-warn { color: var(--amber); font-weight: 600; }
.tag-crit { color: var(--red); font-weight: 600; }

/* link (batonlink) copy animation */
.t-link-row {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.t-link {
  color: var(--primary);
  word-break: break-all;
  border-radius: 3px;
  background-image: linear-gradient(rgba(79, 70, 229, 0.16), rgba(79, 70, 229, 0.16));
  background-repeat: no-repeat;
  background-size: 0% 100%;
  transition: background-size 0.6s ease;
}
.t-link.sel-on { background-size: 100% 100%; }
.t-copied {
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 0 7px;
  font-size: 0.7rem;
  line-height: 1.4rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.t-copied.show { opacity: 1; }

/* caret + spinner */
.caret {
  display: inline-block;
  width: 0.5rem;
  height: 1.05em;
  margin-left: 1px;
  transform: translateY(0.16em);
  background: currentColor;
  animation: blink 1.05s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* GitHub issue / PR card (collaboration medium) */
.t-gh-cmd { color: var(--fg); margin-top: 2px; }
.t-gh-cmd .dollar { color: var(--accent); font-weight: 600; }
.gh-card {
  margin: 6px 0 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
}
.gh-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.gh-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #fff;
}
.gh-state::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,0.9);
}
.gh-state.open { background: #1a7f37; }
.gh-state.done { background: #8250df; }
.gh-state.pr { background: #1a7f37; }
.gh-num { font-family: var(--mono); color: var(--muted-2); font-size: 0.78rem; }
.gh-title { font-weight: 650; color: var(--fg); flex: 1; min-width: 12ch; }
.gh-meta {
  padding: 8px 13px;
  color: var(--muted);
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border);
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
}
.gh-meta b { color: var(--fg); font-weight: 600; }
.gh-label {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--card);
}
.gh-label.hot { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.gh-body {
  padding: 11px 13px;
  color: var(--fg);
  white-space: pre-wrap;
}
.gh-body .gl { display: block; animation: fade-up 0.2s ease both; }
.gh-body .gl.dim { color: var(--muted); }
.gh-body .gl.head { font-weight: 650; margin-top: 4px; }
.gh-tasks { padding: 4px 13px 12px; }
.gh-task {
  display: flex; align-items: baseline; gap: 8px;
  padding: 3px 0;
  animation: fade-up 0.24s ease both;
}
.gh-task .box { color: var(--muted-2); }
.gh-task .box.checked { color: var(--accent); }
.gh-task .ref { font-family: var(--mono); color: var(--primary); font-size: 0.78rem; }
.gh-task .who {
  margin-left: auto;
  font-size: 0.72rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 5px;
}
.gh-task .who .av {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 0.62rem; font-weight: 700;
}
.gh-conf {
  color: var(--add-fg); font-weight: 600;
  display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap;
}
.gh-conf .url { color: var(--primary); font-weight: 400; word-break: break-all; }

/* team board (act 3) */
.team-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.team-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--card);
  font-size: 0.82rem;
}
.team-card .who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.team-card .who .av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
}
.team-card .phase { color: var(--muted); margin-top: 4px; }
.team-card .baton {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--primary);
  word-break: break-all;
}

/* ============================================================
   GUI agent (product manager) — 图形化界面，对比技术角色的终端
   窗口 chrome + session 栏 + 对话气泡 + 工具折叠 + issue 卡 + 动作卡 + 输入框
   ============================================================ */
.gui-app {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.gui-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fff, #fcfcfb);
}
.gui-chrome .gc-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--border-strong);
}
.gc-tabs {
  margin-left: 10px;
  display: inline-flex;
  gap: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.gc-tabs span {
  font-size: 0.72rem;
  color: var(--muted);
  padding: 2px 9px;
  border-radius: 6px;
}
.gc-tabs span.on {
  background: var(--card);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}
.gc-title {
  margin-left: 8px;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted-2);
}
.gc-replay {
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  border-radius: 7px;
  padding: 3px 9px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.gc-replay:hover {
  color: var(--fg);
  border-color: var(--border-strong);
}

.gui-main {
  display: flex;
  flex: 1;
  min-height: 0;
}
.gui-rail {
  width: 190px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 12px 10px;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.gr-item {
  color: var(--muted);
  padding: 6px 9px;
  border-radius: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gr-item.new { color: var(--fg); font-weight: 500; }
.gr-item.on {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.gr-sec {
  margin-top: 10px;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  padding: 0 9px;
}
.gr-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.76rem;
}
.gr-av {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #4f46e5;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.gui-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.gui-convo {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.62;
  scroll-behavior: auto; /* instant bottom-tracking during streaming */
}
.gui-convo::-webkit-scrollbar { width: 8px; }
.gui-convo::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
}
.gui-input {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
}
.gi-ph {
  flex: 1;
  color: var(--muted-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--bg-soft);
}
.gi-send {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* gui conversation rows */
.g-row { animation: fade-up 0.34s ease both; }
.g-crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 8px;
}
.g-crumb .ci {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  flex-shrink: 0;
}
.g-user { display: flex; }
.g-bubble {
  background: var(--primary-soft);
  color: var(--fg);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 5px 0;
  max-width: 94%;
  white-space: pre-wrap;
}
.g-bubble.paste {
  position: relative;
}
.g-bubble .g-chip {
  position: absolute;
  top: -9px;
  right: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  border-radius: 5px;
  padding: 1px 7px;
  letter-spacing: 0.03em;
}
/* voice memo bubble */
.g-voice {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-soft);
  border-radius: 14px;
  padding: 9px 14px;
  margin: 5px 0 0;
  max-width: 94%;
}
.gv-play {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.66rem;
  flex-shrink: 0;
}
.gv-wave {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 26px;
}
.gv-wave i {
  width: 2.5px;
  height: 40%;
  border-radius: 2px;
  background: var(--primary);
  opacity: 0.5;
  transform-origin: center;
}
.gv-wave.playing i {
  animation: gv-eq 0.9s ease-in-out infinite;
  opacity: 0.85;
}
.gv-dur {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--primary);
}
.gv-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 5px 0 2px;
  font-size: 0.74rem;
  color: var(--muted);
}
.gv-meta .gv-tag {
  background: var(--primary);
  color: #fff;
  border-radius: 5px;
  padding: 0 6px;
  font-size: 0.62rem;
  font-weight: 600;
}
@keyframes gv-eq {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

.g-think {
  color: var(--muted);
  font-style: italic;
  margin: 3px 0;
}
.g-think .g-glyph { color: var(--muted-2); font-style: normal; }
.g-tool {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--fg);
  margin: 3px 0;
}
.g-tool .g-spin,
.g-tool .g-done { color: var(--accent); width: 1ch; flex-shrink: 0; }
.g-tool .g-tname { font-weight: 600; }
.g-tool .g-targ { color: var(--muted); }
.g-tres {
  color: var(--muted);
  padding-left: 22px;
  margin-bottom: 3px;
}
.g-tres .arrow { color: var(--muted-2); }
.g-tres b { color: var(--fg); font-weight: 600; }
.g-work { color: var(--muted); margin: 3px 0; }
.g-work .g-spin { color: var(--primary); }
.g-work .g-done { color: var(--muted-2); }
.g-ok {
  color: var(--add-fg);
  font-weight: 600;
  margin-top: 8px;
}
.g-ok .g-done { color: var(--add-fg); }

/* gui assistant response */
.g-out { color: var(--fg); margin: 4px 0; }
.g-out .go-h { font-weight: 700; margin-top: 4px; }
.g-out .go-p { color: var(--muted); }
.g-out .go-li { color: var(--fg); padding-left: 4px; }
.g-out .go-li .b { color: var(--accent); }
.g-out .go-q {
  color: var(--fg);
  border-left: 2px solid var(--amber);
  padding-left: 10px;
  margin: 3px 0;
}
.g-out .go-quote {
  color: var(--muted);
  border-left: 2px solid var(--border-strong);
  padding-left: 10px;
  margin: 3px 0;
}
.g-out .go-quote b { color: var(--fg); font-weight: 600; }

/* gui graphical action (no CLI) */
.g-action {
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
}
.ga-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-weight: 600;
  color: var(--fg);
}
.ga-head .g-spin,
.ga-head .g-done { color: var(--primary); width: 1ch; flex-shrink: 0; }
.ga-conf {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  color: var(--add-fg);
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}
.ga-conf .ga-url {
  color: var(--primary);
  font-weight: 400;
  font-family: var(--mono);
  font-size: 0.78rem;
  word-break: break-all;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; }
  html { scroll-behavior: auto; }
}

@media (max-width: 640px) {
  .term-body { font-size: 0.76rem; }
  .gui-convo { font-size: 0.8rem; }
  .gui-rail { display: none; }
  .nav { display: none; }
}
