/* Fonts loaded via <link> in base.html with preconnect — no @import for perf */

:root {
  --primary: #6C5CE7;
  --primary-hover: #5A4BCF;
  --secondary: #1E1B4B;
  --accent: #F59E0B;
  --bg: #F8F7FC;
  --surface: #FFFFFF;
  --surface-alt: #F3F1FA;
  --text-main: #1A1833;
  --text-muted: #6B6A85;
  --border: #E7E5F0;
  
  --stage-new: #6B7280;
  --stage-learning: #F59E0B;
  --stage-graduated: #3B82F6;
  --stage-relearning: #22C55E;
  --stage-error: #DC2626;
}

[data-theme="dark"] {
  --primary: #A89BFF;
  --primary-hover: #C0B6FF;
  --secondary: #0D0B1A;
  --accent: #FBBF24;
  --bg: #12101F;
  --surface: #1C1A2C;
  --surface-alt: #23213A;
  --text-main: #EEEBFF;
  --text-muted: #9B98B5;
  --border: #2A2840;

  --stage-new: #9CA3AF;
  --stage-learning: #FBBF24;
  --stage-graduated: #60A5FA;
  --stage-relearning: #34D399;
  --stage-error: #DC2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 1rem; /* 16px min */
  line-height: 1.6;
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  body { line-height: 1.5; }
}

h1, h2, h3, .brand {
  font-family: 'Space Grotesk', sans-serif;
}

h1 { letter-spacing: -0.02em; }
h2 { letter-spacing: -0.01em; }
h3 { letter-spacing: -0.005em; }

/* Focus visible accessibility requirement */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
@media (max-width: 640px) {
  .topbar { height: 56px; padding: 0 1rem; }
}

.brand {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.topbar a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.topbar a:hover { color: var(--primary-hover); }

.user { color: var(--text-muted); font-size: 0.9rem; }

/* Container & Layout with responsive gutters */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 2rem 1rem; /* 16px gutter on mobile */
  width: 100%;
  flex: 1;
}

@media (min-width: 640px) and (max-width: 1024px) {
  .container { padding: 2rem 1.5rem; /* 24px gutter on tablet */ }
}

@media (min-width: 1024px) {
  .container { padding: 3rem 2rem; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

.card.auth {
  max-width: 400px;
  margin: 3rem auto;
}

/* Typography & Forms */
label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

input, textarea, select {
  width: 100%;
  height: 44px;
  padding: 0 0.875rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

form p { margin: 1rem 0; }

/* Buttons & Actions (min 44px height) */
button.primary, a.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease;
  min-height: 44px;
  min-width: 44px;
}

button.primary:hover, a.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

button.primary:active, a.primary:active {
  transform: scale(0.98);
}

button.secondary, a.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease;
  min-height: 44px;
  min-width: 44px;
}

button.secondary:hover, a.secondary:hover {
  background: var(--surface-alt);
  transform: translateY(-1px);
}

button.secondary:active, a.secondary:active {
  transform: scale(0.98);
}

.linkbtn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.5rem;
  font-weight: 500;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.linkbtn:hover { color: var(--primary-hover); text-decoration: underline; }

.inline { display: inline; margin: 0; }

/* Stats & Dashboard */
.stats { display: flex; gap: 1rem; margin: 1.5rem 0; }
.stat {
  flex: 1;
  text-align: center;
  padding: 1.25rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.stat .num { display: block; font-size: 2.25rem; font-weight: 700; font-family: 'Space Grotesk', sans-serif; color: var(--primary); }
.stat .label { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; margin-top: 0.25rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

/* Pipeline Bar */
.streak {
  margin: 1rem 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
}

.pipeline-label {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
}

.pipeline-bar {
  display: flex;
  width: 100%;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background-color: var(--border);
  margin: 8px 0 24px;
}

.new-percent { background-color: var(--stage-new); }
.learning-percent { background-color: var(--stage-learning); }
.graduated-percent { background-color: var(--stage-graduated); }
.relearning-percent { background-color: var(--stage-relearning);}

/* Card List & Rows */
.card-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.card-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.75rem;
  transition: transform 150ms ease;
}
.card-row:hover { transform: translateY(-1px); }
.card-row .front { font-weight: 600; flex: 1; }
.card-row .back { color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

/* Messages / Toasts */
.message {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  font-weight: 500;
}
.message.success { border-color: var(--stage-relearning); color: var(--stage-relearning); }
.message.error { border-color: var(--stage-error); color: var(--stage-error); }

/* Study & Reveal Specifics — width tracks flashcard-container via study-screen */
.flashcard-container {
  width: 100%;
  margin: 0 auto;
}

.study-progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--border);
  border-radius: 999px;
  margin: 1.5rem 0 2rem;
  overflow: hidden;
}
.study-progress-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: 999px;
  transition: width 200ms ease;
}

