:root {
  --bg: #070b14;
  --panel: rgba(15, 23, 42, .84);
  --panel-2: #111827;
  --line: rgba(148, 163, 184, .18);
  --text: #f8fafc;
  --muted: #94a3b8;
  --indigo: #818cf8;
  --indigo-strong: #6366f1;
  --cyan: #67e8f9;
  --green: #34d399;
  --amber: #fbbf24;
  --rose: #fb7185;
  --radius: 24px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(99,102,241,.18), transparent 34rem),
    radial-gradient(circle at 90% 20%, rgba(6,182,212,.10), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 64px; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:20px; }
.brand { display:flex; align-items:center; gap:12px; }
.brand-mark { width:40px; height:40px; border-radius:14px; display:grid; place-items:center; font-weight:900; background:linear-gradient(135deg,var(--indigo-strong),#a855f7); box-shadow:0 12px 34px rgba(99,102,241,.28); }
.brand-copy strong { display:block; letter-spacing:.08em; font-size:.92rem; }
.brand-copy span { color:var(--muted); font-size:.78rem; }
.lang-select { background:#0f172a; color:var(--text); border:1px solid var(--line); border-radius:12px; padding:9px 12px; }

.progress-wrap { margin-bottom:18px; }
.progress-meta { display:flex; justify-content:space-between; gap:12px; color:var(--muted); font-size:.82rem; margin-bottom:8px; }
.progress-track { height:8px; border-radius:99px; background:#111827; overflow:hidden; border:1px solid rgba(148,163,184,.12); }
.progress-bar { height:100%; background:linear-gradient(90deg,var(--indigo-strong),var(--cyan)); transition:width .35s ease; }

.stage { background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); box-shadow:0 30px 80px rgba(0,0,0,.28); overflow:hidden; backdrop-filter: blur(14px); }
.stage-head { padding:28px 28px 0; }
.eyebrow { color:var(--indigo); text-transform:uppercase; letter-spacing:.14em; font-weight:800; font-size:.72rem; }
h1 { margin:8px 0 10px; font-size:clamp(1.7rem,4vw,2.65rem); line-height:1.05; letter-spacing:-.03em; }
.lead { color:#cbd5e1; line-height:1.65; max-width:780px; margin:0; }
.stage-body { padding:28px; }
.stage-foot { display:flex; justify-content:space-between; gap:12px; padding:20px 28px 28px; border-top:1px solid var(--line); }

.btn { border:0; border-radius:14px; padding:12px 17px; font-weight:800; transition:.18s ease; }
.btn:hover { transform:translateY(-1px); }
.btn-primary { color:white; background:linear-gradient(135deg,var(--indigo-strong),#7c3aed); box-shadow:0 10px 26px rgba(99,102,241,.24); }
.btn-secondary { color:#dbeafe; background:#111827; border:1px solid var(--line); }
.btn-ghost { color:var(--muted); background:transparent; border:1px solid transparent; }
.btn:disabled { opacity:.38; cursor:not-allowed; transform:none; }

.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.card { background:rgba(2,6,23,.45); border:1px solid var(--line); border-radius:20px; padding:20px; }
.card h3 { margin:0 0 8px; }
.muted { color:var(--muted); }
.small { font-size:.86rem; }

.choice-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin:20px 0; }
.choice { text-align:left; padding:16px; border-radius:16px; border:1px solid var(--line); background:#0b1220; color:var(--text); }
.choice.active { border-color:var(--indigo); background:rgba(99,102,241,.14); box-shadow:0 0 0 2px rgba(99,102,241,.08) inset; }

.input, .textarea { width:100%; color:var(--text); background:#070d19; border:1px solid var(--line); border-radius:14px; padding:13px 14px; outline:none; }
.input:focus, .textarea:focus { border-color:var(--indigo); box-shadow:0 0 0 3px rgba(99,102,241,.12); }
.textarea { min-height:118px; resize:vertical; line-height:1.55; }

.feedback { margin-top:14px; border-radius:16px; padding:14px 16px; border:1px solid var(--line); line-height:1.5; }
.feedback.success { color:#d1fae5; background:rgba(16,185,129,.10); border-color:rgba(52,211,153,.3); }
.feedback.warn { color:#fef3c7; background:rgba(245,158,11,.10); border-color:rgba(251,191,36,.3); }
.feedback.error { color:#ffe4e6; background:rgba(244,63,94,.10); border-color:rgba(251,113,133,.3); }

.fence-scene { display:grid; place-items:center; min-height:330px; }
.fence-board { position:relative; width:min(520px,92%); height:250px; background:linear-gradient(180deg,rgba(59,130,246,.05),rgba(16,185,129,.04)); border-radius:22px; }
.wall { position:absolute; left:10%; right:10%; top:18px; height:18px; border-radius:10px; background:repeating-linear-gradient(90deg,#475569 0 18px,#334155 18px 20px); }
.side { position:absolute; border:0; background:rgba(129,140,248,.16); color:#c7d2fe; transition:.2s; }
.side:hover, .side.selected { background:rgba(129,140,248,.55); }
.side-left,.side-right { top:58px; width:18px; height:150px; }
.side-left { left:16%; } .side-right{ right:16%; }
.side-bottom { left:16%; right:16%; bottom:42px; height:18px; }
.side-wall { left:16%; right:16%; top:40px; height:18px; background:rgba(251,191,36,.14); color:#fde68a; }
.side-wall.selected { background:rgba(251,113,133,.42); }
.scene-label { position:absolute; left:0; right:0; bottom:6px; text-align:center; color:var(--muted); font-size:.82rem; }

.slider-row { display:grid; grid-template-columns:1fr auto; align-items:center; gap:16px; }
.range { width:100%; accent-color:var(--indigo-strong); }
.metric-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-top:18px; }
.metric { padding:14px; border-radius:16px; background:#0b1220; border:1px solid var(--line); }
.metric span { display:block; color:var(--muted); font-size:.76rem; text-transform:uppercase; letter-spacing:.08em; }
.metric strong { display:block; margin-top:5px; font-size:1.28rem; }

.garden-wrap { display:flex; align-items:flex-end; justify-content:center; min-height:250px; padding:20px; }
.garden { position:relative; background:linear-gradient(180deg,rgba(16,185,129,.26),rgba(16,185,129,.12)); border-left:5px solid #a78bfa; border-right:5px solid #a78bfa; border-bottom:5px solid #a78bfa; transition:width .18s ease,height .18s ease; box-shadow:inset 0 0 40px rgba(16,185,129,.08); }
.garden::before { content:"MUR"; position:absolute; left:-5px; right:-5px; top:-28px; height:22px; border-radius:8px; display:grid; place-items:center; color:#cbd5e1; font-size:.68rem; letter-spacing:.12em; background:#334155; }

.table { width:100%; border-collapse:collapse; margin-top:14px; overflow:hidden; border-radius:14px; }
.table th,.table td { padding:11px 10px; border-bottom:1px solid var(--line); text-align:center; }
.table th { color:#cbd5e1; font-size:.8rem; text-transform:uppercase; letter-spacing:.06em; }
.table td { color:#f8fafc; }

.morph-grid { display:grid; grid-template-columns:.9fr .9fr 1.2fr; gap:16px; align-items:stretch; }
.morph-panel { background:#07101d; border:1px solid var(--line); border-radius:18px; padding:14px; min-height:280px; }
.graph { width:100%; height:250px; display:block; }
.graph text { fill:#94a3b8; font-size:11px; }
.graph .axis { stroke:#64748b; stroke-width:1; }
.graph .curve { fill:none; stroke:#818cf8; stroke-width:3; }
.graph .ghost-curve { fill:none; stroke:#818cf8; stroke-width:3; opacity:.10; }
.graph .point { fill:#67e8f9; stroke:#e0f2fe; stroke-width:2; }

.formula-row { display:grid; grid-template-columns:160px 1fr auto; gap:10px; align-items:center; margin:12px 0; }
.formula-label { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color:#c7d2fe; }
.equation { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size:clamp(1rem,2.4vw,1.35rem); line-height:1.8; color:#e2e8f0; }
.highlight { color:var(--cyan); font-weight:800; }

.summary-list { display:grid; gap:10px; margin-top:18px; }
.summary-item { display:flex; gap:12px; align-items:flex-start; padding:14px 16px; border:1px solid var(--line); background:#0a1220; border-radius:16px; }
.summary-item b { color:#c7d2fe; }

@media (max-width: 820px) {
  .grid-2,.morph-grid { grid-template-columns:1fr; }
  .choice-grid { grid-template-columns:1fr; }
  .metric-grid { grid-template-columns:1fr; }
  .formula-row { grid-template-columns:1fr; }
  .stage-head,.stage-body { padding-left:20px; padding-right:20px; }
  .stage-foot { padding:18px 20px 22px; }
}

/* MathMorph Engine v0.2 */
.stage-foot.no-back { justify-content:flex-end; }
.feedback.insight { color:#cffafe; background:rgba(6,182,212,.09); border-color:rgba(103,232,249,.30); }
.graph .visited-point { fill:#a78bfa; stroke:#ede9fe; stroke-width:1.5; opacity:.88; }
.graph .curve-reveal { stroke-dasharray:900; stroke-dashoffset:900; animation:drawCurve .8s ease forwards; }
@keyframes drawCurve { to { stroke-dashoffset:0; } }

.morph-values { display:flex; justify-content:center; flex-wrap:wrap; gap:8px; margin-top:-4px; }
.morph-token { display:inline-block; border-radius:8px; padding:1px 5px; }
.x-token { color:#c4b5fd; background:rgba(129,140,248,.10); animation:morphPulseX .45s ease; }
.area-token { color:#a5f3fc; background:rgba(103,232,249,.08); animation:morphPulseArea .52s ease; }
@keyframes morphPulseX {
  0% { box-shadow:0 0 0 0 rgba(129,140,248,.48); transform:scale(1.04); }
  100% { box-shadow:0 0 0 8px rgba(129,140,248,0); transform:scale(1); }
}
@keyframes morphPulseArea {
  0% { box-shadow:0 0 0 0 rgba(103,232,249,.42); transform:scale(1.04); }
  100% { box-shadow:0 0 0 8px rgba(103,232,249,0); transform:scale(1); }
}
.morph-progress { margin:8px 0 12px; }
.error-morph { min-height:220px; display:flex; flex-direction:column; justify-content:center; }

/* MathMorph Engine v0.3 — guided modelling */
.model-layout { align-items:start; }
.model-flow { display:grid; gap:14px; }
.model-block { background:rgba(2,6,23,.45); border:1px solid var(--line); border-radius:20px; padding:18px; transition:.2s ease; }
.model-block.active { border-color:rgba(129,140,248,.34); box-shadow:0 0 0 1px rgba(129,140,248,.06) inset; }
.model-block.complete { border-color:rgba(52,211,153,.22); }
.model-block.locked { opacity:.48; }
.model-block-head { display:flex; gap:12px; align-items:flex-start; }
.model-block-head h3 { margin:1px 0 5px; }
.model-block-head p { margin:0; line-height:1.45; }
.model-step-badge { flex:0 0 auto; width:30px; height:30px; border-radius:10px; display:grid; place-items:center; font-weight:900; color:#e0e7ff; background:rgba(99,102,241,.18); border:1px solid rgba(129,140,248,.25); }
.model-block.complete .model-step-badge { color:#d1fae5; background:rgba(16,185,129,.12); border-color:rgba(52,211,153,.24); }
.model-choice-grid { margin:14px 0 0; }
.model-scaffold { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:10px; margin:16px 0 4px; padding:12px; border-radius:14px; background:#07101d; border:1px dashed rgba(148,163,184,.22); color:#dbeafe; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-weight:800; }
.model-scaffold span:nth-child(2), .model-scaffold span:nth-child(4) { color:var(--muted); }
.model-substitution { margin:16px 0 4px; padding:14px 16px; border-radius:16px; background:rgba(6,182,212,.07); border:1px solid rgba(103,232,249,.18); }
.model-substitution p { margin:6px 0 0; }
.model-visual-card { position:sticky; top:18px; }
.model-diagram { position:relative; width:min(430px,92%); height:290px; margin:6px auto 12px; }
.model-wall { position:absolute; left:16%; right:16%; top:24px; height:32px; border-radius:10px; display:grid; place-items:center; background:#334155; color:#cbd5e1; font-size:.7rem; letter-spacing:.1em; }
.model-side { position:absolute; background:#a78bfa; color:#ede9fe; font-weight:900; }
.model-side span { position:absolute; display:grid; place-items:center; border-radius:8px; background:#111827; border:1px solid var(--line); min-width:34px; min-height:30px; }
.model-left, .model-right { top:62px; width:6px; height:165px; }
.model-left { left:20%; } .model-right { right:20%; }
.model-left span { left:-46px; top:67px; } .model-right span { right:-46px; top:67px; }
.model-bottom { left:20%; right:20%; bottom:62px; height:6px; }
.model-bottom span { left:50%; top:14px; transform:translateX(-50%); }
.model-total { position:absolute; left:0; right:0; bottom:4px; text-align:center; color:#fde68a; font-size:.82rem; }
.model-equation-stack { text-align:center; display:grid; gap:4px; padding-top:2px; }
.model-equation-stack .equation:first-child { color:#cbd5e1; font-size:1rem; }
.model-known { margin-top:12px; }
.model-visual-help { text-align:center; margin:4px 0 0; }
@media (max-width: 820px) {
  .model-visual-card { position:static; }
  .model-choice-grid { grid-template-columns:1fr; }
}

/* MathMorph Engine v0.4 — mathematical input guidance */
.keyboard-note {
  display:flex;
  align-items:flex-start;
  gap:9px;
  margin:8px 0 14px;
  padding:10px 12px;
  border-radius:12px;
  background:rgba(99,102,241,.07);
  border:1px solid rgba(129,140,248,.16);
  color:#aebbd0;
  font-size:.78rem;
  line-height:1.45;
}
.keyboard-note-icon { flex:0 0 auto; line-height:1.3; }

/* MathMorph Engine v0.6 — domain, proof, transfer */
.domain-test-row {
  display:grid;
  grid-template-columns:auto minmax(120px, 1fr) auto;
  gap:10px;
  align-items:center;
  margin:16px 0 4px;
}
.transfer-card { display:grid; gap:16px; }
.transfer-section {
  display:grid;
  grid-template-columns:34px 1fr;
  gap:12px;
  align-items:start;
  padding:14px 0;
  border-bottom:1px solid var(--line);
}
.transfer-section:last-of-type { border-bottom:0; }
.transfer-section h3 { margin:2px 0 10px; }
.transfer-section > div:last-child { min-width:0; }
.transfer-formula-row { grid-template-columns:90px 1fr; margin:8px 0 0; }
.transfer-results label { color:#cbd5e1; font-size:.9rem; }
.transfer-results .input { margin-top:8px; }
@media (max-width: 820px) {
  .domain-test-row { grid-template-columns:1fr; }
  .transfer-formula-row { grid-template-columns:1fr; }
  .transfer-section { grid-template-columns:30px 1fr; }
}

/* SummitMath v0.7 — classroom mode */
.topbar-actions { display:flex; align-items:center; gap:10px; }
.classroom-badge {
  display:flex; align-items:center; gap:8px; max-width:390px;
  padding:8px 11px; border:1px solid rgba(52,211,153,.24); border-radius:12px;
  background:rgba(16,185,129,.08); color:#d1fae5; font-size:.78rem;
}
.classroom-badge-dot { width:7px; height:7px; border-radius:99px; background:var(--green); box-shadow:0 0 0 4px rgba(52,211,153,.08); }
.classroom-badge strong { color:#ecfdf5; }
.classroom-badge span { color:#a7f3d0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.classroom-entry-wrap { min-height:calc(100vh - 88px); display:grid; place-items:center; padding:36px 0; }
.classroom-entry { width:min(650px,100%); }
.classroom-entry-body { display:grid; gap:18px; }
.classroom-code-row { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:15px 16px; border:1px solid var(--line); border-radius:16px; background:#07101d; }
.classroom-code-row span { color:var(--muted); font-size:.84rem; }
.classroom-code-row strong { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; letter-spacing:.16em; font-size:1.28rem; color:#c7d2fe; }
.classroom-form { display:grid; gap:14px; }
.classroom-form label { display:grid; gap:7px; color:#cbd5e1; font-weight:700; font-size:.9rem; }
.classroom-form .btn { margin-top:2px; }
.classroom-privacy { margin:0; color:var(--muted); font-size:.8rem; line-height:1.55; }
@media (max-width:820px) {
  .topbar { align-items:flex-start; }
  .topbar-actions { align-items:flex-end; flex-direction:column-reverse; }
  .classroom-badge { max-width:220px; }
  .classroom-badge span { max-width:120px; }
}
