/* Glassbox Lab: tokens, layout, components. Light and dark; no external fonts. */
:root {
  --bg: #f7f6f2; --surface: #ffffff; --fg: #1d1c1a; --muted: #6b6a66; --line: #e2e0da;
  --accent: #2457d6; --accent2: #0f8a78; --accent3: #b36b00; --warn: #c2410c; --good: #15803d;
  --sky: #dbe8f6; --ground: #d9cfb8; --sun: #e0a100; --on-accent: #ffffff; --soft: #eef1f8; --shadow: 0 1px 2px rgba(20,20,20,.06), 0 4px 14px rgba(20,20,20,.05);
  --radius: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121314; --surface: #1b1d1f; --fg: #ecebe7; --muted: #a3a19b; --line: #2c2f33;
    --accent: #7aa2ff; --accent2: #3cc7b0; --accent3: #f0a83a; --warn: #ff8a5c; --good: #4ade80;
    --sky: #1d2a3a; --ground: #3a3428; --sun: #ffd34d; --on-accent: #0c1220; --soft: #20242b; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121314; --surface: #1b1d1f; --fg: #ecebe7; --muted: #a3a19b; --line: #2c2f33;
  --accent: #7aa2ff; --accent2: #3cc7b0; --accent3: #f0a83a; --warn: #ff8a5c; --good: #4ade80;
  --sky: #1d2a3a; --ground: #3a3428; --sun: #ffd34d; --on-accent: #0c1220; --soft: #20242b; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif; font-variant-numeric: tabular-nums; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; } /* components set display (e.g. .btn is inline-flex), which would otherwise beat the hidden attribute */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--on-accent); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* shell */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 14px; min-height: 58px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.logo { font-weight: 700; font-size: 1.15rem; text-decoration: none; color: var(--fg); display: flex; align-items: center; gap: 8px; }
.logo i { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: inline-block; }
.nav { display: flex; gap: 4px; margin-right: auto; }
.nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); min-height: 40px; display: inline-flex; align-items: center; }
.nav a[aria-current="page"], .nav a:hover { color: var(--fg); background: var(--soft); }
.tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.iconbtn::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--fg); background: linear-gradient(90deg, var(--fg) 50%, transparent 50%); display: block; }
.iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.chipbal { font-size: .85rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; background: var(--surface); }
main.wrap { padding: 28px 16px 48px; min-height: 60vh; }
h1:focus, h1[tabindex="-1"]:focus-visible { outline: none; }
main:focus { outline: none; }
.foot { border-top: 1px solid var(--line); padding: 20px 0 40px; color: var(--muted); font-size: .88rem; }
.foot p { margin: 0 0 .6em; }
.foot img { vertical-align: middle; }
.banner-demo { background: var(--soft); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* buttons */
.gb-btn, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; text-decoration: none; color: var(--fg); font-weight: 500; }
.gb-btn:hover, .btn:hover { border-color: var(--muted); }
.gb-btn:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; }
.gb-primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.gb-btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.gb-link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 8px 0; min-height: 44px; text-decoration: underline; }
.gb-select, select, input[type=text], input[type=number], textarea { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 6px 10px; }
.gb-pulse { animation: gbpulse 1s ease-in-out 3; }
@keyframes gbpulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 40%, transparent); } }

