/* Gillespie Labs studio stylesheet ("Instrument").
 * Shared by every site: studio bar, header with 2-letter mark, nav pills, white
 * panels, a dark readout for results, dark footer. Each site sets four colours
 * (--accent, --on-accent, --accent-ink-light, --glow) in kit/gl_base.html and
 * adds only its own components in static/style.css.
 */
:root {
  --bg: #eceef1;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --line: #d9dde3;
  --line-soft: #eef0f3;
  --ink: #15181d;
  --muted: #4b5563;
  --faint: #6b7480;
  --dark: #15181d;          /* studio bar, readout, footer */
  --dark-2: #1f242b;
  --dark-line: #2c323a;
  --dark-ink: #e8ebef;
  --dark-muted: #aab2bd;
  --good: #1e7a4d; --good-bg: #e2f3ea;
  --bad: #b42318;  --bad-bg: #fbe4e1;
  --warn: #8a5a00; --warn-bg: #fff2d6;
  --accent-ink: var(--accent-ink-light);
  --radius: 14px;
  --radius-sm: 10px;
  --font-display: "Space Grotesk", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014; --panel: #161a20; --panel-2: #1b2027; --line: #2a3038; --line-soft: #20262d;
    --ink: #e8ebef; --muted: #aab2bd; --faint: #8f99a6;
    --dark: #07090c; --dark-2: #161b22; --dark-line: #252b33;
    --good: #7fd8a8; --good-bg: #13301f; --bad: #ff9a90; --bad-bg: #3a1714; --warn: #f5c76b; --warn-bg: #33270e;
    --accent-ink: var(--glow);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1014; --panel: #161a20; --panel-2: #1b2027; --line: #2a3038; --line-soft: #20262d;
  --ink: #e8ebef; --muted: #aab2bd; --faint: #8f99a6;
  --dark: #07090c; --dark-2: #161b22; --dark-line: #252b33;
  --good: #7fd8a8; --good-bg: #13301f; --bad: #ff9a90; --bad-bg: #3a1714; --warn: #f5c76b; --warn-bg: #33270e;
  --accent-ink: var(--glow);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--font-body);
       min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent-ink); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -.015em; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); font-weight: 700; margin: 0 0 .6rem; }
