:root {
  --bg:       #0b1020;
  --panel:    #121a2f;
  --panel2:   #18223d;
  --line:     #26304f;
  --text:     #eef2ff;
  --muted:    #8898c4;
  --accent:   #38bdf8;
  --accent2:  #7dd3fc;
  --amber:    #f59e0b;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 20% 10%, rgba(56,189,248,0.06) 0%, transparent 55%),
                    radial-gradient(ellipse at 80% 80%, rgba(99,102,241,0.06) 0%, transparent 55%);
  color: var(--text);
  min-height: 100vh;
}

/* ── Top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11,16,32,0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 2rem; gap: 1rem;
}
.topbar-name { font-weight: 600; font-size: 0.95rem; letter-spacing: 0.02em; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.home-link { font-size: 0.8rem; color: var(--muted); text-decoration: none; transition: color 0.2s; }
.home-link:hover { color: var(--accent); }
.lang-btn {
  background: none; border: 1px solid var(--line); color: var(--muted);
  padding: 0.2rem 0.55rem; border-radius: 999px; cursor: pointer;
  font-size: 0.78rem; font-family: 'Inter', sans-serif; font-weight: 500;
  transition: all 0.2s; letter-spacing: 0.04em;
}
.lang-btn.active, .lang-btn:hover { border-color: var(--accent); color: var(--accent); }
#theme-toggle {
  background: none; border: 1px solid var(--line); color: var(--muted);
  padding: 0.2rem 0.5rem; border-radius: 999px; cursor: pointer;
  font-size: 1rem; line-height: 1; transition: all 0.2s;
}
#theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Light theme ── */
[data-theme="light"] {
  --accent: #0369a1;
  --accent2: #075985;
  --bg:    #f0f4fa;
  --panel:  #e4eaf5;
  --panel2: #dae2f0;
  --text:  #0b1020;
  --muted: #4a5580;
  --line:  #c0cada;
}
[data-theme="light"] body { background: var(--bg); color: var(--text); }
[data-theme="light"] .topbar { background: rgba(240,244,250,0.92); }
[data-theme="light"] .hero-lead { color: #2a3a5a; }


main { max-width: 1320px; margin: 0 auto; padding: 0 2rem; }
a { color: var(--accent); text-decoration: none; }
.topbar-name { text-decoration: none; }
.hero { padding: 3.5rem 0 2.5rem; max-width: 760px; }
.hero-eyebrow { color: var(--accent); font-size: .75rem; letter-spacing: .18em; text-transform: uppercase; margin-bottom: 1.2rem; }
h1 { font-family: 'Playfair Display', Georgia, serif; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.15; margin-bottom: 1rem; }
.hero-lead { color: #c7d4f0; font-size: 1rem; line-height: 1.75; margin-bottom: 1rem; }
.tech-link { font-size: .85rem; }
.tech-link:hover { text-decoration: underline; }
.workspace { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.settings-panel, .viewer-panel, .explanation-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; min-width: 0; }
h2 { font-size: .8rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 1.4rem; color: var(--text); }
.controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
label { display: grid; gap: .5rem; min-width: 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }
#shape-control, #model-control { grid-column: 1 / -1; }
input, select, .actions button { width: 100%; min-width: 0; padding: .65rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); color: var(--text); font: inherit; font-size: .82rem; }
select { cursor: pointer; }
button { font-family: inherit; cursor: pointer; }
.check { display: flex; align-items: center; grid-column: 1 / -1; }
input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--accent); }
.actions { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: .6rem; margin-bottom: 1rem; }
.actions button:hover { border-color: var(--accent); }
.actions button.primary { color: #0b1020; background: #38bdf8; border-color: #38bdf8; font-weight: 600; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
#status { font-size: .85rem; line-height: 1.6; margin-bottom: .65rem; }
#metrics { color: var(--muted); font-size: .75rem; line-height: 1.7; margin-bottom: 1rem; }
canvas { display: block; width: 100%; height: min(60vh, 600px); min-height: 320px; background: #141e2b; border: 1px solid var(--line); border-radius: 10px; touch-action: none; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .75rem; color: var(--muted); margin-top: 1rem; }
.legend span::before { content: ''; display: inline-block; width: 20px; height: 3px; background: var(--color); margin: 0 .5rem .2rem 0; }
.explanation-panel { margin: 1.5rem 0 3rem; }
.explanation-panel p { color: var(--muted); font-size: .85rem; line-height: 1.8; }
footer { max-width: 1320px; margin: auto; padding: 1.5rem 2rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .8rem; }
@media (max-width: 900px) { .workspace { grid-template-columns: 1fr; } .controls { grid-template-columns: repeat(3,minmax(0,1fr)); } #shape-control, #model-control { grid-column: auto; } .check { grid-column: auto; } .actions { grid-template-columns: repeat(3,minmax(0,1fr)); } }
@media (max-width: 600px) { main { padding: 0 1rem; } .topbar { padding: .75rem 1rem; gap: .5rem; } .topbar-name { font-size: .8rem; } .topbar-right { gap: .4rem; } .topbar .home-link { display: none; } .hero { padding: 2.5rem 0 2rem; } .settings-panel, .viewer-panel, .explanation-panel { padding: 1rem; } .controls { grid-template-columns: repeat(2,minmax(0,1fr)); } #shape-control, #model-control, .check { grid-column: 1 / -1; } .actions { grid-template-columns: repeat(2,minmax(0,1fr)); } footer { padding: 1.5rem 1rem; } }
