:root {
  --bg: #f6f4ef;
  --ink: #1d232a;
  --panel: #fffef8;
  --line: #d2c9b8;
  --accent: #0a6a59;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #efe9dd, var(--bg));
}

body.student-mode {
  background: radial-gradient(circle at top left, #dff2ff, #ecf7ff 55%, #f4fbff);
}

body.student-mode .panel {
  background: #f9fdff;
  border-color: #bdd6e6;
}

body.student-mode header {
  border-bottom-color: #bdd6e6;
}

header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-family: "IBM Plex Serif", Georgia, serif;
  font-size: 1.65rem;
}

main {
  display: grid;
  grid-template-columns: 250px 220px 1fr 1fr;
  gap: 12px;
  padding: 12px;
  align-items: start;
}

#leftStack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#leftStack .panel {
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  min-height: 220px;
}

.panel h2 {
  margin: 0 0 8px 0;
  font-size: 1rem;
}

.chip-row,
.topic-rail {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#noteChipRow {
  max-height: 100px;
  overflow-y: auto;
  overflow-x: hidden;
}

#noteChipRow .pill {
  font-size: 0.9rem;
  padding: 5px 13px;
}

#noteChipRow::-webkit-scrollbar {
  width: 6px;
}

#noteChipRow::-webkit-scrollbar-track {
  background: transparent;
}

#noteChipRow::-webkit-scrollbar-thumb {
  background: #9ec6dd;
  border-radius: 999px;
}

.topic-rail {
  overflow-x: auto;
  flex-wrap: nowrap;
  padding-bottom: 6px;
}

.topic-rail::-webkit-scrollbar {
  height: 10px;
}

.topic-rail::-webkit-scrollbar-track {
  background: #e5f1f8;
  border-radius: 999px;
}

.topic-rail::-webkit-scrollbar-thumb {
  background: #9ec6dd;
  border-radius: 999px;
}

/* Student-mode: grouped vertical rail */
body.student-mode .topic-rail {
  flex-direction: column;
  flex-wrap: nowrap;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 128px;
  padding-bottom: 0;
  gap: 0;
}

body.student-mode .topic-rail::-webkit-scrollbar {
  width: 6px;
  height: auto;
}

body.student-mode .topic-rail::-webkit-scrollbar-track {
  background: transparent;
}

body.student-mode .topic-rail::-webkit-scrollbar-thumb {
  background: #9ec6dd;
  border-radius: 999px;
}

.topic-group {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
}

.topic-group-label {
  flex: 0 0 90px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7a9ab0;
  padding-top: 4px;
  line-height: 1.2;
}

.topic-group-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
}

#questionList {
  max-height: 362px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.student-mode #questionList {
  max-height: 224px;
}

.question-btn {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  color: #1d232a;
  font-weight: 600;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  min-height: 40px;
  line-height: 1.2;
}

.question-btn.active {
  border-color: var(--accent);
  outline: 2px solid #8fd8c9;
}

.question-btn.reviewed {
  background: #f0faf5;
  border-color: #9dd4be;
  color: #3a6655;
}

.question-btn.reviewed.active {
  border-color: var(--accent);
  outline: 2px solid #8fd8c9;
}

.question-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.question-row .question-btn {
  flex: 1;
  margin: 0;
}

