:root {
  --teal: #00b3a4;
  --teal-dark: #009688;
  --teal-light: #e0f5f3;
  --teal-pale: #f0fbfa;
  --text: #1a2332;
  --text-secondary: #546e7a;
  --text-muted: #90a4ae;
  --bg: #f7fafa;
  --surface: #ffffff;
  --border: #e0eaea;
  --border-focus: #00b3a4;
  --red: #e53935;
  --red-light: #ffebee;
  --amber: #f57c00;
  --amber-light: #fff3e0;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --font: 'Nunito', 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Navigation ── */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topnav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--teal);
  letter-spacing: -0.02em;
}

.brand-icon { font-size: 1.4rem; }

.nav-links {
  display: flex;
  gap: 0.25rem;
  margin-left: 1rem;
  flex: 1;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.nav-link:hover { background: var(--teal-light); color: var(--teal-dark); }
.nav-link.active { background: var(--teal-light); color: var(--teal); }

.nav-right { display: flex; align-items: center; gap: 0.75rem; margin-left: auto; }

.btn-nav {
  padding: 0.4rem 1rem;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.btn-nav:hover { background: var(--teal-light); color: var(--teal); }

.btn-nav-primary {
  background: var(--teal);
  color: white !important;
  padding: 0.4rem 1.1rem;
}

.btn-nav-primary:hover { background: var(--teal-dark); }

/* Avatar */
.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.avatar-btn:hover { transform: scale(1.08); box-shadow: 0 2px 8px rgba(0,179,164,0.35); }

.profile-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 1.5rem;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1rem;
  z-index: 200;
}

.profile-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }

.profile-avatar-large {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-name { font-weight: 700; font-size: 0.95rem; }
.profile-email { font-size: 0.8rem; color: var(--text-muted); }

.profile-badge-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.role-badge, .status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
}

.role-badge { background: var(--teal-light); color: var(--teal-dark); }
.status-badge.status-active { background: var(--green-light); color: var(--green); }
.status-badge.status-pending { background: var(--amber-light); color: var(--amber); }
.status-badge.status-admin { background: #ede7f6; color: #5c35a0; }

.profile-meta { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem; }

.btn-logout {
  width: 100%;
  padding: 0.5rem;
  background: var(--red-light);
  color: var(--red);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-logout:hover { background: #ffcdd2; }

/* ── Main content ── */
.main-content { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,179,164,0.3); }

.btn-secondary { background: var(--teal-light); color: var(--teal-dark); }
.btn-secondary:hover { background: #c5ebe8; }

.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: #ffcdd2; }

.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }

.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-weight: 600; font-size: 0.875rem; margin-bottom: 0.4rem; color: var(--text); }
.form-input {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,179,164,0.15);
}

.form-error {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--red);
  font-weight: 600;
}

/* ── Alerts ── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.alert-error { background: var(--red-light); color: var(--red); border-left: 3px solid var(--red); }
.alert-success { background: var(--green-light); color: var(--green); border-left: 3px solid var(--green); }
.alert-warning { background: var(--amber-light); color: var(--amber); border-left: 3px solid var(--amber); }
.alert-info { background: var(--teal-light); color: var(--teal-dark); border-left: 3px solid var(--teal); }

/* ── Word list table ── */
.word-table { width: 100%; border-collapse: collapse; }

.word-table tr { border-bottom: 1px solid var(--border); }
.word-table tr:last-child { border-bottom: none; }
.word-table tr:nth-child(even) { background: var(--teal-pale); }
.word-table tr:hover { background: var(--teal-light); }

.word-table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  font-size: 0.95rem;
}

.word-cell {
  font-weight: 700;
  color: var(--teal-dark);
  min-width: 140px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.speak-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.2rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  font-size: 1rem;
}

.speak-btn:hover { color: var(--teal); }
.speak-btn.speaking { color: var(--teal); animation: pulse 0.6s infinite alternate; }

@keyframes pulse { from { opacity: 1; } to { opacity: 0.4; } }

.sentence-cell { color: var(--text-secondary); }
.bold-word { font-weight: 700; color: var(--text); }

