:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #f0f3f7;
  --passage-bg: #ffffff;
  --text: #1c2430;
  --text-muted: #5f6c7d;
  --border: #dfe4ec;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --accent-hover: #1d4ed8;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --hl-yellow: #fef08a;
  --hl-green: #bbf7d0;
  --hl-pink: #fbcfe8;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  --font-size-passage: 16px;
  --font-size-question: calc(var(--font-size-passage) - 1.5px);
  --font-size-question-sm: calc(var(--font-size-passage) - 2.5px);
}

html[data-theme="sepia"] {
  --bg: #f4efe4;
  --surface: #fbf8f1;
  --surface-alt: #eee7d7;
  --passage-bg: #fbf8f1;
  --text: #2c261e;
  --text-muted: #6f6556;
  --border: #dfd6c5;
  --accent: #0f766e;
  --accent-soft: #e6f4f1;
  --accent-hover: #115e59;
}

html[data-theme="dark"] {
  --bg: #0f141c;
  --surface: #171e29;
  --surface-alt: #1f2836;
  --passage-bg: #151b25;
  --text: #e6ecf5;
  --text-muted: #93a1b5;
  --border: #2a3444;
  --accent: #60a5fa;
  --accent-soft: #1e2d45;
  --accent-hover: #93c5fd;
  --green: #4ade80;
  --green-soft: rgba(34, 197, 94, 0.16);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.16);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.16);
  --hl-yellow: rgba(250, 204, 21, 0.35);
  --hl-green: rgba(74, 222, 128, 0.32);
  --hl-pink: rgba(244, 114, 182, 0.32);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  height: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  text-align: left;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 15px;
  font-weight: 700;
}

.brand-text small {
  font-size: 11px;
  color: var(--text-muted);
}

.main-nav {
  display: flex;
  gap: 4px;
  margin-left: 10px;
}

.nav-tab {
  background: none;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}

.nav-tab:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-tab.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.badge {
  background: var(--surface-alt);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
}

.nav-tab.is-active .badge {
  background: var(--accent);
  color: #fff;
}

.font-controls {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-alt);
}

.icon-btn {
  background: none;
  border: none;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.icon-btn:hover {
  background: var(--border);
}

.font-label {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 4px;
  min-width: 24px;
  text-align: center;
}

.theme-switcher {
  display: flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.theme-btn {
  border: none;
  background: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}

.theme-btn.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Views */
.view {
  display: none;
  flex: 1;
}

.view.is-active {
  display: flex;
  flex-direction: column;
}

/* Library View */
#libraryView {
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 20px 48px;
  gap: 18px;
}

.library-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  box-shadow: var(--shadow);
}

.hero-copy h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
}

.hero-copy p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.hero-stats {
  display: flex;
  gap: 14px;
  flex-shrink: 0;
}

.stat-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  min-width: 106px;
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.library-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 260px;
}

.search-box input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-pills {
  display: flex;
  gap: 6px;
}

.pill {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}

.pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.library-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.book-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 74px;
  max-height: calc(100vh - 94px);
  overflow-y: auto;
}

.book-item {
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  color: var(--text);
}

.book-item:hover {
  background: var(--surface-alt);
}

.book-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.book-item small {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
}

.tests-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.test-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.test-card-head {
  padding: 14px 18px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.test-card-head h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
}

.test-card-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.passage-rows {
  display: flex;
  flex-direction: column;
}

.passage-row {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  transition: background 0.12s;
}

.passage-row:last-child {
  border-bottom: none;
}

.passage-row:hover {
  background: var(--surface-alt);
}

.passage-row-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.passage-row-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.p-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
}

.passage-row-title strong {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
}

.passage-row-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.passage-row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.score-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
}

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-outline:hover {
  background: var(--surface-alt);
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text);
}

/* Practice View */
.practice-view {
  height: calc(100vh - 58px);
  overflow: hidden;
}

