/* Atomic Feline — brand stylesheet (dark charcoal + atomic orange) */
:root {
  --bg: #121212;
  --bg-2: #1a1a1a;
  --bg-3: #202020;
  --card: #1a1a1a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f5f7;
  --muted: #a1a1a8;
  --faint: #6e6e75;
  --orange: #ff7a00;
  --amber: #ffb000;
  --orange-soft: rgba(255, 122, 0, 0.14);
  --green: #34d167;
  --red: #f0524d;
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--amber); text-decoration: none; }
button { font-family: var(--font); }

/* ---- orange radial blooms ---- */
.glow-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
}
.glow.g1 {
  width: 720px; height: 720px; top: -280px; left: -240px;
  background: radial-gradient(circle, rgba(255, 122, 0, 0.16) 0%, rgba(255, 122, 0, 0.05) 45%, transparent 70%);
}
.glow.g2 {
  width: 900px; height: 900px; top: 22%; right: -420px;
  background: radial-gradient(circle, rgba(255, 176, 0, 0.10) 0%, rgba(255, 122, 0, 0.04) 45%, transparent 70%);
}
.glow.g3 {
  width: 640px; height: 640px; bottom: -260px; left: 18%;
  background: radial-gradient(circle, rgba(255, 122, 0, 0.09) 0%, transparent 65%);
}

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-orange {
  background: linear-gradient(180deg, var(--amber) -40%, var(--orange) 60%);
  color: #1c0e00;
  box-shadow: 0 4px 24px rgba(255, 122, 0, 0.35);
}
.btn-orange:hover { box-shadow: 0 6px 32px rgba(255, 122, 0, 0.5); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { border-color: rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.06); }
.btn-sm { padding: 8px 18px; font-size: 13.5px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---- header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(18, 18, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--orange);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.01em;
}
.brand img { width: 34px; height: 34px; object-fit: contain; }
.header-actions { display: flex; align-items: center; gap: 12px; }

/* ---- landing ---- */
.landing-main { position: relative; z-index: 1; }
.hero {
  text-align: center;
  padding: 72px 24px 84px;
  max-width: 860px;
  margin: 0 auto;
}
.hero-logo {
  width: 300px;
  max-width: 72vw;
  height: auto;
  filter: drop-shadow(0 0 48px rgba(255, 122, 0, 0.35));
  margin-bottom: 8px;
}
.hero h1 {
  font-size: 56px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 12px 0 20px;
  color: var(--text);
}
.hero h1 .hl { color: var(--orange); }
.hero .subhead {
  color: var(--muted);
  font-size: 18px;
  max-width: 620px;
  margin: 0 auto 34px;
}
.hero-ctas { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.hero-note {
  margin-top: 26px;
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-green { background: var(--green); box-shadow: 0 0 8px rgba(52, 209, 103, 0.8); }
.dot-red { background: var(--red); box-shadow: 0 0 8px rgba(240, 82, 77, 0.8); }
.dot-gray { background: var(--faint); }
.dot-orange { background: var(--orange); box-shadow: 0 0 8px rgba(255, 122, 0, 0.8); }

.section { max-width: 1080px; margin: 0 auto; padding: 56px 24px; position: relative; z-index: 1; }
.section h2 { font-size: 34px; font-weight: 800; letter-spacing: -0.01em; text-align: center; margin: 0 0 10px; }
.section h2 .hl { color: var(--orange); }
.section .section-sub { text-align: center; color: var(--muted); margin: 0 auto 40px; max-width: 560px; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card {
  background: linear-gradient(180deg, #1d1d1d 0%, var(--card) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 26px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: rgba(255, 122, 0, 0.35); transform: translateY(-2px); }
.card .card-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--orange-soft);
  border: 1px solid rgba(255, 122, 0, 0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 21px;
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 8px; font-size: 19px; font-weight: 700; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; }

/* early access */
.early-access {
  background: linear-gradient(180deg, #1c1c1c 0%, #171717 100%);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 52px 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.early-access::before {
  content: "";
  position: absolute;
  width: 520px; height: 520px; top: -320px; left: 50%; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 122, 0, 0.18) 0%, transparent 65%);
  pointer-events: none;
}
.ea-form { display: flex; gap: 12px; justify-content: center; max-width: 480px; margin: 28px auto 0; }
.ea-form input {
  flex: 1;
  min-width: 0;
  background: #121212;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 12px 22px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
}
.ea-form input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.18); }
.ea-msg { margin-top: 16px; font-size: 14px; min-height: 20px; }
.ea-msg.ok { color: var(--green); }
.ea-msg.err { color: var(--red); }

/* footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 30px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  position: relative;
  z-index: 1;
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-brand img { width: 26px; height: 26px; }
.footer-brand .fb-name { color: var(--orange); font-weight: 700; font-size: 14px; }
.footer-brand .fb-tag { color: var(--faint); font-size: 12px; }

/* ---- auth (login) ---- */
.auth-wrap {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  position: relative;
  z-index: 1;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, #1d1d1d 0%, var(--card) 100%);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 40px 36px;
  text-align: center;
}
.auth-card .auth-logo { width: 130px; filter: drop-shadow(0 0 24px rgba(255, 122, 0, 0.35)); }
.auth-card h1 { font-size: 26px; font-weight: 800; margin: 12px 0 4px; }
.auth-card .auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 26px; }
.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.field input, .field textarea, .field select {
  width: 100%;
  background: #121212;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
}
.field textarea { resize: vertical; min-height: 110px; border-radius: 14px; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.18);
}
.auth-error { color: var(--red); font-size: 14px; min-height: 20px; margin: 4px 0 12px; }
.auth-foot { margin-top: 22px; font-size: 13px; color: var(--faint); }

/* ================= APP CONSOLE ================= */
.app-body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: rgba(24, 24, 24, 0.92);
  border-bottom: 1px solid var(--border);
  z-index: 30;
  flex: none;
}
.topbar .brand { font-size: 15px; }
.topbar .brand img { width: 28px; height: 28px; }
.topbar-agent { font-weight: 600; font-size: 14px; color: var(--text); display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.topbar-agent::before { content: "/"; color: var(--faint); font-weight: 400; }
.topbar-spacer { flex: 1; }
.health { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.icon-btn {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 10px;
  width: 36px; height: 36px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  cursor: pointer;
}
.topbar a.logout { color: var(--muted); font-size: 13px; white-space: nowrap; flex: none; }
.topbar a.logout:hover { color: var(--text); }

.topbar-agentic {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  max-width: 290px;
  flex: none;
  min-width: 0;
  position: relative;
}
.topbar-agentic #topbarAgentic {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- agentic switcher (multi-box dropdown) ---- */
.agentic-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 4px 8px;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
  max-width: 250px;
}
.agentic-btn:hover, .agentic-btn[aria-expanded="true"] {
  color: var(--text);
  border-color: rgba(255, 122, 0, 0.35);
  background: rgba(255, 122, 0, 0.07);
}
.agentic-btn .caret { font-size: 10px; color: var(--faint); flex: none; }
.agentic-btn:hover .caret, .agentic-btn[aria-expanded="true"] .caret { color: var(--orange); }

.agentic-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: -6px;
  min-width: 250px;
  max-width: 320px;
  background: linear-gradient(180deg, #212121 0%, #1a1a1a 100%);
  border: 1px solid rgba(255, 122, 0, 0.28);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(0, 0, 0, 0.4);
  padding: 6px;
  display: none;
  z-index: 70;
}
.agentic-menu.open { display: block; }
.am-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.am-item:hover { background: rgba(255, 255, 255, 0.05); }
.am-item.active { background: var(--orange-soft); border-color: rgba(255, 122, 0, 0.35); }
.am-item .am-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.am-item.am-add {
  color: var(--amber);
  font-weight: 600;
  border-top: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  margin-top: 4px;
  padding-top: 10px;
}
.am-item.am-add:hover { background: var(--orange-soft); }

.btn-danger { color: var(--red); border-color: rgba(240, 82, 77, 0.4); }
.btn-danger:hover { border-color: var(--red); background: rgba(240, 82, 77, 0.08); }
.modal-actions-spacer { flex: 1; }
.lock-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--amber);
  background: var(--orange-soft);
  border: 1px solid rgba(255, 122, 0, 0.4);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
  flex: none;
}
.icon-btn.gear-btn { display: inline-flex; font-size: 16px; color: var(--muted); }
.icon-btn.gear-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.28); }

.modal-sub { color: var(--muted); font-size: 13.5px; margin: -10px 0 18px; }
.field-help { color: var(--faint); font-size: 12px; margin-top: 6px; }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 16px);
  background: #232323;
  border: 1px solid rgba(255, 122, 0, 0.5);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 80;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { border-color: var(--amber); color: var(--amber); }

