:root {
  --bg-deep: #0b1120;
  --bg-card: #111827;
  --bg-panel: #1e293b;
  --border-subtle: #334155;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --sky-accent: #38bdf8;
  --sky-btn: #0369a1;
  --coral-btn: #c2410c;
  --emerald-ok: #15803d;
  --amber-warn: #b45309;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: "DejaVu Sans", system-ui, -apple-system, sans-serif;
  line-height: 1.35;
}

body {
  max-width: 1024px;
  margin: 0 auto;
  padding: 6px 12px 12px;
}

.top-header {
  margin-bottom: 6px;
}

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

h1 {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #f8fafc;
}

.lede {
  margin: 2px 0 6px;
  font-size: 0.79rem;
  color: var(--text-muted);
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

button {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 7px;
  border-radius: 6px;
  border: 1px solid #475569;
  background: var(--bg-panel);
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

button:hover, button:focus-visible {
  border-color: var(--sky-accent);
  background: #273549;
  outline: none;
}

button.btn-tab.active {
  background: var(--coral-btn);
  border-color: #fb923c;
  color: #ffffff;
}

button.btn-chip.active {
  background: var(--sky-btn);
  border-color: #7dd3fc;
  color: #ffffff;
}

.btn-act-full {
  width: 100%;
  padding: 5px 6px;
  background: #172554;
  border-color: #3b82f6;
  color: #ffffff;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 288px;
  gap: 10px;
  align-items: start;
}

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

.canvas-frame {
  position: relative;
  isolation: isolate;
  background: #080e1c;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
}

#origamiCanvas {
  display: block;
  width: 100%;
  height: 392px;
  touch-action: none;
  cursor: pointer;
}

.hud-pill {
  position: absolute;
  bottom: 7px;
  z-index: 2;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.71rem;
  font-weight: 700;
  background: #0f172a;
  border: 1px solid #475569;
  color: #f8fafc;
  pointer-events: none;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-left {
  left: 8px;
}

.hud-left.valid {
  background: var(--emerald-ok);
  border-color: #86efac;
  color: #ffffff;
}

.hud-left.invalid {
  background: var(--amber-warn);
  border-color: #fcd34d;
  color: #ffffff;
}

.hud-right {
  right: 8px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.metric-card {
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 5px 8px;
}

.metric-label {
  display: block;
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.metric-value {
  display: block;
  margin-top: 1px;
  font-size: 0.79rem;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.control-sidebar {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 8px 9px;
}

.control-card.hidden {
  display: none;
}

.control-card h2 {
  margin: 0 0 6px;
  font-size: 0.80rem;
  color: #7dd3fc;
}

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

.slider-row {
  display: block;
  margin-bottom: 6px;
  font-size: 0.73rem;
  color: var(--text-muted);
}

.slider-row input[type="range"] {
  display: block;
  width: 100%;
  margin-top: 3px;
  accent-color: #38bdf8;
}

.side-note {
  margin: 6px 0 0;
  font-size: 0.71rem;
  color: var(--text-muted);
}

.key-card .side-note {
  margin: 0;
}

kbd, code {
  font-family: "DejaVu Sans Mono", monospace;
  font-size: 0.68rem;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 4px;
  padding: 0 4px;
  color: #f8fafc;
}

.site-footer {
  margin-top: 10px;
  padding-top: 7px;
  border-top: 1px solid #1e293b;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.site-footer p {
  margin: 0;
}

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

@media (max-width: 760px) {
  body {
    padding: 4px 6px 10px;
  }

  h1 {
    font-size: 0.94rem;
  }

  .lede {
    font-size: 0.69rem;
    margin: 2px 0 4px;
    line-height: 1.25;
  }

  .action-strip {
    gap: 3px;
  }

  button {
    font-size: 0.65rem;
    padding: 3px 5px;
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  #origamiCanvas {
    height: 236px;
  }

  .hud-pill {
    font-size: 0.63rem;
    padding: 2px 6px;
    max-width: 145px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
  }
}