.review-check {
  -webkit-appearance: checkbox;
  appearance: auto;
  width: 16px;
  min-width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  border: revert;
  border-radius: revert;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

input,
textarea,
select,
button {
  width: 100%;
  margin-top: 4px;
  margin-bottom: 10px;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font: inherit;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
}

button.pill {
  width: auto;
  margin: 0;
  padding: 4px 10px;
  min-height: 0;
  line-height: 1.2;
  white-space: nowrap;
  color: #1d232a;
  background: #fff;
  border: 1px solid var(--line);
}

.note-chip.active,
.topic-pill.active {
  border-color: #2778a2;
  background: #dff2ff;
  color: #0f4f6d;
}

.chip-editor {
  width: 100%;
  margin-top: 4px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.chip-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f5f5f5;
  font-size: 0.85rem;
}

.chip-item.page-chip {
  background: #e9f7f3;
  border-color: #bde4da;
}

.chip-item.page-chip.source-imported {
  background: #e8f0fb;
  border-color: #5b8fd9;
}

.chip-item.page-chip.source-mapped {
  background: #e8f7ef;
  border-color: #1f9d55;
}

.chip-item.page-chip.source-exception {
  background: #fff4e5;
  border-color: #d97706;
}

.chip-item.chip-clickable {
  cursor: pointer;
}

.chip-label {
  line-height: 1;
}

.chip-item.tag-chip {
  background: #f5efe1;
  border-color: #d9c8a0;
}

.chip-item.tag-chip.source-mapped {
  background: #e8f7ef;
  border-color: #1f9d55;
}

.chip-remove {
  border: 0;
  background: transparent;
  color: #6b6f73;
  border-radius: 999px;
  width: 18px;
  height: 18px;
  min-width: 18px;
  padding: 0;
  margin: 0;
  line-height: 1;
  font-size: 0.9rem;
  cursor: pointer;
}

.chip-remove:hover {
  color: #1d232a;
  background: #e8ecef;
}

.chip-input {
  width: 100%;
  border: 0;
  margin: 0;
  padding: 4px;
  border-radius: 6px;
}

.chip-input:focus {
  outline: 0;
}

.chip-editor:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #8fd8c9;
}

.tag-suggestions {
  margin-top: -8px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: 180px;
  overflow: auto;
}

.tag-suggestion {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  margin: 0;
  border: 0;
  background: #fff;
  color: var(--ink);
}

.tag-suggestion.active,
.tag-suggestion:hover {
  background: #eef6ef;
}

.editor-status {
  min-height: 18px;
  margin: -2px 0 8px;
  font-size: 0.85rem;
}

.editor-status.saving {
  color: #7a5f11;
}

.editor-status.saved {
  color: #276738;
}

.editor-status.error {
  color: #8f2e2a;
}

#modeBadge {
  margin: 6px 0 0;
  font-size: 0.9rem;
}

.hidden {
  display: none;
}

.student-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-headline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.pill-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.pill-label {
  font-size: 0.85rem;
  color: #5f6062;
  padding-top: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.86rem;
}

.page-pill {
  background: #e9f7f3;
  border-color: #bde4da;
}

body.student-mode .topic-pill {
  flex: 0 0 auto;
  font-size: 0.78rem;
  padding: 3px 9px;
  background: #e9f7f3;
  border-color: #bde4da;
  color: #1d232a;
}

body.student-mode .topic-pill.active {
  background: #cdeee4;
  border-color: #86d0bb;
  color: #11483a;
}

.id-pill {
  background: #edf1f6;
  border-color: #cad6e6;
}

.set-pill {
  background: #eef6ef;
  border-color: #c5dfc8;
}

.empty-pill {
  color: #777;
  background: #f6f6f6;
}

.video-link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.video-link-list a {
  color: #0f5a7a;
  text-decoration: none;
  font-size: 0.9rem;
}

.video-link-list a:hover {
  text-decoration: underline;
}

.student-question {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 400px;
  width: min(100%, 760px);
  margin: 0 auto;
  line-height: 1.45;
}

body.student-mode #editorPanel {
  display: none;
}

body.student-mode main {
  position: relative;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas:
    "left preview"
    "clear preview"
    "list preview";
  min-height: calc(100vh - 70px);
  max-width: 1600px;
  margin: 0 auto;
}

body.student-mode #previewPanel {
  grid-area: preview;
  overflow-y: auto;
  align-self: stretch;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
}

#clearFilterBar {
  grid-area: clear;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  flex-wrap: wrap;
  min-height: 0;
}

body.student-mode #clearFilterBar:not(.has-filters) {
  display: none;
}

