@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&display=swap');

:root {
  --quiz-font-scale: 1;

  --page-bg: #f5f6f8;
  --page-bg-alt: #eef1f5;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-muted: #f7f8fb;
  --surface-hover: #f1f6ff;

  --text-primary: #17191d;
  --text-secondary: #5f6672;
  --text-muted: #858d99;

  --border-subtle: #d9dee7;
  --border-strong: #b8c0cc;
  --accent: #2563eb;
  --accent-soft: #eef5ff;
  --accent-border: #3b82f6;
  --success: #22a66a;
  --warning: #d59a00;
  --danger: #df5967;
  --danger-soft: #fff0f2;
  --focus-ring: rgba(37, 99, 235, 0.22);

  --shadow-card: 0 14px 34px rgba(28, 36, 50, 0.09);
  --shadow-control: 0 5px 14px rgba(28, 36, 50, 0.07);
  --shadow-popover: 0 16px 36px rgba(28, 36, 50, 0.16);
  --shadow-dialog: 0 26px 70px rgba(28, 36, 50, 0.2);
  --control-hover-shadow: rgba(37, 99, 235, 0.12);
  --inner-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --overlay-bg: rgba(245, 247, 250, 0.86);

  /* Legacy variables retained for existing markup and inline styles. */
  --bg-white: var(--text-primary);
  --bg-black: var(--surface);
  --hover-gray: #edf1f6;
}

.dark-mode {
  --page-bg: #08090b;
  --page-bg-alt: #0d0f12;
  --surface: #14161a;
  --surface-elevated: #191c21;
  --surface-muted: #101216;
  --surface-hover: #1d2127;

  --text-primary: #f4f6f8;
  --text-secondary: #b5bbc4;
  --text-muted: #818892;

  --border-subtle: #34383f;
  --border-strong: #555b64;
  --accent: #f7f8fa;
  --accent-soft: #1b1e23;
  --accent-border: #f2f4f7;
  --success: #58c987;
  --warning: #efbd3f;
  --danger: #f1727e;
  --danger-soft: rgba(241, 114, 126, 0.11);
  --focus-ring: rgba(255, 255, 255, 0.18);

  --shadow-card: 0 18px 42px rgba(0, 0, 0, 0.36);
  --shadow-control: 0 7px 18px rgba(0, 0, 0, 0.24);
  --shadow-popover: 0 18px 42px rgba(0, 0, 0, 0.48);
  --shadow-dialog: 0 28px 76px rgba(0, 0, 0, 0.58);
  --control-hover-shadow: rgba(255, 255, 255, 0.08);
  --inner-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.055);
  --overlay-bg: rgba(4, 5, 7, 0.84);

  /* Legacy variables retained for existing markup and inline styles. */
  --bg-white: var(--text-primary);
  --bg-black: var(--surface);
  --hover-gray: #22262c;
}

body {
  font-family: 'IBM Plex Mono', monospace !important;
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
  padding: 12px;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  box-sizing: border-box;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  zoom: 90%;
  overflow-x: hidden;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.app-workspace {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 850px;
  width: 100%;
  justify-content: center;
  padding-bottom: 20px;
  align-items: stretch;
}

.dashboard-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
  box-sizing: border-box;
}
.greeting-container {
  min-width: 0;
  margin: 0;
  width: auto;
  text-align: left;
  color: var(--bg-black) !important;
}

.dashboard-header-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  width: auto;
  min-height: 38px;
  box-sizing: border-box;
}
.outside-control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
  border: 1px solid var(--bg-black) !important;
  font-family: 'IBM Plex Mono', monospace !important;
  cursor: pointer;
  flex: 0 0 38px;
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.2s;
}
.outside-control-btn:hover {
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  transform: translateY(-1px);
}
.outside-control-btn:active {
  transform: translateY(0);
}
.subject-insights-control,
.theme-control {
  width: 38px;
  height: 38px;
  border-radius: 50%;
}
.outside-control-btn svg {
  width: 19px;
  height: 19px;
  display: block;
  flex-shrink: 0;
}

.game-container {
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  padding: 18px 22px;
  border-radius: 16px;
  position: relative;
  border: 1px solid var(--bg-black);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.header-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--bg-white);
  padding-bottom: 12px;
  margin-bottom: 16px;
  gap: 10px;
}
.mode-badge {
  color: var(--bg-white) !important;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 55%;
}
.stats-group {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}
.score-box {
  font-weight: 600;
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  white-space: nowrap;
}
.timer-box {
  font-weight: 600;
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  min-width: 55px;
  text-align: center;
  white-space: nowrap;
}
.timer-box.study-mode {
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
}
.timer-box.flashcard-mode {
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
}
.timer-box.urgent {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
  border-color: var(--bg-black) !important;
  animation: pulse 1s infinite;
}

.question-title {
  font-size: 19px;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 16px;
  word-break: break-word;
  text-align: justify;
  color: var(--bg-white) !important;
}
.question-title span {
  font-weight: 800;
  color: var(--bg-white) !important;
  margin-right: 8px;
}
.choices-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.choice-btn {
  display: flex;
  align-items: center;
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 12px;
  padding: 12px 16px;
  text-align: left;
  font-size: 15px;
  color: var(--bg-white) !important;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  font-family: 'IBM Plex Mono', monospace !important;
}
.choice-btn:hover:not([disabled]) {
  background: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
  color: var(--bg-black) !important;
}
.choice-btn.correct {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: #10b981 !important;
  color: #34d399 !important;
  font-weight: 600;
}
.choice-btn.wrong {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
  color: #f87171 !important;
  animation: shake 0.4s linear;
}
.choice-letter {
  font-weight: 700;
  margin-right: 14px;
  color: inherit;
  text-transform: uppercase;
  flex-shrink: 0;
}

