@import url("https://fonts.googleapis.com/css2?family=Sora:wght@400;600;700;800&display=swap");

/* ===== DESIGN TOKENS ===== */
:root {
  color-scheme: light dark;

  --font-display: "Sora", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Surfaces */
  --bg-body: #ffffff;
  --bg-surface: #f9fafb;
  --bg-elevated: #ffffff;
  --bg-overlay: rgba(0, 0, 0, 0.4);

  /* Text */
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-tertiary: #6b7280;
  --text-inverse: #ffffff;

  /* Borders */
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.18);

  /* Accent */
  --accent: #2563eb;
  --accent-light: rgba(37, 99, 235, 0.08);
  --accent-mid: rgba(37, 99, 235, 0.15);
  --accent-text: #1d4ed8;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.06), 0 4px 6px rgba(0, 0, 0, 0.04);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 9999px;

  /* Motion */
  --duration-fast: 120ms;
  --duration-normal: 220ms;
  --duration-slow: 360ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== DARK MODE ===== */
body.dark-mode {
  --bg-body: #0a0a0a;
  --bg-surface: #141414;
  --bg-elevated: #1c1c1e;

  --text-primary: #f5f5f7;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.16);

  --accent: #3b82f6;
  --accent-light: rgba(59, 130, 246, 0.10);
  --accent-mid: rgba(59, 130, 246, 0.18);
  --accent-text: #93c5fd;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

/* ===== KEYFRAMES ===== */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes hero-enter {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

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

html {
  scroll-behavior: smooth;
  overflow-y: scroll;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--duration-normal), color var(--duration-normal);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text-primary);
}

h1 { font-size: clamp(1.75rem, 4.5vw, 2.75rem); font-weight: 700; }
h2 { font-size: clamp(1.25rem, 2.5vw, 1.625rem); font-weight: 600; }
h3 { font-size: 1.0625rem; font-weight: 600; }
h4 { font-size: 0.9375rem; font-weight: 600; }

p { margin: 0; }

::selection { background: var(--accent); color: white; }

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.4);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(156, 163, 175, 0.7); }

/* ===== APP SHELL ===== */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 52px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color var(--duration-normal), border-color var(--duration-normal), box-shadow var(--duration-normal);
}
.site-header.scrolled {
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

body.dark-mode .site-header {
  background: rgba(10, 10, 10, 0.88);
}
body.dark-mode .site-header.scrolled {
  box-shadow: 0 1px 8px rgba(0,0,0,0.3);
}

.header-inner {
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (min-width: 640px) { .header-inner { padding: 0 1.5rem; } }

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.9375rem;
  letter-spacing: -0.02em;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}
.brand::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  opacity: 0;
  transform: scaleX(0);
  transition: opacity var(--duration-fast), transform var(--duration-fast) var(--ease-out);
}
.brand:hover::after { opacity: 1; transform: scaleX(1); }

/* Desktop nav */
.nav {
  display: none;
  flex: 1;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 0.25rem;
}
.nav::-webkit-scrollbar { display: none; }

@media (min-width: 820px) { .nav { display: flex; } }

.nav a {
  position: relative;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--duration-fast), background-color var(--duration-fast);
  letter-spacing: 0.01em;
}
.nav a:hover { color: var(--text-primary); background-color: var(--bg-surface); }
.nav a.active {
  color: var(--accent);
  background-color: var(--accent-light);
  font-weight: 600;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
}

/* ===== HAMBURGER ===== */
.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-full, 9999px);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--duration-fast);
}
.hamburger:hover { background-color: var(--bg-surface); }

.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text-primary);
  border-radius: 2px;
  transform-origin: center;
  transition: transform var(--duration-normal) var(--ease-out), opacity var(--duration-fast);
}

.hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (min-width: 820px) { .hamburger { display: none; } }

/* ===== NAV DRAWER (Mobile) ===== */
.nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: min(280px, 80vw);
  height: 100vh;
  height: 100dvh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-default);
  z-index: 200;
  padding: 4rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--duration-slow) var(--ease-out);
  will-change: transform;
}
.nav-drawer.is-open { transform: translateX(0); }

.nav-drawer a {
  padding: 0.625rem 0.875rem;
  min-height: 44px;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
  transition: background-color var(--duration-fast), color var(--duration-fast);
}
.nav-drawer a:hover { background-color: var(--bg-surface); color: var(--text-primary); }
.nav-drawer a.active {
  background-color: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 190;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease-out);
  backdrop-filter: blur(4px);
}
.nav-overlay.is-visible { opacity: 1; pointer-events: auto; }

@media (min-width: 820px) { .nav-drawer, .nav-overlay { display: none !important; } }

/* ===== BOTTOM NAV (Mobile) ===== */
.bottom-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 150;
  height: 64px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px) saturate(1.8);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  justify-content: space-around;
  align-items: center;
}
body.dark-mode .bottom-nav { background: rgba(10, 10, 10, 0.92); }

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  min-height: 44px;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-tertiary);
  font-size: 0.625rem;
  font-weight: 500;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  transition: color var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item svg { width: 22px; height: 22px; stroke-width: 1.75; }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item:active { transform: scale(0.92); transition: transform var(--duration-fast) var(--ease-spring); }

@media (min-width: 820px) { .bottom-nav { display: none; } }

/* ===== MAIN CONTENT ===== */
.main-content {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 6rem;
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) { .main-content { padding: 1.5rem 2rem 2rem; gap: 1.5rem; } }
@media (min-width: 1024px) { .main-content { padding: 2rem 3rem 3rem; gap: 2rem; } }