.study-prompt {
  display: block;
  text-align: center;
  font-size: 2rem;
  font-weight: 600;
  padding: 3rem 2rem;
  background-color: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 2rem;
}

.study-back {
  display: block;
  font-size: 1.75rem;
  font-weight: 600;
  text-align: center;
  margin: 2rem 0;
  padding: 2rem;
  background-color: var(--surface-alt);
  border-radius: 16px;
  border: 1px solid var(--border);
  animation: fadeIn 200ms ease forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Grade buttons container — row on all screens (kapanak alignment) */
.grade-buttons {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* HTMX Transition Classes */
.htmx-swapping {
  opacity: 0;
  transition: opacity 150ms ease-out;
}
.htmx-added {
  opacity: 1;
  transition: opacity 150ms ease-in;
}

/* Landing */
.landing { max-width: none; padding: 0; }
.landing-hero { max-width: 1120px; margin: 0 auto; padding: 3rem 1rem 2rem; }
@media (min-width: 640px) { .landing-hero { padding: 3.5rem 1.5rem 2.5rem; } }
@media (min-width: 1024px) { .landing-hero { padding: 4rem 2rem 3rem; } }
.hero-grid { display: flex; flex-direction: column; gap: 2rem; }
@media (min-width: 1024px) { .hero-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; align-items: center; gap: 3rem; } }
.overline { font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin: 0 0 0.75rem; font-family: 'Inter', sans-serif; }
.landing h1 { font-size: 32px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 1rem; }
@media (min-width: 1024px) { .landing h1 { font-size: 48px; } }
.landing h2 { font-size: 24px; line-height: 1.3; letter-spacing: -0.01em; margin: 0 0 0.5rem; }
@media (min-width: 1024px) { .landing h2 { font-size: 32px; } }
.hero-sub { font-size: 1.05rem; color: var(--text-muted); line-height: 1.6; max-width: 720px; margin: 0 0 1.5rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.hero-note { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.75rem; font-family: 'JetBrains Mono', monospace; }
.hero-visual { display: flex; flex-direction: column; gap: 1rem; }
.hero-card-stack { position: relative; height: 220px; }
.hero-card { position: absolute; left: 0; right: 0; border-radius: 16px; border: 1px solid var(--border); padding: 1.25rem; background: var(--surface); }
.hero-card--back { top: 0; transform: scale(0.96); opacity: 0.7; }
.hero-card--mid { top: 14px; transform: scale(0.98); opacity: 0.85; }
.hero-card--front { top: 28px; background: var(--surface-alt); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.5rem; box-shadow: 0 8px 24px rgba(0,0,0,0.06); }
.mono-label { font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted); }
.hero-front { font-family: 'Space Grotesk', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--text-main); }
.hero-hint { font-size: 0.85rem; color: var(--text-muted); }
.mini-pipeline { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1rem; }
.landing-strip { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: center; max-width: 1120px; margin: 0 auto; padding: 1rem; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); font-size: 0.9rem; font-weight: 500; color: var(--text-muted); }
.strip-item { display: inline-flex; align-items: center; gap: 0.5rem; }
.strip-dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.landing-section { max-width: 1120px; margin: 0 auto; padding: 2.5rem 1rem; }
@media (min-width: 640px) { .landing-section { padding: 3rem 1.5rem; } }
@media (min-width: 1024px) { .landing-section { padding: 3.5rem 2rem; } }
.section-sub { color: var(--text-muted); margin: 0 0 1.5rem; max-width: 720px; }
.steps-grid { display: flex; flex-direction: column; gap: 1rem; }
@media (min-width: 640px) { .steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; } }
.step-card, .feature-card, .faq-item { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; }
.step-card h3, .feature-card h3 { margin: 0.75rem 0 0.5rem; font-size: 1.1rem; }
.step-card p, .feature-card p, .faq-item dd { color: var(--text-muted); line-height: 1.6; margin: 0; font-size: 0.95rem; }
.step-num { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; letter-spacing: 0.05em; color: var(--primary); font-weight: 600; }
.steps-connector { display: none; height: 2px; background: var(--border); margin: 0 1.5rem 1rem; }
@media (min-width: 640px) { .steps-connector { display: block; } }
.step-link { margin-top: 0.75rem; }
.step-link a { color: var(--primary); font-size: 0.9rem; font-weight: 500; text-decoration: none; }
.step-link a:hover { text-decoration: underline; }
.landing-demo { background: var(--surface-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.demo-grid { display: flex; flex-direction: column; gap: 1.5rem; }
@media (min-width: 1024px) { .demo-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 2rem; align-items: start; } }
.demo-controls { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.demo-tab.is-active { background: var(--text-main); color: var(--surface); border-color: var(--text-main); }
.flashcard-demo { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.5rem; }
.demo-prompt { margin-bottom: 1rem; padding: 2rem 1rem; font-size: 1.6rem; }
@media (min-width: 1024px) { .demo-prompt { font-size: 1.8rem; } }
.demo-reveal { width: 100%; }
.demo-feedback { text-align: center; margin-top: 0.75rem; min-height: 1.2em; }
.features-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .features-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .features-grid { grid-template-columns: repeat(3, 1fr); } }
.feature-card { border-radius: 12px; }
.feature-icon { margin-bottom: 0.5rem; }
.feature-thumb { border-radius: 8px; }
.landing-prose .prose { max-width: 720px; color: var(--text-muted); line-height: 1.7; display: flex; flex-direction: column; gap: 1rem; }
.landing-prose .prose strong { color: var(--text-main); }
.faq-list { display: grid; gap: 1rem; max-width: 720px; }
.faq-item dt { font-weight: 600; font-family: 'Space Grotesk', sans-serif; margin-bottom: 0.4rem; color: var(--text-main); }
.landing-cta { text-align: center; max-width: 720px; margin: 0 auto; padding: 3rem 1rem 4rem; }
.landing-cta p { color: var(--text-muted); margin: 0.5rem 0 1.5rem; }
/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: auto; }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 2rem 1rem; display: flex; flex-direction: column; gap: 1rem; }
@media (min-width: 640px) { .footer-inner { padding: 2rem 1.5rem; flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; } }
.footer-brand { display: flex; flex-direction: column; gap: 0.25rem; }
.footer-tagline { margin: 0; font-size: 0.85rem; color: var(--text-muted); max-width: 420px; }
.footer-nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.footer-nav a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; font-weight: 500; }
.footer-nav a:hover { color: var(--primary); }
.footer-copy { width: 100%; margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; border-top: 1px solid var(--border); padding-top: 1rem; }
.footer-muted { color: var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}



