:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #5d6972;
  --line: #dbe2e5;
  --page: #f6f7f4;
  --panel: #ffffff;
  --green: #2f7d5a;
  --green-soft: #e5f3ec;
  --amber: #b87920;
  --amber-soft: #fff1d6;
  --red: #b84848;
  --red-soft: #fae4e2;
  --teal: #226d73;
  --teal-soft: #dff1f2;
  --violet: #5c5b9c;
  --violet-soft: #e9e9f6;
  --blue: #326a9b;
  --blue-soft: #e2eef7;
  --gold: #946f16;
  --gold-soft: #fff4c2;
  --shadow: 0 18px 45px rgba(42, 53, 58, 0.12);
  --radius: 8px;
  font-family: "Century Gothic", "Aptos", "Segoe UI", Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f7f7;
  --muted: #b7c4c8;
  --line: #34484d;
  --page: #101819;
  --panel: #172326;
  --green: #5bd889;
  --green-soft: #173b28;
  --amber: #f7bd5f;
  --amber-soft: #3a2b12;
  --red: #ff8b86;
  --red-soft: #3d2023;
  --teal: #58b7bf;
  --teal-soft: #1b3b40;
  --violet: #aaa8ee;
  --violet-soft: #292946;
  --blue: #8cc6f2;
  --blue-soft: #193246;
  --gold: #f1cf64;
  --gold-soft: #3d3418;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
}

body.online-locked .app-shell {
  display: none;
}

.online-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(34, 109, 115, 0.1), rgba(139, 30, 30, 0.08)),
    var(--page);
}

.online-gate[hidden] {
  display: none;
}

