:root {
  --bg: #0b0f0d;
  --panel: rgba(252, 246, 224, 0.07);
  --panel-strong: rgba(252, 246, 224, 0.045);
  --line: rgba(252, 246, 224, 0.14);
  --text: #fff5dc;
  --muted: #b3bbae;
  --accent: #f0b65b;
  --blue: #8ecbff;
  --green: #86dfaa;
  --danger: #ff806f;
  --shadow: 0 24px 80px rgba(0,0,0,.32);
  --page-gap: 18px;
  --panel-pad: 20px;
  --control-gap: 12px;
  font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 18% 6%, rgba(240,182,91,.18), transparent 30rem), radial-gradient(circle at 90% 0%, rgba(142,203,255,.12), transparent 28rem), linear-gradient(135deg, #050706, var(--bg)); }
main { width: min(1180px, calc(100vw - 32px)); margin: 0 auto; padding: 32px 0 42px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 34px; position: sticky; top: 12px; z-index: 4; padding: 10px 12px; border: 1px solid rgba(244,236,205,.11); border-radius: 999px; background: rgba(8,19,15,.72); box-shadow: 0 18px 60px rgba(0,0,0,.25); backdrop-filter: blur(16px); }
.brand-link { color: var(--text); font-size: clamp(1.9rem, 5vw, 3.2rem); line-height: .8; font-weight: 950; letter-spacing: -.12em; text-decoration: none; padding: 0 8px; }
.topnav { display: flex; gap: 8px; flex-wrap: nowrap; justify-content: flex-end; align-items: center; }
.topnav a { color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 9px 13px; text-decoration: none; background: rgba(0,0,0,.18); white-space: nowrap; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.topnav a:hover, .topnav a:focus-visible { border-color: rgba(244,178,78,.64); background: rgba(244,178,78,.12); transform: translateY(-1px); outline: none; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, .78fr); gap: 34px; align-items: start; min-height: 48vh; }
.hero-copy { padding-top: 34px; }
.eyebrow { margin: 0 0 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .16em; font-size: .82rem; font-weight: 800; }
h1 { margin: 0; line-height: .95; letter-spacing: -.07em; max-width: 780px; }
.hero-line { display: block; font-size: clamp(2.6rem, 5.8vw, 5.2rem); line-height: .95; color: #fff7dc; text-shadow: 0 18px 70px rgba(244,178,78,.16); }
h2 { margin: 0 0 12px; font-size: clamp(1.15rem, 2.2vw, 1.8rem); letter-spacing: -.04em; }
h3 { margin: 0 0 10px; color: var(--accent); font-size: .95rem; text-transform: uppercase; letter-spacing: .12em; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 760px; line-height: 1.55; }
.actions, .row-actions, .panel-head { display: flex; gap: var(--control-gap); flex-wrap: wrap; align-items: center; }
.panel-head { justify-content: space-between; }
.button, button { border: 0; border-radius: 999px; padding: 12px 18px; color: #08130f; background: var(--accent); font-weight: 800; text-decoration: none; cursor: pointer; min-height: 44px; }
button.small { padding: 8px 12px; }
.small-link { display: inline-flex; align-items: center; min-height: 38px; padding: 8px 12px; font-size: .92rem; }
button.danger { background: var(--danger); }
button.secondary { color: var(--text); background: rgba(128,199,255,.18); border: 1px solid rgba(128,199,255,.28); }
.button.ghost { color: var(--text); background: transparent; border: 1px solid var(--line); }
.terminal, article, .panel, .notice, .card, .count-card { border: 1px solid var(--line); background: var(--panel); border-radius: 24px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.terminal { padding: 20px; display: grid; gap: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--blue); transform: rotate(1.5deg); }
.terminal span { padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.24); overflow-wrap: anywhere; }
.notice { padding: 16px 18px; margin: 12px 0 24px; color: #ffe7ad; line-height: 1.55; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 24px 0; }
article, .panel { padding: var(--panel-pad); }
ul { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.7; }
ol { margin: 0; padding-left: 22px; color: var(--muted); line-height: 1.8; }
.quick-setup { display: grid; grid-template-columns: .9fr 1.1fr; gap: 18px; margin: 0 0 24px; align-items: start; }
.connect-card { display: grid; gap: 16px; position: sticky; top: 16px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.app-console { min-height: calc(100vh - 140px); }
.connected .landing-section { display: none; }
.connected .dashboard-grid, .connected .app-console { margin-top: 8px; }
.connected main { width: min(1520px, calc(100vw - 28px)); }
.connected .topbar { position: static; top: auto; }
.app-header { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 12px; background: rgba(8,13,10,.84); }
.app-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.app-subnav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; padding: 10px 12px; border-radius: 999px; background: rgba(8,19,15,.72); box-shadow: 0 18px 60px rgba(0,0,0,.22); backdrop-filter: blur(16px); }
.app-subnav a { color: var(--text); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: rgba(0,0,0,.2); transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.app-subnav a:hover, .app-subnav a:focus-visible, .app-subnav a.active { border-color: rgba(240,182,91,.62); background: rgba(240,182,91,.12); transform: translateY(-1px); outline: none; }
.workspace-shell { display: grid; grid-template-columns: minmax(310px, 420px) minmax(0, 1fr); gap: var(--page-gap); align-items: start; }
.workspace-shell > *, .thread-workspace > *, .codex-shell, .workspace-main, .workspace-side { min-width: 0; }
.workspace-sidebar-stack { display: grid; grid-template-columns: 1fr; gap: var(--page-gap); min-height: 0; position: sticky; top: 132px; }
.workspace-shell.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
.workspace-shell.sidebar-collapsed .workspace-sidebar-stack { display: none; }
.project-sidebar { min-height: 0; max-height: calc(100vh - 154px); overflow: hidden; display: flex; flex-direction: column; padding: 0; }
.sidebar-static { flex: 0 0 auto; display: grid; gap: 10px; margin: 0; padding: var(--panel-pad) var(--panel-pad) 14px; border-radius: 24px 24px 0 0; background: rgba(0, 10, 7, .34); border-bottom: 1px solid rgba(252, 246, 224, 0.08); }
.sidebar-scroll { min-height: 0; display: grid; align-content: start; grid-auto-rows: max-content; overflow: auto; padding: 14px var(--panel-pad) var(--panel-pad); scrollbar-width: thin; }
.codex-shell { display: flex; flex-direction: column; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.project-list { display: grid; grid-template-columns: 1fr; gap: 12px; }
.section-panel { margin-top: 12px; scroll-margin-top: 210px; }
.thread-workspace { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: var(--page-gap); align-items: start; }
.workspace-main, .workspace-side { display: grid; gap: 14px; }
.output-panel, .composer-shell { border: 1px solid var(--line); background: rgba(0,0,0,.18); border-radius: 22px; padding: 16px; margin-top: 12px; overflow: hidden; }
.panel-subhead, .composer-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.output-stream { max-height: 430px; overflow: auto; padding-right: 4px; }
.final-panel { border-color: rgba(117,216,156,.3); background: linear-gradient(135deg, rgba(117,216,156,.12), rgba(0,0,0,.16)); }
.final-output { border-left-color: var(--accent); }
.reasoning-panel { border-color: rgba(128,199,255,.3); background: linear-gradient(135deg, rgba(128,199,255,.10), rgba(0,0,0,.16)); }
.reasoning-stream { max-height: 260px; overflow: auto; padding-right: 4px; }
.reasoning-card { border-left: 3px solid var(--blue); }
.output-panel.is-empty { padding: 11px 14px; }
.output-panel.is-empty .cards { display: none; }
.output-panel.is-empty .panel-subhead { margin-bottom: 0; }
.composer-shell { background: linear-gradient(135deg, rgba(244,178,78,.14), rgba(128,199,255,.08)); position: relative; bottom: auto; z-index: 1; clear: both; display: grid; gap: 14px; }
.mode-toggle { display: inline-grid; grid-template-columns: repeat(2, minmax(72px, 1fr)); gap: 6px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(0,0,0,.22); }
button.toggle { min-height: 34px; padding: 6px 12px; color: var(--text); background: transparent; border: 0; }
button.toggle.active { color: #08130f; background: var(--accent); }
.skill-row { display: grid; gap: 10px; margin: 10px 0 4px; }
.skill-search-row { display: grid; gap: 7px; max-width: 520px; }
.skill-search-row input { min-height: 42px; padding-block: 10px; }
.skill-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; max-height: 164px; overflow: auto; padding: 2px 4px 4px 0; scrollbar-width: thin; }
.skill-chip { min-height: 34px; padding: 7px 11px; color: var(--text); background: rgba(128,199,255,.12); border: 1px solid rgba(128,199,255,.25); }
.skill-chip.active { color: #08130f; background: var(--green); border-color: transparent; }
.skill-picker-label { font-size: .88rem; }
select { min-height: 38px; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; background: rgba(0,0,0,.22); color: var(--text); font: inherit; }
.composer-form { display: grid; gap: 12px; }
.composer-form textarea { min-height: 126px; }
.attachment-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; }
.attachment-picker { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; width: fit-content; border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; color: var(--text); background: rgba(0,0,0,.2); cursor: pointer; }
#attachmentInput { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.attachment-preview { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.approval-drawer { position: fixed; inset: 0; z-index: 6; display: grid; justify-items: end; background: rgba(0,0,0,.42); }
.drawer-card { width: min(540px, 100%); height: 100%; border-left: 1px solid var(--line); background: rgba(8,19,15,.96); padding: 20px; box-shadow: -22px 0 70px rgba(0,0,0,.35); overflow: auto; }
.drawer-card pre { min-height: 280px; }
.span-2 { grid-column: 1 / -1; }
.muted { color: var(--muted); line-height: 1.55; }
.small-copy { margin: 0; font-size: .92rem; }
.connect-form, .cards, .field-group { display: grid; gap: 10px; }
.cards.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mode-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 0; border: 0; }
.mode-picker legend { grid-column: 1 / -1; color: var(--muted); font-weight: 800; margin-bottom: 2px; }
.mode-option { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 18px; background: rgba(0,0,0,.18); cursor: pointer; }
.mode-option input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.mode-option span { display: grid; gap: 4px; }
.mode-option small { color: var(--muted); line-height: 1.35; }
.mode-help { margin: 0; }
label { color: var(--muted); font-weight: 700; }
.search-label { display: block; margin: 8px 0 6px; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; background: rgba(0,0,0,.2); color: var(--text); font: inherit; font-size: 16px; }
button:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
textarea { min-height: 92px; resize: vertical; }
pre { grid-column: 1 / -1; white-space: pre-wrap; overflow-x: auto; overflow-wrap: anywhere; min-height: 120px; padding: 16px; border-radius: 16px; background: rgba(0,0,0,.28); color: #dcebdc; }
.card { box-shadow: none; padding: 14px; background: var(--panel-strong); }
.project-button, .thread-button, .see-more-card { width: 100%; min-height: 0; color: var(--text); background: var(--panel-strong); border: 1px solid var(--line); border-radius: 18px; text-align: left; cursor: pointer; font: inherit; display: block; padding: 14px; }
.project-button:hover, .thread-button:hover, .see-more-card:hover { border-color: rgba(240,182,91,.58); background: rgba(240,182,91,.08); transform: none; }
.see-more-card { color: var(--accent); text-align: center; font-weight: 800; }
.inline-link { color: var(--accent); font-size: .9rem; font-weight: 800; }
.card.selected { outline: 2px solid rgba(244,178,78,.65); }
.project-group { display: grid; gap: 10px; border: 1px solid rgba(252, 246, 224, 0.12); border-radius: 18px; background: rgba(252, 246, 224, 0.04); overflow: hidden; }
.project-group.selected { border-color: rgba(240,182,91,.48); background: rgba(240,182,91,.06); }
.project-heading, .thread-row, .see-more-inline { width: 100%; min-height: 0; color: var(--text); background: transparent; border: 0; border-radius: 0; text-align: left; cursor: pointer; font: inherit; display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 13px 14px; }
.project-heading strong, .thread-row strong { display: block; overflow-wrap: anywhere; line-height: 1.25; }
.project-heading small, .thread-row small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.3; overflow-wrap: anywhere; }
.project-heading:hover, .thread-row:hover, .project-heading:focus-visible, .thread-row:focus-visible { background: rgba(240,182,91,.08); outline: none; }
.nested-thread-list { display: grid; gap: 6px; padding: 0 8px 10px; }
.thread-row { border: 1px solid rgba(128,199,255,.18); border-radius: 13px; background: rgba(0,0,0,.16); padding: 10px 11px; }
.thread-row.selected { border-color: rgba(134,223,170,.58); background: rgba(134,223,170,.10); }
.see-more-inline { justify-content: center; color: var(--accent); font-weight: 800; border-top: 1px solid rgba(252,246,224,.08); }
.thread-card { border-left: 3px solid rgba(128,199,255,.45); }
.project-card { border-left: 3px solid rgba(244,178,78,.5); }
.project-card p, .thread-card p { margin: 5px 0; font-size: .9rem; }
.thread-card .inline-link { display: none; }
.card-title { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.card-title strong {
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card p { margin: 8px 0; }
.output-card { border-left: 3px solid var(--green); }
.event-card { border-left: 3px solid var(--blue); }
.turn-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.turn-controls label { display: grid; gap: 6px; }
.confirm-hint { margin: 0; border: 1px solid rgba(240,182,91,.36); border-radius: 14px; padding: 10px 12px; background: rgba(240,182,91,.10); color: #ffe2a5; }
.approval-card textarea { min-height: 78px; margin-top: 8px; }
.approval-history-block { margin-top: 20px; }
.compact-card { padding: 11px 12px; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(720px, calc(100vw - 24px)); z-index: 5; border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; background: rgba(8,19,15,.94); color: var(--text); box-shadow: 0 20px 70px rgba(0,0,0,.38); }
.tag { display: inline-flex; width: fit-content; border-radius: 999px; padding: 3px 9px; font-size: .75rem; background: rgba(128,199,255,.16); color: var(--blue); }
.tag.running, .tag.waiting_approval, .tag.waiting_operator { color: var(--green); background: rgba(117,216,156,.15); }
.tag.failed, .tag.interrupted { color: var(--danger); background: rgba(255,123,114,.14); }
.count-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.count-card { padding: 14px; box-shadow: none; }
.count-card strong { display: block; color: var(--accent); font-size: 2rem; }
.count-card span { color: var(--muted); }
.session-grid, .health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.mini-status, .health-card, .relay-state { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: rgba(0,0,0,.18); }
.mini-status small, .health-card small, .relay-state small { display: block; color: var(--muted); line-height: 1.4; }
.relay-state { min-width: min(360px, 100%); align-items: center; }
.status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 999px; margin-top: 4px; background: var(--muted); box-shadow: 0 0 0 4px rgba(255,255,255,.04); }
.status-dot.completed { background: var(--green); }
.status-dot.pending { background: var(--accent); }
.status-dot.failed { background: var(--danger); }
.status-dot.idle { background: var(--blue); }
.relay-banner { margin: 0 0 12px; border-color: rgba(255,128,111,.4); background: rgba(255,128,111,.08); }
code { color: var(--blue); overflow-wrap: anywhere; }
@media (max-width: 1280px) {
  .workspace-shell, .thread-workspace { grid-template-columns: 1fr; }
  .workspace-sidebar-stack { position: static; display: grid; grid-template-columns: 1fr; align-items: start; }
  .project-sidebar, .codex-shell { grid-column: auto; grid-row: auto; }
  .project-sidebar { max-height: min(70vh, 760px); }
  .composer-shell { position: relative; bottom: auto; margin-top: 16px; }
}
@media (max-width: 820px) {
  .hero, .grid, .quick-setup, .dashboard-grid, .cards.compact, .mode-picker, .thread-workspace, .workspace-shell, .session-grid, .health-grid, .turn-controls { grid-template-columns: 1fr; }
  .terminal { transform: none; }
  .connect-card { position: static; }
  .workspace-sidebar-stack { display: grid; grid-template-columns: 1fr; }
  .project-sidebar { max-height: 76vh; }
  main { padding: 24px 0; }
}
@media (max-width: 520px) {
  :root { --panel-pad: 16px; }
  main { width: min(100% - 20px, 1180px); padding: 18px 0; }
  .topbar { align-items: center; border-radius: 22px; }
  .app-header { flex-direction: column; align-items: stretch; }
  .app-actions { justify-content: flex-start; }
  .topnav { justify-content: flex-start; overflow-x: auto; }
  .topnav a { padding: 8px 10px; }
  .hero { min-height: auto; gap: 18px; }
  .hero-copy { padding-top: 12px; }
  .lead { font-size: 1rem; }
  article, .panel, .notice, .terminal { border-radius: 18px; padding: 16px; }
  .sidebar-static { gap: 8px; padding: 0; }
  .sidebar-static h2 { font-size: 1.55rem; line-height: 1.05; margin-bottom: 2px; }
  .sidebar-static .small-copy { font-size: .95rem; line-height: 1.45; }
  .project-card p, .thread-card p, .project-card code, .thread-card code { line-height: 1.38; }
  .project-button, .thread-button, .see-more-card { text-align: left; }
  .see-more-card { text-align: center; }
  .actions, .row-actions { align-items: stretch; }
  .button, button, .row-actions button { width: 100%; text-align: center; }
  .panel-head { align-items: flex-start; }
  .panel-subhead, .composer-toolbar, .attachment-row { grid-template-columns: 1fr; display: grid; }
  .mode-toggle { width: 100%; }
  .skill-row { display: grid; grid-template-columns: 1fr; }
  .skill-chips { max-height: 220px; }
  .skill-chip, .attachment-picker { width: 100%; }
  .drawer-card { width: 100%; padding: 16px; }
}
.demo-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 16px; background: #2b2410; border-bottom: 1px solid rgba(240,182,91,.55); color: var(--text); font-size: .95rem; }
.demo-banner p { margin: 0; }
.demo-banner a { color: var(--accent); }
.demo-page { padding-top: 96px; }
@media (max-width: 640px) { .demo-page { padding-top: 150px; } }