/* ── Notebook — port from kapanak/css/style.css:1145-1424 adapted to DESIGN tokens ── */
.notebook-screen {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
}
.notebook-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.notebook-header h2 {
  font-size: 1.25rem;
  flex: 1;
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.01em;
}
.nb-page-indicator {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: 'JetBrains Mono', monospace;
}
.nb-filter-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.nb-filter-btn {
  flex: 1;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
  font-family: 'Inter', sans-serif;
  min-height: 36px;
}
.nb-filter-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}
.nb-filter-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.nb-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.nb-ctrl-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
  font-family: 'Inter', sans-serif;
  min-height: 36px;
}
.nb-ctrl-btn.active {
  background: var(--surface-alt);
  border-color: var(--primary);
  color: var(--primary);
}
.nb-ctrl-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.nb-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  min-height: 0;
}
.nb-cell {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: border-color 150ms ease, opacity 150ms ease, transform 150ms ease;
  user-select: none;
  -webkit-user-select: none;
  text-align: center;
  overflow: hidden;
  min-height: 88px;
}
.nb-cell:active { transform: scale(0.96); transition: transform 80ms; }
.nb-cell:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nb-cell.nb-cell-due {
  border-color: var(--primary);
  border-left-width: 3px;
}
.nb-cell.nb-cell-new {
  border-color: var(--stage-relearning);
  border-left-width: 3px;
}
.nb-cell.nb-cell-dim {
  opacity: 0.45;
  align-items: flex-start;
  justify-content: flex-start;
  border-left-width: 1px;
}
.nb-cell.nb-cell-dim .nb-primary {
  font-size: 0.72rem !important;
  font-weight: 500;
  color: var(--text-muted);
}
.nb-cell.nb-cell-empty {
  background: transparent;
  border-style: dashed;
  border-color: var(--border);
  opacity: 0.35;
  cursor: default;
}
.nb-cell.nb-cell-empty:active { transform: none; }
.nb-badge {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 0.6rem;
  color: var(--text-muted);
  line-height: 1;
  font-family: 'JetBrains Mono', monospace;
}
.nb-primary {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
  word-break: break-word;
  text-align: center;
}
.nb-secondary {
  font-size: 0.72rem;
  color: var(--primary);
  line-height: 1.4;
  word-break: break-word;
  text-align: center;
  margin-top: 2px;
}
.nb-cell.nb-cell-dim .nb-secondary { display: none !important; }
.nb-anchor {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.2;
  margin-top: 2px;
  text-align: center;
  word-break: break-word;
}
.nb-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.25rem 0 0.5rem;
  flex-wrap: wrap;
}
.nb-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background-color 150ms ease, transform 150ms ease;
  flex-shrink: 0;
  display: inline-block;
  text-indent: -9999px;
  overflow: hidden;
  line-height: 1;
}
.nb-dot:hover { background: var(--text-muted); transform: scale(1.2); }
.nb-dot.nb-dot-current {
  background: var(--text-main);
  width: 14px;
  height: 14px;
}
[data-theme="dark"] .nb-dot.nb-dot-current { background: #FFFFFF; box-shadow: 0 0 6px rgba(255,255,255,0.5); }
.nb-dot.nb-dot-due { outline: 2px solid var(--primary); outline-offset: 1px; }
.nb-dot.nb-dot-new { outline: 2px solid var(--stage-relearning); outline-offset: 1px; }
.nb-dot.nb-dot-current.nb-dot-due,
.nb-dot.nb-dot-current.nb-dot-new { outline: none; }
.nb-dot-gap { font-size: 0.75rem; color: var(--text-muted); line-height: 1; }
.nb-footer {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.nb-footer .btn-primary { flex: 1; }
.notebook-empty { grid-column: 1 / -1; text-align: center; color: var(--text-muted); padding: 2rem; }
/* legacy compat */
.notebook-grid { display: none; }
.page-dots { display: none; }
.dot { display: none; }

/* responsive: keep 3 cols but adjust gaps/min-height for narrow screens */
@media (max-width: 400px) {
  .nb-grid { gap: 0.35rem; }
  .nb-cell { min-height: 76px; padding: 0.4rem 0.2rem; }
  .nb-primary { font-size: 0.9rem; }
}

/* ── Manage Cards — port from kapanak/css/style.css:743-900 adapted to DESIGN tokens ── */
.manage-screen {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
}
.manage-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.manage-header h2 {
  font-size: 1.25rem;
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.01em;
}
.manage-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}
.manage-search svg { flex-shrink: 0; color: var(--text-muted); }
.manage-search input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  font-size: 0.95rem;
  color: var(--text-main);
  height: 36px;
  padding: 0;
}
.manage-search input::placeholder { color: var(--text-muted); }
.sort-chips {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.sort-chip {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
  font-family: 'Inter', sans-serif;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
}
.sort-chip.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}
.sort-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.card-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.card-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background-color: var(--surface);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.card-item-content { flex: 1; min-width: 0; }
.card-item-front {
  font-weight: 600;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-main);
}
.card-item-back {
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-item-anchor {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-item-actions { display: flex; gap: 0.25rem; flex-shrink: 0; align-items: center; }
.card-item-edit,
.card-item-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
  flex-shrink: 0;
}
.card-item-edit:hover { background-color: var(--primary); color: #FFFFFF; }
.card-item-delete:hover { background-color: var(--stage-error); color: #FFFFFF; }
.card-item-edit:active, .card-item-delete:active { transform: scale(0.98); }
.card-item-edit:focus-visible, .card-item-delete:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 200;
}
.modal.hidden { display: none !important; }
.modal-content {
  background-color: var(--surface);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  border: 1px solid var(--border);
}
.modal-content h3 { margin: 0 0 1.25rem; font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.01em; }
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input {
  width: 100%;
  padding: 0.75rem;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--text-main);
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 44px;
}
.form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15); }
.form-hint { font-size: 0.75rem; font-weight: 400; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
.modal-actions { display: flex; gap: 0.5rem; margin-top: 1.5rem; }
.modal-actions .btn { flex: 1; }
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  gap: 0.5rem;
}
.empty-state p { margin: 0; }

