:root {
  --bg: #ffffff; --fg: #09090b; --muted: #71717a; --muted-bg: #f4f4f5;
  --card: #ffffff; --border: #e4e4e7; --primary: #18181b; --primary-fg: #fafafa;
  --ring: #a1a1aa; --danger: #dc2626; --ok: #16a34a; --ok-bg: #f0fdf4; --ok-border: #bbf7d0;
  --accent: #ff6a00; --accent-fg: #ffffff; --accent-soft: rgb(255 106 0 / .12);
  --radius: 8px; --shadow: 0 1px 2px rgb(0 0 0 / .05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b; --fg: #fafafa; --muted: #a1a1aa; --muted-bg: #18181b;
    --card: #0c0c0e; --border: #27272a; --primary: #fafafa; --primary-fg: #18181b;
    --ring: #52525b; --danger: #f87171; --ok: #4ade80; --ok-bg: #052e16; --ok-border: #166534;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
main a:not(.btn):not(.tabs a):not(.seg a) { color: var(--accent); }
code, pre { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { background: var(--muted-bg); border: 1px solid var(--border); border-radius: 5px; padding: .1rem .35rem; overflow-wrap: anywhere; }
pre { margin: 0; padding: .9rem 1rem; background: var(--muted-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
pre code { background: none; border: 0; padding: 0; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; margin: 0 0 .35rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
ul { margin: 0 0 .75rem; padding-left: 1.2rem; }
li { margin-bottom: .3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 1rem; }
.narrow { max-width: 400px; margin: 3rem auto; }
.top { border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 2; }
.top .row { min-height: 56px; gap: .9rem; }
.brand { font-weight: 600; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: .4rem; }
.brand span { color: var(--muted); font-weight: 500; }
.who { margin-left: auto; display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
main { padding: 1.75rem 0 3rem; min-width: 0; }
main.wrap { padding: 1.75rem 1rem 3rem; }
.foot { padding: 1.25rem 1rem 2.5rem; border-top: 1px solid var(--border); font-size: .85rem; }


.row { display: flex; align-items: center; gap: .75rem; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: .9rem; }
.stack > h2 { margin-bottom: 0; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card-new { border-color: var(--accent); background: var(--accent-soft); }
.badge { font-size: .75rem; border: 1px solid var(--border); border-radius: 999px; padding: .1rem .55rem; color: var(--muted); white-space: nowrap; }
.alert { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent); border-radius: var(--radius); padding: .6rem .8rem; }

.label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; }
.input {
  width: 100%; min-width: 0; background: var(--bg); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; padding: .55rem .7rem; font: inherit; line-height: 1.3;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.stack .label { margin-top: .9rem; }
.stack .label:first-of-type { margin-top: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 500; line-height: 1; padding: .6rem .95rem; border-radius: 6px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { opacity: .9; }
.btn-outline { background: var(--card); border-color: var(--border); color: var(--fg); }
.btn-outline:hover { background: var(--muted-bg); }
.btn-ghost { background: none; color: var(--muted); }
.btn-ghost:hover { color: var(--fg); background: var(--muted-bg); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: .4rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; margin-top: 1.1rem; }

.copy-row { display: flex; gap: .5rem; align-items: stretch; }
.copy-row code { flex: 1; padding: .55rem .7rem; display: block; }
.secret { font-weight: 500; }

.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: .8rem; padding: 0 .5rem .5rem; border-bottom: 1px solid var(--border); }
.table td { padding: .65rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; }
.table form { margin: 0; }

.kv { width: 100%; border-collapse: collapse; }
.kv th { text-align: left; font-weight: 500; color: var(--muted); width: 7.5rem; padding: .45rem .5rem .45rem 0; vertical-align: top; font-size: .9rem; }
.kv td { padding: .45rem 0; border-bottom: 1px solid var(--border); }
.kv tr:last-child td { border-bottom: 0; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; padding: 2px; background: var(--muted-bg); }
.seg a { text-decoration: none; color: var(--muted); font-size: .85rem; padding: .3rem .7rem; border-radius: 4px; white-space: nowrap; }
.seg a[aria-current] { background: var(--card); color: var(--accent); box-shadow: var(--shadow); font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .1rem; box-shadow: var(--shadow); }
.stat strong { font-size: 1.45rem; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat > .muted { font-size: .85rem; }

.chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; padding-top: .25rem; }
.chart .bar:only-child { flex: 0 0 24px; }
.bar { flex: 1; min-width: 2px; height: max(var(--h), 2px); background: var(--accent); opacity: .85; border-radius: 2px 2px 0 0; }
.bar:hover { opacity: 1; }
.axis { display: flex; justify-content: space-between; margin-top: .35rem; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .top .row { gap: .75rem; flex-wrap: wrap; padding: .6rem 1rem; }
  .brand, .who { min-height: 36px; }
  .tabs { order: 3; width: 100%; justify-content: space-around; gap: 0; border-top: 1px solid var(--border); padding-top: .35rem; margin-top: .1rem; }
  .tabs a { flex-direction: column; gap: .15rem; font-size: .68rem; padding: .25rem .4rem; flex: 1; }
  .tabs svg { width: 20px; height: 20px; }
  .who .muted { display: none; }
  .wrap-sm { flex-wrap: wrap; }
  .wrap-sm .seg { width: 100%; }
  .wrap-sm .seg a { flex: 1; text-align: center; }
  .wrap-sm .btn { width: 100%; }
  .copy-row { flex-direction: column; }
  .table thead { display: none; }
  .table tr { display: block; padding: .6rem 0; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; border: 0; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .table .actions { justify-content: flex-end; padding-top: .5rem; }
  .table .actions::before { content: none; }
  .kv th { width: auto; display: block; padding-bottom: 0; }
  .kv td { display: block; padding-top: .15rem; }
}
@media (max-width: 400px) {
  .stats { grid-template-columns: 1fr; }
}

/* playground */
.ptabs a { padding: .3rem .6rem; }
.play { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1rem; align-items: start; }
.panel .card { margin-bottom: 0; }
.options h2 { margin-bottom: .6rem; }
.options .label { margin-top: .75rem; }
.options .label:first-of-type { margin-top: 0; }
.options .label .input, .options .label textarea { margin-top: .3rem; }
.options output { float: right; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.options input[type=range] { width: 100%; margin: .35rem 0 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: .5rem; margin-top: .9rem; font-size: .9rem; }
.check + .row { margin-top: .9rem; }
.chat { display: flex; flex-direction: column; min-height: 65vh; max-height: 80vh; padding: 0; overflow: hidden; }
.chatlog { flex: 1; overflow-y: auto; padding: .25rem 0; }
.chatlog .empty { height: 100%; min-height: 12rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; color: var(--muted); }
.chatlog .empty strong { color: var(--fg); font-size: 1.1rem; }
.msg { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: .5rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); }
.msg:last-child { border-bottom: 0; }
.msg .who { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding-top: .2rem; }
.msg.user .who { color: var(--accent); }
.msg .body { line-height: 1.6; overflow-wrap: anywhere; }
.msg.user .body { white-space: pre-wrap; }
.msg .body p { margin: 0 0 .6rem; } .msg .body p:last-child { margin-bottom: 0; }
.msg .body h3, .msg .body h4, .msg .body h5, .msg .body h6 { font-size: 1rem; margin: .8rem 0 .4rem; }
.msg .body ul, .msg .body ol { margin: .2rem 0 .6rem; padding-left: 1.4rem; }
.msg .body pre { margin: .5rem 0; padding: .7rem .9rem; font-size: 12.5px; }
.msg .body code { font-size: .85em; }
.msg .body pre code { font-size: 12.5px; }
.msg .err { color: var(--danger); }
.reasoning { color: var(--muted); font-size: .85rem; margin-bottom: .6rem; }
.reasoning summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: .35rem; }
.reasoning summary::before { content: "▸"; font-size: .7rem; transition: transform .15s; }
.reasoning[open] summary::before { transform: rotate(90deg); }
.reasoning div { white-space: pre-wrap; margin-top: .4rem; border-left: 2px solid var(--border); padding-left: .7rem; max-height: 16rem; overflow-y: auto; }
.composer { padding: .6rem 1rem .9rem; border-top: 1px solid var(--border); }
.composer-box { border: 1px solid var(--border); border-radius: 14px; background: var(--bg); padding: .45rem .55rem .45rem .9rem; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-box textarea { width: 100%; border: 0; background: none; color: var(--fg); font: inherit; line-height: 1.5; resize: none; max-height: 220px; padding: .35rem 0; outline: none; }
.composer-row { display: flex; align-items: center; gap: .5rem; }
.composer .attach { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); cursor: pointer; }
.composer .attach:hover { background: var(--muted-bg); color: var(--fg); }
.composer .send { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.composer .send:disabled { opacity: .45; cursor: default; }
.sysbox { border-bottom: 1px solid var(--border); padding: .6rem 1.1rem; }
.sysbox summary { cursor: pointer; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sysbox textarea { margin-top: .5rem; }
textarea.input { resize: vertical; font: inherit; line-height: 1.45; }
textarea.mono { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.input.inline { width: auto; display: inline-block; margin-left: .4rem; padding: .35rem .5rem; }
.panel .controls { gap: .6rem; }
.file-btn { cursor: pointer; }
#rec.recording { background: var(--danger); color: #fff; border-color: transparent; }
audio { width: 100%; }
@media (max-width: 860px) {
  .play { grid-template-columns: 1fr; }
  .options { order: 2; }
  .chat { min-height: 55vh; max-height: none; }
  .msg { grid-template-columns: 1fr; gap: .2rem; padding: .75rem .9rem; }
  .ptabs { width: 100%; }
  .ptabs a { flex: 1; text-align: center; padding: .3rem .2rem; font-size: .8rem; }
  .panel .controls .btn { width: auto; }
  .composer .btn { width: auto; }
}

input[type=checkbox] { accent-color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.toolbar h1 { margin: 0; }
.toolbar .model-pick { margin-left: auto; }
@media (max-width: 860px) { .toolbar .model-pick { margin-left: 0; width: 100%; } .toolbar .model-pick .input { width: 100%; margin-left: 0; margin-top: .3rem; } }

.share { width: 100%; min-width: 4rem; height: 6px; background: var(--muted-bg); border-radius: 3px; overflow: hidden; }
.share span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
@media (max-width: 720px) { .table td[data-label="Share"] { display: none; } }

/* docs: sidebar chapters + content, like the OpenAI/Anthropic reference pages */
.docs { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.docnav { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; font-size: .9rem; padding-right: .5rem; }
.docnav-group { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 1rem 0 .35rem; }
.docnav-group:first-child { margin-top: 0; }
.docnav a { display: block; color: var(--muted); text-decoration: none; padding: .3rem .6rem; border-radius: 6px; border-left: 2px solid transparent; }
.docnav a:hover { color: var(--fg); background: var(--muted-bg); }
.docnav a[aria-current] { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
.doccontent { min-width: 0; max-width: 720px; }
.doccontent section { padding: .5rem 0 2.25rem; border-bottom: 1px solid var(--border); scroll-margin-top: 72px; }
.doccontent section:last-child { border-bottom: 0; }
.doccontent h1 { font-size: 1.8rem; margin-bottom: .6rem; }
.doccontent h2 { font-size: 1.3rem; margin: 1.6rem 0 .6rem; letter-spacing: -.01em; }
.doccontent h3 { font-size: .95rem; margin: 1.3rem 0 .4rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.doccontent .lead { font-size: 1.05rem; color: var(--muted); }
.doccontent p, .doccontent li { line-height: 1.65; }
.doccontent pre { margin: .75rem 0 1rem; }
.params { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; font-size: .92rem; }
.params th { text-align: left; font-weight: 500; color: var(--fg); width: 11rem; padding: .5rem .6rem .5rem 0; vertical-align: top; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }
.params td { padding: .5rem 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.params tr:last-child td, .params tr:last-child th { border-bottom: 0; }
.params th { border-bottom: 1px solid var(--border); }

/* app shell: sidebar with the navigation (and the docs chapters), content on the right */
.menu { display: none; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--fg); cursor: pointer; padding: 0; align-items: center; justify-content: center; }
.menu svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.side { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; padding: 1.25rem 0 1rem; font-size: .92rem; }
.sidenav a, .chapters a { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--muted); padding: .42rem .7rem; border-radius: 7px; }
.sidenav a:hover, .chapters a:hover { color: var(--fg); background: var(--muted-bg); }
.sidenav a[aria-current] { color: var(--fg); background: var(--muted-bg); font-weight: 500; }
.sidenav a[aria-current] svg { color: var(--accent); }
.sidenav svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-group { font-size: .7rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 1.4rem .7rem .4rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.side-sub { font-size: .7rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: .9rem .7rem .25rem; opacity: .8; }
.chapters a { padding: .3rem .7rem; font-size: .88rem; border-left: 2px solid transparent; border-radius: 0 7px 7px 0; }
.chapters a[aria-current] { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }
.side-overlay { position: fixed; inset: 0; background: rgb(0 0 0 / .35); z-index: 5; }
.doccontent { min-width: 0; max-width: 760px; }
.doccontent section { padding: .5rem 0 2.25rem; border-bottom: 1px solid var(--border); scroll-margin-top: 72px; }
.doccontent section:last-child { border-bottom: 0; }
.doccontent h1 { font-size: 1.8rem; margin-bottom: .6rem; }
.doccontent h2 { font-size: 1.3rem; margin: 1.6rem 0 .6rem; letter-spacing: -.01em; }
.doccontent h3 { font-size: .8rem; margin: 1.3rem 0 .4rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.doccontent .lead { font-size: 1.05rem; color: var(--muted); }
.doccontent p, .doccontent li { line-height: 1.65; }
.doccontent pre { margin: .75rem 0 1rem; }
.params { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; font-size: .92rem; }
.params th { text-align: left; font-weight: 500; color: var(--fg); width: 11rem; padding: .5rem .6rem .5rem 0; vertical-align: top; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; border-bottom: 1px solid var(--border); }
.params td { padding: .5rem 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.params tr:last-child td, .params tr:last-child th { border-bottom: 0; }
@media (max-width: 900px) {
  .menu { display: inline-flex; }
  .shell { display: block; }
  .side { position: fixed; top: 0; left: 0; bottom: 0; width: min(80vw, 300px); max-height: none; z-index: 6; background: var(--bg); border-right: 1px solid var(--border);
          padding: 1rem .8rem; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 0 0 40px rgb(0 0 0 / .25); }
  .side.open { transform: none; }
  .main { padding-top: 1.25rem; }
  .params th { width: auto; display: block; padding-bottom: 0; border-bottom: 0; }
  .params td { display: block; padding-top: .15rem; }
}

.stat .up { color: var(--ok); }
.stat .down { color: var(--muted); }