/* ---- AF_UNREAD: clickable "agent finished" toast (stacks above #toast) ---- */
.toast-finish {
  bottom: 74px;
  cursor: pointer;
  font-family: inherit;
}
.toast-finish.visible { pointer-events: auto; }
.toast-finish:hover { border-color: var(--orange); background: #2a2420; }
/* green-phosphor variant while the chat is in CRT mode */
body.crt-chat .toast-finish {
  background: #0a140c;
  border-color: rgba(51, 255, 102, 0.55);
  color: var(--crt-green);
  text-shadow: var(--crt-glow);
  font-family: var(--crt-mono);
}
body.crt-chat .toast-finish:hover { border-color: var(--crt-bright); background: #0e1a10; }

/* ---- Agentic Brain figure ---- */
.brain-fig {
  display: flex;
  justify-content: center;
  margin: 4px 0 10px;
}
.bf-brain, .bf-glowbg {
  transform-box: fill-box;
  transform-origin: center;
  animation: brainPulse 3s ease-in-out infinite;
}
.bf-glowbg { animation-name: glowPulse; }
.bf-orbit { transform-box: fill-box; transform-origin: center; }
.bf-orbit1 { animation: orbitSpin 8s linear infinite; }
.bf-orbit2 { animation: orbitSpin 12s linear infinite reverse; }
.brain-fig.thinking .bf-brain,
.brain-fig.thinking .bf-glowbg { animation-duration: 1.1s; }
.brain-fig.flash .bf-brain {
  animation: brainFlash 0.6s ease-out, brainPulse 3s ease-in-out infinite;
}
@keyframes brainPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.06); opacity: 1; }
}
@keyframes glowPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes orbitSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes brainFlash {
  0% { filter: brightness(1); }
  25% { filter: brightness(2.4) drop-shadow(0 0 20px rgba(255, 176, 0, 0.95)); }
  100% { filter: brightness(1); }
}

/* topbar mini-brain — the box's "alive" indicator */
.mini-brain { flex: none; overflow: visible; }
.mini-brain .mb-dot {
  transform-box: fill-box;
  transform-origin: center;
  animation: brainPulse 3s ease-in-out infinite;
}
.mini-brain .mb-orbit {
  transform-box: fill-box;
  transform-origin: center;
  animation: orbitSpin 8s linear infinite;
}
.mini-brain.dead .mb-dot, .mini-brain.dead .mb-orbit { animation-play-state: paused; }
.mini-brain.dead .mb-dot { fill: #6e6e75; }
.mini-brain.dead .mb-orbit ellipse { stroke: rgba(255, 255, 255, 0.18); }
.mini-brain.dead .mb-electron { fill: #6e6e75; }

@media (prefers-reduced-motion: reduce) {
  .bf-brain, .bf-glowbg, .bf-orbit1, .bf-orbit2,
  .mini-brain .mb-dot, .mini-brain .mb-orbit { animation: none !important; }
}

/* ---- Wiki (auto-updating skills directory) ---- */
.icon-btn.wiki-btn { display: inline-flex; font-size: 15px; color: var(--muted); }
.icon-btn.wiki-btn:hover, .icon-btn.wiki-btn.active { color: var(--text); border-color: rgba(255, 122, 0, 0.5); }

.wiki-view { flex: 1; display: none; min-height: 0; }
.wiki-view.visible { display: flex; }
.panes.hidden { display: none; }

/* ---- Table of Contents rail (persistent left) ---- */
.wiki-toc {
  width: 260px;
  flex: none;
  border-right: 1px solid var(--border);
  background: #161616;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.wiki-toc .pane-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wiki-toc #wikiTocTitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiki-toc-note {
  padding: 4px 16px 10px;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.wiki-toc-list { display: flex; flex-direction: column; gap: 4px; padding: 0 10px; }
.wiki-toc-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
}
.wiki-toc-item:hover { background: rgba(255, 255, 255, 0.04); }
.wiki-toc-item.active { background: var(--orange-soft); border-color: rgba(255, 122, 0, 0.35); }
.wiki-toc-item .wt-num { color: var(--orange); font-weight: 800; min-width: 16px; }
.wiki-toc-item.active .wt-label { color: var(--orange); }

/* ---- Section container + a single active section ---- */
.wiki-sections { flex: 1; min-width: 0; min-height: 0; display: flex; }
.wiki-section { flex: 1; min-width: 0; min-height: 0; display: none; flex-direction: column; }
.wiki-section.active { display: flex; }
.wiki-toc-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; }
.wiki-view.in-section .wiki-toc-placeholder { display: none; }
.wiki-section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 122, 0, 0.05);
}
.wiki-section-title { font-size: 16px; font-weight: 800; color: var(--text); }
.wiki-section-title .wt-num { color: var(--orange); }
.wiki-toc-back { display: inline-block; } /* returns to the pure table of contents */
.wiki-skills-split { flex: 1; display: flex; min-width: 0; min-height: 0; }

.wiki-list-pane {
  width: 320px;
  flex: none;
  border-right: 1px solid var(--border);
  background: #161616;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.wiki-search { padding: 12px 12px 10px; }
.wiki-search input {
  width: 100%;
  background: #121212;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 9px 16px;
  color: var(--text);
  font-size: 13.5px;
  font-family: var(--font);
  outline: none;
}
.wiki-search input:focus { border-color: var(--orange); }
.wiki-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.wiki-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  margin-bottom: 2px;
  color: var(--text);
}
.wiki-item:hover { background: rgba(255, 255, 255, 0.04); }
.wiki-item.active { background: var(--orange-soft); border-color: rgba(255, 122, 0, 0.35); }
.wiki-item .wi-name { color: var(--orange); font-weight: 600; font-size: 14px; }
.wiki-item .wi-desc {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wiki-item .wi-updated { color: var(--faint); font-size: 10.5px; margin-top: 3px; }

.wiki-page-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.wiki-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 12.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 122, 0, 0.05);
}
.wiki-back { display: none; }
.wiki-page { flex: 1; overflow-y: auto; padding: 26px 34px 50px; max-width: 860px; }
.wiki-page h1.wp-title { font-size: 28px; font-weight: 800; margin: 0 0 4px; }
.wiki-page .wp-sub { color: var(--muted); font-size: 14.5px; margin: 0 0 24px; }