/* === Kapanak Home (post-login) — port from kapanak/css/style.css === */
/* Topbar icon-btn — 48×48 per DESIGN touch target for icon-only */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
  flex-shrink: 0;
}
.icon-btn:hover {
  background-color: var(--surface-alt);
  color: var(--text-main);
}
.icon-btn:active {
  transform: scale(0.98);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Home screen — centered 600px like original kapanak #app, inside 1120 shell */
.home-screen {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.dashboard {
  margin-bottom: 1.5rem;
}
.streak-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #FFFFFF;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  transition: opacity 150ms ease;
}
[data-theme="dark"] .streak-banner {
  background: var(--accent);
  color: #1A1833;
}
.streak-banner.inactive {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.streak-icon { font-size: 1.25rem; line-height: 1; }

.pipeline-card {
  background-color: var(--surface);
  padding: 1rem;
  border-radius: 16px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.pipeline-boxes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.pipeline-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}
.pipeline-count {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
  font-family: 'Space Grotesk', sans-serif;
}
.pipeline-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-family: 'Inter', sans-serif;
}
.pipeline-new .pipeline-count { color: var(--stage-new); }
.pipeline-learning .pipeline-count { color: var(--stage-learning); }
.pipeline-graduated .pipeline-count { color: var(--stage-graduated); }
.pipeline-mature .pipeline-count { color: var(--stage-relearning); }
.pipeline-arrow {
  color: var(--text-muted);
  font-size: 1.1rem;
  flex-shrink: 0;
  padding: 0 2px;
  margin-bottom: 14px;
}
.pipeline-bar {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background-color: var(--border);
}
.pipeline-segment {
  height: 100%;
  transition: width 300ms ease;
  width: 0%;
}
.pipeline-seg-new { background-color: var(--stage-new); }
.pipeline-seg-learning { background-color: var(--stage-learning); }
.pipeline-seg-graduated { background-color: var(--stage-graduated); }
.pipeline-seg-mature { background-color: var(--stage-relearning); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}
.stat-box {
  background-color: var(--surface);
  padding: 1rem;
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.stat-box .stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  font-family: 'Space Grotesk', sans-serif;
}
.stat-box .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-weight: 500;
}

