/* ============================================================
   APUSH Command Center – Stylesheet
   Patriotic, modern, archival. Light + dark. Lots of motion.
   ============================================================ */

:root {
  /* Light theme - inspired by old parchment, patriotic accents */
  --bg: #f5f1e8;
  --bg-panel: #fffdf7;
  --bg-elevated: #fff;
  --bg-soft: #efe9db;
  --ink: #1c1917;
  --ink-soft: #44403c;
  --ink-muted: #78716c;
  --border: #d6cfbf;
  --border-soft: #e8e2d3;
  --accent: #b91c1c;       /* old glory red */
  --accent-soft: #fee2e2;
  --accent-hover: #991b1b;
  --navy: #1e3a5f;         /* old glory blue */
  --navy-soft: #dbeafe;
  --gold: #c49b1d;
  --gold-soft: #fef3c7;
  --success: #166534;
  --success-soft: #dcfce7;
  --shadow: 0 1px 2px rgba(28,25,23,0.06), 0 4px 12px rgba(28,25,23,0.06);
  --shadow-lg: 0 6px 24px rgba(28,25,23,0.12), 0 20px 48px rgba(28,25,23,0.08);
  --radius: 12px;
  --radius-lg: 18px;
  --serif: 'Fraunces', 'Iowan Old Style', 'Georgia', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0e0f14;
  --bg-panel: #161822;
  --bg-elevated: #1d1f2b;
  --bg-soft: #22242f;
  --ink: #f5f1e8;
  --ink-soft: #d6d3d1;
  --ink-muted: #a8a29e;
  --border: #2e3141;
  --border-soft: #252733;
  --accent: #ef4444;
  --accent-soft: #3a1515;
  --accent-hover: #f87171;
  --navy: #60a5fa;
  --navy-soft: #1e2a42;
  --gold: #fbbf24;
  --gold-soft: #332813;
  --success: #4ade80;
  --success-soft: #0f2614;
  --shadow: 0 2px 6px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* Subtle patterned background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(185,28,28,0.035), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(30,58,95,0.035), transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* Loading screen */
#loading {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 1rem;
  background: var(--bg);
  z-index: 9999;
  transition: opacity 0.5s;
}
#loading.gone { opacity: 0; pointer-events: none; }
.loading-eagle {
  font-size: 4rem;
  animation: float 2s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.loading-text {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-style: italic;
  color: var(--ink-muted);
}

/* ========== TOPBAR ========== */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex; align-items: center; gap: 0.75rem;
  min-width: 280px;
}
.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--navy));
  color: #fff; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 900;
  box-shadow: var(--shadow);
}
.brand-title {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.brand-sub {
  font-size: 0.7rem;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.topbar-search {
  flex: 1;
  max-width: 560px;
  position: relative;
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s;
}
.topbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.topbar-search svg { color: var(--ink-muted); flex-shrink: 0; }
.topbar-search input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: inherit; color: var(--ink);
  font-size: 0.92rem;
}
.topbar-search input::placeholder { color: var(--ink-muted); }
kbd {
  font-family: var(--mono);
  font-size: 0.7rem;
  background: var(--bg-soft);
  color: var(--ink-muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}

.topbar-actions {
  display: flex; align-items: center; gap: 0.75rem;
  margin-left: auto;
}
.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon:hover { background: var(--bg-soft); transform: translateY(-1px); }
.theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: none; }
[data-theme="dark"] .theme-moon { display: block; }

.progress-chip {
  display: flex; align-items: baseline; gap: 0.2rem;
  padding: 0.5rem 0.9rem;
  background: linear-gradient(135deg, var(--accent-soft), var(--navy-soft));
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
}
[data-theme="dark"] .progress-chip { color: var(--accent-hover); }
.progress-chip .slash { color: var(--ink-muted); margin: 0 2px; font-weight: 400; }
.progress-chip .progress-label {
  margin-left: 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ========== SEARCH RESULTS ========== */
.search-results {
  position: fixed;
  top: 70px; left: 50%;
  transform: translateX(-50%);
  width: 90%; max-width: 700px;
  max-height: 70vh; overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  padding: 0.5rem;
}
.search-results.hidden { display: none; }
.search-hit {
  display: block;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.search-hit:hover { background: var(--bg-soft); }
.search-hit-term {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  margin-bottom: 3px;
}
.search-hit-term mark {
  background: var(--gold-soft); color: inherit;
  padding: 0 2px; border-radius: 3px; font-weight: 800;
}
.search-hit-def {
  color: var(--ink-muted);
  font-size: 0.85rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-hit-unit {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--navy-soft);
  color: var(--navy);
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ========== LAYOUT ========== */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 70px);
}

/* ========== SIDEBAR ========== */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 1.2rem 0.9rem;
  display: flex; flex-direction: column;
  gap: 1rem;
  position: sticky; top: 70px;
  height: calc(100vh - 70px);
  overflow-y: auto;
}
.mode-nav {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.mode-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  padding: 0.75rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.mode-btn .mode-ico { font-size: 1.2rem; }
.mode-btn:hover { background: var(--bg-soft); }
.mode-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  box-shadow: var(--shadow);
}

.sidebar-divider {
  height: 1px; background: var(--border-soft);
  margin: 0.3rem 0;
}

.unit-list-wrapper { flex: 1; }
.unit-list-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  padding: 0 0.5rem 0.5rem;
  text-transform: uppercase;
}