.action-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 16px;
  border-top: 1px solid var(--bg-white);
  padding-top: 16px;
  gap: 12px;
}
.next-btn {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 14px 28px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: none;
  text-align: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace !important;
}
.next-btn:hover {
  background: var(--hover-gray) !important;
}

.subject-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}
.subj-card {
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 12px 16px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  gap: 10px;
  position: relative;
  color: var(--bg-white) !important;
}
.subj-card:hover {
  background: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
  color: var(--bg-black) !important;
}
.subj-card:hover * {
  color: var(--bg-black) !important;
}
.subj-card .card-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
  width: calc(100% - 32px);
  overflow: hidden;
  gap: 10px;
}
.subj-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subj-remove-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  color: var(--bg-white) !important;
  font-size: 18px;
  font-family: 'IBM Plex Mono', monospace !important;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  line-height: 1;
  z-index: 2;
  padding: 0;
}
.subj-remove-btn::before {
  content: '\00d7';
  transform: translateY(-1px);
}
.subj-remove-btn:hover {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
  border-color: var(--bg-white) !important;
  transform: scale(1.08);
}

.ultimate-btn {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 14px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 16px;
  transition: transform 0.2s;
  font-family: 'IBM Plex Mono', monospace !important;
}
.ultimate-btn:hover {
  background: var(--hover-gray) !important;
}

.file-upload-box {
  border: 2px dashed var(--bg-white) !important;
  min-height: 120px;
  padding: 16px 20px;
  text-align: center;
  border-radius: 14px;
  margin-bottom: 16px;
  cursor: pointer;
  background: var(--bg-black) !important;
  margin-top: 0px;
  transition:
    background 0.2s,
    border-color 0.2s,
    transform 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  color: var(--bg-white) !important;
}
.file-upload-box:hover {
  background: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
  color: var(--bg-black) !important;
}
.file-upload-box:hover * {
  color: var(--bg-black) !important;
}
.upload-icon {
  width: 44px;
  height: 44px;
  color: inherit;
  opacity: 0.9;
  margin-bottom: 8px;
}
.upload-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  stroke: currentColor;
}
.upload-primary {
  margin: 0;
  color: inherit;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
}
.upload-primary strong {
  color: inherit;
  font-weight: 800;
}
.upload-secondary {
  margin: 2px 0 0;
  color: inherit;
  font-size: 15px;
  font-weight: 500;
}

.dashboard-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
  width: 100%;
}
.import-subject-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-shrink: 0;
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 9px;
  padding: 8px 11px;
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
}
.import-subject-btn:hover {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
}
.import-subject-btn svg {
  width: 17px;
  height: 17px;
  display: block;
  stroke: currentColor;
}


.mode-button-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  margin-bottom: 16px;
  position: relative;
}
.mode-btn {
  padding: 12px 8px;
  min-height: 68px;
  font-weight: 700;
  border-radius: 12px;
  border: 2px solid var(--bg-white) !important;
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  box-shadow: none !important;
  font-family: 'IBM Plex Mono', monospace !important;
}
.mode-btn:hover {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
  transform: translateY(-1px);
}
.mode-btn:hover * {
  color: var(--bg-black) !important;
}
.mode-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: center;
  width: 100%;
}
.mode-title {
  font-size: 16px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.mode-subtitle {
  color: inherit;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 500;
}

.mode-btn.active-study,
.mode-btn.active-exam,
.mode-btn.active-flashcards {
  background: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
  color: var(--bg-black) !important;
  box-shadow: none !important;
}
.mode-btn.active-study *,
.mode-btn.active-exam *,
.mode-btn.active-flashcards * {
  color: var(--bg-black) !important;
}

/* --- OPTIONS POP LAYOUT (FLOATING) --- */
.exam-pop-container {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 0;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: popDown 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.exam-pop-lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--bg-white) !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.exam-pop-options {
  display: flex;
  gap: 8px;
  justify-content: center;
  width: 100%;
}
.exam-pop-opt-btn {
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--bg-white) !important;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
  max-width: 120px;
  text-align: center;
  font-family: 'IBM Plex Mono', monospace !important;
}
.exam-pop-opt-btn:hover {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
}
.exam-pop-opt-btn.active {
  background: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
  color: var(--bg-black) !important;
}

/* STUDY POP VARIANT */
.study-pop-container {
  background: var(--bg-black) !important;
  border-color: var(--bg-white) !important;
}
.study-pop-lbl {
  color: var(--bg-white) !important;
}
.study-pop-opt-btn.active {
  background: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
  color: var(--bg-black) !important;
}

/* --- REVIEWER SCROLL SYSTEM --- */
.reviewer-scroll-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 6px;
  margin: 16px 0;
  border-bottom: 1px solid var(--bg-white);
}
.reviewer-scroll-view::-webkit-scrollbar {
  width: 6px;
}
.reviewer-scroll-view::-webkit-scrollbar-track {
  background: transparent;
}
.reviewer-scroll-view::-webkit-scrollbar-thumb {
  background: var(--bg-white);
  border-radius: 10px;
}
.reviewer-item {
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 12px;
  padding: 16px;
  text-align: justify;
  color: var(--bg-white) !important;
}
.reviewer-ans-box {
  font-size: 15px;
  font-weight: 600;
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 10px;
  word-break: break-word;
}

