:root {
  --bg: #0f1720;
  --surface: #17212b;
  --surface-raised: #202d3b;
  --border: #2a3644;
  --ink: #e8edf2;
  --ink-muted: #8593a3;
  --accent: #2dd4bf;
  --accent-dim: #14b8a6;
  --accent-glow: rgba(45, 212, 191, 0.4);
  --danger: #f0654a;
  --success: #34d399;
}

:root[data-theme="light"] {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-raised: #eef2f3;
  --border: #dde3e6;
  --ink: #16212a;
  --ink-muted: #647685;
  --accent: #0d9488;
  --accent-dim: #0f766e;
  --accent-glow: rgba(13, 148, 136, 0.25);
  --danger: #d9432c;
  --success: #16a34a;
}
:root[data-theme="light"] .btn-primary { color: #ffffff; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

p { line-height: 1.6; }
h1, h2 { letter-spacing: -0.01em; }

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

.mono { font-family: "Consolas", "SFMono-Regular", Menlo, monospace; }

/* ---------- Nav ---------- */

.navbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.navbar-inner {
  max-width: 1000px; margin: 0 auto; padding: 0 16px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; object-fit: cover;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav-links { display: flex; gap: 20px; margin-left: 28px; font-size: 14px; }
.nav-links a { text-decoration: none; color: var(--ink-muted); }
.nav-links a.active, .nav-links a:hover { color: var(--ink); }
.nav-right { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-muted); }
.btn-outline {
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px;
  color: var(--ink-muted); text-decoration: none; background: none; font-size: 14px; cursor: pointer;
}
.btn-outline:hover { color: var(--ink); border-color: var(--ink-muted); }

/* ---------- Layout ---------- */

main { max-width: 1000px; margin: 0 auto; padding: 32px 16px; }
main.narrow { max-width: 640px; }
h1 { font-size: 23px; font-weight: 650; margin: 0 0 24px; letter-spacing: -0.015em; }
.subtitle { color: var(--ink-muted); font-size: 14px; margin-top: -14px; margin-bottom: 20px; }

/* ---------- Flash ---------- */

.flash { border-radius: 6px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.flash-success { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: var(--success); }
.flash-error { background: rgba(240,101,74,0.1); border: 1px solid rgba(240,101,74,0.3); color: var(--danger); }
.flash-warning { background: rgba(45,212,191,0.1); border: 1px solid rgba(45,212,191,0.3); color: var(--accent); }

/* ---------- Cards ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.card-pad { padding: 20px; }
.row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); border-left: 4px solid transparent; }
.row:last-child { border-bottom: none; }
.row:hover { background: var(--surface-raised); }
.row a.row-link { display: flex; width: 100%; align-items: center; justify-content: space-between; text-decoration: none; color: inherit; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 28px; }
.subject-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px;
  text-decoration: none; color: var(--ink); transition: border-color 0.15s;
}
.subject-card:hover { border-color: var(--accent); }
.subject-card h2 { margin: 0 0 6px; font-size: 17px; }
.subject-card p { margin: 0; color: var(--ink-muted); font-size: 13px; }

/* ---------- Forms ---------- */

label { display: block; font-size: 13px; color: var(--ink-muted); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; color: var(--ink); font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { min-height: 70px; }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }
.helper-text { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-muted); }

.btn-primary {
  background: var(--accent); color: #06251f; border: none; border-radius: 6px;
  padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-danger-link { background: none; border: none; color: var(--danger); font-size: 14px; cursor: pointer; padding: 0; }
.btn-danger-link:hover { opacity: 0.8; }
.btn-text-link { background: none; border: none; color: var(--ink-muted); font-size: 14px; cursor: pointer; padding: 0; text-decoration: none; }
.btn-text-link:hover { color: var(--ink); }

/* ---------- Question review / edit ---------- */

.photo-preview { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 20px; }
.question-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 16px; }
.question-card.incomplete { border-color: var(--danger); }
.missing-flag { color: var(--danger); font-size: 12px; margin-bottom: 10px; }
.option-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.option-row .option-label { width: 22px; flex-shrink: 0; color: var(--ink-muted); font-family: "Consolas", monospace; }
.option-row input[type="text"] { flex: 1; }

/* ---------- Correct-answer toggle: a large clickable pill, not a tiny checkbox ---------- */

.correct-toggle { display: inline-flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.correct-toggle-input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0; /* visually hidden, still focusable & functional */
}
.correct-toggle-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 9px 18px; min-width: 92px; border-radius: 999px; border: 2px solid var(--border);
  background: var(--surface-raised); color: var(--ink-muted); font-size: 13px; font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease; user-select: none;
}
.correct-toggle-pill::before { content: ""; }
.correct-toggle-input:checked + .correct-toggle-pill {
  background: var(--success); border-color: var(--success); color: #06251f;
}
.correct-toggle-input:checked + .correct-toggle-pill::before { content: "\2713"; }
.correct-toggle-input:focus-visible + .correct-toggle-pill { box-shadow: 0 0 0 3px rgba(45,212,191,0.35); }
.correct-toggle:hover .correct-toggle-pill { border-color: var(--accent); }

