/* ============================================================
   GoodNotes-style annotation overlay
   - SVG overlay covers full document
   - Floating bottom toolbar
   - Apple Pencil first, mouse / touch supported
   ============================================================ */

.annot-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none; /* default: page is interactive */
  z-index: 50;
  overflow: visible;
}

/* Active drawing mode. touch-action:pan-y lets the FINGER scroll/zoom the page
   natively (smooth, momentum, no judder). The Apple Pencil is blocked from
   scrolling in JS (touchType==='stylus' → preventDefault) so it draws instead. */
.annot-svg.annot-mode-draw,
.annot-svg.annot-mode-erase {
  pointer-events: auto;
  touch-action: pan-y pinch-zoom;
  cursor: crosshair;
}

.annot-svg.annot-mode-erase { cursor: cell; }

.annot-svg.annot-hidden { display: none; }

/* ---------- Toolbar ---------- */
.annot-toolbar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(253, 250, 243, 0.96);
  border: 1px solid #d8cdb3;
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(26, 24, 20, 0.18);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  color: #3a3530;
  z-index: 100;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}

.annot-toolbar button,
.annot-toolbar .annot-color {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #3a3530;
  font: inherit;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
  line-height: 1;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.annot-toolbar button:hover { background: #f4ecd9; }
.annot-toolbar button:active { transform: scale(0.96); }
.annot-toolbar button.annot-active {
  background: #1a1814;
  color: #fdfaf3;
  border-color: #1a1814;
}

.annot-toolbar .annot-sep {
  width: 1px;
  align-self: stretch;
  background: #d8cdb3;
  margin: 2px 2px;
}

/* Mode buttons grouped on a subtle inset track */
.annot-toolbar .annot-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: rgba(26, 24, 20, 0.05);
}

/* Colour palette — perfectly round swatches (the shared min-height:32px
   was squashing the 24px swatches into vertical ellipses). */
.annot-colors {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.annot-toolbar .annot-color {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.annot-toolbar .annot-color.annot-active {
  border-color: #1a1814;
  transform: scale(1.18);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(26, 24, 20, 0.25);
}

/* Icon-only action buttons (undo / redo / clear / hide) */
.annot-toolbar .annot-icon-btn {
  padding: 7px;
  min-height: 0;
  color: #3a3530;
}
.annot-toolbar .annot-icon-btn svg {
  width: 19px;
  height: 19px;
  display: block;
}
.annot-toolbar .annot-icon-btn[data-act="clear"]:hover { color: #a64427; background: #f6e3da; }

.annot-toolbar input[type="range"] {
  width: 92px;
  accent-color: #1f5e5b;
}

.annot-size-preview {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #1a1814;
  transition: width 0.1s ease, height 0.1s ease;
  flex-shrink: 0;
}

.annot-toolbar .annot-label {
  font-size: 11px;
  color: #6b6358;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding-right: 2px;
}

/* Compact handle when toolbar is collapsed */
.annot-toolbar.annot-collapsed > :not(.annot-toggle-btn):not(.annot-tip) { display: none; }
.annot-toolbar.annot-collapsed { padding: 6px 8px; }

.annot-tip {
  display: none;
  font-size: 11px;
  color: #6b6358;
  padding: 0 4px;
}
.annot-toolbar.annot-collapsed .annot-tip { display: inline; }

/* Tiny status indicator (saving) */
.annot-saved {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 94, 91, 0.9);
  color: #fdfaf3;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 99;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.annot-saved.annot-show { opacity: 1; }

@media (max-width: 520px) {
  .annot-toolbar { font-size: 12px; gap: 6px; padding: 6px 8px; bottom: 10px; }
  .annot-toolbar button { padding: 5px 7px; }
  .annot-toolbar input[type="range"] { width: 70px; }
}

@media print {
  .annot-toolbar, .annot-saved { display: none !important; }
}

/* ============================================================
   Quick Check — inline problem after each concept section
   ============================================================ */
.quick-check {
  margin: 1.6em 0 2em;
  padding: 14px 18px 12px;
  background: linear-gradient(180deg, #fdfaf3 0%, #f6f1e7 100%);
  border: 1px solid #d8cdb3;
  border-left: 4px solid #a64427;
  border-radius: 6px;
  position: relative;
  box-shadow: 0 1px 3px rgba(26, 24, 20, 0.06);
}

.quick-check .qc-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.quick-check .qc-badge {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #a64427;
  font-weight: 600;
}

.quick-check .qc-source {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72em;
  color: #6b6358;
}
.quick-check .qc-source a {
  color: #6b6358;
  text-decoration: none;
  border-bottom: 1px dotted #6b6358;
}
.quick-check .qc-source a:hover { color: #a64427; border-bottom-color: #a64427; }

.quick-check .qc-problem {
  margin: 4px 0 6px;
  font-size: 0.98em;
  line-height: 1.55;
}
.quick-check .qc-problem p { margin: 0; }

.quick-check details {
  margin-top: 8px;
}
.quick-check details > summary {
  cursor: pointer;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.78em;
  letter-spacing: 0.04em;
  color: #1f5e5b;
  padding: 6px 10px;
  background: #d4e8e6;
  border-radius: 5px;
  display: inline-block;
  user-select: none;
  -webkit-user-select: none;
  list-style: none;
  transition: background 0.15s ease;
}
.quick-check details > summary::-webkit-details-marker { display: none; }
.quick-check details > summary::before {
  content: '▸ ';
  display: inline-block;
  margin-right: 2px;
  transition: transform 0.15s ease;
}
.quick-check details[open] > summary::before { content: '▾ '; }
.quick-check details > summary:hover { background: #b8d8d4; }

.quick-check .qc-solution {
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(212, 232, 230, 0.4);
  border-left: 3px solid #1f5e5b;
  border-radius: 4px;
  font-size: 0.95em;
  line-height: 1.6;
}
.quick-check .qc-solution p { margin: 0.4em 0; }
.quick-check .qc-solution p:first-child { margin-top: 0; }
.quick-check .qc-solution p:last-child { margin-bottom: 0; }

.quick-check .qc-more {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #d8cdb3;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.74em;
  color: #6b6358;
  letter-spacing: 0.02em;
}
.quick-check .qc-more a {
  color: #a64427;
  text-decoration: none;
  border-bottom: 1px dotted #a64427;
  margin: 0 3px;
}
.quick-check .qc-more a:hover { color: #1a1814; }

@media (max-width: 720px) {
  .quick-check { padding: 12px 14px 10px; }
}

@media print {
  .quick-check details { open: ''; }
  .quick-check details > summary { display: none; }
}

/* ============================================================
   READING PROGRESS BAR (auto-injected & wired by annotate.js)
   Lives in the shared asset so every note gets it for free,
   even older notes whose inline <style> predates the feature.
   Uses theme vars with fallbacks so it works standalone.
   ============================================================ */
.progress-track {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(216, 205, 179, 0.4);
  z-index: 1200;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal, #1f5e5b), var(--teal-soft, #3a8b86));
  transition: width 0.1s ease;
}
.progress-label {
  position: fixed;
  top: 10px;
  right: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-muted, #6b6358);
  letter-spacing: 0.1em;
  z-index: 1200;
  background: var(--paper, #f6f1e7);
  padding: 4px 10px;
  border: 1px solid var(--paper-line, #d8cdb3);
  border-radius: 2px;
}

@media print {
  .progress-track, .progress-label { display: none !important; }
}

/* ============================================================
   NOTE TOP BAR (shared, injected by annotate.js)
   Back button + material title (left) + reading % (right).
   ============================================================ */
body.has-note-topbar { padding-top: 46px; }
.note-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: rgba(246, 241, 231, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--paper-line, #d8cdb3);
  z-index: 1100;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
}
.note-topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  color: var(--rust, #a64427);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.note-topbar-back:hover { color: var(--ink, #1a1814); }
.note-topbar-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 14px;
  color: var(--ink-soft, #3a3530);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* the reading % lives inside the bar — override the floating chip style */
.note-topbar .progress-label {
  position: static;
  top: auto; right: auto;
  margin-left: auto;
  flex-shrink: 0;
  background: transparent;
  border: none;
  padding: 0;
  z-index: auto;
}

@media print {
  .note-topbar { display: none !important; }
  body.has-note-topbar { padding-top: 0 !important; }
}