/* ===== PANELS ===== */
.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 72px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out),
              background-color var(--duration-normal),
              border-color var(--duration-normal);
}
.panel.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 640px) { .panel { padding: 1.75rem; } }
@media (min-width: 1024px) { .panel { padding: 2rem; } }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

/* ===== HERO ===== */
.hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  /* Hero is always visible */
  opacity: 1 !important;
  transform: none !important;
  box-shadow: var(--shadow-md);
  padding: 2rem 1.25rem;
}

.hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6, var(--accent));
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
}

.hero > * {
  opacity: 0;
  animation: hero-enter var(--duration-slow) var(--ease-out) forwards;
}
.hero .eyebrow   { animation-delay: 50ms; }
.hero h1          { animation-delay: 150ms; }
.hero .lead       { animation-delay: 250ms; }
.hero .hero-metrics { animation-delay: 350ms; }
.hero .hero-actions { animation-delay: 420ms; }

@media (min-width: 820px) { .hero { padding: 3rem 2.5rem; } }

.eyebrow {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.lead {
  max-width: 54ch;
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.hero-metrics {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.625rem;
}
@media (min-width: 480px) { .hero-metrics { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .hero-metrics { grid-template-columns: repeat(6, 1fr); } }

.metric {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  text-align: left;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.metric:hover { border-color: var(--border-default); box-shadow: var(--shadow-xs); }
.metric span { display: block; font-size: 0.75rem; color: var(--text-tertiary); margin-bottom: 0.25rem; }
.metric strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  justify-content: center;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 44px;
  padding: 0.625rem 1.125rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: transform var(--duration-fast) var(--ease-spring),
              box-shadow var(--duration-fast),
              background-color var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.96); }

.btn-solid {
  background: var(--text-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}
.btn-solid:hover { box-shadow: var(--shadow-md); }
body.dark-mode .btn-solid { background: var(--accent); color: #fff; }
body.dark-mode .btn-solid:hover { background: #1d4ed8; }

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-outline:hover { background: var(--bg-surface); border-color: var(--border-strong); }

.btn-large {
  min-height: 52px;
  padding: 0.875rem 1.75rem;
  font-size: 0.9375rem;
  border-radius: var(--radius-xl);
}

/* ===== FORM CONTROLS ===== */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.625rem 0.875rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  -webkit-appearance: none;
  appearance: none;
}

textarea { resize: vertical; min-height: 90px; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-mid);
}

.search { width: min(380px, 100%); }

/* ===== LANG & THEME TOGGLES ===== */
.lang-switch {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full, 9999px);
  padding: 2px;
}

.lang-btn {
  min-height: 28px;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-full, 9999px);
  border: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background-color var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast);
}
.lang-btn.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

#theme-toggle, #sync-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-full, 9999px);
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
}
#theme-toggle:hover, #sync-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}
#theme-toggle svg, #sync-btn svg { width: 16px; height: 16px; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  transition: background-color var(--duration-normal), border-color var(--duration-normal);
}

/* ===== PATTERN SECTION ===== */
.pattern-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 640px) { .pattern-layout { grid-template-columns: 1fr 1fr; } }

.pattern-col { display: grid; gap: 0.75rem; align-content: start; }

.pattern-stats {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.stat-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.9rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border-subtle);
}
.stat-item:last-child { border-bottom: none; }
.stat-label { color: var(--text-tertiary); }
.stat-value { font-weight: 600; color: var(--text-primary); }

.list { margin: 0.7rem 0 0; padding-left: 1rem; }
.list li { margin-bottom: 0.35rem; }

.paper-list { display: grid; gap: 0.55rem; margin-top: 0.65rem; }

.paper-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  transition: border-color var(--duration-fast);
}
.paper-item:hover { border-color: var(--border-default); }

.paper-item h4 { margin: 0; font-family: var(--font-display); font-size: 0.95rem; }
.paper-item p { margin: 0.2rem 0 0; color: var(--text-tertiary); font-size: 0.875rem; }
.paper-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem; }
.paper-id { font-size: 0.8rem; color: var(--accent); font-weight: 600; }
.paper-marks { font-size: 0.8rem; color: var(--text-tertiary); font-weight: 600; }
.paper-title { font-family: var(--font-display); }
.paper-meta { font-size: 0.8rem; color: var(--text-tertiary); margin-top: 0.25rem; }

/* Timeline */
.timeline {
  position: relative;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
}
.timeline::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-default);
  z-index: 0;
}
.timeline-item {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
}
.timeline-marker {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 0 0 4px var(--bg-elevated);
}
.timeline-content { display: flex; flex-direction: column; align-items: center; }
.timeline-title { font-weight: 600; font-size: 0.875rem; }
.timeline-sub { font-size: 0.8rem; color: var(--text-tertiary); }

/* ===== CALCULATOR ===== */
.calc-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.calc-form label { display: grid; gap: 0.375rem; font-weight: 600; font-size: 0.875rem; }

.calc-summary-text { font-size: 1rem; color: var(--text-secondary); margin-bottom: 0.5rem; }