/* ---------- Test taking ---------- */

.timer-bar {
  position: sticky; top: 0; z-index: 10; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 20px; margin-bottom: 20px; display: flex; align-items: center;
  justify-content: space-between; gap: 28px;
}
.timer-display { font-family: "Consolas", monospace; font-size: 22px; color: var(--accent); flex-shrink: 0; }
.timer-display.low-time { color: var(--danger); }
.test-question { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 14px; }
.test-question-number { font-size: 12px; color: var(--ink-muted); margin-bottom: 6px; }
.test-option { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.test-option:first-of-type { border-top: none; }
.test-option input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- Results ---------- */

.score-hero { text-align: center; padding: 40px 20px; }
.score-number { font-size: 48px; font-weight: 700; color: var(--accent); font-family: "Consolas", monospace; }
.result-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.result-row:first-of-type { border-top: none; }
.result-icon-correct { color: var(--success); }
.result-icon-wrong { color: var(--danger); }

/* ---------- Question list row + gear config button ---------- */

.question-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 12px;
  border-left: 4px solid transparent;
}
.question-row:last-child { border-bottom: none; }
.question-row:hover { background: var(--surface-raised); }
.question-row .select-checkbox { display: none; width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.question-row.select-mode .select-checkbox { display: inline-block; }
.question-row a.row-link { flex: 1; text-decoration: none; color: inherit; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.question-row a.row-link span.q-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gear-btn {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-raised); color: var(--ink-muted); display: flex; align-items: center;
  justify-content: center; text-decoration: none; font-size: 15px;
}
.gear-btn:hover { color: var(--ink); border-color: var(--accent); }

.select-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }

/* ---------- View/reveal question page ---------- */

.view-option {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px;
  border: 1px solid var(--border); margin-bottom: 8px; background: var(--surface);
}
.view-option .option-letter { font-family: "Consolas", monospace; color: var(--ink-muted); flex-shrink: 0; }
.view-option.revealed-correct { background: rgba(52,211,153,0.12); border-color: var(--success); color: var(--success); }
.view-option.revealed-wrong { background: rgba(240,101,74,0.08); border-color: var(--border); color: var(--ink-muted); }

/* ---------- Search ---------- */

.search-bar-inline { display: flex; gap: 8px; margin-bottom: 24px; }
.search-bar-inline input[type="search"] {
  flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 14px; color: var(--ink); font-size: 14px;
}
.search-result-meta { font-size: 12px; color: var(--ink-muted); margin-top: 3px; }

/* ---------- Warnings / span-photo flags ---------- */

.spans-photo-flag {
  font-size: 12px; color: var(--danger); margin-bottom: 8px; display: inline-block;
  border: 1px solid var(--danger); border-radius: 6px; padding: 3px 8px;
}

/* ---------- Multi-file upload ---------- */

.file-count-hint { font-size: 12px; color: var(--ink-muted); margin-top: 4px; }

/* ---------- Search suggestions dropdown ---------- */

.search-bar-inline { position: relative; }
.search-suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.35); overflow: hidden;
  animation: suggestions-in 0.15s ease-out;
}
.suggestion-row {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 14px;
  text-decoration: none; color: var(--ink); font-size: 14px; border-bottom: 1px solid var(--border);
}
.suggestion-row:last-child { border-bottom: none; }
.suggestion-row:hover { background: var(--surface-raised); }
.suggestion-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-path { font-size: 12px; color: var(--ink-muted); }
@keyframes suggestions-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Smoother transitions everywhere interactive ---------- */

a, button, .btn-primary, .btn-outline, .btn-text-link, .btn-danger-link, .gear-btn,
.row, .question-row, .subject-card, .view-option, input, select, textarea {
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease,
              opacity 0.15s ease, transform 0.15s ease;
}
.question-card, .test-question, .card { animation: fade-in-up 0.2s ease-out; }
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Nav overflow "More" dropdown ---------- */

