:root {
    --bg: #f6f6f3;
    --bg-raised: #ffffff;
    --bg-sunken: #f1f1ec;
    --line: #d7d7cf;
    --line-soft: #e6e6df;
    --text: #1b1b19;
    --text-dim: #55554e;
    --text-faint: #6e6e66;
    --accent: #1f5fa8;
    --code: #216e45;
    --agent: #6b3fa8;
    --warn: #8a5a10;
    --bad: #b02a33;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.6;
}

code { font-family: var(--mono); font-size: 0.9em; color: #8a3d20; background: #f1f1ec; padding: 1px 4px; border-radius: 3px; }
a { color: var(--accent); }

/* ── chrome ─────────────────────────────────────────────────────────────────────────── */
/* Fixed 32px side padding (not a centered .container) so the topbar's edges line up
   with main/footer below it — same fix applied to ChatPort's header. */
.topbar { border-bottom: 1px solid var(--line); background: var(--bg-raised); }
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: 14px 32px; display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.topbar-left { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 9px; text-decoration: none; color: var(--text); }
.brand-mark { font-family: var(--mono); color: var(--accent); font-size: 20px; }
.brand-name { font-weight: 600; font-size: 19px; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Identity chip — name when registered, a Register prompt when not. Same corner ChatPort
   puts its identity chip in, own look. */
.identity-chip {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
    color: var(--text-dim); text-decoration: none; border: 1px solid var(--line); border-radius: 999px;
    padding: 5px 13px; white-space: nowrap;
}
.identity-chip:hover { border-color: var(--text-faint); color: var(--text); }

/* Icon menu — same corner and idea as ChatPort's hamburger, own look. */
.menu { position: relative; }
.menu-toggle {
    display: flex; align-items: center; justify-content: center; width: 34px; height: 34px;
    background: var(--bg-raised); border: 1px solid var(--line); border-radius: 7px;
    color: var(--text-dim); cursor: pointer; padding: 0;
}
.menu-toggle:hover { border-color: var(--text-faint); color: var(--text); }
.menu-panel {
    display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
    flex-direction: column; min-width: 175px; background: var(--bg-raised); border: 1px solid var(--line);
    border-radius: 9px; box-shadow: 0 12px 28px rgba(27,27,25,0.16); padding: 6px; gap: 1px;
}
.menu-panel.is-open { display: flex; }
.menu-panel a { padding: 9px 12px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 13.5px; font-weight: 550; }
.menu-panel a:hover { background: var(--bg-sunken); }

main { max-width: 1400px; margin: 0 auto; padding: 0 32px 80px; }

.footer { border-top: 1px solid var(--line); margin-top: 60px; padding-bottom: 26px; }

/* Company mark — the parent brand closes the page, same shape as ChatPort/WebShare. */
.footer-company { max-width: 1400px; margin: 0 auto; padding: 26px 32px 0; text-align: center; }
.footer-company-logo { height: 42px; width: auto; display: block; margin: 0 auto 8px; opacity: 0.8; transition: opacity 0.15s ease; }
.footer-company-logo:hover { opacity: 1; }
.footer-company-line { display: block; color: var(--text-faint); font-size: 12px; }
.footer-company-line a { color: var(--accent); text-decoration: none; }
.footer-company-line a:hover { text-decoration: underline; }

/* ── hero ───────────────────────────────────────────────────────────────────────────── */
.hero { padding: 48px 0 30px; max-width: 860px; }
.hero h1 { font-size: 30px; line-height: 1.3; margin: 0 0 16px; letter-spacing: -0.02em; font-weight: 650; }
.hero h1 code { font-size: 0.95em; }
.hero-sub { color: var(--text-dim); margin: 0; font-size: 16px; }
.hero-sub strong { color: var(--text); font-weight: 600; }

.alert { margin-top: 18px; padding: 11px 15px; border: 1px solid rgba(138,90,16,0.35); border-left: 3px solid var(--warn); border-radius: 5px; background: #fdf6e6; color: var(--warn); font-size: 14px; }

/* ── registration lock wall ────────────────────────────────────────────────────────── */
.lock-wall {
    max-width: 520px; margin-bottom: 40px; padding: 26px 28px; background: var(--bg-raised);
    border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 9px;
}
.lock-wall h2 { margin: 0 0 8px; font-size: 19px; font-weight: 650; }
.lock-wall p { margin: 0 0 16px; color: var(--text-dim); font-size: 14px; }
.lock-wall .run-btn { display: inline-block; text-decoration: none; }

/* ── scenarios ──────────────────────────────────────────────────────────────────────── */
.scenarios { margin-bottom: 28px; }
.scenario-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-bottom: 16px; }
.scenario-tab {
    text-align: left; background: var(--bg-raised); border: 1px solid var(--line);
    border-radius: 7px; padding: 13px 15px; color: var(--text); cursor: pointer;
    font-family: inherit; font-size: 14px; font-weight: 600; transition: border-color .12s, background .12s;
}
.scenario-tab:hover { border-color: var(--text-faint); }
.scenario-tab.is-active { border-color: var(--accent); background: #eaf1fa; box-shadow: inset 0 0 0 1px var(--accent); }
.scenario-tab:disabled { opacity: .5; cursor: not-allowed; }
.scenario-tab:disabled:hover { border-color: var(--line); }
.scenario-blurb { display: block; font-weight: 400; color: var(--text-faint); font-size: 12.5px; margin-top: 4px; line-height: 1.45; }

.input-row { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
#taskInput {
    width: 100%; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 7px;
    color: var(--text); font-family: var(--mono); font-size: 13px; line-height: 1.65; padding: 14px; resize: vertical;
}
#taskInput:focus { outline: none; border-color: var(--accent); }
#taskInput:disabled { opacity: .55; cursor: not-allowed; }
.input-side { display: flex; flex-direction: column; gap: 10px; }
.expectation { margin: 0 0 4px; color: var(--text-dim); font-size: 13.5px; }

.run-btn {
    background: var(--accent); color: #ffffff; border: none; border-radius: 6px; padding: 11px 18px;
    font-family: inherit; font-size: 14.5px; font-weight: 650; cursor: pointer;
}
.run-btn:hover { filter: brightness(1.08); }
.run-btn:disabled { opacity: .45; cursor: default; filter: none; }
.ghost-btn {
    background: transparent; color: var(--text-dim); border: 1px solid var(--line);
    border-radius: 6px; padding: 9px 16px; font-family: inherit; font-size: 13.5px; cursor: pointer;
}
.ghost-btn:hover { border-color: var(--text-faint); color: var(--text); }
.ghost-btn:disabled { opacity: .45; cursor: not-allowed; }
.ghost-btn:disabled:hover { border-color: var(--line); color: var(--text-dim); }
.budget { margin: 2px 0 0; color: var(--text-faint); font-size: 12.5px; }

/* ── the run area ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
.run-area { margin-bottom: 34px; }
.column { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 9px; padding: 20px; display: flex; flex-direction: column; min-height: 320px; }
.column-agent { border-top: 3px solid var(--agent); }

.col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.col-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.col-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-family: var(--mono); font-size: 11.5px; padding: 2px 8px; border-radius: 4px; background: var(--bg-sunken); border: 1px solid var(--line); color: var(--text-faint); }
.chip-cost { color: var(--warn); background: #fdf6e6; border-color: rgba(138,90,16,0.28); }

.col-note { color: var(--text-faint); font-size: 12.5px; margin: 8px 0 14px; }

.transcript { flex: 1; overflow-y: auto; max-height: 560px; display: flex; flex-direction: column; gap: 8px; }
.transcript .empty { color: var(--text-faint); font-size: 13.5px; font-style: italic; }

.entry { border-left: 2px solid var(--line); padding: 5px 0 5px 12px; font-size: 13.5px; }
.entry-step { border-left-color: var(--text-faint); color: var(--text-faint); font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; }
.entry-text { border-left-color: var(--agent); color: var(--text-dim); }
.entry-tool { border-left-color: var(--accent); }
.entry-tool .tool-name { font-family: var(--mono); color: var(--accent); font-size: 13px; }
.entry-tool .tool-args { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); word-break: break-word; margin-top: 2px; }
.entry-result { border-left-color: var(--line-soft); }
.entry-result .result-body { font-family: var(--mono); font-size: 11.5px; color: var(--text-faint); word-break: break-word; }
.entry-result.is-error { border-left-color: var(--bad); }
.entry-result.is-error .result-body { color: var(--bad); }
.entry-error { border-left-color: var(--bad); color: var(--bad); }

.outcome { margin-top: 14px; padding: 12px 14px; border-radius: 6px; font-size: 13.5px; display: none; }
.outcome.is-shown { display: block; }
.outcome.is-ok { background: #ecf6ef; border: 1px solid rgba(33,110,69,0.28); }
.outcome.is-bad { background: #fbeded; border: 1px solid rgba(176,42,51,0.26); }
.outcome-title { font-weight: 650; margin: 0 0 5px; }
.outcome-detail { margin: 0; color: var(--text-dim); font-size: 13px; }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-dim); cursor: pointer; }
.toggle input { margin: 0; }
.toggle:has(input:disabled) { color: var(--text-faint); cursor: not-allowed; opacity: .7; }

/* ── the world ──────────────────────────────────────────────────────────────────────── */
.world { margin-bottom: 34px; }
.world h2 { font-size: 17px; margin: 0 0 4px; font-weight: 650; }
.world-sub { color: var(--text-faint); font-weight: 400; font-size: 13.5px; }
.world-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-top: 14px; }
.world-card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.world-card h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 600; }
.world-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.world-table th { text-align: left; color: var(--text-faint); font-weight: 500; padding: 3px 8px 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 11.5px; }
.world-table td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--line-soft); font-family: var(--mono); font-size: 12px; color: var(--text-dim); vertical-align: top; }
.world-table tr.is-new td { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: #d9e7f7; } 100% { background: transparent; } }
.world-empty { color: var(--text-faint); font-size: 12.5px; font-style: italic; margin: 0; }
.email-item { border-bottom: 1px solid var(--line-soft); padding-bottom: 9px; margin-bottom: 9px; }
.email-item:last-child { border-bottom: none; margin-bottom: 0; }
.email-subject { font-size: 12.5px; font-weight: 600; margin: 0 0 3px; }
.email-body { font-size: 12.5px; color: var(--text-dim); margin: 0; white-space: pre-wrap; }

/* ── panels ─────────────────────────────────────────────────────────────────────────── */
.panels { border: 1px solid var(--line); border-radius: 9px; background: var(--bg-raised); overflow: hidden; }
.panel-tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); background: var(--bg-sunken); }
.panel-tab { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-faint); padding: 12px 18px; font-family: inherit; font-size: 13.5px; cursor: pointer; }
.panel-tab:hover { color: var(--text); }
.panel-tab.is-active { color: var(--text); border-bottom-color: var(--accent); }