.filter-bar-label {
  display: inline-flex;
  align-items: center;
  font-size: 0.73rem;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid rgba(134, 200, 150, 0.7);
  background: rgba(220, 245, 228, 0.8);
  color: #2a7a45;
}

.filter-clear-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid rgba(240, 160, 170, 0.7);
  background: rgba(253, 232, 235, 0.8);
  color: #9b2335;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.filter-clear-btn:hover {
  background: rgba(251, 208, 214, 0.9);
  border-color: rgba(232, 145, 158, 0.85);
}

body.student-mode #topicPanel {
  position: fixed;
  z-index: 30;
  top: 76px;
  left: min(324px, calc(100vw - 536px));
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  min-height: 0;
  overflow: auto;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(15, 52, 96, 0.24), 0 4px 16px rgba(15, 52, 96, 0.12);
}

body.student-mode #topicPanel .topic-rail {
  max-height: none;
  overflow: visible;
}

body.student-mode #leftStack {
  grid-area: left;
  background: #f9fdff;
  border: 1px solid #bdd6e6;
  border-radius: 16px;
  gap: 0;
  overflow: hidden;
}

body.student-mode #leftStack .panel {
  background: transparent;
  border: none;
  border-radius: 0;
  min-height: 0;
  padding: 12px;
}

body.student-mode #leftStack .panel + .panel {
  border-top: 1px solid rgba(150, 195, 230, 0.4);
}

body.student-mode #listPanel {
  grid-area: list;
  min-height: 0;
}

body.student-mode #noteChipRow {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  max-height: none;
  padding-bottom: 4px;
}

body.student-mode #noteChipRow .pill {
  flex: 0 0 auto;
}

body.student-mode #questionList {
  max-height: 174px;
  gap: 5px;
}

body.student-mode #questionList .question-btn {
  min-height: 36px;
  padding: 6px 10px;
  line-height: 1.15;
}

.student-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.student-control-label {
  display: none;
}

body.student-mode #filterPanel .authoring-filter-title {
  display: none;
}

body.student-mode .student-control-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

body.student-mode .student-control-row + .student-control-row {
  margin-top: 10px;
}

body.student-mode .student-control-label {
  display: block;
  color: #557a96;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
}

body.student-mode #maxPagePanel.hidden {
  display: none;
}

body.student-mode #maxPageInput {
  margin: 0;
}

body.student-mode .student-search-row #filterInput {
  min-width: 0;
  flex: 1;
}

.filter-toggle {
  width: auto;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(120, 175, 215, 0.7);
  border-radius: 999px;
  background: rgba(225, 241, 253, 0.9);
  color: #164b78;
  font: 600 0.82rem "Inter", sans-serif;
  cursor: pointer;
  margin: 0;
}

.filter-toggle:hover,
.filter-toggle.active {
  background: #d3eaff;
  border-color: #1a5db0;
}

.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: #1a5db0;
  color: white;
  font-size: 0.7rem;
}

.filter-count.hidden {
  display: none;
}

.topic-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

body.student-mode .topic-panel-header h2 {
  margin-bottom: 3px;
  color: #315f82;
}

.topic-panel-header p {
  margin: 0;
  color: #718da3;
  font-size: 0.8rem;
}

.topic-panel-close {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #edf6fc;
  color: #315f82;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

.filter-option {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 0 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(150, 195, 230, 0.4);
}

.filter-option label,
.topic-panel-label {
  color: #557a96;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topic-panel-label {
  margin-bottom: 8px;
}

body.student-mode #noteSelect {
  display: none;
}

.student-question ol {
  margin-top: 8px;
  padding-left: 20px;
}

.student-question li {
  margin: 6px 0;
}

.student-question .prompt {
  margin-bottom: 12px;
}

.student-inline-figures {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0 0 12px 0;
}

.student-inline-figures.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.student-inline-figure {
  margin: 0;
}

.student-inline-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Cap single-image prompts so lone figures don't become oversized. */
.student-inline-figures:not(.two-up) .student-inline-figure img {
  width: min(100%, 760px);
  max-height: 520px;
  margin: 0 auto;
  object-fit: contain;
}