.online-gate-card {
  width: min(500px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.online-gate-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.online-school {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
}

.online-gate-logo {
  width: 108px;
  max-width: 34%;
  height: auto;
  object-fit: contain;
}

.online-gate-card h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.05;
}

.online-gate-card label {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
}

.online-gate-card button {
  width: 100%;
  margin-top: 12px;
  background: var(--teal);
}

.online-gate-status {
  min-height: 20px;
  margin: 12px 0 0;
  color: #8b1e1e;
  font-weight: 800;
}

.teacher-selector {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.teacher-selector[hidden] {
  display: none;
}

.teacher-selector select {
  margin-top: 6px;
}

.teacher-selector button {
  margin-top: 10px;
}

:root[data-theme="dark"] .online-gate-status {
  color: var(--red);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

button.secondary {
  background: #edf1f0;
  color: var(--ink);
  border: 1px solid var(--line);
}

button.danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid #efc1bd;
}

button.compact {
  min-height: 34px;
  padding: 0 12px;
}

.print-button {
  min-width: 92px;
  padding: 0 18px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  line-height: 1.4;
}

label span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
  background: #edf1f0;
  color: var(--teal);
  border: 1px solid var(--line);
  font-weight: 800;
  line-height: 1;
}

.app-shell.sidebar-collapsed .sidebar {
  padding: 54px 10px 16px;
  align-items: center;
  gap: 14px;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  right: 50%;
  transform: translateX(50%);
}

.app-shell.sidebar-collapsed .brand {
  justify-items: center;
}

.app-shell.sidebar-collapsed .brand-top {
  justify-content: center;
}

.app-shell.sidebar-collapsed .brand-logo,
.app-shell.sidebar-collapsed .brand-text,
.app-shell.sidebar-collapsed .nav-tabs,
.app-shell.sidebar-collapsed .storage-panel {
  display: none;
}

.app-shell.sidebar-collapsed .brand-mark {
  width: 48px;
  height: 48px;
  font-size: 0.9rem;
}

.brand {
  display: grid;
  gap: 8px;
  align-items: start;
}

.brand-top {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1,
.brand p,
.view-header h2,
.view-header p,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 1.22rem;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.brand-logo {
  display: block;
  width: min(128px, 100%);
  height: auto;
}

.brand-text {
  padding-left: 2px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  background: transparent;
  color: var(--muted);
  text-align: left;
  border: 1px solid transparent;
  font-weight: 700;
  line-height: 1.2;
}

.nav-tab span {
  display: block;
}

.view-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-tab.active {
  background: var(--teal-soft);
  color: var(--teal);
  border-color: #b9dde0;
  font-weight: 700;
}

.storage-panel {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.storage-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.storage-actions button {
  padding: 0 8px;
}

.student-code-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  margin: 8px 0 0;
  word-break: break-word;
}

.logout-button {
  width: 100%;
  margin-top: 10px;
}

.save-status {
  color: #8b1e1e;
  font-size: 0.78rem;
  font-weight: 700;
  margin: 10px 0 0;
}

.main-content {
  padding: 30px;
  max-width: 1480px;
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.view-header h2 {
  font-size: clamp(1.7rem, 3vw, 2.55rem);
  line-height: 1.1;
  margin-top: 4px;
  letter-spacing: 0;
}

.dashboard-header-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.dashboard-student-name {
  color: var(--teal);
  font-size: clamp(1.15rem, 2vw, 1.65rem);
  line-height: 1.1;
  text-align: right;
  min-width: 0;
  max-width: 300px;
}

.dashboard-student-name.is-empty {
  display: none;
}

.view-header-actions .dashboard-student-name {
  align-self: center;
}

.date-card,
.inline-summary {
  min-width: 210px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.date-card span,
.inline-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.date-card strong,
.inline-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong {
  display: block;
  font-size: 1.8rem;
  margin-top: 6px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr);
  gap: 16px;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h3 {
  font-size: 1.05rem;
}

.panel-header select {
  max-width: 230px;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.subject-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.subject-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.subject-card h4,
.concept-card h4,
.exam-card h4 {
  margin: 0;
  font-size: 0.98rem;
}

.subject-card p,
.concept-card p,
.exam-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.88rem;
}

.progress-track {
  height: 10px;
  background: #e9eeee;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--green));
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-row span {
  background: #f4f6f6;
  border-radius: var(--radius);
  padding: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.stat-row strong {
  color: var(--ink);
  display: block;
  font-size: 0.95rem;
}

.focus-list,
.exam-list,
.concept-list {
  display: grid;
  gap: 10px;
}

.focus-list {
  gap: 6px;
}

.focus-item,
.exam-card,
.concept-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px 12px;
}

.focus-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.focus-item.unsure-item {
  padding: 7px 10px;
}

.compact-tabs {
  margin-bottom: 12px;
  gap: 6px;
}

.compact-tabs .subject-tab {
  min-height: 32px;
  padding: 0 9px;
  font-size: 0.74rem;
}

.unsure-group {
  display: grid;
  gap: 6px;
}

.unsure-group > h4 {
  margin: 2px 0 0;
  color: #8b1e1e;
  font-size: 0.88rem;
}

.selected-support-group h4 {
  font-size: 1rem;
}

.unsure-item h4 {
  font-size: 0.8rem;
  color: var(--ink);
  line-height: 1.2;
}

.unsure-item p {
  margin-top: 3px;
  font-size: 0.72rem;
  line-height: 1.25;
}

.resolved-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 28px;
  padding: 0 8px;
  background: #f8faf9;
  white-space: nowrap;
}

.resolved-check input {
  width: 14px;
  min-height: 14px;
}

.resolved-check span {
  margin: 0;
  color: var(--ink);
  font-size: 0.72rem;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(180px, 0.55fr) minmax(260px, 0.9fr);
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.subject-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: start;
}

.subject-tab {
  min-height: 38px;
  padding: 0 12px;
  background: #f3f7f7;
  border: 1px solid var(--line);
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 700;
}

.subject-tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.concept-card {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.7fr) minmax(240px, 0.55fr);
  gap: 12px;
  align-items: stretch;
}

.concept-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #edf1f0;
  color: var(--muted);
}

.chip.Mastered {
  background: var(--green-soft);
  color: var(--green);
}

.chip.Building {
  background: var(--amber-soft);
  color: var(--amber);
}

.chip.Needs-support {
  background: var(--red-soft);
  color: var(--red);
}

.chip.Not-yet-started {
  background: var(--violet-soft);
  color: var(--violet);
}

.concept-controls {
  display: grid;
  gap: 8px;
  align-content: start;
}

.choice-group {
  display: grid;
  gap: 6px;
}

.choice-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.choice-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.choice-button {
  min-height: 28px;
  border: 1px solid #d5dcdf;
  background: #eef2f2;
  color: #4f5c63;
  padding: 0 7px;
  font-size: 0.72rem;
  font-weight: 700;
}

.choice-button.is-selected {
  background: #34464f;
  color: #fff;
  border-color: #34464f;
}

.choice-button.status-Mastered.is-selected {
  background: #bfe4ce;
  color: #1f6545;
  border-color: #78bf96;
}

.choice-button.status-Building.is-selected {
  background: #ffd888;
  color: #7a4d0d;
  border-color: #dda94d;
}

.choice-button.status-Needs-support.is-selected {
  background: #f7bdb8;
  color: #9e2626;
  border-color: #de817a;
}

.concept-notes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.concept-notes textarea {
  min-width: 0;
  min-height: 52px;
  height: 52px;
  max-height: 52px;
  resize: none;
  overflow-y: auto;
}

.selected-concept-subject {
  margin: 0 0 10px;
  color: #8b1e1e;
  font-size: 1.55rem;
  line-height: 1.1;
}

.error-note-list {
  display: grid;
  gap: 12px;
}

.selected-subject-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 12px;
}

.selected-error-subject {
  flex: 1;
  margin: 0;
  color: #8b1e1e;
  font-size: 1.55rem;
  line-height: 1.1;
}

.error-note-filters {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(360px, 520px);
  gap: 10px;
  margin: 10px 0 12px;
}

.error-note-filters label {
  display: grid;
  gap: 5px;
}

.error-note-filters span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

#addErrorNoteBtn,
#addAvailableExamRowBtn {
  flex: 0 0 auto;
  background: var(--teal);
  color: #fff;
  border: 1px solid var(--teal);
  font-weight: 800;
}

.error-note-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}

.error-note-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.error-note-fields {
  display: grid;
  grid-template-columns: minmax(130px, 150px) minmax(260px, 1fr);
  gap: 10px;
  width: 100%;
  max-width: none;
  align-items: end;
}

.error-note-fields.has-exam {
  grid-template-columns: minmax(130px, 150px) minmax(92px, 120px) minmax(260px, 1fr);
}

.error-question-field.is-hidden {
  display: none;
}

.error-concept-field {
  min-width: 0;
}

.error-concept-field select,
#errorConceptFilter {
  font-size: 0.78rem;
  line-height: 1.15;
}

.error-note-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.55fr) minmax(440px, 1.45fr);
  gap: 12px;
  align-items: start;
}

.error-note-body textarea {
  min-height: 56px;
  height: auto;
  max-height: none;
  resize: none;
  overflow: hidden;
}

.error-notes-field {
  min-width: 0;
}

.error-image-panel {
  display: grid;
  gap: 8px;
}

.error-image-drop {
  border: 1px dashed #aab8bc;
  border-radius: var(--radius);
  background: #f8faf9;
  min-height: 126px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  text-align: center;
}

.error-image-drop.has-image {
  min-height: 0;
  padding: 6px;
  background: #fff;
  cursor: zoom-in;
}

.error-image-drop.is-dragging,
.error-image-drop:focus {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  background: var(--teal-soft);
}

.error-image-drop img {
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  display: block;
  background: #fff;
}

.error-image-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.error-image-actions .compact {
  min-height: 28px;
  padding: 0 9px;
  font-size: 0.74rem;
}

.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 32px;
  background: rgba(10, 18, 22, 0.88);
  cursor: zoom-out;
}

.image-preview-overlay img {
  max-width: min(1120px, 96vw);
  max-height: 88vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
}

.image-preview-close {
  position: fixed;
  top: 18px;
  right: 18px;
  min-height: 36px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  cursor: pointer;
}

.error-print-area {
  display: none;
}

.planner-panel {
  padding: 0;
  overflow: hidden;
}