.calc-visual {
  height: 24px;
  background: var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  margin: 1rem 0;
}
.calc-bar-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  transition: width 0.3s ease;
}
.calc-seg-correct { background: #059669; }
.calc-seg-wrong { background: #dc2626; }
.calc-seg-unattempted { background: transparent; color: var(--text-tertiary); }

.calc-metrics {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.625rem;
}

.calc-alert { margin-top: 0.75rem; color: var(--text-tertiary); font-size: 0.9rem; }
.calc-alert.error { color: #dc2626; font-weight: 600; }

/* ===== SCHEME TABS ===== */
.tab-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 480px) {
  .tab-row { grid-template-columns: repeat(2, 1fr); }
}

.scheme-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  padding: 0.625rem 0.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: all var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: 56px;
  justify-content: center;
}
.scheme-tab:hover { border-color: var(--border-strong); }

.scheme-tab-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}
.scheme-tab-marks {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.scheme-tab.active {
  background: var(--text-primary);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
.scheme-tab.active .scheme-tab-label { color: var(--text-inverse); }
.scheme-tab.active .scheme-tab-marks { color: rgba(255,255,255,0.7); }
body.dark-mode .scheme-tab.active { background: var(--accent); }

/* Scheme Header */
.scheme-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 0.875rem;
}
.scheme-header-info { flex: 1; min-width: 0; }
.scheme-paper-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scheme-duration {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 0.125rem;
  display: block;
}

.scheme-total-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  flex-shrink: 0;
}
.scheme-total-value {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}
.scheme-total-label {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

/* Unit Cards */
.scheme-units-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}

.scheme-unit-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.scheme-unit-card:hover { border-color: var(--border-default); box-shadow: var(--shadow-xs); }

.scheme-unit-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}
.scheme-unit-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.scheme-unit-marks {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

.scheme-unit-label {
  margin: 0 0 0.5rem 0;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.scheme-bar {
  height: 4px;
  background: var(--border-default);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 0.375rem;
}
.scheme-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 400ms var(--ease-out);
}

.scheme-unit-pct {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Pattern Rows */
.scheme-patterns {
  display: grid;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

.scheme-pattern-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.625rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  gap: 0.75rem;
}

.scheme-pattern-detail {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
}
.scheme-pattern-q {
  font-weight: 600;
  color: var(--text-primary);
}
.scheme-pattern-sep {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}
.scheme-pattern-m {
  color: var(--text-secondary);
}

.scheme-pattern-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}
.scheme-pattern-total {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text-primary);
  min-width: 28px;
  text-align: right;
}
.scheme-pattern-wl {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  padding: 0.125rem 0.375rem;
  background: var(--accent-light);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* Generic tab (keep for filter chips reuse) */
.tab {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  cursor: pointer;
  transition: background-color var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text-primary); border-color: var(--border-strong); }
.tab.active {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}
body.dark-mode .tab.active { background: var(--accent); }

/* ===== SYLLABUS ===== */
.syllabus-controls {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.filter-chip {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast);
  -webkit-tap-highlight-color: transparent;
}
.filter-chip:hover { border-color: var(--border-strong); color: var(--text-primary); }
.filter-chip.active {
  background: var(--text-primary);
  color: var(--text-inverse);
  border-color: transparent;
}
body.dark-mode .filter-chip.active { background: var(--accent); }

.syllabus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}

.syllabus-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  background: var(--bg-surface);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.syllabus-card:hover { border-color: var(--border-default); box-shadow: var(--shadow-xs); }

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

.syllabus-card h4 { margin: 0; font-family: var(--font-display); font-size: 0.9375rem; }
.syllabus-card-body { margin-top: 0.25rem; }
.syllabus-card ul { margin: 0; padding-left: 1.125rem; }
.syllabus-card li { margin-bottom: 0.3rem; font-size: 0.875rem; color: var(--text-secondary); line-height: 1.5; }