@media (max-width: 900px) {
  .student-inline-figures.two-up {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1200px) {
  main {
    grid-template-columns: 1fr;
  }

  body.student-mode main {
    grid-template-columns: minmax(240px, 290px) minmax(0, 1fr);
    grid-template-areas:
      "left preview"
      "clear preview"
      "list preview";
  }

  body.student-mode #topicPanel {
    left: 16px;
  }
}

@media (max-width: 760px) {
  body.student-mode main {
    grid-template-columns: 1fr;
    grid-template-areas:
      "left"
      "clear"
      "list"
      "preview";
  }

  body.student-mode #previewPanel {
    position: static;
    max-height: none;
  }

  body.student-mode #questionList {
    max-height: 174px;
  }

  body.student-mode #topicPanel {
    inset: 70px 12px auto 12px;
    width: auto;
    max-height: calc(100vh - 84px);
  }
}

/* Header layout */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-btn {
  width: auto;
  margin: 0;
  padding: 5px 12px;
  font-size: 0.85rem;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.header-btn:hover {
  background: #f0f0f0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  width: min(640px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-close-btn {
  width: auto;
  margin: 0;
  padding: 4px 10px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.modal-close-btn:hover {
  background: #f0f0f0;
}

.modal-hint {
  margin: 0;
  font-size: 0.88rem;
  color: #5f6062;
}

/* Tag cleanup list */
#tagCleanupList {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cleanup-loading,
.cleanup-empty,
.cleanup-error {
  margin: 0;
  font-size: 0.9rem;
  color: #5f6062;
}

.cleanup-error {
  color: #8f2e2a;
}

.tag-cleanup-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  flex-wrap: wrap;
}

.tag-cleanup-row.tag-cleanup-duplicate {
  border-color: #e6a817;
  background: #fffbf0;
}

.tag-cleanup-chip {
  flex-shrink: 0;
}

.tag-cleanup-count {
  font-size: 0.85rem;
  color: #5f6062;
  flex: 1;
}

.tag-cleanup-rename-btn {
  font-size: 0.82rem;
  padding: 3px 8px;
  flex-shrink: 0;
}

.duplicate-warn {
  color: #c97a00;
  font-size: 0.8rem;
}

/* Rename inline form */
.tag-rename-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 6px;
}

.rename-arrow {
  color: #888;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.rename-input {
  width: auto;
  flex: 1;
  min-width: 120px;
  margin: 0;
  padding: 4px 8px;
  font-size: 0.9rem;
}

.rename-apply-btn {
  width: auto;
  margin: 0;
  padding: 4px 10px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.rename-cancel-btn {
  font-size: 0.85rem;
  flex-shrink: 0;
}

.rename-status {
  font-size: 0.82rem;
}

.rename-status.saving {
  color: #7a5f11;
}

.rename-status.saved {
  color: #276738;
}

.rename-status.error {
  color: #8f2e2a;
}

/* Tag page map modal */
.modal-box-wide {
  width: min(860px, 95vw);
}

.tagmap-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}

.tagmap-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tagmap-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tagmap-section-title {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
}

.dirty-badge {
  font-size: 0.8rem;
  color: #7a5f11;
  background: #fff8e0;
  border: 1px solid #e6c84a;
  border-radius: 999px;
  padding: 2px 8px;
}

.tagmap-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.tagmap-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  flex-wrap: wrap;
}