.available-exams {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.planner-panel .available-exams .panel-header {
  padding: 0;
  border-bottom: 0;
}

.available-exams .panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.available-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selected-exam-subject {
  margin: 2px 0 0;
  font-size: 1.55rem;
  line-height: 1.1;
  color: #8b1e1e;
}

.exam-download-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.exam-download-panel .panel-header {
  padding: 0;
  border-bottom: 0;
}

.exam-download-panel .panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.selected-download-subject {
  margin: 0;
  color: #8b1e1e;
  font-size: 1.55rem;
  line-height: 1.1;
}

.download-code-control {
  max-width: 320px;
}

.download-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.download-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  min-height: 112px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  gap: 12px;
}

.download-card span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.download-card a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.download-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.download-card.unavailable {
  background: #f8faf9;
}

.download-card.fallback {
  background: #fffaf0;
  border-color: #ead7a7;
}

.download-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.exam-entry-table {
  display: grid;
  gap: 6px;
}

.exam-entry-row {
  display: grid;
  grid-template-columns: 110px 150px 120px 86px 74px;
  gap: 8px;
  align-items: center;
}

.exam-entry-row select {
  min-height: 36px;
}

.exam-entry-row strong {
  font-size: 0.9rem;
}

.exam-entry-row button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 0.76rem;
}

.exam-entry-heading {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.exam-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
}

.exam-chip-list .chip {
  background: var(--blue-soft);
  color: var(--blue);
}

.planner-panel .panel-header {
  padding: 18px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}

.planner-scroll {
  overflow: auto;
  max-height: calc(100vh - 190px);
}

.planner-print-area {
  display: none;
}

.exam-planner {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  table-layout: fixed;
}

.exam-planner th,
.exam-planner td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.exam-planner thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  min-width: 84px;
  width: 84px;
  padding: 6px 5px;
  background: #f3f7f7;
  text-align: left;
}

.exam-planner thead th span,
.exam-planner thead th strong {
  display: block;
}

.exam-planner thead th span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.exam-planner thead th strong {
  margin-top: 2px;
  font-size: 0.72rem;
}

.exam-planner thead th.week-heading,
.planner-cell.weekly-planner-cell {
  min-width: 132px;
  width: 132px;
}

.week-heading-inner {
  display: grid;
  gap: 3px;
}

.exam-planner thead th .week-date,
.exam-planner thead th .week-count {
  margin: 0;
}

.exam-planner thead th .week-date {
  border-top: 1px solid var(--line);
  padding-top: 3px;
  text-align: left;
  white-space: nowrap;
}

.exam-planner thead th .week-count {
  color: #8b1e1e;
  text-align: left;
  white-space: nowrap;
}

.exam-planner thead th.is-current-week .week-count {
  background: #0f6870;
  color: #fff;
  border-radius: 4px;
  padding: 4px 6px;
}

.exam-planner .subject-heading,
.exam-planner .subject-cell {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 170px;
  width: 170px;
  background: #fff;
}

.exam-planner .exam-count-heading,
.exam-planner .exam-count-cell {
  position: sticky;
  left: 170px;
  z-index: 4;
  min-width: 58px;
  width: 58px;
  background: #fff;
  text-align: center;
}

.exam-planner .subject-heading {
  background: #e6f1f2;
}

.exam-planner .exam-count-heading {
  background: #e6f1f2;
}

.exam-planner .exam-count-heading span,
.exam-planner .exam-count-cell span {
  display: block;
  line-height: 1.05;
}

.exam-planner .exam-count-heading span + span,
.exam-planner .exam-count-cell span + span {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 4px;
}

.exam-planner .subject-cell {
  padding: 5px 8px;
  font-weight: 800;
  color: var(--ink);
  text-align: left;
  font-size: 0.82rem;
}

.exam-planner .exam-count-cell {
  padding: 4px 5px;
  font-weight: 800;
  color: #8b1e1e;
  font-size: 0.82rem;
  vertical-align: middle;
}

.exam-count-stack {
  position: absolute;
  top: 50%;
  left: 5px;
  right: 5px;
  display: grid;
  transform: translateY(-50%);
}

.exam-count-complete {
  color: #1f8f46;
}

.exam-planner .concept-study-row .subject-cell,
.exam-planner .concept-study-row .exam-count-cell {
  background: #fff8dc;
}

.exam-planner .concept-study-row .subject-cell {
  color: #8b1e1e;
}

