:root {
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #202631;
  --muted: #667085;
  --border: #dde2e8;
  --accent: #3b6fa0;
  --accent-contrast: #ffffff;
  --locked: #c7ccd3;
  --learning: #3b6fa0;
  --mastered: #4c9a6a;
  --due: #c9862b;
  --wrong: #b5544a;
  --radius: 14px;
  --focus: #1f5fa8;
}

/* Deliberately light-only: these products are pinned to a light theme regardless of the viewer's
   system/browser dark-mode setting (Mark's standing preference for everything shipped off these
   VPS products). The former `@media (prefers-color-scheme: dark)` override was removed here rather
   than fought page-by-page, since the student app and the parent view both share this one
   stylesheet. teacher.html carries the same light values in its own <style> for the same reason. */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.5;
}

@media (prefers-reduced-motion: no-preference) {
  .card,
  .btn,
  .badge {
    transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  }

  .context-drawer {
    transition: transform 0.2s ease;
  }

  .context-backdrop {
    transition: opacity 0.2s ease;
  }
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 4px;
}

h2 {
  font-size: 1.25rem;
  margin: 0 0 12px;
}

p {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
}

.btn.secondary {
  background: transparent;
  color: var(--accent);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

input[type="text"] {
  width: 100%;
  min-height: 48px;
  font-size: 1.15rem;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
}

.ladder {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rung {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  min-height: 48px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot.locked {
  background: var(--locked);
}

.dot.learning {
  background: var(--learning);
}

.dot.mastered {
  background: var(--mastered);
}

.rung-title {
  flex: 1;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.due {
  background: var(--due);
  color: #1a1200;
}

.review-btn {
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.review-btn:hover {
  filter: brightness(1.08);
}

.badge.mastered {
  background: var(--mastered);
  color: #06210f;
}

.streak {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.streak .count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}

.problem-display {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.steps {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.steps ol {
  margin: 0;
  padding-left: 20px;
}

.steps li {
  margin-bottom: 6px;
}

.feedback {
  border-radius: 10px;
  padding: 14px;
  margin-top: 16px;
}

.feedback.correct {
  background: color-mix(in srgb, var(--mastered) 18%, transparent);
  border: 1px solid var(--mastered);
}

.feedback.incorrect {
  background: color-mix(in srgb, var(--wrong) 15%, transparent);
  border: 1px solid var(--wrong);
}

/* A near-miss (sign or power/index slip) reads as "close, fix this detail" rather than
   "wrong" - amber instead of red, reusing the same tone already used for due-for-review. */
.feedback.incorrect-minor {
  background: color-mix(in srgb, var(--due) 15%, transparent);
  border: 1px solid var(--due);
}

.mistake-tag {
  color: var(--due);
  font-weight: 600;
  margin: 4px 0 10px;
}

.ai-note {
  background: var(--card-bg);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 0.95rem;
}

.progress-note {
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 8px 0;
  text-decoration: underline;
  min-height: 44px;
}

.app-header {
  margin-bottom: 20px;
}

.app-header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.header-label {
  font-weight: 700;
  font-size: 1rem;
}

.header-streak {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.app-header-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.mini-ladder {
  display: flex;
  gap: 5px;
  flex: 1;
}

.mini-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  flex: 0 0 auto;
}

.mini-dot.locked {
  background: var(--locked);
}

.mini-dot.learning {
  background: var(--learning);
}

.mini-dot.mastered {
  background: var(--mastered);
}

.mini-dot.due {
  border-color: var(--due);
}

.mini-dot.current {
  border-color: var(--text);
}

.header-home-link {
  min-height: auto;
  padding: 4px 0;
  font-size: 0.85rem;
  flex: 0 0 auto;
}

.mini-ladder-expand {
  flex: 1;
}

.mini-ladder-expand summary {
  cursor: pointer;
  min-height: 32px;
  display: flex;
  align-items: center;
}

.mini-ladder-expand summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.mini-ladder-expand summary .mini-ladder {
  margin-left: 6px;
}

.mini-ladder-expand[open] .ladder {
  margin-top: 12px;
}

.why-box {
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 16px;
}

.why-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.why-box summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.why-box p {
  margin: 10px 0 0;
  color: var(--text);
}

.context-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 36px;
  white-space: nowrap;
}

.context-toggle:hover {
  border-color: var(--accent);
}

.context-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 40;
}

.context-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.context-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(340px, 88vw);
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  z-index: 41;
  padding: 28px 20px 20px;
  overflow-y: auto;
}

.context-drawer.open {
  transform: translateX(0);
}

.context-drawer-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
}

.context-drawer-close:focus-visible,
.context-toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.context-drawer-body h2 {
  margin-top: 0;
}

.context-drawer-body p {
  color: var(--text);
}

.why-box p:first-of-type {
  margin-top: 14px;
}

/* The goal card is the visible motivational anchor on Home - a calm left-accent bar marks it as
   the "why", distinct from the plain ladder/action cards, without shouting like a reward banner. */
.goal-card {
  border-left: 4px solid var(--accent);
}

.goal-card p {
  color: var(--text);
  margin: 10px 0 0;
}

.goal-card p:first-of-type {
  font-size: 1.05rem;
}
