/* ==========================================================================
   SỔ CHÉP BÀI GIÁO ÁN — SỸ QUAN & QNCN (NỐI TIẾP THÁNG 11)
   Responsive Web Reader & Progress Tracker
   ========================================================================== */

:root,
[data-theme="sepia"] {
  --bg-app: #f4efe4;
  --bg-surface: #fbf8f1;
  --bg-surface-elevated: #ffffff;
  --bg-sidebar: #efe9da;
  --bg-header: rgba(251, 248, 241, 0.94);
  --bg-hover: rgba(31, 77, 54, 0.06);
  --bg-subtle: #ebe3d1;

  --text-primary: #1f2421;
  --text-secondary: #4c564f;
  --text-muted: #737d76;

  --brand-primary: #1b4d35;
  --brand-primary-hover: #143b28;
  --brand-primary-soft: rgba(27, 77, 53, 0.11);
  --brand-accent: #b45309;
  --brand-accent-soft: rgba(180, 83, 9, 0.13);

  --pin-bg: #fef3c7;
  --pin-border: #d97706;
  --pin-text: #92400e;
  --pin-shadow: rgba(217, 119, 6, 0.22);

  --nov-bg: linear-gradient(135deg, #1b4d35 0%, #276749 100%);
  --nov-badge-bg: #fef3c7;
  --nov-badge-text: #92400e;

  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.12);

  --border-color: #ded5c3;
  --border-strong: #c8bca4;
  --shadow-sm: 0 1px 3px rgba(25, 32, 28, 0.06);
  --shadow-md: 0 6px 20px rgba(25, 32, 28, 0.09);
  --shadow-lg: 0 14px 36px rgba(25, 32, 28, 0.16);
}

[data-theme="light"] {
  --bg-app: #f1f5f3;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-sidebar: #f8faf9;
  --bg-header: rgba(255, 255, 255, 0.94);
  --bg-hover: rgba(27, 77, 53, 0.06);
  --bg-subtle: #e7eeea;

  --text-primary: #141a17;
  --text-secondary: #45524b;
  --text-muted: #6c7a72;

  --brand-primary: #184e35;
  --brand-primary-hover: #113a27;
  --brand-primary-soft: rgba(24, 78, 53, 0.1);
  --brand-accent: #c2410c;
  --brand-accent-soft: rgba(194, 65, 12, 0.1);

  --pin-bg: #fffbeb;
  --pin-border: #ea580c;
  --pin-text: #9a3412;
  --pin-shadow: rgba(234, 88, 12, 0.18);

  --border-color: #dce4df;
  --border-strong: #c1cec6;
}

[data-theme="dark"] {
  --bg-app: #111614;
  --bg-surface: #18201c;
  --bg-surface-elevated: #202a25;
  --bg-sidebar: #141b18;
  --bg-header: rgba(20, 27, 24, 0.94);
  --bg-hover: rgba(110, 231, 183, 0.07);
  --bg-subtle: #222d28;

  --text-primary: #e7ece9;
  --text-secondary: #a8b8b0;
  --text-muted: #76887f;

  --brand-primary: #34d399;
  --brand-primary-hover: #6ee7b7;
  --brand-primary-soft: rgba(52, 211, 153, 0.14);
  --brand-accent: #fbbf24;
  --brand-accent-soft: rgba(251, 191, 36, 0.14);

  --pin-bg: rgba(245, 158, 11, 0.16);
  --pin-border: #f59e0b;
  --pin-text: #fcd34d;
  --pin-shadow: rgba(245, 158, 11, 0.2);

  --nov-bg: linear-gradient(135deg, #163d2b 0%, #1e523a 100%);
  --nov-badge-bg: rgba(251, 191, 36, 0.18);
  --nov-badge-text: #fde68a;

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.15);

  --border-color: #28352f;
  --border-strong: #374840;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
}

:root {
  --reader-font-size: 19px;
  --reader-line-height: 1.78;
  --reader-font-sans: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --reader-font-serif: "Lora", "Times New Roman", Georgia, serif;
  --reader-font: var(--reader-font-sans);
  --header-height: 60px;
  --sidebar-width: 340px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;
}

body {
  margin: 0;
  font-family: var(--reader-font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

/* ==========================================================================
   TOP STICKY HEADER
   ========================================================================== */

.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.icon-btn.active {
  background: var(--brand-primary-soft);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.brand-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--brand-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Track Switcher (Sỹ quan vs QNCN) */
.track-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-subtle);
  padding: 3px;
  border-radius: 11px;
  border: 1px solid var(--border-color);
  gap: 3px;
}

.track-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.track-tab:hover {
  color: var(--text-primary);
}

.track-tab.active {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}

[data-theme="dark"] .track-tab.active {
  background: #1f6f4c;
  color: #ffffff;
}

.track-count-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.08);
}

