:root {
  /* Canonical values: web/theme.js → THEME_DEFAULT.css (edit THEME.css when experimenting) */
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3d8bfd;
  --accent-dim: #2a5fad;
  /* timeline.js: LABEL_W (118) + TUNER_W (96) */
  --timeline-pad-l: 214px;
  /* piano-roll column labels (Channel, BPM, Key) — set from theme.js */
  --ui-kv-label-size: 10px;
  --ui-kv-label-color: #8b9cb3;
}

* {
  box-sizing: border-box;
}

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

header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.site-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 600;
}

.header-info {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.5rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.timeline-panel {
  padding-bottom: 0.75rem;
}

.timeline-toolbar {
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem;
}

.timeline-nav-control {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.timeline-nav-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: 0.1rem;
}

.timeline-nav-control button {
  min-width: 1.45rem;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 600;
}

.timeline-note-control {
  /* +1px matches .timeline-host border-left */
  margin-left: calc(var(--timeline-pad-l) + 1px);
  display: flex;
  align-items: center;
  min-height: 1.45rem;
  font-size: 0.85rem;
  text-align: left;
  flex-shrink: 0;
}

.timeline-note-control label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
}

.timeline-note-control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.timeline-note-control input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.timeline-note-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px;
  height: 14px;
  margin-top: -5px;
  border: none;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(61, 139, 253, 0.5);
}

.timeline-note-control input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  border: none;
}

.timeline-note-control input[type="range"]::-moz-range-thumb {
  width: 3px;
  height: 14px;
  border: none;
  border-radius: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(61, 139, 253, 0.5);
}

.timeline-note-control input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 2px rgba(61, 139, 253, 0.35), 0 0 8px rgba(61, 139, 253, 0.5);
}

.timeline-note-control input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 2px rgba(61, 139, 253, 0.35), 0 0 8px rgba(61, 139, 253, 0.5);
}

.timeline-host {
  width: 100%;
  min-height: 546px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0c1016;
}

.hit-timeline-canvas {
  display: block;
  cursor: crosshair;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.load-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.file-btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.file-btn.secondary {
  background: var(--accent-dim);
}

.file-btn input {
  display: none;
}

.transport-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.transport-row label {
  font: 0.9rem "Segoe UI", system-ui, sans-serif;
  color: var(--text);
}

.transport-row label:has(input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  user-select: none;
}

.transport-row label:has(input[type="checkbox"]) input {
  cursor: pointer;
}

.transport-row button {
  font-size: 0.9rem;
}

.kv-label,
#playbackState {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 400;
  line-height: 1;
  color: #8b9cb3;
}

.playback-state {
  margin-bottom: 0.5rem;
}

input[type="number"] {
  width: 5.5rem;
  margin-left: 0.35rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

button {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#btnReset,
#btnReanalyze {
  background: #243044;
  border-color: var(--accent-dim);
  color: #dce8f8;
}

#btnReset:hover:not(:disabled),
#btnReanalyze:hover:not(:disabled) {
  background: #2d3a4f;
  border-color: var(--accent);
}

#btnPlay {
  background: #1a6b38;
  border-color: #27ae60;
  color: #ecfdf3;
}

#btnPlay:hover:not(:disabled) {
  background: #20844a;
  border-color: #2ecc71;
}

#btnStop {
  background: #962f2f;
  border-color: #e74c3c;
  color: #fceaea;
}

#btnStop:hover:not(:disabled) {
  background: #a83232;
  border-color: #ff6b6b;
}

#btnExportWav,
#btnExportVgm {
  background: #1a3d5c;
  border-color: #5eb3ff;
  color: #e8f4ff;
}

#btnExportWav:hover:not(:disabled),
#btnExportVgm:hover:not(:disabled) {
  background: #245a82;
  border-color: #7ec8ff;
}

.mute-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.mute-grid label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

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

.hint-key {
  color: #fff;
  text-transform: lowercase;
}

footer {
  text-align: center;
  padding: 0.35rem 1rem 8rem;
  font-size: 0.55rem;
  color: var(--muted);
  line-height: 1.35;
}

footer p {
  margin: 0 auto;
  max-width: min(98vw, 68rem);
}

.footer-disclaimer,
.footer-extra {
  display: block;
  margin-top: 0.45rem;
}

footer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

footer a:hover {
  color: var(--text);
}

footer code {
  background: var(--panel);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}