/* ===== TAGS ===== */
.tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.6875rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.tag-prelims { background: rgba(37, 99, 235, 0.08); color: #1d4ed8; border-color: rgba(37, 99, 235, 0.15); }
.tag-p1 { background: rgba(219, 39, 119, 0.08); color: #be185d; border-color: rgba(219, 39, 119, 0.15); }
.tag-p2 { background: rgba(5, 150, 105, 0.08); color: #065f46; border-color: rgba(5, 150, 105, 0.15); }
.tag-p3 { background: rgba(124, 58, 237, 0.08); color: #6d28d9; border-color: rgba(124, 58, 237, 0.15); }
.tag-p4 { background: rgba(234, 88, 12, 0.08); color: #c2410c; border-color: rgba(234, 88, 12, 0.15); }

body.dark-mode .tag-prelims { background: rgba(59, 130, 246, 0.15); color: #93c5fd; border-color: rgba(59, 130, 246, 0.25); }
body.dark-mode .tag-p1 { background: rgba(236, 72, 153, 0.15); color: #f9a8d4; border-color: rgba(236, 72, 153, 0.25); }
body.dark-mode .tag-p2 { background: rgba(34, 197, 94, 0.15); color: #86efac; border-color: rgba(34, 197, 94, 0.25); }
body.dark-mode .tag-p3 { background: rgba(168, 85, 247, 0.15); color: #d8b4fe; border-color: rgba(168, 85, 247, 0.25); }
body.dark-mode .tag-p4 { background: rgba(249, 115, 22, 0.15); color: #fdba74; border-color: rgba(249, 115, 22, 0.25); }

.highlight { background-color: rgba(250, 204, 21, 0.25); color: inherit; padding: 0 0.15rem; border-radius: 2px; }
body.dark-mode .highlight { background-color: rgba(250, 204, 21, 0.15); }

/* ===== MICRO TRACKER ===== */

/* Micro Hero — Overall Progress */
.micro-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
}
.micro-hero-ring { flex-shrink: 0; }
.micro-ring-svg { display: block; }
.micro-ring-bg {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 6;
}
.micro-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 600ms var(--ease-out);
}
.micro-ring-pct {
  fill: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-display);
}
.micro-ring-sub {
  fill: var(--text-tertiary);
  font-size: 10px;
}
.micro-hero-stats { display: flex; flex-direction: column; gap: 0.25rem; }
.micro-hero-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.micro-hero-summary {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin: 0;
}

/* Micro Toolbar */
/* Micro Stage + Paper Tabs */
.micro-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
}

.micro-stage-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0.25rem;
}
.micro-stage-tab {
  flex: 1;
  padding: 0.45rem 0.5rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast);
  white-space: nowrap;
}
.micro-stage-tab.is-active {
  background: var(--bg-surface);
  color: var(--accent);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.micro-stage-tab:hover:not(.is-active) {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.micro-paper-tabs {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  padding: 0.375rem 0.5rem;
  background: var(--accent-light);
  border-radius: var(--radius-md);
}
.micro-paper-tabs.hidden { display: none; }
.micro-paper-tab {
  padding: 0.3rem 0.75rem;
  border: none;
  border-radius: var(--radius-full, 9999px);
  background: transparent;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  white-space: nowrap;
}
.micro-paper-tab.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.micro-paper-tab:hover:not(.is-active) {
  background: rgba(37, 99, 235, 0.15);
}
body.dark-mode .micro-paper-tab:hover:not(.is-active) {
  background: rgba(96, 165, 250, 0.15);
}

/* Toolbar — unified search + action strip */
.micro-toolbar {
  margin-bottom: 1.25rem;
}
.micro-search-bar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  padding: 0 0.5rem 0 1rem;
  height: 44px;
  width: 100%;
  cursor: text;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

/* Bulk syllabus coverage action row */
.micro-bulk-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.micro-bulk-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-right: 0.25rem;
}
.micro-search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.micro-search-icon { color: var(--text-tertiary); flex-shrink: 0; }
.micro-search-input {
  border: none;
  background: transparent;
  outline: none;
  flex: 1;
  min-width: 0;
  align-self: stretch;
  font-size: 0.9375rem;
  color: var(--text-primary);
}
.micro-search-input::placeholder { color: var(--text-tertiary); }

/* Micro Groups */
.micro-groups { display: grid; gap: 1rem; }

.micro-group {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
}

.micro-group-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem 0.75rem;
}
.micro-group-left {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}
.micro-group-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}
.micro-group-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.micro-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--bg-body);
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
}
.micro-tag-prelims {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: transparent;
}
.micro-tag-mains {
  background: #fef3c7;
  color: #92400e;
  border-color: transparent;
}
body.dark-mode .micro-tag-prelims { background: #1e3a5f; color: #93c5fd; }
body.dark-mode .micro-tag-mains { background: #422006; color: #fcd34d; }

.micro-group-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.125rem;
  flex-shrink: 0;
}
.micro-group-pct {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent);
}
.micro-group-count {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.micro-group-bar {
  height: 3px;
  background: var(--border-subtle);
  margin: 0 1.25rem;
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.micro-group-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 400ms var(--ease-out);
}

.micro-group-body {
  padding: 0.5rem 0.75rem 0.75rem;
  display: grid;
  gap: 0.375rem;
}

/* Micro Subtopic — Collapsible */
.micro-subtopic, .micro-subtopic-flat {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-body);
  overflow: hidden;
  transition: border-color var(--duration-fast);
}
.micro-subtopic-flat .micro-sublist { padding: 0.25rem 0; }
.micro-subtopic.is-complete, .micro-subtopic-flat.is-complete {
  border-color: #86efac;
  background: rgba(34, 197, 94, 0.04);
}
body.dark-mode .micro-subtopic.is-complete, body.dark-mode .micro-subtopic-flat.is-complete {
  border-color: #166534;
  background: rgba(34, 197, 94, 0.06);
}

.micro-sub-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  min-height: 44px;
  list-style: none;
  user-select: none;
}
.micro-sub-summary::-webkit-details-marker { display: none; }
.micro-sub-summary::marker { content: ""; }

.micro-sub-chevron {
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: transform var(--duration-fast);
}
.micro-subtopic[open] > .micro-sub-summary .micro-sub-chevron {
  transform: rotate(90deg);
}

.micro-sub-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}
.micro-sub-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.micro-sub-bar {
  width: 48px;
  height: 3px;
  background: var(--border-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
  flex-shrink: 0;
}
.micro-sub-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 400ms var(--ease-out);
}

.micro-sublist {
  padding: 0 0.75rem 0.75rem;
  display: grid;
  gap: 0.25rem;
}

/* Micro Item */
.micro-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: 36px;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.micro-item:hover { background: var(--bg-surface); }
.micro-item input {
  margin-top: 0.2rem;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.micro-item span {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-primary);
}
.micro-item.is-done span {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

/* Tool Row (kept for any remaining usage) */
.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ===== PLANNER ===== */
.planner-form-new { display: grid; gap: 1.5rem; margin-bottom: 1.5rem; }

.plan-group { border: none; padding: 0; margin: 0; }
.plan-group legend {
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: 0.9375rem;
}

.plan-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.plan-option { position: relative; cursor: pointer; display: block; }
.plan-option input { position: absolute; opacity: 0; width: 0; height: 0; }

.plan-option-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 1rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  transition: all var(--duration-fast);
}
.plan-option:hover .plan-option-content { border-color: var(--border-strong); }

.plan-option input:checked + .plan-option-content {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 2px var(--accent);
}

