/* Physics Playground: global stylesheet (shared by every page).
   Look: technical but plain, like a dashboard. Raised, slightly glossy buttons, thin borders, small radii,
   mono numerals, violet accent. Never hard-code colors in a demo: use the variables (--c1..--c5 are the data colors). */

:root {
  --header-h: 48px;
  --bg: #f6f6f8; --surface: #ffffff; --surface-2: #faf9fc; --text: #1c1b22; --muted: #6a6878;
  --border: #e4e2ea; --border-strong: #cdc9d8;
  --accent: #7c3aed; --accent-top: #9061f9; --accent-hover: #6d28d9; --accent-soft: #f3eefe; --accent-ink: #ffffff;
  --btn-top: #ffffff; --btn-bot: #f1f0f5; --btn-border: #cdc9d8; --btn-hi: rgb(255 255 255 / .9); --btn-shadow: 0 1px 1px rgb(24 20 40 / .08);
  --c1: #7c3aed; --c2: #0891b2; --c3: #d97706; --c4: #db2777; --c5: #16a34a;
  --accent-2: #0891b2; --warn: #d97706; --good: #16a34a;
  --sim-bg: #fbfbfd; --sim-grid: #e9e7ef; --sim-ink: #1c1b22;
  --glass: rgb(255 255 255 / .86);
  --radius: 8px; --shadow: 0 1px 2px rgb(24 20 40 / .05);
  --ease-pop: cubic-bezier(.2, .9, .3, 1.15);
  --font: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Sora", "Fira Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Fira Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121116; --surface: #1a191f; --surface-2: #1f1e26; --text: #ececf3; --muted: #9b98aa; --border: #2c2a36; --border-strong: #433f52;
  --accent: #a78bfa; --accent-top: #c4b5fd; --accent-hover: #c4b5fd; --accent-soft: #241f3a; --accent-ink: #14102a;
  --btn-top: #2d2b36; --btn-bot: #232129; --btn-border: #433f52; --btn-hi: rgb(255 255 255 / .07); --btn-shadow: 0 1px 1px rgb(0 0 0 / .4);
  --c1: #a78bfa; --c2: #22d3ee; --c3: #fbbf24; --c4: #f472b6; --c5: #4ade80;
  --accent-2: #22d3ee; --warn: #fbbf24; --good: #4ade80;
  --sim-bg: #15141b; --sim-grid: #2a2834; --sim-ink: #ececf3; --glass: rgb(26 25 31 / .86); --shadow: none; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121116; --surface: #1a191f; --surface-2: #1f1e26; --text: #ececf3; --muted: #9b98aa; --border: #2c2a36; --border-strong: #433f52;
    --accent: #a78bfa; --accent-top: #c4b5fd; --accent-hover: #c4b5fd; --accent-soft: #241f3a; --accent-ink: #14102a;
    --btn-top: #2d2b36; --btn-bot: #232129; --btn-border: #433f52; --btn-hi: rgb(255 255 255 / .07); --btn-shadow: 0 1px 1px rgb(0 0 0 / .4);
    --c1: #a78bfa; --c2: #22d3ee; --c3: #fbbf24; --c4: #f472b6; --c5: #4ade80;
    --accent-2: #22d3ee; --warn: #fbbf24; --good: #4ade80;
    --sim-bg: #15141b; --sim-grid: #2a2834; --sim-ink: #ececf3; --glass: rgb(26 25 31 / .86); --shadow: none; color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 1rem; line-height: 1.6; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3.6vw, 2.1rem); font-weight: 600; margin-block: .3em; }
h2 { font-size: 1.2rem; font-weight: 600; margin-block: 1.6em .4em; }
h3 { font-size: .95rem; font-weight: 600; }
p, ul, ol { margin-block: .7em; }
li { margin-block: .3em; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: .92em; }
i.ph, i.ph-fill, i.ph-bold { line-height: 1; vertical-align: -.125em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.hidden { display: none !important; }
.sr-only { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding-block: .2em; }

/* ---------- raised buttons (slight top-to-bottom gradient, hairline highlight, press-down) ---------- */
.btn {
  font: inherit; font-size: .88rem; font-weight: 500; padding: .4rem .85rem; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--btn-border); color: var(--text);
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bot));
  box-shadow: var(--btn-shadow), inset 0 1px 0 var(--btn-hi);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; white-space: nowrap;
  transition: transform .09s var(--ease-pop), box-shadow .12s, border-color .12s, filter .12s;
}
.btn:hover { border-color: var(--accent); filter: brightness(1.02); }
.btn:active { transform: translateY(1px) scale(.985); box-shadow: inset 0 2px 3px rgb(0 0 0 / .14); background: linear-gradient(180deg, var(--btn-bot), var(--btn-top)); }
.btn.primary {
  color: var(--accent-ink); border-color: var(--accent-hover);
  background: linear-gradient(180deg, var(--accent-top), var(--accent));
  box-shadow: 0 1px 2px rgb(76 29 149 / .35), inset 0 1px 0 rgb(255 255 255 / .28);
}
.btn.primary:hover { filter: brightness(1.06); border-color: var(--accent-hover); }
.btn.primary:active { background: linear-gradient(180deg, var(--accent), var(--accent-hover)); box-shadow: inset 0 2px 3px rgb(0 0 0 / .25); }
.btn[aria-pressed="true"] { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 70%, var(--accent))); color: var(--text); }
.btn.icon { inline-size: 2.4rem; block-size: 2.4rem; padding: 0; font-size: 1.15rem; border-radius: 9px; }
.btn.small { padding: .28rem .65rem; font-size: .82rem; }
.btn i { font-size: 1.15em; }