/* rendered markdown */
.md { font-size: 14.5px; line-height: 1.65; color: var(--text); }
.md h1, .md h2, .md h3, .md h4 { color: var(--text); line-height: 1.25; margin: 26px 0 10px; }
.md h1 { font-size: 22px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.md h2 { font-size: 18px; }
.md h3 { font-size: 15.5px; color: var(--amber); }
.md h4 { font-size: 14px; }
.md p { margin: 10px 0; }
.md a { color: var(--amber); text-decoration: underline; text-decoration-color: rgba(255, 176, 0, 0.35); }
.md code {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--amber);
}
.md pre {
  background: #0e0e0e;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 14px 0;
}
.md pre code { background: none; border: none; padding: 0; color: #e8e8ec; font-size: 12.5px; line-height: 1.55; }
.md ul, .md ol { margin: 10px 0; padding-left: 26px; }
.md li { margin: 4px 0; }
.md table { border-collapse: collapse; margin: 14px 0; width: 100%; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--border-strong); padding: 7px 12px; text-align: left; }
.md th { background: rgba(255, 122, 0, 0.08); color: var(--amber); font-weight: 700; }
.md tr:nth-child(even) td { background: rgba(255, 255, 255, 0.02); }
.md blockquote { border-left: 3px solid var(--orange); margin: 12px 0; padding: 2px 16px; color: var(--muted); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.wiki-files { margin-top: 34px; border-top: 1px solid var(--border); padding-top: 14px; }
.wiki-files summary { cursor: pointer; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.wiki-files summary:hover { color: var(--text); }
.wiki-files pre {
  background: #0e0e0e;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--faint);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.6;
  margin-top: 10px;
  overflow-x: auto;
}

/* ---- Section 2: Agentic Memory ---- */
.wiki-memory { flex: 1; overflow-y: auto; padding: 24px 34px 50px; max-width: 900px; }
.wiki-memory-note { color: var(--muted); font-size: 14px; margin: 0 0 22px; font-style: italic; }
.wiki-memory-groups { display: flex; flex-direction: column; gap: 16px; }
.mem-group { border: 1px solid var(--border); border-radius: 14px; background: #161616; overflow: hidden; }
.mem-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 12px 18px;
  list-style: none;
  user-select: none;
}
.mem-group-head::-webkit-details-marker { display: none; }
.mem-group-head::before {
  content: '▸';
  color: var(--orange);
  font-size: 12px;
  transition: transform 0.15s ease;
}
.mem-group[open] .mem-group-head::before { transform: rotate(90deg); }
.mem-group-title { font-size: 15px; font-weight: 800; color: var(--orange); letter-spacing: 0.02em; }
.mem-count { color: var(--faint); font-size: 12px; }
.mem-group-body { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 12px; }
.mem-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: 12px;
  background: #121212;
  padding: 14px 18px;
}
.mem-period { color: var(--amber); font-weight: 700; font-size: 13.5px; margin-bottom: 6px; letter-spacing: 0.01em; }
.mem-abstract { font-size: 14px; }
.mem-abstract > :first-child { margin-top: 0; }
.mem-abstract > :last-child { margin-bottom: 0; }
.mem-empty { text-align: left; padding: 8px 4px; }

.auth-banner {
  display: none;
  background: linear-gradient(90deg, rgba(255, 122, 0, 0.22), rgba(255, 122, 0, 0.1));
  border-bottom: 1px solid rgba(255, 122, 0, 0.45);
  padding: 10px 18px;
  font-size: 14px;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  z-index: 25;
  flex: none;
}
.auth-banner.visible { display: flex; }
.auth-banner .ab-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-banner input {
  background: #121212;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--text);
  font-size: 13px;
  width: 150px;
  outline: none;
}
.auth-banner a { font-weight: 600; word-break: break-all; }

.panes { flex: 1; display: flex; min-height: 0; }

/* left: agents */
.pane-agents {
  width: 240px;
  flex: none;
  border-right: 1px solid var(--border);
  background: #161616;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pane-title {
  padding: 14px 16px 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.agent-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.agent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
}
.agent-item:hover { background: rgba(255, 255, 255, 0.04); }
.agent-item.active { background: var(--orange-soft); border-color: rgba(255, 122, 0, 0.35); }
.agent-swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); flex: none; }
/* alive = glowing green pulse (box reachable + healthy) */
.agent-swatch.alive {
  background: #27f06a;
  box-shadow: 0 0 4px #27f06a, 0 0 9px rgba(39,240,106,0.7);
  animation: alivePulse 2s ease-in-out infinite;
}
@keyframes alivePulse {
  0%, 100% { box-shadow: 0 0 3px #27f06a, 0 0 7px rgba(39,240,106,0.55); opacity: 0.82; }
  50%      { box-shadow: 0 0 6px #27f06a, 0 0 13px rgba(39,240,106,0.9); opacity: 1; }
}
/* offline = dim gray, no pulse */
.agent-swatch.offline { background: #4a4a52; box-shadow: none; animation: none; }
@media (prefers-reduced-motion: reduce) { .agent-swatch.alive { animation: none; } }
.agent-item .agent-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* AF_UNREAD: count badge on the agent tab — unread finished conversations */
.agent-item .agent-unread {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--orange);
  color: #141414;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  animation: badgePulse 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .agent-item .agent-unread { animation: none; } }
.agent-item .agent-edit,
.agent-item .agent-delete { flex: none; opacity: 0; font-size: 13px; transition: opacity .12s, transform .12s; cursor: pointer; }
.agent-item .agent-edit { color: var(--orange); }
.agent-item .agent-delete { font-size: 12.5px; }
.agent-item:hover .agent-edit { opacity: .7; }
.agent-item:hover .agent-delete { opacity: .55; }
.agent-item .agent-edit:hover,
.agent-item .agent-delete:hover { opacity: 1; transform: scale(1.2); }
.pane-foot { padding: 12px; border-top: 1px solid var(--border); }
.pane-foot .btn { width: 100%; }
/* external agents section — sits below the main agent list, capped height */
.pane-title-ext { border-top: 1px solid var(--border); padding-top: 12px; }
.agent-list-ext { flex: none; max-height: 30vh; overflow-y: auto; }

/* center: conversations / chat */
.pane-center { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.center-list { flex: 1; overflow-y: auto; padding: 22px; max-width: 760px; width: 100%; margin: 0 auto; }
.center-list h2 { font-size: 20px; margin: 0 0 4px; }
.center-list .cl-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }
.convo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px 18px;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 10px;
  font-size: 14.5px;
}
.convo-item:hover { border-color: rgba(255, 122, 0, 0.4); }
.convo-item .ci-title { font-weight: 600; }
.convo-item .ci-meta { color: var(--faint); font-size: 12px; flex: none; }
.convo-item .ci-delete { flex: none; opacity: .5; margin-left: 8px; font-size: 15px; transition: opacity .12s, transform .12s; cursor: pointer; }
.convo-item:hover .ci-delete { opacity: .85; }
.convo-item .ci-delete:hover { opacity: 1; transform: scale(1.2); }
.convo-item .ci-rename { flex: none; opacity: 0; margin-left: auto; color: var(--orange); font-size: 14px; transition: opacity .12s, transform .12s; cursor: pointer; }
.convo-item:hover .ci-rename { opacity: .7; }
.convo-item .ci-rename:hover { opacity: 1; transform: scale(1.2); }
/* AF_UNREAD: dot on a conversation row with a finished, not-yet-viewed reply */
.convo-item .ci-unread {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--orange);
  display: none;
}
.convo-item.unread { border-color: rgba(255, 122, 0, 0.45); }
.convo-item.unread .ci-unread { display: inline-block; animation: unreadPulse 1.8s ease-in-out infinite; }
@keyframes unreadPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 0, 0.55); }
  50% { box-shadow: 0 0 0 5px rgba(255, 122, 0, 0); }
}
@media (prefers-reduced-motion: reduce) { .convo-item.unread .ci-unread { animation: none; } }
.empty-note { color: var(--faint); font-size: 14px; text-align: center; padding: 40px 10px; }

/* chat view */
.chat-view { flex: 1; display: none; flex-direction: column; min-height: 0; }
.chat-view.visible { display: flex; }
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #161616;
  flex: none;
}
.chat-header .ch-title { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.chat-header .ch-title:hover { color: var(--orange); }
.icon-btn.ch-rename { display: inline-flex; align-items: center; justify-content: center; font-size: 14px; color: var(--orange); opacity: .55; flex: none; }
.icon-btn.ch-rename:hover { opacity: 1; border-color: rgba(255, 122, 0, 0.5); }
#chatDelete { display: inline-flex; align-items: center; justify-content: center; font-size: 15px; color: #ff6b5e; border-color: rgba(255, 90, 78, 0.4); flex: none; }
#chatDelete:hover { color: #fff; background: #d83a2c; border-color: #d83a2c; }
.back-btn { background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.back-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.model-select {
  background: #121212;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-family: var(--font);
  outline: none;
  cursor: pointer;
}
.model-select:focus { border-color: var(--orange); }

.messages { flex: 1; overflow-y: auto; padding: 22px 18px; }
.messages-inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 12px 16px; border-radius: 16px; font-size: 14.5px; word-wrap: break-word; }

/* rendered markdown inside a message bubble */
.msg .md { white-space: normal; }
.msg .md > :first-child { margin-top: 0; }
.msg .md > :last-child { margin-bottom: 0; }
.msg .md p { margin: 0 0 10px; }
.msg .md ul, .msg .md ol { margin: 6px 0 10px; padding-left: 22px; }
.msg .md li { margin: 3px 0; }
.msg .md h1, .msg .md h2, .msg .md h3 { margin: 12px 0 6px; line-height: 1.25; }
.msg .md h1 { font-size: 19px; } .msg .md h2 { font-size: 17px; } .msg .md h3 { font-size: 15px; }
.msg .md strong { color: #fff; font-weight: 700; }
.msg .md a { color: var(--amber); text-decoration: underline; }
.msg .md code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; background: #0d0d0d; border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.msg .md pre { background: #0a0a0a; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 8px 0; }
.msg .md pre code { background: none; border: none; padding: 0; font-size: 12.5px; color: #e6e6e6; }
.msg .md blockquote { margin: 8px 0; padding: 2px 0 2px 14px; border-left: 2px solid rgba(255,122,0,0.5); color: var(--muted); }
.msg .md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.msg .md th, .msg .md td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; }
.msg .md hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* WarGames terminal type-on */
.msg.assistant.typing { cursor: pointer; }
.msg.assistant .type-pre {
  margin: 0; white-space: pre-wrap; word-wrap: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px; line-height: 1.5; color: #ffd9a8;
  text-shadow: 0 0 6px rgba(255, 145, 40, 0.35);
}
.msg.assistant.typing .type-pre::after {
  content: "▊"; color: var(--amber); margin-left: 1px;
  animation: af-caret 1s steps(1) infinite; text-shadow: 0 0 8px rgba(255,176,0,0.7);
}
@keyframes af-caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .msg.assistant .type-pre::after { animation: none; } }
.msg.user {
  align-self: flex-end;
  background: #262626;
  border: 1px solid var(--border);
  border-bottom-right-radius: 6px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-bottom-left-radius: 6px;
}
.tool-chip {
  align-self: flex-start;
  font-size: 12px;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: default;
  max-width: 82%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-chip .tc-name { color: var(--muted); font-weight: 600; }

.composer { padding: 14px 18px 18px; border-top: 1px solid var(--border); flex: none; background: var(--bg); }
.composer-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }

/* paperclip attach button in the composer */
.icon-btn.attach-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 44px;
  font-size: 18px;
  color: var(--muted);
  border-radius: 14px;
}
.icon-btn.attach-btn:hover { color: var(--orange); border-color: rgba(255, 122, 0, 0.5); }

