/* ==========================================================================
   TradeEntrance: Warm Hand-Drawn Theme ("Workshop")
   Mobile-First (320px+), Accessible Touch Targets (44px+), 3D Card Flip
   ========================================================================== */

:root {
  --bg-darkest: #f6ede0;
  --bg-darker: #f0e2c8;
  --bg-card: #fbf4e8;
  --bg-card-hover: #f4e8d3;
  --bg-input: #fffaf0;

  --border-subtle: #e4d3b8;
  --border-focus: #c9552f;
  --border-accent: #e3a857;

  --text-main: #3b2f2a;
  --text-muted: #6b5d4f;
  --text-dim: #8a7a68;

  --color-cyan: #c9552f;
  --color-cyan-glow: rgba(201, 85, 47, 0.25);
  --color-amber: #e3a857;
  --color-amber-ink: #8a5a1f;
  --color-emerald: #7c9473;
  --color-emerald-ink: #4f6b47;
  --color-rose: #b5533f;
  --color-purple: #8a6d8f;
  --color-purple-ink: #5c4760;
  --color-neutral-ink: #4a5a63;
  --text-on-accent: #fbf4e8;

  --font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 15px;

  --transition-fast: 0.18s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 6px 16px -6px rgba(59, 47, 42, 0.14), 0 3px 8px -4px rgba(59, 47, 42, 0.08);
  --shadow-glow: 0 0 15px var(--color-cyan-glow);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-darkest);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 12px;
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ==========================================================================
   Header & Badges
   ========================================================================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 8px 4px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
}

.logo-group > div {
  min-width: 0;
  flex: 1 1 auto;
}

.logo-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text-main);
  line-height: 1.1;
  font-family: 'Nunito', var(--font-family);
}

.logo-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-badges {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ==========================================================================
   Trade Selector
   ========================================================================== */
.trade-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
}

.trade-select-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.trade-select.styled-select {
  flex: none;
  min-height: 38px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.trade-select option:disabled {
  color: var(--text-dim);
}

/* ==========================================================================
   Session Milestones (dopamine-reward checklist)
   ========================================================================== */
.milestones-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 4px 4px;
  scrollbar-width: none;
  mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
}

.milestones-strip::-webkit-scrollbar {
  display: none;
}

.milestone-pill {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.milestone-pill .milestone-icon {
  font-size: 1rem;
  filter: grayscale(1);
  opacity: 0.6;
}

.milestone-pill.done {
  background: rgba(124, 148, 115, 0.18);
  border-color: var(--color-emerald);
  color: var(--color-emerald-ink);
  animation: milestonePop 0.4s ease;
}

.milestone-pill.done .milestone-icon {
  filter: none;
  opacity: 1;
}

@keyframes milestonePop {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.badge {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 4px;
}

.streak-badge {
  border-color: rgba(227, 168, 87, 0.45);
  color: var(--color-amber-ink);
}

.score-badge {
  border-color: rgba(201, 85, 47, 0.4);
  color: var(--color-cyan);
}

.license-badge {
  text-decoration: none;
  border-color: var(--color-emerald);
  color: var(--color-emerald-ink);
}
.license-badge:hover {
  background: var(--bg-card-hover);
}

/* ==========================================================================
   Countdown & Study Plan Ribbon
   ========================================================================== */
.countdown-card {
  background: linear-gradient(180deg, var(--bg-darker) 0%, var(--bg-card) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-card);
}

.countdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.target-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.target-title strong {
  color: var(--color-cyan);
}

.edit-date-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 4px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 6px;
  opacity: 0.7;
}

.edit-date-btn:hover {
  opacity: 1;
  background: var(--bg-card-hover);
}

.target-date-input {
  display: none;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.8rem;
  padding: 4px 6px;
  min-height: 32px;
}

.target-date-input.open {
  display: inline-block;
}

.rotation-am {
  color: var(--color-purple-ink);
  font-weight: 700;
}

.rotation-pm {
  color: var(--color-cyan);
  font-weight: 700;
}

.pill-btn {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  transition: all var(--transition-fast);
}

.pill-btn:hover, .pill-btn:active {
  background: var(--color-cyan);
  color: var(--text-on-accent);
  border-color: var(--color-cyan);
}

.timer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.time-box {
  background: var(--bg-darkest);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.time-val {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
}

.time-lbl {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

/* Study Plan Drawer */
.study-plan-drawer {
  display: none;
  background: rgba(255, 250, 240, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px;
  flex-direction: column;
  gap: 10px;
  animation: fadeIn 0.2s ease-out;
}

.study-plan-drawer.open {
  display: flex;
}

.plan-header h3 {
  font-size: 0.95rem;
  color: var(--text-main);
}

.plan-rotation {
  font-size: 0.78rem;
  color: var(--color-amber);
  display: block;
  margin-top: 2px;
}

.plan-progress-container {
  height: 8px;
  background: var(--bg-darkest);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.plan-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-cyan), var(--color-emerald));
  transition: width 0.3s ease;
}

.plan-stat {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.plan-days-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
  margin-top: 4px;
}

.plan-day-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 6px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.plan-day-pill.active-day {
  border-color: var(--color-cyan);
  background: rgba(201, 85, 47, 0.15);
  color: var(--text-main);
  font-weight: 700;
}

/* ==========================================================================
   Navigation Tabs
   ========================================================================== */
.nav-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: var(--bg-darker);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  transition: all var(--transition-fast);
}

.nav-tab span {
  font-size: 1.1rem;
}

.nav-tab.active {
  background: var(--bg-card);
  color: var(--color-cyan);
  box-shadow: 0 2px 8px rgba(59, 47, 42, 0.12);
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-content.active {
  display: flex;
}

/* ==========================================================================
   Flash Cards Engine
   ========================================================================== */
.deck-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 28px), transparent);
}

