/* ==========================================================================
   GRAMMAR TRACKER — OBSIDIAN & ICE DESIGN SYSTEM
   Background: pure obsidian. Accent: cold electric blue (#7dd3fc).
   Signature: razor-thin 1px rules + monospaced lecture numbers.
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600;700&display=swap');

:root {
  /* Obsidian Base */
  --bg-body:              #09090b;
  --bg-surface:           #0f0f11;
  --bg-surface-elevated:  #18181b;
  --bg-card:              #111113;
  --bg-card-hover:        #1c1c1f;
  --bg-glass:             rgba(9, 9, 11, 0.92);

  /* Ice Borders */
  --border-subtle:  rgba(255, 255, 255, 0.06);
  --border-medium:  rgba(255, 255, 255, 0.12);
  --border-bright:  rgba(255, 255, 255, 0.28);

  /* Typography */
  --text-main:      #f4f4f5;
  --text-muted:     #a1a1aa;
  --text-faint:     #52525b;

  /* Cold Blue-White Accent — the only real color */
  --accent:         #7dd3fc;
  --accent-dim:     rgba(125, 211, 252, 0.12);
  --accent-glow:    rgba(125, 211, 252, 0.20);
  --accent-glow-subtle: rgba(125, 211, 252, 0.08);
  --accent-hover:   #bae6fd;
  --accent-pink:    #7dd3fc;

  /* Semantic */
  --success-color:  #4ade80;
  --success-bg:     rgba(74, 222, 128, 0.10);
  --danger-color:   #f87171;
  --danger-bg:      rgba(248, 113, 113, 0.10);
  --star-color:     #fbbf24;
  --star-glow:      rgba(251, 191, 36, 0.25);

  /* Video / PDF */
  --video-color:    #7dd3fc;
  --video-bg:       rgba(125, 211, 252, 0.08);
  --video-border:   rgba(125, 211, 252, 0.18);
  --pdf-color:      #a78bfa;
  --pdf-bg:         rgba(167, 139, 250, 0.08);
  --pdf-border:     rgba(167, 139, 250, 0.18);

  /* Geometry */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.5);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.6);
  --shadow-lg:  0 12px 36px rgba(0,0,0,0.7);
  --shadow-glow: 0 0 16px rgba(125, 211, 252, 0.15);

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --transition: background-color 0.18s ease,
                border-color 0.18s ease,
                color 0.18s ease,
                transform 0.18s ease,
                box-shadow 0.18s ease;

  /* Gradient (kept for compatibility, now blue) */
  --accent-gradient: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 100%);

  /* Type */
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Mono', monospace;
}

[data-theme="light"] {
  --bg-body:              #fafafa;
  --bg-surface:           #ffffff;
  --bg-surface-elevated:  #f4f4f5;
  --bg-card:              #ffffff;
  --bg-card-hover:        #f9f9fb;
  --bg-glass:             rgba(255, 255, 255, 0.92);

  --border-subtle:  rgba(0, 0, 0, 0.07);
  --border-medium:  rgba(0, 0, 0, 0.13);
  --border-bright:  rgba(0, 0, 0, 0.30);

  --text-main:      #09090b;
  --text-muted:     #52525b;
  --text-faint:     #a1a1aa;

  --accent:         #0284c7;
  --accent-dim:     rgba(2, 132, 199, 0.10);
  --accent-glow:    rgba(2, 132, 199, 0.18);
  --accent-glow-subtle: rgba(2, 132, 199, 0.08);
  --accent-hover:   #0369a1;
  --accent-pink:    #0284c7;
  --accent-gradient: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);

  --video-color:    #0284c7;
  --video-bg:       rgba(2, 132, 199, 0.07);
  --video-border:   rgba(2, 132, 199, 0.18);

  --shadow-sm:  0 1px 4px rgba(0,0,0,0.07);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:  0 12px 36px rgba(0,0,0,0.14);
}

/* ==========================================================================
   RESET & ACCESSIBILITY BASE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.55;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* Accessible Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent-pink);
  color: var(--bg-body);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.88rem;
  z-index: 999999;
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 16px;
  outline: 2px solid var(--text-main);
}

:focus-visible {
  outline: 1.5px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* Tabular Numerics to avoid digit layout shift */
.stat-val-sm,
.ring-pct-sm,
.gauge-fraction,
.num-badge,
.chapter-progress-text,
.note-char-count,
.date-tag {
  font-variant-numeric: tabular-nums;
}

/* Balanced Headings */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  transition: var(--transition);
}

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ==========================================================================
   TOP NAVIGATION
   ========================================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border-subtle);
  height: 58px;
}

.nav-container {
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 1rem;
}