.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; inline-size: 30px; block-size: 18px; border-radius: 9px; background: var(--border-strong); position: relative; margin: 0; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; inset: 2px auto 2px 2px; inline-size: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform .2s var(--ease-pop); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(12px); }

.chip, .legend-item {
  font: inherit; font-size: .8rem; padding: .18rem .7rem; border-radius: 999px; border: 1px solid var(--btn-border);
  background: linear-gradient(180deg, var(--btn-top), var(--btn-bot)); box-shadow: inset 0 1px 0 var(--btn-hi);
  color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; transition: transform .09s var(--ease-pop), border-color .12s;
}
.chip:active, .legend-item:active { transform: scale(.95); }
.chip[aria-pressed="true"] { background: linear-gradient(180deg, var(--accent-top), var(--accent)); border-color: var(--accent-hover); color: var(--accent-ink); }
.legend { display: flex; flex-wrap: wrap; gap: .35rem; }
.legend-item { padding: .08rem .55rem; font-family: var(--mono); font-size: .72rem; }
.legend-item .dot { inline-size: .55rem; block-size: .55rem; border-radius: 50%; background: var(--dot, var(--accent)); }
.legend-item[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.legend-item[aria-pressed="false"] .dot { background: var(--border-strong); }
.tag { font-size: .72rem; padding: .08rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.seg { display: inline-flex; border: 1px solid var(--btn-border); border-radius: 8px; overflow: hidden; background: linear-gradient(180deg, var(--btn-top), var(--btn-bot)); box-shadow: var(--btn-shadow), inset 0 1px 0 var(--btn-hi); }
.seg button { font: inherit; font-size: .84rem; font-weight: 500; padding: .38rem .8rem; border: 0; background: transparent; color: var(--text); cursor: pointer; display: inline-flex; gap: .4rem; align-items: center; transition: background .12s; }
.seg button + button { border-inline-start: 1px solid var(--btn-border); }
.seg button:hover { background: var(--accent-soft); }
.seg button[aria-pressed="true"] { background: linear-gradient(180deg, var(--accent-top), var(--accent)); color: var(--accent-ink); }

/* ---------- site chrome ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .6rem; block-size: var(--header-h);
  padding: 0 clamp(.7rem, 2vw, 1.2rem); background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; gap: .5rem; align-items: center; font-family: var(--font-head); font-weight: 600; font-size: .95rem; color: var(--text); text-decoration: none; }
.brand-mark { inline-size: 1.6rem; block-size: 1.6rem; border-radius: 7px; color: #fff; background: linear-gradient(135deg, #8b5cf6, #5b21b6); display: grid; place-items: center; font-size: 1rem; box-shadow: inset 0 1px 0 rgb(255 255 255 / .25); }
.site-header .title { flex: 1; text-align: center; font-family: var(--font-head); font-weight: 600; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-header .spacer { flex: 1; }
.header-actions { display: flex; gap: .4rem; }
@media (max-width: 760px) { .header-actions .lbl, .brand .brand-name { display: none; } }
.site-footer { margin-block-start: 4rem; padding: 2rem 1rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: .5rem; flex-wrap: wrap; text-align: center; }
.footer-repo { color: inherit; display: inline-flex; align-items: center; font-size: 1.2rem; text-decoration: none; transition: color .12s; }
.footer-repo:hover { color: var(--accent); }
main { max-inline-size: 76rem; margin-inline: auto; padding: 1rem clamp(1rem, 4vw, 2rem) 0; }

/* ---------- demo page: one full-viewport app, no page scrolling ---------- */
body.demo { block-size: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.app { flex: 1; min-block-size: 0; display: flex; position: relative; overflow: hidden; }
.stage-wrap { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; }
.stage { position: relative; flex: 1; min-block-size: 0; background: var(--sim-bg); overflow: hidden; }
.stage canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.stage-readouts { position: absolute; inset: .7rem auto auto .7rem; display: flex; gap: .5rem; flex-wrap: wrap; pointer-events: none; max-inline-size: calc(100% - 1.4rem); }
.stage-tools { position: absolute; inset: .7rem .7rem auto auto; display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; z-index: 2; max-inline-size: 60%; }
.readout { background: var(--glass); border: 1px solid var(--border); border-radius: 9px; padding: .3rem .75rem; backdrop-filter: blur(6px); box-shadow: var(--shadow); }
.readout .r-label { display: block; font-size: .72rem; color: var(--muted); line-height: 1.2; }   /* no uppercase: it would turn λ, ψ, x into Λ, Ψ, X */
.readout .r-value { display: block; font-family: var(--mono); font-size: 1.15rem; font-weight: 500; white-space: nowrap; line-height: 1.3; }

.playbar { display: flex; align-items: center; gap: .6rem; padding: .55rem .9rem; border-top: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.playbar .scrub { flex: 1 1 10rem; min-inline-size: 8rem; }
.playbar .tlabel { font-family: var(--mono); font-size: .88rem; color: var(--muted); min-inline-size: 11ch; text-align: end; }
.playbar select { font: inherit; font-family: var(--mono); font-size: .85rem; padding: .3rem .4rem; border-radius: 7px; border: 1px solid var(--btn-border); background: linear-gradient(180deg, var(--btn-top), var(--btn-bot)); color: var(--text); }

/* ---------- side docks (settings on the left, graphs on the right) ---------- */
.dock { flex: none; inline-size: 0; overflow: hidden; background: var(--surface); transition: inline-size .28s var(--ease-pop); display: flex; flex-direction: column; }
.dock.left { border-inline-end: 1px solid var(--border); --dock-w: 17rem; }
.dock.right { border-inline-start: 1px solid var(--border); --dock-w: clamp(21rem, 30vw, 30rem); }
.dock.open { inline-size: var(--dock-w); }
.dock > * { min-inline-size: var(--dock-w); }
.dock-head { display: flex; align-items: center; justify-content: space-between; padding: .6rem .9rem; border-bottom: 1px solid var(--border); }
.dock-head h3 { margin: 0; }
.dock-body { flex: 1; min-block-size: 0; overflow: auto; padding: .4rem .9rem 1rem; }
@media (max-width: 640px) { .stage-readouts { inset-block-start: 3.5rem; } .stage-tools { inset-inline: .7rem; max-inline-size: none; justify-content: flex-start; } .seg button { padding: .38rem .55rem; } }
@media (max-width: 900px) {
  .dock { position: absolute; top: 0; bottom: 0; z-index: 10; box-shadow: 0 0 40px rgb(0 0 0 / .25); }
  .dock.left { left: 0; } .dock.right { right: 0; }
  .dock.right { --dock-w: min(24rem, 92vw); } .dock.left { --dock-w: min(18rem, 88vw); }
}

.graph-menu { display: flex; flex-wrap: wrap; gap: .4rem; padding: .6rem .9rem; border-bottom: 1px solid var(--border); }
.graph-menu .chip { padding: .22rem .7rem; }
.graph-list { flex: 1; min-block-size: 0; overflow: auto; padding: .7rem .8rem 1rem; display: flex; flex-direction: column; gap: .7rem; }
.graph-empty { color: var(--muted); font-size: .9rem; text-align: center; padding: 2rem 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > header { display: flex; align-items: center; gap: .75rem; padding: .5rem .8rem; border-bottom: 1px solid var(--border); }
.card > header h3 { margin: 0; flex: 1; }
.graph-card { flex: none; animation: pop-in .26s var(--ease-pop); }
.graph-card[hidden] { display: none; }
.graph-card > header { flex-wrap: wrap; row-gap: .35rem; }
.graph-card > header .legend { flex: 1 0 100%; }
.graph-body { position: relative; padding: .3rem .4rem .2rem; }
.graph-body canvas { display: block; inline-size: 100%; max-inline-size: 100%; }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.gtip {
  position: absolute; z-index: 5; inset-block-start: .4rem; pointer-events: none; padding: .35rem .6rem; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 4px 14px rgb(0 0 0 / .12);
  font-family: var(--mono); font-size: .72rem; line-height: 1.5; white-space: nowrap;
}
.gtip .gx { color: var(--muted); margin-block-end: .15rem; }
.gtip .dot { display: inline-block; inline-size: .5rem; block-size: .5rem; border-radius: 50%; margin-inline-end: .4rem; }

/* ---------- sliders, controls ---------- */
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; inline-size: 100%; block-size: 22px; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { block-size: 5px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--border) var(--p, 50%)); }
input[type="range"]::-moz-range-track { block-size: 5px; border-radius: 3px; background: var(--border); }
input[type="range"]::-moz-range-progress { block-size: 5px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; inline-size: 16px; block-size: 16px; border-radius: 50%; background: linear-gradient(180deg, var(--btn-top), var(--btn-bot)); border: 2px solid var(--accent); margin-top: -6px; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .12s var(--ease-pop); }
input[type="range"]::-moz-range-thumb { inline-size: 12px; block-size: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); transition: transform .12s var(--ease-pop); }
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.25); }
input[type="range"]:hover::-moz-range-thumb, input[type="range"]:active::-moz-range-thumb { transform: scale(1.25); }
input[type="range"]:disabled { opacity: .4; cursor: not-allowed; }
.ctl { margin-block: .75rem; }
.ctl.disabled { opacity: .45; }
.ctl-heading { margin-block: 1rem .2rem; font-family: var(--font-head); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; border-top: 1px solid var(--border); padding-top: .8rem; }
.ctl-heading:first-child { border-top: 0; padding-top: 0; margin-top: .2rem; }
.ctl > label { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .9rem; font-weight: 500; }
.ctl output { font-family: var(--mono); font-size: .82rem; color: var(--muted); }
.ctl select { inline-size: 100%; font: inherit; font-size: .9rem; padding: .35rem .5rem; border-radius: 7px; border: 1px solid var(--btn-border); background: linear-gradient(180deg, var(--btn-top), var(--btn-bot)); color: var(--text); margin-block-start: .2rem; }
.ctl .toggle { display: flex; align-items: center; gap: .55rem; font-weight: 500; cursor: pointer; justify-content: flex-start; }
.ctl-hint { font-size: .82rem; color: var(--muted); margin-block: .8rem 0; }
.chk { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); cursor: pointer; }

