:root {
  --color-primary: #14532d;
  --color-primary-hover: #0f3f22;
  --color-secondary: #15803d;
  --color-secondary-soft: #dcfce7;
  --color-bg: #f8faf9;
  --color-surface: #ffffff;
  --color-surface-muted: #f1f5f3;
  --color-border: #d7e2dc;
  --color-border-strong: #b7c9bf;
  --color-text: #14261d;
  --color-text-muted: #475b51;
  --color-success: #166534;
  --color-success-bg: #dcfce7;
  --color-warning: #92400e;
  --color-warning-bg: #fef3c7;
  --color-danger: #991b1b;
  --color-danger-bg: #fee2e2;
  --color-info: #1e40af;
  --color-info-bg: #dbeafe;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 38, 29, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 38, 29, 0.08);
  --shadow-lg: 0 16px 36px rgba(20, 38, 29, 0.16);
  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  --touch-min: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-secondary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--color-primary);
}

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

/* App Shell & Topbar */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--color-primary);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.brand-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--color-primary);
}

.brand-sub {
  margin: 0;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.topbar-user {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.user-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.workspace-nav {
  background: var(--color-surface-muted);
  border-top: 1px solid var(--color-border);
}

.workspace-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.4rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-main {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4.5rem;
}

/* Badges & Status Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-admin {
  background: #ede9fe;
  color: #5b21b6;
}

.badge-teacher {
  background: var(--color-secondary-soft);
  color: var(--color-primary);
}

.badge-student {
  background: var(--color-info-bg);
  color: var(--color-info);
}

.badge-draft {
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-strong);
}

.badge-published,
.badge-active,
.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-pending,
.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-revoked,
.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 38px;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: var(--color-surface-muted);
  border-color: var(--color-primary);
}

.btn:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-secondary);
  border-color: var(--color-secondary);
  color: #ffffff;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-danger {
  background: var(--color-surface);
  border-color: #fca5a5;
  color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--color-danger-bg);
  border-color: var(--color-danger);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-muted);
}

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

.btn-sm {
  min-height: 32px;
  padding: 0.25rem 0.65rem;
  font-size: 0.84rem;
}

/* Tabs */
.tab-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tab-btn {
  min-height: 38px;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}

.tab-btn:hover {
  background: rgba(20, 83, 45, 0.07);
  color: var(--color-primary);
}

.tab-btn[aria-selected="true"] {
  background: var(--color-primary);
  color: #ffffff;
}

/* Cards & Grids */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.card-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--color-primary);
}

.card-desc {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}

.field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
}

.textarea {
  min-height: 88px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.16);
}

.helper-text {
  margin: 0;
  font-size: 0.84rem;
  color: var(--color-text-muted);
}

/* Notice Banners */
.notice {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-muted);
  font-size: 0.9rem;
}

.notice-info {
  background: var(--color-info-bg);
  border-color: #bfdbfe;
  color: var(--color-info);
}

.notice-warning {
  background: var(--color-warning-bg);
  border-color: #fde68a;
  color: var(--color-warning);
}

.notice-success {
  background: var(--color-success-bg);
  border-color: #bbf7d0;
  color: var(--color-success);
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table th {
  background: var(--color-surface-muted);
  font-weight: 700;
  color: var(--color-text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.code-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  word-break: break-all;
}

/* Auth View */
.auth-wrap {
  max-width: 480px;
  margin: 2.5rem auto;
  padding: 0 1rem;
}

.auth-hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-hero h1 {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.5rem;
  color: var(--color-primary);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background: var(--color-surface-muted);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
}

/* Classroom Header & Dual Tabs */
.classroom-header {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.classroom-title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--color-primary);
}

/* External Tools Bar */
.tools-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  font-size: 0.86rem;
}

/* 16:9 Lesson Reader Shell */
.reader-shell {
  position: relative;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

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

.reader-shell.sidebar-collapsed .reader-sidebar {
  display: none;
}

.reader-sidebar {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  padding: 0.75rem;
  max-height: 76vh;
  overflow-y: auto;
}

.reader-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.reader-sidebar-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
}

.unit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.unit-item-btn {
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--color-text);
}

.unit-item-btn:hover {
  background: var(--color-surface);
  border-color: var(--color-border);
}

.unit-item-btn.is-active {
  background: var(--color-secondary-soft);
  border-color: var(--color-secondary);
  color: var(--color-primary);
  font-weight: 700;
}

.page-jump-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--color-border-strong);
}

.page-chip {
  min-width: 34px;
  min-height: 30px;
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  font-size: 0.8rem;
  cursor: pointer;
}

.page-chip.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
  font-weight: 700;
}

.reader-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.reader-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.reader-stage-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.slide-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  container-type: size;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.slide-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #ffffff;
  user-select: none;
}