.planner-cell {
  min-width: 84px;
  width: 84px;
  height: 34px;
  padding: 0;
  line-height: 0;
  vertical-align: middle;
}

.planner-cell input {
  display: block;
  width: 100%;
  height: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  padding: 4px 5px;
  background: transparent;
  color: var(--ink);
  font-size: 0.72rem;
}

.planner-cell select {
  display: block;
  width: 100%;
  height: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  padding: 4px 5px;
  background: transparent;
  color: var(--ink);
  font-size: 0.72rem;
}

.planner-cell input:focus,
.planner-cell select:focus {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
  background: var(--teal-soft);
}

.planner-cell.is-weekend input,
.planner-cell.is-weekend select {
  background: #faf8ef;
}

.planner-cell.is-filled input,
.planner-cell.is-filled select,
.planner-cell select.is-filled {
  background: #6f7c82;
  color: #fff;
  font-weight: 800;
}

.planner-cell.is-distributed input,
.planner-cell.is-distributed select,
.planner-cell select.is-distributed {
  background: #f2a84b;
  color: #281a06;
  font-weight: 800;
}

.planner-cell.is-complete input,
.planner-cell.is-complete select,
.planner-cell select.is-complete {
  background: #34c759;
  color: #fff;
  font-weight: 800;
}

.planner-cell.is-filled select option,
.planner-cell.is-distributed select option,
.planner-cell.is-complete select option,
.planner-cell select.is-filled option,
.planner-cell select.is-distributed option,
.planner-cell select.is-complete option {
  color: var(--ink);
  background: #fff;
}

.planner-cell.concept-study-cell.is-filled select {
  background: var(--gold-soft);
  color: transparent;
  font-size: 0.66rem;
}

.planner-cell.concept-study-cell {
  position: relative;
  height: 34px;
  min-height: 34px;
  line-height: 1.1;
}

.planner-cell.concept-study-cell select {
  height: 34px;
  min-height: 34px;
  padding-right: 18px;
}

.planner-cell.concept-study-cell.is-filled select option {
  color: var(--ink);
}

.weekly-planner-cell {
  height: 92px;
  min-height: 92px;
  padding: 4px;
  line-height: 1;
  vertical-align: top;
}

.planner-cell.concept-study-cell.weekly-planner-cell {
  height: 92px;
  min-height: 92px;
  padding: 4px;
  line-height: 1;
}

.weekly-slot-list {
  display: grid;
  gap: 4px;
}

.weekly-slot-list select {
  height: 26px;
  min-height: 26px;
  padding: 3px 5px;
  font-size: 0.68rem;
}

.planner-cell.concept-study-cell.weekly-planner-cell select {
  height: 26px;
  min-height: 26px;
  padding: 3px 5px;
  font-size: 0.62rem;
}

.concept-study-cell.weekly-planner-cell select.is-filled {
  background: var(--gold-soft);
  color: #5f4310;
  font-weight: 800;
}