/* pending attachment chips above the composer input */
.attach-chips { max-width: 760px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px; }
.attach-chips:not(:empty) { margin-bottom: 10px; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 5px 8px 5px 6px;
  font-size: 12.5px;
  color: var(--text);
  max-width: 240px;
}
.attach-chip.uploading { opacity: 0.7; border-style: dashed; }
.attach-chip .ac-thumb {
  width: 30px; height: 30px; flex: none;
  border-radius: 7px; object-fit: cover;
  background: #0d0d0d; border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--amber);
}
.attach-chip .ac-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip .ac-spin {
  width: 13px; height: 13px; flex: none;
  border: 2px solid rgba(255, 176, 0, 0.3);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: ac-spin 0.7s linear infinite;
}
@keyframes ac-spin { to { transform: rotate(360deg); } }
.attach-chip .ac-remove {
  flex: none;
  cursor: pointer;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
}
.attach-chip .ac-remove:hover { color: #fff; background: #d83a2c; }

/* attached-file thumbnail row inside a user message bubble */
.msg .attach-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.msg .attach-row .ar-item {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.25); border: 1px solid var(--border);
  border-radius: 9px; padding: 3px 8px 3px 4px; font-size: 11.5px; color: var(--muted);
  max-width: 200px;
}
.msg .attach-row .ar-thumb {
  width: 26px; height: 26px; flex: none; border-radius: 6px; object-fit: cover;
  background: #0d0d0d; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--amber);
}
.msg .attach-row .ar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Stop / interrupt button (red) — chat header + console */
.stop-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(240, 82, 77, 0.12);
  border: 1px solid rgba(240, 82, 77, 0.5);
  color: #ff6b5e;
  font: 600 12.5px/1 var(--font);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.stop-btn:hover { background: #d83a2c; border-color: #d83a2c; color: #fff; box-shadow: 0 4px 18px rgba(216, 58, 44, 0.45); }
.stop-btn .stop-glyph { font-size: 10px; }
.stop-btn.flashing { animation: stop-flash 0.5s ease; }
@keyframes stop-flash {
  0% { box-shadow: 0 0 0 0 rgba(240, 82, 77, 0.7); }
  100% { box-shadow: 0 0 0 14px rgba(240, 82, 77, 0); }
}
/* prominent Stop floating in the console pane */
.stop-btn-console {
  position: sticky;
  top: 0;
  float: right;
  margin: 0 0 8px 8px;
  z-index: 3;
  padding: 9px 18px;
  font-size: 13px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.stop-btn-console .stop-glyph { font-size: 11px; }

/* full-pane drag overlay (chat + viewer) */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(18, 18, 18, 0.82);
  backdrop-filter: blur(1.5px);
  pointer-events: none;
}
.drop-overlay.visible { display: flex; }
.drop-inner {
  border: 2.5px dashed var(--orange);
  border-radius: 20px;
  padding: 34px 48px;
  text-align: center;
  background: rgba(255, 122, 0, 0.06);
  box-shadow: 0 0 40px rgba(255, 122, 0, 0.25);
}
.drop-inner .drop-icon { font-size: 40px; margin-bottom: 8px; }
.drop-inner .drop-text { color: var(--amber); font-weight: 700; font-size: 16px; letter-spacing: 0.02em; }
/* chat view + viewer stage need positioning context for the overlay */
.chat-view { position: relative; }
/* wraps the textarea so the CRT mirror can overlay it exactly */
.composer-field { flex: 1; min-width: 0; position: relative; display: flex; }
.composer textarea {
  flex: 1;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 12px 18px;
  color: var(--text);
  font-size: 14.5px;
  font-family: var(--font);
  resize: none;
  outline: none;
  max-height: max(160px, 40vh); /* grows tall on big screens; JS keeps the caret in view */
  line-height: 1.45;
}
.composer textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.15); }

/* CRT terminal input mirror — hidden entirely in modern mode */
.crt-input-mirror { display: none; }

/* ---- "Claude is asking" — inline interactive prompt card above the composer ---- */
.ask-card {
  display: none;
  flex: none;
  margin: 0 18px 8px;
  padding: 12px 14px;
  border: 1px solid var(--orange);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.10);
  max-height: 45vh;
  overflow-y: auto;
}
.ask-card.visible { display: block; }
/* pane visible = answer there; external agents are monitor-only */
.chat-view.console-mode .ask-card, .chat-view.external-mode .ask-card { display: none; }
.ask-card.answering { opacity: 0.55; pointer-events: none; }
.ask-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ask-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange);
}
.ask-terminal {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}
.ask-terminal:hover { color: var(--text); }
.ask-question { font-size: 13.5px; line-height: 1.5; margin-bottom: 10px; color: var(--text); }
.ask-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.ask-opt {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}
.ask-opt:hover { border-color: var(--orange); background: rgba(255, 122, 0, 0.06); }
.ask-opt.selected { border-color: var(--orange); }
.ask-num { flex: none; font-weight: 700; color: var(--orange); min-width: 14px; }
.ask-opt-label { flex: 1; }
.ask-free { display: flex; gap: 8px; }
.ask-free input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.ask-free input:focus { border-color: var(--orange); }

/* CRT mode: the card reads as part of the green tube */
body.crt-chat #chatView .ask-card {
  background: rgba(51, 255, 102, 0.04);
  border-color: rgba(51, 255, 102, 0.55);
  box-shadow: 0 0 14px rgba(51, 255, 102, 0.12);
  font-family: var(--crt-mono);
}
body.crt-chat #chatView .ask-label { color: var(--crt-bright); text-shadow: var(--crt-glow-strong); }
body.crt-chat #chatView .ask-terminal { color: rgba(51, 255, 102, 0.7); }
body.crt-chat #chatView .ask-terminal:hover { color: var(--crt-bright); }
body.crt-chat #chatView .ask-question { color: var(--crt-green); text-shadow: var(--crt-glow); font-family: var(--crt-mono); }
body.crt-chat #chatView .ask-opt {
  background: none;
  border-color: rgba(51, 255, 102, 0.35);
  color: var(--crt-green);
  text-shadow: var(--crt-glow);
  font-family: var(--crt-mono);
}
body.crt-chat #chatView .ask-opt:hover,
body.crt-chat #chatView .ask-opt.selected { border-color: var(--crt-green); background: rgba(51, 255, 102, 0.10); }
body.crt-chat #chatView .ask-num { color: var(--crt-bright); text-shadow: var(--crt-glow-strong); }
body.crt-chat #chatView .ask-free input {
  background: none;
  border-color: rgba(51, 255, 102, 0.35);
  color: var(--crt-green);
  font-family: var(--crt-mono);
}
body.crt-chat #chatView .ask-free input:focus { border-color: var(--crt-green); }
body.crt-chat #chatView .ask-free .ask-free-send {
  background: none;
  color: var(--crt-green);
  border: 1px solid rgba(51, 255, 102, 0.6);
  text-shadow: var(--crt-glow);
  font-family: var(--crt-mono);
}

/* failed optimistic send — a subtle red-ish affix under the echoed line */
.msg.user.send-failed { opacity: 0.85; }
.send-fail-affix {
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: #ff6b5e;
  letter-spacing: 0.02em;
}
body.crt-chat #chatView .send-fail-affix {
  color: #ff5a4a;
  font-family: var(--crt-mono);
  text-shadow: 0 0 6px rgba(255, 90, 74, 0.6);
}

/* ---- console view (the "I miss tmux" toggle) ---- */
.icon-btn.console-toggle {
  display: inline-flex;
  width: 30px; height: 28px;
  flex: none;
  border-radius: 8px;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--muted);
}
.icon-btn.console-toggle:hover { color: var(--text); border-color: rgba(255, 122, 0, 0.5); }
.icon-btn.console-toggle.active {
  color: var(--orange);
  border-color: rgba(255, 122, 0, 0.6);
  background: rgba(255, 122, 0, 0.1);
}