/* --- FLASHCARDS STRUCTURAL STYLES --- */
.flashcard-options-strip {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.flashcard-opt-btn {
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 8px 16px;
  border-radius: 8px;
  color: var(--bg-white) !important;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'IBM Plex Mono', monospace !important;
}
.flashcard-opt-btn:hover {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
}
.flashcard-opt-btn.active {
  background: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
  color: var(--bg-black) !important;
}

.flashcard-stage {
  perspective: 1000px;
  width: 100%;
  min-height: 240px;
  margin: 16px 0;
  display: flex;
  justify-content: center;
}
.flashcard-card {
  width: 100%;
  max-width: 500px;
  min-height: 240px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.flashcard-card.flipped {
  transform: rotateY(180deg);
}
.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 16px;
  border: 1px solid var(--bg-white) !important;
  padding: 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}
.flashcard-front {
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
}
.flashcard-back {
  background: var(--bg-black) !important;
  border-color: var(--bg-white) !important;
  color: var(--bg-white) !important;
  transform: rotateY(180deg);
}
.flashcard-face-lbl {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--bg-white) !important;
  position: absolute;
  top: 12px;
}
.flashcard-face-content {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.5;
  word-break: break-word;
  color: var(--bg-white) !important;
}
.flashcard-hint-tap {
  font-size: 12px;
  color: var(--bg-white) !important;
  margin-top: 16px;
  opacity: 0.6;
  font-style: italic;
  position: absolute;
  bottom: 12px;
}

.active-recall-input-container {
  width: 100%;
  max-width: 500px;
  margin: 16px auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.active-recall-input {
  width: 100%;
  background: var(--bg-black) !important;
  border: 2px solid var(--bg-white) !important;
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--bg-white) !important;
  font-size: 16px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
  font-family: 'IBM Plex Mono', monospace !important;
}
.active-recall-input:focus {
  border-color: var(--bg-white) !important;
}
.active-recall-feedback {
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  display: none;
  text-align: left;
}
.active-recall-feedback.correct {
  background: rgba(16, 185, 129, 0.2) !important;
  border: 1px solid #10b981 !important;
  color: #34d399 !important;
}
.active-recall-feedback.incorrect {
  background: rgba(239, 68, 68, 0.2) !important;
  border: 1px solid #ef4444 !important;
  color: #f87171 !important;
}

/* --- INSIGHTS STYLING --- */
.insights-btn {
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--bg-white) !important;
  z-index: 10;
  padding: 0;
  flex-shrink: 0;
}
.insights-btn:hover {
  background: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
  transform: scale(1.05);
  color: var(--bg-black) !important;
}

.insight-set-group {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.insight-set-title {
  color: var(--bg-white) !important;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0 12px 0;
  border-bottom: 1px solid var(--bg-white) !important;
  padding-bottom: 6px;
  width: 100%;
  text-align: center;
}

.insight-table-header {
  display: flex;
  width: 100%;
  padding: 8px 16px;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 800;
  color: var(--bg-white) !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--bg-white) !important;
  margin-bottom: 8px;
}
.insight-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-bottom: 6px;
  width: 100%;
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 10px;
  padding: 10px 16px;
  box-sizing: border-box;
  gap: 8px;
  color: var(--bg-white) !important;
}
.insight-col-subj {
  flex: 2;
  min-width: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--bg-white) !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.insight-col-stat {
  flex: 0.55;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--bg-white) !important;
  white-space: nowrap;
}

/* --- FIRST-TIME WELCOME EXPERIENCE --- */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  background: var(--overlay-bg) !important;
  animation: welcomeFadeIn 0.24s ease both;
}
.welcome-overlay.is-closing {
  animation: welcomeFadeOut 0.18s ease both;
  pointer-events: none;
}
.welcome-dialog {
  width: min(100%, 520px);
  box-sizing: border-box;
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
  animation: welcomeRise 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.welcome-eyebrow {
  margin-bottom: 10px;
  color: var(--bg-white) !important;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.7;
}
.welcome-title {
  margin: 0;
  color: var(--bg-white) !important;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.4px;
}
.welcome-description,
.welcome-instruction {
  color: var(--bg-white) !important;
  font-size: 14px;
  line-height: 1.65;
}
.welcome-description {
  margin: 16px 0 0;
  opacity: 0.86;
}
.welcome-instruction {
  margin: 16px 0 22px;
  font-weight: 600;
}
.welcome-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.welcome-label {
  color: var(--bg-white) !important;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.welcome-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 10px;
  padding: 13px 14px;
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 15px;
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s,
    transform 0.2s;
}
.welcome-input::placeholder {
  color: var(--bg-white);
  opacity: 0.5;
}
.welcome-input:focus {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
}
.welcome-input.has-error {
  border-color: #f87171 !important;
}
.welcome-error {
  min-height: 18px;
  color: #f87171 !important;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
}
.welcome-continue-btn {
  width: 100%;
  margin-top: 3px;
  padding: 13px 18px;
  border: 1px solid var(--bg-white) !important;
  border-radius: 10px;
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s,
    transform 0.2s;
}
.welcome-continue-btn:hover {
  background: var(--hover-gray) !important;
  transform: translateY(-1px);
}
.welcome-continue-btn:active {
  transform: translateY(0);
}

.confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-bg) !important;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}
.confirm-box {
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 24px;
  border-radius: 16px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  color: var(--bg-white) !important;
}
.confirm-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--bg-white) !important;
}
.confirm-desc {
  font-size: 14px;
  color: var(--bg-white) !important;
  margin-bottom: 20px;
  line-height: 1.4;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.confirm-btn {
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 14px;
  flex: 1;
  transition: opacity 0.2s;
  font-family: 'IBM Plex Mono', monospace !important;
}
.confirm-btn:hover {
  opacity: 0.85;
}
.btn-cancel {
  background: var(--bg-black) !important;
  color: var(--bg-white) !important;
  border: 1px solid var(--bg-white) !important;
}
.btn-danger {
  background: var(--bg-white) !important;
  color: var(--bg-black) !important;
  border: 1px solid var(--bg-black) !important;
}

/* --- SPLIT / DETACHED TOOLS PANEL --- */
.dashboard-tools-row {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 850px;
  box-sizing: border-box;
  align-items: center;
  margin-top: 12px;
}

.matrix-tabs-container {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--bg-white) !important;
  padding-bottom: 0;
  gap: 0;
  margin-top: 4px;
  justify-content: center;
}
.matrix-tab {
  background: transparent !important;
  border: none !important;
  color: var(--bg-white) !important;
  font-size: 18px;
  font-weight: 700;
  padding: 14px 8px 12px;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  position: relative;
  transition: color 0.2s;
  text-align: center;
  min-width: 0;
  line-height: 1.3;
  font-family: 'IBM Plex Mono', monospace !important;
}
.matrix-tab:hover {
  color: var(--bg-white) !important;
  opacity: 0.8;
}
.matrix-tab.active {
  color: var(--bg-white) !important;
  font-weight: 800;
}
.matrix-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--bg-white) !important;
  border-radius: 999px;
  box-shadow: none;
}