.practice-bar {
  height: 50px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.practice-bar-left, .practice-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-switch {
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}

.mode-pill {
  border: none;
  background: transparent;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-pill.is-active[data-mode="practice"] {
  background: var(--accent);
  color: #fff;
}

.mode-pill.is-active[data-mode="exam"] {
  background: var(--amber);
  color: #fff;
}

.practice-view.is-exam-mode .practice-bar {
  border-bottom-color: var(--amber);
}

.timer-mode-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.practice-view.is-exam-mode .timer-mode-tag {
  background: var(--amber-soft);
  color: var(--amber);
}

.timer-pill.is-warning {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}

.timer-pill.is-urgent {
  background: var(--red-soft);
  border-color: var(--red);
  color: var(--red);
}

.exam-breakdown {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.exam-p-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-exam {
  background: var(--amber);
  border: 1px solid var(--amber);
  color: #fff;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-exam:hover {
  opacity: 0.9;
}

.crumb {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.passage-tabs {
  display: flex;
  gap: 4px;
  margin-left: 6px;
}

.p-tab {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-muted);
}

.p-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.timer-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-variant-numeric: tabular-nums;
}

#timerDisplay {
  font-weight: 700;
  font-size: 13.5px;
  min-width: 46px;
}

.mini-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
}

.result-banner {
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  flex-shrink: 0;
}

.result-banner strong {
  font-size: 16px;
  color: var(--accent);
}

/* Split Workspace */
.split-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 6px 1fr;
}

.pane {
  overflow-y: auto;
  padding: 24px 28px 60px;
}

.passage-pane {
  background: var(--passage-bg);
}

.questions-pane {
  background: var(--bg);
}

.split-resizer {
  background: var(--border);
  cursor: col-resize;
  transition: background 0.15s;
}

.split-resizer:hover, .split-resizer.is-dragging {
  background: var(--accent);
}

.passage-meta {
  max-width: 65ch;
  margin: 0 auto 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.passage-meta .kicker {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.passage-meta h2 {
  margin: 0 0 8px;
  font-family: "Charter", "Bitstream Charter", "Sitka Text", "Times New Roman", "Songti SC", "Noto Serif CJK SC", serif;
  font-variant-numeric: lining-nums tabular-nums;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.28;
}

.passage-meta .subtitle {
  margin: 0;
  font-family: "Charter", "Bitstream Charter", "Sitka Text", "Times New Roman", "Songti SC", "Noto Serif CJK SC", serif;
  font-variant-numeric: lining-nums tabular-nums;
  font-style: italic;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}

.passage-body {
  max-width: 65ch;
  margin: 0 auto;
  font-family: "Charter", "Bitstream Charter", "Sitka Text", "Times New Roman", "Songti SC", "Noto Serif CJK SC", serif;
  font-variant-numeric: lining-nums tabular-nums;
  font-size: var(--font-size-passage);
  line-height: 1.82;
  letter-spacing: 0.004em;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

.para-block {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.para-block.is-footnote {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.86em;
  line-height: 1.65;
  color: var(--text-muted);
}

.para-block.is-footnote .para-label {
  color: var(--text-muted);
  font-size: 11.5px;
  padding-top: 2px;
}

.para-label {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: var(--accent);
  min-width: 22px;
  padding-top: 5px;
  user-select: none;
}

.para-text {
  flex: 1;
  margin: 0;
}

.hl-mark {
  border-radius: 3px;
  padding: 0 2px;
  cursor: pointer;
}

.hl-yellow { background: var(--hl-yellow); }
.hl-green { background: var(--hl-green); }
.hl-pink { background: var(--hl-pink); }

/* Question Groups */
.questions-list {
  max-width: 68ch;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  font-variant-numeric: lining-nums tabular-nums;
}

.q-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.q-group-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.q-group-header h3 {
  margin: 0 0 6px;
  font-size: var(--font-size-passage);
  color: var(--accent);
}

.q-instruction {
  margin: 0;
  font-size: var(--font-size-question-sm);
  line-height: 1.55;
  color: var(--text-muted);
  white-space: pre-line;
}

.q-word-limit {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
  background: var(--red-soft);
  padding: 2px 8px;
  border-radius: 5px;
}

.options-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: var(--font-size-question-sm);
  line-height: 1.6;
}

.options-box-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 13px;
}

.options-box-item {
  display: flex;
  gap: 8px;
  margin-bottom: 3px;
}

.options-box-item b {
  min-width: 24px;
  color: var(--accent);
}

.q-item {
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}

.q-item:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.q-item.is-target {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  border-radius: 6px;
}

.q-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.q-prompt {
  font-size: var(--font-size-question);
  line-height: 1.6;
  flex: 1;
}

.q-num {
  display: inline-block;
  font-weight: 800;
  color: var(--accent);
  margin-right: 6px;
}

.flag-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-muted);
  flex-shrink: 0;
}