.track-tab.active .track-count-pill {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.reading-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: transparent;
  pointer-events: none;
}

.reading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  transition: width 0.12s linear;
}

/* ==========================================================================
   APP SHELL (SIDEBAR + MAIN CONTENT)
   ========================================================================== */

.app-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
  position: relative;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left 0.22s ease, transform 0.24s ease;
  z-index: 90;
}

body.sidebar-collapsed .sidebar {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-backdrop {
  display: none;
}

.sidebar-top {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Saved Position Status Card in Sidebar */
.saved-status-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--brand-accent);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.saved-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.saved-status-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--brand-accent);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.saved-time {
  font-size: 11px;
  color: var(--text-muted);
}

.saved-status-desc {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 8px;
}

.saved-status-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-jump-saved {
  flex: 1;
  height: 30px;
  border-radius: 7px;
  border: none;
  background: var(--brand-primary);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: opacity 0.15s;
}

[data-theme="dark"] .btn-jump-saved {
  background: #1f6f4c;
}

.btn-jump-saved:hover {
  opacity: 0.92;
}

.completion-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px dashed var(--border-color);
}

.completion-bar-mini {
  width: 78px;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 99px;
  overflow: hidden;
}

.completion-bar-mini > span {
  display: block;
  height: 100%;
  background: var(--success);
  border-radius: 99px;
  transition: width 0.2s ease;
}

/* Search Input */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 32px 0 33px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus {
  border-color: var(--brand-primary);
}

.search-clear {
  position: absolute;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.search-clear.visible {
  display: inline-flex;
}

/* Filter Chips */
.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-label {
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 1px;
}

.chip {
  height: 27px;
  padding: 0 9px;
  border-radius: 99px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.chip.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
}

[data-theme="dark"] .chip.active {
  background: #1f6f4c;
  border-color: #34d399;
}

.sidebar-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.toggle-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.toggle-check input {
  accent-color: var(--brand-primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* TOC Lesson List */
.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 24px;
  overscroll-behavior: contain;
}

.toc-section-header {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-primary);
  padding: 10px 8px 6px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toc-section-header.nov-section {
  color: var(--brand-accent);
  border-top: 1px solid var(--border-color);
  margin-top: 10px;
  padding-top: 12px;
}

.toc-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.12s ease;
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.toc-item:hover {
  background: var(--bg-hover);
}

.toc-item.active {
  background: var(--bg-surface);
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.toc-item.pinned-lesson {
  border-left: 3px solid var(--pin-border);
}

.toc-check-btn {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-surface);
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  padding: 0;
  transition: all 0.14s ease;
}

.toc-check-btn:hover {
  border-color: var(--success);
}

.toc-item.completed .toc-check-btn {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}

.toc-item-body {
  flex: 1;
  min-width: 0;
}

.toc-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 2px;
}

.toc-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-primary);
}

.toc-date {
  font-size: 11px;
  color: var(--text-muted);
}

.toc-assignee {
  font-size: 10.5px;
  font-weight: 700;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--brand-accent-soft);
  color: var(--brand-accent);
}

.toc-pin-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--pin-text);
  background: var(--pin-bg);
  border: 1px solid var(--pin-border);
  border-radius: 99px;
  padding: 0 5px;
}

.toc-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.38;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toc-item.completed .toc-title {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* ==========================================================================
   MAIN READING VIEW
   ========================================================================== */

.main-pane {
  flex: 1;
  min-width: 0;
  padding: 20px 18px 120px;
}

.reader-container {
  max-width: 820px;
  margin: 0 auto;
}

/* QNCN Sub-Track Selector Banner (Main Screen) */
.qncn-selector-panel {
  background: var(--bg-surface);
  border: 1.5px solid var(--brand-primary);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.qncn-selector-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--brand-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.qncn-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.qncn-profile-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-app);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 3px;
}

.qncn-profile-card:hover {
  border-color: var(--brand-primary);
  background: var(--bg-hover);
}

.qncn-profile-card.active {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(27, 77, 53, 0.24);
}

[data-theme="dark"] .qncn-profile-card.active {
  background: #1f6f4c;
  border-color: #34d399;
}