/* home */
.hero { max-width: 760px; margin-bottom: 28px; }
.hero p { color: var(--muted); font-size: 1.05rem; }
.create { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); max-width: 760px; }
.create label.lab { display: block; font-weight: 600; margin-bottom: 6px; }
.create input[type=text] { width: 100%; font-size: 1.05rem; }
.hint, .gb-hint { color: var(--muted); font-size: .88rem; }
.levels { border: 0; padding: 0; margin: 14px 0 6px; display: flex; flex-wrap: wrap; gap: 8px; }
.levels legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.levels label { position: relative; }
.levels input { position: absolute; opacity: 0; inset: 0; }
.levels span { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; }
.levels input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.levels input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.err { color: var(--warn); margin: 6px 0 0; min-height: 1.2em; }
.section-title { margin: 36px 0 14px; font-size: 1.3rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.gb-gcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.gb-gthumb { background: var(--sky); border-bottom: 1px solid var(--line); }
.gb-thumb { display: block; width: 100%; height: auto; min-height: 120px; }
.gb-gbody { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.gb-gbody h3 { margin: 4px 0; } .gb-gbody p { color: var(--muted); font-size: .92rem; flex: 1; }
.gb-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.gb-tag, .gb-chip { display: inline-flex; align-items: center; font-size: .78rem; padding: 2px 10px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); color: var(--muted); }
.gb-chip-btn { cursor: pointer; min-height: 32px; color: var(--fg); background: var(--surface); }
.gb-chip-check { cursor: pointer; color: var(--fg); background: var(--surface); }
.gb-chip-origin { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

/* dialogs */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--fg); padding: 0; max-width: min(560px, calc(100vw - 24px)); width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 18px; }
.cost { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .92rem; }
.cost td { padding: 6px 4px; border-bottom: 1px solid var(--line); } .cost td:last-child { text-align: right; white-space: nowrap; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

/* progress */
.progress { max-width: 640px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.steps { list-style: none; padding: 0; margin: 16px 0; }
.steps li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps .st { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; margin-top: 2px; }
.steps .done .st { background: var(--good); border-color: var(--good); color: #fff; }
.steps .warn .st { background: var(--accent3); border-color: var(--accent3); color: #fff; }
.steps .error .st { background: var(--warn); border-color: var(--warn); color: #fff; }
.steps .skipped .st { opacity: .5; }
.steps .active .st { border-color: var(--accent); border-top-color: transparent; animation: spin .9s linear infinite; }
.steps .detail { color: var(--muted); font-size: .88rem; text-align: right; max-width: 260px; }
.steps .pending { opacity: .6; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { font-weight: 600; min-height: 1.5em; }

/* settings */
.settings { max-width: 680px; display: grid; gap: 14px; }
.settings .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.settings label.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; flex-wrap: wrap; }

/* lesson */
.gb-lhead { margin-bottom: 14px; max-width: 900px; }
.gb-bigidea { font-size: 1.1rem; color: var(--muted); }
.gb-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.gb-banner { display: flex; gap: 12px; justify-content: space-between; align-items: center; flex-wrap: wrap; border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--surface); padding: 10px 14px; border-radius: 8px; margin: 0 0 12px; }
.gb-banner-warn { border-left-color: var(--warn); }
.gb-lgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.gb-lgrid > * { min-width: 0; }
.gb-canvas, .gb-chart, .gb-thumb { max-width: 100%; }
@media (min-width: 960px) { .gb-lgrid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } .gb-stagecol { position: sticky; top: 72px; } }
.gb-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.gb-cover { margin: 0 0 12px; } .gb-cover img { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.gb-cover figcaption { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.gb-simhost { min-width: 0; }
.gb-stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); position: relative; }
.gb-canvas { display: block; width: 100%; background: var(--surface); }
.gb-canvas:focus-visible { outline-offset: -3px; }
.gb-note { margin: 0; padding: 8px 12px; background: color-mix(in srgb, var(--warn) 14%, var(--surface)); color: var(--fg); border-top: 1px solid var(--line); }
.gb-transport { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.gb-time { margin-left: auto; color: var(--muted); font-size: .9rem; }
.gb-readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.gb-ro { background: var(--surface); padding: 8px 12px; }
.gb-ro-label { display: block; font-size: .78rem; color: var(--muted); }
.gb-ro-val { font-size: 1.15rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.gb-ro small { color: var(--muted); }
.gb-charts { display: grid; gap: 12px; margin-top: 12px; }
.gb-fig { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px 6px; }
.gb-fig figcaption { font-size: .88rem; font-weight: 600; margin-bottom: 2px; }
.gb-chart { display: block; width: 100%; height: 170px; }
.gb-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--muted); }
.gb-lg { display: inline-flex; align-items: center; gap: 6px; } .gb-lg i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.gb-param { padding: 8px 0; border-bottom: 1px solid var(--line); }
.gb-param-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gb-param-top input[type=number] { width: 96px; text-align: right; }
.gb-param input[type=range] { width: 100%; min-height: 36px; accent-color: var(--accent); }
.gb-param small { color: var(--muted); }
.gb-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.gb-tabs { display: flex; flex-wrap: wrap; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: -4px -4px 12px; padding: 0 4px; }
.gb-tab { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 12px; cursor: pointer; white-space: nowrap; color: var(--muted); min-height: 44px; }
.gb-tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.gb-pane[hidden] { display: none; }
.gb-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.gb-tour { list-style: none; counter-reset: s; padding: 0; margin: 12px 0 0; }
.gb-step { counter-increment: s; padding: 12px 12px 12px 44px; position: relative; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: var(--surface); }
.gb-step::before { content: counter(s); position: absolute; left: 12px; top: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--soft); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; }
.gb-step.gb-active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.gb-step.gb-active::before { background: var(--accent); color: var(--on-accent); }
.gb-cite { font-size: .72rem; padding: 0 6px; min-height: 22px; border-radius: 6px; border: 1px solid var(--line); background: var(--soft); color: var(--accent); cursor: pointer; margin: 0 2px; vertical-align: baseline; }
.gb-inline { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; }
.gb-pcard { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0 0 12px; min-width: 0; }
.gb-pcard legend { font-weight: 600; padding: 0 6px; }
.gb-opts { display: grid; gap: 6px; margin: 8px 0; }
.gb-opt { display: flex; gap: 8px; align-items: center; min-height: 44px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.gb-verdict { font-weight: 600; } .gb-right { color: var(--good); } .gb-wrong { color: var(--warn); }
.gb-measure { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--soft); padding: 6px 10px; border-radius: 8px; }
.gb-note-corrected { font-size: .88rem; color: var(--accent3); }
.gb-score { font-weight: 600; }
.gb-eq { padding: 8px 0; border-bottom: 1px solid var(--line); } .gb-eq code { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92rem; overflow-wrap: anywhere; } .gb-eqnote { color: var(--muted); font-size: .85rem; }
.gb-checks { list-style: none; padding: 0; margin: 0 0 12px; }
.gb-check { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; }
.gb-ic { flex: none; width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; color: #fff; margin-top: 2px; background: var(--muted); }
.gb-ic-ok { background: var(--good); } .gb-ic-warn { background: var(--accent3); } .gb-ic-err { background: var(--warn); }
.gb-tablewrap { overflow-x: auto; } .gb-claims { border-collapse: collapse; width: 100%; font-size: .9rem; } .gb-claims th, .gb-claims td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.gb-badge { font-size: .72rem; border-radius: 6px; padding: 1px 8px; border: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
.gb-badge-established { color: var(--good); } .gb-badge-simplification { color: var(--accent3); } .gb-badge-uncertain { color: var(--warn); }
.gb-sources { padding-left: 22px; } .gb-sources li { padding: 4px 0; } .gb-flash { background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 6px; }
.gb-stance { font-size: .88rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.gb-gloss dt { font-weight: 600; margin-top: 8px; } .gb-gloss dd { margin: 0 0 4px; color: var(--muted); }
.gb-misc { list-style: none; padding: 0; } .gb-misc li { padding: 8px 0; border-bottom: 1px solid var(--line); } .gb-wrongtxt { color: var(--warn); }
.gb-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.gb-exportfoot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: calc(100vw - 32px); }
.toast[hidden] { display: none; }
@media (max-width: 600px) { .gb-btn, .btn { padding: 8px 12px; } .steps .detail { max-width: 150px; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }
