@import url('https://fonts.googleapis.com/css2?family=Anton&display=swap');

:root {
  --font-display: 'Anton', 'Arial Narrow', sans-serif;

  --bg: #f4f1e8;
  --surface: #ffffff;
  --surface-alt: #fffdf6;
  --surface-alt2: #f0eee6;
  --callout-bg: #f4f1e8;
  --text: #000000;
  --text-muted-1: #666666;
  --text-muted-2: #777777;
  --text-muted-3: #555555;
  --border: #000000;
  --hover: #c3beb0;
  --divider: #c3beb0;
  --accent-bg: #000000;
  --accent-text: #ffffff;
  --danger: #d93025;
  --success: #1e9e4a;
  --shadow-color: #000000;
  --curve-d: #1f5fbf; --curve-s: #c0392b; --curve-mr: #2e8b57;
}

[data-theme="dark"] {
  --bg: #1b1a17;
  --surface: #2a2822;
  --surface-alt: #33312a;
  --surface-alt2: #302e27;
  --callout-bg: #242219;
  --text: #f0eee6;
  --text-muted-1: #b9b4a6;
  --text-muted-2: #aca795;
  --text-muted-3: #9d9887;
  --border: #f0eee6;
  --hover: #4a4438;
  --divider: #4a4438;
  --accent-bg: #f0eee6;
  --accent-text: #1b1a17;
  --danger: #ff6b5b;
  --success: #4ade80;
  --shadow-color: #f0eee6;
  --curve-d: #7db0ff; --curve-s: #ff8a7a; --curve-mr: #6fd49a;
}

body {
  transition: background-color 0.15s ease, color 0.15s ease;
}

.logo-icon {
  display: inline-block;
  filter: grayscale(1);
  font-size: 0.7em;
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg);
  margin: 0;
  padding: 0 20px 40px;
}

h1 {
  font-size: 50px;
  color: var(--text);
  font-family: var(--font-display);
  text-align: center;
}

h2 { 
  font-size: 35px;
  color: var(--text);
  font-family: var(--font-display);
  text-align: center;
}

.nav-top-layout {
  font-size: 50px;
  color: var(--text);
  font-family: var(--font-display);
  text-align: left;
  padding-top: 20px;
}

.app-name-link {
  color: var(--text);
  text-decoration: none;
}

.app-name-link:hover {
  text-decoration: underline;
}

.back-row {
  max-width: 900px;
  margin: 0 auto 10px;
  padding-top: 20px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.back-arrow-icon {
  width: 48px;
  height: 48px;
  fill: var(--text);
  transition: transform 0.15s ease;
}

.back-link:hover .back-arrow-icon {
  transform: translateX(-6px);
}

.profile-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--accent-bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 0;
  transition: transform 0.15s ease;
}

.profile-btn:hover {
  transform: scale(1.06);
}

.profile-btn svg {
  width: 26px;
  height: 26px;
  fill: var(--accent-text);
}

.theme-toggle-btn {
  position: fixed;
  top: 20px;
  right: 78px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--accent-bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 0;
  transition: transform 0.15s ease;
}

.theme-toggle-btn:hover {
  transform: scale(1.06);
}

.theme-toggle-btn svg {
  width: 24px;
  height: 24px;
  fill: var(--accent-text);
}

.theme-toggle-btn .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-moon { display: block; }

.ref-nav {
  max-width: 900px;
  margin: 0 auto 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.ref-nav a {
  font-family: var(--font-display);
  font-size: 15px;
  padding: 10px 18px;
  border: 3px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.ref-nav a:hover {
  background-color: var(--hover);
}

.ref-nav a.active {
  background-color: var(--accent-bg);
  color: var(--accent-text);
}

/* ---------------- Periodic Table ---------------- */
:root {
  --cat-alkali: #f4b8ae;
  --cat-alkaline: #f6d3a1;
  --cat-transition: #f4ecab;
  --cat-post: #c7e3b0;
  --cat-metalloid: #a9dbd4;
  --cat-nonmetal: #a9c9ec;
  --cat-halogen: #c6b7e6;
  --cat-noble: #e3b6dc;
  --cat-lanth: #e0c9b0;
  --cat-actin: #d7b9c4;
  --cat-unknown: #d6d2c6;
}
[data-theme="dark"] {
  --cat-alkali: #6e352d;
  --cat-alkaline: #6f5528;
  --cat-transition: #64602c;
  --cat-post: #33502a;
  --cat-metalloid: #245a54;
  --cat-nonmetal: #2c4468;
  --cat-halogen: #40315e;
  --cat-noble: #562f52;
  --cat-lanth: #55402a;
  --cat-actin: #4a2c38;
  --cat-unknown: #45423a;
}

.pt-wrap {
  max-width: 1100px;
  margin: 0 auto 30px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.pt-grid {
  display: grid;
  grid-template-columns: repeat(18, minmax(46px, 1fr));
  gap: 3px;
  min-width: 900px;
}

.pt-fblock {
  display: grid;
  grid-template-columns: repeat(15, minmax(46px, 1fr));
  gap: 3px;
  min-width: 780px;
  margin: 14px auto 0;
}

.pt-tile {
  border: 2px solid var(--border);
  background-color: var(--cat-unknown);
  color: var(--text);
  padding: 4px 3px;
  cursor: pointer;
  text-align: left;
  font-family: Arial, sans-serif;
  line-height: 1.1;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: flex;
  flex-direction: column;
  min-height: 52px;
}

.pt-tile:hover {
  transform: scale(1.08);
  z-index: 5;
  box-shadow: 2px 2px 0 var(--shadow-color);
}

.pt-tile .pt-z { font-size: 9px; opacity: 0.75; }
.pt-tile .pt-sym { font-family: var(--font-display); font-size: 18px; }
.pt-tile .pt-mass { font-size: 8px; opacity: 0.75; }

.pt-tile.cat-alkali-metal { background-color: var(--cat-alkali); }
.pt-tile.cat-alkaline-earth-metal { background-color: var(--cat-alkaline); }
.pt-tile.cat-transition-metal { background-color: var(--cat-transition); }
.pt-tile.cat-post-transition-metal { background-color: var(--cat-post); }
.pt-tile.cat-metalloid { background-color: var(--cat-metalloid); }
.pt-tile.cat-nonmetal { background-color: var(--cat-nonmetal); }
.pt-tile.cat-halogen { background-color: var(--cat-halogen); }
.pt-tile.cat-noble-gas { background-color: var(--cat-noble); }
.pt-tile.cat-lanthanide { background-color: var(--cat-lanth); }
.pt-tile.cat-actinide { background-color: var(--cat-actin); }
.pt-tile.cat-unknown { background-color: var(--cat-unknown); }

.pt-legend {
  max-width: 1100px;
  margin: 0 auto 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 16px;
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
}

.pt-legend-item { display: flex; align-items: center; gap: 6px; }
.pt-legend-swatch { width: 14px; height: 14px; border: 1px solid var(--border); display: inline-block; }

.pt-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pt-modal-backdrop.open { display: flex; }

.pt-modal {
  background-color: var(--surface);
  border: 4px solid var(--border);
  max-width: 440px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 26px 28px;
  position: relative;
}

.pt-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}

.pt-modal h3 {
  font-family: var(--font-display);
  font-size: 34px;
  margin: 0 0 2px;
  color: var(--text);
}

.pt-modal .pt-modal-name {
  font-family: Arial, sans-serif;
  font-size: 15px;
  color: var(--text-muted-1);
  text-transform: capitalize;
  margin: 0 0 16px;
}

.pt-modal-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--divider);
  font-family: Arial, sans-serif;
  font-size: 14px;
}

.pt-modal-row .pt-label { color: var(--text-muted-1); }
.pt-modal-row .pt-value { color: var(--text); font-weight: bold; text-align: right; }

.pt-modal-cfg {
  margin-top: 14px;
  font-family: Arial, sans-serif;
  font-size: 14px;
}

.pt-modal-cfg .pt-cfg-line {
  font-size: 16px;
  margin: 4px 0;
  color: var(--text);
}

/* ---------------- Cheat sheets (shared by chem / econ / math) ---------------- */
.cs-main {
  max-width: 900px;
  margin: 0 auto 60px;
  font-family: Arial, sans-serif;
  color: var(--text);
}

.cs-section { margin-bottom: 38px; }

.cs-section h3 {
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 26px;
  border-bottom: 3px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 14px;
}

.cs-formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.cs-formula-card {
  border: 3px solid var(--border);
  background-color: var(--surface);
  padding: 14px 16px;
}

.cs-formula-card .cs-f-name {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 6px;
}

.cs-formula-card .cs-f-eq {
  font-size: 18px;
  font-family: 'Courier New', monospace;
}

.cs-formula-card .cs-f-note {
  font-size: 12px;
  color: var(--text-muted-1);
  margin-top: 6px;
  line-height: 1.4;
}

.cs-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.cs-table th, .cs-table td {
  border: 1px solid var(--divider);
  padding: 8px 10px;
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.cs-table th {
  background-color: var(--surface-alt2);
  font-family: var(--font-display);
  font-weight: normal;
  font-size: 15px;
}

.cs-rxn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.cs-rxn-block h4 {
  font-size: 16px;
  margin: 0 0 6px;
}

.cs-rxn-list {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.7;
}

.cs-note-box {
  border-left: 4px solid var(--border);
  background-color: var(--callout-bg);
  padding: 12px 16px;
  font-size: 14px;
  margin: 10px 0;
  line-height: 1.5;
}

.cs-svg-card {
  border: 3px solid var(--border);
  background-color: var(--surface);
  padding: 12px;
  text-align: center;
}

.cs-svg-card svg { max-width: 100%; height: auto; }
/* cheat-sheet curve colors follow the theme (readable on both light and dark cards) */
.cs-svg-card .cv-d { stroke: var(--curve-d); } .cs-svg-card .cv-s { stroke: var(--curve-s); } .cs-svg-card .cv-mr { stroke: var(--curve-mr); }
.cs-svg-card .tx-d { fill: var(--curve-d); } .cs-svg-card .tx-s { fill: var(--curve-s); } .cs-svg-card .tx-mr { fill: var(--curve-mr); }
.cs-svg-card .cs-svg-caption { font-size: 13px; color: var(--text-muted-1); margin-top: 8px; }

.profile-toast {
  position: fixed;
  top: 74px;
  right: 20px;
  background-color: var(--accent-bg);
  color: var(--accent-text);
  padding: 10px 16px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 16px;
  max-width: 220px;
  text-align: center;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}

.profile-toast.show {
  opacity: 1;
  transform: translateY(0);
}


.selection-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 500px));
justify-content: center;
align-content: center;
}

.selection-grid a {
  border: 4px solid var(--border);
  margin-top: -4px;
  margin-left: -4px;
  padding: 40px;
  text-align: center;
  font-weight: bold;
  font-family: var(--font-display);
  font-size: 27px;
  color: var(--text);
  text-decoration: none;
  display: block;
  transition: background-color 0.2s ease;
}

.selection-grid a:hover {
  background-color: var(--hover);
  cursor: pointer;
}

.mode-toolbar {
  max-width: 900px;
  margin: 0 auto 24px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.toolbar-btn {
  font-family: var(--font-display);
  font-size: 16px;
  padding: 10px 22px;
  border: 3px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.toolbar-btn:hover {
  background-color: var(--hover);
}

.category-main {
  padding-bottom: 110px;
}

.selection-grid .exercise-box {
  border: 4px solid var(--border);
  margin-top: -4px;
  margin-left: -4px;
  padding: 40px;
  text-align: center;
  font-weight: bold;
  font-family: var(--font-display);
  font-size: 27px;
  color: var(--text);
  display: block;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.selection-grid .exercise-box:hover {
  background-color: var(--hover);
}

.selection-grid .exercise-box.selected {
  background-color: var(--accent-bg);
  color: var(--accent-text);
}

.selection-grid .exercise-box.selected::after {
  content: "\2713";
  position: absolute;
  top: 8px;
  right: 14px;
  font-size: 22px;
}

.start-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--accent-bg);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 18px 20px;
  font-family: var(--font-display);
  font-size: 20px;
  z-index: 150;
  transform: translateY(100%);
  pointer-events: none;
  transition: transform 0.2s ease;
}

.start-bar.visible {
  transform: translateY(0);
  pointer-events: auto;
}

.start-btn {
  font-family: var(--font-display);
  font-size: 20px;
  padding: 10px 28px;
  border: none;
  border-radius: 6px;
  background-color: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.start-btn:hover {
  transform: scale(1.05);
}

.whitebox-layout {
  display: flex;
  justify-content: center;
  width: 100%;
}

.white-box {
  position: relative;
  background-color: var(--surface);
  width: 90%;
  max-width: 800px;
  min-height: 400px;
  padding: 40px 40px 96px;   /* v53: bottom room for the refresh / copy buttons so they never sit on the text or graph */
  border-radius: 12px; 
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.whitebox-states {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex-grow: 1;
}

.math-problem {
  font-family: var(--font-display);
  font-size: 250%;
  color: var(--text);
}

.hidden {
  display: none;
}

.next-icon-btn {
  position: absolute;
  left: 24px;
  bottom: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--surface);
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s ease, background-color 0.2s ease;
}

/* v20: copy button, bottom-right of the card, mirrors the refresh button */
.copy-icon-btn {
  position: absolute;
  right: 24px;
  bottom: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--surface);
  border: 2px solid var(--border);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s ease, background-color 0.2s ease;
}
.copy-icon-btn svg { width: 24px; height: 24px; }
.svg-icon-btn { right: 84px; }
.svg-icon-btn[hidden] { display: none; }
.copy-icon-btn:hover { background-color: var(--surface-alt2); transform: scale(1.08); }
.copy-icon-btn.on { background-color: var(--surface-alt2); }
.copy-icon-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.next-icon-btn svg {
  width: 26px;
  height: 26px;
  fill: var(--text);
}

.next-icon-btn:hover {
  background-color: var(--surface-alt2);
  transform: scale(1.08);
}


/* ---- v7: page search ---- */
.search-row {
  max-width: 900px;
  margin: 0 auto 24px;
  text-align: center;
}

.search-input {
  width: 100%;
  max-width: 500px;
  font-family: var(--font-display);
  font-size: 20px;
  padding: 12px 18px;
  border: 4px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  outline: none;
}

.search-input:focus {
  background-color: var(--surface-alt);
  box-shadow: 4px 4px 0 var(--shadow-color);
}

.search-hidden {
  display: none !important;
}

.search-empty {
  display: none;
  text-align: center;
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--text-muted-1);
  margin-top: 30px;
}

