/* ==========================================================================
   TARA // PASS — Minimalist Rounded Monochrome Design System
   Default: Dark Mode (Obsidian Black & Crisp White) + Light Mode Support
   ========================================================================== */

:root,
[data-theme="dark"] {
  --bg-root: #09090b;
  --bg-surface: #111114;
  --bg-elevated: #18181c;
  --bg-hover: #222228;
  --bg-active: #2c2c34;
  --bg-invert: #f4f4f5;

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-invert: #09090b;

  --border-subtle: #1f1f24;
  --border-default: #27272d;
  --border-strong: #3f3f48;
  --border-focus: #f4f4f5;

  --accent-correct-bg: rgba(34, 197, 94, 0.12);
  --accent-correct-border: #22c55e;
  --accent-correct-text: #4ade80;

  --accent-wrong-bg: rgba(239, 68, 68, 0.12);
  --accent-wrong-border: #ef4444;
  --accent-wrong-text: #f87171;

  --hl-conclusion-bg: rgba(255, 255, 255, 0.18);
  --hl-conclusion-border: #ffffff;
  --hl-premise-bg: rgba(255, 255, 255, 0.08);
  --hl-premise-border: #a1a1aa;
  --hl-keyword-bg: rgba(255, 255, 255, 0.04);
  --hl-keyword-border: #d4d4d8;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.55);
  --backdrop-overlay: rgba(0, 0, 0, 0.72);
}

[data-theme="light"] {
  --bg-root: #f6f6f8;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f1f4;
  --bg-hover: #e7e7ec;
  --bg-active: #dcdce2;
  --bg-invert: #111114;

  --text-primary: #111114;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-invert: #ffffff;

  --border-subtle: #ececf0;
  --border-default: #e2e2e8;
  --border-strong: #c4c4ce;
  --border-focus: #111114;

  --accent-correct-bg: rgba(22, 163, 74, 0.09);
  --accent-correct-border: #16a34a;
  --accent-correct-text: #15803d;

  --accent-wrong-bg: rgba(220, 38, 38, 0.08);
  --accent-wrong-border: #dc2626;
  --accent-wrong-text: #b91c1c;

  --hl-conclusion-bg: rgba(0, 0, 0, 0.12);
  --hl-conclusion-border: #111114;
  --hl-premise-bg: rgba(0, 0, 0, 0.05);
  --hl-premise-border: #71717a;
  --hl-keyword-bg: rgba(0, 0, 0, 0.03);
  --hl-keyword-border: #3f3f46;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.08);
  --backdrop-overlay: rgba(15, 15, 20, 0.45);
}

:root {
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
  --font-serif: "Georgia", "Times New Roman", "Songti SC", serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background-color: var(--bg-root);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* App Shell */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Top Header Bar */
.top-header {
  height: 58px;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  z-index: 100;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 14.5px;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  padding: 5px 12px;
  border: 1.5px solid var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: transform 0.12s ease;
}

.brand-logo:hover {
  transform: translateY(-1px);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.nav-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.nav-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-btn.active {
  background: var(--bg-invert);
  color: var(--text-invert);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.nav-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(128, 128, 128, 0.18);
  color: inherit;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-status-btn {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.sync-status-btn:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.status-dot {
  width: 7px;
  height: 7px;
  min-width: 7px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
}

/* Generic Buttons & Inputs */
.btn {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--bg-invert);
  color: var(--text-invert);
  border-color: var(--bg-invert);
  font-weight: 600;
}

.btn-primary:hover {
  opacity: 0.9;
  background: var(--bg-invert);
  color: var(--text-invert);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.select-input, .text-input {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 12.5px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s ease;
}

.select-input:focus, .text-input:focus {
  border-color: var(--text-primary);
}

/* Main Content Area */
.main-viewport {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.view-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  height: calc(100vh - 58px);
}

.view-panel.active {
  display: block;
}

#view-practice.active,
#view-exam.active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================================
   VIEW 1: DASHBOARD & MODULES (Simplified & Rounded)
   ========================================================================== */
.dashboard-container {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.hero-banner {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 22px 26px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-sm);
}

.hero-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.kpi-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.section-heading {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading span:last-child {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 26px;
}

.module-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.15s ease, transform 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.module-card:hover {
  border-color: var(--border-strong);
}

.module-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.module-num {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  white-space: nowrap;
}

.module-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}

.module-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.subtype-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.subtype-tag {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s ease;
}

.subtype-tag:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.module-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.preset-papers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 26px;
}

.preset-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.preset-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  display: inline-block;
  margin-bottom: 8px;
}

.preset-badge.warn {
  border-style: dashed;
}

/* ==========================================================================
   VIEW 2: PRACTICE WORKSPACE (SPLIT SCREEN)
   ========================================================================== */
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.practice-split {
  flex: 1;
  display: grid;
  grid-template-columns: 50% 50%;
  overflow: hidden;
  height: calc(100vh - 114px);
}

.pane-left {
  border-right: 1px solid var(--border-default);
  overflow-y: auto;
  padding: 24px 28px 60px;
  background: var(--bg-root);
}

.pane-right {
  overflow-y: auto;
  padding: 24px 28px 60px;
  background: var(--bg-surface);
}

/* Question Meta Header */
.q-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-default);
}

