/* ── Reset & Tokens ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Background layers ── */
  --bg:        #0d1117;
  --surface:   #161b27;
  --surface2:  #1f2535;
  --border:    #2a3050;

  /* ── Accent ── */
  --accent:    #76ff03;
  --accent-lo: rgba(118,255,3,.22);

  /* ── Semantic colours ── */
  --green:     #3ddc84;
  --red:       #ff5555;
  --gold:      #f5c842;

  /* ── Typography ── */
  --text:      #dde3f0;
  --text-dim:  #6b7a99;
  --font:      'Segoe UI', system-ui, sans-serif;
  --mono:      'Courier New', monospace;

  /* ── Layout ── */
  --radius:    12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  padding: 0 16px;
}

#app { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* ── Header ─── */
header { text-align: center; padding: 4px 0; }
header h1 {
  font-size: 1.8rem; font-weight: 700;
  background: linear-gradient(120deg, var(--accent) 0%, #b2ff59 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.subtitle { color: var(--text-dim); font-size: 0.85rem; margin-top: 3px; }

/* ── Controls bar ─── */
.controls-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.ctrl-group  { display: flex; align-items: center; gap: 8px; }
.ctrl-label  { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); white-space: nowrap; }

/* ── Pill tabs ─── */
.pill-tabs { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.pill {
  padding: 5px 13px; border: none; background: transparent; color: var(--text-dim);
  border-radius: 6px; cursor: pointer; font-size: 0.81rem;
  transition: background .18s, color .18s, box-shadow .18s;
}
.pill.active { background: var(--accent); color: #111; font-weight: 600; box-shadow: 0 0 12px var(--accent-lo); }
.pill:hover:not(.active) { background: var(--surface2); color: var(--text); }

/* ── Buttons ─── */
.btn { padding: 8px 18px; border: none; border-radius: 8px; cursor: pointer; font-size: 0.84rem; font-weight: 600; transition: filter .18s, box-shadow .18s, opacity .18s; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #111; }
.btn-primary:not(:disabled):hover { filter: brightness(1.12); box-shadow: 0 0 12px var(--accent-lo); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }

/* ── Select input ─── */
.sel-input {
  padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 0.82rem;
  cursor: pointer; outline: none;
}
.sel-input:focus { border-color: var(--accent); box-shadow: 0 0 6px var(--accent-lo); }

/* ── Canvas card ─── */
.canvas-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px;
  overflow-x: clip;
}
.canvas-card canvas { display: block; width: 100%; height: auto; touch-action: none; }

/* ── Slider panel ─── */
.slider-panel {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px;
  padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.slider-row { display: flex; flex-direction: column; gap: 4px; }
.slider-label { font-size: 0.78rem; color: var(--text-dim); }
.slider-label span { color: var(--accent); font-weight: 700; font-family: var(--mono); }
.slider-panel input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--surface2); outline: none;
}
.slider-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  box-shadow: 0 0 6px var(--accent-lo);
}
.slider-panel input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: none;
  background: var(--accent); cursor: pointer;
}

/* ── Readout panel ─── */
.readout-panel {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px;
  padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.readout-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 8px;
  background: var(--surface2); border-radius: 8px;
}
.readout-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.readout-value { font-size: 1.3rem; font-weight: 700; color: var(--accent); font-family: var(--mono); }
.readout-unit { font-size: 0.7rem; color: var(--text-dim); }

/* ── Explore cards ─── */
#explore-cards {
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
.explore-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.explore-card h3 { font-size: 1rem; color: var(--accent); margin-bottom: 6px; }
.explore-card .formula {
  font-family: var(--mono); font-size: 0.88rem; color: var(--text);
  background: var(--surface2); padding: 8px 12px; border-radius: 6px;
  margin: 8px 0; display: inline-block;
}
.explore-card p { font-size: 0.84rem; color: var(--text-dim); line-height: 1.5; margin-top: 6px; }
.explore-card .example {
  margin-top: 10px; padding: 10px 14px;
  background: var(--bg); border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0;
  font-size: 0.82rem; line-height: 1.6; color: var(--text);
}