.tagmap-tag-chip {
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tagmap-pages-input {
  flex: 1;
  min-width: 140px;
  margin: 0;
  padding: 4px 8px;
  font-size: 0.88rem;
}

.tagmap-delete-btn {
  flex-shrink: 0;
  font-size: 0.82rem;
  padding: 3px 8px;
  color: #8f2e2a;
  border-color: #e0b0ae;
}

.tagmap-tag-unmapped {
  opacity: 0.5;
}

.tagmap-add-mapping-btn {
  flex-shrink: 0;
  font-size: 0.82rem;
  padding: 3px 8px;
  color: #2a6e3f;
  border-color: #9dd0b0;
  background: #eaf7ef;
}

.tagmap-add-mapping-btn:hover {
  background: #d4f0e0;
}

.tagmap-unmapped-details {
  margin-top: 10px;
}

.tagmap-unmapped-summary {
  font-size: 0.82rem;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  padding: 4px 2px;
  user-select: none;
  list-style: none;
}

.tagmap-unmapped-summary::-webkit-details-marker {
  display: none;
}

.tagmap-unmapped-summary::before {
  content: "▶";
  font-size: 0.6rem;
  margin-right: 5px;
  display: inline-block;
  transition: transform 0.15s;
}

.tagmap-unmapped-details[open] .tagmap-unmapped-summary::before {
  transform: rotate(90deg);
}

.tagmap-unmapped-details .tagmap-row {
  background: #fafafa;
  border-color: #e8e8e8;
}

.tagmap-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #f9f9f9;
  border: 1px dashed var(--line);
  border-radius: 8px;
  flex-wrap: wrap;
}

.tagmap-new-input {
  flex: 1;
  min-width: 120px;
  margin: 0;
  padding: 4px 8px;
  font-size: 0.88rem;
}

.tagmap-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0;
}

.tagmap-run-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.run-result-note {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.run-result-note-header {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 2px;
}

.run-result-row {
  font-size: 0.82rem;
  padding: 2px 6px;
  display: flex;
  gap: 6px;
  align-items: baseline;
  flex-wrap: wrap;
}

.run-result-qid {
  font-weight: 600;
  color: #0f4f6d;
  flex-shrink: 0;
}

.run-result-before {
  color: #999;
}

.run-result-after {
  color: #276738;
}

.run-result-added {
  color: #276738;
  font-weight: 600;
}

/* --- Page Videos Modal --- */

.pv-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 2px;
}

.pv-page-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
  padding: 2px;
}

.pv-page-pill {
  margin: 0;
}

.pv-page-pill.active {
  border-color: var(--accent);
  background: #dff2ff;
  color: #0f4f6d;
}

.pv-detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.pv-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.pv-video-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}

.pv-video-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pv-video-input {
  width: auto;
  margin: 0;
  padding: 4px 8px;
  font-size: 0.88rem;
}

.pv-title-input {
  flex: 0 0 200px;
}

.pv-url-input {
  flex: 1;
  min-width: 0;
}

.pv-remove-btn {
  flex-shrink: 0;
  padding: 3px 8px;
}

.pv-add-video-row {
  padding-top: 4px;
}

/* ===== STUDENT MODE REDESIGN ===== */

/* --- Base & Background --- */
body.student-mode {
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #e8f4fd 0%, #ddeefa 40%, #eef6ff 100%);
  min-height: 100vh;
}

/* --- Header --- */
body.student-mode header {
  background: linear-gradient(90deg, #0f3460 0%, #1a5db0 100%);
  border-bottom: none;
  box-shadow: 0 2px 16px rgba(15, 52, 96, 0.28);
  padding: 14px 24px;
}

body.student-mode h1 {
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  font-size: 1.45rem;
  color: #ffffff;
  letter-spacing: -0.01em;
}

/* --- Panels --- */
body.student-mode .panel {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(180, 210, 240, 0.45);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(15, 52, 96, 0.08), 0 1px 4px rgba(15, 52, 96, 0.06);
  padding: 14px 16px;
}

body.student-mode .panel h2 {
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7aa3c2;
  margin: 0 0 10px 0;
}

/* --- Note chips (Notes selector row) --- */
body.student-mode #noteChipRow .pill {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(150, 195, 230, 0.6);
  color: #1a3d5c;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

body.student-mode #noteChipRow .pill:hover {
  background: rgba(220, 240, 255, 0.85);
  border-color: #7ab8d9;
}

body.student-mode #noteChipRow .note-chip.active {
  background: #0f3460;
  border-color: #0f3460;
  color: #ffffff;
  font-weight: 600;
}

/* --- Max page panel --- */
body.student-mode #maxPageInput {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(150, 195, 230, 0.7);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.88rem;
  color: #1a3d5c;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  box-sizing: border-box;
}

body.student-mode #maxPageInput:focus {
  outline: none;
  border-color: #1a5db0;
  box-shadow: 0 0 0 3px rgba(26, 93, 176, 0.18);
  background: rgba(255, 255, 255, 0.92);
}

body.student-mode #maxPageInput::placeholder {
  color: rgba(26, 61, 92, 0.4);
}

/* --- Filter input --- */
body.student-mode #filterInput {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(150, 195, 230, 0.7);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.88rem;
  color: #1a3d5c;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 0.15s, box-shadow 0.15s;
  margin-top: 0;
  margin-bottom: 0;
  width: 100%;
}

body.student-mode #filterInput:focus {
  outline: none;
  border-color: #1a5db0;
  box-shadow: 0 0 0 3px rgba(26, 93, 176, 0.18);
  background: rgba(255, 255, 255, 0.92);
}

body.student-mode #filterInput::placeholder {
  color: #8fb4cc;
}

