:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #23395d;
  --primary-2: #1e3a5f;
  --deep-navy: #172033;
  --teal: #0f766e;
  --gold: #b7791f;
  --danger: #b91c1c;
  --success: #15803d;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --radius: 14px;
  --header-h: 56px;
  --sidebar-w: 260px;
  --sidebar-collapsed-w: 72px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1f2937;
  --surface-2: #111827;
  --text: #f9fafb;
  --muted: #d1d5db;
  --line: #374151;
  --primary: #dbeafe;
  --primary-2: #23395d;
  --teal: #7dd3c7;
  --gold: #d6a645;
  --danger: #fca5a5;
  --success: #86efac;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.72;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* ── App Layout ── */
.app-layout {
  min-height: 100vh;
  background: var(--bg);
}

.app-body {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ── Top Header ── */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.header-center {
  position: relative;
  flex: 1;
  max-width: 420px;
  min-width: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.header-app-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 4px;
}

.header-page-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  width: 100%;
}

.header-search:focus-within {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.08);
}

.header-search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  min-width: 0;
}

.search-icon {
  color: var(--muted);
  flex-shrink: 0;
}

.search-kbd {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 36px;
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

.pomo-header-btn {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12px;
}

.pomo-wrap {
  position: relative;
}

.pomo-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 300;
}

.pomo-dropdown strong {
  display: block;
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}

.pomo-label {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pomo-mode {
  margin: 0 0 12px;
  font-size: 13px;
}

.pomo-link {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--teal);
  font-weight: 600;
}

.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: block; }

.mobile-only { display: none; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 150;
  transition: width 0.22s ease, transform 0.22s ease;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  background: var(--primary-2);
  flex-shrink: 0;
}

.sidebar-brand-text strong {
  display: block;
  font-size: 14px;
  white-space: nowrap;
}

.sidebar-brand-text small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 1px;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: thin;
}

.nav-group {
  margin-bottom: 16px;
}

.nav-group-label {
  display: block;
  padding: 0 10px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  white-space: nowrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link.active {
  background: rgba(30, 58, 95, 0.1);
  color: var(--primary-2);
  font-weight: 600;
}

[data-theme="dark"] .nav-link.active {
  background: rgba(219, 234, 254, 0.08);
  color: var(--primary);
}

.nav-link .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
}

.nav-link.active .nav-icon { opacity: 1; }

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-backdrop {
  display: none;
}

/* Collapsed sidebar */
.app-layout.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-w);
}

.app-layout.sidebar-collapsed .sidebar-brand-text,
.app-layout.sidebar-collapsed .nav-group-label,
.app-layout.sidebar-collapsed .nav-link span:not(.nav-icon),
.app-layout.sidebar-collapsed .sidebar-collapse-btn span {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.app-layout.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.app-layout.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 10px;
}

.app-layout.sidebar-collapsed .sidebar-collapse-btn {
  justify-content: center;
  padding: 10px;
}

.app-layout.sidebar-collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.app-layout.sidebar-collapsed .nav-link[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--deep-navy);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 400;
  pointer-events: none;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  max-width: none;
  padding: 24px clamp(16px, 3vw, 32px) 32px;
  transition: margin-left 0.22s ease;
}

.app-layout.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-w);
}

.route-view {
  max-width: 1200px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
}

h1, h2, h3, h4 {
  line-height: 1.28;
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3vw, 34px);
  letter-spacing: -0.015em;
  font-weight: 750;
}

h2 {
  font-size: clamp(22px, 2.4vw, 26px);
  margin-bottom: 12px;
  font-weight: 720;
}

h3 {
  font-size: 18px;
  margin-bottom: 8px;
  font-weight: 680;
}

h4 {
  font-size: 15.5px;
  margin-bottom: 6px;
}

.top-actions,
.actions,
.button-row,
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 13px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

button:hover,
.button:hover {
  transform: none;
  box-shadow: none;
  background: var(--surface-2);
  border-color: #cbd5e1;
}

.primary {
  background: var(--primary-2);
  color: #ffffff;
  border-color: var(--primary-2);
}

[data-theme="dark"] .primary {
  background: #dbeafe;
  border-color: #dbeafe;
  color: #111827;
}

.primary:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.accent {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

[data-theme="dark"] .accent {
  color: #111827;
}

.gold {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--line);
}

.ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.icon-btn { min-width: 40px; }

