/* Suminagashi & Ebru Paper-Marbling Studio — CC0 1.0 Public Domain */
:root {
  --bg-deep: #080e1c;
  --bg-panel: #0f172a;
  --bg-card: #152036;
  --border-subtle: #293956;
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --accent-sky: #7dd3fc;
  --btn-blue: #0369a1;
  --btn-blue-hover: #0284c7;
  --btn-amber: #c2410c;
  --btn-amber-hover: #ea580c;
  --btn-emerald: #15803d;
  --btn-emerald-hover: #16a34a;
  --btn-slate: #1e293b;
  --btn-slate-hover: #334155;
}

*, *::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, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

.page-wrap {
  max-width: 1012px;
  margin: 0 auto;
  padding: 6px 10px 14px;
}

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

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

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

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-sky);
  background: #0c1c36;
  border: 1px solid #1d4d7a;
  border-radius: 999px;
  padding: 2px 9px;
}

.lede {
  margin: 3px 0 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

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

button {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--btn-slate);
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

button:hover {
  background: var(--btn-slate-hover);
  border-color: #64748b;
}

button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
}

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

button.btn-primary:hover {
  background: var(--btn-blue-hover);
}

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

button.btn-emerald:hover {
  background: var(--btn-emerald-hover);
}

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

button.btn-amber:hover {
  background: var(--btn-amber-hover);
}

button.active {
  background: var(--btn-blue);
  border-color: #7dd3fc;
  box-shadow: inset 0 0 0 1px #7dd3fc;
}

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

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

.canvas-frame {
  position: relative;
  width: 100%;
  background: #070c18;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

#marbling-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 680 / 420;
  touch-action: none;
  cursor: crosshair;
}

.hud-pill {
  position: absolute;
  bottom: 6px;
  font-size: 0.69rem;
  font-weight: 600;
  color: #f8fafc;
  background: rgba(8, 14, 28, 0.86);
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 2px 8px;
  pointer-events: none;
  max-width: 47%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-left {
  left: 7px;
}

.hud-right {
  right: 7px;
  color: var(--accent-sky);
  border-color: #1d4d7a;
}

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

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

.metric-label {
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #94a3b8;
  text-transform: uppercase;
}

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

.control-col {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 7px 8px;
  min-width: 0;
}

.ctrl-group {
  margin-bottom: 7px;
}

.ctrl-group:last-child {
  margin-bottom: 0;
}

.ctrl-title {
  font-size: 0.71rem;
  font-weight: 700;
  color: var(--accent-sky);
  margin: 0 0 4px;
}

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

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

.btn-grid-3 button,
.btn-grid-2 button {
  padding: 4px 5px;
  font-size: 0.71rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slider-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 6px;
  font-size: 0.71rem;
  margin-top: 3px;
}

.slider-row label {
  color: var(--text-muted);
  font-weight: 600;
}

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

.slider-val {
  text-align: right;
  font-weight: 700;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}

.notes-section {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

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

.note-card h2 {
  margin: 0 0 4px;
  font-size: 0.82rem;
  color: var(--accent-sky);
}

.note-card p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.page-footer {
  margin-top: 10px;
  padding-top: 7px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

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

@media (max-width: 760px) {
  .page-wrap {
    padding: 4px 6px 12px;
  }
  h1 {
    font-size: 0.96rem;
  }
  .badge {
    font-size: 0.63rem;
    padding: 1px 7px;
  }
  .lede {
    font-size: 0.68rem;
    line-height: 1.26;
    margin: 2px 0 4px;
  }
  kbd, code {
    font-size: 0.64rem;
    padding: 0 3px;
  }
  .action-strip {
    gap: 3px;
    margin-bottom: 4px;
  }
  .action-strip button {
    font-size: 0.65rem;
    padding: 3px 6px;
  }
  .workbench-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .hud-pill {
    font-size: 0.6rem;
    padding: 1px 6px;
    bottom: 4px;
  }
  .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    margin-top: 5px;
  }
  .notes-section {
    grid-template-columns: minmax(0, 1fr);
  }
}
