/* Core interface styles */

:root {
  --bg-amoled: #000000;
  --bg-surface-1: #09090b;
  --bg-surface-2: #121215;
  --bg-surface-3: #18181c;
  --bg-input: #0e0e11;
  --bg-hover: #1f1f24;
  --border-subtle: #222226;
  --border-active: #38bdf8;
  --border-focus: #00f0ff;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-cyan: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.15);
  --accent-terminal-green: #10b981;
  --accent-warn: #fbbf24;
  --accent-danger: #f43f5e;
  --canvas-dots: #1e1e24;
  --paper: #ffffff;
  --paper-shadow: rgba(0, 0, 0, 0.95);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-amoled);
  color: var(--text-primary);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
/* Simplified editor mode */

body.simple-mode .menu-wrap,
body.simple-mode .canvas-toolbar-overlay,
body.simple-mode .mini-toolbar,
body.simple-mode .resize-handle,
body.simple-mode .el-badge,
body.simple-mode #customEmblemSection {
  display: none !important;
}
/* Simple mode intentionally exposes only the cover page and quick-fill details. */

body.simple-mode .sidebar-nav-item[data-panel="styling"],
body.simple-mode .sidebar-nav-item[data-panel="experiments"],
body.simple-mode #pageSelectionSection {
  display: none !important;
}

body.simple-mode .c-el {
  cursor: default !important;
  outline: none !important;
}

body.simple-mode .sidebar {
  width: var(--sidebar-width, 400px);
}

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

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: var(--bg-amoled);
}
/* Main navigation */

.top-nav {
  height: 52px;
  background: var(--bg-surface-1);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

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

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
}
/* Display mode controls */

.mode-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  padding: 3px 10px;
  border-radius: 20px;
  margin-left: 6px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.6);
}

.mode-label {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-label.active {
  color: var(--accent-cyan);
}

.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  cursor: pointer;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-amoled);
  transition: .22s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
}

.slider:before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: var(--text-muted);
  transition: .22s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

input:checked + .slider {
  background-color: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
}

input:checked + .slider:before {
  transform: translateX(16px);
  background-color: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.view-tabs {
  display: flex;
  background: var(--bg-surface-2);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  gap: 3px;
}

.view-tab {
  padding: 6px 13px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 5px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'Inter', sans-serif;
  transition: all 0.15s ease;
}

.page-tab-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  font-size: 10px;
  font-weight: 700;
}

.view-tab.active .page-tab-num {
  background: rgba(0,0,0,0.25);
}

.view-tab:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.03);
}

.view-tab.active {
  background: var(--bg-surface-3);
  color: #ffffff;
  border: 1px solid #2d2d34;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

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

.btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-secondary {
  background: var(--bg-surface-2);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: #383842;
  color: #fff;
}

.btn-primary {
  background: #ffffff;
  color: #000000;
  font-weight: 700;
}

.btn-primary:hover {
  background: #e2e8f0;
  box-shadow: 0 0 12px rgba(255,255,255,0.25);
}

.btn-cyan {
  background: var(--accent-cyan);
  color: #000000;
  font-weight: 700;
}

.btn-cyan:hover {
  background: #7dd3fc;
  box-shadow: 0 0 14px var(--accent-glow);
}
/* Editor layout */

.studio-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.sidebar {
  width: var(--sidebar-width, 400px);
  background: var(--bg-surface-1);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 20;
  flex-shrink: 0;
  transition: width 0.15s ease, opacity 0.1s ease;
}

.sidebar.sidebar-collapsed {
  width: 0;
  opacity: 0;
  pointer-events: none;
  border-right: none;
}

.sidebar-tab-strip {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
}

.sidebar-nav-item {
  flex: 1;
  padding: 11px 8px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.sidebar-nav-item:hover {
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: var(--bg-surface-1);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  user-select: text;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: #222226;
  border-radius: 4px;
}

.panel-section {
  margin-bottom: 18px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-section:last-child {
  border-bottom: none;
}

.section-heading {
  font-size: 10.5px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.status-badge {
  font-size: 9.5px;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.status-badge.custom {
  background: rgba(251, 191, 36, 0.1);
  color: var(--accent-warn);
  border-color: rgba(251, 191, 36, 0.3);
}

.control-group {
  margin-bottom: 10px;
}

.control-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.control-label .sub {
  color: var(--text-dim);
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
}

.input-box,
.select-box,
.textarea-box {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.15s ease;
}

.input-box:focus,
.select-box:focus,
.textarea-box:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--accent-cyan);
  background: #111115;
}

.textarea-box {
  resize: vertical;
  min-height: 48px;
  line-height: 1.4;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 7px;
}

.drop-box {
  border: 1.5px dashed var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  background: var(--bg-surface-2);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  display: block;
}

.drop-box:hover {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.04);
}

.drop-box.has-file {
  border-style: solid;
  border-color: var(--accent-terminal-green);
  background: rgba(16, 185, 129, 0.06);
}

.drop-box input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
/* Page canvas */

.stage-viewport {
  flex: 1;
  background-color: var(--bg-amoled);
  background-image: radial-gradient(var(--canvas-dots) 1px, transparent 1px), linear-gradient(to right, rgba(255,255,255,0.015) 1px, transparent 1px), linear-gradient(to bottom, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 24px 24px, 120px 120px, 120px 120px;
  overflow: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.canvas-toolbar-overlay {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 3px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.62);
  z-index: 90;
}

.canvas-tool-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}

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

.canvas-tool-btn.active {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
}

.zoom-label {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
  width: 44px;
  text-align: center;
}

#canvasArea {
  position: relative;
  margin: 36px auto 90px auto;
  transform-origin: top center;
  transition: transform 0.05s ease-out;
}

#page,
.print-page {
  width: 794px;
  height: 1123px;
  /* A4 @ 96dpi */
  background: var(--paper);
  position: relative;
  box-shadow: 0 24px 70px var(--paper-shadow);
  overflow: hidden;
  color: #111;
  font-family: 'Times New Roman', Times, serif;
}

.page-border-frame {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
  z-index: 50;
  transition: all 0.15s ease;
}

.guide-line {
  position: absolute;
  pointer-events: none;
  z-index: 999;
  display: none;
}

.guide-x {
  top: 0;
  bottom: 0;
  width: 1px;
  background: #f43f5e;
}

.guide-y {
  left: 0;
  right: 0;
  height: 1px;
  background: #f43f5e;
}
/* Experiment index table */

.exp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  color: #111;
  font-family: 'Times New Roman', Times, serif;
}

.exp-table th,
.exp-table td {
  border: 1px solid #333;
  padding: 8px 10px;
  text-align: center;
  vertical-align: top;
}

.exp-table thead th {
  background: #f0f0f0;
  font-weight: 700;
}

.c-el {
  position: absolute;
  cursor: grab;
  padding: 2px 4px;
  border-radius: 2px;
  outline: 1.5px dashed transparent;
  user-select: text;
  line-height: 1.35;
  box-sizing: border-box;
  touch-action: none;
}

.c-el:hover {
  outline-color: rgba(56, 189, 248, 0.5);
}

.c-el.dragging {
  cursor: grabbing;
  outline-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.06);
  z-index: 500 !important;
}

.c-el.selected {
  outline: 2px solid var(--accent-cyan);
  z-index: 400;
}

.c-el[contenteditable]:focus {
  outline: 2px solid var(--accent-cyan);
  background: rgba(255,255,255,0.98);
  cursor: text;
}