h2 { font-size: 1.35rem; font-weight: 600; margin: 2.2rem 0 .8rem; }
h3 { font-size: 1.05rem; font-weight: 600; }
code, kbd { font-family: var(--font-mono); font-size: .92em; }
img, svg { max-width: 100%; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto;
        padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.gl-main { flex: 1; padding-top: 2.4rem; padding-bottom: 3.5rem; }
.muted, .tool-intro, .lede { color: var(--muted); }
.tool-intro, .lede { font-size: 1.06rem; max-width: 720px; }
.small { font-size: .9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* -------------------------------------------------------- studio chrome */
.gl-bar { background: var(--dark); color: var(--dark-muted); font: 500 11px/1 var(--font-mono);
          letter-spacing: .1em; text-transform: uppercase; }
.gl-bar-inner { display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: space-between; padding-top: 8px; padding-bottom: 8px; }
.gl-bar b { color: #ffffff; font-weight: 600; }
.gl-bar a { color: var(--dark-muted); text-decoration: none; }
.gl-bar a:hover { color: #ffffff; }
.gl-header { background: var(--panel); border-bottom: 1px solid var(--line); }
.gl-header-inner { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; justify-content: space-between;
                   padding-top: 14px; padding-bottom: 14px; }
.gl-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.gl-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--on-accent);
           display: grid; place-items: center; font: 700 13px var(--font-mono); letter-spacing: .02em; flex: none; }
.gl-name { font: 700 1.3rem var(--font-display); letter-spacing: -.01em; }
.gl-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.gl-nav a { color: var(--muted); text-decoration: none; font-weight: 500; font-size: .93rem;
            padding: 6px 12px; border-radius: 9px; }
.gl-nav a:hover { background: var(--panel-2); color: var(--ink); }
.gl-nav a[aria-current] { background: var(--dark); color: #ffffff; }
.gl-footer { background: var(--dark); color: var(--dark-muted); font-size: .9rem; }
.gl-footer-inner { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) auto; gap: 18px 36px;
                   padding-top: 28px; padding-bottom: 32px; align-items: start; }
.gl-footer p { margin: 0 0 .4rem; max-width: 520px; }
.gl-wordmark { font: 600 12px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: #ffffff; }
.gl-footnote { color: var(--dark-muted); }
.gl-footer a { color: #d5dae1; }
.gl-footer a:hover { color: #ffffff; }
.gl-tools, .gl-legal { display: flex; flex-direction: column; gap: 4px; }
.gl-label { font: 500 11px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dark-muted); margin-bottom: 2px; }
@media (max-width: 760px) { .gl-footer-inner { grid-template-columns: 1fr; } .gl-tools, .gl-legal { flex-direction: row; flex-wrap: wrap; gap: 6px 16px; } }

/* ----------------------------------------------------------- page blocks */
.hero { max-width: 760px; margin-bottom: 1.5rem; }
.hero h1 { font-size: clamp(2.2rem, 6.5vw, 3.3rem); }
.hero p { color: var(--muted); font-size: 1.12rem; }
.cta { display: flex; flex-wrap: wrap; gap: .6rem; }
.button, .btn, .tool-form button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px;
  background: var(--accent); color: var(--on-accent); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .65rem 1.25rem; font: 600 .95rem var(--font-body); text-decoration: none; cursor: pointer; }
.button:hover, .tool-form button:hover { filter: brightness(1.08); }
.button.ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.button.ghost:hover { border-color: var(--ink); filter: none; }
.cards, .model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
        color: inherit; text-decoration: none; display: block; min-width: 0; }
a.card:hover, .card:has(h2 a:hover) { border-color: var(--ink); }
.card h2 { font-size: 1.12rem; margin: 0 0 .3rem; }
.card h2 a { color: var(--ink); text-decoration: none; }
.card p { margin: .25rem 0; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.chips a, .chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .8rem;
                  text-decoration: none; color: var(--ink); font-size: .92rem; font-variant-numeric: tabular-nums; }
.chips a:hover { border-color: var(--ink); }
.two, .two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 0 2rem; }
.crumbs { color: var(--faint); font-size: .9rem; margin: 0 0 .6rem; }
.crumbs a { color: var(--muted); }
.source { color: var(--faint); font-size: .85rem; margin-top: 2rem; }
.notice { background: var(--good-bg); color: var(--good); padding: 1rem; border-radius: var(--radius-sm); }

/* ------------------------------------------------------------------ forms */
form { display: grid; gap: 1rem; max-width: 560px; }
label { display: grid; align-content: start; gap: .35rem; font-size: .9rem; font-weight: 600; color: var(--muted); }
input, select, textarea { font: 500 1rem var(--font-body); color: var(--ink); background: var(--panel-2);
                          border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .75rem; width: 100%; }
input[type="number"], input[inputmode="decimal"] { font-family: var(--font-mono); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.check, label.check { display: flex; gap: .5rem; align-items: center; align-self: end; padding-bottom: .6rem; color: var(--ink); }
.check input { width: auto; }
.tool-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem;
             grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); max-width: none; margin: 1.5rem 0; }
.tool-form button { grid-column: 1 / -1; justify-self: start; }
.tool-form small { color: var(--faint); font-weight: 400; }
.tool-form input[type="number"] { font-family: var(--font-mono); }

/* --------------------------------------------- results: the dark readout */
.tool-result { background: var(--dark); color: var(--dark-ink); border-radius: var(--radius); padding: 1.4rem 1.5rem;
               margin: 1.5rem 0; display: grid; gap: .9rem; min-width: 0;
               --ink: var(--dark-ink); --muted: var(--dark-muted); --faint: var(--dark-muted); --line: var(--dark-line);
               --line-soft: var(--dark-line); --panel: var(--dark-2); --panel-2: var(--dark-2); --accent-ink: var(--glow); }