.concept-study-display {
  position: absolute;
  inset: 4px 18px 4px 5px;
  z-index: 1;
  display: flex;
  align-items: center;
  color: #5f4310;
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.08;
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.planner-cell select:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.planner-cell.is-exam {
  background: var(--red-soft);
  color: var(--red);
  height: 66px;
  min-height: 66px;
  padding: 4px 5px;
  font-weight: 800;
  vertical-align: top;
  line-height: 1.08;
}

.exam-marker {
  display: grid;
  gap: 2px;
  align-content: center;
  min-height: 56px;
  overflow-wrap: anywhere;
}

.exam-marker span {
  font-size: 0.58rem;
  line-height: 1.08;
}

.exam-marker small {
  color: var(--red);
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 1.08;
}

.exam-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.exam-card {
  display: grid;
  gap: 8px;
}

.exam-card strong {
  font-size: 1.7rem;
}

.empty-state {
  border: 1px dashed #bac6c8;
  border-radius: var(--radius);
  padding: 22px;
  color: var(--muted);
  display: grid;
  gap: 4px;
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.settings-panel .panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.danger-zone {
  margin-top: 14px;
}

.danger-zone .panel-header {
  margin-bottom: 0;
}

.subject-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.subject-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #f8faf9;
  font-weight: 700;
}

.subject-toggle input {
  width: 18px;
  min-height: 18px;
}

.subject-toggle span {
  margin: 0;
  color: var(--ink);
  font-size: 0.88rem;
}

.appearance-panel {
  margin-top: 14px;
}

.appearance-panel .panel-header {
  margin-bottom: 0;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.theme-switch span {
  margin: 0;
  color: var(--ink);
  font-size: 0.92rem;
}

.theme-switch input {
  position: absolute;
  width: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.theme-switch b {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #dde5e5;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.theme-switch b::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(23, 32, 38, 0.22);
  transition: transform 0.18s ease;
}

.theme-switch input:checked + b {
  background: var(--teal);
  border-color: var(--teal);
}

.theme-switch input:checked + b::after {
  transform: translateX(24px);
}

.theme-switch input:focus-visible + b {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

:root[data-theme="dark"] body {
  background: var(--page);
  color: var(--ink);
}

:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .date-card,
:root[data-theme="dark"] .inline-summary,
:root[data-theme="dark"] .metric,
:root[data-theme="dark"] .subject-card,
:root[data-theme="dark"] .focus-item,
:root[data-theme="dark"] .exam-card,
:root[data-theme="dark"] .concept-card,
:root[data-theme="dark"] .filter-bar,
:root[data-theme="dark"] .error-note-card,
:root[data-theme="dark"] .download-card,
:root[data-theme="dark"] .empty-state {
  background: var(--panel);
  border-color: var(--line);
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: #101b1e;
  color: var(--ink);
  border-color: var(--line);
}

:root[data-theme="dark"] select option {
  background: #172326;
  color: var(--ink);
}

:root[data-theme="dark"] button.secondary,
:root[data-theme="dark"] .sidebar-toggle,
:root[data-theme="dark"] .subject-tab,
:root[data-theme="dark"] .subject-toggle,
:root[data-theme="dark"] .resolved-check,
:root[data-theme="dark"] .stat-row span,
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .choice-button,
:root[data-theme="dark"] .error-image-drop,
:root[data-theme="dark"] .download-card.unavailable {
  background: #203034;
  color: var(--ink);
  border-color: var(--line);
}

:root[data-theme="dark"] button:not(.secondary):not(.danger):not(.nav-tab):not(.subject-tab):not(.choice-button):not(.sidebar-toggle) {
  background: #2b7f87;
  color: #fff;
  border: 1px solid var(--teal);
}

:root[data-theme="dark"] #addErrorNoteBtn,
:root[data-theme="dark"] #addAvailableExamRowBtn {
  background: #2b7f87;
  color: #fff;
  border-color: var(--teal);
}

:root[data-theme="dark"] .nav-tab {
  color: var(--muted);
}

:root[data-theme="dark"] .nav-tab.active,
:root[data-theme="dark"] .subject-tab.active {
  background: var(--teal-soft);
  color: var(--ink);
  border-color: var(--teal);
}

:root[data-theme="dark"] .subject-tab.active {
  background: #2b7f87;
  color: #fff;
}

:root[data-theme="dark"] .progress-track {
  background: #263538;
}

:root[data-theme="dark"] .chip.Mastered,
:root[data-theme="dark"] .choice-button.status-Mastered.is-selected {
  background: var(--green-soft);
  color: var(--green);
  border-color: #2e8e58;
}

:root[data-theme="dark"] .chip.Building,
:root[data-theme="dark"] .choice-button.status-Building.is-selected {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #a8732e;
}

:root[data-theme="dark"] .chip.Needs-support,
:root[data-theme="dark"] .choice-button.status-Needs-support.is-selected {
  background: var(--red-soft);
  color: var(--red);
  border-color: #9f4a4a;
}

:root[data-theme="dark"] .chip.Not-yet-started,
:root[data-theme="dark"] .choice-button.is-selected {
  background: #2c3f47;
  color: #fff;
  border-color: #4f6770;
}

:root[data-theme="dark"] .selected-concept-subject,
:root[data-theme="dark"] .selected-error-subject,
:root[data-theme="dark"] .selected-exam-subject,
:root[data-theme="dark"] .selected-download-subject,
:root[data-theme="dark"] .unsure-group > h4,
:root[data-theme="dark"] .save-status,
:root[data-theme="dark"] .exam-planner .exam-count-cell,
:root[data-theme="dark"] .exam-planner .concept-study-row .subject-cell {
  color: #ff9f9a;
}

:root[data-theme="dark"] .download-card.fallback {
  background: #2f2917;
  border-color: #6d5728;
}

:root[data-theme="dark"] .error-image-drop.has-image,
:root[data-theme="dark"] .error-image-drop img,
:root[data-theme="dark"] .image-preview-overlay img {
  background: #fff;
}

:root[data-theme="dark"] .image-preview-close {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line);
}

:root[data-theme="dark"] .theme-switch b {
  background: #25363a;
}

:root[data-theme="dark"] .theme-switch b::after {
  background: #eef4f5;
}

:root[data-theme="dark"] .exam-planner th,
:root[data-theme="dark"] .exam-planner td,
:root[data-theme="dark"] .exam-planner .subject-cell,
:root[data-theme="dark"] .exam-planner .exam-count-cell {
  background: #121d20;
  border-color: var(--line);
}

:root[data-theme="dark"] .exam-planner thead th,
:root[data-theme="dark"] .exam-planner .subject-heading,
:root[data-theme="dark"] .exam-planner .exam-count-heading {
  background: #1d3337;
}

:root[data-theme="dark"] .exam-planner thead th .week-count {
  color: #fff;
}

:root[data-theme="dark"] .planner-cell input,
:root[data-theme="dark"] .planner-cell select {
  background: transparent;
  color: var(--ink);
}

:root[data-theme="dark"] .planner-cell input:focus,
:root[data-theme="dark"] .planner-cell select:focus {
  background: var(--teal-soft);
}

:root[data-theme="dark"] .planner-cell.is-weekend input,
:root[data-theme="dark"] .planner-cell.is-weekend select {
  background: #192222;
}

:root[data-theme="dark"] .planner-cell.is-filled input,
:root[data-theme="dark"] .planner-cell.is-filled select,
:root[data-theme="dark"] .planner-cell select.is-filled {
  background: #6f7c82;
  color: #fff;
}

:root[data-theme="dark"] .planner-cell.is-distributed input,
:root[data-theme="dark"] .planner-cell.is-distributed select,
:root[data-theme="dark"] .planner-cell select.is-distributed {
  background: #f2a84b;
  color: #281a06;
}

:root[data-theme="dark"] .planner-cell.is-complete input,
:root[data-theme="dark"] .planner-cell.is-complete select,
:root[data-theme="dark"] .planner-cell select.is-complete {
  background: #34c759;
  color: #fff;
}

:root[data-theme="dark"] .planner-cell.is-filled select option,
:root[data-theme="dark"] .planner-cell.is-distributed select option,
:root[data-theme="dark"] .planner-cell.is-complete select option,
:root[data-theme="dark"] .planner-cell.concept-study-cell.is-filled select option,
:root[data-theme="dark"] .planner-cell select.is-filled option,
:root[data-theme="dark"] .planner-cell select.is-distributed option,
:root[data-theme="dark"] .planner-cell select.is-complete option {
  background: #172326;
  color: var(--ink);
}

:root[data-theme="dark"] .exam-planner .concept-study-row .subject-cell,
:root[data-theme="dark"] .exam-planner .concept-study-row .exam-count-cell,
:root[data-theme="dark"] .planner-cell.concept-study-cell.is-filled select,
:root[data-theme="dark"] .concept-study-cell.weekly-planner-cell select.is-filled {
  background: var(--gold-soft);
}

:root[data-theme="dark"] .concept-study-display {
  color: #f4d778;
}

:root[data-theme="dark"] .planner-cell.is-exam {
  background: var(--red-soft);
  color: var(--red);
}

@media (max-width: 1120px) {
  .app-shell,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .metrics-grid,
  .subject-grid,
  .exam-list,
  .download-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .main-content,
  .sidebar {
    padding: 18px;
  }

  .view-header,
  .panel-header,
  .focus-item,
  .dashboard-header-meta {
    display: grid;
  }

  .metrics-grid,
  .subject-grid,
  .filter-bar,
  .concept-card,
  .concept-notes,
  .error-note-top,
  .error-note-filters,
  .error-note-fields,
  .error-note-body,
  .exam-entry-row,
  .subject-toggle-grid,
  .exam-list,
  .download-links {
    grid-template-columns: 1fr;
  }

  .date-card,
  .inline-summary,
  .panel-header select {
    min-width: 0;
    max-width: none;
  }
}

@media print {
  :root[data-theme="dark"] body,
  :root[data-theme="dark"] .main-content,
  :root[data-theme="dark"] .panel,
  :root[data-theme="dark"] .exam-planner th,
  :root[data-theme="dark"] .exam-planner td,
  :root[data-theme="dark"] .exam-planner .subject-cell,
  :root[data-theme="dark"] .exam-planner .exam-count-cell {
    background: #fff;
    color: #172026;
  }

  .sidebar,
  .filter-bar,
  .view-header button {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .view {
    display: none;
  }

  body.printing-dashboard #dashboardView,
  body.printing-concepts #conceptsView,
  body.printing-planner #plannerView {
    display: block;
  }

  .main-content {
    padding: 0;
  }

  .panel,
  .exam-planner th,
  .exam-planner td {
    box-shadow: none;
  }

  .subject-card,
  .focus-item,
  .concept-card,
  .metric,
  .error-print-note {
    break-inside: avoid;
  }

  body.printing-planner .planner-panel,
  body.printing-planner .planner-scroll {
    overflow: visible;
    max-height: none;
  }

  body.printing-planner #plannerView > .planner-panel {
    display: none;
  }

  body.printing-planner .planner-print-area {
    display: block;
  }

  body.printing-planner .exam-planner thead th,
  body.printing-planner .exam-planner .subject-heading,
  body.printing-planner .exam-planner .subject-cell,
  body.printing-planner .exam-planner .exam-count-heading,
  body.printing-planner .exam-planner .exam-count-cell {
    position: static;
  }

  body.printing-planner .exam-planner {
    width: max-content;
    min-width: 100%;
  }

  body.printing-planner .exam-planner .exam-count-cell {
    position: relative;
  }

  body.printing-planner-a3 .main-content {
    width: 100%;
  }

  body.printing-planner-a3 .planner-print-area {
    font-size: 0.92rem;
  }

  body.printing-planner-a3 .planner-panel {
    border: 0;
  }

  body.printing-error-notes .view,
  body.printing-error-notes .sidebar,
  body.printing-error-notes .subject-tabs,
  body.printing-error-notes .error-note-filters,
  body.printing-error-notes .selected-subject-line,
  body.printing-error-notes .error-note-list,
  body.printing-error-notes .view-header {
    display: none;
  }

  body.printing-error-notes #plannerView {
    display: none;
  }

  body.printing-error-notes #errorNotesView {
    display: block;
  }

  body.printing-error-notes .error-print-area {
    display: block;
    font-family: "Century Gothic", Arial, sans-serif;
    color: #132126;
  }

  .error-print-header {
    border-bottom: 1px solid #d6e0e2;
    margin-bottom: 10mm;
    padding-bottom: 5mm;
  }

  .error-print-header h1 {
    margin: 0 0 2mm;
    font-size: 20pt;
  }

  .error-print-header h2 {
    margin: 0;
    color: #8b1e1e;
    font-size: 16pt;
  }

  .error-print-header p {
    margin: 3mm 0 0;
    font-size: 9pt;
  }

  .error-print-note {
    break-inside: avoid;
    border: 1px solid #d6e0e2;
    border-radius: 4px;
    padding: 5mm;
    margin-bottom: 6mm;
  }

  .error-print-note h4 {
    margin: 0 0 3mm;
    color: #8b1e1e;
    font-size: 11pt;
  }

  .error-print-note p {
    margin: 0 0 4mm;
    font-size: 9.5pt;
    line-height: 1.45;
  }

  .error-print-note img {
    max-width: 100%;
    max-height: 120mm;
    object-fit: contain;
    display: block;
    margin-top: 3mm;
  }

  .print-empty {
    font-size: 10pt;
  }
}
