:root {
  --bg-deep: #0b1120;
  --bg-panel: #111827;
  --bg-card: #1e293b;
  --border-slate: #334155;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --accent-sky: #38bdf8;
  --accent-ice: #7dd3fc;
  --btn-blue: #0369a1;
  --btn-blue-hover: #075985;
  --btn-amber: #c2410c;
  --btn-amber-hover: #9a3412;
  --btn-emerald: #15803d;
  --btn-emerald-hover: #166534;
}

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

body {
  margin: 0;
  padding: 10px 14px 18px;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.42;
}

.top-header {
  max-width: 1120px;
  margin: 0 auto 8px;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: 1.32rem;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent-sky);
  background: #0f172a;
  color: var(--accent-ice);
  font-size: 0.76rem;
  font-weight: 600;
}

.lede {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.studio-grid {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.58fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

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

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

.btn {
  appearance: none;
  border: 1px solid var(--border-slate);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: #ffffff;
  background: var(--bg-card);
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.btn:hover, .btn:focus-visible {
  border-color: var(--accent-ice);
  outline: 2px solid transparent;
}

.btn-primary {
  background: var(--btn-blue);
  border-color: #38bdf8;
}
.btn-primary:hover {
  background: var(--btn-blue-hover);
}

.btn-accent {
  background: var(--btn-amber);
  border-color: #fb923c;
}
.btn-accent:hover {
  background: var(--btn-amber-hover);
}

.btn-emerald {
  background: var(--btn-emerald);
  border-color: #4ade80;
}
.btn-emerald:hover {
  background: var(--btn-emerald-hover);
}

.btn-secondary {
  background: #1e293b;
  color: #f8fafc;
}
.btn-secondary:hover {
  background: #334155;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-slate);
  background: #0f172a;
}

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

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

.status-box {
  margin-top: 7px;
  padding: 6px 10px;
  border-radius: 7px;
  background: var(--bg-panel);
  border: 1px solid var(--border-slate);
  color: var(--text-muted);
  font-size: 0.79rem;
}

.control-col {
  background: var(--bg-panel);
  border: 1px solid var(--border-slate);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  isolation: isolate;
}

.panel-group {
  border-bottom: 1px solid #1e293b;
  padding-bottom: 9px;
}

.panel-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.panel-group h2 {
  margin: 0 0 6px;
  font-size: 0.84rem;
  color: var(--accent-ice);
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.group-head h2 {
  margin: 0;
}

.readout-pill {
  padding: 2px 7px;
  border-radius: 6px;
  background: #0f172a;
  border: 1px solid var(--border-slate);
  color: #f8fafc;
  font-size: 0.74rem;
  font-weight: 700;
}

.pill-grid {
  display: grid;
  gap: 6px;
}

.pill-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pill {
  appearance: none;
  border: 1px solid var(--border-slate);
  border-radius: 7px;
  padding: 6px 8px;
  background: var(--bg-card);
  color: #f8fafc;
  font-size: 0.76rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pill:hover, .pill:focus-visible {
  border-color: var(--accent-ice);
}

.pill.is-active {
  background: var(--btn-blue);
  border-color: #7dd3fc;
  color: #ffffff;
}

.slider-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  font-size: 0.77rem;
  color: var(--text-muted);
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent-sky);
}

.hint-text {
  margin: 7px 0 0;
  font-size: 0.74rem;
  color: var(--text-muted);
}

kbd, code {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 0 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.73rem;
  color: #f8fafc;
}

.site-footer {
  max-width: 1120px;
  margin: 12px auto 0;
  padding-top: 9px;
  border-top: 1px solid #1e293b;
  font-size: 0.77rem;
  color: var(--text-muted);
}

.site-footer p {
  margin: 4px 0;
}

.site-footer a {
  color: var(--accent-ice);
  text-decoration: underline;
}

.footer-meta {
  color: #cbd5e1;
}

@media (max-width: 820px) {
  body {
    padding: 8px 10px 16px;
  }

  h1 {
    font-size: 1.12rem;
  }

  .studio-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .pill-grid.two-col {
    grid-template-columns: minmax(0, 1fr);
  }

  .action-bar .btn {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
  }
}