.category-filters::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  background: var(--bg-darker);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: all var(--transition-fast);
}

.filter-chip.active {
  background: rgba(201, 85, 47, 0.15);
  border-color: var(--color-cyan);
  color: var(--color-cyan);
}

.deck-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.action-btn-sm {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 36px;
}

.action-btn-sm:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.card-stage {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  padding: 0 4px;
}

.category-tag {
  background: rgba(138, 109, 143, 0.22);
  color: var(--color-purple-ink);
  border: 1px solid rgba(138, 109, 143, 0.35);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.card-indicator {
  color: var(--text-muted);
  font-weight: 700;
}

.status-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.status-tag.mastered {
  border-color: var(--color-emerald);
  color: var(--color-emerald);
  background: rgba(124, 148, 115, 0.18);
}

.status-tag.review {
  border-color: var(--color-rose);
  color: var(--color-rose);
  background: rgba(181, 83, 63, 0.18);
}

/* 3D Card Flip Implementation */
.flashcard-container {
  width: 100%;
  min-height: 330px;
  perspective: 1200px;
  cursor: pointer;
  outline: none;
  position: relative;
}

/* --- Content gating: lock overlay shared by flashcards & step-through demos --- */
.card-lock-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 20px;
  gap: 10px;
  cursor: default;
}

.lock-icon { font-size: 2rem; }
.lock-title { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 1.15rem; color: var(--text-main); }
.lock-desc { font-size: 0.85rem; color: var(--text-muted); max-width: 320px; line-height: 1.5; margin: 0; }

.lock-cta {
  background: var(--color-amber);
  color: var(--text-main);
  border-radius: 999px;
  padding: 10px 22px;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  margin-top: 4px;
}
.lock-cta:hover { background: var(--color-cyan); color: var(--text-on-accent); }

.lock-alt { font-size: 0.78rem; color: var(--text-muted); text-decoration: underline; }

.demo-card.lock-panel { align-items: center; text-align: center; }

/* Concept accordion locked modules */
.accordion-item.locked .accordion-trigger span:first-child::after { content: ' 🔒'; }
.acc-lock-msg {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.acc-lock-msg p { font-size: 0.85rem; color: var(--text-muted); margin: 0; }
.lock-cta-inline {
  background: var(--color-amber);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
}
.lock-cta-inline:hover { background: var(--color-cyan); color: var(--text-on-accent); }
.lock-alt-inline { color: var(--text-muted); text-decoration: underline; font-size: 0.85rem; font-weight: 700; }

.flashcard {
  width: 100%;
  min-height: 330px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 330px;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow-card);
}

.card-front {
  border-color: var(--border-subtle);
}

.card-back {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-darkest) 100%);
  border-color: rgba(201, 85, 47, 0.4);
}

.card-face-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(59, 47, 42, 0.10);
  padding-bottom: 10px;
}

.face-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
}

.question-label {
  background: rgba(227, 168, 87, 0.24);
  color: var(--color-amber-ink);
}

.answer-label {
  background: rgba(124, 148, 115, 0.22);
  color: var(--color-emerald-ink);
}