.c-el .el-badge {
  position: absolute;
  top: -18px;
  left: -2px;
  font-size: 8.5px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  background: var(--accent-cyan);
  color: #000000;
  padding: 1px 4px;
  border-radius: 2px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.c-el.selected .el-badge,
.c-el:hover .el-badge {
  opacity: 1;
}

.resize-handle {
  position: absolute;
  width: 7px;
  height: 7px;
  background: #000;
  border: 1.5px solid var(--accent-cyan);
  border-radius: 1px;
  display: none;
  z-index: 450;
  touch-action: none;
}

.c-el.selected .resize-handle {
  display: block;
}

.rh-nw {
  top: -4px;
  left: -4px;
  cursor: nwse-resize;
}

.rh-ne {
  top: -4px;
  right: -4px;
  cursor: nesw-resize;
}

.rh-se {
  bottom: -4px;
  right: -4px;
  cursor: nwse-resize;
}

.rh-sw {
  bottom: -4px;
  left: -4px;
  cursor: nesw-resize;
}

.rh-e {
  top: 50%;
  right: -4px;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.rh-w {
  top: 50%;
  left: -4px;
  transform: translateY(-50%);
  cursor: ew-resize;
}

@media (pointer: coarse) {
  .resize-handle {
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
  }

  .resize-handle::after {
    content: '';
    position: absolute;
    inset: 6px;
    background: #000;
    border: 1.5px solid var(--accent-cyan);
    border-radius: 2px;
  }

  .rh-nw {
    top: -10px;
    left: -10px;
  }

  .rh-ne {
    top: -10px;
    right: -10px;
  }

  .rh-se {
    bottom: -10px;
    right: -10px;
  }

  .rh-sw {
    bottom: -10px;
    left: -10px;
  }

  .rh-e {
    top: 50%;
    right: -10px;
  }

  .rh-w {
    top: 50%;
    left: -10px;
  }
}

.logo-box {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

.logo-box img,
.logo-box svg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}
/* Selected element toolbar */

.mini-toolbar {
  position: fixed;
  display: none;
  flex-wrap: wrap;
  max-width: min(480px, calc(100vw - 24px));
  background: rgba(9, 9, 11, 0.94);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 4px 7px;
  gap: 5px;
  align-items: center;
  box-shadow: 0 16px 36px rgba(0,0,0,0.85);
  z-index: 1000;
  backdrop-filter: blur(12px);
}

.mini-toolbar button {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 5px;
  min-width: 26px;
  height: 26px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  padding: 0 5px;
}

.mini-toolbar button:hover {
  background: var(--bg-hover);
  border-color: #383842;
}

.mini-toolbar button.active {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.mini-toolbar .tb-sep {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
  margin: 0 2px;
}

.mini-toolbar select {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 5px;
  font-size: 11px;
  padding: 2px 6px;
  height: 26px;
  outline: none;
}

.size-stepper-label {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  width: 38px;
  text-align: center;
  color: var(--text-primary);
}

.tb-spacing-group {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 26px;
}

.tb-spacing-group span:first-child {
  font-size: 12px;
  color: var(--text-muted);
}

.tb-spacing-group input[type="range"] {
  width: 64px;
  height: 4px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.color-picker-wrap {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  overflow: hidden;
}

.color-picker-swatch {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.color-picker-wrap input[type="color"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
/* Dialogs and notifications */

.toast-box {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.85);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  gap: 9px;
  z-index: 9999;
  pointer-events: none;
  /* informational only: never block the controls underneath */
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-box.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.modal-card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  width: 520px;
  max-width: 90vw;
  padding: 22px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.9);
}
/* Native print layout */

#printMount {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html,
  body {
    background: #ffffff !important;
    color: #000000 !important;
    height: auto !important;
    width: auto !important;
    overflow: visible !important;
  }

  .app-container,
  .top-nav,
  .sidebar,
  .sidebar-backdrop,
  .stage-viewport,
  .canvas-toolbar-overlay,
  .mini-toolbar,
  .modal-overlay,
  .toast-box,
  .subject-bar,
  #studentDashboardBar,
  #dropHint {
    display: none !important;
  }

  #printMount {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .print-page {
    position: relative !important;
    width: 794px !important;
    height: 1123px !important;
    page-break-after: always !important;
    break-after: page !important;
    overflow: hidden !important;
    background: #ffffff !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    box-shadow: none !important;
  }

  .print-page:last-child {
    page-break-after: avoid !important;
    break-after: avoid !important;
  }

  .print-page .resize-handle,
  .print-page .el-badge,
  .print-page .guide-line {
    display: none !important;
  }

  .print-page .c-el {
    outline: none !important;
  }
}
/* Mobile and touch layouts */

.sidebar-toggle-btn {
  display: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 150;
}

.sidebar-backdrop.visible {
  display: block;
}

@media (max-width: 860px) {
  .top-nav {
    height: auto;
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 8px 10px;
  }

  .brand-block {
    gap: 8px;
  }

  .mode-switch-wrapper {
    transform: scale(0.92);
    transform-origin: left center;
  }

  .view-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .view-tab {
    white-space: nowrap;
  }

  .nav-actions {
    gap: 6px;
  }

  .nav-actions .btn span,
  .nav-actions .btn {
    font-size: 11px;
    padding: 6px 9px;
  }

  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    cursor: pointer;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(340px, 86vw) !important;
    z-index: 200;
    transform: translateX(-100%);
    opacity: 1 !important;
    pointer-events: auto !important;
    box-shadow: 12px 0 40px rgba(0,0,0,0.7);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar.sidebar-collapsed {
    transform: translateX(-100%);
  }

  .stage-viewport {
    padding: 12px;
  }

  .mini-toolbar {
    max-width: calc(100vw - 16px);
  }
}

@media (max-width: 560px) {
  .brand-title {
    font-size: 13px;
  }

  .mode-label {
    display: none;
  }

  .nav-actions .btn {
    padding: 6px 8px;
  }

  .nav-actions .btn svg {
    margin: 0;
  }
}
/* Accessible controls and responsive refinements */

:root {
  --border-subtle: #26262c;
  --text-muted: #a5b0c0;
  --text-dim: #8391a5;
}

.top-nav {
  height: 56px;
  gap: 12px;
}

.brand-title {
  font-size: 16px;
}

.mode-label {
  font-family: 'Inter',sans-serif;
  font-size: 12px;
  font-weight: 600;
}

.view-tab {
  font-size: 12.5px;
  padding: 7px 14px;
}

.view-tab.active {
  border-color: transparent;
  box-shadow: none;
  background: var(--bg-hover);
}

.btn {
  font-size: 12.5px;
  padding: 8px 13px;
  min-height: 34px;
}

.btn-cyan:hover,
.btn-primary:hover {
  box-shadow: none;
}

.btn-icon {
  padding: 8px 10px;
}

.sidebar {
  width: var(--sidebar-width, 400px);
}

.sidebar-nav-item {
  font-size: 12.5px;
  padding: 13px 8px;
}

.sidebar-scroll {
  padding: 20px;
}

.panel-section {
  margin-bottom: 22px;
  padding-bottom: 20px;
}

.section-heading {
  font-family: 'Inter',sans-serif;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-primary);
  font-weight: 650;
  margin-bottom: 12px;
}

.status-badge {
  font-family: 'Inter',sans-serif;
  font-size: 11px;
}

.control-group {
  margin-bottom: 12px;
}

.control-label {
  font-size: 12px;
  margin-bottom: 6px;
}

.input-box,
.select-box,
.textarea-box {
  font-size: 13.5px;
  padding: 9px 11px;
  min-height: 38px;
}

.input-box:focus,
.select-box:focus,
.textarea-box:focus {
  box-shadow: 0 0 0 3px var(--accent-glow);
}

:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.modal-card {
  max-width: calc(100vw - 24px);
}
/* Overflow menu */

.menu-wrap {
  position: relative;
}

.menu-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 270px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 6px;
  z-index: 300;
  box-shadow: 0 12px 32px rgba(0,0,0,.7);
}

.menu-panel.open {
  display: block;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-primary);
}

.menu-item small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--bg-hover);
}

@media (max-width:860px) {
  .nav-actions .btn .lbl {
    display: none;
  }

  .nav-actions .btn {
    padding: 8px 10px;
  }

  #exportPdfBtn .lbl {
    display: inline;
  }
}

@media (prefers-reduced-motion:reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
/* Course and assignment navigation */

.mode-switch-wrapper {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.mode-switch-wrapper .switch,
#simpleModeText {
  display: none;
}

body:not(.simple-mode) #simpleModeText {
  display: inline;
}

body:not(.simple-mode) #advModeText {
  display: none;
}

.mode-label {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

#tabViewBatch {
  display: none;
}

.subject-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-surface-1);
  border-bottom: 1px solid var(--border-subtle);
}

.subject-bar .select-box {
  width: auto;
  min-height: 34px;
  padding: 6px 10px;
}

.chips {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  padding: 2px;
}

.chip {
  white-space: nowrap;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  color: var(--text-muted);
  border-radius: 16px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
}

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

.chip.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  background: var(--accent-glow);
}

.page-checks {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.page-checks label {
  display: flex;
  gap: 6px;
  align-items: center;
  cursor: pointer;
}

.drop-hint {
  display: none;
  position: fixed;
  inset: 12px;
  z-index: 500;
  border: 2px dashed var(--accent-cyan);
  border-radius: 14px;
  background: rgba(0,0,0,.85);
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  pointer-events: none;
}

.drop-hint.on {
  display: flex;
}

@media(max-width:860px) {
  .subject-bar {
    padding: 8px 10px;
    flex-wrap: wrap;
  }

  .chips {
    order: 3;
    flex-basis: 100%;
  }
}

.page-checks {
  flex-direction: column;
  gap: 4px;
}

.page-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-surface-2);
}

.page-row label {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1;
  cursor: pointer;
}

.mv {
  background: none;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
  font-size: 11px;
  border-radius: 6px;
}

.mv:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
/* Compact simple mode and page controls */

body.simple-mode .sidebar-tab-strip,
body.simple-mode .sidebar-nav-item[data-panel="doc"] {
  display: none !important;
}
/* Keep the Details form visible in Simple mode while removing its tab strip. */

body.simple-mode:not([data-panel="experiments"]) #panelDoc {
  display: block !important;
}

[hidden] {
  display: none !important;
}

.preset-section-hidden {
  display: none !important;
}

.menu-panel {
  max-height: calc(100vh - 70px);
  overflow-y: auto;
}
/* Smart save, reusable profiles, and practical design controls */

.save-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  min-width: 110px;
}

.save-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-terminal-green);
  box-shadow: 0 0 7px rgba(16,185,129,.35);
  flex: none;
}

.save-status[data-state="saving"] .save-status-dot {
  background: var(--accent-warn);
  box-shadow: 0 0 7px rgba(251,191,36,.3);
}

.save-status[data-state="error"] .save-status-dot {
  background: var(--accent-danger);
  box-shadow: 0 0 7px rgba(244,63,94,.3);
}

.save-status[data-state="saved"] {
  color: #a7f3d0;
}

.profile-manager {
  background: linear-gradient(135deg,rgba(56,189,248,.055),transparent 75%);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 18px;
}

.profile-manager .section-heading {
  margin-bottom: 10px;
  padding-bottom: 0;
  border: 0;
}

.profile-count {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.profile-action-row {
  display: flex;
  gap: 7px;
  margin-top: 7px;
}

.profile-action-row .btn {
  justify-content: center;
  flex: 1;
  font-size: 11.5px;
  padding: 8px 9px;
}

.profile-help,
.control-hint {
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-dim);
  margin-top: 5px;
}

.range-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.range-label-row output {
  font-family: 'JetBrains Mono',monospace;
  font-size: 11px;
  color: var(--accent-cyan);
  white-space: nowrap;
}

.page-manager-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 9px;
  font-size: 10.5px;
  color: var(--text-muted);
}

.page-manager-footer>div {
  display: flex;
  gap: 6px;
}

.page-manager-footer .btn {
  font-size: 10.5px;
  padding: 6px 8px;
  justify-content: center;
  flex: 1;
}

.page-row {
  cursor: grab;
  transition: border-color .12s,background .12s;
}