.empty-state {
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--bg-white) !important;
  text-align: center;
  padding: 16px 12px;
  box-sizing: border-box;
}
.empty-state-icon {
  width: 44px;
  height: 44px;
  color: var(--bg-white) !important;
  opacity: 0.82;
}
.empty-state-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  stroke: currentColor;
}
.empty-state-text {
  margin: 0;
  color: var(--bg-white) !important;
  font-style: normal;
  font-size: 16px;
  font-weight: 500;
}

/* --- DETACHED CENTRED SEAMLESS COUNTDOWN --- */
.board-countdown-container {
  width: 100%;
  max-width: 500px;
  padding: 12px 20px;
  box-sizing: border-box;
  text-align: center;
  border: none;
  background: transparent;
  box-shadow: none;
  margin: 4px auto;
  color: var(--bg-black) !important;
}
.countdown-title {
  font-size: 15px;
  letter-spacing: 0.5px;
  color: var(--bg-black) !important;
  font-weight: 700;
  margin-bottom: 2px;
  text-transform: uppercase;
}
.countdown-subtitle {
  font-size: 12px;
  color: var(--bg-black) !important;
  font-weight: 600;
  margin-bottom: 12px;
}
.countdown-ticker {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-variant-numeric: tabular-nums;
}
.ticker-segment {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
}
.ticker-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--bg-black) !important;
}
.ticker-lbl {
  font-size: 10px;
  color: var(--bg-black) !important;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 2px;
}

/* --- QUICK INSIGHTS CARD STYLING --- */
.quick-insights-card {
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 14px;
  padding: 22px 20px;
  text-align: left;
  color: var(--bg-white) !important;
  width: 100%;
  box-sizing: border-box;
}
.quick-insights-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--bg-white) !important;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  margin-bottom: 24px;
  padding-bottom: 0;
  border-bottom: none;
}
.quick-insights-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  text-align: center;
}
.quick-insights-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  padding: 0 10px;
  min-width: 0;
  box-sizing: border-box;
}
.quick-insights-col:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 15%;
  height: 70%;
  width: 1px;
  background: currentColor;
  opacity: 0.25;
}
.quick-insights-count {
  font-size: calc(34px * var(--quiz-font-scale));
  font-weight: 800;
  color: var(--bg-white) !important;
  text-align: center;
  line-height: 1;
}
.quick-insights-label-row {
  display: flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
  margin-top: 8px;
  color: var(--bg-white) !important;
}
.quick-insights-icon {
  width: 17px;
  height: 17px;
  display: inline-flex;
  flex-shrink: 0;
}
.quick-insights-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.quick-insights-label {
  font-size: calc(13px * var(--quiz-font-scale));
  font-weight: 700;
  color: var(--bg-white) !important;
}
.quick-insights-range {
  margin-top: 2px;
  font-size: calc(10px * var(--quiz-font-scale));
  font-weight: 500;
  color: var(--bg-white) !important;
  opacity: 0.72;
  line-height: 1.3;
}


.back-dash-btn {
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  color: var(--bg-white) !important;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  font-family: 'IBM Plex Mono', monospace !important;
}
.back-dash-btn::before {
  content: '\2190';
  font-family: 'IBM Plex Mono', monospace !important;
  font-weight: 800;
  line-height: 1;
}
.back-dash-btn:hover {
  background: var(--bg-white) !important;
  border-color: var(--bg-white) !important;
  color: var(--bg-black) !important;
}