.tool-result > * { margin: 0; }
.tool-value { font: 700 clamp(1.6rem, 4.5vw, 2.4rem)/1.1 var(--font-mono); color: var(--glow); letter-spacing: -.02em; margin: 0; }
.tool-result dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: .6rem; margin: 0; }
.tool-result dl > div, .tool-result dt + dd { min-width: 0; }
.tool-result dt { color: var(--dark-muted); font-size: .8rem; margin: 0; }
.tool-result dd { margin: 0 0 .2rem; font: 500 1.05rem var(--font-mono); word-break: break-word; }
.tool-result .notes, .notes { color: var(--muted); font-size: .9rem; padding-left: 1.1rem; margin: .2rem 0 0; }
.tool-result .back a { color: var(--glow); }
.tool-error { background: var(--bad-bg); color: var(--bad); padding: .85rem 1rem; border-radius: var(--radius-sm); font-weight: 500; }
@media (min-width: 640px) {
  .tool-result dl { grid-template-columns: max-content minmax(0, 1fr); gap: .45rem 1.5rem; }
  .tool-result dt { font-size: .9rem; align-self: baseline; }
}

/* ----------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin: 1rem 0; }
table.data, table.ledger, table.chart { border-collapse: collapse; width: 100%; font-size: .94rem; font-variant-numeric: tabular-nums; }
.data th, .data td, .ledger th, .ledger td, .chart th, .chart td { padding: .5rem .9rem; border-bottom: 1px solid var(--line-soft); white-space: nowrap; text-align: left; }
.ledger td, .ledger th { text-align: right; } .ledger td:first-child, .ledger th:first-child { text-align: left; }
.data thead th, .ledger thead th, .chart thead th { font: 500 .74rem var(--font-mono); text-transform: uppercase; letter-spacing: .06em;
                                                     color: var(--faint); background: var(--panel-2); }
.data td, .ledger td { font-family: var(--font-mono); font-size: .9rem; }
.data td:first-child { font-family: var(--font-body); font-size: .94rem; }
tbody tr:last-child td { border-bottom: 0; }
.data td.up { color: var(--bad); } .data td.down { color: var(--good); }

/* ------------------------------------------------------- stat tiles, ranks */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: .75rem; margin: 1rem 0 1.5rem; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem 1rem; display: grid; gap: .15rem; }
.stats div:first-child { background: var(--dark); border-color: var(--dark); color: var(--dark-ink); }
.stats div:first-child span { color: var(--dark-muted); }
.stats div:first-child b { color: var(--glow); }
.stats span { color: var(--faint); font-size: .84rem; }
.stats b { font: 700 1.35rem var(--font-mono); letter-spacing: -.01em; }
.rank { padding-left: 1.4rem; }
.rank li { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding: .35rem 0; }
.rank span { font-family: var(--font-mono); }

/* --------------------------------------------------------- FAQ and prose */
.faq { margin-top: 2.5rem; max-width: 780px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem 1.2rem; }
.faq h2 { font-size: 1.15rem; margin: .9rem 0 .2rem; }
.faq details { border-bottom: 1px solid var(--line-soft); padding: .75rem 0; }
.faq details:last-child { border-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); margin: .5rem 0 0; }
.tool-api { margin-top: 1.6rem; color: var(--faint); font-size: .85rem; }
.page { max-width: 760px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.7rem; }
.page h1 { font-size: clamp(1.8rem, 5vw, 2.3rem); }
.page h2 { font-size: 1.2rem; margin-top: 1.6rem; }
.page form { margin-top: 1rem; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .4rem 1.5rem; }
.facts dt { color: var(--faint); } .facts dd { margin: 0; }
.ad { max-width: 1120px; margin: 1rem auto; padding: 0 16px; min-height: 90px; }

@media (max-width: 560px) {
  .gl-tagline { display: none; }
  .gl-header-inner { padding-top: 10px; padding-bottom: 10px; }
  .gl-nav a { padding: 5px 9px; }
  .facts { grid-template-columns: 1fr; gap: 0; } .facts dd { margin-bottom: .5rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .button, .chips a, .card, .gl-nav a { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
}