.search-empty.visible {
  display: block;
}

.fav-hint {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text-muted-2);
  letter-spacing: 0.02em;
}

/* ---- v7: favorites ---- */
.selection-grid a,
.selection-grid .exercise-box {
  position: relative;
}

.is-favorite::before {
  content: "\2605";
  position: absolute;
  top: 8px;
  left: 14px;
  font-size: 22px;
  line-height: 1;
}

.favorites-section {
  margin-top: 50px;
}

.favorites-section.no-favorites {
  display: none;
}

.favorites-section h2 {
  margin-bottom: 20px;
}

.fav-context {
  display: block;
  margin-top: 8px;
  font-size: 15px;
  font-weight: normal;
  color: var(--text-muted-3);
  letter-spacing: 0.04em;
}

.fav-toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%, 8px);
  background-color: var(--accent-bg);
  color: var(--accent-text);
  padding: 10px 20px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
}

.fav-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---- v8: pomodoro timer ---- */
.pomo {
  position: fixed;
  top: 20px;
  right: 136px; /* leaves room for the theme toggle (right: 78px) and profile button */
  z-index: 100;
  font-family: var(--font-display);
}

.pomo-pill {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 16px;
  border-radius: 24px;
  background-color: var(--accent-bg);
  color: var(--accent-text);
  border: 3px solid var(--border);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.pomo.is-rest .pomo-pill {
  background-color: var(--surface);
  color: var(--text);
}

.pomo-readout {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 64px;
  line-height: 1;
  margin-right: 4px;
}

.pomo-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  opacity: 0.7;
}

.pomo-time {
  font-size: 22px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.pomo.is-running .pomo-label::before {
  content: "\25CF ";
  font-size: 9px;
  vertical-align: 1px;
}

.pomo-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface);
  transition: transform 0.15s ease;
}

.pomo.is-rest .pomo-btn {
  background-color: var(--accent-bg);
}

.pomo-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--text);
}

.pomo.is-rest .pomo-btn svg {
  fill: var(--accent-text);
}

.pomo-btn:hover {
  transform: scale(1.1);
}

.pomo.ding .pomo-pill {
  animation: pomo-ding 0.6s ease 5;
}