.analytics-card {
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  border-radius: 14px;
  padding: 22px 20px;
  margin-top: 24px;
  text-align: left;
  color: var(--bg-white) !important;
}
.analytics-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--bg-white) !important;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--bg-white) !important;
  padding-bottom: 10px;
}
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid var(--bg-white) !important;
  gap: 20px;
}
.metric-row:last-child {
  border-bottom: none;
}
.sub-tag {
  font-weight: 600;
  font-size: 14px;
  color: var(--bg-white) !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.stat-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.stat-good {
  font-size: 12px;
  font-weight: 700;
  color: var(--bg-white) !important;
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.stat-bad {
  font-size: 12px;
  font-weight: 700;
  color: var(--bg-white) !important;
  background: var(--bg-black) !important;
  border: 1px solid var(--bg-white) !important;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

body {
  font-size: calc(16px * var(--quiz-font-scale));
}
.mode-badge {
  font-size: calc(12px * var(--quiz-font-scale));
}
.score-box,
.timer-box,
.back-dash-btn,
.analytics-title,
.quick-insights-title {
  font-size: calc(13px * var(--quiz-font-scale));
}
.question-title {
  font-size: calc(19px * var(--quiz-font-scale));
}
.choice-btn,
.next-btn,
.portal-btn,
.insight-col-subj {
  font-size: calc(15px * var(--quiz-font-scale));
}
.sub-tag {
  font-size: calc(14px * var(--quiz-font-scale));
}
.subj-remove-btn::before {
  font-size: calc(18px * var(--quiz-font-scale));
}
.ultimate-btn {
  font-size: calc(16px * var(--quiz-font-scale));
}
.matrix-tab,
.upload-secondary,
.empty-state-text {
  font-size: calc(18px * var(--quiz-font-scale));
}
.upload-primary {
  font-size: calc(18px * var(--quiz-font-scale));
}
.mode-title {
  font-size: calc(16px * var(--quiz-font-scale));
}
.mode-subtitle {
  font-size: calc(12px * var(--quiz-font-scale));
}
.ticker-lbl {
  font-size: calc(10px * var(--quiz-font-scale));
}
.countdown-subtitle {
  font-size: calc(13px * var(--quiz-font-scale));
}
.countdown-title {
  font-size: calc(17px * var(--quiz-font-scale));
}
.ticker-value {
  font-size: calc(28px * var(--quiz-font-scale));
}
.portal-title {
  font-size: calc(24px * var(--quiz-font-scale));
}
.stat-good,
.stat-bad,
.insight-col-stat {
  font-size: calc(12px * var(--quiz-font-scale));
}

@keyframes welcomeFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes welcomeFadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes welcomeRise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes popDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 480px) {
  .next-btn {
    width: auto;
  }
}
@media (max-width: 760px) {
  .welcome-overlay {
    padding: 14px;
  }
  .welcome-dialog {
    padding: 24px 20px;
    border-radius: 15px;
  }
  .welcome-title {
    font-size: calc(21px * var(--quiz-font-scale));
  }
  .welcome-description,
  .welcome-instruction {
    font-size: calc(13px * var(--quiz-font-scale));
  }

  .mode-button-group {
    gap: 6px;
    margin-bottom: 12px;
  }
  .mode-btn {
    min-height: 58px;
    padding: 6px 4px;
    gap: 4px;
    border-radius: 10px;
  }
  .mode-title {
    font-size: calc(11px * var(--quiz-font-scale));
  }
  .mode-subtitle {
    font-size: calc(9px * var(--quiz-font-scale));
  }
  .file-upload-box {
    min-height: 94px;
    padding: 14px 12px;
    margin-bottom: 14px;
    border-radius: 10px;
  }
  .upload-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
  }
  .upload-primary {
    font-size: calc(14px * var(--quiz-font-scale));
  }
  .upload-secondary {
    font-size: calc(13px * var(--quiz-font-scale));
  }
  .matrix-tab {
    font-size: calc(11px * var(--quiz-font-scale));
    padding: 10px 4px 8px;
  }
  .subject-grid {
    margin-top: 14px;
    gap: 6px;
  }
  .empty-state {
    min-height: 76px;
    gap: 8px;
    padding: 12px 6px;
  }
  .empty-state-icon {
    width: 34px;
    height: 34px;
  }
  .empty-state-text {
    font-size: calc(13px * var(--quiz-font-scale));
  }
  .dashboard-tools-row {
    gap: 8px;
  }
  .dashboard-title-row {
    gap: 8px;
  }
  .dashboard-title-row h2 {
    font-size: calc(17px * var(--quiz-font-scale)) !important;
  }
  .import-subject-btn {
    padding: 7px 9px;
    font-size: calc(10px * var(--quiz-font-scale));
  }
  .quick-insights-card {
    padding: 18px 10px;
  }
  .quick-insights-col {
    padding: 0 6px;
  }
  .quick-insights-label-row {
    gap: 4px;
  }
  .quick-insights-icon {
    width: 14px;
    height: 14px;
  }
  .quick-insights-label {
    font-size: calc(10px * var(--quiz-font-scale));
  }
  .quick-insights-range {
    font-size: calc(8px * var(--quiz-font-scale));
  }
  .board-countdown-container {
    padding: 8px 10px;
  }
  .countdown-title {
    font-size: calc(13px * var(--quiz-font-scale));
    line-height: 1.15;
  }
  .countdown-subtitle {
    font-size: calc(10px * var(--quiz-font-scale));
    margin-bottom: 12px;
  }
  .ticker-value {
    font-size: calc(20px * var(--quiz-font-scale));
  }
  .ticker-lbl {
    font-size: calc(7px * var(--quiz-font-scale));
    margin-top: 4px;
  }
}
@media (max-width: 380px) {
  body {
    padding-left: 8px;
    padding-right: 8px;
  }
  .mode-button-group {
    gap: 4px;
  }
  .mode-btn {
    min-height: 54px;
    padding: 6px 4px;
    gap: 2px;
  }
  .matrix-tab {
    font-size: calc(10px * var(--quiz-font-scale));
  }
  .dashboard-tools-row {
    gap: 6px;
  }
  .dashboard-title-row h2 {
    font-size: calc(13px * var(--quiz-font-scale)) !important;
  }
  .import-subject-btn {
    padding: 6px 7px;
    font-size: calc(8px * var(--quiz-font-scale));
    gap: 4px;
    white-space: nowrap;
  }
  .import-subject-btn svg {
    width: 14px;
    height: 14px;
  }
  .dashboard-topbar {
    gap: 8px;
  }
  .greeting-container > div:first-child {
    font-size: calc(11px * var(--quiz-font-scale)) !important;
  }
  .greeting-container > div:last-child {
    font-size: calc(16px * var(--quiz-font-scale)) !important;
  }
  .ticker-value {
    font-size: calc(18px * var(--quiz-font-scale));
  }
}
@keyframes pulse {
  50% {
    transform: scale(1.04);
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}

/* --- REFINED LIGHT / DARK THEME (VISUAL-ONLY OVERRIDES) --- */
html {
  background: var(--page-bg);
  color-scheme: light;
}
html.dark-mode {
  color-scheme: dark;
}

body {
  background:
    radial-gradient(circle at 14% -10%, rgba(37, 99, 235, 0.055), transparent 34%),
    linear-gradient(180deg, var(--page-bg-alt) 0%, var(--page-bg) 44%, var(--page-bg) 100%) !important;
  color: var(--text-primary) !important;
}
.dark-mode body {
  background:
    radial-gradient(circle at 16% -10%, rgba(255, 255, 255, 0.038), transparent 34%),
    linear-gradient(180deg, var(--page-bg-alt) 0%, var(--page-bg) 46%, var(--page-bg) 100%) !important;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-border);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px var(--focus-ring);
}
button:disabled,
.choice-btn[disabled],
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  box-shadow: none !important;
}

