/* Study tools (/tools): graph plotter + equation solver (.tg), unit converter + constants
   (.tu), the Tools button and menu on /know and /learn, and the tool overlay. Page-scoped:
   linked by templates/tools/*.html and by tools_overlay() on subject pages. Plain CSS (no
   Tailwind rebuild). Dark first; light rules are generated below the marker by
   scripts/build_light_theme.py, with hand overrides just above it. Chrome is muted
   steel-blue; bright hues are for data (curves) and each tool's own icon colour. */

/* ── Tools button + menu (rose, distinct from amber Simulate and sky Animation) ───────── */
.tools-menu { position: relative; display: inline-flex; }
.tools-launch {
  display: inline-flex; align-items: center; gap: 0.4rem; flex-shrink: 0;
  padding: 0.375rem 0.625rem; border: 1px solid rgba(251, 113, 133, 0.38); border-radius: 0.375rem;
  background: rgba(251, 113, 133, 0.12); color: #fda4af;
  font-size: 0.75rem; font-weight: 500; line-height: 1rem; text-decoration: none; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tools-launch:hover { background: rgba(251, 113, 133, 0.2); color: #fecdd3; }
.tools-launch:focus-visible { outline: none; box-shadow: 0 0 0 2px rgba(251, 113, 133, 0.6); }
.tools-ico { width: 1rem; height: 1rem; flex: none; }
.tools-caret { width: 0.8rem; height: 0.8rem; margin-left: -0.1rem; transition: transform 0.15s; }
.tools-launch[aria-expanded="true"] .tools-caret { transform: rotate(180deg); }
.tools-pop {
  position: absolute; z-index: 60; top: calc(100% + 0.4rem); left: 0;
  display: grid; gap: 0.25rem; width: min(19rem, 86vw); padding: 0.4rem;
  border: 1px solid rgba(148, 163, 184, 0.25); border-radius: 0.8rem;
  background: #0a1222; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.tools-pop[hidden] { display: none; }
.tools-item {
  display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.55rem 0.6rem; border-radius: 0.6rem;
  color: #e2e8f0; text-decoration: none;
}
.tools-item:hover, .tools-item:focus-visible { background: rgba(148, 163, 184, 0.12); outline: none; }
.tools-item-ico {
  display: grid; place-items: center; flex: none; width: 2.1rem; height: 2.1rem; border-radius: 0.6rem;
  color: rgb(var(--ti)); background: rgba(var(--ti), 0.14); border: 1px solid rgba(var(--ti), 0.35);
}
.tools-item-ico svg { width: 1.2rem; height: 1.2rem; }
.tools-item--graph { --ti: 56, 189, 248; }
.tools-item--units { --ti: 251, 146, 60; }
.tools-item-text { display: grid; gap: 0.1rem; min-width: 0; }
.tools-item-name { font-size: 0.9rem; font-weight: 600; color: #f8fafc; }
.tools-item-desc { font-size: 0.8rem; line-height: 1.35; color: #e2e8f0; }

/* ── Overlay ──────────────────────────────────────────────────────────────────────────── */
.tools-dialog {
  width: min(78rem, 96vw); height: min(54rem, 94vh); max-width: none; max-height: none;
  padding: 0; border: 1px solid rgba(148, 163, 184, 0.22); border-radius: 1rem;
  background: var(--reading-surface, #070d1a); color: #e2e8f0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6); overflow: hidden;
}
.tools-dialog::backdrop { background: rgba(2, 6, 23, 0.74); backdrop-filter: blur(2px); }
html.tools-open { overflow: hidden; }
.tools-dialog-panel { display: flex; flex-direction: column; height: 100%; }
.tools-dialog-head {
  display: flex; align-items: center; gap: 0.25rem; padding: 0.5rem 0.5rem 0.5rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.tools-dialog-title { margin: 0 auto 0 0; font-size: 1rem; font-weight: 600; color: #f8fafc; }
.tools-dialog-btn {
  display: inline-grid; place-items: center; width: 2.4rem; height: 2.4rem; border: 0; border-radius: 0.5rem;
  background: transparent; color: #e2e8f0; cursor: pointer;
}
.tools-dialog-btn svg { width: 1.15rem; height: 1.15rem; }
.tools-dialog-btn:hover, .tools-dialog-btn:focus-visible { background: rgba(148, 163, 184, 0.14); color: #fff; outline: none; }
.tools-dialog-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 0.9rem; overscroll-behavior: contain; }
.tools-loading { margin: 2rem auto; text-align: center; color: #e2e8f0; }
@media (max-width: 640px) {
  .tools-dialog { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .tools-dialog-body { padding: 0.6rem; }
}

/* ── Pages ────────────────────────────────────────────────────────────────────────────── */
#site-main.tools-wide { max-width: 84rem; }
.tools-head { margin: 0 0 1.25rem; max-width: 48rem; }
.tools-head--compact { margin-bottom: 1rem; }
.tools-crumbs { font-size: 0.875rem; margin-bottom: 0.25rem; }
.tools-crumbs a { color: #7dd3fc; text-decoration: none; }
.tools-crumbs a:hover { color: #e0f2fe; }
.tools-h1 { margin: 0; font-family: var(--font-display, inherit); font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.25rem); font-weight: 650; letter-spacing: -0.01em; color: #f8fafc; }
.tools-lead { margin: 0.45rem 0 0; font-size: 1rem; line-height: 1.55; color: #e2e8f0; }
.tools-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: 1rem; margin: 0; padding: 0; list-style: none; max-width: 52rem; }
.tools-card {
  --ti: 56, 189, 248;
  display: grid; gap: 0.45rem; height: 100%; padding: 1.2rem 1.25rem; border-radius: 1rem;
  border: 1px solid rgba(var(--ti), 0.3); background: linear-gradient(150deg, rgba(var(--ti), 0.1), rgba(15, 23, 42, 0.6) 60%);
  color: #e2e8f0; text-decoration: none; transition: border-color 0.15s, transform 0.15s;
}
.tools-card--units { --ti: 251, 146, 60; }
.tools-card:hover { border-color: rgba(var(--ti), 0.7); transform: translateY(-1px); }
.tools-card-ico { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 0.8rem; color: rgb(var(--ti)); background: rgba(var(--ti), 0.14); border: 1px solid rgba(var(--ti), 0.35); }
.tools-card-ico svg { width: 1.5rem; height: 1.5rem; }
.tools-card-name { font-size: 1.1rem; font-weight: 650; color: #f8fafc; }
.tools-card-desc { font-size: 0.95rem; line-height: 1.5; }
.tools-card-go { margin-top: 0.3rem; font-weight: 600; color: rgb(var(--ti)); }

/* ── Shared controls ──────────────────────────────────────────────────────────────────── */
.tg, .tu {
  --tg-bg: #050b18; --tg-grid: rgba(143, 168, 207, 0.08); --tg-grid-major: rgba(143, 168, 207, 0.2);
  --tg-axis: rgba(226, 232, 240, 0.72); --tg-label: #dbe4f0;
  --tg-edge: rgba(104, 130, 176, 0.38); --tg-panel: #0a1222; --tg-field: #050b18;
  color: #e2e8f0; font-size: 0.95rem;
}
.tg-tabs { display: flex; gap: 0.25rem; padding: 0.25rem; border-radius: 0.7rem; background: var(--tg-field); border: 1px solid var(--tg-edge); }
.tg-tab {
  flex: 1 1 0; min-height: 2.4rem; padding: 0.35rem 0.6rem; border: 0; border-radius: 0.5rem; background: transparent;
  color: #e2e8f0; font: inherit; font-weight: 600; cursor: pointer;
}
.tg-tab[aria-selected="true"] { background: rgba(143, 168, 207, 0.22); color: #fff; box-shadow: inset 0 0 0 1px rgba(143, 168, 207, 0.4); }
.tg-tab:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 1px; }
.tg-panel { display: grid; gap: 0.85rem; padding-top: 0.85rem; align-content: start; }
.tg-panel[hidden] { display: none; }
.tg-sub, .tg-label { margin: 0; font-size: 0.8rem; font-weight: 650; letter-spacing: 0.02em; color: #f1f5f9; }
.tg-hint { margin: 0; font-size: 0.85rem; line-height: 1.5; color: #e2e8f0; }
.tg-input, .tg-num, .tg-select, .tu-value, .tu-unit {
  min-width: 0; min-height: 2.6rem; padding: 0.45rem 0.65rem; border: 1px solid var(--tg-edge); border-radius: 0.55rem;
  background: var(--tg-field); color: #f8fafc; font: inherit; font-size: 1rem;
}
.tg-input { font-family: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace; font-size: 0.98rem; }
.tg-num { width: 5.2rem; min-height: 2.25rem; padding: 0.3rem 0.5rem; font-size: 0.9rem; text-align: center; }
.tg-select { padding-right: 1.8rem; }
.tg-input:focus, .tg-num:focus, .tg-select:focus, .tu-value:focus, .tu-unit:focus { outline: none; border-color: #7dd3fc; box-shadow: 0 0 0 2px rgba(125, 211, 252, 0.3); }
.tg-input::placeholder { color: #cbd5e1; opacity: 0.75; }
.tg-icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 2.4rem; height: 2.4rem; padding: 0; border: 1px solid var(--tg-edge);
  border-radius: 0.55rem; background: var(--tg-panel); color: #e2e8f0; cursor: pointer;
}
.tg-icon-btn svg { width: 1.1rem; height: 1.1rem; }
.tg-icon-btn:hover, .tg-icon-btn:focus-visible { color: #fff; border-color: #8fa8cf; background: #0f172a; outline: none; }
.tg-seg { display: inline-flex; padding: 0.2rem; gap: 0.15rem; border: 1px solid var(--tg-edge); border-radius: 0.6rem; background: var(--tg-panel); }
.tg-seg button { min-height: 2rem; padding: 0.2rem 0.7rem; border: 0; border-radius: 0.45rem; background: transparent; color: #e2e8f0; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.tg-seg button[aria-pressed="true"] { background: rgba(143, 168, 207, 0.26); color: #fff; }
.tg-seg button:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 1px; }
.tg-seg--wide { display: flex; }
.tg-seg--wide button { flex: 1 1 0; min-height: 2.3rem; }
.tg-btn {
  min-height: 2.6rem; padding: 0.45rem 1.1rem; border: 1px solid var(--tg-edge); border-radius: 0.6rem;
  background: var(--tg-panel); color: #f1f5f9; font: inherit; font-weight: 650; cursor: pointer;
}
.tg-btn:hover, .tg-btn:focus-visible { border-color: #8fa8cf; color: #fff; outline: none; }
.tg-btn--primary { border-color: rgba(56, 189, 248, 0.6); background: rgba(56, 189, 248, 0.18); color: #e0f2fe; }
.tg-btn--primary:hover { background: rgba(56, 189, 248, 0.28); }
.tg-link { padding: 0.2rem 0; border: 0; background: none; color: #7dd3fc; font: inherit; font-size: 0.85rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; justify-self: start; }
.tg-link[hidden] { display: none; }
.tg-err { margin: 0; font-size: 0.85rem; color: #fda4af; }
.tg-err:empty { display: none; }

/* ── Graph tool layout: plot beside the panel when there is room ─────────────────────── */
.tools-host { container-type: inline-size; }
.tg { display: grid; gap: 0.9rem; }
.tg-plot { position: relative; height: min(62vh, 32rem); min-height: 18rem; border: 1px solid var(--tg-edge); border-radius: 0.9rem; overflow: hidden; background: var(--tg-bg); }
.tg-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.tg-canvas.is-panning { cursor: grabbing; }
.tg-canvas:focus-visible { outline: 2px solid #7dd3fc; outline-offset: -2px; }
.tg-toolbar { position: absolute; top: 0.5rem; right: 0.5rem; display: flex; gap: 0.35rem; align-items: center; }
.tg-toolbar .tg-icon-btn { background: rgba(10, 18, 34, 0.92); }
.tg-toolbar .tg-seg { background: rgba(10, 18, 34, 0.92); }
.tg-readout {
  position: absolute; left: 0.5rem; bottom: 0.5rem; max-width: calc(100% - 1rem); padding: 0.3rem 0.6rem 0.3rem 0.5rem;
  border: 1px solid var(--tg-edge); border-left: 4px solid var(--c, transparent); border-radius: 0.5rem;
  background: rgba(10, 18, 34, 0.94); color: #f8fafc; font-size: 0.88rem; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums;
  pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tg-readout[hidden] { display: none; }
.tg-side { display: grid; gap: 0; align-content: start; min-width: 0; }
@container (min-width: 56rem) {
  .tg { grid-template-columns: minmax(19rem, 23rem) 1fr; align-items: start; }
  .tg-side { order: -1; }
  .tg-plot { height: min(74vh, 40rem); position: sticky; top: 0.5rem; }
}
.tools-dialog .tg-plot { height: min(58vh, 30rem); }
@container (min-width: 56rem) { .tools-dialog .tg-plot { height: calc(min(54rem, 94vh) - 6rem); } }

.tg-rows { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.tg-row { display: grid; grid-template-columns: auto 1fr auto; gap: 0.4rem; align-items: center; }
.tg-swatch {
  width: 2.4rem; height: 2.6rem; padding: 0; border: 1px solid var(--tg-edge); border-radius: 0.55rem; background: var(--tg-panel); cursor: pointer;
  display: grid; place-items: center;
}
.tg-swatch::before { content: ""; width: 1rem; height: 1rem; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06); }
.tg-swatch.is-off::before { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }
.tg-swatch:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 1px; }
.tg-row .tg-input { border-left: 3px solid var(--c); }
.tg-row.has-error .tg-input { border-color: rgba(251, 113, 133, 0.7); border-left-color: var(--c); }
.tg-row .tg-err { grid-column: 2 / 4; }
.tg-del { width: 2.2rem; height: 2.2rem; border-color: transparent; background: transparent; }
.tg-add {
  display: inline-flex; align-items: center; gap: 0.4rem; justify-self: start; min-height: 2.4rem; padding: 0.3rem 0.8rem 0.3rem 0.6rem;
  border: 1px dashed rgba(143, 168, 207, 0.55); border-radius: 0.55rem; background: transparent; color: #e2e8f0; font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.tg-add svg { width: 1rem; height: 1rem; }
.tg-add:hover, .tg-add:focus-visible { border-color: #8fa8cf; color: #fff; background: rgba(143, 168, 207, 0.1); outline: none; }

.tg-sliders { display: grid; gap: 0.55rem; }
.tg-sliders:empty, .tg-trange:empty, .tg-points:empty { display: none; }
.tg-slider {
  display: grid; grid-template-columns: 1.6rem 1fr 4.6rem; gap: 0.25rem 0.55rem; align-items: center; padding: 0.5rem 0.6rem;
  border: 1px solid var(--tg-edge); border-radius: 0.6rem; background: var(--tg-panel);
}
.tg-slider-name { font: 700 1.05rem/1 ui-serif, Georgia, serif; font-style: italic; color: #fbbf24; text-align: center; }
.tg-range { width: 100%; accent-color: #fbbf24; min-height: 1.6rem; }
.tg-slider .tg-num { width: 100%; }
.tg-slider-lims { grid-column: 2 / 4; display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: #e2e8f0; }
.tg-slider .tg-num--lim { width: 4.5rem; min-height: 1.9rem; font-size: 0.8rem; }
.tg-slider-lims span { white-space: nowrap; font-style: italic; }
.tg-trange, .tg-range-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; font-size: 0.85rem; }
.tg-range-row .tg-sub { flex: 1 0 100%; }

.tg-point-list { display: grid; gap: 0.25rem; margin: 0.4rem 0 0; padding: 0; list-style: none; max-height: 15rem; overflow: auto; }
.tg-point {
  display: flex; align-items: center; gap: 0.55rem; width: 100%; min-height: 2.2rem; padding: 0.25rem 0.5rem; border: 0; border-radius: 0.45rem;
  background: transparent; color: #e2e8f0; font: inherit; font-size: 0.88rem; text-align: left; cursor: pointer;
}
.tg-point:hover, .tg-point:focus-visible { background: rgba(143, 168, 207, 0.14); outline: none; }
.tg-point-dots { display: inline-flex; gap: 2px; flex: none; }
.tg-point-dots i { width: 0.6rem; height: 0.6rem; border-radius: 50%; }
.tg-point-kind { flex: 1 1 auto; font-weight: 600; color: #f1f5f9; }
.tg-point-xy { font-variant-numeric: tabular-nums; color: #f8fafc; }
.tg-examples { display: grid; gap: 0.45rem; padding-top: 0.25rem; border-top: 1px solid rgba(143, 168, 207, 0.16); }
.tg-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tg-chip {
  min-height: 2rem; padding: 0.2rem 0.6rem; border: 1px solid var(--tg-edge); border-radius: 999px; background: var(--tg-panel);
  color: #e0f2fe; font: 0.82rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer;
}
.tg-chip:hover, .tg-chip:focus-visible { border-color: #7dd3fc; color: #fff; outline: none; }

/* Solve */
.tg-solve-box { display: grid; gap: 0.5rem; }
.tg-solve-box[hidden] { display: none; }
.tg-input--solo { width: 100%; }
.tg-sim-list { display: grid; gap: 0.45rem; }
.tg-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.tg-result { display: grid; gap: 0.6rem; }
.tg-result:empty { display: none; }
.tg-answers { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.tg-answer {
  padding: 0.4rem 0.75rem; border-radius: 0.6rem; border: 1px solid rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.12);
  color: #fef3c7; font-size: 1.1rem; font-weight: 650; line-height: 1.3; font-variant-numeric: tabular-nums;
}
.tg-decimals { margin: 0; font-size: 0.9rem; font-variant-numeric: tabular-nums; color: #e2e8f0; }
.tg-steps { border: 1px solid var(--tg-edge); border-radius: 0.6rem; background: var(--tg-panel); padding: 0.5rem 0.75rem; }
.tg-steps summary { cursor: pointer; font-weight: 650; color: #f1f5f9; }
.tg-steps ol { margin: 0.5rem 0 0.2rem; padding-left: 1.3rem; display: grid; gap: 0.35rem; }
.tg-steps li { font-size: 0.92rem; line-height: 1.5; font-variant-numeric: tabular-nums; color: #e2e8f0; overflow-wrap: anywhere; }

/* Table */
.tg-table-controls { display: grid; grid-template-columns: 1fr auto auto; gap: 0.5rem; align-items: end; }
.tg-field { display: grid; gap: 0.25rem; min-width: 0; }
.tg-table-wrap { overflow-x: auto; }
.tg-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; line-height: 1.4; font-variant-numeric: tabular-nums; }
.tg-table th { padding: 0.4rem 0.6rem; text-align: right; color: #f8fafc; border-bottom: 1px solid rgba(143, 168, 207, 0.4); font-weight: 700; }
.tg-table td { padding: 0.35rem 0.6rem; text-align: right; color: #e2e8f0; border-bottom: 1px solid rgba(143, 168, 207, 0.12); }
.tg-table tbody tr:nth-child(odd) td { background: rgba(143, 168, 207, 0.05); }

/* ── Unit tool ────────────────────────────────────────────────────────────────────────── */
.tu { display: grid; gap: 0; max-width: 56rem; }
.tools-dialog .tu { margin: 0 auto; }
.tu-cats { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tu-cat {
  --tc: 56, 189, 248;
  display: inline-flex; align-items: center; gap: 0.4rem; min-height: 2.4rem; padding: 0.3rem 0.7rem 0.3rem 0.5rem;
  border: 1px solid rgba(var(--tc), 0.3); border-radius: 0.6rem; background: var(--tg-panel); color: #e2e8f0; font: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer;
}
.tu-cat svg { width: 1.15rem; height: 1.15rem; color: rgb(var(--tc)); }
.tu-cat[aria-pressed="true"] { background: rgba(var(--tc), 0.16); border-color: rgba(var(--tc), 0.75); color: #fff; }
.tu-cat:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 1px; }
.tu-cat[data-cat="length"] { --tc: 56, 189, 248; }
.tu-cat[data-cat="mass"] { --tc: 251, 146, 60; }
.tu-cat[data-cat="time"] { --tc: 244, 114, 182; }
.tu-cat[data-cat="energy"] { --tc: 250, 204, 21; }
.tu-cat[data-cat="pressure"] { --tc: 45, 212, 191; }
.tu-cat[data-cat="temperature"] { --tc: 248, 113, 113; }
.tu-cat[data-cat="volume"] { --tc: 129, 140, 248; }
.tu-cat[data-cat="amount"] { --tc: 192, 132, 252; }
.tu-cat[data-cat="speed"] { --tc: 163, 230, 53; }
.tu-conv { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.6rem; align-items: center; padding: 0.9rem; border: 1px solid var(--tg-edge); border-radius: 0.9rem; background: var(--tg-panel); }
.tu-side { display: grid; gap: 0.4rem; min-width: 0; }
.tu-value { width: 100%; font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.tu-swap { align-self: center; margin-top: 1.2rem; }
.tu-out-line { display: flex; align-items: center; gap: 0.4rem; min-height: 2.9rem; padding: 0.25rem 0.25rem 0.25rem 0.65rem; border: 1px solid rgba(251, 191, 36, 0.45); border-radius: 0.55rem; background: rgba(251, 191, 36, 0.08); }
.tu-out { flex: 1 1 auto; min-width: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; color: #fef3c7; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .tu-conv { grid-template-columns: 1fr; }
  .tu-swap { margin: 0 auto; transform: rotate(90deg); }
}
.tu-copy {
  display: inline-grid; place-items: center; flex: none; width: 2.3rem; height: 2.3rem; padding: 0; border: 1px solid transparent; border-radius: 0.5rem;
  background: transparent; color: #e2e8f0; cursor: pointer;
}
.tu-copy svg { width: 1.05rem; height: 1.05rem; }
.tu-copy:hover, .tu-copy:focus-visible { border-color: var(--tg-edge); color: #fff; background: #0f172a; outline: none; }
.tu-copy.is-done { color: #fbbf24; border-color: rgba(251, 191, 36, 0.5); }
.tu-all { display: grid; gap: 0.4rem; }
.tu-all-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.tu-all-list li { display: flex; align-items: center; gap: 0.25rem; border: 1px solid rgba(143, 168, 207, 0.2); border-radius: 0.55rem; background: var(--tg-panel); }
.tu-all-item { flex: 1 1 auto; display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; min-width: 0; min-height: 2.4rem; padding: 0.3rem 0.4rem 0.3rem 0.65rem; border: 0; background: none; color: #f1f5f9; font: inherit; cursor: pointer; text-align: left; }
.tu-all-item:hover .tu-all-val, .tu-all-item:focus-visible .tu-all-val { color: #fff; text-decoration: underline; }
.tu-all-item:focus-visible { outline: 2px solid #7dd3fc; outline-offset: -2px; border-radius: 0.5rem; }
.tu-all-val { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tu-all-sym { flex: none; font-weight: 700; color: #7dd3fc; }
.tu-note { padding: 0.5rem 0.7rem; border-left: 3px solid #fbbf24; background: rgba(251, 191, 36, 0.06); border-radius: 0 0.4rem 0.4rem 0; }
.tu-note[hidden] { display: none; }
.tu-unit-row { display: flex; align-items: center; gap: 0.6rem; }
.tu-unit { width: 6rem; }
.tu-prefix-table { max-width: 30rem; }
.tu-prefix-table td:first-child, .tu-prefix-table th:first-child { text-align: left; font-family: inherit; }
.tu-sym { font-weight: 700; color: #7dd3fc !important; }
.tu-consts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 0.55rem; margin: 0; padding: 0; list-style: none; }
.tu-const {
  display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0.5rem; align-items: center; padding: 0.7rem 0.75rem;
  border: 1px solid rgba(143, 168, 207, 0.24); border-radius: 0.75rem; background: var(--tg-panel);
}
.tu-const-head { grid-column: 1 / 3; display: flex; align-items: baseline; gap: 0.55rem; min-width: 0; }
.tu-const-sym { flex: none; min-width: 2rem; font: italic 700 1.15rem/1 ui-serif, Georgia, serif; color: #fbbf24; }
.tu-const-sym sub { font-size: 0.65em; font-style: normal; }
.tu-const-name { font-size: 0.9rem; color: #f1f5f9; }
.tu-const-val { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.45rem; min-width: 0; }
.tu-const-num { font-size: 1.12rem; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; color: #f8fafc; }
.tu-const-unit { font-size: 0.92rem; color: #e2e8f0; }
.tu-const-meta { grid-column: 1 / 3; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tu-src { padding: 0.12rem 0.45rem; border-radius: 999px; font-size: 0.72rem; font-weight: 650; color: #e0f2fe; background: rgba(56, 189, 248, 0.14); border: 1px solid rgba(56, 189, 248, 0.32); }
.tu-src--edx_ial { color: #fce7f3; background: rgba(244, 114, 182, 0.14); border-color: rgba(244, 114, 182, 0.34); }
.tu-src--cam_chem { color: #ffedd5; background: rgba(251, 146, 60, 0.14); border-color: rgba(251, 146, 60, 0.34); }
.tu-src--cam_igcse { color: #ccfbf1; background: rgba(45, 212, 191, 0.14); border-color: rgba(45, 212, 191, 0.34); }
.tu-src--si { color: #f1f5f9; background: rgba(143, 168, 207, 0.16); border-color: rgba(143, 168, 207, 0.36); }
.tu-const-note { grid-column: 1 / 3; margin: 0; font-size: 0.82rem; line-height: 1.45; color: #e2e8f0; }
.tu-status { min-height: 1.4rem; margin: 0.6rem 0 0; font-size: 0.85rem; color: #fde68a; }
.tu-offscreen { position: fixed; left: -9999px; top: 0; }

/* Hand-tuned light theme (the generated block below maps the rest). */
html[data-theme="light"] .tg, html[data-theme="light"] .tu {
  --tg-bg: #ffffff; --tg-grid: rgba(15, 23, 42, 0.06); --tg-grid-major: rgba(15, 23, 42, 0.14);
  --tg-axis: rgba(15, 23, 42, 0.75); --tg-label: #334155;
  --tg-edge: rgba(15, 23, 42, 0.18); --tg-panel: #f8fafc; --tg-field: #ffffff;
  color: #1e293b;
}
html[data-theme="light"] .tools-dialog { background: #ffffff; color: #1e293b; border-color: rgba(15, 23, 42, 0.14); }
html[data-theme="light"] .tools-dialog::backdrop { background: rgba(15, 23, 42, 0.4); }
html[data-theme="light"] .tools-pop { background: #ffffff; border-color: rgba(15, 23, 42, 0.14); box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16); }
html[data-theme="light"] .tg-toolbar .tg-icon-btn, html[data-theme="light"] .tg-toolbar .tg-seg, html[data-theme="light"] .tg-readout { background: rgba(255, 255, 255, 0.94); }
html[data-theme="light"] .tg-swatch::before { box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06); }

/* ▼▼ LIGHT THEME — GENERATED by scripts/build_light_theme.py from the rules above. Do not edit by hand: run the builder. Hand tuning goes in 36-theme-light.css. ▼▼ */
html[data-theme="light"] .tools-launch{color:rgb(133 0 16)}
html[data-theme="light"] .tools-launch:hover{color:rgb(133 0 16)}
html[data-theme="light"] .tools-launch:focus-visible{box-shadow:0px 0px 0px 2px rgb(184 10 35/0.55)}
html[data-theme="light"] .tools-pop{background-color:rgb(246 248 250);box-shadow:0px 16px 40px rgb(15 23 42/0.176)}
html[data-theme="light"] .tools-item{color:rgb(44 63 88)}
html[data-theme="light"] .tools-item-ico{color:color-mix(in srgb,rgb(var(--ti)) 44%,#0f172a)}
html[data-theme="light"] .tools-item-name{color:rgb(38 66 94)}
html[data-theme="light"] .tools-item-desc{color:rgb(44 63 88)}
html[data-theme="light"] .tools-dialog{background:var(--reading-surface, rgb(248 249 252));color:rgb(44 63 88);box-shadow:0px 24px 70px rgb(15 23 42/0.192)}
html[data-theme="light"] .tools-dialog::backdrop{background-color:rgb(250 251 252/0.74)}
html[data-theme="light"] .tools-dialog-title{color:rgb(38 66 94)}
html[data-theme="light"] .tools-dialog-btn{color:rgb(44 63 88)}
html[data-theme="light"] .tools-dialog-btn:hover,html[data-theme="light"] .tools-dialog-btn:focus-visible{color:rgb(51 63 82)}
html[data-theme="light"] .tools-loading{color:rgb(44 63 88)}
html[data-theme="light"] .tools-crumbs a{color:rgb(0 90 133)}
html[data-theme="light"] .tools-crumbs a:hover{color:rgb(1 79 132)}
html[data-theme="light"] .tools-h1{color:rgb(38 66 94)}
html[data-theme="light"] .tools-lead{color:rgb(44 63 88)}
html[data-theme="light"] .tools-card{background-image:linear-gradient(150deg, rgba(var(--ti), 0.1), rgb(244 245 249/0.6) 60%);color:rgb(44 63 88)}
html[data-theme="light"] .tools-card-ico{color:color-mix(in srgb,rgb(var(--ti)) 44%,#0f172a)}
html[data-theme="light"] .tools-card-name{color:rgb(38 66 94)}
html[data-theme="light"] .tools-card-go{color:color-mix(in srgb,rgb(var(--ti)) 44%,#0f172a)}
html[data-theme="light"] .tg,html[data-theme="light"] .tu{--tg-bg:rgb(249 250 252);--tg-panel:rgb(246 248 250);color:rgb(44 63 88)}
html[data-theme="light"] .tg-tab{color:rgb(44 63 88)}
html[data-theme="light"] .tg-tab[aria-selected="true"]{color:rgb(51 63 82);box-shadow:inset 0px 0px 0px 1px rgb(58 88 136/0.55)}
html[data-theme="light"] .tg-sub,html[data-theme="light"] .tg-label{color:rgb(38 66 94)}
html[data-theme="light"] .tg-hint{color:rgb(44 63 88)}
html[data-theme="light"] .tg-input,html[data-theme="light"] .tg-num,html[data-theme="light"] .tg-select,html[data-theme="light"] .tu-value,html[data-theme="light"] .tu-unit{color:rgb(38 66 94)}
html[data-theme="light"] .tg-input:focus,html[data-theme="light"] .tg-num:focus,html[data-theme="light"] .tg-select:focus,html[data-theme="light"] .tu-value:focus,html[data-theme="light"] .tu-unit:focus{box-shadow:0px 0px 0px 2px rgb(10 128 184/0.51)}
html[data-theme="light"] .tg-input::placeholder{color:rgb(48 65 85)}
html[data-theme="light"] .tg-icon-btn{color:rgb(44 63 88)}
html[data-theme="light"] .tg-icon-btn:hover,html[data-theme="light"] .tg-icon-btn:focus-visible{color:rgb(51 63 82);background-color:rgb(244 245 249)}
html[data-theme="light"] .tg-seg button{color:rgb(44 63 88)}
html[data-theme="light"] .tg-seg button[aria-pressed="true"]{color:rgb(51 63 82)}
html[data-theme="light"] .tg-btn{color:rgb(38 66 94)}
html[data-theme="light"] .tg-btn:hover,html[data-theme="light"] .tg-btn:focus-visible{color:rgb(51 63 82)}
html[data-theme="light"] .tg-btn--primary{color:rgb(1 79 132)}
html[data-theme="light"] .tg-link{color:rgb(0 90 133)}
html[data-theme="light"] .tg-err{color:rgb(133 0 16)}
html[data-theme="light"] .tg-toolbar .tg-icon-btn{background-color:rgb(246 248 250/0.92)}
html[data-theme="light"] .tg-toolbar .tg-seg{background-color:rgb(246 248 250/0.92)}
html[data-theme="light"] .tg-readout{background-color:rgb(246 248 250/0.94);color:rgb(38 66 94)}
html[data-theme="light"] .tg-swatch::before{box-shadow:0px 0px 0px 3px rgb(15 23 42/0.144)}
html[data-theme="light"] .tg-add{color:rgb(44 63 88)}
html[data-theme="light"] .tg-add:hover,html[data-theme="light"] .tg-add:focus-visible{color:rgb(51 63 82)}
html[data-theme="light"] .tg-slider-name{color:rgb(127 92 0)}
html[data-theme="light"] .tg-slider-lims{color:rgb(44 63 88)}
html[data-theme="light"] .tg-point{color:rgb(44 63 88)}
html[data-theme="light"] .tg-point-kind{color:rgb(38 66 94)}
html[data-theme="light"] .tg-point-xy{color:rgb(38 66 94)}
html[data-theme="light"] .tg-chip{color:rgb(1 79 132)}
html[data-theme="light"] .tg-chip:hover,html[data-theme="light"] .tg-chip:focus-visible{color:rgb(51 63 82)}
html[data-theme="light"] .tg-answer{color:rgb(117 94 0)}
html[data-theme="light"] .tg-decimals{color:rgb(44 63 88)}
html[data-theme="light"] .tg-steps summary{color:rgb(38 66 94)}
html[data-theme="light"] .tg-steps li{color:rgb(44 63 88)}
html[data-theme="light"] .tg-table th{color:rgb(38 66 94)}
html[data-theme="light"] .tg-table td{color:rgb(44 63 88)}
html[data-theme="light"] .tu-cat{color:rgb(44 63 88)}
html[data-theme="light"] .tu-cat svg{color:color-mix(in srgb,rgb(var(--tc)) 44%,#0f172a)}
html[data-theme="light"] .tu-cat[aria-pressed="true"]{color:rgb(51 63 82)}
html[data-theme="light"] .tu-out{color:rgb(117 94 0)}
html[data-theme="light"] .tu-copy{color:rgb(44 63 88)}
html[data-theme="light"] .tu-copy:hover,html[data-theme="light"] .tu-copy:focus-visible{color:rgb(51 63 82);background-color:rgb(244 245 249)}
html[data-theme="light"] .tu-copy.is-done{color:rgb(127 92 0)}
html[data-theme="light"] .tu-all-item{color:rgb(38 66 94)}
html[data-theme="light"] .tu-all-item:hover .tu-all-val,html[data-theme="light"] .tu-all-item:focus-visible .tu-all-val{color:rgb(51 63 82)}
html[data-theme="light"] .tu-all-sym{color:rgb(0 90 133)}
html[data-theme="light"] .tu-sym{color:rgb(0 90 133)!important}
html[data-theme="light"] .tu-const-sym{color:rgb(127 92 0)}
html[data-theme="light"] .tu-const-name{color:rgb(38 66 94)}
html[data-theme="light"] .tu-const-num{color:rgb(38 66 94)}
html[data-theme="light"] .tu-const-unit{color:rgb(44 63 88)}
html[data-theme="light"] .tu-src{color:rgb(1 79 132)}
html[data-theme="light"] .tu-src--edx_ial{color:rgb(120 12 74)}
html[data-theme="light"] .tu-src--cam_chem{color:rgb(133 76 0)}
html[data-theme="light"] .tu-src--cam_igcse{color:rgb(6 111 89)}
html[data-theme="light"] .tu-src--si{color:rgb(38 66 94)}
html[data-theme="light"] .tu-const-note{color:rgb(44 63 88)}
html[data-theme="light"] .tu-status{color:rgb(117 94 0)}
/* ▲▲ LIGHT THEME END ▲▲ */
