:root {
  --bg: #080e1c;
  --surface: #0f172a;
  --surface-elev: #16223b;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #cbd5e1;
  --accent: #38bdf8;
  --btn-blue: #0369a1;
  --btn-blue-hover: #0284c7;
  --btn-coral: #c2410c;
  --btn-emerald: #15803d;
  --btn-neutral: #1e293b;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.4;
}

.page-shell {
  max-width: 1008px;
  margin: 0 auto;
  padding: 10px 12px 18px;
}

.top-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.top-header h1 {
  font-size: 1.28rem;
  margin: 0 0 3px;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.lede {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.spec-pill {
  flex-shrink: 0;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #0ea5e9;
  background: #0c2540;
  color: #bae6fd;
  white-space: nowrap;
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

button {
  font-family: inherit;
  font-size: 0.80rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--btn-neutral);
  border: 1px solid #475569;
  border-radius: 7px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}

button:hover {
  background: #283753;
  border-color: #7dd3fc;
}

button:focus-visible, input[type="range"]:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

button.btn-primary, button[aria-pressed="true"].toggle-blue {
  background: var(--btn-blue);
  border-color: #7dd3fc;
}

button.btn-view {
  background: var(--btn-coral);
  border-color: #fdba74;
}

button.btn-save {
  background: var(--btn-emerald);
  border-color: #86efac;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  isolation: isolate;
}

.stage-col, .control-col {
  min-width: 0;
}

.canvas-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: #050a16;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

#tidepoolCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.hud-pill {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(8, 14, 28, 0.88);
  border: 1px solid #475569;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #f8fafc;
  pointer-events: none;
  max-width: calc(100% - 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-bar {
  margin-top: 6px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.79rem;
  color: var(--muted);
}

.control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.control-group h2 {
  font-size: 0.80rem;
  font-weight: 700;
  color: #7dd3fc;
  margin: 0 0 5px;
}

.btn-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.btn-grid-2 button {
  text-align: left;
  padding: 6px 8px;
  font-size: 0.76rem;
  line-height: 1.25;
}

.btn-grid-2 button.is-active {
  background: var(--btn-blue);
  border-color: #7dd3fc;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 0.77rem;
  color: var(--muted);
}

.slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: #38bdf8;
}

.readout-chip {
  font-size: 0.74rem;
  font-weight: 700;
  color: #f8fafc;
  background: var(--surface-elev);
  border: 1px solid #475569;
  padding: 1px 7px;
  border-radius: 999px;
}

.species-legend {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}

.species-legend h2 {
  font-size: 0.84rem;
  margin: 0 0 6px;
  color: #bae6fd;
}

.species-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 6px;
}

.species-item {
  background: var(--surface-elev);
  border: 1px solid #334155;
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 0.76rem;
}

.species-item strong {
  display: block;
  color: #ffffff;
}

.species-item span {
  color: var(--muted);
}

.kbd-hint {
  font-size: 0.73rem;
  color: var(--muted);
  margin: 0;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 0.71rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #f8fafc;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
}

.page-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #1e293b;
  font-size: 0.76rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.page-footer a {
  color: #7dd3fc;
  text-decoration: underline;
}

@media (max-width: 760px) {
  .page-shell {
    padding: 7px 9px 14px;
  }
  .top-header {
    flex-direction: column;
    gap: 3px;
    margin-bottom: 5px;
  }
  .top-header h1 {
    font-size: 1.04rem;
    margin-bottom: 2px;
  }
  .lede {
    font-size: 0.75rem;
    line-height: 1.3;
  }
  .spec-pill {
    font-size: 0.68rem;
    padding: 2px 8px;
    white-space: normal;
  }
  .action-strip {
    gap: 4px;
    margin-bottom: 6px;
  }
  .action-strip button {
    font-size: 0.70rem;
    padding: 4px 7px;
  }
  .studio-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .btn-grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .hud-pill {
    font-size: 0.66rem;
    padding: 2px 7px;
    max-width: 68%;
  }
}