.greeting-container,
.greeting-container * {
  color: var(--text-primary) !important;
}
.greeting-container > div:first-child {
  color: var(--text-secondary) !important;
}

.game-container,
.quick-insights-card,
.analytics-card {
  background: linear-gradient(180deg, var(--surface-elevated), var(--surface)) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--shadow-card), var(--inner-highlight) !important;
}
.board-countdown-container {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.outside-control-btn {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--shadow-control), var(--inner-highlight);
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s,
    box-shadow 0.2s,
    transform 0.2s;
}
.outside-control-btn:hover {
  background: var(--surface-hover) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 7px 18px var(--control-hover-shadow), var(--inner-highlight);
}
.outside-control-btn:active {
  background: var(--surface-muted) !important;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.14);
}

.dashboard-title-row h2,
.header-panel,
.mode-badge,
.question-title,
.question-title span,
.quick-insights-title,
.analytics-title,
.confirm-title,
.welcome-title {
  color: var(--text-primary) !important;
}

.import-subject-btn,
.back-dash-btn {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
  box-shadow: var(--shadow-control), var(--inner-highlight);
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s,
    box-shadow 0.2s,
    transform 0.2s;
}
.import-subject-btn:hover,
.back-dash-btn:hover {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 7px 18px var(--control-hover-shadow), var(--inner-highlight);
}
.import-subject-btn:active,
.back-dash-btn:active {
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.14);
}

.mode-btn {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--inner-highlight) !important;
}
.mode-btn .mode-title {
  color: var(--text-primary) !important;
}
.mode-btn .mode-subtitle {
  color: var(--text-secondary) !important;
}
.mode-btn:hover,
.mode-btn:hover * {
  background: var(--surface-hover) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
}
.mode-btn:hover {
  box-shadow: var(--shadow-control), var(--inner-highlight) !important;
}
html:not(.dark-mode) .mode-btn.active-study,
html:not(.dark-mode) .mode-btn.active-exam,
html:not(.dark-mode) .mode-btn.active-flashcards {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
  box-shadow:
    0 0 0 1px rgba(37, 99, 235, 0.08),
    0 8px 20px rgba(37, 99, 235, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.92) !important;
}
html:not(.dark-mode) .mode-btn.active-study *,
html:not(.dark-mode) .mode-btn.active-exam *,
html:not(.dark-mode) .mode-btn.active-flashcards * {
  background: transparent !important;
  color: var(--accent) !important;
}
.dark-mode .mode-btn.active-study,
.dark-mode .mode-btn.active-exam,
.dark-mode .mode-btn.active-flashcards {
  background: var(--surface-elevated) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-border) !important;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.09),
    0 0 18px rgba(255, 255, 255, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.11) !important;
}
.dark-mode .mode-btn.active-study *,
.dark-mode .mode-btn.active-exam *,
.dark-mode .mode-btn.active-flashcards * {
  background: transparent !important;
  color: var(--text-primary) !important;
}

.exam-pop-container {
  background: var(--surface-elevated) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--shadow-popover), var(--inner-highlight);
}
.exam-pop-lbl,
.study-pop-lbl {
  color: var(--text-secondary) !important;
}
.exam-pop-opt-btn,
.flashcard-opt-btn {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--inner-highlight);
}
.exam-pop-opt-btn:hover,
.flashcard-opt-btn:hover {
  background: var(--surface-hover) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
}
html:not(.dark-mode) .exam-pop-opt-btn.active,
html:not(.dark-mode) .study-pop-opt-btn.active,
html:not(.dark-mode) .flashcard-opt-btn.active {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.08);
}
.dark-mode .exam-pop-opt-btn.active,
.dark-mode .study-pop-opt-btn.active,
.dark-mode .flashcard-opt-btn.active {
  background: var(--surface-elevated) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
}

.matrix-tabs-container {
  border-bottom-color: var(--border-subtle) !important;
}
.matrix-tab {
  color: var(--text-secondary) !important;
}
.matrix-tab:hover {
  color: var(--text-primary) !important;
  opacity: 1;
}
html:not(.dark-mode) .matrix-tab.active {
  color: var(--accent) !important;
}
html:not(.dark-mode) .matrix-tab.active::after {
  background: var(--accent) !important;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.16);
}
.dark-mode .matrix-tab.active {
  color: var(--text-primary) !important;
}
.dark-mode .matrix-tab.active::after {
  background: var(--text-primary) !important;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.16);
}

.empty-state {
  background: var(--surface-muted) !important;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--inner-highlight);
}
.empty-state-icon {
  color: var(--text-muted) !important;
}
.empty-state-text {
  color: var(--text-secondary) !important;
}

.subj-card,
.reviewer-item,
.insight-item {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--inner-highlight);
}
.subj-card:hover,
.subj-card:hover * {
  background: var(--surface-hover) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-border) !important;
}
.subj-card:hover {
  box-shadow: var(--shadow-control), var(--inner-highlight);
}
.subj-remove-btn {
  background: var(--surface-elevated) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--inner-highlight);
}
.subj-remove-btn:hover {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
  border-color: var(--danger) !important;
}

.header-panel,
.action-bar,
.reviewer-scroll-view,
.analytics-title,
.metric-row,
.insight-set-title,
.insight-table-header {
  border-color: var(--border-subtle) !important;
}
.mode-badge,
.question-title,
.question-title span,
.flashcard-face-content,
.insight-col-subj,
.insight-col-stat,
.sub-tag {
  color: var(--text-primary) !important;
}
.score-box,
.timer-box,
.timer-box.study-mode,
.timer-box.flashcard-mode,
.reviewer-ans-box,
.stat-good,
.stat-bad {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--inner-highlight);
}
.timer-box.urgent {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
  border-color: var(--danger) !important;
}

