/* Workshop Labs: shared design system.
   Type: Newsreader (headings), IBM Plex Sans (body), IBM Plex Mono (code only).
   Each lab sets its own accent through [data-lab]. */

:root {
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --paper: #fbfcfb;
  --surface: #ffffff;
  --sunk: #f1f4f3;
  --ink: #17211f;
  --ink-2: #4a5754;
  --muted: #6b7774;
  --line: #dde4e1;
  --line-2: #c9d3cf;
  --ok: #1f7a4d;
  --ok-bg: #e5f3eb;
  --warn: #8a5a00;
  --warn-bg: #fbf0d9;
  --bad: #a3322a;
  --bad-bg: #fbe7e4;
  --focus: #2b6cb0;
  --radius-s: 6px;
  --radius: 10px;
  --shadow: 0 1px 0 rgba(23, 33, 31, .04), 0 8px 24px -16px rgba(23, 33, 31, .25);
}
[data-lab="slr"] { --accent: #1d6b63; --accent-ink: #ffffff; --accent-soft: #e3f0ee; --accent-2: #b97a1e; }
[data-lab="studio"] { --accent: #4a3c8c; --accent-ink: #ffffff; --accent-soft: #ebe8f6; --accent-2: #c4513a; }

[data-theme="dark"] {
  --paper: #121615; --surface: #191e1d; --sunk: #202725; --ink: #e6ecea; --ink-2: #bcc7c4; --muted: #8f9b98;
  --line: #2b3432; --line-2: #3a4542; --ok: #6cc596; --ok-bg: #173126; --warn: #e3b25c; --warn-bg: #362a12;
  --bad: #f08a7e; --bad-bg: #3b1f1c; --focus: #8ab4f8;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .8);
}
[data-theme="dark"][data-lab="slr"] { --accent: #5fb8ad; --accent-ink: #0d1a18; --accent-soft: #19302d; --accent-2: #e0a64d; }
[data-theme="dark"][data-lab="studio"] { --accent: #a99cf0; --accent-ink: #15112a; --accent-soft: #252040; --accent-2: #f08a6f; }

* { box-sizing: border-box; }
html { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2rem, 3.2vw, 2.75rem); }
h2 { font-size: 1.85rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 .75rem; max-width: 72ch; }
a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: .86rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- controls */
label.field { display: grid; gap: .3rem; margin-bottom: 1rem; }
label.field > span.lbl { font-weight: 600; font-size: .9rem; }
label.field > span.hint { color: var(--muted); font-size: .82rem; margin-top: -.15rem; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--radius-s); padding: .55rem .7rem; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: .84rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { display: inline-flex; align-items: center; gap: .5rem; font: 600 .92rem/1 var(--sans); padding: .7rem 1.05rem;
  border-radius: var(--radius-s); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); padding: .5rem .6rem; }
.btn.quiet:hover { background: var(--sunk); }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn .spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: .25rem 0 1.25rem; }
.actions .note { color: var(--muted); font-size: .85rem; }
.checks { display: flex; flex-wrap: wrap; gap: .5rem .9rem; }
.checks label { display: inline-flex; gap: .4rem; align-items: center; font-size: .92rem; }

/* ---------------------------------------------------------------- feedback */
.callout { border-left: 3px solid var(--line-2); background: var(--sunk); padding: .75rem 1rem; border-radius: 0 var(--radius-s) var(--radius-s) 0; margin: 0 0 1rem; max-width: 80ch; }
.callout p:last-child { margin-bottom: 0; }
.callout.ok { border-color: var(--ok); background: var(--ok-bg); }
.callout.warn { border-color: var(--warn); background: var(--warn-bg); }
.callout.bad { border-color: var(--bad); background: var(--bad-bg); }
.callout.accent { border-color: var(--accent); background: var(--accent-soft); }
.badge { display: inline-block; font-size: .78rem; font-weight: 600; padding: .12rem .5rem; border-radius: 99px; background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: .7rem 1rem;
  border-radius: var(--radius-s); box-shadow: var(--shadow); max-width: min(560px, 92vw); z-index: 50; font-size: .92rem; }
.toast.bad { background: var(--bad); color: #fff; }
.progress { height: 6px; background: var(--sunk); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .25s; }

/* ---------------------------------------------------------------- data display */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin: 0 0 1.25rem; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; vertical-align: top; padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
th { font-weight: 600; color: var(--ink-2); background: var(--sunk); font-size: .82rem; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.flag td { background: color-mix(in srgb, var(--warn-bg) 60%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .sub { color: var(--muted); font-size: .82rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 1.25rem; }
.stat { background: var(--surface); padding: 1rem 1.1rem; }
.stat b { display: block; font: 500 2.1rem/1.05 var(--serif); font-variant-numeric: tabular-nums; color: var(--accent); }
.stat span { color: var(--ink-2); font-size: .85rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .35rem 0 .2rem; }
.chip { font-size: .84rem; padding: .18rem .55rem; border: 1px solid var(--line-2); border-radius: 99px; background: var(--surface); }
.chip.local { border-color: var(--accent-2); color: var(--accent-2); font-weight: 600; }
.codebox { position: relative; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 2.4rem .9rem .8rem; margin: .35rem 0 1rem; }
.codebox pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
.codebox .copy { position: absolute; top: .4rem; right: .4rem; }
.prose { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; font-family: var(--serif); font-size: 1.05rem; line-height: 1.7; max-width: 78ch; }
.prose h4 { font: 600 .95rem var(--sans); margin: 1rem 0 .3rem; }
.prose h4:first-child { margin-top: 0; }
.section-title { font: 600 1rem var(--sans); margin: 1.5rem 0 .6rem; }
details.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 1rem; }
details.panel > summary { cursor: pointer; padding: .7rem 1rem; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.panel > summary::after { content: "Show"; font-weight: 500; color: var(--muted); font-size: .85rem; }
details.panel[open] > summary::after { content: "Hide"; }
details.panel > .inner { padding: 0 1rem 1rem; }

/* ---------------------------------------------------------------- app shell */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1.25rem; padding: .7rem 1.5rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: .75rem; min-width: 0; }
.brand .name { font: 500 1.35rem/1 var(--serif); white-space: nowrap; }
.brand .by { color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.groupchip { font-size: .85rem; color: var(--ink-2); white-space: nowrap; }
.groupchip b { color: var(--ink); }
.meter { display: grid; gap: .25rem; width: 170px; font-size: .78rem; color: var(--ink-2); }
.meter .progress { height: 5px; }
.meter.low .progress > i { background: var(--warn); }
.layout { display: grid; grid-template-columns: 236px minmax(0, 1fr) 300px; gap: 0; min-height: calc(100vh - 58px); }
.rail { border-right: 1px solid var(--line); padding: 1.5rem 1rem; position: sticky; top: 58px; align-self: start; height: calc(100vh - 58px); overflow-y: auto; }
.rail ol { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.rail li a { display: grid; grid-template-columns: 1.9rem 1fr; align-items: center; gap: .55rem; padding: .5rem .55rem; border-radius: var(--radius-s); color: var(--ink-2); text-decoration: none; font-size: .92rem; }
.rail li a .n { width: 1.7rem; height: 1.7rem; border-radius: 50%; display: grid; place-items: center; font: 600 .8rem var(--sans); border: 1.5px solid var(--line-2); color: var(--ink-2); background: var(--surface); }
.rail li a:hover { background: var(--sunk); }
.rail li a[aria-current="step"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.rail li a[aria-current="step"] .n { border-color: var(--accent); color: var(--accent); }
.rail li a.done .n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rail .railfoot { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); display: grid; gap: .25rem; }
main.work { padding: 2rem 2.5rem 4rem; min-width: 0; }
.stephead { margin-bottom: 1.25rem; max-width: 78ch; }
.stephead .kicker { color: var(--accent); font-weight: 600; font-size: .88rem; margin-bottom: .35rem; }
.stephead p.lede { color: var(--ink-2); font-size: 1.02rem; margin-top: .5rem; }
.guide { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .9rem 1.1rem .5rem; margin-bottom: 1.5rem; max-width: 78ch; }
.guide h3 { font: 600 .9rem var(--sans); margin-bottom: .5rem; }
.guide ol { margin: 0; padding-left: 1.2rem; }
.guide li { margin-bottom: .45rem; }
.guide li::marker { color: var(--accent); font-weight: 700; }
.stepnav { display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); margin-top: 2.5rem; padding-top: 1.25rem; max-width: 78ch; }

/* lab notebook: the running record of every model call */
.notebook { border-left: 1px solid var(--line); background: var(--surface); padding: 1.5rem 1.1rem; position: sticky; top: 58px; align-self: start; height: calc(100vh - 58px); overflow-y: auto; }
.notebook h2 { font-size: 1.25rem; }
.notebook .sub { color: var(--muted); font-size: .82rem; margin: .2rem 0 1rem; }
.nb-totals { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.nb-totals div { background: var(--sunk); border-radius: var(--radius-s); padding: .55rem .65rem; }
.nb-totals b { display: block; font: 500 1.35rem/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.nb-totals span { font-size: .75rem; color: var(--muted); }
.nb-list { list-style: none; margin: 0; padding: 0; background-image: repeating-linear-gradient(to bottom, transparent 0 51px, var(--line) 51px 52px); }
.nb-list li { height: 52px; display: grid; grid-template-columns: 3.1rem 1fr; gap: .5rem; align-items: center; font-size: .82rem; }
.nb-list time { color: var(--muted); font-variant-numeric: tabular-nums; }
.nb-list .p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-list .t { color: var(--muted); font-size: .74rem; font-variant-numeric: tabular-nums; }
.nb-list li.fresh { animation: ink 1.6s ease-out; }
@keyframes ink { from { background: var(--accent-soft); } to { background: transparent; } }
.nb-empty { color: var(--muted); font-size: .88rem; border: 1px dashed var(--line-2); border-radius: var(--radius-s); padding: .9rem; }

/* sign-in */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); }
.signin .about { padding: clamp(2rem, 6vw, 5.5rem); display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); }
.signin .about h1 { font-size: clamp(2.4rem, 5vw, 4rem); max-width: 14ch; }
.signin .about .lede { font: 400 1.2rem/1.6 var(--serif); color: var(--ink-2); max-width: 44ch; margin-top: 1.25rem; }
.signin .about dl { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1.25rem; margin: 2rem 0 0; font-size: .92rem; max-width: 52ch; }
.signin .about dt { color: var(--muted); }
.signin .about dd { margin: 0; }
.signin .form { padding: clamp(2rem, 5vw, 4.5rem); display: flex; flex-direction: column; justify-content: center; background: var(--surface); }
.signin .form form { max-width: 380px; width: 100%; }
.signin .form h2 { font-size: 1.6rem; margin-bottom: 1.25rem; }
.signin .err { color: var(--bad); font-size: .9rem; min-height: 1.4em; margin: -.25rem 0 .75rem; }
.signin .mark { width: 44px; height: 44px; color: var(--accent); margin-bottom: 1.5rem; }
.foot { color: var(--muted); font-size: .8rem; margin-top: 2rem; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .notebook { grid-column: 1 / -1; position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; padding: .6rem 1rem; gap: .6rem 1rem; }
  .brand .by { display: none; }
  .meter { width: 120px; }
  .layout { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: .6rem; overflow-x: auto; }
  .rail ol { display: flex; gap: .25rem; }
  .rail li a { grid-template-columns: 1.7rem auto; white-space: nowrap; }
  .rail .railfoot { display: none; }
  main.work { padding: 1.5rem 1rem 3rem; }
  .signin { grid-template-columns: 1fr; }
  .signin .about { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---------------------------------------------------------------- print (report) */
@media print {
  .noprint { display: none !important; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .table-wrap { border: 1px solid #bbb; overflow: visible; }
  th { background: #eee !important; }
  a { color: #000; text-decoration: none; }
  section { break-inside: avoid-page; }
}