.flag-btn.is-flagged {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
  font-weight: 700;
}

/* Question Inputs */
.tfng-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.choice-pill {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.choice-pill.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mcq-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mcq-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  cursor: pointer;
  text-align: left;
  font-size: var(--font-size-question-sm);
  line-height: 1.5;
}

.mcq-option:hover {
  border-color: var(--accent);
}

.mcq-option.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}

.mcq-letter {
  font-weight: 800;
  color: var(--accent);
  min-width: 18px;
}

.blank-input {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--accent);
  border-radius: 6px;
  background: var(--surface-alt);
  font-size: 14.5px;
  font-weight: 600;
  outline: none;
}

.blank-input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.inline-blank {
  display: inline-block;
  width: 136px;
  padding: 3px 8px;
  margin: 0 4px;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--accent);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: var(--font-size-question-sm);
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.inline-blank:focus,
.inline-blank.is-target,
.inline-select:focus,
.inline-select.is-target {
  box-shadow: 0 0 0 3px var(--accent-soft);
  border-color: var(--accent);
}

.inline-blank.is-correct,
.inline-select.is-correct {
  border-color: var(--green);
  border-bottom-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.inline-blank.is-wrong,
.inline-select.is-wrong {
  border-color: var(--red);
  border-bottom-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.summary-prose {
  font-size: var(--font-size-question);
  line-height: 1.85;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 12px;
}

.summary-prose h4 {
  margin: 0 0 10px;
  font-size: var(--font-size-passage);
  font-weight: 700;
}

.summary-subhead {
  font-size: var(--font-size-question);
  font-weight: 700;
  color: var(--text);
  margin: 12px 0 4px;
}

.summary-subhead:first-child {
  margin-top: 0;
}

.summary-line {
  position: relative;
  padding: 3px 0;
  line-height: 1.9;
}

.summary-line.has-bullet {
  padding-left: 16px;
}

.summary-line.has-bullet::before {
  content: "•";
  position: absolute;
  left: 2px;
  top: 3px;
  color: var(--accent);
  font-weight: 700;
}

.inline-feedback-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.match-select {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 13.5px;
  font-weight: 600;
  min-width: 140px;
}

/* Grading Feedback */
.q-feedback {
  margin-top: 8px;
  padding: 7px 11px;
  border-radius: 7px;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.q-feedback.is-correct {
  background: var(--green-soft);
  color: var(--green);
}

.q-feedback.is-wrong {
  background: var(--red-soft);
  color: var(--red);
}

/* Bottom Navigator */
.question-nav-bar {
  height: 48px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.nav-legend {
  display: flex;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.nav-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid var(--border);
}

.dot-answered { background: var(--accent); border-color: var(--accent); }
.dot-flagged { background: var(--amber); border-color: var(--amber); }
.dot-correct { background: var(--green); border-color: var(--green); }
.dot-wrong { background: var(--red); border-color: var(--red); }

.q-dots {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 4px 0;
}

.q-dot-btn {
  min-width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.q-dot-btn.is-answered {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.q-dot-btn.is-flagged {
  box-shadow: 0 0 0 2px var(--amber);
}

.q-dot-btn.is-correct {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.q-dot-btn.is-wrong {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* Notes Drawer */
.side-drawer {
  position: fixed;
  top: 108px;
  right: 16px;
  width: 340px;
  max-height: calc(100vh - 170px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.drawer-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-head h3 {
  margin: 0;
  font-size: 14px;
}

.drawer-body {
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-label, .drawer-subtitle {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

#passageNoteInput {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  resize: vertical;
  font-size: 13px;
}

.highlights-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hl-card {
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--surface-alt);
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* Subpages (Mistakes & Vocab) */
#mistakesView, #vocabView {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 60px;
  gap: 18px;
}

.subpage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.subpage-header h2 {
  margin: 0 0 4px;
}

.subpage-header p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.cards-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.dictation-box {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.dictation-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.dictation-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.speak-btn {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.dictation-input-row {
  display: flex;
  gap: 8px;
  width: min(460px, 100%);
}

.dictation-input-row input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 16px;
  text-align: center;
  font-weight: 600;
}

.vocab-add-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.vocab-add-bar input {
  flex: 1;
  min-width: 200px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
}

/* Floating Selection Toolbar */
.selection-toolbar {
  position: fixed;
  z-index: 100;
  background: #111827;
  color: #f9fafb;
  padding: 5px 8px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.selection-toolbar button {
  background: none;
  border: none;
  color: inherit;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.selection-toolbar button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.selection-toolbar .divider {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 2px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.swatch.yellow { background: #fde047; }
.swatch.green { background: #86efac; }
.swatch.pink { background: #f9a8d4; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-panel {
  width: min(960px, 95vw);
  max-height: 90vh;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-page-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.modal-body {
  overflow: auto;
  padding: 16px;
  background: var(--surface-alt);
  text-align: center;
}

.modal-body img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.empty-state {
  text-align: center;
  padding: 46px 20px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

@media (max-width: 900px) {
  .library-layout {
    grid-template-columns: 1fr;
  }
  .book-sidebar {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
  }
  .book-item {
    width: auto;
    white-space: nowrap;
  }
  .split-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .split-resizer {
    display: none;
  }
  .nav-legend {
    display: none;
  }
}


/* Account & Admin Panel */
.user-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
}

.user-chip strong {
  color: var(--accent);
}

.auth-modal-panel {
  width: min(440px, 94vw);
}

.auth-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface-alt);
  padding: 4px;
  border-radius: 10px;
}

.auth-tab {
  border: none;
  background: none;
  padding: 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.auth-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-field input {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 14px;
  outline: none;
}

.form-field input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.form-error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
}

.form-msg {
  font-size: 13px;
  margin-top: 8px;
  color: var(--green);
}

.auth-submit {
  padding: 10px 16px;
  font-size: 14.5px;
}

#adminView {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 60px;
  gap: 18px;
}

.admin-settings-card,
.admin-create-card,
.admin-users-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.admin-settings-card h3,
.admin-create-card h3,
.admin-users-head h3 {
  margin: 0 0 12px;
  font-size: 15.5px;
}

.admin-toggles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}

.toggle-item input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.admin-create-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: center;
}

.admin-create-form input,
.admin-create-form select,
.admin-users-head input {
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 13.5px;
}

.admin-users-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.admin-users-head h3 {
  margin: 0;
}

.admin-users-head input {
  min-width: 240px;
}

.user-row-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.user-row-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.role-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.role-badge.is-admin {
  background: var(--accent-soft);
  color: var(--accent);
}

.role-badge.is-user {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.status-badge-disabled {
  background: var(--red-soft);
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

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