.console-pane {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none; /* we manage scroll ourselves — keep the user's spot */
  background: #0a0a0a;
  padding: 14px 18px 20px;
  outline: none;
  position: relative;
  border: 1.5px solid transparent;
  border-radius: 10px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.chat-view.console-mode .messages { display: none; }
.chat-view.console-mode .console-pane { display: block; }

/* ===== external-agent monitor mode: read-only, no chat ===== */
/* Clear button lives only in monitor mode */
.chat-header .ch-clear { display: none; flex: none; padding: 6px 14px; }
.chat-view.external-mode #chatClear { display: inline-flex; }
/* No composer, no rename/delete, no interactive console hint when monitoring */
.chat-view.external-mode .composer { display: none; }
.chat-view.external-mode #chatRename,
.chat-view.external-mode #chatDelete { display: none; }
.chat-view.external-mode .console-hint { display: none; }
/* focus ring — the pane is capturing keystrokes (orange glow) */
.console-pane.focused {
  border-color: rgba(255, 122, 0, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255, 122, 0, 0.25), 0 0 0 3px rgba(255, 122, 0, 0.18), 0 0 22px rgba(255, 122, 0, 0.15);
}

/* live "click to type / Esc-hold to release" hint, pinned top-left */
.console-hint {
  position: sticky;
  top: 0;
  z-index: 3;
  float: right; /* keeps it out of the pre's flow, right of the Stop button */
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: -4px 0 8px 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid var(--border);
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: var(--muted);
  -webkit-user-select: none;
  user-select: none;
}
.console-live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 7px rgba(52, 209, 103, 0.8);
  flex: none;
  animation: consoleLivePulse 1.8s ease-in-out infinite;
}
@keyframes consoleLivePulse { 50% { opacity: 0.35; } }
.console-hint-focused { display: none; color: var(--orange); }
.console-release { display: none; }
.console-pane.focused .console-live-dot { background: var(--orange); box-shadow: 0 0 7px rgba(255, 122, 0, 0.9); }
.console-pane.focused .console-hint { border-color: rgba(255, 122, 0, 0.5); }
.console-pane.focused .console-hint-idle { display: none; }
.console-pane.focused .console-hint-focused { display: inline; }
.console-pane.focused .console-release {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  padding: 1px 8px;
  border: 1px solid rgba(255, 122, 0, 0.5);
  border-radius: 999px;
  background: transparent;
  color: var(--orange);
  font: inherit;
  cursor: pointer;
}
.console-pane.focused .console-release:hover { background: var(--orange-soft); }
@media (prefers-reduced-motion: reduce) { .console-live-dot { animation: none; } }
.console-pane pre {
  margin: 0;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #cfe0cf; /* subtle green-tinted terminal text */
  white-space: pre-wrap;
  word-break: break-word;
}
.console-pane pre::after {
  content: "\258A"; /* ▊ blinking block caret */
  color: var(--orange);
  margin-left: 2px;
  animation: caretBlink 1.1s steps(1) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }
.console-dead {
  display: none;
  margin-top: 12px;
  padding: 6px 12px;
  border: 1px solid rgba(240, 82, 77, 0.4);
  border-radius: 8px;
  color: var(--red);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.console-dead.visible { display: inline-block; }

/* ---- the Viewer (agent-driven canvas) ---- */
.icon-btn.viewer-btn { display: inline-flex; font-size: 15px; color: var(--muted); position: relative; }
.icon-btn.viewer-btn:hover, .icon-btn.viewer-btn.active { color: var(--text); border-color: rgba(255, 122, 0, 0.5); }
.icon-btn.viewer-btn.active { color: var(--orange); }
.viewer-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--orange);
  display: none;
}
.viewer-btn.has-new .viewer-badge { display: block; animation: badgePulse 1.2s ease-in-out infinite; }
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 0, 0.65); }
  50% { box-shadow: 0 0 0 6px rgba(255, 122, 0, 0); }
}

/* drag-to-resize handle (left edge of the viewer) — desktop only */
.viewer-resize {
  flex: none;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 6;
  display: none;
  touch-action: none;
  align-self: stretch;
}
.panes.viewer-open .viewer-resize { display: block; }
.viewer-resize::before {
  content: "";
  position: absolute;
  inset: 0 2px;
  border-radius: 3px;
  background: transparent;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.viewer-resize:hover::before,
.viewer-resize.dragging::before {
  background: linear-gradient(180deg, rgba(255, 176, 0, 0.55), rgba(255, 122, 0, 0.55));
  box-shadow: 0 0 12px rgba(255, 122, 0, 0.45);
}

/* drag-to-resize handle (left edge of the automations panel) — desktop only.
   Mirrors the viewer handle; only shown on desktop when the panel is open. */
.autos-resize {
  flex: none;
  width: 6px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 6;
  display: none;
  touch-action: none;
  align-self: stretch;
}
.autos-resize::before {
  content: "";
  position: absolute;
  inset: 0 2px;
  border-radius: 3px;
  background: transparent;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.autos-resize:hover::before,
.autos-resize.dragging::before {
  background: linear-gradient(180deg, rgba(255, 176, 0, 0.55), rgba(255, 122, 0, 0.55));
  box-shadow: 0 0 12px rgba(255, 122, 0, 0.45);
}

.pane-viewer {
  width: var(--viewer-w, 380px);
  flex: none;
  border-left: 1px solid var(--border);
  background: #161616;
  display: none;
  flex-direction: column;
  min-height: 0;
}
.panes.viewer-open .pane-viewer { display: flex; }
.viewer-titlebar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 10px 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.vt-text { flex: 1; min-width: 0; }
.vt-title { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vt-note { color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }

/* CRT on/off toggle pill in the titlebar */
.crt-toggle {
  flex: none;
  align-self: center;
  font: 700 10px/1 var(--font);
  letter-spacing: 0.12em;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.crt-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.pane-viewer:not(.crt-off) .crt-toggle {
  color: var(--amber);
  border-color: rgba(255, 176, 0, 0.5);
  background: rgba(255, 122, 0, 0.1);
  box-shadow: 0 0 10px rgba(255, 122, 0, 0.28);
}

/* stage wraps the scrollable content + the CRT overlay layers */
.viewer-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.viewer-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 0.24s ease;
}
.viewer-body.booting { opacity: 0; }

/* ---- persistent CRT texture (scanlines + vignette + slow flicker) ---- */
.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  border-radius: 0;
  background:
    radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.38) 100%),
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.16) 3px,
      rgba(0, 0, 0, 0.16) 3px
    );
  mix-blend-mode: normal;
}
.crt-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 176, 0, 0.03);
  animation: crtFlicker 5.5s steps(1) infinite;
}
@keyframes crtFlicker {
  0%, 100% { opacity: 0.35; }
  10% { opacity: 0.85; }
  20% { opacity: 0.25; }
  32% { opacity: 0.6; }
  45% { opacity: 0.2; }
  60% { opacity: 0.75; }
  72% { opacity: 0.3; }
  85% { opacity: 0.55; }
}
.pane-viewer.crt-off .crt-overlay { display: none; }