.brand-title {
  display: block;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.025em;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  background: var(--accent-dim);
  border: 1px solid rgba(125, 211, 252, 0.20);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-pink);
  box-shadow: 0 0 8px var(--accent-pink);
  animation: pulse-dot-anim 2s infinite ease-in-out;
}

@keyframes pulse-dot-anim {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

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

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-size: 0.86rem;
  font-weight: 600;
}

.nav-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  color: var(--text-main);
  transform: translateY(-1px);
}

.nav-btn.icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  font-size: 1.05rem;
}

/* ==========================================================================
   HERO DASHBOARD & COMPACT LIVE STATS
   ========================================================================== */
.hero-dashboard {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 18px 24px 20px;
}

.hero-container {
  max-width: 1440px;
  margin: 0 auto;
}

.hero-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.batch-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px;
  background: var(--accent-dim);
  border: 1px solid rgba(125, 211, 252, 0.20);
  border-radius: var(--radius-full);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.hero-title {
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  line-height: 1.2;
  color: var(--text-main);
}

.hero-gauge-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.hero-gauge-card.mastery-achieved {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.08) 0%, rgba(125, 211, 252, 0.08) 100%), var(--bg-surface-elevated);
  border-color: rgba(251, 191, 36, 0.4);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.15);
}

.hero-gauge-card.mastery-achieved .ring-fill {
  stroke: var(--star-color);
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.6));
}

.hero-gauge-card.mastery-achieved .gauge-status {
  color: var(--star-color);
  font-weight: 700;
}

.ring-container-sm {
  position: relative;
  width: 66px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring-sm {
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

.ring-bg {
  fill: transparent;
  stroke: var(--border-subtle);
}

.ring-fill {
  fill: transparent;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 163.36;
  stroke-dashoffset: 163.36;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 5px var(--accent-glow));
}

.ring-pct-sm {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-main);
  text-align: center;
}

.gauge-meta {
  display: flex;
  flex-direction: column;
}

.gauge-fraction {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.gauge-status {
  font-size: 0.76rem;
  color: var(--accent-pink);
  font-weight: 600;
}

/* ==========================================================================
   9 VIDEO CHECKPOINTS MILESTONE TIMELINE
   ========================================================================== */
.timeline-section {
  background: radial-gradient(ellipse 70% 60% at 50% 90%, rgba(125, 211, 252, 0.06) 0%, transparent 80%), var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 24px 22px 24px;
  margin-top: 0;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 14px;
}

.timeline-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.timeline-icon {
  color: var(--accent);
  font-size: 0.95rem;
}

.timeline-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.timeline-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(125, 211, 252, 0.2);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.timeline-container {
  position: relative;
  width: 100%;
  padding: 10px 0 6px 0;
  overflow-x: auto;
  overflow-y: visible;
}

.timeline-track-wrap {
  position: relative;
  height: 98px;
  min-width: 720px;
  margin: 0 45px;
}

.timeline-track-bg {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
}

.timeline-track-fill {
  position: absolute;
  top: 52px;
  left: 0;
  height: 6px;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  box-shadow: 0 0 14px var(--accent-glow), 0 0 4px var(--accent);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-checkpoints {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
}

.timeline-checkpoint-node {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s ease;
}

.timeline-checkpoint-node:hover {
  transform: translateX(-50%) translateY(-2px);
}

/* Regular Locked/In-progress dot centered on 52px line */
.timeline-node-dot {
  width: 32px;
  height: 32px;
  margin-top: 36px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 1.5px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-muted);
  transition: var(--transition);
  z-index: 2;
}

/* Start (0) Node Portal */
.timeline-checkpoint-node.start-node .timeline-node-dot {
  width: 28px;
  height: 28px;
  margin-top: 38px;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.timeline-checkpoint-node.start-node:hover .timeline-node-dot {
  background: var(--accent-dim);
  transform: scale(1.15);
}

.timeline-checkpoint-node.completed .timeline-node-dot {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-body);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Figurine sitting on top of the track line */
.timeline-checkpoint-node.completed .timeline-node-dot.has-sticker {
  width: 56px;
  height: 56px;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  margin-top: -4px;
  overflow: visible;
  position: relative;
}

/* Glowing pedestal anchor on the line */
.timeline-checkpoint-node.completed .timeline-node-dot.has-sticker::after {
  content: '';
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 4px;
  background: var(--accent);
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px var(--accent);
  opacity: 0.8;
}

.timeline-sticker-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.8));
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s ease;
  animation: sticker-reveal 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  user-select: none;
  pointer-events: none;
}

.timeline-checkpoint-node:hover .timeline-sticker-img {
  transform: scale(1.22) translateY(-6px);
  filter: drop-shadow(0 12px 20px rgba(125, 211, 252, 0.5));
}