.qncn-card-person {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.qncn-card-dept {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.qncn-profile-card.active .qncn-card-dept {
  color: rgba(255, 255, 255, 0.88);
}

.qncn-card-meta {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--bg-surface);
  color: var(--brand-primary);
}

.qncn-profile-card.active .qncn-card-meta {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.badge-common-qncn {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}

/* Top Track Banner */
.track-hero {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.track-hero-info h1 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 800;
  color: var(--brand-primary);
}

.track-hero-info p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.track-hero-tip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  padding: 7px 12px;
  border-radius: 9px;
  background: var(--pin-bg);
  border: 1px solid var(--pin-border);
  color: var(--pin-text);
  font-weight: 600;
}

/* Seamless Tháng 11 Milestone Divider */
.november-divider {
  margin: 30px 0 22px;
  padding: 20px 22px;
  border-radius: 14px;
  background: var(--nov-bg);
  color: #ffffff;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.november-divider-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--nov-badge-bg);
  color: var(--nov-badge-text);
  margin-bottom: 8px;
}

.november-divider h2 {
  margin: 0 0 5px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.november-divider p {
  margin: 0;
  font-size: 13.5px;
  opacity: 0.92;
}

/* Lesson Card */
.lesson-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.lesson-card.has-pin {
  border-color: var(--pin-border);
}

.lesson-card.is-completed {
  border-color: var(--border-color);
}

.lesson-header {
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(to bottom, var(--bg-hover), transparent);
}

.lesson-meta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 9px;
}

.lesson-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.badge-num {
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--brand-primary);
  color: #ffffff;
}

[data-theme="dark"] .badge-num {
  background: #1f6f4c;
}

.badge-date {
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 7px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.badge-month-nov {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--brand-accent-soft);
  color: var(--brand-accent);
}

.badge-assignee {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 7px;
  background: var(--pin-bg);
  color: var(--pin-text);
  border: 1px solid var(--pin-border);
}

.lesson-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-complete-lesson {
  height: 30px;
  padding: 0 11px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-complete-lesson:hover {
  border-color: var(--success);
  color: var(--success);
}

.lesson-card.is-completed .btn-complete-lesson {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.lesson-teacher {
  font-size: 13.5px;
  font-style: italic;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.lesson-title {
  margin: 0;
  font-family: var(--reader-font);
  font-size: calc(var(--reader-font-size) * 1.08);
  line-height: 1.42;
  font-weight: 800;
  color: var(--text-primary);
}

.lesson-title-prefix {
  color: var(--brand-primary);
}

/* Lesson Content Body */
.lesson-body {
  padding: 16px 22px 22px;
  font-family: var(--reader-font);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
  color: var(--text-primary);
}

body.collapse-completed .lesson-card.is-completed:not(.has-pin) .lesson-body {
  display: none;
}

body.collapse-completed .lesson-card.is-completed:not(.has-pin) .lesson-header {
  border-bottom: none;
  opacity: 0.78;
}

/* Individual Copyable Paragraphs */
.para {
  position: relative;
  padding: 6px 12px 6px 14px;
  margin: 2px -12px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background-color 0.12s ease, opacity 0.18s ease;
}

.para:hover {
  background-color: var(--bg-hover);
}

.para-prefix {
  font-weight: 700;
  margin-right: 6px;
  color: var(--brand-primary);
}

.para.role-sec-part {
  text-align: center;
  font-weight: 800;
  margin-top: 14px;
  margin-bottom: 6px;
  color: var(--brand-primary);
  text-transform: uppercase;
}

.para.role-sec-roman {
  font-weight: 800;
  margin-top: 14px;
  margin-bottom: 4px;
  color: var(--brand-primary);
}

.para.role-sec-num {
  font-weight: 700;
  margin-top: 10px;
  margin-bottom: 2px;
}

.para.role-sec-alpha {
  font-weight: 700;
  margin-top: 6px;
}

.para.role-body {
  text-indent: 1.4em;
  text-align: justify;
}

.para.role-bullet,
.para.role-ordered,
.para.role-dash-item {
  padding-left: 26px;
  text-align: justify;
}

.para.role-bullet.lvl-1,
.para.role-plus-item {
  padding-left: 42px;
  text-align: justify;
}

.para.align-center {
  text-align: center;
  text-indent: 0;
}

/* Dim already-passed paragraphs when user turns on "Làm mờ phần đã chép qua" */
body.dim-passed .para.is-passed {
  opacity: 0.42;
}

body.dim-passed .para.is-passed:hover {
  opacity: 0.85;
}

/* Pinned ("Đang chép đến đây") Highlight */
.para.is-pinned {
  background: var(--pin-bg) !important;
  border-left: 4px solid var(--pin-border);
  box-shadow: 0 2px 10px var(--pin-shadow);
  padding-top: 26px;
  margin-top: 8px;
  margin-bottom: 8px;
  opacity: 1 !important;
}

.pin-flag {
  position: absolute;
  top: 4px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--reader-font-sans);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--pin-text);
  text-indent: 0;
  letter-spacing: 0.01em;
}

.pin-unpin-hint {
  font-weight: 500;
  opacity: 0.78;
  font-size: 11px;
}

/* Brief pulse when jumping to auto-saved scroll paragraph */
@keyframes flashSavedPulse {
  0% { background-color: var(--pin-bg); }
  75% { background-color: var(--pin-bg); }
  100% { background-color: transparent; }
}

.para.flash-restored {
  animation: flashSavedPulse 2.2s ease forwards;
  border-left-color: var(--brand-accent);
}

/* Search Highlight */
mark.hl {
  background: #fde047;
  color: #1c1917;
  padding: 0 2px;
  border-radius: 3px;
}

/* Single Lesson Focus Navigation Footer */
.focus-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

/* Empty Filter State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  color: var(--text-secondary);
}

/* ==========================================================================
   FLOATING BOTTOM COPYING DOCK (1-THUMB CONTROL)
   ========================================================================== */

.bottom-dock {
  position: fixed;
  bottom: 14px;
  left: calc(var(--sidebar-width) + (100vw - var(--sidebar-width)) / 2);
  transform: translateX(-50%);
  z-index: 95;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 7px 10px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 20px);
  transition: left 0.22s ease;
}