.hero {
  display: block !important;
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.hero:after { content: none; }

.hero p {
  max-width: 760px;
  margin: 0 0 16px;
  color: var(--muted);
}

.hero h2 {
  color: var(--text);
  font-size: clamp(26px, 3vw, 32px);
  letter-spacing: -0.015em;
  margin-bottom: 8px;
}

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card.hover {
  transition: none;
}

.card.hover:hover {
  transform: none;
  border-color: #cbd5e1;
  box-shadow: var(--shadow);
}

.stat {
  display: grid;
  gap: 2px;
}

.stat b {
  font-size: 26px;
  letter-spacing: -0.02em;
  color: var(--primary);
  font-weight: 750;
}

.stat span,
.muted {
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 650;
  width: fit-content;
  max-width: 100%;
}

.tag.teal { color: var(--teal); }
.tag.gold { color: var(--gold); }
.tag.red { color: var(--danger); }

[data-theme="dark"] .tag.teal,
[data-theme="dark"] .tag.gold,
[data-theme="dark"] .tag.red {
  color: var(--text);
}

.module-card h3 { margin-bottom: 4px; }

.module-card .number {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--primary-2);
  font-weight: 750;
  margin-bottom: 12px;
}

.accordion {
  display: grid;
  gap: 10px;
}

details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow);
}

summary {
  list-style: none;
  padding: 13px 16px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}

summary::-webkit-details-marker { display: none; }

details[open] summary {
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.details-body { padding: 16px; }

.route-view > section {
  display: grid;
  gap: 14px;
}

.route-view > section.hero {
  display: block;
}

.section-spacer {
  margin-top: 14px;
}

.term-list {
  display: grid;
  gap: 10px;
}

.term-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.term-item strong {
  color: var(--primary);
}

.tip,
.trap,
.scenario-box {
  padding: 12px 14px;
  border-radius: 10px;
  margin: 10px 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.tip {
  border-left: 3px solid var(--teal);
}

.trap {
  border-left: 3px solid var(--gold);
}

.scenario-box {
  border-left: 3px solid var(--primary-2);
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
}

tr:last-child td { border-bottom: 0; }

.flashcard {
  min-height: 220px;
  perspective: 1000px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 220px;
  transition: transform 0.32s ease;
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flash-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.flash-back {
  transform: rotateY(180deg);
  background: var(--surface);
  color: var(--text);
}

.flash-back p {
  color: var(--teal);
  font-weight: 650;
}

.quiz-panel {
  display: grid;
  gap: 14px;
}

.quiz-choice {
  display: block;
  width: 100%;
  text-align: left;
  margin: 8px 0;
  border-radius: 10px;
  padding: 12px 13px;
  background: var(--surface);
}

.quiz-choice.correct {
  border-color: var(--success);
  background: rgba(21, 128, 61, 0.08);
}

.quiz-choice.wrong {
  border-color: var(--danger);
  background: rgba(185, 28, 28, 0.08);
}

.feedback {
  padding: 13px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.progress-bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-bar > span {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: var(--teal);
}

.input-line,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
}

.input-line:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(35, 57, 93, 0.08);
}

textarea {
  width: 100%;
  min-height: 90px;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 250;
}

.result-list {
  max-height: 380px;
  overflow: auto;
  display: grid;
  gap: 4px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.result-item {
  padding: 11px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
}

.result-item:hover {
  background: var(--surface-2);
}

.pdf-stage {
  display: grid;
  gap: 14px;
}

.pdf-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.pdf-list {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 6px;
}

.pdf-list a {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--text);
  font-weight: 650;
  line-height: 1.35;
}

.pdf-list a span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.pdf-list a:hover,
.pdf-list a.active {
  background: var(--surface-2);
  border-color: var(--line);
}

.pdf-document {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.pdf-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.pdf-toolbar h2 {
  margin: 6px 0 4px;
}

.pdf-stage iframe,
#pdfFrame {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
}

.checkline {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
}

.checkline input {
  margin-top: 5px;
}

.pdf-stage iframe,
#pdfFrame {
  width: 100%;
  height: 80vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
}

.pdf-frame-card {
  padding: 0;
  overflow: hidden;
}

.pdf-frame-card iframe,
.pdf-frame-card #pdfFrame {
  display: block;
  border: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Video viewer ── */
.video-stage {
  display: grid;
  gap: 14px;
}

.video-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.video-list {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 6px;
}

.video-list a {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--text);
  font-weight: 650;
  line-height: 1.35;
}