@keyframes pomo-ding {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.pomo-menu {
  display: none;
  position: absolute;
  top: 58px;
  right: 0;
  width: 250px;
  background-color: var(--surface);
  color: var(--text);
  border: 4px solid var(--border);
  padding: 14px 16px;
}

.pomo-menu.open {
  display: block;
}

.pomo-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.pomo-row-label {
  flex: 1;
  font-size: 20px;
}

.pomo-step {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.pomo-step:hover {
  background-color: var(--accent-bg);
  color: var(--accent-text);
}

.pomo-val {
  min-width: 62px;
  text-align: center;
  font-size: 18px;
}

.pomo-note {
  margin: 4px 0 0;
  font-family: Arial, sans-serif;
  font-size: 12px;
  color: var(--text-muted-1);
}

/* ---- v8: profile / stats panel ---- */
.pf-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 300;
}

.pf-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.pf-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 100%;
  background-color: var(--callout-bg);
  border-left: 4px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 301;
  font-family: var(--font-display);
  color: var(--text);
}

.pf-panel.open {
  transform: translateX(0);
}

.pf-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background-color: var(--accent-bg);
  color: var(--accent-text);
}

.pf-head h3 {
  margin: 0;
  font-size: 30px;
  font-weight: normal;
}

.pf-close {
  background: none;
  border: none;
  color: var(--accent-text);
  font-size: 38px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.pf-body {
  padding: 8px 22px 30px;
  overflow-y: auto;
  flex: 1;
}

.pf-body h4 {
  font-size: 22px;
  font-weight: normal;
  letter-spacing: 0.04em;
  margin: 26px 0 10px;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--border);
}

.pf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pf-card {
  background-color: var(--surface);
  border: 3px solid var(--border);
  padding: 12px 14px;
}

.pf-card-value {
  font-size: 30px;
  line-height: 1.1;
}

.pf-card-label {
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--text-muted-3);
  margin-top: 4px;
}

.pf-fine {
  font-family: Arial, sans-serif;
  font-size: 12px;
  color: var(--text-muted-1);
  margin: 10px 0 0;
  line-height: 1.4;
}

.pf-empty {
  font-family: Arial, sans-serif;
  font-size: 14px;
  color: var(--text-muted-1);
  margin: 6px 0;
}

.pf-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pf-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 18px;
}

ol.pf-list {
  counter-reset: miss;
}