/* ---------- lightbox ("Read more") ---------- */
dialog.lightbox {
  padding: 0; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); color: var(--text);
  inline-size: min(58rem, 94vw); block-size: min(41rem, 88vh); box-shadow: 0 30px 90px rgb(10 6 30 / .45); overflow: hidden;
}
dialog.lightbox[open] { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr); animation: lb-in .24s var(--ease-pop); }
dialog.lightbox::backdrop { background: rgb(15 12 30 / .55); backdrop-filter: blur(3px); animation: fade-in .2s; }
@keyframes lb-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes fade-in { from { opacity: 0; } }
.lb-tabs { background: var(--surface-2); border-inline-end: 1px solid var(--border); padding: .8rem .6rem; display: flex; flex-direction: column; gap: .2rem; }
.lb-tabs h3 { margin: .2rem .5rem .6rem; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.lb-tab { font: inherit; font-size: .92rem; font-weight: 500; text-align: start; padding: .55rem .7rem; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; display: flex; gap: .6rem; align-items: center; transition: background .12s; }
.lb-tab:hover { background: var(--accent-soft); }
.lb-tab[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.lb-main { position: relative; overflow: auto; padding: 1.4rem 4rem 2rem 2rem; font-size: 1.08rem; }
.lb-main section { animation: pop-in .22s var(--ease-pop); }
.lb-main section > :first-child { margin-block-start: 0; }
.lb-close { position: absolute; inset: .7rem .7rem auto auto; z-index: 3; }
@media (max-width: 700px) { dialog.lightbox[open] { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } .lb-tabs { flex-direction: row; overflow-x: auto; padding: .5rem; } .lb-tabs h3 { display: none; } .lb-tab .lbl { display: none; } }
.predict-q { font-size: 1.15rem; font-weight: 500; }
.callout { border-radius: var(--radius); padding: .75rem 1.1rem; margin-block: 1.1rem; border: 1px solid var(--border); background: var(--surface-2); }
.callout.misconception { border-inline-start: 4px solid var(--warn); }
.callout.tip { border-inline-start: 4px solid var(--good); }
.callout > :first-child { margin-block-start: 0; } .callout > :last-child { margin-block-end: 0; }
details.reveal { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; background: var(--surface-2); }
details.reveal summary { cursor: pointer; font-weight: 600; color: var(--accent); }

/* ---------- catalog (index page) ---------- */
.hero { padding-block: 2.6rem 1rem; max-inline-size: 44rem; background: radial-gradient(40rem 12rem at 0% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent); }
.lead { font-size: 1.1rem; color: var(--muted); max-inline-size: 46rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-block: 1rem 1.4rem; }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.card-link { display: block; text-decoration: none; color: inherit; padding: 1.1rem 1.2rem; position: relative; overflow: hidden; transition: border-color .12s, transform .15s var(--ease-pop); }
.card-link::before { content: ""; position: absolute; inset: 0 0 auto 0; block-size: 3px; background: linear-gradient(90deg, #8b5cf6, #c4b5fd); opacity: 0; transition: opacity .12s; }
.card-link:hover { border-color: var(--accent); transform: translateY(-3px); }
.card-link:hover::before { opacity: 1; }
.card-link h3 { margin: 0 0 .3rem; font-size: 1.02rem; }
.card-link p { margin: 0 0 .8rem; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.card-link .meta { display: flex; gap: .4rem; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