.q-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.q-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.q-badge.invert {
  background: var(--bg-invert);
  color: var(--text-invert);
  border-color: var(--bg-invert);
  font-weight: 600;
}

.sample-warning-banner {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Annotation Toolbar on Left Pane */
.annotation-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-bottom: 18px;
}

.hl-btn {
  padding: 4px 10px;
  font-size: 12px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: all 0.12s ease;
}

.hl-btn:hover {
  border-color: var(--text-primary);
}

.hl-btn.btn-primary {
  background: var(--bg-invert);
  color: var(--text-invert);
  border-color: var(--bg-invert);
}

/* Passage Content Typography */
.passage-content {
  font-size: 15.5px;
  line-height: 1.78;
  color: var(--text-primary);
}

.passage-content p {
  margin-bottom: 14px;
}

.passage-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 14px 0;
  font-size: 13px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.passage-content th,
.passage-content td {
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  padding: 9px 12px;
  text-align: center;
}

.passage-content th:last-child,
.passage-content td:last-child {
  border-right: none;
}

.passage-content tr:last-child td {
  border-bottom: none;
}

.passage-content th {
  background: var(--bg-elevated);
  font-weight: 600;
  color: var(--text-secondary);
}

/* Image & Diagram Rendering */
.exhibit-image-card {
  margin: 14px 0;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: #000000;
  overflow-x: auto;
  text-align: center;
}

.exhibit-image-card.dark-inverted {
  background: #0d0d10;
}

.exhibit-image-card.dark-inverted img,
.passage-content.dark-inverted img,
.options-list.dark-inverted img {
  filter: invert(1) hue-rotate(180deg) contrast(1.06);
}

.passage-content img,
.options-list img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  background: #ffffff;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
}

/* Text Highlight Styles */
.hl-span-conclusion {
  background: var(--hl-conclusion-bg);
  border-bottom: 2px solid var(--hl-conclusion-border);
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
}

.hl-span-premise {
  background: var(--hl-premise-bg);
  border-bottom: 1.5px dashed var(--hl-premise-border);
  padding: 1px 4px;
  border-radius: 3px;
}

.hl-span-keyword {
  background: var(--hl-keyword-bg);
  border: 1px solid var(--hl-keyword-border);
  padding: 0 4px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* Canvas Sketch Pad */
.canvas-wrapper {
  margin-top: 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  padding: 12px;
}

.sketch-canvas {
  width: 100%;
  height: 240px;
  background: var(--bg-root);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: crosshair;
  display: block;
}

/* Stem & Options (Right Pane) */
.stem-box {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--bg-root);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.option-item {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-root);
  padding: 12px 14px;
  transition: all 0.14s ease;
  position: relative;
}

.option-item:hover {
  border-color: var(--border-strong);
}

.option-item.selected {
  border-color: var(--text-primary);
  border-width: 1.5px;
  background: var(--bg-elevated);
}

.option-item.correct-answer {
  border-color: var(--accent-correct-border);
  border-width: 1.5px;
  background: var(--accent-correct-bg);
}

.option-item.wrong-answer {
  border-color: var(--accent-wrong-border);
  border-width: 1.5px;
  background: var(--accent-wrong-bg);
}

.option-item.eliminated .option-main-row {
  opacity: 0.35;
  text-decoration: line-through;
}

.option-main-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.option-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}

.option-letter {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-surface);
}