.nav-more { position: relative; display: inline-block; }
.nav-more summary {
  cursor: pointer; list-style: none; color: var(--ink-muted); font-size: 14px;
  padding: 2px 0;
}
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary::after { content: " \25be"; font-size: 11px; }
.nav-more[open] summary, .nav-more summary:hover { color: var(--ink); }
.nav-more-menu {
  position: absolute; top: 100%; left: 0; margin-top: 8px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px; display: flex; flex-direction: column; min-width: 170px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
}
.nav-more-menu a {
  padding: 8px 10px; border-radius: 6px; text-decoration: none;
  color: var(--ink-muted); font-size: 14px;
}
.nav-more-menu a:hover, .nav-more-menu a.active { background: var(--surface-raised); color: var(--ink); }

/* ---------- Low-confidence OCR highlighting ---------- */

.low-confidence-field { border-color: #d97706 !important; background: rgba(217,119,6,0.08) !important; }
.low-conf-flag { color: #d97706; font-size: 11px; font-weight: 600; margin-left: 6px; }

/* ---------- Flag for review ---------- */

.flag-toggle {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-muted);
  cursor: pointer; user-select: none;
}
.flag-checkbox { accent-color: #f59e0b; }
.flag-toggle:has(.flag-checkbox:checked) { color: #f59e0b; font-weight: 600; }

/* ---------- Celebratory flourish ---------- */

.celebration {
  text-align: center; font-size: 15px; color: var(--success); margin-top: 10px;
  animation: celebrate-pop 0.5s ease-out;
}
@keyframes celebrate-pop {
  0% { opacity: 0; transform: scale(0.7); }
  60% { opacity: 1; transform: scale(1.08); }
  100% { transform: scale(1); }
}
.confetti-emoji { display: inline-block; animation: confetti-spin 1.2s ease-in-out; }
@keyframes confetti-spin {
  0% { transform: rotate(0deg) scale(0.5); }
  50% { transform: rotate(15deg) scale(1.3); }
  100% { transform: rotate(0deg) scale(1); }
}

/* ---------- Skeleton loading placeholders ---------- */

.skeleton-row { padding: 10px 14px; }
.skeleton-bar {
  height: 12px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-raised) 25%, var(--border) 50%, var(--surface-raised) 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.skeleton-bar.short { width: 40%; margin-top: 6px; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Avatars ---------- */

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; color: #12151a;
  font-size: 11px; font-weight: 700; vertical-align: middle;
}

/* ---------- Settings dropdown ---------- */

.settings-menu { position: relative; }
.settings-summary { cursor: pointer; list-style: none; }
.settings-summary::-webkit-details-marker { display: none; }
.settings-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); animation: fade-in-up 0.15s ease-out;
}

/* ---------- Test progress bar ---------- */

.progress-track { height: 4px; background: var(--border); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.2s ease-out; }

/* ---------- Focus mode ---------- */

body.focus-mode .navbar { display: none; }

/* ---------- Streak calendar heatmap ---------- */

.calendar-toggle-btn {
  font-size: 12px; padding: 5px 11px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-raised); color: var(--ink-muted); cursor: pointer; white-space: nowrap;
}
.calendar-toggle-btn:hover { color: var(--ink); border-color: var(--accent); }
.streak-calendar-wrapper { max-width: 300px; }
.calendar-week {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 3px;
  overflow: hidden; max-height: 0; opacity: 0; transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.25s ease;
}
.calendar-week.current-week, .streak-calendar-wrapper.expanded .calendar-week {
  max-height: 60px; opacity: 1;
}
.streak-day {
  aspect-ratio: 1; border-radius: 5px; background: var(--surface-raised); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform 0.1s;
}
.streak-day-num { font-size: 11px; font-weight: 600; line-height: 1.2; color: var(--ink-muted); }
.streak-day-name { font-size: 8px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--ink-muted); line-height: 1.2; }
.streak-day.practiced { background: var(--accent); border-color: var(--accent); }
.streak-day.practiced .streak-day-num, .streak-day.practiced .streak-day-name { color: #06251f; }
.streak-day.today { box-shadow: inset 0 0 0 2px var(--ink-muted); }
.streak-day.sunday .streak-day-name { text-decoration: underline; text-decoration-color: currentColor; }
.streak-day.outside-month { opacity: 0.35; }
.streak-day:hover { transform: scale(1.15); }

/* ---------- Inactivity nudge ---------- */

.inactivity-nudge {
  max-width: 220px; background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--ink-muted);
}

/* ---------- Exam countdown glow (final week) ---------- */