.unit-list {
  display: flex; flex-direction: column;
  gap: 2px;
}
.unit-pill {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--ink);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.88rem;
}
.unit-pill:hover {
  background: var(--bg-soft);
}
.unit-pill.active {
  background: var(--accent);
  color: #fff;
}
.unit-pill.active .unit-pill-sub { color: rgba(255,255,255,0.75); }
.unit-pill.active .unit-pill-num { background: rgba(255,255,255,0.2); color: #fff; }
.unit-pill.active .unit-pill-count { background: rgba(255,255,255,0.2); color: #fff; }
.unit-pill-num {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy-soft), var(--gold-soft));
  color: var(--navy);
  border-radius: 8px;
  font-family: var(--serif);
  font-weight: 800;
  font-size: 0.95rem;
}
.unit-pill-text {
  display: flex; flex-direction: column;
  min-width: 0;
}
.unit-pill-title {
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.unit-pill-sub {
  font-size: 0.7rem;
  color: var(--ink-muted);
}
.unit-pill-count {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  background: var(--bg-soft);
  border-radius: 99px;
  color: var(--ink-muted);
}

.sidebar-footer { margin-top: auto; }
.btn-ghost {
  width: 100%;
  padding: 0.5rem;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--ink-muted);
  font-family: inherit; font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }

/* ========== MAIN CONTENT ========== */
.content {
  padding: 2rem 2.5rem 4rem;
  max-width: 100%;
  overflow-x: hidden;
}

.view { display: none; animation: fadeUp 0.4s ease-out; }
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

h1 {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  letter-spacing: -0.02em;
  margin: 0 0 0.3rem;
  line-height: 1.1;
}
h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}
.subtitle {
  color: var(--ink-muted);
  font-size: 1rem;
  margin: 0 0 1.8rem;
}
.section-h2 {
  margin: 2.5rem 0 1.2rem;
}

/* ========== STUDY VIEW ========== */
.unit-hero {
  position: relative;
  padding: 2.5rem 2rem;
  margin-bottom: 2rem;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(185,28,28,0.1), rgba(30,58,95,0.1)),
    var(--bg-panel);
  border: 1px solid var(--border);
  overflow: hidden;
}
.unit-hero::before {
  content: '';
  position: absolute;
  top: -20%; right: -5%;
  width: 300px; height: 300px;
  background:
    repeating-linear-gradient(0deg,
      var(--accent) 0, var(--accent) 14px,
      transparent 14px, transparent 28px);
  opacity: 0.08;
  transform: rotate(12deg);
  pointer-events: none;
}
.unit-hero-num {
  display: inline-block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--ink-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}
.unit-hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
}
.unit-hero-dates {
  display: inline-flex; align-items: center; gap: 0.7rem;
  padding: 0.4rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 99px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.88rem;
  margin-top: 0.3rem;
}
.unit-hero-meta {
  display: flex; gap: 1.5rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.meta-pill {
  display: flex; flex-direction: column;
  padding: 0.5rem 1rem;
  background: var(--bg-elevated);
  border-radius: 10px;
  border: 1px solid var(--border-soft);
}
.meta-pill-val {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.meta-pill-label {
  font-size: 0.72rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* Section cards */
.section-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.8rem;
  margin-bottom: 1.2rem;
  transition: all 0.2s;
}
.section-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.section-card-header {
  display: flex; align-items: baseline; gap: 0.75rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}
.section-id {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 700;
  padding: 2px 8px;
  background: var(--accent-soft);
  border-radius: 6px;
}
.section-title {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.section-content {
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.65;
}
.section-content p { margin: 0 0 0.9rem; }

.section-objective {
  display: flex; gap: 0.75rem;
  align-items: baseline;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
  padding: 0.9rem 1.1rem;
  background: var(--gold-soft);
  border-left: 4px solid var(--gold);
  border-radius: 0 10px 10px 0;
  margin-bottom: 1rem;
}
.section-objective .obj-label {
  flex-shrink: 0;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--bg-panel);
  padding: 3px 8px;
  border-radius: 4px;
}

.section-claim {
  padding: 0.9rem 1.1rem 0.6rem;
  background: var(--bg-soft);
  border-left: 4px solid var(--navy);
  border-radius: 0 10px 10px 0;
  margin-bottom: 1rem;
}
.section-claim.secondary { border-left-color: var(--ink-muted); margin-top: 1.2rem; }
.section-claim .claim-label {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--navy);
  background: var(--bg-panel);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 0.4rem;
}
.section-claim p { margin: 0; color: var(--ink); font-size: 0.96rem; }

.section-termdefs {
  list-style: none;
  padding: 0; margin: 0.2rem 0 0.4rem;
  display: flex; flex-direction: column;
  gap: 0.55rem;
}
.section-termdefs li {
  padding: 0.55rem 0.8rem 0.55rem 1rem;
  border-left: 2px solid var(--accent);
  background: var(--bg-panel);
  border-radius: 0 8px 8px 0;
  line-height: 1.55;
}
.td-term {
  font-family: var(--serif);
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
}
.td-sep { color: var(--ink-muted); margin-right: 4px; }

/* Vocab terms grid */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem;
}
.vocab-card {
  position: relative;
  padding: 1.1rem 1.2rem 1.2rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s;
  cursor: default;
}
.vocab-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--gold);
}
.vocab-card.mastered {
  border-color: var(--success);
  background: linear-gradient(135deg, var(--success-soft), var(--bg-panel) 60%);
}
.vocab-card.mastered::after {
  content: '✓';
  position: absolute;
  top: 10px; right: 12px;
  color: var(--success);
  font-weight: 900;
  font-size: 1.1rem;
}
.vocab-term {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  padding-right: 1.5rem;
  letter-spacing: -0.01em;
}
.vocab-def {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0 0 0.75rem;
}
.vocab-def.empty {
  font-style: italic;
  color: var(--ink-muted);
}
.vocab-actions {
  display: flex; gap: 6px;
  margin-top: 0.5rem;
}
.vocab-actions button {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.vocab-actions button:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.vocab-card.mastered .vocab-actions .toggle-mastered {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

/* Quick stats under unit hero */
.quick-actions {
  display: flex; gap: 0.6rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.btn, .btn-pill, .btn-circle, .btn.primary {
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 0;
}
.btn {
  padding: 0.55rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.87rem;
}
.btn:hover { background: var(--bg-soft); }
.btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ========== FLASHCARDS ========== */
.fc-container { max-width: 800px; margin: 0 auto; }
.fc-header { text-align: center; margin-bottom: 2rem; }
.fc-header h1 { margin-bottom: 0.4rem; }
.fc-sub { color: var(--ink-muted); font-size: 0.9rem; margin: 0 0 1rem; }
.fc-controls {
  display: flex; gap: 1rem; justify-content: center;
  flex-wrap: wrap; margin-top: 1rem;
}
.fc-controls label {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.88rem;
}
.fc-controls select {
  font: inherit; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--ink);
}
.checkbox { cursor: pointer; }
.checkbox input { margin-right: 4px; }

.fc-stage { text-align: center; }
.fc-progress {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.2rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}
.fc-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 99px;
  overflow: hidden;
}
#fc-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--navy));
  transition: width 0.3s;
}

.fc-card {
  perspective: 1600px;
  height: 380px;
  margin-bottom: 1.5rem;
  cursor: pointer;
}
.fc-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.7, 0, 0.3, 1);
}
.fc-card.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.fc-front {
  background: var(--bg-panel);
  background-image:
    radial-gradient(circle at 25% 20%, rgba(185,28,28,0.05) 0, transparent 50%),
    radial-gradient(circle at 75% 80%, rgba(30,58,95,0.05) 0, transparent 50%);
}
.fc-front::before {
  content: '★';
  position: absolute;
  top: 20px; left: 24px;
  color: var(--accent);
  font-size: 1.3rem;
  opacity: 0.6;
}
.fc-front::after {
  content: '★';
  position: absolute;
  bottom: 20px; right: 24px;
  color: var(--navy);
  font-size: 1.3rem;
  opacity: 0.6;
}
.fc-back {
  background: linear-gradient(135deg, var(--ink), #2d2a27);
  color: var(--bg);
  transform: rotateY(180deg);
}
[data-theme="dark"] .fc-back {
  background: linear-gradient(135deg, var(--bg-soft), var(--bg-elevated));
  color: var(--ink);
}
.fc-era {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}
.fc-term {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
  max-width: 90%;
}
.fc-hint {
  margin-top: 1.2rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-style: italic;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.fc-definition {
  font-family: var(--serif);
  font-size: clamp(1rem, 1.9vw, 1.2rem);
  line-height: 1.5;
  max-width: 88%;
  font-weight: 400;
}

.fc-actions {
  display: flex; gap: 0.75rem; justify-content: center;
  flex-wrap: wrap;
}
.btn-circle {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 1.3rem;
  color: var(--ink);
}
.btn-circle:hover { background: var(--bg-soft); }
.btn-pill {
  padding: 0.7rem 1.4rem;
  border-radius: 99px;
  font-size: 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--ink);
}
.btn-pill.danger { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn-pill.danger:hover { background: var(--accent); color: #fff; }
.btn-pill.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.btn-pill.success:hover { background: var(--success); color: #fff; }

/* ========== QUIZ ========== */
.quiz-container { max-width: 800px; margin: 0 auto; }
.quiz-header { text-align: center; margin-bottom: 2rem; }
.quiz-sub { color: var(--ink-muted); margin: 0 0 1.3rem; }
.quiz-controls {
  display: flex; gap: 1rem; justify-content: center;
  flex-wrap: wrap;
}
.quiz-controls label {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem;
}
.quiz-controls select {
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-elevated);
  color: var(--ink); font: inherit;
}

.quiz-stage { display: flex; flex-direction: column; gap: 1.2rem; }
.quiz-stage.hidden, .quiz-results.hidden { display: none; }
.quiz-topline {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.streak {
  padding: 4px 12px;
  background: var(--gold-soft);
  color: var(--gold);
  border-radius: 99px;
  font-weight: 700;
}
.quiz-progress {
  height: 4px; background: var(--bg-soft); border-radius: 99px;
  overflow: hidden;
}
#quiz-progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.4s;
}
.quiz-prompt {
  padding: 2rem 2.2rem;
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.5;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  min-height: 140px;
  display: flex; align-items: center;
}
.quiz-prompt .q-label {
  display: inline-block;
  padding: 2px 8px; margin-right: 8px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 4px;
  font-size: 0.7rem; font-weight: 700;
  font-family: var(--sans);
  text-transform: uppercase; letter-spacing: 0.08em;
  vertical-align: middle;
}
.quiz-choices {
  display: grid; gap: 0.7rem;
}
.quiz-choice {
  display: flex; gap: 0.9rem;
  align-items: flex-start;
  padding: 1rem 1.2rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font: inherit; color: var(--ink);
  line-height: 1.45;
  transition: all 0.15s;
}
.quiz-choice:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateX(3px);
}
.quiz-choice .choice-letter {
  flex-shrink: 0;
  width: 28px; height: 28px;
  background: var(--bg-soft); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700;
  font-size: 0.82rem;
}
.quiz-choice.correct {
  background: var(--success-soft); border-color: var(--success);
  color: var(--success);
}
.quiz-choice.correct .choice-letter { background: var(--success); color: #fff; }
.quiz-choice.wrong {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent);
}
.quiz-choice.wrong .choice-letter { background: var(--accent); color: #fff; }
.quiz-choice:disabled { cursor: default; }
.quiz-feedback {
  padding: 1rem;
  text-align: center;
  font-size: 0.95rem;
  min-height: 60px;
  display: flex; align-items: center; justify-content: center;
}
.quiz-feedback .correct-msg {
  color: var(--success); font-weight: 700;
}
.quiz-feedback .wrong-msg { color: var(--accent); font-weight: 700; }
.quiz-feedback .next-btn {
  padding: 0.55rem 1.4rem;
  background: var(--ink); color: var(--bg);
  border: 0; border-radius: 10px;
  font: inherit; font-weight: 600;
  cursor: pointer;
  margin-left: 1rem;
}
.quiz-feedback .next-btn:hover { background: var(--accent); color: #fff; }

.quiz-results {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.quiz-results .result-score {
  font-family: var(--serif);
  font-size: 4rem; font-weight: 900;
  line-height: 1;
  margin: 1rem 0;
  background: linear-gradient(135deg, var(--accent), var(--navy));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ========== TIMELINE ========== */
.timeline-container { max-width: 900px; margin: 0 auto; }
.tl-controls {
  display: flex; gap: 1.5rem;
  margin-bottom: 2rem; flex-wrap: wrap;
  align-items: center;
}
.tl-controls label {
  display: flex; gap: 0.5rem; align-items: center;
  font-size: 0.88rem; color: var(--ink-soft);
}
.tl-controls select {
  padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--ink); font: inherit;
}
.era-btn {
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.8rem;
  font-family: var(--mono);
  cursor: pointer;
  color: var(--ink-soft);
  transition: all 0.15s;
  margin-right: 4px;
}
.era-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.timeline {
  position: relative;
  padding-left: 60px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 20px; top: 10px; bottom: 10px;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--navy), var(--gold));
}
.tl-event {
  position: relative;
  margin-bottom: 1.2rem;
  padding: 1rem 1.3rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.2s;
}
.tl-event:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}
.tl-event::before {
  content: '';
  position: absolute;
  left: -47px; top: 22px;
  width: 14px; height: 14px;
  background: var(--accent);
  border: 3px solid var(--bg);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--accent);
}
.tl-year {
  display: inline-block;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--accent);
  padding: 2px 8px;
  background: var(--accent-soft);
  border-radius: 4px;
  margin-bottom: 0.4rem;
}
.tl-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.3;
  margin: 0 0 0.3rem;
}
.tl-body {
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}
.tl-unit-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.7rem; font-weight: 700;
  padding: 2px 8px;
  background: var(--navy-soft); color: var(--navy);
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.tl-era-marker {
  position: relative;
  margin: 2rem 0 1.2rem;
  padding-left: 0;
}
.tl-era-marker::before { display: none; }
.tl-era-marker .era-label {
  display: inline-block;
  margin-left: -50px;
  padding: 0.5rem 1.2rem;
  background: linear-gradient(135deg, var(--accent), var(--navy));
  color: #fff;
  font-family: var(--serif);
  font-weight: 800;
  font-style: italic;
  font-size: 1.1rem;
  border-radius: 99px;
  box-shadow: var(--shadow);
}