/* ---- CRT power-on animation (old-TV turn-on) ---- */
.crt-turnon {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  background: #000;
  display: none;
}
.crt-turnon.playing { display: block; animation: crtBackdrop 0.6s ease forwards; }
.crt-turnon .crt-beam {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 100%;
  transform: translateY(-50%) scaleY(0);
  transform-origin: center;
  background: linear-gradient(180deg, #fff, #ffe8c4 50%, #fff);
  box-shadow: 0 0 22px 6px rgba(255, 220, 160, 0.9);
}
.crt-turnon.playing .crt-beam { animation: crtBeam 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.crt-turnon .crt-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
}
.crt-turnon.playing .crt-flash { animation: crtFlash 0.6s ease forwards; }
@keyframes crtBackdrop {
  0% { background: #000; }
  70% { background: #000; }
  100% { background: rgba(0, 0, 0, 0); }
}
@keyframes crtBeam {
  0%   { transform: translateY(-50%) scaleY(0);     opacity: 0; }
  10%  { transform: translateY(-50%) scaleY(0.006); opacity: 1; }        /* thin bright band snaps in */
  55%  { transform: translateY(-50%) scaleY(0.03);  opacity: 1; }
  74%  { transform: translateY(-50%) scaleY(1.08);  opacity: 1; }        /* snap open, overshoot */
  84%  { transform: translateY(-50%) scaleY(1);     opacity: 0.95; }
  100% { transform: translateY(-50%) scaleY(1);     opacity: 0; }        /* fade to reveal content */
}
@keyframes crtFlash {
  0%, 66% { opacity: 0; }
  78% { opacity: 0.85; }        /* quick flash/overshoot */
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .crt-overlay::after { animation: none; opacity: 0.4; }
  .crt-turnon { display: none !important; }
}
.viewer-media-link { display: block; }
.viewer-img { width: 100%; display: block; border: 1px solid var(--border); border-radius: 12px; }
.viewer-video { width: 100%; border-radius: 12px; background: #000; }
.viewer-frame-wrap {
  position: relative;
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0e0e0e;
}
.viewer-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: none; background: #fff; }
.viewer-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  background: #141414;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}
.viewer-fallback.visible { display: flex; }
.viewer-fallback.has-poster { justify-content: flex-start; overflow-y: auto; padding: 12px; background: #0e0e0e; }
.viewer-fallback.has-poster .viewer-img { border-radius: 8px; }
.viewer-fallback .vf-openrow { flex: none; padding: 4px 0 2px; }
.viewer-fallback .vf-openrow a { font-weight: 600; white-space: nowrap; }
.viewer-openrow { display: flex; align-items: center; gap: 10px; font-size: 13px; flex: none; }
.viewer-openrow a { font-weight: 600; white-space: nowrap; }
.viewer-openrow .vo-url { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.viewer-file { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 30px 10px; text-align: center; }
.vf-icon { font-size: 34px; }
.vf-name { font-weight: 600; font-size: 14.5px; word-break: break-all; }
.viewer-audio { width: 100%; }

/* doc kind — a readable, typeset document ("an abstract of what we're talking about") */
.viewer-doc {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 4px 6px 24px;
}
.viewer-doc .md { font-size: 14px; }
.viewer-doc .md h1 { font-size: 20px; }

/* email kind — same markdown, wrapped in a clean bordered card */
.viewer-email {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
.viewer-email .ve-accent {
  height: 4px;
  background: linear-gradient(90deg, var(--orange), var(--amber));
}
.viewer-email .ve-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 122, 0, 0.05);
}
.viewer-email .ve-icon { font-size: 18px; flex: none; }
.viewer-email .ve-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--faint);
}
.viewer-email .ve-body { padding: 6px 18px 18px; }
.viewer-email .md { font-size: 14px; }
/* the From:/Subject: lines the markdown carries render as bold paragraphs — give them air */
.viewer-email .md p:first-child { margin-top: 8px; }

/* right: automations — slide-over popout at every width (topbar ⚡ opens it) */
.pane-autos {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(320px, 88vw);
  border-left: 1px solid var(--border);
  background: #161616;
  display: flex;
  flex-direction: column;
  min-height: 0;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  z-index: 50;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  padding-top: 8px;
}
.pane-autos.open { transform: translateX(0); }
.icon-btn.autos-toggle { display: inline-flex; font-size: 15px; color: var(--muted); }
.icon-btn.autos-toggle:hover, .icon-btn.autos-toggle.active { color: var(--text); border-color: rgba(255, 122, 0, 0.5); }
.autos-list { flex: 1; overflow-y: auto; padding: 6px 12px 20px; }

/* ---- daily timeline ---- */
/* spine geometry — one source of truth for the gutter width + spine position so
   the rail, the connector nodes and the now-line always line up. The gutter is
   wide enough to hold a full "11:55 PM" mono label with no truncation. */
:root {
  --tl-gutter: 68px;   /* width of the left time column */
  --tl-gap: 14px;      /* gap between gutter and card */
  --tl-spine: 80px;    /* x of the vertical spine (gutter + part of the gap) */
}
.auto-day-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 2px 2px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.auto-day-head .day-title { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.auto-day-head .day-date { font-size: 11.5px; color: var(--faint); text-align: right; }

/* The timeline is a vertical spine down the left gutter; rows hang off it. */
.auto-timeline { position: relative; padding: 10px 0 6px; }
.auto-timeline::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: var(--tl-spine); width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, transparent, var(--border) 7%, var(--border) 93%, transparent);
}
.auto-timeline.continuous::before { display: none; }

.auto-row {
  position: relative;
  display: grid;
  grid-template-columns: var(--tl-gutter) 1fr;
  column-gap: var(--tl-gap);
  align-items: start;
  padding: 8px 2px;
}
.auto-row .auto-body {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  min-width: 0;
  transition: border-color 0.15s ease, background 0.15s ease;
}
/* connector node where the row meets the spine, centered on the 2px rail */
.auto-timeline .auto-row::before {
  content: ""; position: absolute; left: calc(var(--tl-spine) - 4px); top: 19px;
  width: 10px; height: 10px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--border-strong);
  z-index: 1; transition: border-color 0.15s ease, background 0.15s ease;
}
.auto-timeline.continuous .auto-row::before { display: none; }

/* left gutter: full time label(s) in mono, right-aligned, muted — never clipped */
.auto-gutter {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  padding-top: 13px; text-align: right; min-width: 0;
}
.auto-time {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; font-weight: 700; color: var(--muted); line-height: 1.15;
  white-space: nowrap; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.auto-time-none { color: var(--faint); font-weight: 500; }
.auto-time-sub {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9.5px; color: var(--faint); white-space: nowrap; letter-spacing: -0.01em;
}
.auto-interval {
  font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.02em;
}
.auto-day {
  font-size: 8.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--amber); background: var(--orange-soft); border-radius: 5px; padding: 1px 5px;
}

/* --- past/upcoming treatments ---
   Position (above/below now) is separate from execution state. The toggle and the
   name NEVER get washed out, so "on" always reads unmistakably as full orange. */
/* actually ran today: a subtly recessed card, but full-strength name + toggle */
.auto-row.is-done .auto-body { background: rgba(255, 255, 255, 0.015); border-color: var(--border); }
.auto-row.is-done .auto-name { color: var(--muted); }
.auto-row.is-done .auto-time { color: var(--faint); }
.auto-row.is-done::before { background: var(--green); border-color: rgba(52, 209, 103, 0.5); }
/* past its time but never ran: neutral, not dimmed away */
.auto-row.is-past .auto-time { color: var(--faint); }
/* still upcoming: brighter card edge + amber time to draw the eye forward */
.auto-row.is-upcoming .auto-body { border-color: var(--border-strong); }
.auto-row.is-upcoming .auto-time { color: var(--amber); }
.auto-row.is-upcoming::before { border-color: rgba(255, 176, 0, 0.5); }

.auto-top { display: flex; align-items: center; gap: 9px; }
/* Let the name use whatever horizontal room the panel has: at the default/narrow
   width it wraps to a second line rather than truncating; ellipsis only kicks in
   as a last-resort fallback past two lines. Widening the panel gives it room to
   fit on one line. */
.auto-name {
  font-size: 13.5px; font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.25;
}
.badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2.5px 8px;
  border-radius: 999px;
  flex: none;
}
.badge-flavor { background: var(--orange-soft); color: var(--amber); border: 1px solid rgba(255, 122, 0, 0.3); }
.badge-legacy { background: rgba(255, 255, 255, 0.06); color: var(--faint); border: 1px solid var(--border); }
.auto-meta { display: flex; align-items: center; gap: 7px; margin-top: 9px; font-size: 11.5px; color: var(--faint); flex-wrap: wrap; }
.ran-tag {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--green); background: rgba(52, 209, 103, 0.1);
  border: 1px solid rgba(52, 209, 103, 0.35); border-radius: 999px; padding: 1.5px 8px;
  white-space: nowrap;
}
.fail-tag {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--red); background: rgba(240, 82, 77, 0.1);
  border: 1px solid rgba(240, 82, 77, 0.35); border-radius: 999px; padding: 1.5px 8px;
  white-space: nowrap;
}
.sched-tag {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--faint); border: 1px solid var(--border); border-radius: 999px; padding: 1.5px 8px;
  white-space: nowrap;
}
.auto-times { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.time-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px; color: var(--muted);
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border);
  border-radius: 6px; padding: 1.5px 6px;
}
/* a time already past today = done (dimmed + check), NOT crossed out */
.time-chip.ran { opacity: 0.55; color: var(--muted); }
.time-chip.ran::before { content: '✓ '; color: #27f06a; opacity: 0.8; }
/* the next upcoming run of the day reads a touch brighter */
.time-chip:not(.ran) { color: var(--text); border-color: rgba(255,122,0,0.3); }

/* the NOW marker — the visual centerpiece. A glowing orange node on the spine, a
   full-width hairline sweeping right, and a pill label. */
.now-line {
  position: relative;
  display: flex; align-items: center;
  margin: 12px 0;
  height: 22px;
  z-index: 3;
}
/* full-width hairline, anchored on the spine, fading to the right edge */
.now-line::before {
  content: ""; position: absolute; left: var(--tl-spine); right: 2px; top: 50%; height: 1.5px;
  background: linear-gradient(90deg, var(--orange) 0%, rgba(255, 122, 0, 0.55) 30%, rgba(255, 122, 0, 0));
  transform: translateY(-50%);
  box-shadow: 0 0 10px rgba(255, 122, 0, 0.35);
}
/* glowing node sitting exactly on the spine */
.now-line .now-dot {
  position: absolute; left: var(--tl-spine); top: 50%; transform: translate(-50%, -50%);
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--orange); border: 2px solid var(--bg);
  box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.18), 0 0 12px rgba(255, 122, 0, 0.95);
  z-index: 2;
}
.now-line .now-label {
  position: relative; z-index: 2;
  margin-left: calc(var(--tl-spine) + 12px);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--orange);
  background: var(--bg); padding: 2px 8px; border-radius: 6px;
  border: 1px solid rgba(255, 122, 0, 0.35);
  box-shadow: 0 0 12px rgba(255, 122, 0, 0.18);
  white-space: nowrap;
}