.swap-toggle-home {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--surface);
  padding: 0.875rem 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.swap-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  font-family: 'Inter', sans-serif;
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.btn-row {
  display: flex;
  gap: 0.75rem;
}
.btn-row .btn {
  flex: 1;
}

/* Buttons — base per DESIGN 44px min, 52px for grade, 10px radius */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 150ms ease, background-color 150ms ease, opacity 150ms ease;
  user-select: none;
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.is-disabled { opacity: 0.5; pointer-events: none; }
.btn-primary {
  background-color: var(--primary);
  color: #FFFFFF;
}
.btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  background-color: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background-color: var(--surface-alt); transform: translateY(-1px); }
.btn-secondary:active { transform: scale(0.98); }
.btn-text {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  border: 1px solid transparent;
}
.btn-text:hover { color: var(--text-main); background-color: var(--surface-alt); }
.btn-danger {
  background-color: var(--stage-error);
  color: #FFFFFF;
}
.btn-danger:hover { background-color: #B91C1C; transform: translateY(-1px); }
.btn-danger:active { transform: scale(0.98); }
.btn-large { padding: 1rem 1.5rem; font-size: 1.125rem; }
.btn-full { width: 100%; }
.btn-gradient {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  border: none;
  position: relative;
  overflow: hidden;
}
.btn-gradient:hover { filter: brightness(1.05); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Toggle switch 52×32 */
.toggle {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 32px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border);
  border-radius: 999px;
  transition: background-color 150ms ease;
}
.toggle-slider::before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 3px;
  bottom: 3px;
  background-color: #FFFFFF;
  border-radius: 50%;
  transition: transform 150ms ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background-color: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-slider { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Settings screen — port from kapanak settings-screen */
.settings-screen {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.settings-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.settings-header h2 {
  font-size: 1.25rem;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.01em;
  margin: 0;
}
.settings-section {
  background-color: var(--surface);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}
.settings-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 1rem;
  font-family: 'Inter', sans-serif;
}
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  min-height: 44px;
}
.setting-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
  line-height: 1.4;
}
.settings-section .btn { margin-bottom: 0.75rem; }
.settings-section .btn:last-child { margin-bottom: 0; }
.danger-zone { border: 1px solid var(--stage-error); }
.danger-zone h3 { color: var(--stage-error); }
.settings-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: auto;
  padding: 1.5rem;
}
.settings-footer p { margin-bottom: 0.25rem; }