/* ========== STATS ========== */
.stats-container { max-width: 960px; margin: 0 auto; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2.5rem;
}
.stat-card {
  padding: 1.3rem 1.4rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all 0.2s;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.stat-big { grid-column: span 2; }
.stat-label {
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.stat-num {
  font-family: var(--serif);
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
}
.stat-big-num {
  font-family: var(--serif);
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1;
}
.stat-big-num .muted {
  font-size: 1.3rem;
  color: var(--ink-muted);
  font-weight: 400;
}
.stat-bar {
  margin-top: 0.8rem;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 99px;
  overflow: hidden;
}
#stat-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--navy), var(--gold));
  transition: width 0.6s;
}
.stat-sub {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.stat-units {
  display: flex; flex-direction: column;
  gap: 0.6rem;
}
.stat-unit-row {
  display: grid;
  grid-template-columns: 40px 1fr 120px 70px;
  gap: 1rem; align-items: center;
  padding: 0.8rem 1.1rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.stat-unit-num {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--navy));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-weight: 800;
}
.stat-unit-title .t {
  font-weight: 600;
}
.stat-unit-title .d {
  font-size: 0.75rem;
  color: var(--ink-muted);
}
.stat-unit-bar {
  height: 6px;
  background: var(--bg-soft);
  border-radius: 99px;
  overflow: hidden;
}
.stat-unit-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--success));
  transition: width 0.5s;
}
.stat-unit-count {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: right;
  color: var(--ink-soft);
}