.page-row.dragging {
  opacity: .45;
  border-color: var(--accent-cyan);
}

.page-row.drag-over {
  border-color: var(--accent-cyan);
  background: var(--accent-glow);
}

.page-row .mv {
  min-width: 26px;
}

#zoomFitBtn,
#zoomFitWidthBtn,
#zoomActualBtn {
  width: auto;
  padding: 0 7px;
  white-space: nowrap;
}

@media(max-width:700px) {
  .save-status {
    min-width: 0;
    padding: 3px 5px;
    font-size: 0;
  }

  .save-status-dot {
    width: 8px;
    height: 8px;
  }
}
/* Refined profile entry, resizable workspace panel, and consistent slim scrollbars. */

:root {
  --sidebar-width: 400px;
}

.sidebar-resize-handle {
  position: relative;
  z-index: 30;
  flex: 0 0 6px;
  width: 6px;
  margin-left: -1px;
  margin-right: -1px;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
  user-select: none;
  transition: background .15s ease;
}

.sidebar-resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  border-radius: 2px;
  background: #23242b;
  transition: background .15s ease, box-shadow .15s ease;
}

.sidebar-resize-handle:hover::after,
.sidebar-resize-handle:focus-visible::after,
body.resizing-sidebar .sidebar-resize-handle::after {
  background: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56,189,248,.22);
}

body.resizing-sidebar,
body.resizing-sidebar * {
  cursor: col-resize !important;
  user-select: none !important;
}

#studentProfilesQuickSlot {
  margin-top: 12px;
}

#studentProfilesQuickSlot .profile-manager {
  margin-bottom: 0;
  padding: 13px;
  border-radius: 10px;
  background: var(--bg-surface-1);
}

#studentProfilesQuickSlot .profile-manager .section-heading {
  text-transform: none;
  letter-spacing: 0;
}

#studentProfilesQuickSlot .profile-action-row {
  gap: 7px;
}

#studentProfilesQuickSlot .profile-action-row .btn {
  min-height: 32px;
}

.batch-subjects-list {
  max-height: min(38vh, 360px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 1px 4px 1px 0;
}

.batch-subject-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-surface-2);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  min-width: 0;
}

.batch-subject-details {
  flex: 1;
  min-width: 0;
  padding-right: 2px;
}

.batch-subject-title {
  font-weight: 650;
  font-size: 12.5px;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.batch-subject-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.batch-subject-code {
  color: var(--accent-cyan);
  font-family: 'JetBrains Mono',monospace;
}

.batch-subject-controls {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
}

.batch-subject-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.batch-subject-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  background: var(--bg-surface-1);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(1px);
  transition: opacity .14s ease, color .14s ease, border-color .14s ease, background .14s ease, transform .14s ease;
}

.batch-subject-action svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.batch-subject-row:hover .batch-subject-action,
.batch-subject-row:focus-within .batch-subject-action {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.batch-subject-action:hover,
.batch-subject-action:focus-visible {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: var(--accent-glow);
  outline: none;
}

.batch-subject-action.batch-subject-delete:hover,
.batch-subject-action.batch-subject-delete:focus-visible {
  color: var(--accent-danger);
  border-color: var(--accent-danger);
  background: rgba(244,63,94,.1);
}

.batch-subject-select {
  font-size: 11px;
  padding: 5px 10px;
  min-width: 62px;
  justify-content: center;
}

.batch-empty-state {
  padding: 18px 14px;
  border: 1px dashed var(--border-subtle);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.batch-custom-subject-form {
  padding: 13px;
  margin-top: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: var(--bg-surface-2);
}

@media (hover:none) {
  .batch-subject-action {
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }
}

@media (max-width:520px) {
  .batch-subject-row {
    gap: 6px;
    padding: 9px 8px;
  }

  .batch-subject-controls {
    gap: 4px;
  }

  .batch-subject-actions {
    gap: 3px;
  }

  .batch-subject-action {
    width: 28px;
    height: 30px;
  }

  .batch-subject-meta {
    font-size: 10px;
  }
}

.batch-custom-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.batch-custom-subject-form .grid-2 {
  gap: 8px;
}

.batch-custom-subject-form .control-group {
  margin-bottom: 9px;
}

.batch-custom-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
}
/* Standardize native scrollbars throughout the app and its dialogs. */

* {
  scrollbar-width: thin;
  scrollbar-color: #353740 transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3a3d46, #292b33);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #38bdf8, #218fbd);
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

@media (max-width: 860px) {
  .sidebar-resize-handle {
    display: none;
  }

  .sidebar {
    width: min(340px, 86vw) !important;
  }

  #studentProfilesQuickSlot .profile-action-row {
    flex-wrap: wrap;
  }
}
/* Keep the sidebar scrollbar in the same visual family as all other scrollable panes. */

.sidebar-scroll::-webkit-scrollbar {
  width: 8px;
}

.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: #353740;
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.subject-bar {
  min-width: 0;
  gap: 9px;
  padding: 7px 12px;
  min-height: 52px;
}

.top-university-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 380px;
  min-width: 235px;
  max-width: 420px;
  padding: 3px 6px 3px 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
  border-radius: 10px;
}

.top-university-icon {
  color: var(--accent-cyan);
  font-size: 17px;
  line-height: 1;
  flex: none;
}

.top-university-picker #uniPresetSelect {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 285px;
  min-height: 31px;
  border: 0;
  background: transparent;
  padding: 5px 5px;
  font-size: 11.5px;
  box-shadow: none;
}

.top-university-picker .status-badge {
  flex: none;
  max-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(56,189,248,.08);
  color: var(--accent-cyan);
}

.top-university-reset {
  flex: none;
  width: 27px;
  height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  background: var(--bg-surface-1);
  color: var(--text-muted);
  font-size: 19px;
  cursor: pointer;
}

.top-university-reset:hover {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: var(--accent-glow);
}

.subject-bar .semester-shortcut {
  flex: 0 0 135px;
  min-width: 105px;
  font-size: 12px;
}

.chips {
  min-width: 0;
  gap: 7px;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: thin;
}

.subject-chip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  padding-right: 1px;
}

.subject-chip-wrap .chip {
  max-width: min(245px, 24vw);
  overflow: hidden;
  text-overflow: ellipsis;
}

.subject-chip-wrap.is-pinned .chip {
  border-color: rgba(56,189,248,.55);
}

.chip-action {
  width: 23px;
  height: 28px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity .13s ease, color .13s ease, background .13s ease, border-color .13s ease;
}

.chip-action svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.subject-chip-wrap:hover .chip-action,
.subject-chip-wrap:focus-within .chip-action {
  opacity: 1;
  pointer-events: auto;
}

.subject-chip-wrap .chip-action:hover,
.subject-chip-wrap .chip-action:focus-visible {
  background: var(--bg-hover);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  outline: none;
}

.subject-chip-wrap .chip-pin {
  order: -1;
}

.subject-chip-wrap .chip-pin.is-pinned {
  color: var(--accent-cyan);
  opacity: 1;
  pointer-events: auto;
}

.subject-chip-wrap .chip-remove:hover {
  color: var(--accent-danger);
  border-color: rgba(244,63,94,.4);
}

.chips-empty {
  color: var(--text-dim);
  font-size: 11.5px;
  white-space: nowrap;
  padding: 5px 7px;
}

.course-switcher-top-btn {
  min-height: 33px;
  padding: 6px 10px;
  white-space: nowrap;
  flex: none;
  font-size: 11.5px;
}
/* Course search is instant and keeps the row actions stable. */

.batch-search-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  background: var(--bg-input);
  padding: 0 10px;
  margin: 0 0 5px;
}

.batch-search-wrap > svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: var(--text-muted);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.batch-search-wrap .input-box {
  border: 0;
  box-shadow: none;
  outline: none;
  background: transparent;
  min-width: 0;
  flex: 1;
  padding: 11px 0;
}

.batch-search-wrap .input-box:focus {
  box-shadow: none;
}

.batch-search-wrap kbd,
.shortcut-card kbd {
  flex: none;
  font: 10px 'JetBrains Mono', monospace;
  color: var(--text-dim);
  background: var(--bg-surface-3);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 3px 5px;
  white-space: nowrap;
}

.batch-search-count {
  min-height: 17px;
  margin: 0 1px 5px;
  color: var(--text-dim);
  font-size: 10.5px;
}

.batch-subject-pin.is-pinned {
  color: var(--accent-cyan);
  opacity: 1;
  pointer-events: auto;
  border-color: rgba(56,189,248,.5);
  background: var(--accent-glow);
}

.batch-subject-pin svg {
  fill: none;
}
/* Reserve a real toolbar lane in the scroll viewport. This prevents the toolbar from
   covering the page at high zoom levels and avoids scaling a compensating page margin. */

#stageViewport {
  padding-top: 58px;
}

#canvasArea {
  margin-top: 0;
}

.canvas-toolbar-overlay {
  top: 7px;
  z-index: 45;
  max-width: calc(100% - 20px);
  overflow-x: auto;
  scrollbar-width: none;
}

.canvas-toolbar-overlay::-webkit-scrollbar {
  display: none;
}
/* Keyboard-shortcut help dialog. */

.shortcut-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: min(16vh, 120px) 16px 24px;
  background: rgba(0,0,0,.64);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.shortcut-card {
  width: min(620px, 100%);
  max-height: min(680px, 78vh);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #0b0b0e;
  color: var(--text-primary);
  border: 1px solid #30313a;
  border-radius: 15px;
  box-shadow: 0 26px 90px rgba(0,0,0,.65);
}

.shortcut-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.shortcut-kicker {
  color: var(--accent-cyan);
  font-size: 9.5px;
  letter-spacing: .13em;
  font-weight: 800;
  margin-bottom: 7px;
}

.shortcut-head h2 {
  font-size: 17px;
  letter-spacing: -.025em;
  font-weight: 750;
}

