:root {
  --bg: #14110f;
  --panel: #1c1815;
  --panel-2: #24201c;
  --line: #322c26;
  --text: #f1ebe4;
  --muted: #a39a8f;
  --faint: #6f675e;
  --accent: #f0a35e;
  --accent-ink: #1a1613;
  --green: #7fca8d;
  --amber: #f5c451;
  --red: #ef7b6c;
  --blue: #7fb4e8;
  --term-bg: #0e0c0a;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf7f3; --panel: #ffffff; --panel-2: #f3eee8; --line: #e4dcd2; --text: #231d18; --muted: #6d645a; --faint: #9a9086;
    --accent: #c9682a; --accent-ink: #ffffff; --green: #2f8f4a; --amber: #a9760a; --red: #c8432f; --blue: #2c6fb3;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
#app { min-height: 100%; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.92em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
textarea.input { height: auto; padding: 9px 12px; resize: vertical; }
.input::placeholder { color: var(--faint); }
label.field { display: block; font-size: 13px; color: var(--muted); font-weight: 550; }
label.field > .input, label.field > select { margin-top: 6px; color: var(--text); font-weight: 400; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); font-size: 13px; min-height: 1.2em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 550; z-index: 50; }

/* brand */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; color: var(--text); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand i { display: inline-flex; gap: 3px; }
.brand i::before, .brand i::after { content: ""; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--accent); }
.brand i::before { background: var(--accent); }

/* landing */
.landing { max-width: 980px; width: 100%; margin: 0 auto; padding: 0 24px 56px; }
.landing nav { display: flex; align-items: center; height: 68px; }
.hero { padding: 56px 0 36px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.hero h1 { font-size: clamp(34px, 6vw, 60px); letter-spacing: -0.035em; line-height: 1.04; max-width: 15em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lede { font-size: clamp(17px, 2.2vw, 20px); color: var(--muted); max-width: 34em; }
.hero .lede code, .steps code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; color: var(--text); }
.start { width: 100%; max-width: 440px; margin-top: 6px; }
.start form { display: flex; gap: 8px; }
.start .input, .start .btn { height: 46px; }
.start .btn { padding: 0 20px; }
.start .card { text-align: left; }
.landing .shot { margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 30px 80px -40px rgb(240 163 94 / 0.45); background: #14110f; }
.landing .shot img { display: block; width: 100%; height: auto; }
.steps { list-style: none; margin: 44px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; }
.steps li { display: flex; gap: 14px; min-width: 0; }
.steps .n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; }
.steps h3 { font-size: 17px; margin-bottom: 4px; }
.steps p { color: var(--muted); font-size: 14.5px; }
.foot { margin-top: 48px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--faint); font-size: 13px; }

/* centered flows */
.center { flex: 1; display: grid; place-items: center; padding: 32px 20px; }
.center .card { width: 100%; max-width: 420px; padding: 28px; }
.center h1 { font-size: 22px; margin: 18px 0 6px; }
.bigcode { font: 700 26px var(--mono); letter-spacing: 0.08em; padding: 14px; text-align: center; background: var(--panel-2); border-radius: 8px; }