/* Click zones on slide stage */
.stage-nav-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18%;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.stage-nav-zone:hover {
  opacity: 1;
  background: linear-gradient(90deg, rgba(20, 83, 45, 0.08), transparent);
}

.stage-nav-zone.next {
  right: 0;
}

.stage-nav-zone.next:hover {
  background: linear-gradient(270deg, rgba(20, 83, 45, 0.08), transparent);
}

.stage-nav-zone.prev {
  left: 0;
}

/* Cover Slide & Native Text Slide inside 16:9 container */
.slide-cover,
.slide-native {
  width: 100%;
  height: 100%;
  padding: clamp(1rem, 4cqmin, 3rem) clamp(1.25rem, 6cqmin, 4.5rem);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(0.5rem, 2cqmin, 1.25rem);
  overflow: hidden;
}

.slide-cover-kicker {
  display: inline-block;
  align-self: flex-start;
  padding: 0.2em 0.7em;
  border-radius: 999px;
  background: var(--color-secondary-soft);
  color: var(--color-primary);
  font-size: clamp(0.72rem, 1.8cqmin, 0.95rem);
  font-weight: 700;
}

.slide-cover-title {
  margin: 0;
  color: var(--color-primary);
  font-size: clamp(1.2rem, 4.4cqmin, 2.5rem);
  line-height: 1.25;
}

.slide-cover-sub {
  margin: 0;
  color: var(--color-text-muted);
  font-size: clamp(0.85rem, 2.1cqmin, 1.15rem);
}

.slide-goals {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: clamp(0.25rem, 1cqmin, 0.55rem);
  font-size: clamp(0.78rem, 2cqmin, 1.05rem);
  color: var(--color-text);
}

.slide-cover-actions {
  margin-top: clamp(0.4rem, 1.5cqmin, 1rem);
  z-index: 6;
}

.slide-native {
  justify-content: flex-start;
}

.slide-native-header {
  border-left: 4px solid var(--color-primary);
  padding-left: clamp(0.6rem, 1.8cqmin, 1.1rem);
}

.slide-native-title {
  margin: 0;
  font-size: clamp(1.05rem, 3.4cqmin, 1.95rem);
  color: var(--color-primary);
  line-height: 1.3;
}

.slide-native-subtitle {
  margin: 0.25rem 0 0;
  font-size: clamp(0.8rem, 2cqmin, 1.08rem);
  color: var(--color-text-muted);
}

.slide-native-body {
  display: grid;
  gap: clamp(0.4rem, 1.5cqmin, 0.9rem);
  font-size: clamp(0.76rem, 2.1cqmin, 1.12rem);
  line-height: 1.55;
  color: var(--color-text);
  overflow: hidden;
}

.slide-native-block {
  margin: 0;
  padding: clamp(0.4rem, 1.4cqmin, 0.8rem) clamp(0.6rem, 1.8cqmin, 1rem);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.slide-native-highlight {
  margin: 0;
  padding: clamp(0.45rem, 1.5cqmin, 0.85rem) clamp(0.7rem, 2cqmin, 1.1rem);
  background: var(--color-secondary-soft);
  border-left: 4px solid var(--color-secondary);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-weight: 600;
}

/* Transcript & Sources Drawer (normal mode) */
.reader-drawer {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  overflow: hidden;
}

.reader-drawer-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  border: none;
  background: var(--color-surface-muted);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-primary);
}

.reader-drawer-body {
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.reader-drawer-body[hidden] {
  display: none;
}

.transcript-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  color: var(--color-text);
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

/* Teaching Fullscreen Mode: 100vh pure white, zero vertical scrollbar */
.reader-shell:fullscreen,
.reader-shell.is-pseudo-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  z-index: 900;
}

.reader-shell:fullscreen .reader-toolbar,
.reader-shell.is-pseudo-fullscreen .reader-toolbar {
  display: none;
}

.reader-shell:fullscreen .reader-main,
.reader-shell.is-pseudo-fullscreen .reader-main {
  flex: 1;
  width: 100%;
  height: 100%;
  gap: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.75rem 1rem 4.2rem;
}

.reader-shell:fullscreen .reader-stage-wrap,
.reader-shell.is-pseudo-fullscreen .reader-stage-wrap {
  width: 100%;
  height: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reader-shell:fullscreen .slide-stage,
.reader-shell.is-pseudo-fullscreen .slide-stage {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--color-border);
}

/* Fullscreen overlay drawers */
.reader-shell:fullscreen .reader-sidebar,
.reader-shell.is-pseudo-fullscreen .reader-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 85vw);
  max-height: 100vh;
  z-index: 920;
  border-radius: 0;
  box-shadow: var(--shadow-lg);
}

