:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #555;
  --border: #000000;
  --accent: #000000;
  --accent-fg: #ffffff;
  --max-w: 1100px;
  --pad: clamp(16px, 3vw, 32px);
}

* { 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, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
a:hover { background: var(--accent); color: var(--accent-fg); }

img { max-width: 100%; height: auto; display: block; }

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 12px var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
}
.header-nav { display: flex; gap: 12px; flex-wrap: wrap; }
.header-nav a {
  font-size: 0.9rem;
  text-decoration: none;
  padding: 4px 8px;
  border: 1px solid var(--border);
}

/* Main */
main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--pad);
}

section { margin-bottom: clamp(32px, 5vw, 64px); }

.hero { text-align: center; padding-top: 16px; }
.hero h1 {
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-style: italic;
}

h2 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  margin: 0 0 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

figure { margin: 0; }
figcaption {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

/* Rig section */
.rig figure {
  border: 1px solid var(--border);
  padding: 8px;
  background: #fafafa;
}

/* MIDI section */
.midi figure {
  margin-top: 16px;
  border: 1px solid var(--border);
  background: #fafafa;
  padding: 8px;
  overflow-x: auto;
}

/* DB-driven table */
.db-table {
  margin-top: 16px;
  border: 1px solid var(--border);
  background: #fafafa;
  padding: 8px;
  overflow-x: auto;
}
.db-loading,
.db-empty,
.db-error {
  margin: 12px;
  font-style: italic;
  color: var(--muted);
  text-align: center;
}
.db-error { color: #b00020; font-style: normal; }
.db-source {
  margin: 8px 4px 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
  font-style: italic;
}

.midi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: #fff;
}
.midi-table th,
.midi-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #e0e0e0;
}
.midi-table th {
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  white-space: nowrap;
}
.midi-table tr:last-child td { border-bottom: none; }
.midi-table tbody tr:hover { background: #f0f0f0; }
.midi-table td.name { font-weight: 600; }
.midi-table td.ch,
.midi-table td.vel { font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 600px) {
  .midi-table { font-size: 0.82rem; }
  .midi-table th,
  .midi-table td { padding: 6px 6px; }
}

/* Scenes section */
.scenes-list { margin-top: 16px; }

.scenes-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.scene-card {
  border: 1px solid var(--border);
  background: #fafafa;
  padding: clamp(16px, 2.5vw, 24px);
  border-radius: 0;
  position: relative;
}
.scene-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
}

.scene-head {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ddd;
}
.scene-head h3 {
  margin: 0 0 6px;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.scene-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.scene-meta .meta-bpm,
.scene-meta .meta-clock {
  padding: 2px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0;
}

.scene-body {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #1a1a1a;
}
.scene-body p { margin: 0 0 0.8rem; }
.scene-body p:last-child { margin-bottom: 0; }

.scene-notes {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #ccc;
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}
.scene-notes p { margin: 0 0 0.6rem; }
.scene-notes p:last-child { margin-bottom: 0; }

.scenes-empty {
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--border);
  background: #fafafa;
  color: var(--muted);
}
.scenes-empty .hint {
  margin-top: 8px;
  font-size: 0.85rem;
}

@media (min-width: 800px) {
  .scenes-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Workbench iframe */
.iframe-wrap {
  margin-top: 16px;
  border: 1px solid var(--border);
  background: #000;
}
.iframe-wrap iframe {
  width: 100%;
  height: 92vh;
  min-height: 600px;
  border: 0;
  display: block;
}

/* Contact */
.contact a {
  font-weight: 600;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 32px;
  padding: 16px var(--pad);
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer a { color: var(--muted); }

@media (max-width: 600px) {
  .iframe-wrap iframe { height: 80vh; }
  .header-nav a { font-size: 0.8rem; padding: 3px 6px; }
}