.countdown-glow {
  animation: countdown-pulse 2.5s ease-in-out infinite;
  border-color: var(--accent) !important;
}
@keyframes countdown-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45,212,191,0.25); }
  50% { box-shadow: 0 0 20px 4px rgba(45,212,191,0.25); }
}

/* ---------- Flashcards ---------- */

.flashcard-scene {
  perspective: 1400px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.flashcard-scene.card-exit { opacity: 0; transform: translateX(-16px); }
.flashcard-scene.card-enter { opacity: 0; transform: translateX(16px); }
.flashcard-scene.card-exit-reverse { opacity: 0; transform: translateX(16px); }
.flashcard-scene.card-enter-reverse { opacity: 0; transform: translateX(-16px); }
.flashcard-scene:not(.card-exit):not(.card-enter):not(.card-exit-reverse):not(.card-enter-reverse) { opacity: 1; transform: translateX(0); }

.flashcard-nav-row { display: flex; align-items: center; gap: 10px; }
.card-stack-wrapper { flex: 1; position: relative; }
.card-nav-btn {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-raised); color: var(--ink); font-size: 20px; cursor: pointer;
}
.card-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.card-nav-btn:disabled { opacity: 0.3; cursor: default; }

/* TRIAL, mobile only: a couple of stacked "ghost" cards behind the
   current one, for a physical deck-of-cards look. Desktop uses the
   prev/next buttons instead of swipe, so the stack effect (and the
   arrow buttons themselves) are hidden there — see the media query. */
@media (max-width: 640px) {
  .card-nav-btn { display: none; }
  .card-stack-wrapper::before, .card-stack-wrapper::after {
    content: ""; position: absolute; left: 6%; right: 6%; border-radius: 10px;
    background: var(--surface-raised); border: 1px solid var(--border); z-index: -1;
  }
  .card-stack-wrapper::before { top: -6px; height: 100%; opacity: 0.7; transform: scale(0.97); }
  .card-stack-wrapper::after { top: -12px; height: 100%; opacity: 0.4; transform: scale(0.94); }
}