.reader-shell:fullscreen .reader-drawer,
.reader-shell.is-pseudo-fullscreen .reader-drawer {
  position: fixed;
  right: 1rem;
  bottom: 4.4rem;
  width: min(460px, calc(100vw - 2rem));
  max-height: 50vh;
  z-index: 920;
  box-shadow: var(--shadow-lg);
  background: var(--color-surface);
}

.reader-shell:fullscreen .reader-drawer[data-fs-open="false"],
.reader-shell.is-pseudo-fullscreen .reader-drawer[data-fs-open="false"] {
  display: none;
}

.reader-shell:fullscreen .reader-drawer-body,
.reader-shell.is-pseudo-fullscreen .reader-drawer-body {
  max-height: 40vh;
  overflow-y: auto;
}

/* Floating Fullscreen Control Bar */
.fs-floating-bar {
  display: none;
}

.reader-shell:fullscreen .fs-floating-bar,
.reader-shell.is-pseudo-fullscreen .fs-floating-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  position: fixed;
  left: 50%;
  bottom: 0.75rem;
  transform: translateX(-50%);
  z-index: 930;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(20, 38, 29, 0.9);
  color: #ffffff;
  box-shadow: var(--shadow-lg);
}

.fs-floating-bar .btn {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
  color: #ffffff;
  min-height: 34px;
  padding: 0.25rem 0.7rem;
  font-size: 0.84rem;
}

.fs-floating-bar .btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.24);
  border-color: #ffffff;
}

.fs-floating-bar .btn.is-tool-active {
  background: #ffffff;
  color: var(--color-primary);
  border-color: #ffffff;
}

.fs-divider {
  width: 1px;
  height: 22px;
  background: rgba(255, 255, 255, 0.28);
  margin: 0 0.15rem;
}

.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.color-dot.is-active {
  border-color: #ffffff;
  transform: scale(1.16);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.annotation-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 8;
  pointer-events: none;
  touch-action: none;
}

.annotation-canvas.is-interactive {
  pointer-events: auto;
  cursor: crosshair;
}

.annotation-canvas.is-laser {
  pointer-events: auto;
  cursor: none;
}

.fs-page-indicator {
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0 0.4rem;
  white-space: nowrap;
}

/* Exercises */
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.choice-btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  padding: 0.65rem 0.9rem;
  min-height: var(--touch-min);
  border-radius: var(--radius-md);
}

.choice-btn.is-selected {
  border-color: var(--color-primary);
  background: var(--color-secondary-soft);
  color: var(--color-primary);
}

.choice-feedback {
  margin-top: 0.75rem;
  padding: 0.75rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
}

.choice-feedback.is-correct {
  background: var(--color-success-bg);
  border: 1px solid #86efac;
  color: var(--color-success);
}

.choice-feedback.is-wrong {
  background: var(--color-danger-bg);
  border: 1px solid #fca5a5;
  color: var(--color-danger);
}

.preview-box {
  border: 2px dashed var(--color-secondary);
  background: #f0fdf4;
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 0.75rem;
}

/* Toast Stack (Bottom Right) */
.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-left: 4px solid var(--color-primary);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  color: var(--color-text);
}

.toast-success {
  border-left-color: var(--color-success);
}

.toast-error {
  border-left-color: var(--color-danger);
}

.toast-info {
  border-left-color: var(--color-info);
}

.toast-close {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.25rem;
}

/* Mobile Responsive (< 768px) */
.mobile-drawer-backdrop {
  display: none;
}

@media (max-width: 767px) {
  .topbar-inner {
    padding: 0.65rem 0.9rem;
  }

  .page-main {
    padding: 0.85rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .btn,
  .tab-btn,
  .input,
  .select {
    min-height: var(--touch-min);
  }

  .reader-shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 0.75rem;
  }

  .reader-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 85vw);
    max-height: 100vh;
    z-index: 800;
    border-radius: 0;
    box-shadow: var(--shadow-lg);
  }

  .reader-shell.sidebar-collapsed .reader-sidebar {
    display: none;
  }

  .reader-shell:not(.sidebar-collapsed) .mobile-drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 38, 29, 0.45);
    z-index: 790;
  }

  .reader-shell:fullscreen .slide-stage,
  .reader-shell.is-pseudo-fullscreen .slide-stage {
    width: 100%;
    height: auto;
    max-height: calc(100vh - 5.2rem);
  }
}

/* Printable Seat Pass & QR Code Sheet */
.qr-sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}

.qr-card {
  background: #ffffff;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.45rem;
  break-inside: avoid;
}

.qr-card-seat {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-primary);
}

.qr-card-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .toast-stack,
  .no-print {
    display: none !important;
  }

  .page-main {
    max-width: none;
    padding: 0;
  }

  .card {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .qr-sheet-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .qr-card {
    border: 1px solid #999999;
    padding: 0.6rem;
  }
}