.video-list a span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.video-list a:hover,
.video-list a.active {
  background: var(--surface-2);
  border-color: var(--line);
}

.video-document {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.video-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.video-toolbar h2 {
  margin: 6px 0 4px;
}

.video-player-card {
  padding: 16px;
}

.video-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.video-speed-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.video-speed-label select {
  min-width: 88px;
}

.video-player-wrap[hidden] {
  display: none !important;
}

.module-video {
  width: 100%;
  max-height: 75vh;
  border-radius: 14px;
  background: #000;
  display: block;
}

.video-fallback {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
}

.video-fallback[hidden] {
  display: none !important;
}

.video-fallback code {
  font-size: 13px;
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 4px;
}

.video-tabs {
  display: none;
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.video-tab {
  flex: 1;
  padding: 10px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  border-radius: 0;
  min-height: auto;
}

.video-tab.active {
  color: var(--primary-2);
  border-bottom-color: var(--primary-2);
}

.module-materials {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.module-materials h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.pdf-tabs {
  display: none;
  gap: 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}

.pdf-tab {
  flex: 1;
  padding: 10px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  border-radius: 0;
  min-height: auto;
}

.pdf-tab.active {
  color: var(--primary-2);
  border-bottom-color: var(--primary-2);
  background: transparent;
}

.pdf-panel.hidden { display: none !important; }

.confidence-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.confidence-btn {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

.confidence-btn.selected {
  border-color: var(--primary-2);
  background: rgba(30, 58, 95, 0.08);
  color: var(--primary-2);
}

.continue-card {
  border-left: 3px solid var(--teal);
}

.recent-list {
  display: grid;
  gap: 8px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.recent-item:hover {
  background: var(--surface-2);
}

.cram-grid {
  display: grid;
  gap: 12px;
}

.cram-topic {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.cram-topic h4 {
  margin: 0 0 6px;
  color: var(--primary-2);
}

.glossary-term {
  color: var(--primary-2);
  text-decoration: underline dotted;
  cursor: help;
  font-weight: 600;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  min-height: auto;
}

.header-page-title {
  font-size: 15px !important;
  font-weight: 600 !important;
  letter-spacing: 0 !important;
  margin: 0 !important;
}

.term-popover {
  position: fixed;
  z-index: 500;
  max-width: 320px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 14px;
}

.term-popover strong {
  display: block;
  margin-bottom: 4px;
  color: var(--primary-2);
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 16px;
}

.modal-overlay[hidden],
.pomo-dropdown[hidden],
.term-popover[hidden] {
  display: none !important;
}

.modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-header input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.modal-header kbd {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
}

.modal-body {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}

.command-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}

.command-item:hover,
.command-item.active {
  background: var(--surface-2);
}

.command-item kbd {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
}

.full-width { width: 100%; }

.settings-section {
  display: grid;
  gap: 16px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.settings-row:last-child { border-bottom: 0; }

.shortcut-table {
  width: 100%;
  font-size: 14px;
}

.shortcut-table td:last-child {
  text-align: right;
  color: var(--muted);
}

.exam-review-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
}

.exam-review-item.correct {
  border-left: 3px solid var(--success);
}

.exam-review-item.wrong {
  border-left: 3px solid var(--danger);
}

.mobile-nav { display: none; }

@media (max-width: 1020px) {
  .header-center { display: none; }
  .mobile-only { display: inline-flex; }
  .header-page-title { max-width: 120px; }
  .header-app-name { display: none; }
  .header-divider { display: none; }
  #sidebarToggle { display: none; }

  @media (min-width: 1021px) {
    #sidebarToggle { display: inline-flex; }
  }

  @media (max-width: 1020px) {
    #mobileMenuBtn { display: inline-flex; }
  }
  .sidebar-collapse-btn { display: none; }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    z-index: 300;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.open .sidebar-brand-text,
  .sidebar.open .nav-group-label,
  .sidebar.open .nav-link span:not(.nav-icon) {
    opacity: 1;
    width: auto;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    top: var(--header-h);
    background: rgba(15, 23, 42, 0.4);
    z-index: 250;
  }

  .sidebar-backdrop[hidden] { display: none; }

  .main-content {
    margin-left: 0 !important;
    padding-bottom: 88px;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 4px;
    box-shadow: var(--shadow);
  }

  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    padding: 8px 4px;
    border-radius: 10px;
    min-height: 52px;
  }

  .mobile-nav a .mob-icon {
    font-size: 18px;
    line-height: 1;
  }

  .mobile-nav a.active {
    color: var(--primary-2);
    background: rgba(30, 58, 95, 0.08);
  }

  .pdf-tabs { display: flex; }
  .pdf-layout .pdf-list { display: none; }
  .pdf-layout .pdf-list.pdf-panel-active { display: grid; }
  .pdf-document.pdf-panel-hidden { display: none; }
  .video-tabs { display: flex; }
  .video-layout .video-list { display: none; }
  .video-layout .video-list.video-panel-active { display: grid; }
  .video-document.video-panel-hidden { display: none; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .main-content { padding: 20px 14px 88px; }
  h1, .header-page-title { font-size: 14px; }
  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }
  .hero {
    padding: 18px;
    border-radius: var(--radius);
  }
  .pdf-layout,
  .video-layout {
    grid-template-columns: 1fr;
  }
  .pdf-list,
  .video-list {
    position: static;
  }
  .pdf-toolbar,
  .video-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  #pdfFrame { height: 70vh; }
  .module-video { max-height: 70vh; }
  .button-row,
  .actions,
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  .button-row button,
  .button-row .button,
  .actions button,
  .filters button,
  .filters select {
    width: 100%;
  }
  .pomo-header-btn span:last-child { display: none; }
}

/* ── Auth lock screen ── */
.auth-lock-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow: hidden;
  background: #0f172a;
}

.auth-lock-bg {
  position: absolute;
  inset: 0;
  background-image: url("../assets/konata-studying.gif");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.05);
}

.auth-lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(2px);
}

[data-theme="dark"] .auth-lock-overlay {
  background: rgba(15, 23, 42, 0.72);
}

.auth-lock-screen[hidden],
.app-layout[hidden] {
  display: none !important;
}

.auth-lock-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 28px 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  text-align: center;
}