.shortcut-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 10px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-dim);
  font-size: 10.5px;
}

.shortcut-help-list {
  padding: 12px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
}

.shortcut-help-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #1d1e23;
  padding: 9px 0;
  font-size: 12.5px;
}

.shortcut-help-list > div:last-child {
  border-bottom: 0;
}

.shortcut-help-list kbd {
  min-width: 70px;
  text-align: center;
  font-size: 10.5px;
}

.shortcut-help-card .shortcut-footer {
  padding: 13px 18px;
}
/* Small, persistent offline readiness indicator. */

.offline-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 10.5px;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
}

.offline-status-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: #64748b;
}

.offline-status[data-state="cached"],
.offline-status[data-state="offline-ready"] {
  color: #7dd3a8;
  border-color: rgba(16,185,129,.22);
  background: rgba(16,185,129,.06);
}

.offline-status[data-state="cached"] .offline-status-dot,
.offline-status[data-state="offline-ready"] .offline-status-dot {
  background: #10b981;
  box-shadow: 0 0 7px rgba(16,185,129,.32);
}

.offline-status[data-state="offline-limited"] {
  color: #fbbf24;
  border-color: rgba(251,191,36,.25);
  background: rgba(251,191,36,.06);
}

.offline-status[data-state="offline-limited"] .offline-status-dot {
  background: #fbbf24;
}

@media (hover:none) {
  .chip-action {
    opacity: .85;
    pointer-events: auto;
  }
}

@media (max-width: 1100px) {
  .top-university-picker {
    flex-basis: 315px;
  }

  .top-university-picker .status-badge {
    display: none;
  }

  .course-switcher-top-btn {
    padding-inline: 8px;
  }
}

@media (max-width: 860px) {
  .subject-bar {
    flex-wrap: wrap;
    padding: 8px 10px;
  }

  .top-university-picker {
    flex: 1 1 290px;
    min-width: min(290px, 100%);
    max-width: none;
  }

  .subject-bar .semester-shortcut {
    flex: 0 0 125px;
  }

  .chips {
    order: 3;
    flex-basis: 100%;
    width: 100%;
  }

  .course-switcher-top-btn {
    order: 4;
  }

  .offline-status {
    font-size: 9px;
    padding: 3px 5px;
    max-width: 72px;
    white-space: normal;
    line-height: 1.1;
  }

  .offline-status-dot {
    width: 7px;
    height: 7px;
  }

  #stageViewport {
    padding-top: 60px;
  }
}

@media (max-width: 560px) {
  .subject-bar {
    gap: 7px;
  }

  .top-university-picker {
    flex-basis: 100%;
    min-width: 0;
  }

  .top-university-picker #uniPresetSelect {
    font-size: 11px;
  }

  #stageViewport {
    padding-top: 62px;
  }

  .subject-chip-wrap .chip {
    max-width: 54vw;
  }

  .shortcut-overlay {
    padding: 8vh 9px 12px;
  }

  .shortcut-head {
    padding: 15px 14px 12px;
  }

  .shortcut-footer {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

.shortcut-overlay[hidden] {
  display: none !important;
}

select,
.select-box {
  color-scheme: dark;
}

select option,
.select-box option {
  background: #15161b;
  color: #e8eaf0;
}

select option:checked,
.select-box option:checked {
  background: #0b4a6b;
  color: #fff;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) select {
    color-scheme: light;
  }
}

.subject-bar {
  gap: 8px;
  padding: 5px 12px;
  min-height: 0;
  align-items: center;
}

.top-university-picker {
  flex: 0 0 auto;
  min-width: 0;
  max-width: none;
  gap: 2px;
  padding: 2px 3px 2px 8px;
  border-radius: 9px;
  position: relative;
}

.top-university-picker #uniPresetSelect {
  flex: 0 0 auto;
  width: 118px;
  max-width: none;
  min-height: 28px;
  padding: 3px 4px;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  cursor: pointer;
}

.top-university-icon {
  font-size: 14px;
}

.top-university-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-warn, #fbbf24);
  box-shadow: 0 0 0 2px var(--bg-surface-2);
  pointer-events: none;
}

.top-university-dot[hidden] {
  display: none;
}

.top-university-reset {
  width: 24px;
  height: 24px;
  font-size: 15px;
  border-radius: 6px;
}
/* The university selector keeps a neutral border even when edited. */

.top-university-picker.is-modified {
  border-color: var(--border-subtle);
}

.top-university-dot {
  display: none !important;
}

.subject-bar .semester-shortcut {
  flex: 0 0 auto;
  width: 88px;
  min-width: 0;
  min-height: 30px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-surface-2);
}

.course-switcher-top-btn {
  min-height: 30px;
  padding: 4px 10px;
}

.chips {
  gap: 6px;
  padding: 1px 2px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}
/* Chip actions overlay the chip on hover; they take no layout space. */

.subject-chip-wrap {
  position: relative;
  display: inline-flex;
  padding: 0;
  gap: 0;
}

.subject-chip-wrap .chip {
  padding: 5px 12px;
  font-size: 12px;
  max-width: min(220px, 24vw);
  transition: padding .12s ease, border-color .12s ease;
}

.subject-chip-wrap.is-pinned .chip::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  margin: 0 6px 1px -2px;
  border-radius: 50%;
  background: var(--accent-cyan);
  vertical-align: middle;
}

.chip-actions {
  position: absolute;
  top: 50%;
  right: 3px;
  transform: translateY(-50%);
  display: inline-flex;
  gap: 1px;
  padding-left: 14px;
  border-radius: 0 14px 14px 0;
  background: linear-gradient(90deg, transparent, var(--bg-hover, #23252c) 14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}

.subject-chip-wrap:hover .chip-actions,
.subject-chip-wrap:focus-within .chip-actions {
  opacity: 1;
  pointer-events: auto;
}

.chip-actions .chip-action {
  opacity: 1;
  pointer-events: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.chip-actions .chip-action svg {
  width: 12px;
  height: 12px;
}

.chip-actions .chip-pin {
  order: 0;
}

.chip-actions .chip-pin.is-pinned {
  color: var(--accent-cyan);
}

.subject-chip-wrap:hover .chip,
.subject-chip-wrap:focus-within .chip {
  padding-right: 12px;
}

@media (hover: none) {
  .subject-chip-wrap .chip {
    padding-right: 50px;
  }

  .chip-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 860px) {
  .top-university-picker {
    flex: 0 0 auto;
    min-width: 0;
  }

  .subject-bar .semester-shortcut {
    flex: 0 0 88px;
  }

  .course-switcher-top-btn {
    order: 2;
    margin-left: auto;
  }

  .chips {
    order: 3;
  }
}

@media (max-width: 560px) {
  .top-university-picker {
    flex-basis: auto;
  }

  .top-university-picker #uniPresetSelect {
    width: 104px;
  }
}

.subject-chip-wrap.is-pinned .chip-pin {
  color: var(--accent-cyan);
}

.lucide {
  flex: none;
}

.save-status,
.offline-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  min-width: 0;
}

.save-status[data-state="error"],
.save-status[data-state="warning"],
.offline-status[data-state="offline-limited"] {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  padding: 4px 8px;
  overflow: visible;
  clip: auto;
  clip-path: none;
  border: 1px solid rgba(244,63,94,.35);
  border-radius: 7px;
  font-size: 11px;
}

.save-status[data-state="warning"],
.offline-status[data-state="offline-limited"] {
  border-color: rgba(251,191,36,.35);
}

.top-university-picker {
  padding-left: 4px;
}

.menu-item-icon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-item-icon > svg {
  color: var(--accent-cyan);
}

.menu-item-icon > span {
  flex: 1;
  min-width: 0;
}

.menu-item-icon kbd {
  font: 10px 'JetBrains Mono', monospace;
  color: var(--text-dim);
  background: var(--bg-surface-3);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 2px 5px;
}

.menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border-subtle);
}

.nav-actions {
  gap: 8px;
}

.nav-actions .menu-wrap .btn-icon {
  min-height: 36px;
  width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.top-university-reset svg {
  display: block;
}

.chip-actions .chip-action svg {
  width: 12px;
  height: 12px;
}

.canvas-tool-btn svg {
  display: block;
}

.exp-table {
  table-layout: fixed;
}

.exp-table th {
  padding: 7px 6px;
  font-size: 12.5px;
}

.exp-table td {
  height: 34px;
  padding: 6px 8px;
  vertical-align: middle;
  font-size: 12.5px;
  word-break: break-word;
}

.exp-table td.exp-title-cell {
  text-align: left;
}

.index-count {
  margin-left: 6px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
  font-size: 11px;
}

.index-clear {
  background: none;
  border: 0;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  text-transform: none;
  letter-spacing: 0;
}

.index-clear:hover {
  color: var(--accent-danger);
}

.index-clear[hidden] {
  display: none;
}

.index-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.index-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px;
  border: 1px dashed var(--border-subtle);
  border-radius: 8px;
  text-align: center;
}

.index-entry {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px;
}

.index-entry:focus-within {
  border-color: rgba(56,189,248,.5);
}

.index-entry-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.index-entry-no {
  flex: none;
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent-glow);
  color: var(--accent-cyan);
  font: 700 11px 'JetBrains Mono', monospace;
}

.index-entry-top .input-box {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  padding: 6px 8px;
  min-height: 32px;
}

.index-entry-actions {
  display: flex;
  gap: 1px;
  flex: none;
}

.icon-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
}

.icon-btn:hover:not(:disabled),
.icon-btn:focus-visible {
  background: var(--bg-hover);
  color: var(--text-primary);
  outline: none;
}

.icon-btn.danger:hover:not(:disabled) {
  color: var(--accent-danger);
}

.icon-btn:disabled {
  opacity: .3;
  cursor: default;
}