.tap-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px 0;
  gap: 12px;
}

.card-topic {
  font-size: 0.85rem;
  color: var(--color-cyan);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-prompt {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
}

.card-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.choice-item {
  background: var(--bg-darker);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.9rem;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.choice-item:active {
  transform: scale(0.98);
}

.choice-item.answered {
  cursor: default;
  pointer-events: none;
}

.choice-item.wrong {
  background: rgba(181, 83, 63, 0.22);
  border-color: var(--color-rose);
  color: #7a3122;
}

.choice-item.correct {
  background: rgba(124, 148, 115, 0.28);
  border-color: var(--color-emerald);
  color: var(--color-emerald-ink);
  font-weight: 700;
}

/* ==========================================================================
   Industry-Term Highlighting
   Real-world electrical color associations, so the term itself builds
   the same visual memory as the wire/state it describes.
   ========================================================================== */
.term-hot {
  color: var(--color-rose);
  font-weight: 800;
}

.term-ground, .term-safe {
  color: var(--color-emerald-ink);
  font-weight: 800;
}

.term-neutral {
  color: var(--color-neutral-ink);
  font-weight: 800;
}

.term-caution {
  color: var(--color-amber-ink);
  font-weight: 800;
}

.term-caps {
  color: var(--color-cyan);
  font-weight: 800;
}

.answer-highlight {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-emerald);
}

.solution-steps {
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.5;
  background: rgba(255, 250, 240, 0.5);
  border-left: 3px solid var(--color-cyan);
  padding: 10px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.concept-callout {
  font-size: 0.82rem;
  color: var(--text-main);
  background: rgba(227, 168, 87, 0.14);
  border: 1px dashed rgba(227, 168, 87, 0.35);
  padding: 8px 10px;
  border-radius: 6px;
}

.card-face-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(59, 47, 42, 0.10);
  padding-top: 10px;
}

.source-cite {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.flip-icon {
  font-size: 0.75rem;
  color: var(--color-cyan);
  font-weight: 600;
}

.inline-concept-btn {
  background: rgba(201, 85, 47, 0.15);
  border: 1px solid var(--color-cyan);
  color: var(--color-cyan);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 40px;
}

/* Rating Buttons */
.card-rating-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.rating-btn {
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 10px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  min-height: 56px;
  transition: all var(--transition-fast);
}

.rating-btn .btn-icon {
  font-size: 1.1rem;
}

.rating-btn .btn-text {
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
}

.btn-again { color: var(--color-rose); }
.btn-again:active { background: rgba(181, 83, 63, 0.22); }

.btn-hard { color: var(--color-amber-ink); }
.btn-hard:active { background: rgba(227, 168, 87, 0.22); }

.btn-good { color: var(--color-emerald-ink); }
.btn-good:active { background: rgba(124, 148, 115, 0.22); }

.btn-mastered { color: var(--color-cyan); }
.btn-mastered:active { background: rgba(201, 85, 47, 0.2); }

/* Navigation Controls */
.navigation-controls {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.nav-control-btn {
  flex: 1;
  background: var(--bg-darker);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.nav-control-btn.btn-flip {
  flex: 1.5;
  background: var(--bg-card-hover);
  border-color: var(--color-cyan);
  color: var(--color-cyan);
}

.nav-control-btn:active {
  background: var(--border-subtle);
}

/* ==========================================================================
   Math Demos & Visualizers
   ========================================================================== */
.demo-section-header, .concept-page-header, .timer-section-header {
  padding: 4px;
}

.demo-section-header h2, .concept-page-header h2, .timer-section-header h2 {
  font-size: 1.2rem;
  color: var(--text-main);
}

.demo-section-header p, .concept-page-header p, .timer-section-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.demo-selector-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.demo-selector-pills::-webkit-scrollbar {
  display: none;
}

.demo-pill {
  background: var(--bg-darker);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  min-height: 44px;
  transition: all var(--transition-fast);
}

.demo-pill.active {
  background: rgba(201, 85, 47, 0.2);
  border-color: var(--color-cyan);
  color: var(--color-cyan);
}

.demo-container {
  display: none;
}

.demo-container.active {
  display: block;
}

.demo-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.demo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.demo-header h3 {
  font-size: 1.05rem;
  color: var(--text-main);
}

.demo-tag {
  background: rgba(201, 85, 47, 0.15);
  color: var(--color-cyan);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.demo-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.concept-link-btn {
  align-self: flex-start;
  background: rgba(201, 85, 47, 0.1);
  border: 1px dashed var(--color-cyan);
  color: var(--color-cyan);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
}

.concept-link-btn:hover {
  background: rgba(201, 85, 47, 0.18);
}

.demo-input-row {
  display: flex;
  gap: 8px;
}

.styled-select, .styled-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 10px 12px;
  font-size: 0.9rem;
  min-height: 44px;
  outline: none;
}

.styled-select:focus, .styled-input:focus {
  border-color: var(--border-focus);
}

.pemdas-visual-steps, .fraction-result-panel, .series-visual-output, .quadratic-steps-output {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(59, 47, 42, 0.05);
  border-radius: 6px;
  border-left: 3px solid var(--color-cyan);
}

.step-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-amber);
}

.step-expr {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.step-rule {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Fraction Inputs */
.fraction-calc-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
}

.fraction-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.fraction-box label, .op-box label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.frac-inputs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 60px;
}

.frac-field {
  width: 100%;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 6px 0;
  min-height: 44px;
}

.frac-divider {
  width: 100%;
  height: 2px;
  background: var(--color-cyan);
}

.op-select {
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
  width: 60px;
}

.full-width {
  width: 100%;
  margin-top: 4px;
}

/* Slope SVG Graph */
.slope-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.slider-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.highlight-val {
  color: var(--color-cyan);
  font-weight: 800;
}

.range-slider {
  width: 100%;
  min-height: 36px;
  accent-color: var(--color-cyan);
}

.graph-wrapper {
  width: 100%;
  height: 220px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.cartesian-svg {
  width: 100%;
  height: 100%;
}

.slope-readout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
  font-size: 0.85rem;
}

/* Series & Quadratic Presets */
.series-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

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

.tag-btn {
  background: var(--bg-darker);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 4px 8px;
  cursor: pointer;
  min-height: 36px;
}

.tag-btn:hover {
  border-color: var(--color-cyan);
  color: var(--text-main);
}

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

.quad-term {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.quad-field {
  width: 60px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  min-height: 44px;
}

/* ==========================================================================
   Concept Accordion Guide
   ========================================================================== */
.concept-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.accordion-trigger {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  cursor: pointer;
  min-height: 48px;
}

.acc-chevron {
  font-size: 0.8rem;
  color: var(--color-cyan);
  transition: transform 0.2s ease;
}

.accordion-item.open .acc-chevron {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  border-top: 1px solid rgba(59, 47, 42, 0.08);
  background: var(--bg-darker);
}

.accordion-item.open .accordion-content {
  display: block;
}

.acc-inner {
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule-box {
  background: rgba(201, 85, 47, 0.08);
  border: 1px solid rgba(201, 85, 47, 0.2);
  border-radius: 6px;
  padding: 10px;
  font-family: monospace;
  color: var(--text-main);
}

/* ==========================================================================
   Pomodoro & Checklists
   ========================================================================== */
.pomodoro-card, .milestones-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pomodoro-mode-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.pomo-mode-btn {
  background: var(--bg-darker);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 8px 4px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 44px;
}

.pomo-mode-btn.active {
  background: rgba(201, 85, 47, 0.2);
  border-color: var(--color-cyan);
  color: var(--color-cyan);
}

.pomodoro-clock {
  font-size: 3.2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--text-main);
  letter-spacing: 0.05em;
  text-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.pomodoro-status {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pomodoro-controls {
  display: flex;
  gap: 8px;
}

.pomo-btn {
  flex: 1;
  border: 1px solid var(--border-subtle);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 48px;
}

.pomo-btn.btn-start {
  background: var(--color-cyan);
  color: var(--text-on-accent);
  border-color: var(--color-cyan);
}

.pomo-btn.btn-pause {
  background: var(--bg-darker);
  color: var(--color-amber);
  border-color: rgba(227, 168, 87, 0.45);
}

.pomo-btn.btn-reset {
  background: var(--bg-darker);
  color: var(--text-muted);
}

.checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-main);
}

.checklist input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--color-cyan);
}

/* ==========================================================================
   Modal & Toast
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(59, 47, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(59,47,42,0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-size: 1.1rem;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  min-height: 40px;
  min-width: 40px;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.6;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  max-width: min(90vw, 360px);
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card-hover);
  border: 1px solid var(--color-cyan);
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.35;
  box-shadow: 0 10px 25px rgba(59, 47, 42, 0.18);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
  z-index: 1100;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.app-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
  padding: 12px 0;
}

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