/* continuous (interval) group at the bottom */
.auto-group-head {
  margin-top: 18px; padding: 12px 2px 8px;
  border-top: 1px solid var(--border);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--faint);
}
.auto-group-head .group-sub { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.auto-timeline.continuous { padding-top: 4px; }
.auto-timeline.continuous .auto-row { grid-template-columns: var(--tl-gutter) 1fr; }
.auto-timeline.continuous .auto-gutter { padding-top: 12px; }
.auto-timeline.continuous .auto-time { color: var(--muted); font-weight: 700; white-space: nowrap; }

.progress { height: 5px; background: rgba(255, 255, 255, 0.07); border-radius: 999px; margin-top: 9px; overflow: hidden; }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--orange), var(--amber)); border-radius: 999px; }
.progress-label { font-size: 10.5px; color: var(--faint); margin-top: 4px; }

.toggle { position: relative; width: 34px; height: 20px; flex: none; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .track {
  position: absolute; inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  transition: background 0.18s ease;
}
.toggle .track::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform 0.18s ease;
}
.toggle input:checked + .track { background: var(--orange); box-shadow: 0 0 8px rgba(255, 122, 0, 0.45); }
.toggle input:checked + .track::after { transform: translateX(14px); }
.toggle.disabled { opacity: 0.35; cursor: not-allowed; }
/* even inside a "done"/past row, the toggle stays full-strength so on/off is
   never ambiguous — past state must not make an enabled toggle look disabled. */
.auto-row.is-done .toggle:not(.disabled),
.auto-row.is-past .toggle:not(.disabled) { opacity: 1; }

/* sub-agent toggles (Agentic settings modal) */
.subagents { display: flex; flex-direction: column; gap: 14px; }
.subagent-row { display: flex; align-items: flex-start; gap: 12px; }
.subagent-row .toggle { margin-top: 2px; }
.subagent-text { min-width: 0; }
.subagent-name { font-weight: 600; font-size: 13.5px; color: var(--text); text-transform: none; letter-spacing: 0; }
.subagent-text .field-help { margin-top: 3px; }

/* modals */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal-overlay.visible { display: flex; }
.modal {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, #1f1f1f 0%, var(--card) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 28px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { margin: 0 0 18px; font-size: 19px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal .m-error { color: var(--red); font-size: 13.5px; min-height: 18px; margin-bottom: 6px; }

.pane-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 49; display: none; }
.pane-scrim.visible { display: block; }

/* desktop: automations is an in-flow right pane — hidden until the ⚡ toggle */
@media (min-width: 761px) {
  .pane-autos {
    position: static;
    width: var(--autos-w, 300px);
    display: none;
    transform: none;
    transition: none;
    box-shadow: none;
    padding-top: 0;
  }
  .pane-autos.open { display: flex; transform: none; }
  /* the resize handle rides alongside the panel — only visible while it's open */
  .panes.autos-open .autos-resize { display: block; }
  .pane-scrim { display: none !important; } /* scrim is a mobile-only affordance */
}

/* ---- responsive ---- */
@media (max-width: 760px) {
  .hero h1 { font-size: 36px; }
  .hero { padding: 44px 20px 60px; }
  .hero-logo { width: 220px; }
  .cards { grid-template-columns: 1fr; }
  .section h2 { font-size: 26px; }
  .ea-form { flex-direction: column; }
  .ea-form .btn { width: 100%; }
  .site-footer { flex-direction: column; text-align: center; justify-content: center; }
  .header-actions .btn-ghost { display: none; }

  .pane-agents {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 84vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 50;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5);
    padding-top: 8px;
  }
  .pane-agents.open { transform: translateX(0); }
  .icon-btn.agents-toggle { display: inline-flex; }
  .topbar { gap: 10px; padding: 10px 12px; }
  .topbar .brand span { display: none; }
  .topbar-agentic { max-width: 130px; }
  .topbar-agentic #topbarAgentic { display: none; }
  .lock-chip #lockChipModel { display: none; }
  .health span { display: none; }

  /* viewer: full-screen overlay on mobile — no resize handle */
  .pane-viewer {
    position: fixed;
    inset: 0;
    width: 100%;
    z-index: 56;
    border-left: none;
  }
  .panes.viewer-open .viewer-resize { display: none; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; }

  /* wiki mobile: TOC → section → (skills) list → detail, one screen at a time */
  .wiki-toc { width: 100%; border-right: none; }
  .wiki-view.in-section .wiki-toc { display: none; }          /* in a section: hide the TOC rail */
  .wiki-sections { display: none; }
  .wiki-view.in-section .wiki-sections { display: flex; }
  .wiki-toc-back { display: inline-block; }                   /* "Contents" back affordance */
  .wiki-skills-split { flex-direction: column; }
  .wiki-list-pane { width: 100%; border-right: none; }
  .wiki-page-pane { display: none; }
  .wiki-view.detail .wiki-list-pane { display: none; }
  .wiki-view.detail .wiki-page-pane { display: flex; }
  .wiki-view.detail .wiki-back { display: inline-block; }
  .wiki-page { padding: 20px 16px 40px; }
  .wiki-memory { padding: 20px 16px 40px; }
  .msg { max-width: 92%; }
}

/* ==================================================================== */
/* GREEN-PHOSPHOR CRT MODE — chat only (#chatView + convo-list header).  */
/* Activated by body.crt-chat. Scoped tightly so the sidebar, viewer,    */
/* automations, wiki, header chrome, and console stay untouched.         */
/* ==================================================================== */
:root {
  --crt-green: #33ff66;       /* base phosphor */
  --crt-bright: #7dffa0;      /* emphasis / bold / user */
  --crt-dim: #1f9d43;         /* meta / muted */
  --crt-screen: #050a06;      /* near-black tube */
  --crt-glow: 0 0 6px rgba(51, 255, 102, 0.45);
  --crt-glow-strong: 0 0 8px rgba(125, 255, 160, 0.7);
  --crt-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- CRT toggle pill (chat header + convo-list header) ---- */
.crt-chat-toggle {
  flex: none;
  align-self: center;
  font: 700 10px/1 var(--font);
  letter-spacing: 0.12em;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.crt-chat-toggle:hover { color: var(--text); border-color: var(--border-strong); }
body.crt-chat .crt-chat-toggle {
  color: var(--crt-green);
  border-color: rgba(51, 255, 102, 0.55);
  background: rgba(51, 255, 102, 0.1);
  box-shadow: 0 0 10px rgba(51, 255, 102, 0.32);
  text-shadow: var(--crt-glow);
}

/* convo-list header row (title + toggle) */
.cl-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.cl-head-text { min-width: 0; }

/* ================= the screen itself (CRT ON) ================= */
body.crt-chat #chatView {
  background: var(--crt-screen);
}
body.crt-chat #chatView .chat-header {
  background: #071009;
  border-bottom-color: rgba(51, 255, 102, 0.22);
}
body.crt-chat #chatView .ch-title {
  color: var(--crt-green);
  font-family: var(--crt-mono);
  text-shadow: var(--crt-glow);
}
body.crt-chat #chatView .messages { background: var(--crt-screen); }