ol.pf-list li {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.pf-sub {
  font-family: Arial, sans-serif;
  font-size: 12px;
  color: var(--text-muted-1);
  white-space: nowrap;
}

ol.pf-list .pf-sub {
  white-space: normal;
}

.pf-rest {
  color: var(--text-muted-2);
}

.pf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pf-btn {
  font-family: var(--font-display);
  font-size: 16px;
  padding: 10px 16px;
  border: 3px solid var(--border);
  background-color: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.pf-btn:hover {
  background-color: var(--hover);
}

.pf-btn.armed {
  background-color: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* ---- v8: problem counter + check / x boxes ---- */
.session-counter {
  text-align: center;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.06em;
  color: var(--text-muted-3);
  margin: -14px 0 22px;
  white-space: pre;
}

.mark-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 26px;
}

.mark-btn {
  width: 130px;
  height: 68px;
  background-color: var(--surface);
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.18s ease, transform 0.15s ease;
}

.mark-btn svg {
  width: 38px;
  height: 38px;
  fill: var(--text);
  transition: fill 0.18s ease;
}

.mark-btn:hover {
  transform: translateY(-2px);
}

.mark-btn:active {
  transform: translateY(0);
}

.mark-miss:hover {
  background-color: var(--danger);
}

.mark-hit:hover {
  background-color: var(--success);
}

.mark-btn:hover svg {
  fill: #fff;
}

.mark-hint {
  text-align: center;
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: var(--text-muted-2);
  margin: 14px 0 0;
}

@media (max-width: 900px) {
  .pomo-label { display: none; }
  .pomo-readout { min-width: 52px; }
}


/* ---- v17: figures (graphs, shapes, diagrams) on the question card ---- */
.fig {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 18px;
}
.fig:empty { display: none; margin: 0; }
.fig svg {
  max-width: 100%;
  height: auto;
  max-height: 380px;
}
.white-box.has-fig .math-problem {
  font-size: 175%;
  text-align: center;
}

/* v16: quick-reference drawer, profile toggles, favorites help */
.ref-btn { position: fixed; right: 18px; bottom: 18px; z-index: 140; font-family: var(--font-display); font-size: 16px; padding: 10px 16px; border: 2px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; box-shadow: 3px 3px 0 var(--shadow-color); }
.ref-btn:hover { background: var(--hover); }
.ref-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 92vw); z-index: 200; background: var(--surface); color: var(--text); border-left: 2px solid var(--border); transform: translateX(100%); transition: transform 0.2s ease; display: flex; flex-direction: column; }
.ref-drawer.open { transform: translateX(0); }
.ref-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 2px solid var(--border); }
.ref-head .pf-close { color: var(--text); font-size: 34px; }
.ref-head h3 { margin: 0; font-size: 16px; font-family: var(--font-display); font-weight: normal; }
.ref-body { overflow-y: auto; padding: 12px 16px 28px; font-family: Arial, sans-serif; font-size: 13px; line-height: 1.45; }
.ref-sec { margin-bottom: 22px; }
.ref-sec h4 { margin: 0 0 8px; font-size: 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ref-src { font-size: 10px; font-weight: normal; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.04em; }
.ref-list { margin: 0; padding-left: 18px; }
.ref-list li { margin-bottom: 6px; }
.ref-note { margin: 8px 0 0; font-size: 12px; opacity: 0.75; }
.ref-body .cs-table { font-size: 12px; }
.ref-body .cs-formula-grid, .ref-body .cs-rxn-grid { grid-template-columns: 1fr; }
.pf-toggle { display: block; padding: 6px 0; font-family: Arial, sans-serif; font-size: 14px; cursor: pointer; }
.pf-toggle input { margin-right: 6px; }
.fav-help { text-align: center; margin: 4px 0 12px; }
.selection-grid .exercise-box .fav-context { display: block; margin-top: 4px; }

/* v17: compact periodic table inside the reference drawer */
.rpt-grid { display: grid; grid-template-columns: repeat(18, 1fr); gap: 1px; }
.rpt-grid .pt-tile { min-height: 0; padding: 1px 0; border-width: 1px; align-items: center; cursor: default; }
.rpt-grid .pt-tile:hover { transform: none; box-shadow: none; outline: 2px solid var(--border); z-index: 5; }
.rpt-grid .pt-z { font-size: 6px; }
.rpt-grid .pt-sym { font-size: 10px; }

/* StemDriller: logo icon + topics/subjects that are planned but not built yet */
.logo-svg { width: .85em; height: .85em; vertical-align: -0.08em; margin-left: 4px; }
.selection-grid a.soon, .selection-grid .exercise-box.coming-soon { opacity: .4; }
.selection-grid .exercise-box.coming-soon { cursor: default; }
.selection-grid .exercise-box.coming-soon:hover { background-color: transparent; }
.soon-tag { display: block; margin-top: 6px; font-family: inherit; font-size: 13px; font-weight: bold; letter-spacing: .12em; text-transform: uppercase; }

/* v25: code problems (Programming Fundamentals) - monospace, whitespace preserved, left-aligned */
.math-problem.code-text { font-family: 'Courier New', Consolas, monospace; font-size: 135%; white-space: pre-wrap; text-align: left; line-height: 1.35; overflow-wrap: anywhere; }
.white-box.has-fig .math-problem.code-text { font-size: 120%; }

/* Flashcard-style topics sit after the drills, under a quiet divider */
.selection-grid .flash-divider { grid-column: 1 / -1; margin: 18px 0 4px; padding-top: 12px; border-top: 1px solid currentColor; opacity: .55; font-size: 13px; font-weight: bold; letter-spacing: .08em; text-transform: uppercase; }
.selection-grid .exercise-box.flash-topic { opacity: .85; }

/* v53: keep the floating Reference button from covering the page: reserve room under the content when it is shown */
body.has-ref-btn { padding-bottom: 76px; }
.ref-btn.ref-inline { position: static; display: block; margin: 16px auto 36px; }
@media (max-width: 520px) {
  .white-box { padding: 28px 18px 96px; }
  .copy-icon-btn, .next-icon-btn { width: 44px; height: 44px; bottom: 20px; }
  .copy-icon-btn { right: 16px; } .svg-icon-btn { right: 68px; } .next-icon-btn { left: 16px; }
}

/* Legal pages and footer */
.legal-main { max-width: 720px; margin: 24px auto; padding: 0 20px; color: var(--text); line-height: 1.6; }
.legal-main h2 { margin-top: 28px; }
.legal-main a { color: var(--text); text-decoration: underline; overflow-wrap: anywhere; }
.legal-date { color: var(--text-muted-1); }
.site-footer { text-align: center; padding: 28px 16px 24px; font-size: 14px; color: var(--text-muted-1); }
.site-footer a { color: var(--text-muted-1); text-decoration: underline; }