.index-entry-meta {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 6px;
  margin-top: 6px;
}

.index-entry-meta .input-box {
  font-size: 12px;
  padding: 5px 8px;
  min-height: 30px;
}

.index-add {
  width: 100%;
  margin-top: 10px;
  justify-content: center;
}

.index-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.45;
}

.chip-actions {
  padding-left: 0;
  background: none;
  gap: 2px;
  right: 4px;
  pointer-events: none !important;
}

.chip-actions .chip-action {
  width: 16px;
  height: 16px;
  pointer-events: auto;
  background: var(--bg-hover, #23252c);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 0 0 1px var(--bg-surface-2);
}

.chip-actions .chip-action svg {
  width: 10px;
  height: 10px;
}

.subject-chip-wrap .chip {
  min-width: 96px;
}

.mini-toolbar {
  flex-wrap: nowrap;
  max-width: calc(100vw - 16px);
  gap: 6px;
  padding: 5px 7px;
  border-radius: 10px;
}

.mini-toolbar select {
  max-width: 104px;
  font-size: 12px;
}

.mini-toolbar button {
  min-width: 28px;
  height: 28px;
  border-radius: 6px;
  padding: 0 6px;
}

.mini-toolbar .tb-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 1px;
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  background: var(--bg-surface-2);
}

.mini-toolbar .tb-group button {
  border: 0;
  background: transparent;
  min-width: 26px;
  height: 26px;
  border-radius: 5px;
}

.mini-toolbar .tb-group button:hover {
  background: var(--bg-hover);
}

.mini-toolbar .tb-group button.active {
  background: rgba(56,189,248,.2);
}

.mini-toolbar .size-stepper-label {
  width: 34px;
  font-size: 11.5px;
}

.mini-toolbar .tb-danger {
  color: var(--accent-danger);
}

.mini-toolbar .tb-danger:hover {
  background: rgba(244,63,94,.12);
  border-color: rgba(244,63,94,.4);
}

.mini-toolbar .tb-spacing-group {
  position: relative;
}

.tb-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(9,9,11,.97);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,.7);
}

.tb-popover[hidden] {
  display: none;
}

.tb-popover input[type="range"] {
  width: 96px;
}

.mini-toolbar .lucide {
  display: block;
}

@media (max-width: 560px) {
  .mini-toolbar select {
    max-width: 76px;
  }

  .mini-toolbar {
    gap: 4px;
    padding: 4px;
  }
}
/* Primary download action and advanced export tools */

.download-control {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  flex-shrink: 0;
}

.download-control .download-main {
  border-radius: 8px;
}

#exportPdfBtn[aria-busy="true"] {
  cursor: progress;
  opacity: .78;
}

#exportPdfBtn:disabled {
  pointer-events: none;
}

.download-menu {
  position: absolute;
  z-index: 1200;
  right: 0;
  top: calc(100% + 7px);
  width: min(300px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-panel, #101012);
  box-shadow: 0 16px 42px #0008;
}

.download-menu[hidden] {
  display: none !important;
}

.download-menu .menu-item {
  width: 100%;
  text-align: left;
}

#pageSizeSelect {
  width: 100%;
}

.c-el[contenteditable="true"] {
  cursor: text;
}

.c-el[data-manual-editable="true"] {
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

@media (max-width: 760px) {
  .download-control .download-main {
    padding-left: 10px;
    padding-right: 10px;
  }

  #sharePdfBtn {
    min-width: 36px;
    padding-left: 9px;
    padding-right: 9px;
  }

  #sharePdfBtn .lbl {
    display: none;
  }

  .download-menu {
    position: fixed;
    top: auto;
    bottom: 10px;
    right: 10px;
    width: min(320px, calc(100vw - 20px));
  }
}

.top-paper-size-picker {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  min-width: 0;
}

.subject-bar #pageSizeSelect {
  width: 74px;
  max-width: 78px;
  min-width: 0;
  min-height: 30px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-surface-2);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.exp-table td[data-index-field] {
  cursor: text;
}

.exp-table td[data-index-field]:focus-visible,
.exp-table td.index-cell-editing {
  outline: 2px solid var(--accent-cyan);
  outline-offset: -2px;
  background: #e9f7ff;
  color: #111827;
}

@media (max-width: 860px) {
  .subject-bar {
    gap: 7px;
  }

  .top-paper-size-picker {
    flex: 0 0 auto;
  }

  .subject-bar #pageSizeSelect {
    width: 70px;
    max-width: 76px;
  }
}

@media (max-width: 560px) {
  .subject-bar #pageSizeSelect {
    width: 64px;
    max-width: 68px;
    padding-left: 5px;
    padding-right: 3px;
  }

  .subject-bar .semester-shortcut {
    flex-basis: 78px;
  }
}
/* Compact page-switcher controls leave more room for the document workspace. */

.view-tabs {
  gap: 2px;
  padding: 2px;
}

.view-tab {
  padding: 4px 9px;
  font-size: 10.5px;
  gap: 5px;
}

.page-tab-num {
  width: 14px;
  height: 14px;
  font-size: 9px;
}
/* Divider rules remain easy to target even when their visible stroke is only 1–2px. */

.c-el[data-id^="rule"],
.c-el[data-id*="_rule"],
.c-el[data-id$="rule"] {
  padding: 5px 4px;
  background-clip: content-box;
}

.c-el[data-id^="rule"].selected,
.c-el[data-id*="_rule"].selected,
.c-el[data-id$="rule"].selected {
  outline: 2px solid var(--accent-cyan);
}

@media (max-width: 600px) {
  html,
  body {
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .app-container {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .top-nav {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    padding: 8px 10px 7px;
    display: grid;
    grid-template-columns: minmax(0,1fr);
    gap: 8px;
    align-items: center;
  }

  .brand-block {
    min-width: 0;
    width: 100%;
    gap: 9px;
    flex-wrap: nowrap;
  }

  .sidebar-toggle-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 10px;
  }

  .brand-title {
    font-size: 18px;
    white-space: nowrap;
  }

  .mode-switch-wrapper {
    margin-left: auto;
    transform: none;
    padding: 4px 6px;
    gap: 4px;
    flex: 0 0 auto;
  }

  .mode-switch-wrapper .switch {
    transform: scale(.86);
    transform-origin: center;
  }

  .mode-label {
    display: none;
  }

  .view-tabs {
    order: initial;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    display: flex;
    justify-content: stretch;
    gap: 4px;
    padding: 3px;
    border-radius: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .view-tabs::-webkit-scrollbar {
    display: none;
  }

  .view-tab {
    flex: 1 0 auto;
    width: auto;
    min-width: 0;
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .nav-actions {
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-columns: 40px 40px 40px 40px minmax(112px,1fr);
    gap: 6px;
    align-items: stretch;
  }

  .nav-actions > .menu-wrap,
  .nav-actions > #sharePdfBtn,
  .nav-actions > #openMergerBtn {
    min-width: 0;
    width: 100%;
    height: 40px;
    min-height: 40px;
    padding: 0;
    justify-content: center;
  }

  .nav-actions > .menu-wrap .btn-icon {
    width: 100%;
    height: 40px;
    min-height: 40px;
  }

  .nav-actions #sharePdfBtn .lbl,
  .nav-actions #openMergerBtn .lbl {
    display: none;
  }

  .nav-actions .download-control {
    min-width: 0;
    width: 100%;
    height: 40px;
  }

  .download-control .download-main {
    flex: 1 1 auto;
    min-width: 0;
    height: 40px;
    padding: 0 8px;
    gap: 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .download-control .download-main .lbl {
    display: inline;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-actions > #tabViewBatch {
    display: none;
  }

  .subject-bar {
    flex: 0 0 auto;
    min-width: 0;
    padding: 7px 9px;
    gap: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    overflow: visible;
  }

  .top-university-picker {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
    max-width: none;
  }

  .top-university-picker #uniPresetSelect {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    font-size: 12px;
  }

  .subject-bar .semester-shortcut {
    flex: 0 0 calc(25% - 5px);
    width: auto;
    min-width: 0;
    font-size: 12px;
  }

  .top-paper-size-picker {
    flex: 0 0 calc(25% - 5px);
    min-width: 0;
  }

  .subject-bar #pageSizeSelect {
    width: 100%;
    max-width: none;
    min-width: 0;
    font-size: 12px;
  }

  .chips {
    order: 5;
    flex: 1 0 100%;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding: 2px 0;
    scrollbar-width: none;
  }

  .chips::-webkit-scrollbar {
    display: none;
  }

  .subject-chip-wrap {
    flex: 0 0 auto;
    max-width: 72vw;
  }

  .subject-chip-wrap .chip {
    max-width: 72vw;
    min-width: 0;
    font-size: 11px;
  }

  .course-switcher-top-btn {
    order: 6;
    flex: 1 0 100%;
    margin: 0;
    min-height: 32px;
    font-size: 12px;
  }

  .studio-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .sidebar {
    width: min(360px, 92vw) !important;
    max-width: 92vw;
  }

  .sidebar-tab-strip {
    position: sticky;
    top: 0;
    z-index: 2;
  }

  .sidebar-scroll {
    padding: 14px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-resize-handle {
    display: none !important;
  }

  .stage-viewport {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
    padding: 6px 4px 16px;
    overflow: auto;
    overscroll-behavior: contain;
  }

  .canvas-toolbar-overlay {
    position: sticky;
    top: 4px;
    left: auto;
    transform: none;
    align-self: center;
    max-width: calc(100vw - 18px);
    margin: 0 auto 8px;
    gap: 4px;
    padding: 4px 6px;
    z-index: 90;
    flex-shrink: 0;
  }

  .canvas-tool-btn {
    min-width: 30px;
    min-height: 30px;
    padding: 4px 6px;
    font-size: 11px;
  }

  #canvasArea {
    margin: 8px auto 32px;
  }

  .mini-toolbar {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
    top: auto !important;
    transform: none !important;
    width: max-content;
    max-width: calc(100vw - 16px);
    overflow-x: auto;
    z-index: 260 !important;
    box-shadow: 0 8px 28px #0009;
  }

  .download-menu {
    position: fixed;
    top: auto;
    bottom: max(10px, env(safe-area-inset-bottom));
    right: 10px;
    width: min(340px, calc(100vw - 20px));
    max-height: min(70dvh, 520px);
    overflow-y: auto;
  }

  .menu-panel {
    max-width: calc(100vw - 20px);
  }

  .shortcut-overlay {
    padding: max(10px, env(safe-area-inset-top)) 8px 12px;
  }

  #studentDashboardBar {
    display: none !important;
  }

  button,
  select,
  input,
  textarea {
    scroll-margin: 12px;
  }
}