[data-theme="dark"] .auth-lock-card {
  background: rgba(31, 41, 55, 0.94);
}

.auth-logo {
  margin: 0 auto 16px;
  width: 48px;
  height: 48px;
  font-size: 15px;
}

.auth-lock-card h1 {
  font-size: 22px;
  margin: 0 0 6px;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.auth-form {
  text-align: left;
  display: grid;
  gap: 12px;
}

.auth-field span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--muted);
}

.auth-input-row {
  display: flex;
  gap: 8px;
}

.auth-input-row input {
  flex: 1;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

.auth-note {
  margin: 16px 0 0;
  font-size: 13px;
}

.auth-disclaimer {
  margin: 10px 0 0;
  font-size: 11px;
}

body.auth-locked {
  overflow: hidden;
}

/* ── Focus mode ── */
body.focus-mode .sidebar,
body.focus-mode .top-header,
body.focus-mode .mobile-nav {
  display: none !important;
}

body.focus-mode .app-body {
  padding-top: 0;
}

body.focus-mode .main-content {
  margin-left: 0 !important;
  max-width: 900px;
  margin-inline: auto;
  padding-top: 24px;
}

.reviewer-notes {
  display: grid;
  gap: 12px;
}

.reviewer-notes ul {
  margin: 0;
  padding-left: 20px;
}

.exam-box {
  display: grid;
  gap: 14px;
}

.exam-mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.exam-mode-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.exam-mode-card h4 {
  margin: 0 0 6px;
}

.enum-answers {
  margin: 10px 0 0;
  padding-left: 20px;
}

.enum-answers[hidden] {
  display: none;
}

.pass-badge {
  color: var(--success);
  font-weight: 700;
}

.fail-badge {
  color: var(--danger);
  font-weight: 700;
}

.module-progress-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

@media print {
  body {
    background: #ffffff;
    color: #000000;
  }
  .auth-lock-screen {
    display: none !important;
  }
  .top-header,
  .sidebar,
  .sidebar-backdrop,
  .mobile-nav,
  .actions,
  .button-row,
  .search-dropdown,
  .modal-overlay,
  .term-popover {
    display: none !important;
  }
  .app-body { padding-top: 0; }
  .main-content {
    margin-left: 0 !important;
    padding: 0;
  }
  .card,
  details {
    box-shadow: none;
    border-color: #bbbbbb;
    break-inside: avoid;
  }
}