.choice-btn {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--inner-highlight);
}
.choice-btn:hover:not([disabled]),
.choice-btn:hover:not([disabled]) * {
  background: var(--surface-hover) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-border) !important;
}
.choice-btn.correct {
  background: rgba(16, 185, 129, 0.14) !important;
  border-color: var(--success) !important;
  color: var(--success) !important;
}
.choice-btn.wrong {
  background: rgba(239, 68, 68, 0.14) !important;
  border-color: var(--danger) !important;
  color: var(--danger) !important;
}

.next-btn,
.ultimate-btn,
.welcome-continue-btn {
  background: var(--text-primary) !important;
  color: var(--surface) !important;
  border-color: var(--text-primary) !important;
  box-shadow: var(--shadow-control);
}
.next-btn:hover,
.ultimate-btn:hover,
.welcome-continue-btn:hover {
  background: var(--text-primary) !important;
  color: var(--surface) !important;
  filter: brightness(0.92);
  box-shadow: 0 8px 20px var(--control-hover-shadow);
}
.dark-mode .next-btn:hover,
.dark-mode .ultimate-btn:hover,
.dark-mode .welcome-continue-btn:hover {
  filter: brightness(1.08);
}

.file-upload-box {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
  box-shadow: var(--inner-highlight);
}
.file-upload-box:hover,
.file-upload-box:hover * {
  background: var(--surface-hover) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
}

.flashcard-face {
  background: linear-gradient(180deg, var(--surface-elevated), var(--surface-muted)) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--shadow-card), var(--inner-highlight);
}
.flashcard-face-lbl,
.flashcard-hint-tap {
  color: var(--text-secondary) !important;
}
.active-recall-input {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--inner-highlight);
}
.active-recall-input::placeholder,
.welcome-input::placeholder {
  color: var(--text-muted) !important;
  opacity: 1;
}
.active-recall-input:focus {
  background: var(--surface) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.insights-btn {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--shadow-control), var(--inner-highlight);
}
.insights-btn:hover {
  background: var(--surface-hover) !important;
  color: var(--accent) !important;
  border-color: var(--accent-border) !important;
}
.insight-set-title,
.insight-table-header {
  color: var(--text-secondary) !important;
}

.quick-insights-title {
  color: var(--text-primary) !important;
}
.quick-insights-col:not(:last-child)::after {
  background: var(--border-subtle) !important;
  opacity: 1;
}
.quick-insights-col:nth-child(1) .quick-insights-count,
.quick-insights-col:nth-child(1) .quick-insights-label,
.quick-insights-col:nth-child(1) .quick-insights-icon {
  color: var(--success) !important;
}
.quick-insights-col:nth-child(2) .quick-insights-count,
.quick-insights-col:nth-child(2) .quick-insights-label,
.quick-insights-col:nth-child(2) .quick-insights-icon {
  color: var(--warning) !important;
}
.quick-insights-col:nth-child(3) .quick-insights-count,
.quick-insights-col:nth-child(3) .quick-insights-label,
.quick-insights-col:nth-child(3) .quick-insights-icon {
  color: var(--danger) !important;
}
.quick-insights-range {
  color: var(--text-muted) !important;
  opacity: 1;
}

.countdown-title,
.ticker-value {
  color: var(--text-primary) !important;
}
.countdown-subtitle {
  color: var(--text-secondary) !important;
}
.ticker-lbl {
  color: var(--text-muted) !important;
}

.welcome-overlay,
.confirm-overlay {
  background: var(--overlay-bg) !important;
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.welcome-dialog,
.confirm-box {
  background: linear-gradient(180deg, var(--surface-elevated), var(--surface)) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--shadow-dialog), var(--inner-highlight);
}
.welcome-eyebrow,
.welcome-description,
.welcome-instruction,
.welcome-label,
.confirm-desc {
  color: var(--text-secondary) !important;
}
.welcome-input {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--inner-highlight);
}
.welcome-input:focus {
  background: var(--surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-border) !important;
  box-shadow: 0 0 0 4px var(--focus-ring);
}
.btn-cancel {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
}
.btn-danger {
  background: var(--danger-soft) !important;
  color: var(--danger) !important;
  border-color: var(--danger) !important;
}