/* --- Question list buttons --- */
body.student-mode .question-btn {
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(170, 205, 230, 0.5);
  border-radius: 10px;
  color: #1a3d5c;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 8px 12px;
  transition: background 0.14s, border-color 0.14s, box-shadow 0.14s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

body.student-mode .question-btn:hover {
  background: rgba(210, 235, 255, 0.8);
  border-color: #90c0de;
  box-shadow: 0 2px 8px rgba(15, 52, 96, 0.08);
}

body.student-mode .question-btn.active {
  background: rgba(219, 237, 255, 0.9);
  border-color: #1a5db0;
  border-left: 4px solid #1a5db0;
  color: #0f3460;
  font-weight: 600;
  outline: none;
  box-shadow: 0 2px 10px rgba(26, 93, 176, 0.14);
  padding-left: 10px;
}

body.student-mode .question-btn.reviewed {
  background: rgba(212, 245, 232, 0.65);
  border-color: rgba(77, 207, 161, 0.5);
  color: #0d5c38;
}

body.student-mode .question-btn.reviewed.active {
  background: rgba(195, 238, 218, 0.9);
  border-color: #0d9e5e;
  border-left: 4px solid #0d9e5e;
  color: #0a4a2d;
  outline: none;
  padding-left: 10px;
}

/* --- Topic pills --- */
body.student-mode .topic-pill {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-weight: 500;
  padding: 4px 11px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(150, 195, 230, 0.55);
  color: #1a3d5c;
  border-radius: 999px;
  transition: background 0.14s, border-color 0.14s, color 0.14s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

body.student-mode .topic-pill:hover {
  background: rgba(210, 235, 255, 0.85);
  border-color: #80b4d4;
}

body.student-mode .topic-pill.active {
  background: #1a5db0;
  border-color: #1a5db0;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(26, 93, 176, 0.25);
}

/* --- Topic clear button --- */
body.student-mode .topic-clear-btn {
  font-size: 0.73rem;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid rgba(240, 160, 170, 0.7);
  background: rgba(253, 232, 235, 0.8);
  color: #9b2335;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

body.student-mode .topic-clear-btn:hover {
  background: rgba(251, 208, 214, 0.9);
  border-color: rgba(232, 145, 158, 0.85);
}

/* --- Student meta card --- */
body.student-mode .student-meta {
  background: linear-gradient(135deg, rgba(219, 237, 255, 0.75) 0%, rgba(235, 247, 255, 0.85) 100%);
  border: 1px solid rgba(160, 205, 240, 0.5);
  border-radius: 14px;
  padding: 12px 14px;
  gap: 9px;
  box-shadow: 0 2px 10px rgba(15, 52, 96, 0.07);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* --- Pill label --- */
body.student-mode .pill-label {
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #7aa3c2;
  padding-top: 5px;
}

/* --- ID pill --- */
body.student-mode .id-pill {
  background: #0f3460;
  border-color: #0f3460;
  color: #ffffff;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

/* --- Set pill --- */
body.student-mode .set-pill {
  background: rgba(220, 240, 255, 0.6);
  border-color: rgba(130, 185, 220, 0.5);
  color: #1a3d5c;
  font-weight: 500;
}

/* --- Page pills --- */
body.student-mode .page-pill {
  background: #d4f5e8;
  border-color: #4dcfa1;
  color: #0d5c38;
  font-weight: 600;
  font-size: 0.82rem;
}

/* --- Tag pills --- */
body.student-mode .tag-pill {
  background: #fef7e0;
  border-color: #e8c050;
  color: #6b4a00;
  font-weight: 500;
  font-size: 0.82rem;
}

/* --- Video collapsible --- */
body.student-mode .video-details {
  margin-top: 6px;
}

body.student-mode .video-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

body.student-mode .video-summary::-webkit-details-marker {
  display: none;
}

body.student-mode .video-summary .pill-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

body.student-mode .video-summary .pill-label::before {
  content: "▶";
  font-size: 0.6rem;
  transition: transform 0.15s;
  display: inline-block;
}

body.student-mode .video-details[open] .video-summary .pill-label::before {
  transform: rotate(90deg);
}

body.student-mode .video-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: #666;
}

body.student-mode .video-details .video-link-list {
  margin-top: 6px;
}

/* --- Video row & links --- */

body.student-mode .video-link-list {
  flex: 1;
  gap: 6px;
  display: flex;
  flex-direction: column;
  list-style: none;
  margin: 0;
  padding: 0;
}

body.student-mode .video-link-list a {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 238, 238, 0.7);
  border: 1px solid rgba(220, 160, 160, 0.45);
  border-radius: 10px;
  color: #7a1515;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.14s, box-shadow 0.14s, border-color 0.14s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

body.student-mode .video-link-list a::before {
  content: "▶";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  min-width: 22px;
  height: 22px;
  background: #cc0000;
  color: #ffffff;
  font-size: 0.65rem;
  border-radius: 5px;
  flex-shrink: 0;
  padding-left: 1px;
}

body.student-mode .video-link-list a:hover {
  background: rgba(255, 218, 218, 0.9);
  border-color: rgba(200, 100, 100, 0.55);
  box-shadow: 0 3px 12px rgba(180, 20, 20, 0.12);
  text-decoration: none;
  color: #5a0e0e;
}

/* --- Question content area --- */
body.student-mode .student-question {
  background: #ffffff;
  border: none;
  border-radius: 16px;
  padding: 28px 32px;
  min-height: 400px;
  width: min(100%, 760px);
  margin: 0 auto;
  box-shadow: 0 6px 28px rgba(15, 52, 96, 0.1), 0 1px 6px rgba(15, 52, 96, 0.07);
  line-height: 1.65;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.95rem;
  color: #1a2d3d;
}

/* --- Hide preview panel heading in student mode --- */
body.student-mode #previewPanel h2 {
  display: none;
}

/* --- Scrollbar refinements for student mode panels --- */
body.student-mode #questionList::-webkit-scrollbar,
body.student-mode #noteChipRow::-webkit-scrollbar,
body.student-mode .topic-rail::-webkit-scrollbar {
  width: 5px;
}

body.student-mode #questionList::-webkit-scrollbar-track,
body.student-mode #noteChipRow::-webkit-scrollbar-track,
body.student-mode .topic-rail::-webkit-scrollbar-track {
  background: transparent;
}

body.student-mode #questionList::-webkit-scrollbar-thumb,
body.student-mode #noteChipRow::-webkit-scrollbar-thumb,
body.student-mode .topic-rail::-webkit-scrollbar-thumb {
  background: rgba(120, 175, 215, 0.55);
  border-radius: 999px;
}