.spelling-heading {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.year-tabs {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.year-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-weight: 800;
  text-decoration: none;
  border: 2px solid transparent;
  transition: all 0.15s;
}

.year-tab:hover {
  color: var(--teal);
  background: var(--teal-pale);
  border-color: var(--border);
}

.year-tab.active {
  color: var(--teal);
  background: var(--teal-light);
  border-color: var(--teal);
}

/* ── Tab navigation ── */
.tab-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border);
  background: var(--surface);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.tab-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-pale); }
.tab-btn.active { border-color: var(--teal); color: var(--teal); background: var(--teal-light); }

.tab-icon { font-size: 1.1rem; }

.tab-study { --tab-color: #00b3a4; --tab-bg: #e0f5f3; }
.tab-learn { --tab-color: #7c3aed; --tab-bg: #f3edff; }
.tab-games { --tab-color: #f57c00; --tab-bg: #fff3e0; }
.tab-test { --tab-color: #2563eb; --tab-bg: #eaf1ff; }
.tab-print { --tab-color: #2e7d32; --tab-bg: #e8f5e9; }
.tab-write { --tab-color: #c2410c; --tab-bg: #fff0e8; }
.tab-done { --tab-color: #64748b; --tab-bg: #f1f5f9; }

.tab-btn:hover,
.tab-btn.active {
  border-color: var(--tab-color, var(--teal));
  color: var(--tab-color, var(--teal));
  background: var(--tab-bg, var(--teal-light));
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-study { --panel-color: #00b3a4; --panel-bg: #e0f5f3; }
.panel-learn { --panel-color: #7c3aed; --panel-bg: #f3edff; }
.panel-games { --panel-color: #f57c00; --panel-bg: #fff3e0; }
.panel-test { --panel-color: #2563eb; --panel-bg: #eaf1ff; }
.panel-print { --panel-color: #2e7d32; --panel-bg: #e8f5e9; }
.panel-write { --panel-color: #c2410c; --panel-bg: #fff0e8; }
.panel-done { --panel-color: #64748b; --panel-bg: #f1f5f9; }

.panel-heading {
  color: var(--text);
  border-left: 5px solid var(--panel-color);
  background: var(--panel-bg);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
}

.panel-heading span { color: var(--panel-color); }

/* ── Speed reading ── */
.speed-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.speed-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.speed-tab-timed { --tab-color: #2563eb; --tab-bg: #eaf1ff; }
.speed-tab-progress { --tab-color: #2e7d32; --tab-bg: #e8f5e9; }
.speed-tab-flash { --tab-color: #7c3aed; --tab-bg: #f3edff; }
.speed-tab-games { --tab-color: #f57c00; --tab-bg: #fff3e0; }

.panel-timed { --panel-color: #2563eb; --panel-bg: #eaf1ff; }
.panel-progress { --panel-color: #2e7d32; --panel-bg: #e8f5e9; }
.panel-flash { --panel-color: #7c3aed; --panel-bg: #f3edff; }

.speed-layout {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.speed-side {
  display: grid;
  gap: 0.75rem;
}

.speed-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
}

.speed-stat span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.speed-stat strong {
  display: block;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.3;
  margin-top: 0.25rem;
}

.speed-panel { display: none; }
.speed-panel.active { display: block; }

.reading-card,
.flash-reading-card,
.speed-question {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.reading-card {
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.9;
}

.flash-reading-card {
  min-height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
}

.speed-question {
  margin-top: 1rem;
}

.speed-question details {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.speed-question details:last-child { border-bottom: none; }
.speed-question summary { cursor: pointer; font-weight: 800; color: var(--text); }
.speed-question p { color: var(--text-secondary); margin-top: 0.35rem; }

.speed-clock {
  color: var(--text);
  background: var(--teal-pale);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  min-width: 76px;
  text-align: center;
}

.progress-chart {
  display: grid;
  gap: 1rem;
}

.progress-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.progress-metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
}

.progress-metric span {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.progress-metric strong {
  display: block;
  color: var(--green);
  font-size: 1.35rem;
  line-height: 1.2;
  margin-top: 0.25rem;
}

.progress-graph {
  position: relative;
  min-height: 280px;
  background:
    linear-gradient(to bottom, rgba(46,125,50,0.08) 1px, transparent 1px) 0 0 / 100% 25%,
    var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1rem 2.25rem;
  overflow: hidden;
}

.progress-axis {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.progress-axis-top { top: 0.6rem; }

.progress-graph svg {
  position: absolute;
  inset: 1.25rem 1rem 3.3rem;
  width: calc(100% - 2rem);
  height: calc(100% - 4.55rem);
  pointer-events: none;
  z-index: 2;
}

.progress-graph polyline {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.progress-bars {
  position: absolute;
  inset: 2.4rem 1rem 1rem;
  display: flex;
  align-items: end;
  gap: 0.55rem;
  z-index: 1;
}

.progress-column {
  flex: 1;
  height: 100%;
  min-width: 30px;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  gap: 0.4rem;
}

.progress-column-bar {
  width: 100%;
  max-width: 58px;
  min-height: 18px;
  background: linear-gradient(180deg, #66bb6a, #2e7d32);
  border-radius: 8px 8px 3px 3px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 0.25rem;
  box-shadow: 0 6px 14px rgba(46,125,50,0.18);
}

.progress-column-bar span {
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

.progress-column small {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.progress-history {
  display: grid;
  gap: 0.75rem;
}

.progress-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(120px, 2fr) 80px;
  gap: 0.75rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}

.progress-row span {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
}

.progress-row strong {
  color: var(--text);
  text-align: right;
  font-size: 0.9rem;
}

.progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar div {
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

/* ── Punctuation ── */
.punctuation-tab-addresses { --tab-color: #2563eb; --tab-bg: #eaf1ff; }
.punctuation-tab-dialogue { --tab-color: #7c3aed; --tab-bg: #f3edff; }
.punctuation-tab-apostrophes { --tab-color: #c2410c; --tab-bg: #fff0e8; }

.punctuation-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.punctuation-side {
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 0;
}

.punctuation-activity-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.punctuation-activity {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.75rem;
  text-align: center;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  line-height: 1.25;
  transition: all 0.15s;
}

.punctuation-activity:hover,
.punctuation-activity.active {
  border-color: var(--teal);
  background: var(--teal-pale);
  color: var(--teal-dark);
}

.punctuation-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.punctuation-prompt {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.6;
}

.punctuation-choices {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.punctuation-choice {
  justify-content: flex-start;
  text-align: left;
}

/* ── Grammar ── */
.grammar-tab-noun { --tab-color: #2563eb; --tab-bg: #eaf1ff; }
.grammar-tab-pronoun { --tab-color: #7c3aed; --tab-bg: #f3edff; }
.grammar-tab-verb { --tab-color: #2e7d32; --tab-bg: #e8f5e9; }
.grammar-tab-adjective { --tab-color: #f57c00; --tab-bg: #fff3e0; }
.grammar-tab-adverb { --tab-color: #c2410c; --tab-bg: #fff0e8; }
.grammar-tab-preposition { --tab-color: #0891b2; --tab-bg: #e6faff; }
.grammar-tab-conjunction { --tab-color: #be123c; --tab-bg: #fff1f2; }
.grammar-tab-article { --tab-color: #64748b; --tab-bg: #f1f5f9; }

.grammar-card {
  max-width: 920px;
}

/* ── Speed math ── */
.speedmath-tab-round-adjust { --tab-color: #2563eb; --tab-bg: #eaf1ff; }
.speedmath-tab-left-right { --tab-color: #2e7d32; --tab-bg: #e8f5e9; }
.speedmath-tab-give-back { --tab-color: #c2410c; --tab-bg: #fff0e8; }
.speedmath-tab-square-ending-5 { --tab-color: #7c3aed; --tab-bg: #f3edff; }
.speedmath-tab-multiply-by-11 { --tab-color: #0891b2; --tab-bg: #e6faff; }
.speedmath-tab-double-halve { --tab-color: #f57c00; --tab-bg: #fff3e0; }

.speedmath-card {
  max-width: 920px;
}

.speedmath-input {
  width: 100%;
  margin-top: 1rem;
  font-size: 1.15rem;
  font-weight: 900;
}

.speedmath-resources {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: -0.25rem 0 1rem;
}

.speedmath-steps {
  margin: 0.75rem 0 0 1.25rem;
  color: var(--text-secondary);
  font-weight: 700;
}

/* ── Arithmetic game ── */
.arithmetic-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.arithmetic-settings {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.arithmetic-select {
  width: 100%;
}

.arithmetic-start {
  width: 100%;
  justify-content: center;
  margin-top: 1rem;
}

.arithmetic-game-card {
  min-width: 0;
}

.arithmetic-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.arithmetic-problem {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--teal-pale);
  color: var(--text);
  font-size: 3rem;
  font-weight: 900;
  text-align: center;
}

.arithmetic-answer {
  width: 100%;
  margin-top: 1rem;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 900;
}

/* ── Module cards (dashboard) ── */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }

.module-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: block;
  position: relative;
  overflow: hidden;
}

.module-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--teal);
  transform: scaleX(0);
  transition: transform 0.2s;
}

.module-card:hover {
  border-color: var(--teal);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.module-card:hover::before { transform: scaleX(1); }

.module-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.module-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 0.25rem; }
.module-desc { font-size: 0.875rem; color: var(--text-secondary); }
.module-badge { display: inline-flex; align-items: center; padding: 0.15rem 0.65rem; background: var(--teal-light); color: var(--teal-dark); border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 700; margin-top: 0.75rem; }

/* ── Timetables ── */
.timetable-tab-reading { --tab-color: #2563eb; --tab-bg: #eaf1ff; }
.timetable-tab-facts { --tab-color: #c2410c; --tab-bg: #fff0e8; }
.timetable-tab-week { --tab-color: #2e7d32; --tab-bg: #e8f5e9; }

.panel-reading { --panel-color: #2563eb; --panel-bg: #eaf1ff; }
.panel-facts { --panel-color: #c2410c; --panel-bg: #fff0e8; }
.panel-week { --panel-color: #2e7d32; --panel-bg: #e8f5e9; }

.timetable-layout,
.timetable-practice-grid {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.timetable-practice-grid {
  grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
}

.timetable-side {
  display: grid;
  gap: 0.75rem;
}

.timetable-main {
  min-width: 0;
}

.timetable-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.timetable-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

.timetable-table th,
.timetable-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.timetable-table thead th {
  color: var(--text);
  background: var(--teal-pale);
  font-size: 0.85rem;
  font-weight: 900;
}

.timetable-table tbody th {
  color: var(--text);
  font-weight: 900;
}

.timetable-table tbody td {
  color: var(--text-secondary);
  font-weight: 800;
}

.timetable-table tr:last-child th,
.timetable-table tr:last-child td {
  border-bottom: 0;
}

.schedule-image-wrap {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.schedule-image {
  display: block;
  width: 100%;
  max-width: 760px;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.schedule-question-list {
  display: grid;
  gap: 1.25rem;
}

.schedule-page-tabs {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.schedule-question-set {
  display: grid;
  gap: 1rem;
}

.schedule-question-set h3 {
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
}

.schedule-question-item {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.schedule-question-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.schedule-question-input {
  width: 100%;
  margin-top: 0.75rem;
}

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

.fact-display {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 2.4rem;
  font-weight: 900;
  text-align: center;
}

.fact-input {
  width: 100%;
  margin-top: 1rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 900;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 0.75rem;
}

.week-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  min-height: 155px;
}

.week-day h3 {
  color: var(--green);
  font-size: 0.95rem;
  font-weight: 900;
  margin-bottom: 0.5rem;
}

.week-day p {
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.35;
  padding: 0.4rem 0;
  border-top: 1px solid var(--border);
}

/* ── Search/filter bar ── */
.search-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 0.6rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}

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

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.page-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover { border-color: var(--teal); color: var(--teal); }
.page-btn.active { background: var(--teal); border-color: var(--teal); color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Admin table ── */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.admin-table th {
  padding: 0.6rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  text-align: left;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.sort-th { text-align: left; }
.sort-th:hover { color: var(--teal); }
.sort-arrow { margin-left: 0.3rem; opacity: 0.4; }
.sort-arrow.active { opacity: 1; color: var(--teal); }

.admin-table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tbody tr:hover { background: var(--teal-pale); }

.action-btns { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── Stats row ── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }

.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--teal); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 0.2rem; }

/* ── Landing page ── */
.hero { text-align: center; padding: 4rem 1rem 3rem; }
.hero-title { font-size: 3rem; font-weight: 900; color: var(--text); letter-spacing: -0.04em; line-height: 1.1; margin-bottom: 1rem; }
.hero-title span { color: var(--teal); }
.hero-desc { font-size: 1.15rem; color: var(--text-secondary); max-width: 560px; margin: 0 auto 2rem; }
.hero-btns { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; margin-top: 3rem; }
.feature-card { background: var(--surface); border-radius: var(--radius-lg); padding: 1.5rem; text-align: center; border: 1px solid var(--border); }
.feature-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.feature-title { font-weight: 800; margin-bottom: 0.4rem; }
.feature-desc { font-size: 0.875rem; color: var(--text-secondary); }

/* ── Auth pages ── */
.auth-container { max-width: 420px; margin: 2rem auto; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2.5rem; box-shadow: var(--shadow); }
.auth-title { font-size: 1.75rem; font-weight: 900; text-align: center; margin-bottom: 0.4rem; color: var(--text); }
.auth-subtitle { text-align: center; color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 2rem; }
.auth-link { text-align: center; margin-top: 1.25rem; font-size: 0.875rem; color: var(--text-secondary); }
.auth-link a { color: var(--teal); font-weight: 700; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

/* ── Pending page ── */
.pending-container { max-width: 540px; margin: 3rem auto; text-align: center; }
.pending-steps { display: flex; align-items: center; justify-content: center; gap: 0; margin: 2rem 0; }
.step { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.step-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.step.done .step-circle { background: var(--teal); border-color: var(--teal); color: white; }
.step.current .step-circle { background: var(--amber-light); border-color: var(--amber); color: var(--amber); }
.step-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); max-width: 80px; text-align: center; line-height: 1.3; }
.step.done .step-label { color: var(--teal-dark); }
.step.current .step-label { color: var(--amber); }
.step-line { flex: 1; height: 2px; background: var(--border); min-width: 40px; }
.step.done + .step-line { background: var(--teal); }

/* ── Game/Quiz styles ── */
.quiz-container { max-width: 680px; margin: 0 auto; }
.quiz-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.quiz-progress { display: flex; gap: 0.3rem; margin-bottom: 2rem; }
.quiz-progress-dot { flex: 1; height: 6px; border-radius: 3px; background: var(--border); transition: background 0.3s; }
.quiz-progress-dot.done { background: var(--teal); }
.quiz-progress-dot.current { background: var(--amber); }

.quiz-word { font-size: 2.5rem; font-weight: 900; color: var(--text); margin: 1rem 0 0.5rem; letter-spacing: -0.02em; }
.quiz-sentence { font-size: 1rem; color: var(--text-secondary); margin-bottom: 2rem; line-height: 1.5; }
.quiz-input {
  width: 100%;
  max-width: 320px;
  padding: 0.85rem 1.25rem;
  text-align: center;
  font-size: 1.25rem;
  font-family: var(--font);
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}

.quiz-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,179,164,0.15); }
.quiz-input.correct { border-color: var(--green); background: var(--green-light); color: var(--green); }
.quiz-input.incorrect { border-color: var(--red); background: var(--red-light); color: var(--red); }

.quiz-feedback {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 1rem 0;
  min-height: 2rem;
}

.quiz-feedback.correct { color: var(--green); }
.quiz-feedback.incorrect { color: var(--red); }

/* Learn mode */
.learn-card { perspective: 800px; cursor: pointer; }
.learn-card-inner {
  position: relative;
  height: 280px;
  transform-style: preserve-3d;
  transition: transform 0.5s;
}
.learn-card.flipped .learn-card-inner { transform: rotateY(180deg); }
.learn-front, .learn-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px solid var(--border);
}
.learn-front { background: var(--surface); }
.learn-back { background: var(--teal-light); transform: rotateY(180deg); }
.learn-word { font-size: 3rem; font-weight: 900; color: var(--text); }
.learn-pos { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin-top: 0.5rem; }
.learn-sentence { font-size: 1rem; color: var(--text-secondary); text-align: center; line-height: 1.6; }
.learn-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 1.5rem; }

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--teal-light);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Loading state ── */
.loading { text-align: center; padding: 3rem; color: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 640px) {
  .hero-title { font-size: 2.2rem; }
  .main-content { padding: 1.25rem 1rem; }
  .auth-card { padding: 1.75rem 1.25rem; }
  .tab-bar { gap: 0.35rem; }
  .tab-btn { padding: 0.4rem 0.9rem; font-size: 0.8rem; }
  .speed-layout { grid-template-columns: 1fr; }
  .punctuation-layout { grid-template-columns: 1fr; }
  .progress-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-graph { min-height: 230px; }
  .progress-row { grid-template-columns: 1fr; }
  .progress-row strong { text-align: left; }
}

/* ── Flashcard (Learn tab) ── */
.flashcard {
  width: 100%;
  max-width: 480px;
  height: 220px;
  perspective: 1000px;
  cursor: pointer;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
}
.flashcard-inner.flipped { transform: rotateY(180deg); }
.flashcard-front,
.flashcard-back {
  position: absolute;
  inset: 0;
  border-radius: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backface-visibility: hidden;
  border: 2px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,.07);
  text-align: center;
}
.flashcard-front { background: var(--card); }
.flashcard-back  { background: var(--teal-light); transform: rotateY(180deg); }

/* ── Stats row (admin) ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem 1rem;
  text-align: center;
}
.stat-val {
  font-size: 2rem;
  font-weight: 900;
  color: var(--teal);
  line-height: 1;
}
.stat-lbl {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Admin table ── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th {
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
}
.sort-th {
  cursor: pointer;
  user-select: none;
  text-align: left;
}
.sort-th:hover { color: var(--teal); }
.sort-arrow { font-size: 0.7rem; margin-left: 0.25rem; }
.admin-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:hover td { background: var(--surface); }

/* ── Status badges ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-denied   { background: #fee2e2; color: #991b1b; }
.badge-locked   { background: #fde8d8; color: #9a3412; }

/* ── Search input ── */
.search-input {
  border: 1.5px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 200px;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--teal); }

/* ── Pagination ── */
.pagination {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  justify-content: center;
}
.page-btn {
  border: 1.5px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.35rem 0.65rem;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all .15s;
}
.page-btn:hover    { border-color: var(--teal); color: var(--teal); }
.page-btn.active   { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ── Audio button ── */
.audio-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.1rem 0.25rem;
  border-radius: 0.35rem;
  transition: transform .15s;
}
.audio-btn:hover { transform: scale(1.2); }

.search-input.fact-input {
  width: 100%;
}

.search-input.schedule-question-input {
  width: 100%;
}

.search-input.speedmath-input {
  width: 100%;
}

.search-input.arithmetic-select,
.search-input.arithmetic-answer {
  width: 100%;
}

@media (max-width: 780px) {
  .timetable-layout,
  .timetable-practice-grid {
    grid-template-columns: 1fr;
  }

  .arithmetic-layout {
    grid-template-columns: 1fr;
  }

  .arithmetic-stats {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .arithmetic-problem {
    min-height: 120px;
    font-size: 2.35rem;
  }

  .timetable-practice-grid .timetable-side {
    order: -1;
  }

  .week-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .fact-display {
    min-height: 120px;
    font-size: 2rem;
  }
}

/* ── Print styles ── */
@media print {
  .topnav, .tab-bar, .btn, .pagination, .search-input, #wordCount { display: none !important; }
  .tab-panel { display: block !important; }
  #panel-study, #panel-print { page-break-after: always; }
  body { background: white; color: black; }
}