.reviewer-scroll-view::-webkit-scrollbar-thumb {
  background: var(--border-strong);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* --- FULLSCREEN / JSFIDDLE PRESENTATION CLEANUP --- */
/*
 * The JSFiddle show-page badge is platform chrome, not dashboard content.
 * Exact-title selectors avoid affecting any application control.
 */
a[title="Edit in JSFiddle"],
a[aria-label="Edit in JSFiddle"],
body > *:has(a[title="Edit in JSFiddle"]),
body > *:has(a[aria-label="Edit in JSFiddle"]),
.jsfiddle-badge,
#jsfiddle-badge,
.edit-in-jsfiddle {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html:fullscreen,
html:-webkit-full-screen {
  width: 100%;
  min-height: 100%;
  background: var(--page-bg) !important;
}

html:fullscreen body,
html:-webkit-full-screen body {
  min-height: 100vh;
}

/* --- ADMIN ACCESS CONTROLS --- */
.outside-control-btn.admin-control.admin-active {
  color: #b77900 !important;
  background: rgba(235, 174, 24, 0.12) !important;
  border-color: rgba(197, 139, 0, 0.72) !important;
  box-shadow:
    0 0 0 3px rgba(235, 174, 24, 0.13),
    var(--shadow-control),
    var(--inner-highlight) !important;
}
.outside-control-btn.admin-control.admin-active:hover,
.outside-control-btn.admin-control.admin-active:focus-visible {
  color: #9b6900 !important;
  background: rgba(235, 174, 24, 0.18) !important;
  border-color: #c98e00 !important;
  box-shadow:
    0 0 0 4px rgba(235, 174, 24, 0.17),
    var(--shadow-control),
    var(--inner-highlight) !important;
}
.dark-mode .outside-control-btn.admin-control.admin-active {
  color: #ffd35a !important;
  background: rgba(255, 200, 57, 0.1) !important;
  border-color: rgba(255, 211, 90, 0.72) !important;
  box-shadow:
    0 0 0 3px rgba(255, 211, 90, 0.11),
    0 7px 18px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.07) !important;
}
.dark-mode .outside-control-btn.admin-control.admin-active:hover,
.dark-mode .outside-control-btn.admin-control.admin-active:focus-visible {
  color: #ffe28d !important;
  background: rgba(255, 200, 57, 0.15) !important;
  border-color: #ffe28d !important;
  box-shadow:
    0 0 0 4px rgba(255, 211, 90, 0.14),
    0 8px 20px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  background: var(--overlay-bg) !important;
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: adminOverlayIn 0.18s ease-out both;
}
.admin-overlay.is-closing {
  pointer-events: none;
  animation: adminOverlayOut 0.16s ease-in both;
}
.admin-dialog {
  width: 100%;
  max-width: 390px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 24px;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 16px;
  background: linear-gradient(
    180deg,
    var(--surface-elevated),
    var(--surface)
  ) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-dialog), var(--inner-highlight);
  animation: adminDialogIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.admin-overlay.is-closing .admin-dialog {
  animation: adminDialogOut 0.16s ease-in both;
}
.admin-confirm-dialog {
  max-width: 350px;
}
.admin-dialog-eyebrow {
  margin-bottom: 8px;
  color: #b77900 !important;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
}
.dark-mode .admin-dialog-eyebrow {
  color: #ffd35a !important;
}
.admin-dialog-title {
  margin: 0 0 10px;
  color: var(--text-primary) !important;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 800;
}
.admin-dialog-description {
  margin: 0 0 20px;
  color: var(--text-secondary) !important;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.admin-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.admin-label {
  color: var(--text-secondary) !important;
  font-size: 12px;
  font-weight: 700;
}
.admin-input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 13px;
  border: 1px solid var(--border-subtle) !important;
  border-radius: 9px;
  outline: none;
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--inner-highlight);
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 14px;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}
.admin-input:focus {
  background: var(--surface) !important;
  border-color: #d49b13 !important;
  box-shadow: 0 0 0 4px rgba(235, 174, 24, 0.14);
}
.dark-mode .admin-input:focus {
  border-color: #ffd35a !important;
  box-shadow: 0 0 0 4px rgba(255, 211, 90, 0.12);
}
.admin-input.has-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 4px rgba(223, 89, 103, 0.1);
}
.admin-error {
  min-height: 17px;
  color: var(--danger) !important;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}
.admin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 5px;
}
.admin-btn {
  min-width: 100px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-family: 'IBM Plex Mono', monospace !important;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}
.admin-btn-secondary {
  background: var(--surface-muted) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
  box-shadow: var(--inner-highlight);
}
.admin-btn-secondary:hover {
  background: var(--surface-hover) !important;
  border-color: var(--border-strong) !important;
}
.admin-btn-primary {
  background: #d89d0d !important;
  color: #17120a !important;
  border-color: #d89d0d !important;
  box-shadow: 0 6px 16px rgba(183, 121, 0, 0.18);
}
.admin-btn-primary:hover {
  background: #e8ae21 !important;
  border-color: #e8ae21 !important;
  box-shadow: 0 8px 20px rgba(183, 121, 0, 0.22);
}
.dark-mode .admin-btn-primary {
  background: #ffd35a !important;
  color: #19150b !important;
  border-color: #ffd35a !important;
}
.dark-mode .admin-btn-primary:hover {
  background: #ffe080 !important;
  border-color: #ffe080 !important;
}
.admin-btn:disabled {
  cursor: wait;
  opacity: 0.58;
}

.insight-col-subj:has(.insight-edit-btn) > span:nth-child(2) {
  min-width: 0;
  flex: 1 1 auto;
}
.insight-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  margin-left: auto;
  flex: 0 0 28px;
  border: 1px solid rgba(197, 139, 0, 0.55) !important;
  border-radius: 50%;
  background: rgba(235, 174, 24, 0.1) !important;
  color: #b77900 !important;
  box-shadow: var(--inner-highlight);
  cursor: pointer;
  transition:
    background 0.18s ease,
    color 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}
.insight-edit-btn svg {
  width: 14px;
  height: 14px;
  display: block;
  flex-shrink: 0;
}
.insight-edit-btn:hover,
.insight-edit-btn:focus-visible {
  background: rgba(235, 174, 24, 0.18) !important;
  color: #986500 !important;
  border-color: #c98e00 !important;
  box-shadow: 0 0 0 3px rgba(235, 174, 24, 0.13);
}
.insight-edit-btn:active {
  background: rgba(235, 174, 24, 0.23) !important;
}
.dark-mode .insight-edit-btn {
  color: #ffd35a !important;
  background: rgba(255, 211, 90, 0.08) !important;
  border-color: rgba(255, 211, 90, 0.46) !important;
}
.dark-mode .insight-edit-btn:hover,
.dark-mode .insight-edit-btn:focus-visible {
  color: #ffe28d !important;
  background: rgba(255, 211, 90, 0.14) !important;
  border-color: #ffd35a !important;
  box-shadow: 0 0 0 3px rgba(255, 211, 90, 0.11);
}

@keyframes adminOverlayIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes adminOverlayOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
@keyframes adminDialogIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes adminDialogOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(5px) scale(0.99);
  }
}

@media (max-width: 480px) {
  .admin-dialog {
    padding: 20px;
  }
  .admin-actions {
    width: 100%;
  }
  .admin-btn {
    flex: 1;
    min-width: 0;
  }
}
