:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #74777d;
  --line: #e4e5e8;
  --paper: #ffffff;
  --ground: #f5f5f3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: minmax(0, 1fr);
  font: 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--ground);
}

.sidebar {
  min-width: 0;
  min-height: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.sidebar-title {
  padding: 22px 20px 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

#contents { overflow-y: auto; padding: 0 10px 18px; }

.kind-heading {
  padding: 14px 10px 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

.piece-link {
  width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 9px 10px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}
.piece-link:hover { background: #f3f4f6; }
.piece-link.active { background: #e9edf7; color: #244caa; }
.piece-link strong { display: block; font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.piece-link small { display: block; margin-top: 2px; color: var(--muted); }

main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(24px, 4vw, 56px);
  display: grid;
  justify-items: center;
  align-content: start;
  gap: clamp(20px, 3vw, 34px);
}

.card {
  width: min(1180px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: clamp(22px, 3.5vw, 40px);
  box-shadow: 0 8px 26px rgb(27 31 36 / 7%);
}

.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.position { color: var(--muted); font-size: 12px; }
.kind-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e9edf7;
  color: #244caa;
  font-size: 12px;
  font-weight: 700;
}


h1 {
  margin: 9px 0 3px;
  font: 700 clamp(17px, 2vw, 21px)/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.subtitle { color: var(--muted); font-size: 12.5px; }
.structure { margin-top: 12px; display: grid; gap: 4px; }
.structure-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 7px 10px;
  border-radius: 4px;
  background: #f2f2f0;
  border-left: 3px solid #d6d7da;
}
.structure-row code {
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #46494f;
  word-break: break-word;
}
.structure-name { font-size: 11px; font-weight: 700; color: var(--muted); }
.structure-row.teacher { border-left-color: #7256b8; }
.structure-row.teacher .structure-name { color: #7256b8; }
.structure-row.probe { border-left-color: #c2601f; }
.structure-row.probe .structure-name { color: #c2601f; }

.snap-note {
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

#piece { margin-top: 18px; }
audio { width: 100%; display: block; margin-bottom: 8px; }
.roll-stack { position: relative; cursor: crosshair; }
.roll-stack canvas { display: block; width: 100%; }
.roll-stack .cursor { position: absolute; inset: 0; pointer-events: none; }

.toolbar {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.legend { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 16px; height: 10px; border-radius: 2px; }
.swatch.band { background: #7256b8; }
.swatch.source { background: #c8cace; }
.swatch.teacher-line { height: 0; border-top: 2px solid #7256b8; }
.swatch.probe-line { height: 0; border-top: 2px dashed #c2601f; }
.swatch.cursor-line { height: 0; border-top: 2px solid #141619; }
.nav-buttons { display: flex; gap: 7px; }
.nav-buttons button { width: 38px; height: 34px; border: 1px solid var(--line); border-radius: 7px; background: white; cursor: pointer; }
.nav-buttons button:disabled { opacity: .35; cursor: default; }

@media (max-width: 760px) {
  body { grid-template-columns: 1fr; grid-template-rows: 150px minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  #contents { display: flex; overflow-x: auto; padding: 0 8px 10px; }
  .piece-link { min-width: 210px; }
  main { padding: 16px; }
  .card { padding: 18px; }
}

/* --- unconditional-sample page additions --- */
.kind-tag { font: 600 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

.variant-tabs {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.variant-tab {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfbfa;
  color: var(--muted);
  font: 600 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
}
.variant-tab:hover { border-color: #c3c6cc; color: var(--ink); }
.variant-tab.active {
  background: #e9edf7;
  border-color: #b9c7e8;
  color: #244caa;
}

.header-panel {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}
.field {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfbfa;
}
.field-name {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}
.field code {
  display: block;
  margin-top: 3px;
  font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #2b2e33;
  word-break: break-word;
}

.structure-row.plan { border-left-color: #7256b8; }
.structure-row.plan .structure-name { color: #7256b8; }
.structure-row.states { border-left-color: #3f7f96; }
.structure-row.states .structure-name { color: #3f7f96; }
.structure-row { grid-template-columns: 88px 1fr; }

.swatch.pedal { background: #c2601f; opacity: .55; }

/* --- conditional-sample page additions --- */
.card { scroll-margin-top: 12px; }
.piece { margin-top: 18px; }
.sentiment {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid #7256b8;
  border-radius: 6px;
  background: #fbfbfa;
}
.sentiment p { margin: 4px 0 0; font-size: 13.5px; line-height: 1.45; }
.sentiment .field-name { color: #7256b8; }

.card-foot { margin-top: 10px; }
.midi-link {
  font: 11.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  text-decoration: none;
}
.midi-link:hover { color: #244caa; text-decoration: underline; }

.sidebar-foot {
  margin-top: auto;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11.5px;
}

/* --- best-of-K page additions --- */
.home-link {
  display: block;
  padding: 16px 20px 0;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.home-link:hover { color: #244caa; }

.page-head {
  width: min(1180px, 100%);
  padding: 0 4px;
}
.page-head h1 {
  margin: 0 0 6px;
  font: 700 clamp(18px, 2.2vw, 23px)/1.25 system-ui, -apple-system, sans-serif;
}
.page-head p {
  margin: 0;
  max-width: 74ch;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.score-lines {
  margin-top: 12px;
  display: grid;
  gap: 4px;
}
.score-line {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: 4px;
  border-left: 3px solid #d6d7da;
  background: #f7f7f5;
  color: var(--muted);
}
.score-line.active {
  border-left-color: #244caa;
  background: #eef2fb;
  color: var(--ink);
}
.score-rank {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.score-text {
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-word;
}