/* the message column becomes one green terminal — no bubbles */
body.crt-chat #chatView .msg {
  max-width: 100%;
  background: none !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 2px 0;
  color: var(--crt-green);
  font-family: var(--crt-mono);
}
body.crt-chat #chatView .msg.user,
body.crt-chat #chatView .msg.assistant {
  align-self: stretch;
  background: none;
}
/* USER lines: bright, prefixed with "> " */
body.crt-chat #chatView .msg.user > .md { position: relative; padding-left: 1.4em; }
body.crt-chat #chatView .msg.user > .md::before {
  content: "> ";
  position: absolute; left: 0; top: 0;
  color: var(--crt-bright);
  text-shadow: var(--crt-glow-strong);
  font-weight: 700;
}
body.crt-chat #chatView .msg.user .md,
body.crt-chat #chatView .msg.user .md p,
body.crt-chat #chatView .msg.user .md li {
  color: var(--crt-bright);
  text-shadow: var(--crt-glow-strong);
}

/* rendered markdown — everything green phosphor + mono */
body.crt-chat #chatView .msg .md,
body.crt-chat #chatView .msg .md p,
body.crt-chat #chatView .msg .md li,
body.crt-chat #chatView .msg .md td,
body.crt-chat #chatView .msg .md th,
body.crt-chat #chatView .msg .md blockquote,
body.crt-chat #chatView .msg .md h1,
body.crt-chat #chatView .msg .md h2,
body.crt-chat #chatView .msg .md h3,
body.crt-chat #chatView .msg .md h4 {
  color: var(--crt-green);
  font-family: var(--crt-mono);
  text-shadow: var(--crt-glow);
}
body.crt-chat #chatView .msg .md a {
  color: var(--crt-bright);
  text-decoration-color: rgba(125, 255, 160, 0.5);
  text-shadow: var(--crt-glow-strong);
}
body.crt-chat #chatView .msg .md strong {
  color: var(--crt-bright) !important;
  text-shadow: var(--crt-glow-strong);
  font-weight: 700;
}
body.crt-chat #chatView .msg .md h1 { border-bottom-color: rgba(51, 255, 102, 0.3); }
body.crt-chat #chatView .msg .md blockquote { border-left-color: rgba(51, 255, 102, 0.55); }
body.crt-chat #chatView .msg .md hr { border-top-color: rgba(51, 255, 102, 0.25); }
body.crt-chat #chatView .msg .md th,
body.crt-chat #chatView .msg .md td { border-color: rgba(51, 255, 102, 0.3); }
body.crt-chat #chatView .msg .md th { background: rgba(51, 255, 102, 0.1); }

/* code — inset darker-green panel, still green text */
body.crt-chat #chatView .msg .md code {
  color: var(--crt-bright);
  background: rgba(51, 255, 102, 0.08);
  border: 1px solid rgba(51, 255, 102, 0.28);
  text-shadow: var(--crt-glow);
}
body.crt-chat #chatView .msg .md pre {
  background: #030603;
  border: 1px solid rgba(51, 255, 102, 0.28);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6);
}
body.crt-chat #chatView .msg .md pre code {
  color: var(--crt-green);
  background: none;
  border: none;
  text-shadow: var(--crt-glow);
}

/* tool chips read as dim green meta lines */
body.crt-chat #chatView .tool-chip {
  color: var(--crt-dim);
  background: none;
  border: 1px dashed rgba(51, 255, 102, 0.25);
  font-family: var(--crt-mono);
  text-shadow: 0 0 5px rgba(31, 157, 67, 0.5);
}
body.crt-chat #chatView .tool-chip .tc-name { color: var(--crt-green); }

/* WarGames type-on goes GREEN with a green block caret */
body.crt-chat #chatView .msg.assistant .type-pre {
  color: var(--crt-green);
  text-shadow: var(--crt-glow);
}
body.crt-chat #chatView .msg.assistant.typing .type-pre::after {
  content: "\2588"; /* solid block caret */
  color: var(--crt-green);
  text-shadow: var(--crt-glow-strong);
}

/* ---- composer in CRT mode: an inline TERMINAL INPUT LINE on the screen ---- */
/* flush with the messages above — no boxed field, part of the tube */
body.crt-chat #chatView .composer {
  background: var(--crt-screen);
  border-top: none;
}
/* the real textarea stays (it does the typing) but goes invisible: no box,
   transparent text + caret. The green line the user sees is the mirror. */
body.crt-chat #chatView .composer textarea {
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none !important;
  color: transparent;
  caret-color: transparent;
  font-family: var(--crt-mono);
  font-size: 14.5px;
  line-height: 1.45;
  /* left padding matches the mirror's "> " prompt column so both wrap at the
     same width — otherwise the mirror runs taller and its last lines clip */
  padding: 12px 18px 12px calc(18px + 2ch);
  position: relative;
  z-index: 1;
}
body.crt-chat #chatView .composer textarea::placeholder { color: transparent; }
body.crt-chat #chatView .composer textarea::selection { background: rgba(51, 255, 102, 0.28); }

/* the mirrored green terminal line "> {value}█" — overlaid on the textarea */
body.crt-chat #chatView .crt-input-mirror {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  padding: 12px 18px 12px calc(18px + 2ch);
  text-indent: -2ch;                 /* hanging indent: wrapped lines clear the prompt */
  font-family: var(--crt-mono);
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--crt-green);
  text-shadow: var(--crt-glow);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}
.crt-input-mirror .crt-prompt {
  color: var(--crt-bright);
  text-shadow: var(--crt-glow-strong);
  font-weight: 700;
}
/* blinking green BLOCK cursor at end of the typed text */
.crt-input-mirror .crt-block {
  color: var(--crt-green);
  text-shadow: var(--crt-glow-strong);
  animation: crt-block-blink 1s steps(1) infinite;
}
@keyframes crt-block-blink { 50% { opacity: 0; } }
/* hold solid (no blink) while actively typing; resume blinking when idle */
.crt-input-mirror.typing .crt-block { animation: none; opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .crt-input-mirror .crt-block { animation: none; opacity: 1; }
}

/* paperclip reads green in CRT (not just on hover) */
body.crt-chat #chatView .composer .attach-btn { color: var(--crt-green); }
body.crt-chat #chatView .composer .attach-btn:hover {
  color: var(--crt-bright);
  border-color: rgba(51, 255, 102, 0.5);
}
/* Send button -> green outline */
body.crt-chat #chatView .composer #sendBtn {
  background: none;
  color: var(--crt-green);
  border: 1px solid rgba(51, 255, 102, 0.6);
  text-shadow: var(--crt-glow);
  box-shadow: 0 0 10px rgba(51, 255, 102, 0.18);
  font-family: var(--crt-mono);
  letter-spacing: 0.06em;
}
body.crt-chat #chatView .composer #sendBtn:hover {
  background: rgba(51, 255, 102, 0.12);
  border-color: var(--crt-green);
}

/* ---- persistent CRT texture over the chat screen (scanlines + vignette + flicker) ---- */
.crt-chat-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;   /* never blocks clicks/scroll */
  z-index: 6;
  display: none;
  background:
    radial-gradient(ellipse at center, transparent 54%, rgba(0, 0, 0, 0.45) 100%),
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 20, 6, 0.22) 3px,
      rgba(0, 20, 6, 0.22) 3px
    );
}
.crt-chat-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(51, 255, 102, 0.03);
  animation: crtChatFlicker 5.5s steps(1) infinite;
}
@keyframes crtChatFlicker {
  0%, 100% { opacity: 0.35; }
  10% { opacity: 0.7; }
  20% { opacity: 0.25; }
  32% { opacity: 0.55; }
  45% { opacity: 0.2; }
  60% { opacity: 0.6; }
  72% { opacity: 0.3; }
  85% { opacity: 0.5; }
}
body.crt-chat #chatView .crt-chat-overlay { display: block; }

/* ---- CRT power-on flash, scoped to the chat screen (reuses the viewer approach) ---- */
.crt-chat-turnon {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: #000;
  display: none;
}
.crt-chat-turnon.playing { display: block; animation: crtBackdrop 0.5s ease forwards; }
.crt-chat-turnon .crt-beam {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 100%;
  transform: translateY(-50%) scaleY(0);
  transform-origin: center;
  background: linear-gradient(180deg, #c8ffd8, #33ff66 50%, #c8ffd8);
  box-shadow: 0 0 22px 6px rgba(51, 255, 102, 0.9);
}
.crt-chat-turnon.playing .crt-beam { animation: crtBeam 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
.crt-chat-turnon .crt-flash {
  position: absolute;
  inset: 0;
  background: #d6ffe2;
  opacity: 0;
}
.crt-chat-turnon.playing .crt-flash { animation: crtFlash 0.5s ease forwards; }

@media (prefers-reduced-motion: reduce) {
  /* keep static scanlines + glow, drop flicker + screen-on animation */
  .crt-chat-overlay::after { animation: none; opacity: 0.4; }
  .crt-chat-turnon { display: none !important; }
}