@keyframes sticker-reveal {
  0% { transform: scale(0.2) rotate(-15deg); opacity: 0; }
  65% { transform: scale(1.18) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.timeline-checkpoint-node.current .timeline-node-dot {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 12px var(--accent-glow);
  animation: pulse-dot-anim 2s infinite ease-in-out;
}

.timeline-checkpoint-node.locked .timeline-node-dot {
  opacity: 0.55;
  border-color: var(--border-subtle);
  color: var(--text-faint);
  background: var(--bg-surface-elevated);
}

/* Capsule Number Badges */
.timeline-node-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 4px;
  margin-top: 10px;
  white-space: nowrap;
  transition: var(--transition);
  letter-spacing: 0.02em;
}

.timeline-checkpoint-node.completed .timeline-node-label {
  color: var(--accent);
  background: var(--accent-dim);
  border-color: rgba(125, 211, 252, 0.25);
  box-shadow: 0 2px 8px rgba(125, 211, 252, 0.12);
}

.timeline-checkpoint-node.current .timeline-node-label {
  color: var(--text-main);
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

.stats-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.stat-pill:hover {
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.stat-pill.clickable {
  cursor: pointer;
}

.stat-icon-sm {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.stat-icon-sm.video-icon {
  background: var(--video-bg);
  color: var(--video-color);
  border: 1px solid var(--video-border);
}

.stat-icon-sm.star-icon {
  background: rgba(251, 191, 36, 0.12);
  color: var(--star-color);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.stat-icon-sm.streak-icon {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(125, 211, 252, 0.25);
}

.stat-val-sm {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-lbl-sm {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.streak-mini-goal {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.goal-adjusters {
  display: inline-flex;
  gap: 3px;
}

.goal-adjusters button {
  width: 22px;
  height: 22px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: 4px;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.goal-adjusters button:hover {
  background: var(--accent-pink);
  color: #100d14;
  border-color: var(--accent-pink);
}

/* ==========================================================================
   MAIN WORKSPACE (CLEAN FULL-WIDTH LAYOUT)
   ========================================================================== */
.main-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px;
  display: block;
}

.content-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

/* Filter Toolbar */
.filter-toolbar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.pill-group {
  display: flex;
  gap: 8px;
}

.pill {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border-medium);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
  transition: var(--transition);
}

.pill:hover {
  color: var(--text-main);
  border-color: var(--border-bright);
  background: var(--bg-card-hover);
}

.pill.active {
  background: var(--accent);
  color: var(--bg-body);
  border-color: var(--accent);
  font-weight: 700;
}

/* Inline Search Box in Filter Toolbar */
.search-box-inline {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 380px;
}

.search-box-inline input {
  width: 100%;
  padding: 8px 34px 8px 34px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  color: var(--text-main);
  font-size: 0.86rem;
  outline: none;
  transition: var(--transition);
}

.search-box-inline input:focus {
  border-color: var(--accent-pink);
  box-shadow: 0 0 0 3px var(--accent-glow-subtle);
}

.search-box-inline .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-box-inline .clear-search-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
}

.search-box-inline .clear-search-btn:hover {
  color: var(--text-main);
}

.secondary-filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-select-wrapper select {
  padding: 7px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.filter-select-wrapper select:focus {
  border-color: var(--accent-pink);
  box-shadow: 0 0 0 3px var(--accent-glow-subtle);
}

/* Dropdown */
.dropdown {
  position: relative;
}

.btn-bulk {
  padding: 7px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-bulk:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 6px;
  min-width: 200px;
  box-shadow: var(--shadow-md);
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 50;
}

.dropdown-menu.show {
  display: flex;
}

.dropdown-menu button {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.82rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropdown-menu button:hover {
  background: var(--accent-dim);
  color: var(--accent);
}

/* Active Header View */
.active-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 14px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 12px;
}

.active-view-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

.active-chapter-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-left: 10px;
  font-weight: 500;
  font-family: var(--font-mono);
}

.view-header-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-outline {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
}
.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.btn-outline-danger {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
}
.btn-outline-danger:hover {
  border-color: var(--danger-color);
  color: var(--danger-color);
  background: var(--danger-bg);
}

/* ==========================================================================
   CHAPTER CARDS & ACCORDION
   ========================================================================== */
.chapters-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chapter-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.18s ease, background-color 0.18s ease;
  content-visibility: auto;
  contain-intrinsic-size: 0 300px;
}

.chapter-card:hover {
  border-color: var(--border-medium);
  border-left-color: var(--border-bright);
}

.chapter-card.open {
  border-left-color: var(--accent);
}

.chapter-header {
  padding: 14px 18px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  gap: 14px;
  transition: var(--transition);
}

.chapter-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.chapter-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chapter-toggle-icon {
  font-size: 0.88rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.chapter-card.open .chapter-toggle-icon {
  transform: rotate(90deg);
  color: var(--accent-pink);
}

.chapter-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

/* Chapter number prefix is dimmer */
.chapter-title .ch-num {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin-right: 4px;
}

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

.chapter-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chapter-progress-bar {
  width: 90px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

/* Empty track hint: always show a faint ghost track */
.chapter-progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-full);
}

.chapter-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
  position: relative;
  z-index: 1;
  min-width: 2px; /* Always show a tiny sliver even at 0% */
}

.chapter-progress-text {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 60px;
  text-align: right;
  opacity: 0.85;
}

.chapter-body {
  display: none;
  padding: 10px 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-body);
}

.chapter-card.open .chapter-body {
  display: block;
}

.chapter-items-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ==========================================================================
   CHECKLIST ITEM ROWS (NO EXTERNAL LINKS)
   ========================================================================== */
.tracker-item-row {
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}

.tracker-item-row:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-subtle);
}

.tracker-item-row.completed {
  opacity: 0.58;
}

/* Checkbox */
.item-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border-medium);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
  color: transparent;
}