.option-item.selected .option-letter {
  background: var(--bg-invert);
  color: var(--text-invert);
  border-color: var(--bg-invert);
}

.option-item.correct-answer .option-letter {
  background: var(--accent-correct-border);
  color: #ffffff;
  border-color: var(--accent-correct-border);
}

.option-item.wrong-answer .option-letter {
  background: var(--accent-wrong-border);
  color: #ffffff;
  border-color: var(--accent-wrong-border);
}

.option-text {
  font-size: 14.5px;
  line-height: 1.55;
  flex: 1;
  padding-top: 2px;
}

.option-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.opt-tool-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  padding: 3px 7px;
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
}

.opt-tool-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-default);
  background: var(--bg-elevated);
}

.option-note-input {
  margin-top: 8px;
  width: 100%;
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-sans);
  outline: none;
}

/* Explanation & Notes Cards */
.result-banner {
  padding: 14px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-root);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-root);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.panel-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.error-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.err-tag-chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.12s ease;
}

.err-tag-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.err-tag-chip.active {
  background: var(--bg-invert);
  color: var(--text-invert);
  border-color: var(--bg-invert);
  font-weight: 600;
}

.note-textarea {
  width: 100%;
  min-height: 82px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  resize: vertical;
  outline: none;
}

.note-textarea:focus {
  border-color: var(--text-primary);
}

.markdown-body {
  font-size: 14px;
  line-height: 1.72;
  color: var(--text-primary);
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 12px 0 6px;
  font-weight: 700;
}

.markdown-body p {
  margin-bottom: 10px;
}

.markdown-body ul,
.markdown-body ol {
  margin: 8px 0 12px 20px;
}

.markdown-body code {
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.markdown-body pre {
  background: var(--bg-elevated);
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  overflow-x: auto;
  margin: 10px 0;
}

/* Writing Task Editor */
.writing-plan-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.essay-editor {
  width: 100%;
  min-height: 320px;
  background: var(--bg-root);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 16px;
  font-size: 15px;
  line-height: 1.75;
  font-family: var(--font-serif);
  resize: vertical;
  outline: none;
}

.essay-editor:focus {
  border-color: var(--text-primary);
}

.word-counter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ==========================================================================
   VIEW 3: EXAM MODE
   ========================================================================== */
.exam-top-bar {
  height: 50px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
}

.exam-timer {
  font-size: 15px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-root);
}

.exam-bottom-nav {
  height: 56px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-default);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.q-grid-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.q-dot {
  width: 28px;
  height: 28px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-default);
  background: var(--bg-root);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.12s ease;
}

.q-dot.answered {
  background: var(--bg-active);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.q-dot.current {
  background: var(--bg-invert);
  color: var(--text-invert);
  border-color: var(--bg-invert);
  font-weight: 700;
}

.q-dot.flagged::after {
  content: "⚑";
  position: absolute;
  top: -4px;
  right: -2px;
  font-size: 9px;
}

/* ==========================================================================
   VIEW 4 & 5: MISTAKES & ANNOTATIONS
   ========================================================================== */
.mistake-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mistake-card {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  padding: 18px 20px;
  transition: border-color 0.12s ease;
  box-shadow: var(--shadow-sm);
}

.mistake-card:hover {
  border-color: var(--border-strong);
}

/* ==========================================================================
   VIEW 6: PDF ARCHIVE
   ========================================================================== */
.pdf-archive-split {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100vh - 58px);
  overflow: hidden;
}

.pdf-sidebar {
  border-right: 1px solid var(--border-default);
  overflow-y: auto;
  background: var(--bg-surface);
  padding: 14px;
}

.pdf-item {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background 0.12s ease;
}

.pdf-item:hover {
  background: var(--bg-hover);
}

.pdf-item.active {
  background: var(--bg-invert);
  color: var(--text-invert);
  font-weight: 600;
}

/* ==========================================================================
   MODAL DIALOG (DATA PERSISTENCE & BACKUP)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop-overlay);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

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

.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-default);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
}

.storage-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.storage-stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.storage-stat-num {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
}

.storage-stat-label {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

@media (max-width: 1024px) {
  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .modules-grid, .preset-papers-grid {
    grid-template-columns: 1fr;
  }
  .practice-split {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .pane-left, .pane-right {
    border-right: none;
    border-bottom: 1px solid var(--border-default);
    overflow-y: visible;
    height: auto;
  }
}