@media (max-width: 380px) {
  .brand-title {
    font-size: 16px;
  }

  .nav-actions {
    grid-template-columns: 36px 36px 36px 36px minmax(96px,1fr);
    gap: 4px;
  }

  .nav-actions > .menu-wrap,
  .nav-actions > #sharePdfBtn,
  .nav-actions > #openMergerBtn,
  .nav-actions > .menu-wrap .btn-icon {
    height: 36px;
    min-height: 36px;
  }

  .download-control,
  .download-control .download-main {
    height: 36px;
    min-height: 36px;
  }

  .download-control .download-main {
    font-size: 11px;
    padding-inline: 5px;
  }

  .subject-bar .semester-shortcut {
    flex-basis: calc(27% - 4px);
  }

  .top-paper-size-picker {
    flex-basis: calc(23% - 4px);
  }

  .view-tab {
    padding-inline: 7px;
  }
}

@media (max-width: 600px) {
  .top-nav {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 7px;
    padding: 8px 10px 7px;
  }

  .brand-block {
    grid-column: 1;
    grid-row: 1;
    width: auto;
    min-width: 0;
    gap: 8px;
  }

  .brand-title {
    font-size: 17px;
    letter-spacing: -.4px;
  }

  .brand-block .mode-switch-wrapper,
  .brand-block .save-status,
  .brand-block .offline-status {
    display: none !important;
  }

  .nav-actions {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
  }

  .nav-actions > .menu-wrap,
  .nav-actions > #sharePdfBtn,
  .nav-actions > #openMergerBtn,
  .nav-actions > .menu-wrap .btn-icon {
    flex: 0 0 31px;
    width: 31px;
    min-width: 31px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 9px;
  }

  .nav-actions > .menu-wrap {
    display: flex;
  }

  .nav-actions .download-control {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
  }

  .download-control .download-main {
    flex: 0 0 34px;
    width: 34px;
    min-width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    gap: 0;
  }

  .download-control .download-main .lbl {
    display: none;
  }

  .download-control .download-main svg {
    width: 15px;
    height: 15px;
  }

  .nav-actions > #tabViewBatch {
    display: none !important;
  }

  .view-tabs {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    margin: 0;
  }

  .subject-bar {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(74px, .7fr) minmax(58px, .48fr);
    grid-template-rows: auto auto;
    gap: 6px;
    padding: 7px 9px;
    align-items: center;
  }

  .top-university-picker {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: 2px 4px 2px 6px;
    gap: 2px;
  }

  .top-university-picker #uniPresetSelect {
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: 4px 2px;
    font-size: 11px;
    text-overflow: ellipsis;
  }

  .top-university-reset {
    flex: 0 0 27px;
    width: 27px;
    min-width: 27px;
    padding: 0;
  }

  .subject-bar .semester-shortcut {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    flex: initial;
    padding: 5px 5px;
    font-size: 11px;
  }

  .top-paper-size-picker {
    grid-column: 3;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    flex: initial;
  }

  .subject-bar #pageSizeSelect {
    width: 100%;
    min-width: 0;
    max-width: none;
    padding: 5px 4px;
    font-size: 11px;
  }

  .chips {
    grid-column: 1 / 3;
    grid-row: 2;
    order: initial;
    flex: initial;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    flex-wrap: nowrap;
    margin: 0;
  }

  .subject-chip-wrap {
    max-width: 66vw;
  }

  .subject-chip-wrap .chip {
    max-width: 66vw;
  }

  .course-switcher-top-btn {
    grid-column: 3;
    grid-row: 2;
    order: initial;
    width: 100%;
    min-width: 0;
    min-height: 34px;
    margin: 0;
    padding: 5px 4px;
    font-size: 10px;
    line-height: 1.15;
    white-space: normal;
  }
}

@media (max-width: 380px) {
  .top-nav {
    column-gap: 5px;
    padding-inline: 7px;
  }

  .brand-block {
    gap: 6px;
  }

  .sidebar-toggle-btn {
    width: 32px;
    height: 34px;
    flex-basis: 32px;
  }

  .brand-title {
    font-size: 15px;
  }

  .nav-actions {
    gap: 3px;
  }

  .nav-actions > .menu-wrap,
  .nav-actions > #sharePdfBtn,
  .nav-actions > #openMergerBtn,
  .nav-actions > .menu-wrap .btn-icon {
    flex-basis: 27px;
    width: 27px;
    min-width: 27px;
    height: 32px;
    min-height: 32px;
  }

  .nav-actions .download-control {
    flex-basis: 30px;
    width: 30px;
    height: 32px;
  }

  .download-control .download-main {
    flex-basis: 30px;
    width: 30px;
    min-width: 30px;
    height: 32px;
  }

  .subject-bar {
    grid-template-columns: minmax(0, 1.15fr) minmax(68px, .7fr) minmax(54px, .45fr);
    gap: 5px;
    padding-inline: 7px;
  }

  .top-university-reset {
    display: none;
  }

  .top-university-picker #uniPresetSelect {
    font-size: 10px;
  }

  .course-switcher-top-btn {
    font-size: 9px;
  }
}
/* Mobile wordmark is a one-tap shortcut to Advanced mode. */