body.sidebar-collapsed .bottom-dock {
  left: 50%;
}

.dock-info {
  display: flex;
  flex-direction: column;
  padding: 0 6px;
  min-width: 0;
  max-width: 240px;
}

.dock-status-tag {
  font-size: 10.5px;
  font-weight: 800;
  color: var(--brand-accent);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-lesson-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.dock-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

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

[data-theme="dark"] .dock-btn.primary {
  background: #1f6f4c;
}

.dock-btn.accent {
  background: var(--pin-bg);
  border-color: var(--pin-border);
  color: var(--pin-text);
}

/* ==========================================================================
   SETTINGS POPOVER PANEL
   ========================================================================== */

.settings-popover {
  position: fixed;
  top: calc(var(--header-height) + 8px);
  right: 14px;
  width: 310px;
  max-width: calc(100vw - 28px);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 120;
  display: none;
  flex-direction: column;
  gap: 14px;
}

.settings-popover.open {
  display: flex;
}

.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

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

.segmented-row.two-cols {
  grid-template-columns: repeat(2, 1fr);
}

.seg-btn {
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}

.seg-btn.active {
  background: var(--brand-primary-soft);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.font-size-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.font-size-stepper button {
  flex: 1;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
}

.font-size-stepper span {
  min-width: 54px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

/* Toast Notification */
.toast {
  position: fixed;
  top: calc(var(--header-height) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: #1c2420;
  color: #ffffff;
  padding: 9px 16px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (TABLET & MOBILE)
   ========================================================================== */

@media (max-width: 1024px) {
  .brand-block {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    margin-left: 0 !important;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    width: min(340px, 88vw);
  }

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

  body.mobile-drawer-open .sidebar-backdrop {
    display: block;
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.42);
    z-index: 85;
  }

  .bottom-dock {
    left: 50% !important;
    width: calc(100vw - 20px);
    justify-content: space-between;
  }
}

@media (max-width: 640px) {
  :root {
    --reader-font-size: 18px;
    --header-height: 56px;
  }

  .top-header {
    padding: 0 8px;
    gap: 6px;
  }

  .btn-label-desktop {
    display: none;
  }

  .icon-btn {
    padding: 0 9px;
    height: 36px;
  }

  .track-tab {
    padding: 0 10px;
    font-size: 12.5px;
    height: 32px;
    gap: 5px;
  }

  .track-count-pill {
    display: none;
  }

  .main-pane {
    padding: 12px 10px 116px;
  }

  .qncn-selector-panel {
    padding: 12px;
    margin-bottom: 12px;
  }

  .qncn-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
  }

  .qncn-profile-card {
    padding: 9px 10px;
  }

  .qncn-card-person {
    font-size: 13.5px;
  }

  .track-hero {
    padding: 13px 14px;
    margin-bottom: 14px;
  }

  .track-hero-info h1 {
    font-size: 16.5px;
  }

  .lesson-header {
    padding: 13px 14px 11px;
  }

  .lesson-body {
    padding: 12px 14px 16px;
  }

  .para {
    padding: 6px 8px 6px 10px;
    margin: 2px -6px;
  }

  .para.role-body {
    text-indent: 1.1em;
    text-align: left;
  }

  .para.role-bullet,
  .para.role-ordered,
  .para.role-dash-item {
    padding-left: 20px;
    text-align: left;
  }

  .para.role-bullet.lvl-1,
  .para.role-plus-item {
    padding-left: 32px;
    text-align: left;
  }

  .para.is-pinned {
    padding-top: 25px;
  }

  .dock-info {
    max-width: 130px;
  }

  .dock-btn {
    padding: 0 10px;
    height: 36px;
    font-size: 12.5px;
  }
}

@media print {
  .top-header,
  .sidebar,
  .bottom-dock,
  .settings-popover,
  .lesson-actions,
  .track-hero-tip {
    display: none !important;
  }
  .main-pane {
    padding: 0;
  }
  .lesson-card {
    box-shadow: none;
    break-inside: avoid-page;
  }
}