/* ========== UTILITIES ========== */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; top: 0;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .content { padding: 1.5rem; }
  .mode-nav { grid-template-columns: repeat(5, 1fr); }
  .mode-btn .mode-ico { font-size: 1rem; }
  .mode-btn { font-size: 0.7rem; padding: 0.5rem 0.3rem; }
  .brand-sub { display: none; }
  .topbar { gap: 0.8rem; padding: 0.6rem 1rem; flex-wrap: wrap; }
  .brand { min-width: 0; }
  kbd { display: none; }
  .stat-big { grid-column: span 1; }
  .stat-unit-row { grid-template-columns: 36px 1fr 60px; }
  .stat-unit-bar { display: none; }
}
@media (max-width: 600px) {
  .topbar { gap: 0.5rem; padding: 0.5rem 0.7rem; }
  .brand-title { font-size: 1rem; }
  .brand-icon { width: 32px; height: 32px; font-size: 1rem; }
  .topbar-search { order: 3; flex-basis: 100%; max-width: none; }
  .topbar-actions { margin-left: auto; }
  .progress-chip .progress-label { display: none; }
  .progress-chip { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
  h1 { font-size: 1.8rem; }
  .unit-hero { padding: 1.5rem 1.2rem; }
  .content { padding: 1rem; }
  .fc-card { height: 320px; }
  .fc-term { font-size: 1.6rem !important; }
  .unit-hero-meta { gap: 0.6rem; }
  .meta-pill { padding: 0.4rem 0.7rem; }
  .meta-pill-val { font-size: 1.3rem; }
  .vocab-grid { grid-template-columns: 1fr; }
}

/* Scrollbar polish */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

/* Selection color */
::selection { background: var(--accent); color: #fff; }

/* Confetti-ish animation for quiz right */
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.pop { animation: pop 0.3s ease-out; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
.shake { animation: shake 0.4s ease-out; }
