:root {
  --bg-top: #eef6ff;
  --bg-bottom: #d7e8ff;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-border: rgba(18, 57, 99, 0.12);
  --ink: #15304d;
  --muted: #55708d;
  --accent: #0f766e;
  --accent-strong: #0d9488;
  --shadow: 0 24px 60px rgba(19, 48, 77, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.page {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
}

/* ── Hero ─────────────────────────────────────────────────── */

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(21, 48, 77, 0.12);
}
.hero-link:hover { background: white; }

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 0.95;
}

.intro {
  max-width: 68ch;
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

/* ── Layout ────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

/* ── Controls sidebar ──────────────────────────────────────── */

.controls {
  padding: 1.25rem;
}

.controls h2 {
  margin: 0 0 1rem;
  font-size: 1.2rem;
}

.control-group {
  margin-bottom: 1.1rem;
}

.control-group > label {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  margin-bottom: 0.55rem;
  accent-color: var(--accent-strong);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input[type="number"] {
  flex: 1;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(21, 48, 77, 0.16);
  border-radius: 14px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

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

/* ── Segmented frame toggle ────────────────────────────────── */

.seg-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: rgba(21, 48, 77, 0.07);
  border-radius: 14px;
  padding: 3px;
}

.seg-btn {
  padding: 0.6rem 0.5rem;
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(21, 48, 77, 0.12);
}

/* ── Readout cards ─────────────────────────────────────────── */

.readout-grid {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.3rem;
}

.readout-card {
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(239, 247, 255, 0.95);
}

.readout-label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.readout-value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
}

.readout-value + .readout-value {
  margin-top: 0.2rem;
}

.highlight {
  color: var(--accent-strong);
}

.highlight-green { color: #16a34a; }
.highlight-red   { color: #dc2626; }
.muted           { color: var(--muted); }

/* ── Canvas panel ──────────────────────────────────────────── */

.visual-panel {
  padding: 0.85rem;
}

.canvas-wrap {
  overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(225, 238, 255, 0.94));
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 12 / 7;
}

/* ── Buttons ───────────────────────────────────────────────── */

.toggle-button {
  padding: 0.85rem 1.15rem;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.28);
}

.secondary-button {
  background: linear-gradient(135deg, #475569, #64748b);
  box-shadow: 0 10px 24px rgba(71, 85, 105, 0.22);
}

.fire-button {
  background: linear-gradient(135deg, #ea580c, #dc2626);
  box-shadow: 0 10px 24px rgba(220, 38, 38, 0.35);
}

.fire-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 960px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .hero-actions { justify-content: flex-start; }
  .layout { grid-template-columns: 1fr; }
}