.flashcard-3d {
  position: relative;
  min-height: 140px;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0.1, 0.2, 1), height 0.3s ease;
}
.flashcard-3d.flipped { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 28px 24px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
.flashcard-back {
  transform: rotateY(180deg);
  justify-content: flex-start; align-items: stretch; text-align: left;
}
.flashcard-question { font-size: 19px; margin: 0 0 20px; }
.flashcard-question-small { font-size: 15px; color: var(--ink-muted); margin-bottom: 14px; }

.confidence-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.confidence-btn {
  flex: 1; min-width: 110px; border-radius: 8px; padding: 10px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border); background: var(--surface-raised); color: var(--ink);
}
.confidence-knew:hover { border-color: var(--success); color: var(--success); }
.confidence-unsure:hover { border-color: #f59e0b; color: #f59e0b; }
.confidence-guessed:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- COSMETIC: soft highlight on the focused/hovered option row ---------- */
/* To revert: delete this block. */

.test-option, .view-option { border-radius: 6px; padding-left: 8px; padding-right: 8px; }
.test-option:hover, .test-option:focus-within {
  background: var(--surface-raised);
}

/* ---------- COSMETIC: smooth checkbox check animation ---------- */
/* To revert: delete this block. */

input[type="checkbox"] {
  transition: transform 0.12s ease;
}
input[type="checkbox"]:checked {
  animation: checkbox-pop 0.22s ease;
}
@keyframes checkbox-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ---------- COSMETIC: very subtle background grain texture ---------- */
/* To revert: delete this block (and the "position: relative" is safe to leave, or remove it too). */

body { position: relative; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main { position: relative; z-index: 1; }
.navbar { position: relative; z-index: 20; }

/* ---------- Admin-only page treatment ---------- */

body.admin-context .navbar { border-bottom: 2px solid #a855f7; }
.admin-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: #a855f7;
  border: 1px solid #a855f7; border-radius: 4px; padding: 2px 6px; margin-left: 4px;
}

/* ---------- COSMETIC: glow ring around focused input fields ---------- */
/* To revert: delete this block. */

input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- Difficulty indicator (personal accuracy history) ---------- */

.difficulty-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.difficulty-easy { background: var(--success); }
.difficulty-medium { background: #f59e0b; }
.difficulty-hard { background: var(--danger); }

/* ---------- Quick subject switcher pills ---------- */

.subject-pills { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.subject-pill {
  padding: 6px 14px; border-radius: 999px; border: 2px solid var(--border);
  background: var(--surface-raised); color: var(--ink-muted); font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.subject-pill:hover { color: var(--ink); }
.subject-pill.active { color: var(--ink); background: var(--surface); }

/* ---------- Admin user management ---------- */

.user-row { border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.reset-password-toggle summary { cursor: pointer; list-style: none; }
.reset-password-toggle summary::-webkit-details-marker { display: none; }

/* ---------- Responsive nav: hamburger menu + compact account button on mobile/tablet ---------- */

.hamburger-btn {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 30px; height: 30px; background: none; border: none; cursor: pointer; margin-right: 10px; padding: 0;
}
.hamburger-btn span { display: block; width: 20px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform 0.2s ease, opacity 0.2s ease; }
.hamburger-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.mobile-account { display: none; }
.account-menu { position: relative; }
.avatar-summary { cursor: pointer; list-style: none; display: flex; }
.avatar-summary::-webkit-details-marker { display: none; }
.account-menu-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.35); animation: fade-in-up 0.15s ease-out;
}
.account-menu-name { font-weight: 600; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.account-menu-signout {
  display: block; text-align: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
  color: var(--danger); text-decoration: none; font-size: 14px;
}

.mobile-nav { display: none; }

@media (max-width: 860px) {
  .hamburger-btn { display: flex; }
  .desktop-nav, .desktop-account { display: none !important; }
  .mobile-account { display: block; }
  .mobile-nav {
    flex-direction: column; padding: 8px 16px 16px; border-top: 1px solid var(--border);
    max-height: 0; overflow: hidden; transition: max-height 0.25s ease;
  }
  .mobile-nav.open { display: flex; max-height: 500px; }
  .mobile-nav a { padding: 12px 4px; color: var(--ink-muted); text-decoration: none; border-bottom: 1px solid var(--border); }
  .mobile-nav a:last-child { border-bottom: none; }
  .mobile-nav a.active { color: var(--accent); }
  .navbar-inner { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .navbar-inner { padding: 0 12px; }
  main { padding: 20px 12px; }
}

/* ---------- TRIAL: mastery level badges (per subsection) ---------- */
/* To revert: remove the .mastery-badge span from subject.html and delete this block. */

.mastery-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.mastery-new { background: var(--surface-raised); color: var(--ink-muted); }
.mastery-learning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.mastery-familiar { background: rgba(59,130,246,0.15); color: #3b82f6; }
.mastery-mastered { background: rgba(34,197,94,0.15); color: var(--success); }

/* ---------- TRIAL: circular progress ring (Study Plan) ---------- */
/* To revert: remove the ring block from study_plan.html and delete this block. */

.progress-ring-track { fill: none; stroke: var(--border); stroke-width: 8; }
.progress-ring-fill { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dasharray 0.4s ease; }
.progress-ring-label { fill: var(--ink); font-size: 16px; font-weight: 700; font-family: inherit; }

/* ---------- First-time walkthrough ---------- */

.tour-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.tour-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px; max-width: 380px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  animation: fade-in-up 0.2s ease-out;
}

/* ---------- Session-end mood check-in ---------- */

.mood-btn {
  flex: 1; padding: 12px 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-raised); color: var(--ink-muted); font-size: 13px; text-align: center;
  cursor: pointer; line-height: 1.6;
}
.mood-btn:hover { border-color: var(--accent); color: var(--ink); }

/* ---------- Disable double-tap-to-zoom on flashcards and the exam-taking page ---------- */
/* Scoped to just these two pages via a main_class flag — the rest of the site keeps normal zoom behavior. */

main.no-double-tap-zoom { touch-action: manipulation; }

/* ---------- Settings modal (centered popup, replacing the old dropdown) ---------- */

.settings-modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.55); align-items: center; justify-content: center; padding: 20px;
}
.settings-modal-overlay.open { display: flex; }
.settings-modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px; max-width: 420px; width: 100%; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4); animation: fade-in-up 0.15s ease-out;
}
.modal-close-btn {
  background: none; border: none; font-size: 24px; line-height: 1; cursor: pointer;
  color: var(--ink-muted); padding: 0 4px;
}
.modal-close-btn:hover { color: var(--ink); }

/* ---------- Animated sun/moon theme toggle ---------- */

.theme-toggle {
  position: relative; width: 64px; height: 32px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-raised); cursor: pointer; margin-top: 6px; padding: 0;
}
.theme-toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); transition: transform 0.25s ease;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.theme-toggle[data-theme="light"] .theme-toggle-thumb { transform: translateX(32px); }
.theme-icon-in-thumb {
  position: absolute; font-size: 12px; line-height: 1;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
/* Exactly one icon shows at a time — driven by state, never by stacking order. */
.theme-toggle[data-theme="dark"] .icon-sun,
.theme-toggle[data-theme="light"] .icon-moon { opacity: 0; transform: scale(0.4); }
.theme-toggle[data-theme="dark"] .icon-moon,
.theme-toggle[data-theme="light"] .icon-sun { opacity: 1; transform: scale(1); }

/* ---------- Movement reminder banner ---------- */

.movement-reminder-banner {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 120;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 18px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); font-size: 14px;
  display: flex; align-items: center; gap: 12px; animation: fade-in-up 0.2s ease-out;
}
.movement-reminder-banner button {
  background: none; border: none; color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; padding: 0;
}

