: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 {
  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; }

.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 {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 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 {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  max-height: calc(100vh - 6rem);
}

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

.source-select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(21,48,77,0.16);
  border-radius: 10px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255,255,255,0.9);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2355708d' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
}

.elem-section-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.elem-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
}

.elem-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.5rem;
  border: 1.5px solid rgba(21,48,77,0.14);
  border-radius: 8px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  overflow: hidden;
}

.elem-btn .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0.45;
  transition: opacity 0.12s;
}

.elem-btn.active {
  color: var(--ink);
  background: rgba(255,255,255,0.95);
}
.elem-btn.active .swatch { opacity: 1; }

.toggle-btn {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1.5px solid rgba(21,48,77,0.14);
  border-radius: 10px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  background: rgba(255,255,255,0.7);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.toggle-btn[data-active="true"] {
  color: var(--ink);
  background: rgba(255,255,255,0.95);
  border-color: rgba(21,48,77,0.22);
}
.toggle-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.readout-card {
  padding: 0.6rem 0.75rem;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(21,48,77,0.10);
  border-radius: 12px;
}

.readout-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  padding: 0.15rem 0;
}
.readout-row + .readout-row { border-top: 1px dashed rgba(21,48,77,0.10); }

.readout-k { color: var(--muted); font-weight: 700; }
.readout-v {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.readout-unit { color: var(--muted); font-weight: 600; font-size: 0.82rem; margin-left: 0.15rem; }

.visual-panel { padding: 0.85rem; }

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: #0a1628;
  aspect-ratio: 8 / 5;
}

#spec-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

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