.opt-title { font-weight: 700; font-size: 0.9375rem; display: block; }
.opt-desc { font-size: 0.8rem; color: var(--text-tertiary); margin-top: 0.25rem; }

.plan-date-label {
  display: grid;
  gap: 0.5rem;
  font-weight: 700;
  max-width: 300px;
  font-size: 0.9375rem;
}

.plan-results.hidden { display: none; }

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.plan-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.plan-meta { color: var(--text-tertiary); font-size: 0.875rem; }

.print-compact-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  cursor: pointer;
}

/* Plan Overview Summary */
.plan-overview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
.plan-overview-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25rem;
}
.plan-stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
}
.plan-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}
@media (max-width: 479px) {
  .plan-overview { grid-template-columns: repeat(2, 1fr); }
  .plan-stat-value { font-size: 1rem; }
}

/* Plan Output Grid */
.plan-output {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
}

/* Week Card */
.week-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  overflow: hidden;
  transition: box-shadow var(--duration-fast);
}
.week-card:hover {
  box-shadow: var(--shadow-md);
}

.week-header {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
}
.week-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.week-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}
.week-task-count {
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent);
  color: white;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.week-dates {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}
.week-topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.125rem;
}
.week-topic-chip {
  font-size: 0.7rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.week-body { padding: 1rem 1.25rem; }
.week-task-list { display: grid; gap: 0.25rem; }

.topic-group {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
}
.topic-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.plan-topic-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.plan-topic-header::before {
  content: "";
  width: 3px;
  height: 1em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

.subtopic-group { margin-left: 0.75rem; margin-bottom: 0.625rem; }
.plan-sub-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 0.375rem 0;
}

.week-task-sublist { display: grid; gap: 0.375rem; }
.week-task-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.5;
  cursor: pointer;
  min-height: 32px;
  padding: 0.25rem 0.375rem;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast);
}
.week-task-item:hover { background: var(--bg-body); }
.week-task-item input { margin-top: 0.25rem; width: auto; cursor: pointer; accent-color: var(--accent); }
.week-task-item span { color: var(--text-primary); }
.week-task-item:has(input:checked) span {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

/* ===== TRACKER ===== */

/* Tracker Dashboard — Circular Progress Rings */
.tracker-dashboard {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 819px) {
  .tracker-dashboard { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 479px) {
  .tracker-dashboard { grid-template-columns: repeat(2, 1fr); }
}

.dash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--duration-fast), transform var(--duration-fast);
}
.dash-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.dash-card.total-card {
  background: var(--accent);
  border: none;
  color: white;
}

.dash-ring { display: block; }
.dash-ring-bg {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 5;
}
.total-card .dash-ring-bg { stroke: rgba(255,255,255,0.2); }
.dash-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 600ms var(--ease-out);
}
.total-card .dash-ring-fill { stroke: white; }
.dash-ring-text {
  fill: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-display);
}
.total-card .dash-ring-text { fill: white; }
.dash-ring-sub {
  fill: var(--text-tertiary);
  font-size: 9px;
}
.total-card .dash-ring-sub { fill: rgba(255,255,255,0.7); }

.dash-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}
.total-card .dash-label { color: rgba(255,255,255,0.9); }

/* Tracker Toolbar — Search + Filter */
.tracker-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.tracker-search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  padding: 0 1rem;
  height: 44px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.tracker-search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.tracker-search-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.tracker-search-input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 0.9375rem;
  color: var(--text-primary);
  height: 100%;
}
.tracker-search-input::placeholder { color: var(--text-tertiary); }

.tracker-filter-select {
  height: 44px;
  padding: 0 2rem 0 1rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 110px;
}

/* Tracker Action Buttons */
.tracker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.btn-sm {
  font-size: 0.8rem;
  padding: 0.375rem 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}
.btn-danger {
  color: #dc2626;
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: #dc2626;
}
body.dark-mode .btn-danger { color: #f87171; border-color: #7f1d1d; }
body.dark-mode .btn-danger:hover { background: #1c0a0a; border-color: #f87171; }

/* Checklist */
.checklist { display: grid; gap: 0.75rem; }

/* Tracker Group — Collapsible */
.tracker-group {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
}
.tracker-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  gap: 1rem;
}
.tracker-group-header::-webkit-details-marker { display: none; }
.tracker-group-header::marker { content: ""; }

.tracker-group-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.tracker-chevron {
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: transform var(--duration-fast);
}
.tracker-group[open] > .tracker-group-header .tracker-chevron {
  transform: rotate(90deg);
}
.tracker-group-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tracker-group-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}
.tracker-group-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.tracker-group-bar {
  width: 60px;
  height: 4px;
  background: var(--border-subtle);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.tracker-group-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 400ms var(--ease-out);
}

.tracker-list {
  display: grid;
  gap: 0;
  padding: 0 0.5rem 0.5rem;
}

/* Unit Sub-header (Mains papers) */
.tracker-unit-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-text);
  padding: 0.75rem 0.75rem 0.25rem;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tracker-unit-header::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}
.tracker-list .tracker-unit-header:first-child {
  border-top: none;
  margin-top: 0;
}

/* Check Row */
.check-row {
  display: flex;
  gap: 0.625rem;
  align-items: center;
  border-radius: var(--radius-md);
  padding: 0.625rem 0.75rem;
  background: transparent;
  min-height: 44px;
  transition: background var(--duration-fast);
  cursor: pointer;
  border: none;
}
.check-row:hover { background: var(--bg-body); }
.check-row input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
  border-radius: 4px;
}