@media (max-width: 600px) {
  .brand-title[role="button"] {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .16s ease;
  }

  .brand-title.mobile-advanced-active {
    color: var(--cyan, #35bdf4);
  }

  .brand-title[role="button"]:focus-visible {
    outline: 2px solid var(--cyan, #35bdf4);
    outline-offset: 4px;
    border-radius: 3px;
  }
}
/* Keep editor interactions predictable while a document capture is in flight. */

body.document-task-busy,
body.document-task-busy .app-container {
  cursor: progress;
}
/* Accessibility and theme refinements. Keep these last so they also cover later component styles. */

:root {
  color-scheme: dark;
  --border-focus: #00e5ff;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-amoled: #f8fafc;
  --bg-surface-1: #ffffff;
  --bg-surface-2: #f1f5f9;
  --bg-surface-3: #e2e8f0;
  --bg-input: #ffffff;
  --bg-hover: #e7edf5;
  --border-subtle: #7c8a9d;
  --border-active: #0369a1;
  --border-focus: #075985;
  --text-primary: #0f172a;
  --text-muted: #475569;
  --text-dim: #596579;
  --accent-cyan: #0369a1;
  --accent-terminal-green: #047857;
  --accent-warn: #92400e;
  --accent-danger: #be123c;
  --accent-glow: rgba(3, 105, 161, .13);
  --canvas-dots: #cbd5e1;
  --paper-shadow: rgba(15, 23, 42, .18);
  background: #f8fafc;
}

:root[data-theme="light"] body,
:root[data-theme="light"] .app-container,
:root[data-theme="light"] .stage-viewport,
:root[data-theme="light"] .sidebar,
:root[data-theme="light"] .sidebar-scroll,
:root[data-theme="light"] .top-nav,
:root[data-theme="light"] .subject-bar {
  background-color: var(--bg-amoled);
  color: var(--text-primary);
}

:root[data-theme="light"] .top-nav,
:root[data-theme="light"] .subject-bar,
:root[data-theme="light"] .sidebar,
:root[data-theme="light"] .sidebar-nav,
:root[data-theme="light"] .sidebar-tab-strip {
  border-color: var(--border-subtle);
}

:root[data-theme="light"] .brand-title,
:root[data-theme="light"] .view-tab.active,
:root[data-theme="light"] .menu-item,
:root[data-theme="light"] .btn-secondary:hover {
  color: var(--text-primary);
}

:root[data-theme="light"] .view-tab.active {
  background: var(--bg-surface-3);
  border-color: var(--border-subtle);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

:root[data-theme="light"] .view-tab:hover {
  background: var(--bg-hover);
}

:root[data-theme="light"] .btn-secondary:hover {
  background: var(--bg-hover);
  border-color: #94a3b8;
}

:root[data-theme="light"] .btn-cyan {
  background: #0369a1;
  color: #ffffff;
}

:root[data-theme="light"] .btn-cyan:hover {
  background: #075985;
}

:root[data-theme="light"] .btn-primary {
  background: #0f172a;
  color: #ffffff;
}

:root[data-theme="light"] .mode-switch-wrapper,
:root[data-theme="light"] .view-tabs,
:root[data-theme="light"] .menu-panel,
:root[data-theme="light"] .download-menu,
:root[data-theme="light"] .modal-card,
:root[data-theme="light"] .shortcut-card,
:root[data-theme="light"] .tb-popover,
:root[data-theme="light"] .pdf-preview-page-wrap {
  background-color: var(--bg-surface-1);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

:root[data-theme="light"] .shortcut-overlay {
  background: rgba(15, 23, 42, .46);
}

:root[data-theme="light"] .shortcut-help-list > div {
  border-color: #e2e8f0;
}

:root[data-theme="light"] .sidebar-scroll::-webkit-scrollbar-thumb,
:root[data-theme="light"] .sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

:root[data-theme="light"] * {
  scrollbar-color: #94a3b8 transparent;
}

:root[data-theme="light"] select,
:root[data-theme="light"] .select-box,
:root[data-theme="light"] select option,
:root[data-theme="light"] .select-box option {
  color-scheme: light;
  background-color: #ffffff;
  color: #0f172a;
}

:root[data-theme="light"] select option:checked,
:root[data-theme="light"] .select-box option:checked {
  background: #dbeafe;
  color: #0f172a;
}

:root[data-theme="light"] .drop-hint {
  background: rgba(255, 255, 255, .96);
  color: #0f172a;
}

:root[data-theme="light"] .sidebar-resize-handle {
  background: #e2e8f0;
}

:root[data-theme="light"] .canvas-area,
:root[data-theme="light"] #canvasArea {
  background-color: #edf2f7;
}

:root[data-theme="light"] .canvas-dots {
  background-color: #edf2f7;
}

:root[data-theme="light"] .offline-status[data-state="cached"],
:root[data-theme="light"] .offline-status[data-state="offline-ready"] {
  color: #166534;
}

:root[data-theme="light"] .offline-status[data-state="offline-limited"] {
  color: #854d0e;
}

:root[data-theme="light"] .save-status[data-state="saved"] {
  color: #166534;
}
/* Keyboard focus. Buttons and links get a clear 2px ring; text fields and selects get an accent border
   and soft glow instead of an offset outline, so a focused field never shows a heavy box around it. */

:where(button, a[href], summary, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]):focus-visible {
  outline: 2px solid var(--border-focus) !important;
  outline-offset: 2px !important;
}

:where(input, select, textarea):focus-visible {
  outline: none !important;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

:where(button, input, select, textarea):focus:not(:focus-visible) {
  outline: none;
}
/* Composite fields: the wrapper shows the focus state, the inner control stays plain. */

.batch-search-wrap:focus-within,
.top-university-picker:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
/* Dialogs stay usable on short screens and inside mobile safe areas. */

.modal-overlay,
#studentQuickStart,
.shortcut-overlay {
  padding-top: max(12px, env(safe-area-inset-top));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left));
}

.modal-card,
.qs-card,
.shortcut-card {
  max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
/* Coarse pointers get larger interactive targets without changing desktop density. */

@media (pointer: coarse) {
  button,
  input[type="button"],
  input[type="submit"],
  input[type="reset"],
  select,
  summary,
  .mv,
  .icon-btn,
  .canvas-tool-btn {
    min-height: 44px;
  }

  .mv,
  .icon-btn {
    min-width: 44px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
  }

  input[type="range"] {
    min-height: 32px;
  }

  input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea {
    scroll-margin-block: 16px;
  }

  .nav-actions > .menu-wrap,
  .nav-actions > #sharePdfBtn,
  .nav-actions > #openMergerBtn,
  .nav-actions > .menu-wrap .btn-icon {
    min-height: 44px !important;
    height: 44px !important;
  }

  .nav-actions .download-control,
  .nav-actions .download-control .download-main {
    min-height: 44px !important;
    height: 44px !important;
  }

  .menu-item {
    min-height: 44px;
    padding-block: 10px;
  }

  .modal-overlay {
    align-items: center;
    overflow-y: auto;
  }

  .modal-card {
    width: min(620px, 100%);
    padding: clamp(14px, 4vw, 22px);
  }

  .pdf-preview-card {
    width: min(100%, 1100px);
  }

  .qs-card {
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
  }

  .qs-actions button,
  .pdf-preview-footer button {
    min-height: 44px;
  }

  .view-tab {
    min-height: 44px;
  }
}
/* Reduced motion applies to all current and future CSS components, including later-declared transitions. */

@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    animation-delay: 0ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:root[data-theme="light"] .input-box:focus,
:root[data-theme="light"] .select-box:focus,
:root[data-theme="light"] .textarea-box:focus {
  background: #ffffff;
  color: #0f172a;
}

:root[data-theme="light"] .mini-toolbar {
  background: rgba(255, 255, 255, .97);
  color: #0f172a;
  border-color: #cbd5e1;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .18);
}

:root[data-theme="light"] .mini-toolbar button,
:root[data-theme="light"] .mini-toolbar select {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

:root[data-theme="light"] .mini-toolbar button:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

:root[data-theme="light"] .stage-viewport {
  background-image: radial-gradient(var(--canvas-dots) 1px, transparent 1px), linear-gradient(to right, rgba(15, 23, 42, .025) 1px, transparent 1px), linear-gradient(to bottom, rgba(15, 23, 42, .025) 1px, transparent 1px);
}
/* Very narrow touch screens keep the header controls on a dedicated row so hit targets stay generous. */

@media (pointer: coarse) and (max-width: 380px) {
  .top-nav {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    row-gap: 7px;
  }

  .brand-block {
    grid-column: 1;
    grid-row: 1;
  }

  .nav-actions {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 44px) minmax(44px, 1fr);
    gap: 4px;
  }

  .nav-actions > .menu-wrap,
  .nav-actions > #sharePdfBtn,
  .nav-actions > #openMergerBtn,
  .nav-actions > .menu-wrap .btn-icon {
    flex: none;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
  }

  .nav-actions .download-control,
  .nav-actions .download-control .download-main {
    width: 100% !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
  }

  .view-tabs {
    grid-column: 1;
    grid-row: 3;
  }
}
/* Split download action: primary PDF export plus the adjacent advanced-options trigger. */

.download-control {
  display: inline-flex;
  align-items: stretch;
}

.download-control .download-main {
  border-radius: 8px 0 0 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.download-control .download-options-toggle {
  display: inline-flex;
  flex: 0 0 38px;
  width: 38px;
  min-width: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border-radius: 0 8px 8px 0;
  border-left: 1px solid rgba(0,0,0,.22);
  margin-left: -1px;
}

.download-control .download-options-toggle[aria-expanded="true"] {
  filter: brightness(.92);
}

.download-control .download-menu {
  max-width: calc(100vw - 20px);
}

@media (max-width:600px) {
  .nav-actions .download-control {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    display: flex;
  }

  .nav-actions .download-control .download-main {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    justify-content: center;
  }

  .nav-actions .download-control .download-options-toggle {
    flex: 0 0 36px !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 44px !important;
    min-height: 44px !important;
  }
}

@media (max-width:380px) {
  .nav-actions .download-control {
    min-width: 44px !important;
  }

  .nav-actions .download-control .download-options-toggle {
    flex-basis: 36px !important;
    width: 36px !important;
    min-width: 36px !important;
  }
}

@media (pointer:coarse) {
  .download-control .download-options-toggle {
    min-height: 44px;
  }

  .pdf-preview-selection .page-row .mv {
    min-width: 44px;
    min-height: 44px;
  }

  .pdf-preview-selection-actions .btn {
    min-height: 44px;
  }
}
/* Imported documents use the same editor canvas and page navigation as built-in pages. */

.view-tab.imported-page-tab {
  max-width: 190px;
  flex: 0 0 auto;
}

.view-tab.imported-page-tab .imported-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 142px;
}

.view-tab.imported-page-tab .page-tab-num {
  background: rgba(56,189,248,.16);
  color: var(--accent-cyan);
}

body.simple-mode .view-tab[data-page^="import-"] {
  display: none !important;
}

.page-row.imported-page-row {
  gap: 8px;
}

.page-row.imported-page-row label {
  min-width: 0;
  overflow-wrap: anywhere;
}
/* Combined subject export lives inside the PDF preview instead of its own menu action. */
/* Local formats: header actions and backup status */
/* Design lives in the top tab bar (it opens the Design panel instead of switching page) */

.view-tab-design {
  position: relative;
  margin-left: 6px;
}

.view-tab-design::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 22%;
  bottom: 22%;
  width: 1px;
  background: var(--border-subtle);
}

.view-tab-design svg {
  flex: none;
}

body.simple-mode .view-tab-design {
  display: none !important;
}
/* Paper size lives in the Design panel; the subject bar has two controls */

#panelStyling #pageSizeSelect {
  width: 100%;
}

@media (max-width: 600px) {
  .subject-bar .semester-shortcut {
    grid-column: 2 / 4;
  }
}

@media (max-width: 600px) {
  /* keep the reset button inside the university picker so it never covers the semester select */
  .top-university-picker #uniPresetSelect {
    flex: 1 1 0;
    min-width: 0;
  }
}
/* Attach PDF: optional index page (Simple mode only; Advanced mode uses the page manager) */

.merge-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  margin: 0 0 12px;
  cursor: pointer;
}

.merge-option input {
  width: 16px;
  height: 16px;
  flex: none;
}

body:not(.simple-mode) .merge-option {
  display: none;
}

.merge-pages {
  margin-bottom: 12px;
}

body.simple-mode .merge-pages {
  display: none;
}

.page-row.dragging {
  opacity: .45;
}
/* Saved layouts: template preview thumbnails */
/* PDF preview dialog: settings on the left, preview on the right, footer always visible */

.modal-card.pdf-preview-card {
  width: min(1080px,96vw);
  max-width: 96vw;
  height: min(90vh,780px);
  max-height: 94vh;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  gap: 12px;
  padding: 16px 18px;
  overflow: hidden;
}

.pdf-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pdf-preview-header h3 {
  font-size: 16px;
  margin: 0 0 2px;
}

.pdf-preview-header p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.pdf-preview-body {
  display: grid;
  grid-template-columns: 300px minmax(0,1fr);
  gap: 14px;
  min-height: 0;
}

.pdf-preview-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.pdf-preview-selection {
  flex: none;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  background: var(--bg-surface-2);
  min-width: 0;
}

.pdf-preview-selection-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.pdf-preview-selection-heading h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.pdf-preview-selection-heading span {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.pdf-side-hint {
  margin: 4px 0 10px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-muted);
}

.pdf-preview-selection .page-checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pdf-preview-selection .page-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-surface-1);
  font-size: 13px;
  cursor: grab;
}