/* app shell */
.topbar { display: flex; align-items: center; gap: 6px; height: 54px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.topbar .ws { margin-left: 14px; height: 32px; width: auto; max-width: 190px; padding: 0 8px; font-weight: 600; background: transparent; }
.topbar a.tab { padding: 6px 11px; border-radius: 7px; color: var(--muted); font-weight: 550; font-size: 14px; }
.topbar a.tab:hover { color: var(--text); text-decoration: none; }
.topbar a.tab.on { color: var(--text); background: var(--panel-2); }
.page { max-width: 1040px; width: 100%; margin: 0 auto; padding: 28px 24px 70px; }
.page > h1 { font-size: 22px; margin-bottom: 4px; }
.page > .sub { color: var(--muted); margin-bottom: 22px; }
.h2 { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 30px 0 12px; display: flex; align-items: center; gap: 8px; }

.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #16120f; flex: none; border: 2px solid var(--panel); }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -8px; }
.avatar.more { background: var(--panel-2); color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 650; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.working { color: var(--green); }
.pill.working::before { animation: pulse 1.4s ease-in-out infinite; }
.pill.blocked { color: var(--accent-ink); background: var(--amber); }
.pill.reconnecting { color: var(--red); }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .pill.working::before { animation: none; } }

.sessions { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
a.session { display: flex; flex-direction: column; gap: 10px; color: inherit; padding: 16px; min-height: 132px; }
a.session:hover { text-decoration: none; border-color: var(--faint); }
a.session.blocked { border-color: var(--amber); }
a.session h3 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.session .meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { text-align: center; padding: 38px 20px; }
.empty h3 { font-size: 18px; margin-bottom: 6px; }
.cmd { display: inline-flex; align-items: center; gap: 12px; margin-top: 16px; padding: 10px 10px 10px 16px; background: var(--term-bg); color: #efe8df; border-radius: 9px; font: 14px var(--mono); border: 1px solid var(--line); max-width: 100%; }
.cmd span { overflow-x: auto; white-space: nowrap; }
.cmd .btn { color: #efe8df; background: #2a2520; border-color: #3a332c; }

table.list { width: 100%; border-collapse: collapse; }
table.list td, table.list th { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.num { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.tablecard { padding: 4px 8px; overflow-x: auto; }
.meter { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; width: 140px; }
.meter i { display: block; height: 100%; background: var(--accent); }
.setting { display: flex; gap: 20px; align-items: flex-start; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; padding-bottom: 0; }
.setting:first-child { padding-top: 0; }
.setting h3 { font-size: 15px; }
.setting p { color: var(--muted); font-size: 13.5px; max-width: 46em; margin-top: 2px; }
.setting .ctl { flex: none; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 60%; }

/* live session */
.room { flex: 1; display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100vh; height: 100dvh; max-height: 100dvh; min-height: 0; overflow: hidden; }
.roombar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0; }
.roombar .title { min-width: 0; }
.roombar h1 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roombar .title .meta { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roombody { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 0; }
.stage { background: var(--term-bg); min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.termwrap { flex: 1; min-height: 0; padding: 12px; overflow: hidden; display: grid; place-items: start center; }
.termwrap .xterm { padding: 0; }
.banner { padding: 8px 14px; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.banner.blocked { background: var(--amber); color: #1a1613; }
.banner.info { background: var(--panel-2); color: var(--muted); }
.banner.reconnecting { background: var(--red); color: #1a1613; }
.side { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.side .tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.side .tabs button { flex: 1; }
.side .tabs button.on { background: var(--panel-2); color: var(--text); }
.feed { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.msg { font-size: 14px; overflow-wrap: anywhere; }
.msg b { font-weight: 650; margin-right: 6px; }
.msg time, .evt time { color: var(--faint); font-size: 11.5px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.evt { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.evt .q { display: block; margin-top: 3px; padding: 6px 9px; background: var(--panel-2); border-radius: 6px; color: var(--text); font: 12.5px/1.45 var(--mono); }
.composer { border-top: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.composer .modes { display: flex; gap: 4px; }
.composer .modes button.on { background: var(--panel-2); color: var(--text); }
.composer textarea { min-height: 62px; max-height: 180px; }
.people { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 7px; max-height: 30%; overflow-y: auto; }
.people .p { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.people .p .tag { color: var(--faint); font-size: 12px; margin-left: auto; }
.player { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-top: 1px solid #2a2520; color: #cfc7bd; font-size: 13px; }
.player input[type=range] { flex: 1; accent-color: var(--accent); }
.player .btn { background: #2a2520; border-color: #3a332c; color: #efe8df; }

@media (max-width: 860px) {
  .hero { padding-top: 28px; }
  .steps { grid-template-columns: 1fr; gap: 20px; }
  .start form { flex-direction: column; }
  .roombody { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 42%; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .people { display: none; }
  .topbar { overflow-x: auto; }
  .setting { flex-direction: column; gap: 10px; }
  .hide-sm { display: none !important; }
}

/* conversation view (Codex app sessions) */
.stage.light { background: var(--bg); }
.transcript { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 24px 30px; }
.turns, .thinking { max-width: 780px; margin: 0 auto; }
.turn { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.bubble { overflow-wrap: anywhere; line-height: 1.6; }
.bubble p, .bubble ul, .bubble pre, .bubble h4 { margin: 0 0 10px; }
.bubble > :last-child { margin-bottom: 0; }
.bubble ul { padding-left: 20px; }
.bubble h4 { font-size: 15px; }
.bubble.user { align-self: flex-end; max-width: 85%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; padding: 10px 14px; white-space: pre-wrap; }
.bubble.user .by { display: flex; align-items: center; gap: 6px; font-size: 12.5px; margin-bottom: 6px; white-space: normal; }
.bubble.user .by .avatar { width: 20px; height: 20px; font-size: 9px; border: 0; }
.bubble.plan { border-left: 3px solid var(--accent); padding-left: 12px; }
.bubble .label { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.bubble code, .tool code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.bubble pre, .tool pre { background: var(--term-bg); color: #e6dfd6; padding: 12px 14px; border-radius: 8px; overflow-x: auto; font: 13px/1.5 var(--mono); white-space: pre; }
.tool { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; background: var(--panel); }
.tool summary { list-style: none; display: flex; gap: 10px; align-items: center; min-width: 0; }
details.tool summary { cursor: pointer; }
.tool summary code { background: none; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.tool summary .tag { margin-left: auto; flex: none; font-size: 12px; }
.tool pre { margin: 8px 0 2px; max-height: 260px; overflow-y: auto; }
.tool.failed { color: var(--red); border-color: var(--red); }
.thinking { padding-bottom: 6px; }
.bubble.user .queued { font-size: 12px; color: var(--muted); margin-top: 6px; white-space: normal; }

/* notifications */
.notes { position: fixed; top: 66px; right: 16px; z-index: 40; display: flex; flex-direction: column; gap: 8px; width: min(340px, calc(100vw - 32px)); }
a.note { display: flex; flex-direction: column; gap: 2px; padding: 11px 14px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 9px; color: var(--text); box-shadow: 0 12px 30px -12px rgb(0 0 0 / 0.5); font-size: 13.5px; }
a.note:hover { text-decoration: none; border-color: var(--faint); border-left-color: var(--accent); }
a.note.urgent { border-left-color: var(--amber); }
a.note span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
label.check { display: flex; align-items: center; gap: 10px; font-size: 14.5px; cursor: pointer; }
label.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* pick up a session whose host is gone */
.pickup { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); border-left: 3px solid var(--accent); color: var(--text); font-size: 14px; }
.pickup > div:first-child { flex: 1; min-width: 260px; }
.pickup .small { color: var(--muted); margin-top: 2px; }
.pickup .cmd { margin-top: 0; font-size: 13px; }

/* invited agents, catch-up notes, search */
.msg.agent { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.msg.agent b { color: var(--accent); }
.msg .tag { font-size: 11.5px; color: var(--faint); margin-right: 6px; }
.msg.err span { color: var(--muted); font-style: italic; }
.banner.driver { background: var(--panel-2); color: var(--text); border-bottom: 1px solid var(--accent); font-weight: 500; }
.banner.driver span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary:empty { display: none; }
.summary { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; max-height: 38%; overflow-y: auto; }
.summary .label { font-size: 11.5px; font-weight: 650; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; display: flex; justify-content: space-between; }
.summary .label time { color: var(--faint); font-weight: 400; text-transform: none; letter-spacing: 0; }
.summary ul { margin: 0; padding-left: 18px; color: var(--muted); }
.composer .modes { flex-wrap: wrap; }
.search { display: flex; gap: 8px; margin: 18px 0 0; }
.search .input { height: 40px; }
.hit { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); color: inherit; }
.hit:last-child { border-bottom: 0; }
.hit:hover { text-decoration: none; background: var(--panel-2); }
.hit .meta { font-size: 12.5px; color: var(--muted); }
.hit .snip { font: 12.5px/1.5 var(--mono); color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.hit mark { background: none; color: var(--accent); font-weight: 700; }