/* ---------- "Why am I studying this" reminder ---------- */

.study-reason-card {
  font-size: 13px; color: var(--ink-muted); font-style: italic;
  padding: 10px 14px; margin-bottom: 16px; border-left: 3px solid var(--accent);
  background: var(--surface-raised); border-radius: 0 8px 8px 0;
}

/* ---------- Admin: disk usage bar (System Settings) ---------- */

.disk-usage-bar {
  display: flex; height: 20px; border-radius: 999px; overflow: hidden; background: var(--surface-raised);
  border: 1px solid var(--border);
}
.disk-usage-app { background: var(--accent); }
.disk-usage-other { background: #64748b; }
.disk-legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.disk-legend-app { background: var(--accent); }
.disk-legend-other { background: #64748b; }

/* ---------- Custom scrollbar, site-wide ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- Skeleton-loading shimmer (OCR processing) ---------- */

.skeleton-loader { max-width: 100%; }
.skeleton-block { border-radius: 8px; background: var(--surface-raised); overflow: hidden; position: relative; }
.skeleton-shimmer::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  animation: skeleton-shimmer-sweep 1.4s ease-in-out infinite;
}
@keyframes skeleton-shimmer-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ---------- TRIAL: login/signup page — glassmorphism card, entrance animation ---------- */
/* The animated moving gradient background was removed entirely per feedback — it caused
   real problems beyond just the mobile lag case (see below), and wasn't worth trying to
   keep tuning. To revert what's left: change login.html/signup.html back to plain .card
   divs (drop auth-wrapper/auth-card), and delete this whole block. */

main.auth-page { position: relative; overflow: hidden; min-height: 70vh; }
.auth-wrapper {
  position: relative; z-index: 1; max-width: 360px; margin: 50px auto 0;
  animation: auth-fade-slide-in 0.5s ease-out;
}
@keyframes auth-fade-slide-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-header { text-align: center; margin-bottom: 28px; }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 14px; }
.auth-tagline { color: var(--ink-muted); font-size: 14px; font-style: italic; margin: 0 0 20px; }
.auth-card {
  background: rgba(255,255,255,0.06);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 28px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
:root[data-theme="light"] .auth-card {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

/* Mobile: the backdrop-filter itself still costs something even
   without the old moving layer behind it, so it's still swapped for a
   plain solid card below this width, matching the original mobile fix. */
@media (max-width: 768px) {
  .auth-card { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
  :root[data-theme="light"] .auth-card { background: var(--surface); }
}

/* ---------- TRIAL: password show/hide toggle ---------- */
/* To revert: remove .password-field-wrapper/.password-toggle-btn markup and delete this block. */

.password-field-wrapper { position: relative; }
.password-field-wrapper input { width: 100%; padding-right: 42px; box-sizing: border-box; }
.password-toggle-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 16px; padding: 6px; opacity: 0.6; line-height: 1;
}
.password-toggle-btn:hover { opacity: 1; }

/* ---------- Toast notifications (replacing the old static banner flash messages) ---------- */
/* Intentionally fully opaque — not glass, not transparent — per explicit request. */

.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 300;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px; width: calc(100% - 40px);
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 10px; padding: 14px 40px 14px 16px; position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35); font-size: 14px; line-height: 1.4;
  animation: toast-slide-in 0.3s ease-out;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--accent); }