.panel { display: none; padding: 20px; }
.panel.is-active { display: block; }
.panel-intro { color: var(--text-dim); font-size: 14px; margin: 0 0 14px; max-width: 780px; }
.panel-intro strong { color: var(--text); }

.code-block {
    background: var(--bg-sunken); border: 1px solid var(--line-soft); border-radius: 6px;
    padding: 14px; overflow-x: auto; max-height: 520px; overflow-y: auto;
    font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--text-dim);
    white-space: pre; margin: 0;
}
.context-meta { display: flex; gap: 14px; margin-bottom: 10px; font-family: var(--mono); font-size: 11.5px; color: var(--warn); }

.src-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.src-tab { background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 5px; color: var(--text-dim); padding: 6px 11px; font-family: var(--mono); font-size: 12px; cursor: pointer; }
.src-tab:hover { border-color: var(--text-faint); }
.src-tab.is-active { border-color: var(--accent); color: var(--accent); }
.src-blurb { color: var(--text-faint); font-size: 13px; margin: 0 0 10px; min-height: 20px; }

/* ── approval modal ─────────────────────────────────────────────────────────────────── */
.approval { position: fixed; inset: 0; background: rgba(27,27,25,0.42); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.approval[hidden] { display: none; }
.approval-card { background: var(--bg-raised); border: 1px solid var(--accent); border-radius: 9px; padding: 22px; max-width: 480px; width: 100%; box-shadow: 0 12px 32px rgba(27,27,25,0.18); }
.approval-label { margin: 0 0 5px; color: var(--text-faint); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; }
.approval-tool { margin: 0 0 10px; font-family: var(--mono); font-size: 17px; color: var(--accent); }
.approval-args { background: var(--bg-sunken); border: 1px solid var(--line-soft); border-radius: 5px; padding: 11px; font-family: var(--mono); font-size: 12px; color: var(--text-dim); overflow-x: auto; margin: 0 0 15px; white-space: pre-wrap; }
.approval-actions { display: flex; gap: 9px; }
.approval-hint { margin: 12px 0 0; color: var(--text-faint); font-size: 12.5px; }

/* ── doc pages (About / Help / Privacy / Account) ──────────────────────────────────── */
.doc { max-width: 740px; padding: 46px 0 70px; }
.doc h1 { font-size: 27px; margin: 0 0 6px; letter-spacing: -0.02em; font-weight: 650; }
.doc .doc-sub { color: var(--text-faint); font-size: 13.5px; margin: 0 0 30px; }
.doc h2 { font-size: 16.5px; margin: 30px 0 10px; font-weight: 650; }
.doc p { color: var(--text-dim); margin: 0 0 14px; }
.doc p strong, .doc li strong { color: var(--text); }
.doc ul, .doc ol { color: var(--text-dim); margin: 0 0 14px; padding-left: 20px; }
.doc li { margin-bottom: 6px; }
.doc code { font-size: 0.92em; }
.doc .doc-note {
    margin: 6px 0 18px; padding: 11px 15px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
    border-radius: 5px; background: var(--bg-raised); font-size: 13.5px; color: var(--text-dim);
}
.doc .doc-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 18px; }
.doc a.back-link { display: inline-block; margin-top: 8px; font-size: 13.5px; }

/* ── auth form (Register / Account gate) ───────────────────────────────────────────── */
.auth-card { max-width: 420px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 5px; }
.field input {
    width: 100%; background: var(--bg-sunken); border: 1px solid var(--line); border-radius: 6px;
    color: var(--text); font-family: inherit; font-size: 14px; padding: 10px 12px;
}
.field input:focus { outline: none; border-color: var(--accent); }
.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.field-errors { margin: 0 0 16px; padding: 10px 13px; border: 1px solid rgba(176,42,51,0.3); border-left: 3px solid var(--bad); border-radius: 5px; background: #fbeded; color: var(--bad); font-size: 13.5px; }
.field-errors p { margin: 0; color: var(--bad); }
.unregister-form { display: inline; }
.link-btn { background: none; border: none; padding: 0; color: var(--bad); font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: underline; }

/* ── narrow ─────────────────────────────────────────────────────────────────────────── */
@media (max-width: 980px) {
    main { padding: 0 18px 60px; }
    .topbar-inner, .footer-company { padding-left: 18px; padding-right: 18px; }
    .input-row { grid-template-columns: 1fr; }
    .hero h1 { font-size: 24px; }
}
