/* Pitch Scope: a restrained studio palette of neutral greys, one blue, one amber. */

:root {
  --bg: #101216;
  --panel: #191c22;
  --panel-2: #1f232b;
  --border: #2a2f39;
  --border-soft: #22262e;
  --text: #d8dce3;
  --text-dim: #949cab;
  --text-faint: #6e7684;
  --track-a: #4a90d9;
  --track-b: #d98f4a;
  --good: #6f9e72;
  --warn: #c9a227;
  --alert: #c4705a;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Any rule setting `display` beats the UA stylesheet's [hidden] { display: none },
 * which would leave full-bleed overlays (.modal, .empty, .progress) invisible but
 * still on top, swallowing every click. Keep this above those rules. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* not advanced -> hide the extras */
body:not(.advanced) .adv-only { display: none !important; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  height: 48px;
  flex: none;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-mark {
  width: 15px; height: 15px;
  border-radius: 3px;
  background: linear-gradient(140deg, var(--track-a) 0 50%, var(--track-b) 50% 100%);
  opacity: 0.85;
}

.topbar h1 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
  white-space: nowrap;
}

.tracks-strip {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.track-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 260px;
  padding: 4px 6px 4px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
}

.track-chip.is-hidden { opacity: 0.45; }

.chip-swatch {
  width: 9px; height: 9px;
  border-radius: 2px;
  flex: none;
}

.chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-btn {
  background: none;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1;
}

.chip-btn:hover { color: var(--text); background: var(--border); }

.topbar-actions { display: flex; align-items: center; gap: 7px; flex: none; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { background: #262b34; border-color: #39404c; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--track-a); outline-offset: 1px; }

.btn-primary {
  background: #2b3f57;
  border-color: #3a566f;
}
.btn-primary:hover:not(:disabled) { background: #33506f; }

.btn-ghost { background: transparent; }

.btn-lg { padding: 9px 18px; font-size: 13px; }

.btn-icon {
  width: 30px;
  padding: 0;
  height: 28px;
  justify-content: center;
  font-size: 14px;
}
.btn-icon kbd { display: none; }
.btn-wide { width: auto; padding: 0 9px; font-size: 12px; }

.btn[aria-pressed="true"] {
  background: #2b3f57;
  border-color: #3a566f;
  color: #dce7f3;
}

kbd {
  font: 10px/1 var(--mono);
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #14171c;
  color: var(--text-faint);
}

/* ---------- layout ---------- */

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.plot-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.plot-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #16181d;
}

#plot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.plot-wrap.dragging #plot { cursor: grabbing; }
.plot-wrap.drop-active { outline: 2px dashed var(--track-a); outline-offset: -8px; }

/* ---------- empty state ---------- */

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: #16181d;
}

.empty-inner { max-width: 460px; }

.empty h2 {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 10px;
}

.empty p {
  color: var(--text-dim);
  margin: 0 0 16px;
}

.empty-note {
  font-size: 12px;
  margin: 14px 0 0 !important;
}

.empty-note.quiet { color: var(--text-faint); }

/* ---------- readout + progress ---------- */

.readout {
  position: absolute;
  top: 10px;
  right: 16px;
  padding: 7px 10px;
  background: rgba(20, 23, 28, 0.93);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: 11px/1.55 var(--mono);
  pointer-events: none;
  min-width: 128px;
}

.readout-time { color: var(--text-faint); margin-bottom: 3px; }
.readout-row { display: flex; align-items: center; gap: 6px; }
.readout-swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.readout-note { font-weight: 600; min-width: 34px; }
.readout-cents { color: var(--text-dim); }

.progress {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  background: rgba(16, 18, 22, 0.88);
}

.progress-label { text-align: center; color: var(--text-dim); font-size: 12px; }

.progress-bar {
  width: 240px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--track-a);
  transition: width 0.12s linear;
}

/* ---------- transport ---------- */

.transport {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  flex: none;
  background: var(--panel);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.spacer { flex: 1; }

.time-display {
  font: 11px/1 var(--mono);
  color: var(--text-dim);
  min-width: 92px;
}

.icon-play {
  width: 0; height: 0;
  border-left: 8px solid currentColor;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  margin-left: 2px;
}

.is-playing .icon-play {
  width: 8px; height: 10px;
  border: 0;
  margin-left: 0;
  background: currentColor;
  -webkit-mask: linear-gradient(#000 0 0) 0 0/3px 10px no-repeat, linear-gradient(#000 0 0) 5px 0/3px 10px no-repeat;
  mask: linear-gradient(#000 0 0) 0 0/3px 10px no-repeat, linear-gradient(#000 0 0) 5px 0/3px 10px no-repeat;
}

.seg {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.seg-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 0;
  cursor: pointer;
}

.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { color: var(--text); }
.seg-btn.is-on { background: #2b3f57; color: #dce7f3; }

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.toggle input { accent-color: var(--track-a); margin: 0; }

.zoom-group { display: flex; gap: 5px; }

/* ---------- sidebar ---------- */

.sidebar {
  width: 328px;
  flex: none;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-empty { color: var(--text-faint); font-size: 12px; }

.report {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  overflow: hidden;
}

.report-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border-soft);
}

.report-head .chip-swatch { width: 10px; height: 10px; }

.report-title {
  font-weight: 600;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-body { padding: 11px; }

.verdict { font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.verdict.tone-high { color: var(--alert); }
.verdict.tone-mid { color: var(--warn); }
.verdict.tone-low, .verdict.tone-none { color: var(--good); }
.verdict.tone-unknown { color: var(--text-dim); }

.verdict-text { color: var(--text-dim); font-size: 12px; margin: 0 0 11px; }

.score-line {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-bottom: 5px;
}

.score-value { font: 600 22px/1 var(--mono); }
.score-label { font-size: 11px; color: var(--text-faint); }

.meter {
  height: 5px;
  background: #13161b;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.meter-fill { height: 100%; border-radius: 3px; }

.components { display: grid; gap: 9px; }

.component-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 3px;
}

.component-label b { font-weight: 500; }
.component-label span { color: var(--text-faint); font-family: var(--mono); }

.component-bar {
  height: 3px;
  background: #13161b;
  border-radius: 2px;
  overflow: hidden;
}

.component-fill { height: 100%; }

.component-detail {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 3px;
}

.facts {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 10px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
}

.facts dt { color: var(--text-faint); }
.facts dd { margin: 0; font-family: var(--mono); text-align: right; }

.hist-block { margin-top: 12px; }

.hist-title {
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 5px;
}

canvas.hist {
  width: 100%;
  height: 62px;
  display: block;
  border-radius: 3px;
  background: #13161b;
}

.hist-axis {
  display: flex;
  justify-content: space-between;
  font: 9px var(--mono);
  color: var(--text-faint);
  margin-top: 3px;
}

/* ---------- settings ---------- */

.settings {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.settings summary {
  padding: 9px 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  user-select: none;
}

.settings-body { padding: 0 11px 11px; display: grid; gap: 11px; }

.field { display: grid; gap: 5px; font-size: 11px; color: var(--text-dim); }

.field-row { display: flex; align-items: center; gap: 8px; }

.field-row input[type="range"] { flex: 1; accent-color: var(--track-a); }

.field-row output {
  font: 11px var(--mono);
  color: var(--text);
  min-width: 52px;
  text-align: right;
}

.field-row select {
  flex: 1;
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.settings-note, .disclaimer {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.55;
  margin: 0;
}

.disclaimer { margin-top: auto; padding-top: 6px; }

/* ---------- modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 12, 0.72);
  padding: 24px;
  z-index: 50;
}

.modal-card {
  width: min(520px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px 18px;
}

.modal-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-card h2 { font-size: 15px; margin: 0; }
.modal-card h3 { font-size: 12px; margin: 18px 0 6px; }

.shortcuts { display: grid; gap: 6px; margin: 0; }

.shortcuts > div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: baseline;
}

.shortcuts dt { display: flex; gap: 3px; }
.shortcuts dd { margin: 0; color: var(--text-dim); font-size: 12px; }

.help-body { color: var(--text-dim); font-size: 12px; margin: 0 0 8px; }

/* ---------- narrow screens ---------- */

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; border-left: 0; border-top: 1px solid var(--border); max-height: 42vh; }
  .plot-area { min-height: 46vh; }

  /* The chips move to their own row, which needs wrapping turned on and the
   * fixed bar height released; order/flex-basis alone would just overflow. */
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 8px 12px;
    gap: 8px 12px;
  }
  .tracks-strip { order: 3; flex-basis: 100%; flex-wrap: wrap; }
  .track-chip { max-width: none; }
}

.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--track-a);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkish:hover { color: #6aa8e8; }

.error-box {
  padding: 9px 11px;
  border: 1px solid #5a3830;
  border-left-width: 3px;
  border-radius: var(--radius);
  background: #241b19;
  color: #e0a596;
  font-size: 12px;
}