/* Study screen — responsive dynamic width (narrow mobile → wide PC) */
/* Study screen — fully fluid viewport-based (width 88vw, height 42vh, no container cap) */
.study-screen {
  width: clamp(340px, 88vw, 1280px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
.study-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.study-progress .progress-bar {
  flex: 1;
  height: 8px;
  background-color: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.study-progress .progress-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: 999px;
  transition: width 200ms ease;
  width: 0%;
}
.study-progress .progress-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 60px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}
.flashcard-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  min-height: clamp(300px, 44vh, 540px);
  flex: 1;
}
.flashcard {
  width: 100%;
  height: clamp(280px, 42vh, 520px);
  position: relative;
  cursor: pointer;
  transition: transform 150ms ease;
}
.flashcard:hover { transform: translateY(-1px); }
.flashcard:active { transform: scale(0.98); }
.flashcard .card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  border-radius: 16px;
  font-size: clamp(1.75rem, 4vw, 3rem);
  line-height: 1.4;
  word-break: break-word;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0,0,0,0.06);
  transition: opacity 200ms ease, transform 200ms ease;
}
.card-face-front {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-weight: 600;
}
.card-face-back {
  background: var(--primary);
  color: #FFFFFF;
  opacity: 0;
  transform: scale(0.98);
  pointer-events: none;
}
.flashcard.flipped .card-face-front { opacity: 0; transform: scale(0.98); }
.flashcard.flipped .card-face-back { opacity: 1; transform: scale(1); }
.card-position {
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  margin-bottom: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
}
.card-anchor {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  margin-top: 0.75rem;
  padding: 0.25rem 0.75rem;
  background: var(--surface);
  border-radius: 8px;
  border-left: 3px solid var(--primary);
  max-width: 100%;
}
.hidden { display: none !important; }
.card-anchor.hidden { display: none !important; }
.tap-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  transition: opacity 150ms ease;
}
.swipe-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  opacity: 0.7;
}
@media (min-width: 768px) { .swipe-hint { display: none; } }

/* Grade buttons — row on all widths per kapanak alignment */
.grade-buttons {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.grade-buttons .btn {
  flex: 1;
  flex-direction: column;
  padding: 0.875rem 0.5rem;
  min-height: 62px;
}
.btn-label { font-weight: 600; line-height: 1; }
.btn-hint {
  font-size: 0.75rem;
  opacity: 0.85;
  margin-top: 0.25rem;
  font-family: 'JetBrains Mono', monospace;
}
.btn-again { background-color: var(--stage-error); color: #FFFFFF; border: none; }
.btn-again:hover { background-color: #B91C1C; transform: translateY(-1px); }
.btn-good { background-color: var(--stage-graduated); color: #FFFFFF; border: none; }
.btn-good:hover { background-color: #2563EB; transform: translateY(-1px); }
.btn-easy { background-color: var(--stage-relearning); color: #FFFFFF; border: none; }
.btn-easy:hover { background-color: #16A34A; transform: translateY(-1px); }
.study-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
}
.study-back {
  display: block;
  font-size: 1.75rem;
  font-weight: 600;
  text-align: center;
  margin: 1.5rem 0 0.75rem;
  padding: 1.5rem;
  background-color: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  animation: fadeIn 200ms ease forwards;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 640px) {
  .grade-buttons { gap: 0.5rem; }
  .grade-buttons .btn { min-height: 58px; padding: 0.75rem 0.25rem; }
  .btn-label { font-size: 0.95rem; }
  .btn-hint { font-size: 0.7rem; }
}

/* Responsive tweaks per DESIGN breakpoints */
@media (max-width: 400px) {
  .stats-grid { gap: 0.5rem; }
  .stat-box { padding: 0.75rem 0.5rem; }
  .stat-box .stat-number { font-size: 1.25rem; }
  .stat-box .stat-label { font-size: 0.65rem; }
  .btn-row .btn { padding: 0.5rem 0.75rem; font-size: 0.875rem; }
}