.toast-close {
  position: absolute; top: 8px; right: 10px; background: none; border: none;
  color: var(--ink-muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px;
}
.toast-close:hover { color: var(--ink); }
@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-slide-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

@media (max-width: 480px) {
  .toast-container { top: 12px; right: 12px; left: 12px; max-width: none; width: auto; }
}

/* ---------- Subtle hover lift, site-wide, on buttons and cards ---------- */

.btn-primary, .btn-outline {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:hover, .btn-outline:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.btn-primary:active, .btn-outline:active { transform: translateY(0); }

.card, .subject-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.subject-card:hover, .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

/* ---------- Refined dark mode: richer glow accents, deeper contrast ---------- */
/* Dark mode gets a slightly more vivid, glowing treatment on key interactive
   elements — a plain inverted palette can feel flat; a soft glow reads as
   more considered without changing the actual accent color used everywhere. */

:root:not([data-theme="light"]) .btn-primary:hover {
  box-shadow: 0 4px 20px var(--accent-glow);
}
:root:not([data-theme="light"]) .card:hover, :root:not([data-theme="light"]) .subject-card:hover {
  box-shadow: 0 10px 26px rgba(0,0,0,0.45), 0 0 0 1px var(--accent-glow);
}
:root:not([data-theme="light"]) .streak-day.today {
  box-shadow: inset 0 0 0 2px var(--ink-muted), 0 0 12px var(--accent-glow);
}

/* ---------- Chemistry notation toolbar ---------- */

.chem-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 10px; background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: 8px 8px 0 0; border-bottom: none;
}
.chem-btn {
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 14px; cursor: pointer;
}
.chem-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Chemical sub/superscript rendering in question and option text */
sup, sub { line-height: 0; }

/* ---------- A question whose actual content is a photo, not typed text ---------- */

.question-photo-content { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; margin: 8px 0; }

/* ---------- Custom exam-date calendar picker ---------- */

.custom-date-picker { position: relative; }
.custom-date-input {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 220px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-raised); color: var(--ink); font-size: 14px; cursor: pointer;
  text-align: left;
}
.custom-date-input:hover { border-color: var(--accent); }
.custom-date-input-icon { opacity: 0.6; font-size: 14px; }

.custom-calendar-popup {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; width: 260px; box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  animation: fade-in-up 0.15s ease-out;
}
.custom-calendar-popup.open { display: block; }

.calendar-popup-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-weight: 600; font-size: 14px; }
.calendar-nav-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-raised); color: var(--ink); cursor: pointer; font-size: 15px; line-height: 1;
}
.calendar-nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.calendar-popup-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px;
  font-size: 10px; text-transform: uppercase; color: var(--ink-muted); text-align: center;
}
.calendar-popup-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-day-cell {
  aspect-ratio: 1; border: none; background: none; border-radius: 6px; color: var(--ink);
  font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.calendar-day-blank { cursor: default; }
.calendar-day-cell:not(.calendar-day-blank):hover { background: var(--surface-raised); }
.calendar-day-today { box-shadow: 0 0 0 1px var(--ink-muted) inset; font-weight: 700; }
.calendar-day-selected { background: var(--accent); color: #06251f; font-weight: 700; }

/* ---------- Custom file-upload buttons (replacing the default browser style) ---------- */

.file-upload-input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.file-upload-wrapper { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; position: relative; }
.file-upload-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-raised); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease;
}
.file-upload-btn:hover { border-color: var(--accent); color: var(--accent); }
.file-upload-input:focus-visible + .file-upload-btn { box-shadow: 0 0 0 3px var(--accent-glow); }
.file-upload-filename { font-size: 13px; color: var(--ink-muted); }

/* ---------- Fix: a popup inside a .card was getting clipped by the card's own overflow:hidden ---------- */
/* .card clips its contents to its rounded corners by design (useful for photos, etc.) — but that
   same clipping was cutting off the exam-date calendar popup the moment it extended past the
   card's own edge, regardless of its z-index. Explicit override for that one card, plus a
   :has()-based catch-all so any future popup-in-a-card doesn't quietly hit the same bug. */
.card-allow-overflow { overflow: visible; }
.card:has(.custom-date-picker, .custom-calendar-popup) { overflow: visible; }

/* ---------- Calculation-type answer builder ---------- */

.calc-option-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.calc-option-row input[type="text"] { flex: 1; }
.calc-option-badge {
  flex-shrink: 0; width: 64px; text-align: center; padding: 6px 0; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
}
.calc-option-badge-correct { background: rgba(34,197,94,0.15); color: var(--success); }
.calc-option-badge-wrong { background: rgba(240,101,74,0.15); color: var(--danger); }
.calc-remove-btn {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-raised); color: var(--ink-muted); font-size: 16px; cursor: pointer; line-height: 1;
}
.calc-remove-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- Periodic table overlay ---------- */
/* Slide-up overlay (same "display:none -> flex triggers a CSS animation"
   technique as the settings modal). The detail popup is a single shared
   element positioned by JS with getBoundingClientRect + position:fixed —
   deliberately NOT nested inside .pt-grid-scroll, since that container
   needs its own horizontal overflow:auto for the wide grid, and nesting
   the popup inside it would risk the exact clipping bug found and fixed
   earlier for the exam-date calendar (an overflow:hidden/auto ancestor
   cutting off anything that tries to extend past its own edge). */

