/* Periodic Table Trainer — single stylesheet, no build step, no external assets. */

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;

  --topbar-h: 56px;
  --cell: 68px;
  --fgap: 14px;
  --radius: 10px;
  --radius-sm: 7px;

  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --surface-3: #e2e5ec;
  --border: #d3d7e0;
  --border-strong: #b6bcc9;
  --text: #191b21;
  --text-dim: #5c6474;
  --text-faint: #8b93a3;
  --accent: #2f6df6;
  --accent-text: #ffffff;
  --accent-soft: #dfe8fe;
  --good: #1f9254;
  --good-soft: #d6f2e1;
  --bad: #d23b3b;
  --bad-soft: #fbdcdc;
  --warn: #b7791f;
  --warn-soft: #fbeed0;
  --cell-fg: #1a1c22;
  --shadow: 0 1px 2px rgba(16, 20, 30, .07), 0 6px 20px rgba(16, 20, 30, .07);
  --shadow-lg: 0 12px 44px rgba(16, 20, 30, .22);

  --c-alkali:     #f4a09a;
  --c-alkaline:   #f7c58c;
  --c-transition: #f2dc8e;
  --c-post:       #b7dfa8;
  --c-metalloid:  #93dcc9;
  --c-nonmetal:   #a6cdf2;
  --c-halogen:    #b9b3ef;
  --c-noble:      #e7abdf;
  --c-lanthanide: #d3dd91;
  --c-actinide:   #e0b795;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141a;
    --surface: #1a1d25;
    --surface-2: #22262f;
    --surface-3: #2b303b;
    --border: #333a47;
    --border-strong: #4a5261;
    --text: #e9ecf2;
    --text-dim: #a4adbe;
    --text-faint: #7b8598;
    --accent: #5b8cff;
    --accent-text: #0d1017;
    --accent-soft: #1d2b4d;
    --good: #3ecf83;
    --good-soft: #16341f;
    --bad: #ff6b6b;
    --bad-soft: #3b1a1c;
    --warn: #e2b04a;
    --warn-soft: #3a2e14;
    --cell-fg: #0e1016;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    --shadow-lg: 0 14px 50px rgba(0, 0, 0, .6);

    --c-alkali:     #c9736c;
    --c-alkaline:   #cc9560;
    --c-transition: #c4ad5f;
    --c-post:       #7fae74;
    --c-metalloid:  #5fab99;
    --c-nonmetal:   #6b98c4;
    --c-halogen:    #8b85c2;
    --c-noble:      #b578ac;
    --c-lanthanide: #a3ac64;
    --c-actinide:   #b08765;
  }
}

:root[data-theme="dark"] {
  --bg: #12141a;
  --surface: #1a1d25;
  --surface-2: #22262f;
  --surface-3: #2b303b;
  --border: #333a47;
  --border-strong: #4a5261;
  --text: #e9ecf2;
  --text-dim: #a4adbe;
  --text-faint: #7b8598;
  --accent: #5b8cff;
  --accent-text: #0d1017;
  --accent-soft: #1d2b4d;
  --good: #3ecf83;
  --good-soft: #16341f;
  --bad: #ff6b6b;
  --bad-soft: #3b1a1c;
  --warn: #e2b04a;
  --warn-soft: #3a2e14;
  --cell-fg: #0e1016;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 14px 50px rgba(0, 0, 0, .6);

  --c-alkali:     #c9736c;
  --c-alkaline:   #cc9560;
  --c-transition: #c4ad5f;
  --c-post:       #7fae74;
  --c-metalloid:  #5fab99;
  --c-nonmetal:   #6b98c4;
  --c-halogen:    #8b85c2;
  --c-noble:      #b578ac;
  --c-lanthanide: #a3ac64;
  --c-actinide:   #b08765;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 700;
}

.brand-text { font-size: 15px; letter-spacing: -.01em; }

.tabs { display: flex; gap: 3px; flex: 1; flex-wrap: wrap; }

.tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-weight: 550;
  font-size: 14px;
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  /* Hold width: without this the labels wrap instead of the strip scrolling. */
  flex: none;
  white-space: nowrap;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  font: inherit;
  font-weight: 560;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 85%, black);
}

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 26px; font-size: 16px; }

.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

/* ---------- layout ---------- */
main { padding: 20px 18px 40px; max-width: 1500px; margin: 0 auto; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel-title { font-size: 22px; margin-bottom: 8px; }
.panel-lead { color: var(--text-dim); max-width: 76ch; margin-bottom: 22px; }
.section-h { font-size: 16px; margin: 28px 0 8px; }
.muted-text { color: var(--text-dim); font-size: 13.5px; max-width: 80ch; }

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 18px;
  align-items: start;
}
.setup-grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.fs {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px 16px;
  margin: 0;
  background: var(--surface);
}
.fs legend {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
  padding: 0 6px;
}
.fs-actions { display: flex; gap: 6px; margin-bottom: 10px; }
.fs-note { color: var(--text-dim); font-size: 13.5px; }

.chk-grid { display: grid; gap: 4px; }
.chk-grid-tight { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }

.chk {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.chk:hover { background: var(--surface-2); }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; cursor: pointer; }
.chk-sm { font-size: 13.5px; }
.chk-text { flex: 1; }
.chk-count { color: var(--text-faint); font-size: 12px; font-variant-numeric: tabular-nums; }

.chk-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--cat, var(--surface-3));
  border: 1px solid rgba(0, 0, 0, .18);
  flex: none;
}

.opt-list { display: grid; gap: 2px; margin-top: 6px; }

.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field-label { font-size: 12.5px; color: var(--text-dim); font-weight: 550; }

select, .search, .card-input {
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  width: 100%;
}

.preset-row { display: flex; flex-wrap: wrap; gap: 6px; }

.start-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.count-text { color: var(--text-dim); font-size: 14px; }

/* ---------- HUD ---------- */
.run { display: grid; gap: 12px; }

/* HUD + prompt/focus strip travel together so the timer, controls and the
   current-cell readout stay on screen while you work down the table. */
.run-sticky {
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  display: grid;
  gap: 10px;
  padding-bottom: 8px;
  background: var(--bg);
}

.hud {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.hud-left { display: flex; align-items: baseline; gap: 12px; }

.hud-timer {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 62px;
}
.hud-timer.warn { color: var(--bad); }

.hud-stat { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.hud-bar-wrap {
  flex: 1;
  min-width: 120px;
  height: 7px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.hud-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 99px;
  transition: width .2s ease;
}

.hud-right { display: flex; gap: 6px; flex-wrap: wrap; }

.focus-strip, .prompt-strip {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.focus-title { font-weight: 650; }
.focus-sub, .prompt-sub { color: var(--text-dim); font-size: 13.5px; }
.focus-hint { color: var(--warn); font-size: 13.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.prompt-strip { align-items: center; }
.prompt-q { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }

.q-feedback { font-size: 14px; font-weight: 560; min-height: 1.4em; }
.q-feedback.good { color: var(--good); }
.q-feedback.bad { color: var(--bad); }

/* ---------- the table ---------- */
.table-scroll {
  overflow: auto;
  padding: 10px 14px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.ptable {
  display: grid;
  grid-template-columns: 20px repeat(18, var(--cell));
  grid-template-rows: 16px repeat(7, var(--cell)) var(--fgap) repeat(2, var(--cell));
  gap: 3px;
  width: max-content;
  margin: 0 auto;
}

.axis {
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 650;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.axis-f { opacity: .55; }

.cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border-radius: var(--radius-sm);
  background: var(--cat, var(--surface-2));
  color: var(--cell-fg);
  border: 1px solid rgba(0, 0, 0, .14);
  overflow: hidden;
  transition: transform .12s ease, box-shadow .12s ease, opacity .15s ease;
}

.cell.clickable { cursor: pointer; }
.cell.clickable:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

.cell.ghost {
  background: transparent;
  border-style: dashed;
  border-color: var(--border-strong);
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 650;
}

.c-z {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9px;
  font-weight: 650;
  opacity: .72;
  font-variant-numeric: tabular-nums;
}
.hide-z .c-z { display: none; }

.c-sym { font-size: 19px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.c-name {
  font-size: 8.5px;
  line-height: 1.15;
  text-align: center;
  padding: 0 2px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.c-mass { font-size: 7.5px; opacity: .7; font-variant-numeric: tabular-nums; }
.c-sym.muted, .c-name.muted { opacity: .55; }

.mask-symbols .c-sym,
.mask-symbols .c-name,
.mask-symbols .c-mass { visibility: hidden; }

.cell.dimmed { opacity: .18; }

/* category fills */
.cat-alkali     { --cat: var(--c-alkali); }
.cat-alkaline   { --cat: var(--c-alkaline); }
.cat-transition { --cat: var(--c-transition); }
.cat-post       { --cat: var(--c-post); }
.cat-metalloid  { --cat: var(--c-metalloid); }
.cat-nonmetal   { --cat: var(--c-nonmetal); }
.cat-halogen    { --cat: var(--c-halogen); }
.cat-noble      { --cat: var(--c-noble); }
.cat-lanthanide { --cat: var(--c-lanthanide); }
.cat-actinide   { --cat: var(--c-actinide); }

/* ---------- fill-in cells ---------- */

/* Inputs occupy the whole cell, so the atomic number joins the flow above them
   instead of floating over the top-left corner. */
.ptable-input .cell {
  justify-content: flex-start;
  padding: 2px 2px 0;
  gap: 0;
}
.ptable-input .c-z {
  position: static;
  width: 100%;
  padding-left: 2px;
  line-height: 1.15;
  text-align: left;
}

.c-in {
  font: inherit;
  width: 100%;
  border: 0;
  background: rgba(255, 255, 255, .55);
  color: #12141a;
  text-align: center;
  padding: 1px 2px;
  border-radius: 4px;
  min-width: 0;
}
.c-in:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.c-in-sym {
  font-size: 18px;
  font-weight: 700;
  height: 26px;
  text-transform: none;
}
.c-in-name { font-size: 8.5px; height: 15px; }

.cell.locked { opacity: .62; filter: saturate(.75); }
.cell.locked .c-in {
  background: transparent;
  color: var(--cell-fg);
  cursor: default;
  user-select: none;
}

.cell.active-scope { box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .35); }

.cell.cell-active {
  z-index: 30;
  box-shadow: 0 0 0 2.5px var(--accent), var(--shadow);
}

/* zoom the focused cell so a full element name is legible */
.cell:focus-within {
  transform: scale(1.65);
  z-index: 35;
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-lg);
}
.cell:focus-within .c-in-name { height: 17px; font-size: 9px; }

.in-right { background: color-mix(in srgb, var(--good) 26%, white) !important; }
.in-close { background: color-mix(in srgb, var(--warn) 30%, white) !important; }
.in-wrong { background: color-mix(in srgb, var(--bad) 26%, white) !important; }
.in-filled { background: rgba(255, 255, 255, .85) !important; }
.in-revealed {
  background: rgba(255, 255, 255, .7) !important;
  font-style: italic;
  text-decoration: underline dotted;
}

.cell-right { box-shadow: inset 0 0 0 2px var(--good); }
.cell-close { box-shadow: inset 0 0 0 2px var(--warn); }
.cell-wrong { box-shadow: inset 0 0 0 2px var(--bad); }
.cell-revealed { border-style: dashed; }

/* locate-mode flashes */
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.flash-right { animation: pop .5s ease; box-shadow: 0 0 0 3px var(--good), var(--shadow-lg); z-index: 30; }
.flash-wrong { animation: shake .4s ease; box-shadow: 0 0 0 3px var(--bad); z-index: 30; }
.flash-show { box-shadow: 0 0 0 3px var(--accent), var(--shadow-lg); z-index: 30; }

/* ---------- mastery heatmap ---------- */
.heatmap .cell { background: var(--surface-3); border-color: var(--border); color: var(--text); }
.heatmap .cell.heat-none { background: var(--surface-2); color: var(--text-faint); }
.heatmap .cell.heat-0 { background: color-mix(in srgb, var(--bad) 55%, var(--surface)); color: var(--text); }
.heatmap .cell.heat-1 { background: color-mix(in srgb, var(--warn) 55%, var(--surface)); color: var(--text); }
.heatmap .cell.heat-2 { background: color-mix(in srgb, var(--good) 30%, var(--surface)); color: var(--text); }
.heatmap .cell.heat-3 { background: color-mix(in srgb, var(--good) 58%, var(--surface)); color: var(--text); }
.heatmap .cell.heat-4 { background: color-mix(in srgb, var(--good) 88%, var(--surface)); color: var(--text); }
.heatmap .cell.ghost { background: transparent; }

/* ---------- legend ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 5px; }

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
}
.legend-item:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.legend-item:disabled { cursor: default; }
.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--cat);
  border: 1px solid rgba(0, 0, 0, .2);
}

/* ---------- cards ---------- */
.card-stage {
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 32px 18px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.card {
  display: grid;
  place-items: center;
  gap: 8px;
  min-width: min(420px, 100%);
  min-height: 170px;
  padding: 26px;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.card-front { font-size: clamp(34px, 8vw, 60px); font-weight: 700; letter-spacing: -.02em; text-align: center; }
.card-hint { font-size: 13px; color: var(--text-dim); min-height: 1.2em; }

.card-answer-wrap { display: flex; gap: 8px; width: min(420px, 100%); }
.card-input { font-size: 17px; text-align: center; }

.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; width: min(560px, 100%); }

.choice {
  font: inherit;
  font-weight: 550;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: center;
}
.choice:hover { background: var(--surface-2); }
.choice-right { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.choice-wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

/* ---------- reference ---------- */
.ref-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.ref-main { display: grid; gap: 12px; min-width: 0; }

.ref-toolbar {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.search { max-width: 420px; }

.detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--cat, var(--accent));
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 70px;
}
.detail-top { display: flex; align-items: baseline; justify-content: space-between; }
.detail-z { font-size: 13px; color: var(--text-faint); font-weight: 650; }
.detail-sym { font-size: 40px; font-weight: 700; letter-spacing: -.02em; }
.detail-name { font-size: 20px; margin-top: 2px; }
.detail-cat { color: var(--text-dim); font-size: 13px; margin-bottom: 14px; }

.detail-rows { display: grid; gap: 6px; }
.detail-row, .detail-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.detail-k { color: var(--text-dim); flex: none; }
.detail-v { text-align: right; font-weight: 550; overflow-wrap: anywhere; }
.detail-stats { margin-top: 12px; border-bottom: 0; }
.detail-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }

/* ---------- stats ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 8px; }

.tile {
  display: grid;
  gap: 2px;
  padding: 16px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tile-v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile-k { font-size: 13px; color: var(--text-dim); }
.tile-sub { font-size: 11.5px; color: var(--text-faint); }

.stats-detail { min-height: 1.5em; font-size: 13.5px; color: var(--text-dim); margin-top: 8px; }

.htable { width: 100%; border-collapse: collapse; font-size: 13px; }
.htable th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.htable td { padding: 7px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }

.data-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- results ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 12, 18, .55);
  backdrop-filter: blur(3px);
}

.modal {
  width: min(680px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-body { padding: 24px; overflow: auto; }
.modal-actions {
  display: flex;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}

.res-head { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }

.res-score {
  --pct: 0;
  display: grid;
  place-items: center;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  flex: none;
  background:
    conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--surface-3) 0);
  position: relative;
}
.res-score::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: var(--surface);
}
.res-pct { position: relative; font-size: 30px; font-weight: 700; z-index: 1; }
.res-sub { position: relative; font-size: 11px; color: var(--text-dim); z-index: 1; text-align: center; }

.res-meta { display: grid; gap: 5px; flex: 1; min-width: 190px; }
.res-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; border-bottom: 1px solid var(--border); padding-bottom: 5px; }
.res-k { color: var(--text-dim); }
.res-v { font-weight: 550; font-variant-numeric: tabular-nums; }

.res-h { font-size: 14px; margin: 18px 0 8px; }
.res-perfect {
  padding: 14px;
  border-radius: 10px;
  background: var(--good-soft);
  color: var(--good);
  font-weight: 560;
}

.res-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }

.res-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  border-left: 4px solid var(--cat, var(--border-strong));
  font-size: 13.5px;
}
.res-el {
  display: grid;
  place-items: center;
  width: 42px;
  flex: none;
  padding: 3px 0;
  border-radius: 6px;
  background: var(--cat, var(--surface-3));
  color: var(--cell-fg);
}
.res-el b { font-size: 15px; line-height: 1.1; }
.res-elz { font-size: 9px; opacity: .8; }
.res-txt { display: block; }
.res-detail { color: var(--text-dim); }

/* ---------- help ---------- */
.help-dialog {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 12, 18, .55);
  backdrop-filter: blur(3px);
}
.help-inner {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  max-height: 86vh;
  overflow: auto;
}
.help-inner h2 { font-size: 18px; margin-bottom: 12px; }
.help-inner h3 { font-size: 14px; margin: 18px 0 6px; }
.help-inner ul { margin: 0; padding-left: 20px; color: var(--text-dim); display: grid; gap: 5px; font-size: 14px; }
.help-inner p { color: var(--text-dim); font-size: 14px; }
.help-inner .btn { margin-top: 18px; }

/* ---------- footer ---------- */
.footer {
  padding: 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .ref-layout { grid-template-columns: 1fr; }
  .detail { position: static; }
}

@media (max-width: 900px) {
  :root { --cell: 56px; }
  .c-sym, .c-in-sym { font-size: 16px; }
  .run-sticky { position: static; background: transparent; padding-bottom: 0; }
}

@media (max-width: 620px) {
  :root { --cell: 48px; }
  main { padding: 14px 10px 32px; }
  .panel { padding: 18px 14px; }
  .brand-text { display: none; }
  /* Keep the header one line tall; the tab strip scrolls if it must. */
  .topbar { flex-wrap: nowrap; gap: 8px; padding: 8px 10px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 7px 9px; font-size: 13px; }
  .table-scroll { padding: 8px 8px 18px; }
  /* At this size the mass line crowds the atomic number into the symbol. */
  .c-mass { display: none; }
  .c-sym { font-size: 15px; }
  .c-in-sym { height: 21px; font-size: 15px; }
  .c-in-name { height: 13px; }
  .c-name { font-size: 7px; }
  .cell:focus-within { transform: scale(1.9); }
  .res-head { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ======================= VSEPR ======================= */

.subtabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: var(--shadow);
}

.btn-on {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

/* ---------- chart drill grid ---------- */
.vgrid {
  display: grid;
  grid-template-columns: 92px repeat(5, minmax(150px, 1fr));
  gap: 8px;
  min-width: 900px;
}

.vgrid-corner,
.vgrid-head {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-faint);
  text-align: center;
}
.vgrid-corner { justify-content: flex-start; }

.vgrid-row-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding-right: 8px;
  font-size: 15px;
}
.vgrid-sub { font-size: 11.5px; color: var(--text-faint); font-weight: 550; }

.vcell {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  min-height: 84px;
}
.vcell-empty { background: transparent; border: 1px dashed transparent; min-height: 0; }

.vcell-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.vcell-cn { font-size: 12px; font-weight: 650; color: var(--text-dim); }
.vcell-formula { font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.vcell-active { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--border-strong); }
.vcell-locked { opacity: .62; }

.vfield { display: grid; gap: 2px; }
.vfield-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
  font-weight: 650;
}

.vinput {
  font: inherit;
  font-size: 14px;
  width: 100%;
  padding: 5px 7px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}
.vinput:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.vinput.in-right { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.vinput.in-wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.vinput.in-filled { background: var(--surface-3); }
.vinput.in-revealed {
  background: var(--surface-3);
  font-style: italic;
  text-decoration: underline dotted;
}

.vlocked { font-size: 14px; font-weight: 550; }

.vcell.cell-right { box-shadow: inset 0 0 0 2px var(--good); }
.vcell.cell-wrong { box-shadow: inset 0 0 0 2px var(--bad); }
.vcell.cell-active { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.vcell.cell-revealed { border-style: dashed; }

/* ---------- shape diagrams ---------- */
.vs-svg { width: 100%; height: auto; display: block; overflow: visible; }

.vs-bond { stroke: var(--text); stroke-width: 3; stroke-linecap: round; }
.vs-wedge { fill: var(--text); }
.vs-hash { stroke: var(--text); stroke-width: 2.6; stroke-linecap: round; }

.vs-atom {
  fill: var(--surface);
  stroke: var(--text);
  stroke-width: 2.5;
}
.vs-central { fill: var(--accent); stroke: none; }

.vs-atom-label,
.vs-central-label {
  font: 600 15px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  text-anchor: middle;
  dominant-baseline: central;
  fill: var(--text);
}
.vs-central-label { fill: var(--accent-text); font-size: 16px; }

.vs-lobe {
  fill: color-mix(in srgb, var(--accent) 26%, transparent);
  stroke: color-mix(in srgb, var(--accent) 55%, transparent);
  stroke-width: 1.5;
}
.vs-dot { fill: var(--accent); }

/* ---------- shape reference ---------- */
.vref { display: grid; gap: 26px; }

.vref-group { display: grid; gap: 10px; }

.vref-h {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 15px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.vref-sn {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 13px;
}
.vref-parent { color: var(--text-dim); font-size: 13px; font-weight: 500; }

.vref-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }

.vref-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.vref-pic {
  background: var(--surface);
  border-radius: 10px;
  padding: 8px;
  border: 1px solid var(--border);
}
.vref-name { font-size: 16px; }
.vref-formula { font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; }
.vref-note {
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-soft);
  padding: 6px 8px;
  border-radius: 7px;
}
.vref-stat { font-size: 12px; color: var(--text-faint); }
.vref-card .detail-row { font-size: 12.5px; }

/* ---------- cards / results extras ---------- */
.card-sub { font-size: 13.5px; color: var(--text-dim); text-align: center; }
.card-front-diagram { width: min(240px, 70vw); }
.card-front-diagram .vs-svg { max-height: 240px; }

.res-item-v { align-items: flex-start; }
.res-shape {
  width: 74px;
  flex: none;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.res-item-v .res-txt { display: grid; gap: 1px; }

@media (max-width: 900px) {
  .vgrid { grid-template-columns: 78px repeat(5, minmax(140px, 1fr)); min-width: 820px; }
}

.vgrid-single .vfield-label { display: none; }
.vgrid-single .vcell { min-height: 74px; }

/* A square viewBox in a wide card wastes a lot of height on one-column layouts. */
.vref-pic .vs-svg { max-height: 200px; }

/* ======================= SYMMETRY ======================= */

.sym-stage {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.sym-molecule {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  text-align: center;
}
.sym-pic-big {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 12px;
}
.sym-mol-name { font-size: 20px; }
.sym-mol-formula { font-size: 15px; color: var(--accent); font-weight: 650; margin-top: 2px; }
.sym-mol-shape { font-size: 13.5px; color: var(--text-dim); margin-top: 6px; }

.sym-answer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.sym-svg { width: 100%; height: auto; max-height: 240px; display: block; overflow: visible; }
.sym-bond { stroke: var(--text); stroke-width: 2.6; stroke-linecap: round; }
.sym-hash { stroke-dasharray: 3 5; }
.sym-bridge { stroke-dasharray: 5 5; opacity: .7; }
.sym-wedge { fill: var(--text); }
.sym-atom { fill: var(--surface); stroke: var(--text); stroke-width: 2.2; }
.sym-metal { fill: var(--accent); stroke: none; }
.sym-node { fill: var(--text); }
.sym-newman { fill: none; stroke: var(--text-faint); stroke-width: 2.4; }
.sym-aromatic { fill: none; stroke: var(--text-faint); stroke-width: 2; }
.sym-label {
  font: 600 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  text-anchor: middle;
  dominant-baseline: central;
  fill: var(--text);
}
.sym-metal + .sym-label { fill: var(--accent-text); }
.sym-note-text {
  font: 500 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  text-anchor: middle;
  fill: var(--text-faint);
}

/* element palette */
.palette { display: grid; gap: 8px; }
.pal-row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.pal-head {
  width: 100%;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
}

.pal-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-width: 46px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
}
.pal-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.pal-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pal-locked { opacity: .8; cursor: default; }
.pal-right { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.pal-missed {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: var(--bad);
  border-style: dashed;
}
.pal-extra {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
  text-decoration: line-through;
}

.sym-group-field { max-width: 260px; margin: 0; }
.sym-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.explain {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: grid;
  gap: 7px;
  font-size: 13.5px;
}
.exp-head { display: flex; align-items: baseline; gap: 10px; }
.exp-pg { font-size: 20px; font-weight: 700; color: var(--accent); }
.exp-order { font-size: 12px; color: var(--text-faint); }
.exp-ops, .exp-line { color: var(--text); }
.exp-why { color: var(--text-dim); }
.exp-note {
  color: var(--text-dim);
  border-left: 3px solid var(--border-strong);
  padding-left: 9px;
}
.exp-miss { color: var(--bad); }

/* flowchart + group table */
.flow { display: grid; gap: 8px; margin-bottom: 10px; }
.flow-step {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.flow-n {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 700;
}
.flow-body { display: grid; gap: 3px; }
.flow-q { font-weight: 600; }
.flow-a { font-size: 13.5px; color: var(--text-dim); }

.sym-table td { vertical-align: top; }
.sym-key { font-size: 15px; color: var(--accent); }
.sym-ops, .sym-els { font-size: 12.5px; }
.sym-note-row td {
  font-size: 12px;
  color: var(--text-dim);
  padding-top: 0;
  border-bottom: 1px solid var(--border);
}

.sym-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.sym-card {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  align-content: start;
}
.sym-pic {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  margin-bottom: 4px;
}
.sym-pic .sym-svg, .sym-pic .vs-svg { max-height: 150px; }
.sym-card-name { font-size: 15px; }
.sym-card-formula { font-size: 13px; color: var(--accent); font-weight: 600; }
.sym-card-shape { font-size: 12.5px; color: var(--text-dim); }
.sym-card-pg { font-size: 13px; margin-top: 4px; }
.sym-card-why { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.chk-hint { color: var(--text-faint); font-weight: 400; }

/* ======================= ZEFF ======================= */

.cfg-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95em;
}

.cfg-element { display: grid; justify-items: center; gap: 2px; }
.cfg-symbol { font-size: clamp(44px, 9vw, 68px); font-weight: 700; letter-spacing: -.02em; }
.cfg-name { font-size: 18px; font-weight: 600; }
.cfg-z { font-size: 13px; color: var(--text-dim); }

.cfg-wide { width: min(560px, 100%); }
.cfg-narrow { width: min(220px, 100%); margin: 0; }

.sl-question { font-size: clamp(19px, 4vw, 26px); text-align: center; }
.sl-orbital { font-weight: 700; color: var(--accent); }
.sl-in { color: var(--text-dim); }
.sl-el { font-weight: 650; }
.sl-config { color: var(--text-dim); font-size: 13.5px; text-align: center; min-height: 1.2em; }

.sl-inputs { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.sl-inputs .field { width: 160px; margin: 0; }
.sl-inputs .card-input { text-align: center; }

.slater-work { display: grid; gap: 10px; width: 100%; }
.slater-groups { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.slater-table { font-size: 13px; }
.slater-table td:not(:first-child), .slater-table th:not(:first-child) { text-align: right; }
.slater-why { display: block; font-size: 11.5px; color: var(--text-faint); }
.slater-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.slater-sum td { font-weight: 700; border-top: 2px solid var(--border-strong); }
.slater-final { font-size: 15px; text-align: right; }
.slater-final b { color: var(--accent); font-size: 18px; }

.calc-controls { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.calc-controls .field { width: 260px; margin: 0; }

.calc-out {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.calc-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.calc-sym {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  flex: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 26px;
  font-weight: 700;
}
.calc-info { display: grid; gap: 2px; flex: 1; min-width: 180px; }
.calc-name { font-weight: 650; }
.calc-big { display: grid; justify-items: end; }
.calc-big-v { font-size: 34px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.calc-big-k { font-size: 12px; color: var(--text-dim); }

@media (max-width: 900px) {
  .sym-stage { grid-template-columns: 1fr; }
}

.exp-pg sub, .sym-key sub { font-size: .62em; }

.slater-final sub, .calc-big-k sub, .q-feedback sub { font-size: .7em; }

/* ======================= QUANTUM / ORBITALS / TRENDS ======================= */

.qn-fields {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: min(620px, 100%);
}
.qn-fields .field { width: 100px; margin: 0; }
.qn-fields .qn-wide { width: 210px; }
.qn-fields .card-input { text-align: center; }
.qn-yesno { width: min(360px, 100%); grid-template-columns: 1fr 1fr; }

.qn-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.qn-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.orb-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.orb-card {
  display: grid;
  gap: 3px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  align-content: start;
}
.orb-pic {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  margin-bottom: 5px;
}
.orb-svg { width: 100%; height: auto; max-height: 170px; display: block; }
.orb-name { font-size: 15px; }
.orb-desc { font-size: 12px; color: var(--text-dim); }
.orb-radial-note { color: var(--warn); }

.orb-axis { stroke: var(--border-strong); stroke-width: 1.5; stroke-dasharray: 2 4; }
.orb-axis-label {
  font: 600 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  fill: var(--text-faint);
  text-anchor: middle;
}
.orb-lobe { stroke: var(--accent); stroke-width: 2; }
.orb-pos { fill: color-mix(in srgb, var(--accent) 45%, transparent); }
.orb-neg { fill: color-mix(in srgb, var(--accent) 6%, transparent); }
.orb-nodal { stroke: var(--bad); stroke-width: 1.8; stroke-dasharray: 6 4; opacity: .85; }
.orb-radial { fill: none; stroke: var(--warn); stroke-width: 1.4; stroke-dasharray: 3 3; }
.orb-center { fill: var(--text); }

.trend-pair { grid-template-columns: 1fr 1fr; width: min(520px, 100%); }
.trend-choice { font-size: 15px; padding: 16px 12px; }

/* ======================= FORMULA / ISOMERS ======================= */

.panel-gap { margin-top: 16px; }

.formula-result {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.formula-result .sym-pic { margin: 0; }

.iso-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.iso-card {
  display: grid;
  gap: 7px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  align-content: start;
}
.iso-title { font-size: 13px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; }
.iso-sites { display: flex; flex-wrap: wrap; gap: 5px; }
.iso-chip {
  display: grid;
  justify-items: center;
  padding: 4px 8px;
  border-radius: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
}
.iso-ax { border-color: var(--accent); }
.iso-role { font-size: 9.5px; color: var(--text-faint); text-transform: uppercase; }
.iso-pg { font-size: 15px; }
.iso-pg sub { font-size: .62em; }

.sym-final { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.sym-final .field { margin: 0; }

@media (max-width: 700px) {
  .formula-result { grid-template-columns: 1fr; }
}

/* ======================= MO DIAGRAMS ======================= */

.mo-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.mo-formula { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.mo-sub { color: var(--text-dim); font-size: 13.5px; }

.mo-diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin: 12px 0;
  overflow-x: auto;
}
.mo-svg { width: 100%; min-width: 560px; height: auto; display: block; }

.mo-level { stroke-width: 3.4; stroke-linecap: round; }
.mo-bonding { stroke: var(--good); }
.mo-antibonding { stroke: var(--bad); }
.mo-nonbonding { stroke: var(--text-dim); }
.mo-ao { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.mo-link { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 3 3; opacity: .65; }
.mo-arrow { stroke: var(--text); stroke-width: 1.6; }
.mo-arrowhead { fill: var(--text); }

.mo-label, .mo-mo-label, .mo-ao-label, .mo-sym-label, .mo-atom-label {
  font: 500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  fill: var(--text);
}
.mo-atom-label { font-weight: 700; font-size: 14px; text-anchor: middle; fill: var(--accent); }
.mo-ao-label { fill: var(--accent); font-size: 11px; }
.mo-sym-label { fill: var(--text-faint); font-size: 11px; font-style: italic; }
.mo-right { text-anchor: end; }

.mo-notes { display: grid; gap: 6px; }

.mo-table, .mo-match { font-size: 12.5px; }
/* Operation labels are the header text here, and case carries meaning: the
 * table's uppercasing turned σv into Σv and S₄ into an unreadable blur. */
.mo-table th { text-transform: none; font-size: 12px; }
.mo-table th:not(:first-child):not(:last-child) { text-align: center; }
.mo-table td, .mo-match td { text-align: center; }
.mo-table td:first-child, .mo-match td:first-child { text-align: left; }
.mo-table td:last-child, .mo-match td:last-child { text-align: left; }
.mo-funcs { color: var(--text-dim); font-size: 11.5px; }
.mo-gamma td { border-top: 2px solid var(--border-strong); font-weight: 700; }
.mo-gamma { background: var(--accent-soft); }
.mo-row-hit { background: var(--good-soft); }
.mo-row-nb { background: var(--warn-soft); }

.mo-reduce { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.mo-reduce-hit { color: var(--text); font-weight: 550; }
.mo-result { font-size: 16px; margin-top: 6px; }
.mo-quiz-table { width: 100%; }
.mo-quiz-table .mo-head { display: none; }

/* ---------- orbital and SALC drawings ---------- */

.art-svg { display: block; width: 100%; height: auto; overflow: visible; }
.art-pos { fill: var(--accent); fill-opacity: .72; stroke: var(--accent); stroke-width: 1.2; }
.art-neg { fill: var(--surface); stroke: var(--accent); stroke-width: 1.6; }
.art-zero { fill: none; stroke: var(--border-strong); stroke-width: 1.2; stroke-dasharray: 2 2; }
.art-node { stroke: var(--bad); stroke-width: 1.4; stroke-dasharray: 5 4; opacity: .85; }
.art-bond { stroke: var(--border-strong); stroke-width: 1.4; }
.art-bond-solid { stroke-width: 2; }
.art-atom { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.5; }
.art-centre { fill: var(--surface); stroke: var(--text-dim); stroke-width: 2; }
.art-nucleus { fill: var(--text); }
.art-axis { stroke: var(--text-faint); stroke-width: 1; opacity: .7; }
.art-axis-label,
.art-atom-label,
.art-centre-label,
.art-caption,
.art-label {
  font: 500 10.5px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  fill: var(--text-dim); text-anchor: middle;
}
.art-atom-label, .art-centre-label { fill: var(--text); font-size: 11px; font-weight: 600; }
.art-caption { fill: var(--text-faint); font-size: 10.5px; }

.art-grid {
  display: grid; gap: 12px; margin-top: 10px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.art-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 8px;
  background: var(--surface);
}
.art-card-head { font-size: 12.5px; font-weight: 650; margin: 2px 0 4px; }
.art-card-sub { font-size: 11.5px; color: var(--text-dim); }
.art-card-pick { cursor: pointer; text-align: left; width: 100%; font: inherit; }
.art-card-pick:hover { border-color: var(--border-strong); }
.art-card-right { border-color: var(--good); box-shadow: inset 0 0 0 1.5px var(--good); }
.art-card-wrong { border-color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }

/* ---------- vibrations ---------- */

.vib-top { display: grid; grid-template-columns: 200px 1fr; gap: 14px; align-items: start; margin: 10px 0; }
.vib-pic { border: 1px solid var(--border); border-radius: 12px; padding: 6px; background: var(--surface); }
.vib-lead { display: grid; gap: 6px; }
.vib-quiz-pic { max-width: 180px; margin: 0 auto; }
.vib-hint { color: var(--text-faint); font-size: 11px; font-weight: 400; }
.vib-row-aux td { color: var(--text-dim); font-size: 11.5px; }
.vib-tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text-dim); font-size: 10.5px; font-weight: 600;
}
.vib-activity th { text-transform: none; font-size: 12px; }
.vib-activity td { text-align: center; }
.vib-activity td:first-child, .vib-activity td:last-child { text-align: left; }
.vib-yes { color: var(--good); font-weight: 650; }
.vib-no { color: var(--text-faint); }
.vib-answer-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

@media (max-width: 760px) {
  .vib-top { grid-template-columns: 1fr; }
  .vib-pic { max-width: 220px; }
}

/* ---------- build the MO diagram ---------- */

.mob-tray {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  min-height: 38px; margin: 10px 0 4px; padding: 8px;
  border: 1px dashed var(--border-strong); border-radius: 12px;
}
.mob-chip {
  font: 600 13px/1 inherit; padding: 8px 12px; border-radius: 999px;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  color: var(--text); cursor: pointer;
}
.mob-chip:hover { border-color: var(--accent); }
.mob-chip-on { background: var(--accent); border-color: var(--accent); color: #fff; }

.mob-frame {
  position: relative; margin: 10px 0; padding: 10px 10px 10px 34px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.mob-axis {
  position: absolute; left: 10px; top: 50%; transform: rotate(-90deg) translateX(50%);
  transform-origin: left center; font-size: 10.5px; color: var(--text-faint);
  letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
}
.mob-ladder { display: grid; gap: 6px; }
.mob-row { display: grid; grid-template-columns: 22px minmax(118px, 190px) 1fr; gap: 10px; align-items: center; }
.mob-rank { font-size: 11px; color: var(--text-faint); text-align: right; font-variant-numeric: tabular-nums; }
.mob-slot {
  font: 600 13px/1 inherit; padding: 9px 10px; border-radius: 10px;
  border: 1.5px dashed var(--border-strong); background: transparent;
  color: var(--text-faint); cursor: pointer; text-align: center;
}
.mob-slot-filled { border-style: solid; background: var(--surface-2, var(--bg)); color: var(--text); }
.mob-slot:hover { border-color: var(--accent); }
.mob-boxes { display: flex; gap: 8px; align-items: center; }
.mob-box {
  width: 54px; height: 34px; border-radius: 8px; cursor: pointer;
  border: 1.5px solid var(--border-strong); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.mob-box:hover { border-color: var(--accent); }
.mob-arrows { display: inline-flex; gap: 1px; line-height: 1; }
.mob-arrow { font-size: 17px; font-weight: 700; color: var(--text); }
.mob-up { transform: translateY(-1px); }
.mob-down { transform: translateY(1px); }
.mob-empty { color: transparent; }
.mob-right { border-color: var(--good); box-shadow: inset 0 0 0 1.5px var(--good); }
.mob-wrong { border-color: var(--bad); box-shadow: inset 0 0 0 1.5px var(--bad); }

@media (max-width: 640px) {
  .mob-row { grid-template-columns: 18px minmax(96px, 1fr) auto; gap: 6px; }
  .mob-box { width: 44px; height: 30px; }
}

/* ---------- exam mode ---------- */

.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ex-topic {
  font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint);
}
.ex-total-points { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.ex-title { margin-top: 4px; font-size: 20px; }
.ex-picture {
  max-width: 200px; margin: 10px 0; padding: 6px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.ex-parts { display: grid; gap: 14px; margin-top: 14px; }
.ex-part { border-top: 1px solid var(--border); padding-top: 12px; }
.ex-part:first-child { border-top: 0; padding-top: 0; }
.ex-part-head { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: baseline; }
.ex-letter { font-weight: 700; color: var(--text-dim); }
.ex-ask { font-size: 14.5px; line-height: 1.45; }
.ex-points { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }
.ex-part-body { margin: 8px 0 0 32px; display: grid; gap: 8px; justify-items: start; }
.ex-input { max-width: 420px; width: 100%; }
.ex-picture-grid { width: 100%; }
.art-card-on { border-color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }

.ex-mark { display: grid; gap: 2px; font-size: 13px; padding: 7px 10px; border-radius: 10px; width: 100%; }
.ex-mark-good { background: var(--good-soft); }
.ex-mark-bad { background: var(--bad-soft, var(--warn-soft)); }
.ex-mark-part { background: var(--warn-soft); }
.ex-mark-open { background: var(--accent-soft); }
.ex-mark-line { display: block; }
.ex-why { color: var(--text-dim); font-size: 12.5px; }
.ex-score { font-size: 34px; font-weight: 700; margin: 4px 0; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .ex-part-body { margin-left: 0; }
  .ex-part-head { grid-template-columns: 20px 1fr; }
  .ex-points { grid-column: 2; }
}

/* ---------- point groups from geometry ---------- */

.sg-pic-wrap { display: flex; justify-content: center; margin: 6px 0 10px; }
.sg-pic {
  max-width: 260px; width: 100%; padding: 6px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.sg-pic .iso-sites { padding: 10px 6px; }
.sg-table th { text-transform: none; font-size: 12px; }
.sg-table td:nth-child(3), .sg-table td:nth-child(4) { text-align: center; }