/* ── Practice bar ─── */
.practice-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.prac-question { width: 100%; font-size: 0.92rem; line-height: 1.5; color: var(--text); }
.prac-input-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prac-input {
  width: 120px; padding: 7px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 0.9rem; font-family: var(--mono);
  outline: none;
}
.prac-input:focus { border-color: var(--accent); box-shadow: 0 0 6px var(--accent-lo); }
.prac-unit { font-size: 0.8rem; color: var(--text-dim); }
.pbar-score { font-size: 0.84rem; color: var(--text-dim); margin-left: auto; }
.pbar-score span { color: var(--text); font-weight: 700; }
.feedback.ok  { color: var(--green); font-size: 0.88rem; font-weight: 600; width: 100%; }
.feedback.err { color: var(--red);   font-size: 0.88rem; font-weight: 600; width: 100%; }

.solution-panel {
  padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 0.84rem; line-height: 1.7; color: var(--text);
}
.solution-panel .step { margin: 4px 0; font-family: var(--mono); font-size: 0.82rem; }
.solution-panel .step-label { color: var(--accent); font-weight: 600; }

/* ── Quiz ─── */
.quiz-counter { font-size: 0.82rem; color: var(--accent); font-weight: 700; }
.quiz-question { width: 100%; font-size: 0.92rem; line-height: 1.5; color: var(--text); margin: 6px 0; }
#quiz-options { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.quiz-option {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface2); color: var(--text); font-size: 0.84rem;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.quiz-option:hover { border-color: var(--accent); background: var(--bg); }
.quiz-option.selected { border-color: var(--accent); background: var(--accent-lo); }
.quiz-option.correct { border-color: var(--green); background: rgba(61,220,132,.15); }
.quiz-option.wrong { border-color: var(--red); background: rgba(255,85,85,.15); }
.quiz-option:disabled { cursor: default; opacity: 0.85; }
.quiz-btns { display: flex; gap: 8px; }

/* ── Quiz result ─── */
.quiz-result {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px;
}
.qr-header { text-align: center; margin-bottom: 16px; }
.qr-score { font-size: 1.6rem; font-weight: 700; }
.qr-score.perfect { color: var(--gold); }
.qr-score.good    { color: var(--green); }
.qr-score.poor    { color: var(--red); }
.qr-stars { font-size: 1.4rem; margin-top: 4px; }
.qr-rows { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.qr-row {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 12px; border-radius: 6px;
  background: var(--surface2); font-size: 0.82rem;
}
.qr-row.ok  { border-left: 3px solid var(--green); }
.qr-row.err { border-left: 3px solid var(--red); }
.qr-row .qr-q { flex: 1; color: var(--text-dim); }
.qr-row .qr-a { color: var(--text); font-weight: 600; }
.qr-row .qr-mark { font-weight: 700; min-width: 20px; text-align: center; }

/* ── SEO article ─── */
.seo-article { padding: 24px 0; }
.seo-article h2 { font-size: 1.3rem; color: var(--text); margin-bottom: 12px; }
.seo-article h3 { font-size: 1.05rem; color: var(--text); margin: 18px 0 8px; }
.seo-article p { font-size: 0.88rem; color: var(--text-dim); line-height: 1.7; margin-bottom: 10px; }
.seo-article a { color: var(--accent); text-decoration: none; }
.seo-article a:hover { text-decoration: underline; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .slider-panel { grid-template-columns: 1fr; }
  .readout-panel { grid-template-columns: repeat(3, 1fr); }
  .controls-bar { gap: 10px; }
}

@media (max-width: 500px) {
  header h1 { font-size: 1.4rem; }
  .subtitle  { font-size: 0.78rem; }
  .controls-bar { padding: 10px 12px; gap: 8px; }
  .pill { padding: 5px 10px; font-size: 0.76rem; }
  .readout-panel { grid-template-columns: repeat(2, 1fr); }
  .readout-value { font-size: 1.1rem; }
  .practice-bar { padding: 12px 14px; }
}