.pt-overlay {
  display: none; position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.55); align-items: flex-end; justify-content: center;
}
.pt-overlay.open { display: flex; }
.pt-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px 16px 0 0;
  padding: 18px; max-width: 960px; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.45);
  animation: pt-slide-up 0.2s ease-out;
}
@keyframes pt-slide-up {
  from { transform: translateY(50px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.pt-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.pt-panel-header h2 { margin: 0; font-size: 18px; }

.pt-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 14px; font-size: 11px; color: var(--ink-muted); }
.pt-legend-item { display: flex; align-items: center; gap: 5px; }
.pt-legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.pt-grid-scroll { overflow-x: auto; padding-bottom: 6px; }
.pt-grid { display: grid; grid-template-columns: repeat(18, 42px); grid-auto-rows: 42px; gap: 2px; min-width: 780px; }
.pt-fblock { display: grid; grid-template-columns: repeat(15, 42px); grid-auto-rows: 42px; gap: 2px; margin-top: 10px; min-width: 654px; }

.pt-el {
  width: 100%; height: 100%; border-radius: 4px; border: 1px solid rgba(0,0,0,0.2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; position: relative;
}
.pt-el:hover, .pt-el.pt-active { transform: scale(1.35); z-index: 25; box-shadow: 0 8px 24px rgba(0,0,0,0.45); }
.pt-el-number { font-size: 7px; align-self: flex-start; margin: 1px 0 0 3px; opacity: 0.75; }
.pt-el-symbol { font-size: 14px; font-weight: 700; line-height: 1.1; }
.pt-el-name { font-size: 6px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 92%; }

/* Category colors -- chosen for reasonable contrast in both themes; kept
   distinct from the site's own single-accent palette on purpose, since a
   periodic table without color-coded categories loses most of its value
   as a reference. */
.pt-cat-vodik { background: #8b7fd6; color: #fff; }
.pt-cat-alkalicky-kov { background: #f0655a; color: #fff; }
.pt-cat-kov-alkalickych-zemin { background: #4caf6e; color: #062015; }
.pt-cat-skore-prechodny-kov { background: #f2a9a0; color: #4a1810; }
.pt-cat-neskore-prechodny-kov { background: #f6cfc9; color: #4a1810; }
.pt-cat-triel { background: #9fb3e8; color: #0d1a3a; }
.pt-cat-tetragen { background: #b7e8c4; color: #0d2b17; }
.pt-cat-pniktogen { background: #f3d9a6; color: #4a3410; }
.pt-cat-chalkogen { background: #f7f0a8; color: #4a4410; }
.pt-cat-halogen { background: #f0a75c; color: #3a1f00; }
.pt-cat-vzacny-plyn { background: #a6e6ec; color: #06282b; }
.pt-cat-lantanoid { background: #eeb4e8; color: #3a0f36; }
.pt-cat-aktinoid { background: #dd7fce; color: #350a2f; }

/* Shared detail popup -- positioned in JS, not CSS, so it always renders
   relative to the viewport regardless of where inside the (scrollable)
   grid the triggering cell sits. */
.pt-popup {
  display: none; position: fixed; z-index: 160; width: 220px;
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; box-shadow: 0 12px 32px rgba(0,0,0,0.45); font-size: 12px; text-align: left;
  overflow-y: auto;
}
.pt-popup.open { display: block; }
.pt-popup-symbol { font-size: 30px; font-weight: 700; line-height: 1; }
.pt-popup-name { font-size: 14px; color: var(--ink-muted); margin-bottom: 10px; }
.pt-popup dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 11px; }
.pt-popup dt { color: var(--ink-muted); }
.pt-popup dd { margin: 0; text-align: right; font-weight: 600; }

/* Compact, text-scale trigger button placed under "Flag for review" */
.pt-trigger-btn {
  background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 600;
  cursor: pointer; padding: 2px 0; display: inline-flex; align-items: center; gap: 4px;
}
.pt-trigger-btn:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .pt-grid { grid-template-columns: repeat(18, 34px); grid-auto-rows: 34px; }
  .pt-fblock { grid-template-columns: repeat(15, 34px); grid-auto-rows: 34px; }
}