.check-label {
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}
.check-row.is-done .check-label {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.check-row.just-checked {
  animation: scale-in 300ms var(--ease-spring);
  background: var(--accent-light);
}

.badge {
  border-radius: var(--radius-pill);
  padding: 0.15rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-prelims {
  background: #dbeafe;
  color: #1d4ed8;
  border: none;
}
.badge-mains {
  background: #fef3c7;
  color: #92400e;
  border: none;
}
body.dark-mode .badge-prelims { background: #1e3a5f; color: #93c5fd; }
body.dark-mode .badge-mains { background: #422006; color: #fcd34d; }

/* ===== RESOURCES ===== */
.resources { display: grid; gap: 1.5rem; }

/* Resource Section */
/* ===== RESOURCE DOCUMENT GALLERY ===== */
.resources {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Gallery grid — responsive, fills width, 2 cols min on mobile */
.res-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.875rem;
}
@media (min-width: 620px) {
  .res-gallery {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Document cover card */
.res-doc-card {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  transition: transform var(--duration-fast), box-shadow var(--duration-fast), border-color var(--duration-fast);
  cursor: pointer;
}
.res-doc-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  border-color: transparent;
}

/* Cover area with gradient background */
.res-doc-cover {
  position: relative;
  height: 136px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.res-doc-blue .res-doc-cover  { background: linear-gradient(145deg, #3b82f6, #1d4ed8); }
.res-doc-amber .res-doc-cover { background: linear-gradient(145deg, #f59e0b, #b45309); }
.res-doc-emerald .res-doc-cover { background: linear-gradient(145deg, #22c55e, #15803d); }
.res-doc-slate .res-doc-cover { background: linear-gradient(145deg, #94a3b8, #475569); }

/* Subtle noise/texture overlay */
.res-doc-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* Document SVG art */
.res-doc-art {
  width: 50px;
  height: 62px;
  position: relative;
  z-index: 1;
  transition: transform var(--duration-fast);
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.18));
}
.res-doc-card:hover .res-doc-art {
  transform: scale(1.06) translateY(-2px);
}

/* Language tag on cover */
.res-doc-lang-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  font-size: 0.5625rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: rgba(255,255,255,0.22);
  color: rgba(255,255,255,0.95);
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-full, 9999px);
  border: 1px solid rgba(255,255,255,0.28);
  backdrop-filter: blur(4px);
  line-height: 1.4;
}

/* Info section */
.res-doc-info {
  padding: 0.625rem 0.75rem 0.375rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.res-doc-type {
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  line-height: 1.3;
}
.res-doc-name {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

/* Open button */
.res-doc-open {
  margin: 0 0.625rem 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.375rem;
  border-radius: var(--radius-md);
  background: var(--bg-body);
  border: 1px solid var(--border-subtle);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
}
.res-doc-blue:hover    .res-doc-open { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.res-doc-amber:hover   .res-doc-open { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.res-doc-emerald:hover .res-doc-open { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.res-doc-slate:hover   .res-doc-open { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

/* Dark mode open button hovers */
body.dark-mode .res-doc-blue:hover    .res-doc-open { background: #1e3a5f; color: #93c5fd; border-color: #1d4ed8; }
body.dark-mode .res-doc-amber:hover   .res-doc-open { background: #3f2a00; color: #fcd34d; border-color: #b45309; }
body.dark-mode .res-doc-emerald:hover .res-doc-open { background: #052e16; color: #86efac; border-color: #15803d; }
body.dark-mode .res-doc-slate:hover   .res-doc-open { background: #1e293b; color: #94a3b8; border-color: #334155; }

/* Resource Note */
.res-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  line-height: 1.5;
}
.res-note svg {
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 1px;
}

/* ===== FOOTER ===== */
.footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--text-tertiary);
  font-size: 0.8125rem;
}
@media (min-width: 640px) { .footer { padding: 0 2rem 2rem; } }

/* ===== BACK TO TOP ===== */
.back-to-top {
  position: fixed;
  bottom: 5rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--duration-normal), transform var(--duration-normal);
  box-shadow: var(--shadow-lg);
  z-index: 140;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
@media (min-width: 820px) { .back-to-top { bottom: 2rem; } }

/* ===== SCROLL REVEAL ===== */
.reveal-item {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--duration-slow) var(--ease-out), transform var(--duration-slow) var(--ease-out);
}
.reveal-item.is-visible { opacity: 1; transform: translateY(0); }
.reveal-item:nth-child(2) { transition-delay: 60ms; }
.reveal-item:nth-child(3) { transition-delay: 120ms; }
.reveal-item:nth-child(4) { transition-delay: 180ms; }
.reveal-item:nth-child(5) { transition-delay: 240ms; }
.reveal-item:nth-child(6) { transition-delay: 300ms; }

/* ===== HERO WIDGETS ===== */
.hero-widgets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
@media (max-width: 639px) { .hero-widgets { grid-template-columns: 1fr; } }

.hero-quote {
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.hero-quote-text {
  margin: 0;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.6;
}
.hero-quote-author {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-style: normal;
}

/* Countdown Widget */
.exam-countdown {
  display: flex;
  align-items: center;
  justify-content: center;
}
.countdown-set {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.countdown-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.countdown-input {
  height: 38px;
  padding: 0 0.75rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.875rem;
}
.countdown-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
.countdown-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
}
.countdown-num {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.countdown-unit {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}
.countdown-clear-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
}
.countdown-clear-btn:hover { color: var(--text-primary); }
.countdown-done {
  font-weight: 700;
  color: var(--accent);
  font-size: 1rem;
}

/* ===== TIMER FAB + PANEL ===== */
.timer-fab {
  position: fixed;
  bottom: 5rem;
  right: 4rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: transform var(--duration-fast), box-shadow var(--duration-fast);
}
.timer-fab:hover { transform: scale(1.08); }
.timer-fab.timer-active {
  animation: timer-pulse 1.5s infinite;
}
@keyframes timer-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); }
}
@media (max-width: 819px) {
  .timer-fab { bottom: 6rem; right: 1rem; }
}

.timer-panel {
  position: fixed;
  bottom: 9.5rem;
  right: 4rem;
  width: 280px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 91;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.timer-panel.hidden { display: none; }
@media (max-width: 819px) {
  .timer-panel {
    bottom: auto; right: 0; left: 0;
    width: 100%; border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    position: fixed; bottom: 0;
  }
}

.timer-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.timer-panel-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}
.timer-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-tertiary);
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}
.timer-close-btn:hover { color: var(--text-primary); }

.timer-modes {
  display: flex;
  gap: 0.375rem;
  width: 100%;
}
.timer-mode {
  flex: 1;
  padding: 0.375rem 0.25rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all var(--duration-fast);
}
.timer-mode.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.timer-custom-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}
.timer-custom-row.hidden { display: none; }
.timer-custom-input {
  width: 80px;
  height: 36px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.9rem;
  background: var(--bg-surface);
  color: var(--text-primary);
}

.timer-display {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-ring { display: block; }
.timer-ring-bg {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 6;
}
.timer-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 300ms linear;
}
.timer-time {
  position: absolute;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
}

.timer-controls {
  display: flex;
  gap: 0.5rem;
}

.timer-sessions {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  min-height: 1rem;
}

/* ===== MILESTONE BADGES ===== */
.milestone-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.75rem 0 0;
}
.milestone-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  min-width: 60px;
  transition: transform var(--duration-fast);
}
.milestone-badge.locked {
  opacity: 0.3;
  filter: grayscale(1);
}
.milestone-badge.unlocked {
  animation: scale-in 400ms var(--ease-spring);
}
.milestone-icon { font-size: 1.5rem; line-height: 1; }
.milestone-label { font-size: 0.65rem; font-weight: 600; color: var(--text-secondary); }
.milestone-pct { font-size: 0.6rem; color: var(--text-tertiary); }

/* ===== REVISION DOTS + PYQ TOGGLE ===== */
.check-row-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.revision-dots {
  display: inline-flex;
  gap: 4px;
  cursor: pointer;
  padding: 4px;
}
.rev-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.rev-dot.rev-1 { background: #facc15; border-color: #facc15; }
.rev-dot.rev-2 { background: #3b82f6; border-color: #3b82f6; }
.rev-dot.rev-3 { background: #22c55e; border-color: #22c55e; }

.pyq-toggle {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--duration-fast);
  letter-spacing: 0.03em;
}
.pyq-toggle:hover { border-color: var(--accent); color: var(--accent); }
.pyq-toggle.pyq-done {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ===== MICRO NOTES ===== */
.micro-note-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  transition: color var(--duration-fast);
  display: flex;
  align-items: center;
}
.micro-note-btn:hover { color: var(--accent); }
.micro-note-btn.has-note { color: var(--accent); }

.micro-note-area {
  padding: 0 0.75rem 0.5rem;
}
.micro-note-area.hidden { display: none; }
.micro-note-input {
  width: 100%;
  min-height: 60px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.8125rem;
  font-family: var(--font-body);
  resize: vertical;
  line-height: 1.5;
}
.micro-note-input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* ===== SYNC MODAL ===== */
.sync-modal {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.sync-modal.hidden { display: none; }
.sync-modal-content {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.sync-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.sync-modal-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
}
.sync-desc {
  color: var(--text-tertiary);
  font-size: 0.8125rem;
  margin: 0 0 0.75rem;
  line-height: 1.5;
}
.sync-url-box {
  width: 100%;
  padding: 0.625rem;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-family: monospace;
  resize: none;
  word-break: break-all;
}
.sync-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.sync-status {
  font-size: 0.8rem;
  color: var(--accent);
  margin: 0.5rem 0 0;
  min-height: 1.25rem;
}

/* ===== PRINT STYLES ===== */
@media print {
  @page {
    size: A4;
    margin: 1.5cm 1.5cm 2cm 1.5cm;
  }

  * { box-shadow: none !important; text-shadow: none !important; }

  body {
    background: white !important;
    color: black !important;
    font-size: 10.5pt;
    line-height: 1.35;
  }

  .site-header, .panel, .footer, .back-to-top,
  .bottom-nav, .nav-drawer, .nav-overlay {
    display: none !important;
  }

  /* Reset app-shell for print */
  .app-shell {
    all: unset !important;
    display: block !important;
  }
  .main-content {
    all: unset !important;
    display: block !important;
  }

  /* Show the planner section and plan results in print mode */
  body.print-mode-plan #planner {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    border: none !important;
  }
  body.print-mode-plan #planner .section-head,
  body.print-mode-plan #planner #plan-form {
    display: none !important;
  }
  body.print-mode-plan #plan-results {
    display: block !important;
    margin: 0;
    padding: 0;
  }

  /* Hide screen-only elements */
  .plan-actions, .plan-meta,
  .week-topic-chips, .week-task-count { display: none !important; }

  /* ── Cover Page ── */
  .print-cover {
    text-align: center;
    page-break-after: always;
    break-after: page;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 85vh;
    padding: 3rem 2rem;
    border: none;
  }
  .print-header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: black;
    font-weight: 800;
    letter-spacing: -0.02em;
  }
  .print-header h2 {
    font-size: 1.25rem;
    color: #444;
    font-weight: 400;
    margin-bottom: 0.25rem;
  }
  .print-header p {
    font-size: 0.95rem;
    color: #666;
    margin-top: 0.5rem;
  }
  .print-quote {
    margin: 3rem 0 2rem;
    font-style: italic;
    color: #555;
    max-width: 28rem;
  }
  .print-quote blockquote {
    font-size: 1.1rem;
    line-height: 1.6;
    margin: 0;
  }
  .print-quote cite {
    display: block;
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #888;
  }
  .print-footer {
    margin-top: 2.5rem;
    font-size: 0.85rem;
    color: #aaa;
    border-top: 1px solid #ddd;
    padding-top: 1rem;
  }

  /* ── Plan Overview (shown in print as summary strip) ── */
  .plan-overview {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border: 1pt solid #ccc;
    border-radius: 0;
    margin: 0 0 1rem 0;
    padding: 0;
    background: #f8f8f8 !important;
    page-break-after: avoid;
    break-after: avoid;
  }
  .plan-overview-stat {
    text-align: center;
    padding: 0.5rem 0.25rem;
    border-right: 0.5pt solid #ddd;
    background: transparent !important;
    border-radius: 0;
  }
  .plan-overview-stat:last-child { border-right: none; }
  .plan-stat-value {
    display: block;
    font-size: 11pt;
    font-weight: 800;
    color: black !important;
  }
  .plan-stat-label {
    font-size: 7.5pt;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666 !important;
  }

  /* ── Plan output: single continuous column ── */
  .plan-output {
    display: block !important;
  }

  /* ── Week cards: NO page breaks — content flows naturally ── */
  .week-card {
    page-break-before: auto;
    break-before: auto;
    page-break-inside: auto;
    break-inside: auto;
    border: none;
    border-radius: 0;
    margin: 0;
    padding: 0;
    background: white;
    color: black;
    box-shadow: none;
  }

  /* Week header — styled as an inline banner, keeps with content */
  .week-header {
    background: #f0f0f0 !important;
    border: 1pt solid #ccc;
    border-radius: 3pt;
    padding: 0.4rem 0.75rem;
    margin: 0.75rem 0 0.375rem 0;
    color: black;
    page-break-after: avoid;
    break-after: avoid;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  /* First week header needs no top margin (right after overview) */
  .plan-overview + .week-card .week-header,
  .print-cover + .week-card .week-header {
    margin-top: 0;
  }
  .week-header-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }
  .week-title {
    font-size: 11pt;
    font-weight: 800;
    color: black;
  }
  .week-dates {
    font-size: 8.5pt;
    color: #555;
    font-weight: 400;
  }

  .week-body {
    padding: 0.25rem 0 0 0;
  }

  /* ── Topic groups: flow continuously ── */
  .topic-group {
    margin-bottom: 0.375rem;
    padding-bottom: 0.25rem;
    padding-left: 0.5rem;
    border-bottom: 0.5pt solid #e5e5e5;
    border-left: 2pt solid #bbb;
    page-break-inside: auto;
    break-inside: auto;
  }
  .topic-group:last-child { border-bottom: none; margin-bottom: 0; }

  .plan-topic-header {
    font-size: 9pt;
    font-weight: 700;
    color: #222;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0.125rem 0 0.2rem 0;
    padding: 0;
    page-break-after: avoid;
    break-after: avoid;
  }
  .plan-topic-header::before {
    display: none;
  }

  .plan-sub-header {
    font-size: 8.5pt;
    font-weight: 600;
    color: #444;
    margin: 0.15rem 0 0.1rem 0;
    page-break-after: avoid;
    break-after: avoid;
  }

  /* ── Task items: compact checklist rows ── */
  .week-task-item {
    padding: 0.06rem 0;
    min-height: auto;
    gap: 0.3rem;
  }
  .week-task-item input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 8pt;
    height: 8pt;
    border: 0.75pt solid #999;
    border-radius: 1.5pt;
    margin-top: 2pt;
    flex-shrink: 0;
    background: white;
  }
  .week-task-item span {
    color: black !important;
    font-size: 8.5pt;
    line-height: 1.3;
    text-decoration: none !important;
  }

  .subtopic-group {
    margin-left: 0.5rem;
    margin-bottom: 0.15rem;
  }
  .week-task-sublist {
    gap: 0.1rem !important;
  }

  /* ── Compact mode: even tighter ── */
  body.print-compact .week-task-item {
    font-size: 7.5pt;
    padding: 0.025rem 0;
    gap: 0.2rem;
  }
  body.print-compact .week-task-item input[type="checkbox"] {
    width: 7pt;
    height: 7pt;
  }
  body.print-compact .week-task-item span { font-size: 7.5pt; line-height: 1.25; }
  body.print-compact .topic-group { margin-bottom: 0.25rem; padding-bottom: 0.15rem; }
  body.print-compact .plan-topic-header { font-size: 8pt; margin-bottom: 0.125rem; }
  body.print-compact .plan-sub-header { font-size: 7.5pt; }
  body.print-compact .week-header { padding: 0.3rem 0.5rem; margin: 0.5rem 0 0.25rem 0; }
  body.print-compact .week-body { padding: 0.15rem 0 0 0; }
  body.print-compact .subtopic-group { margin-left: 0.375rem; }
}