.item-checkbox:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.tracker-item-row.completed .item-checkbox {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-body);
}

/* Type Badge */
.type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.type-badge.video {
  background: var(--video-bg);
  color: var(--video-color);
  border: 1px solid var(--video-border);
}

.type-badge.pdf {
  background: var(--pdf-bg);
  color: var(--pdf-color);
  border: 1px solid var(--pdf-border);
}

/* Number Badge */
.num-badge {
  font-size: 0.74rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Item Content */
.item-content {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.35;
  word-break: break-word;
}

.tracker-item-row.completed .item-title {
  color: var(--text-faint);
  text-decoration: line-through;
  text-decoration-color: var(--text-faint);
}

.item-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.date-tag {
  font-size: 0.74rem;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Item Actions */
.item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.diff-select {
  padding: 3px 7px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-faint);
  outline: none;
  cursor: pointer;
}

.diff-select.hard {
  border-color: rgba(251, 113, 133, 0.35);
  color: var(--danger-color);
  background: var(--danger-bg);
}

.diff-select.medium {
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--star-color);
}

.diff-select.easy {
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--success-color);
}

.action-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  position: relative;
}

.action-icon-btn:hover {
  color: var(--text-main);
  border-color: var(--border-medium);
  background: var(--accent-dim);
}

.action-icon-btn.star-btn.active {
  color: var(--star-color);
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.35);
}

.action-icon-btn.note-btn.has-note {
  color: var(--accent);
  border-color: var(--accent);
}

.note-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 5px var(--accent);
}

/* ==========================================================================
   MODALS
   ========================================================================= */
.modal {
  display: none !important;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.show {
  display: flex !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 13, 20, 0.7);
  backdrop-filter: blur(8px);
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  overflow: hidden;
  animation: modal-enter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog.modal-lg {
  max-width: 720px;
}

.modal-dialog.modal-sm {
  max-width: 440px;
}

@keyframes modal-enter {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title-icon {
  font-size: 1.25rem;
  color: var(--accent);
}

.modal-item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-close {
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 22px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Note Textarea */
.note-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.auto-save-tag {
  font-size: 0.74rem;
  color: var(--accent);
}

.note-textarea {
  width: 100%;
  height: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 14px;
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.note-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.snippet-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.chip-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chip {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

.chip:hover {
  background: var(--accent-dim);
  color: var(--text-main);
  border-color: var(--accent);
}

.note-char-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Data Hub Info Box */
.data-info-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.info-row strong, .info-row code {
  color: var(--text-main);
  font-size: 0.9rem;
}

.data-action-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.action-card-text h4 {
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: var(--text-main);
}

.action-card-text p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.danger-zone {
  border-color: rgba(248, 113, 113, 0.25);
  background: rgba(248, 113, 113, 0.04);
}

.danger-title {
  color: var(--danger-color);
}

/* Buttons */
.btn-primary {
  padding: 8px 18px;
  background: var(--accent);
  color: var(--bg-body);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  padding: 8px 16px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  padding: 8px 16px;
  background: var(--danger-color);
  color: var(--bg-body);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 700;
}
.btn-danger:hover { opacity: 0.85; }

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--accent-pink);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-xl);
}

.empty-state i {
  font-size: 2.5rem;
  color: var(--accent-pink);
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: 6px;
  color: var(--text-main);
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  .hero-top-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .filter-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box-inline {
    max-width: 100%;
  }
  .secondary-filters {
    justify-content: space-between;
  }
}