.pdf-preview-selection .page-row::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  background: var(--text-dim);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='12' r='1'/%3E%3Ccircle cx='9' cy='5' r='1'/%3E%3Ccircle cx='9' cy='19' r='1'/%3E%3Ccircle cx='15' cy='12' r='1'/%3E%3Ccircle cx='15' cy='5' r='1'/%3E%3Ccircle cx='15' cy='19' r='1'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='12' r='1'/%3E%3Ccircle cx='9' cy='5' r='1'/%3E%3Ccircle cx='9' cy='19' r='1'/%3E%3Ccircle cx='15' cy='12' r='1'/%3E%3Ccircle cx='15' cy='5' r='1'/%3E%3Ccircle cx='15' cy='19' r='1'/%3E%3C/svg%3E") center/contain no-repeat;
}

.pdf-preview-selection .page-row label {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.pdf-preview-selection .page-row label input {
  flex: none;
  accent-color: var(--accent-cyan);
}

.pdf-preview-selection .page-row > span {
  display: flex;
  gap: 2px;
  flex: none;
}

.pdf-preview-selection .page-row .mv {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  border-radius: 6px;
}

.pdf-preview-selection .page-row .mv:disabled {
  opacity: .3;
  cursor: default;
  background: none;
}

.pdf-preview-selection .page-row input:disabled {
  opacity: .55;
}

.pdf-preview-selection-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.pdf-preview-selection-actions .btn {
  flex: 1;
  justify-content: center;
  min-height: 30px;
  padding: 5px 9px;
  font-size: 11px;
}

.subject-export-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.subject-export-toggle input {
  accent-color: var(--accent-cyan);
  flex: none;
}

.subject-selection-actions {
  display: flex;
  gap: 6px;
  margin: 4px 0 8px;
}

.subject-selection-actions .btn {
  flex: 1;
  justify-content: center;
  min-height: 29px;
  padding: 4px 9px;
  font-size: 11px;
}

.subject-checks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 230px;
  overflow: auto;
}

.subject-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  cursor: pointer;
}

.subject-check-row input {
  flex: none;
  accent-color: var(--accent-cyan);
}

.subject-check-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 1px;
}

.subject-check-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.subject-check-details small {
  color: var(--text-muted);
  font-size: 10.5px;
}

.subject-check-empty {
  color: var(--text-muted);
  font-size: 11.5px;
  margin: 3px 0;
}

.pdf-preview-viewer {
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  gap: 8px;
  min-width: 0;
  min-height: 0;
}

.pdf-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.pdf-preview-toolbar .btn {
  font-size: 11.5px;
  padding: 7px 11px;
}

.pdf-preview-page-wrap {
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #09090b;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
}

.pdf-preview-page-wrap img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 8px 35px rgba(0,0,0,.45);
}

.pdf-preview-loading {
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 10px;
  text-align: center;
  align-self: center;
}

.pdf-preview-thumbs {
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 4px;
}

.pdf-preview-thumbs:empty {
  display: none;
}

.pdf-preview-thumb {
  flex: none;
  width: 62px;
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  background: var(--bg-surface-2);
  padding: 4px;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  text-align: center;
}

.pdf-preview-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 794/1123;
  object-fit: contain;
  background: #fff;
  border-radius: 3px;
  margin-bottom: 3px;
}

.pdf-preview-thumb.active {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

.pdf-preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.pdf-preview-footer > span {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.pdf-preview-footer > span:empty {
  display: none;
}

.pdf-preview-footer > div {
  display: flex;
  gap: 8px;
  flex: none;
  margin-left: auto;
}

@media (max-width:760px) {
  .modal-card.pdf-preview-card {
    height: 96vh;
    padding: 12px;
  }

  .pdf-preview-body {
    display: flex;
    flex-direction: column;
    overflow: auto;
    gap: 12px;
  }

  .pdf-preview-side {
    flex: none;
    overflow: visible;
    padding-right: 0;
  }

  .subject-checks {
    max-height: 180px;
  }

  .pdf-preview-viewer {
    flex: none;
    height: min(520px,70vh);
  }

  .pdf-preview-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .pdf-preview-footer > div {
    width: 100%;
  }

  .pdf-preview-footer .btn {
    flex: 1;
    justify-content: center;
    min-height: 44px;
  }
}
/* Disabled buttons look disabled everywhere (they had no style before) and ignore hover effects */

.btn:disabled,
.btn[disabled] {
  opacity: .4;
  cursor: not-allowed;
  filter: grayscale(.7);
  box-shadow: none;
}

.btn-secondary:disabled:hover,
.btn-secondary[disabled]:hover {
  background: var(--bg-surface-2);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-cyan:disabled:hover,
.btn-cyan[disabled]:hover {
  background: var(--accent-cyan);
  box-shadow: none;
}

.btn-primary:disabled:hover,
.btn-primary[disabled]:hover {
  background: #ffffff;
  box-shadow: none;
}
/* Attach PDF: compact one-line page chooser */

.merge-pages {
  padding: 10px 12px;
}

.merge-pages .pdf-preview-selection-heading {
  margin-bottom: 8px;
}

.merge-pages .page-checks {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
}

.merge-pages .page-row {
  flex: 0 0 auto;
  gap: 4px;
  padding: 3px 3px 3px 6px;
}

.merge-pages .page-row label {
  flex: none;
  gap: 6px;
  font-size: 12.5px;
}

.merge-pages .page-row > span {
  gap: 1px;
}

.merge-pages .page-row .mv {
  width: 22px;
  height: 24px;
  min-width: 22px;
  font-size: 16px;
  line-height: 1;
}
/* University / saved-layout list (mouse users): saved layouts show a delete button on hover */

.preset-popover {
  position: fixed;
  z-index: 1300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
}

.preset-popover[hidden] {
  display: none;
}

.preset-menu {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 6px;
  outline: none;
}

.preset-group {
  padding: 9px 10px 4px;
  margin-top: 4px;
  border-top: 1px solid var(--border-subtle);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.preset-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 6px 6px 10px;
  min-height: 36px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

.preset-item.is-active {
  background: var(--bg-hover);
}

.preset-item[aria-selected="true"] .preset-label {
  color: var(--accent-cyan);
  font-weight: 700;
}

.preset-item[aria-selected="true"] .preset-label::before {
  content: "";
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 6px;
  vertical-align: -2px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/contain no-repeat;
}

.preset-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-btn {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease, background .12s ease, color .12s ease;
}

.preset-item:hover .preset-btn,
.preset-item.is-active .preset-btn,
.preset-btn:focus-visible {
  opacity: 1;
}

.preset-edit:hover {
  background: var(--accent-glow);
  color: var(--accent-cyan);
}

.preset-del:hover {
  background: rgba(239,68,68,.16);
  color: var(--accent-danger, #ef4444);
}

.preset-footer {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-2);
}

.preset-action {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.preset-action:hover {
  background: var(--bg-hover);
}

.preset-action svg {
  color: var(--accent-cyan);
  flex: none;
}

@media (hover: none), (pointer: coarse) {
  .preset-btn {
    opacity: 1;
    width: 40px;
    height: 40px;
  }

  .preset-item {
    min-height: 44px;
  }

  .preset-action {
    min-height: 44px;
  }
}
/* Edit-university dialog. */

.uni-edit-card {
  width: min(460px, 100%);
}

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

.uni-edit-head h3 {
  font-size: 16px;
  font-weight: 700;
}

.uni-edit-note {
  color: var(--text-dim);
  font-weight: 400;
}

.uni-edit-layout {
  margin: 14px 0 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.uni-edit-help {
  margin: 4px 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.uni-edit-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 8px;
  font-size: 12.5px;
  line-height: 1.4;
  cursor: pointer;
}

.uni-edit-check input {
  margin-top: 2px;
  flex: none;
}

.uni-edit-check input:disabled + span {
  opacity: .5;
}

.uni-edit-error {
  margin: 8px 0 0;
  color: var(--accent-danger, #ef4444);
  font-size: 12px;
}

.uni-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.uni-edit-actions [hidden] {
  display: none;
}

.uni-edit-spacer {
  flex: 1;
}
/* Subject bar: "+ Add subject" is the main way to add a course; the ready-made library is optional */

.chip.chip-add {
  border-style: dashed;
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
  background: transparent;
  font-weight: 600;
  flex: none;
}

.chip.chip-add:hover {
  background: rgba(56,189,248,.12);
}
/* Phones up to 380px: the action row holds 3 buttons in Simple mode and up to 5 otherwise, so a fixed
   five-column grid squeezed the Download PDF button into a few pixels. A flex row lets Download take the space left. */

@media (max-width: 380px) {
  .nav-actions {
    display: flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 4px;
  }

  .nav-actions > .menu-wrap,
  .nav-actions > #sharePdfBtn,
  .nav-actions > #openMergerBtn {
    flex: 0 0 auto;
  }

  .nav-actions .download-control {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 104px !important;
  }

  .nav-actions .download-control .download-main {
    gap: 5px;
    padding-inline: 6px;
    white-space: nowrap;
  }

  .nav-actions .download-control .download-main .lbl {
    display: inline;
  }
}
/* Upload drop-zone icon. */

.drop-icon {
  color: var(--accent-cyan);
  margin-bottom: 6px;
}
/* Confirmation dialog. */

.confirm-card {
  width: min(420px, 100%);
}

.confirm-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 700;
}

.confirm-message {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.confirm-skip {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  font-size: 12.5px;
  cursor: pointer;
}

.confirm-skip[hidden] {
  display: none;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
/* Above every other dialog (.modal-overlay uses 99999), because it can open on top of one. */

#confirmModal {
  z-index: 100000;
}

.btn-danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

.preset-action[hidden] {
  display: none;
}

#downloadIndividualPdfBtn[hidden] {
  display: none;
}
