/*
 * style.css — dark, grainy, neon.
 *
 * Gray background with a fine white grain, charcoal panels, and one neon
 * color per job so you can read the chart at a glance:
 *   sky blue = your root chord + main buttons
 *   violet   = Jazz colors
 *   yellow   = borrowed chords (Mode Mix)
 *   lime     = locked
 *   red      = outside the key
 */
:root {
  color-scheme: dark; /* makes dropdowns, checkboxes and number boxes dark too */

  --bg: #2a2b2f;
  --panel: rgba(21, 22, 25, .92);
  --field: #1e1f23;
  --raise: #24262b;
  --ink: #eceef2;
  --muted: #8d919a;
  --line: #303238;

  --sky: #38bdf8;
  --violet: #b388ff;
  --yellow: #facc15;
  --lime: #a3e635;
  --red: #ff4d6d;

  /* Older names still used around the code */
  --accent: var(--sky);
  --root: var(--sky);
  --jazz: var(--violet);
  --mix: var(--yellow);
  --locked-line: var(--lime);
  --outside: var(--red);
}

* { box-sizing: border-box; }

html { background: #222326; min-height: 100%; }

/* Soft light from the top, on its own layer so it never seams on phones. */
html::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% -10%, #3a3c42 0%, #2a2b2f 45%, #1f2023 100%);
}

body {
  margin: 0;
  padding: 28px 16px 48px;
  background: transparent;
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* The grain: a tiny white-noise pattern laid over the whole page. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .13;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

header, main, footer { max-width: 1680px; margin: 0 auto; }

/* --- Page layout (from the wireframe) ----------------------------------
   Wide (1280px+): three columns  [controls | song | library + circle]
   Medium (900–1279px): two columns, library + circle side by side below
   Phone: one column, working panels first, "coming next" panels last.   */
.dash { display: grid; gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dash > * { min-width: 0; }

/* Wide (1280px and up): three columns.
     settings          | Band (stretches across to the right edge)
     Instrument Assist | style knobs (Jazz, Mode Mix, Guardrails) | circle,
     fretboard, the song and notation across both                | scale, library
   The last row stretches, so the tall right column never pulls gaps into
   the rows on the left. */
@media (min-width: 1280px) {
  .dash {
    grid-template-columns: 290px minmax(0, 1fr) clamp(380px, 28vw, 460px);
    grid-template-areas:
      "controls band  band"
      "assist   knobs right"
      "fret     fret  right"
      "chart    chart right"
      "nota     nota  right";
    grid-template-rows: auto auto auto auto 1fr;
  }
}
/* Medium (900–1279px): two columns, then the right column's panels below. */
@media (min-width: 900px) and (max-width: 1279px) {
  .dash {
    grid-template-columns: 290px minmax(0, 1fr);
    grid-template-areas:
      "controls band"
      "assist   knobs"
      "fret     fret"
      "chart    chart"
      "nota     nota"
      "right    right";
  }
  .col-right { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .col-right .scale-panel { grid-column: 1 / -1; grid-row: 1; }
  .col-right .circle-panel { grid-column: 1; grid-row: 2; }
  .col-right .library-panel { grid-column: 2; grid-row: 2; }
}
@media (min-width: 900px) {
  .dash > .controls { grid-area: controls; align-self: stretch; }
  .dash > .knobs-panel { grid-area: knobs; align-self: stretch; }
  .dash > .assist-panel { grid-area: assist; align-self: stretch; }
  .dash > .band-panel { grid-area: band; }
  .dash > .fretboard-panel { grid-area: fret; }
  .dash > #chart { grid-area: chart; }
  .dash > .notation-panel { grid-area: nota; margin-top: 0; }
  .col-right { grid-area: right; }
}
/* Phone: one column, in the order you'd use them. */
@media (max-width: 899px) {
  .dash { display: flex; flex-direction: column; align-items: stretch; }
  .col { display: contents; }
  .controls        { order: 1; }
  .band-panel      { order: 2; }
  .assist-panel    { order: 3; }
  .knobs-panel     { order: 4; }
  .fretboard-panel { order: 5; }
  .scale-panel     { order: 6; }
  #chart           { order: 7; }
  .notation-panel  { order: 8; }
  .library-panel   { order: 9; }
  .circle-panel    { order: 10; }
}

h1 { margin: 0 0 6px; font-size: 30px; font-weight: 750; letter-spacing: -.02em; }
h1::after {
  content: "";
  display: block;
  width: 56px;
  height: 3px;
  margin-top: 8px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--sky), var(--violet), var(--yellow), var(--red));
  box-shadow: 0 0 12px rgba(56, 189, 248, .45);
}
.version {
  font: 500 12px/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--muted);
  letter-spacing: .04em;
  vertical-align: middle;
}
.hint { margin: 10px 0 20px; color: var(--muted); max-width: 760px; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--sky);
  outline-offset: 2px;
}

input[type="number"], select {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}
input[type="checkbox"] { accent-color: var(--sky); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 10px 30px rgba(0, 0, 0, .25);
}

/* --- Song controls (left column) ---------------------------------------- */
.controls { display: flex; flex-direction: column; gap: 8px; padding: 12px; }

.setting {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 10px;
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.setting-body { display: flex; align-items: center; gap: 6px; min-width: 0; }
.setting-body.stack { flex-direction: column; align-items: stretch; }
.setting-body select { width: 100%; min-width: 0; }
.label { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.unit { color: var(--muted); font-size: 13px; }
#tempo-input { width: 72px; }

/* Lock buttons: a hollow outline lock. Open + gray when unlocked,
   closed + lime when locked. */
.lock {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: color .15s, border-color .15s, box-shadow .15s;
}
.lock:hover { color: var(--ink); border-color: #45484f; }
.lock.on {
  color: var(--lime);
  border-color: rgba(163, 230, 53, .55);
  box-shadow: 0 0 12px rgba(163, 230, 53, .25);
}
.lock svg { width: 18px; height: 18px; }

.primary {
  padding: 10px 24px;
  border: 0;
  border-radius: 10px;
  background: var(--sky);
  color: #04121b;
  font-weight: 700;
  letter-spacing: .01em;
  box-shadow: 0 0 18px rgba(56, 189, 248, .45);
  transition: box-shadow .15s, transform .05s;
}
.primary:hover { box-shadow: 0 0 26px rgba(56, 189, 248, .7); }
.primary:active { transform: translateY(1px); }
.controls .primary { width: 100%; margin-top: 4px; padding: 12px; font-size: 17px; }

/* --- Knobs ---------------------------------------------------------------- */
.knobs-panel { padding: 14px 12px; display: grid; gap: 14px; }
/* Three columns, one per knob: the knob on top, its settings under it.
   On a phone each column becomes a row: knob on the left, settings beside it. */
.knobs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.knob-col { display: grid; gap: 10px; align-content: start; min-width: 0; }
.knob-col + .knob-col { padding-left: 14px; border-left: 1px solid var(--line); }
.knob-col .chip-group { margin: 0; }
.knob-col .chip-group + .chip-group { margin-top: 0; }
.knob-col .guardrails { border: 0; padding: 0; margin: 0; }
@media (max-width: 640px) {
  .knobs { grid-template-columns: 1fr; gap: 12px; }
  .knob-col { grid-template-columns: 104px minmax(0, 1fr); align-items: start; }
  .knob-col + .knob-col { padding-left: 0; border-left: 0; padding-top: 12px; border-top: 1px solid var(--line); }
}
.dial-jazz { --dial: var(--violet); --glow: rgba(179, 136, 255, .35); }
.dial-mix { --dial: var(--yellow); --glow: rgba(250, 204, 21, .3); }
.dial-guard { --dial: var(--lime); --glow: rgba(163, 230, 53, .3); }
.guard-rules { margin: 4px 0 8px; padding-left: 16px; font-size: 12px; color: var(--ink); line-height: 1.5; }
.guard-rules li::marker { color: var(--lime); }

.knob { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.knob-dial {
  width: 112px;
  max-width: 100%;
  aspect-ratio: 1;
  cursor: ns-resize;
  touch-action: none;   /* so dragging on a phone turns the knob instead of scrolling */
  border-radius: 50%;
  outline: none;
}
.knob-dial:focus-visible { box-shadow: 0 0 0 2px var(--dial); }
.knob-dial svg { width: 100%; height: 100%; display: block; overflow: visible; }
.knob .tick { stroke: #4a4d55; stroke-width: 1.6; stroke-linecap: round; }
.knob .tick.lit { stroke: var(--dial); }
.knob-track { fill: none; stroke: #2e3036; stroke-width: 6; stroke-linecap: round; }
.knob-value { fill: none; stroke: var(--dial); stroke-width: 6; stroke-linecap: round; filter: drop-shadow(0 0 4px var(--dial)); }
.knob-cap { fill: #1b1c20; stroke: #3a3d44; stroke-width: 1; }
.knob-dial.turning .knob-cap, .knob-dial:hover .knob-cap { stroke: var(--dial); }
.knob-pointer { stroke: var(--dial); stroke-width: 2.5; stroke-linecap: round; }
.knob-num { fill: var(--ink); font-size: 13px; font-weight: 700; text-anchor: middle; dominant-baseline: central; transform: translateY(9px); }
.knob-name { font-weight: 700; color: var(--dial); text-shadow: 0 0 12px var(--glow); letter-spacing: .01em; }
.knob-steps { display: flex; align-items: center; gap: 8px; }
.knob-readout { min-width: 38px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.step {
  width: 24px; height: 24px; padding: 0;
  border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--muted); line-height: 1;
}
.step:hover { color: var(--dial); border-color: var(--dial); }

.chip-group { display: grid; gap: 6px; }
.chip-group + .chip-group { margin-top: 10px; }
.chip-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--dial); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 3px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  color: var(--muted);
  text-decoration: line-through;
  transition: all .15s;
}
.chip.on {
  border-color: var(--dial);
  color: var(--dial);
  background: rgba(255, 255, 255, .03);
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 0 10px var(--glow);
}
.chip.current { border-style: dotted; opacity: .45; box-shadow: none; }

.guardrails { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.guardrails label { white-space: nowrap; }
.note { margin: 0; color: var(--muted); font-size: 12px; }

/* --- Panels: titles, placeholders, scale, library ----------------------- */
.panel-title { font-weight: 700; margin-bottom: 10px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.panel-sub { font-weight: 500; font-size: 13px; color: var(--muted); }

.placeholder { padding: 14px; background: rgba(21, 22, 25, .55); border-style: dashed; box-shadow: none; }
.placeholder .panel-title { color: var(--muted); }
.soon {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--sky); border: 1px solid rgba(56, 189, 248, .5); border-radius: 999px; padding: 2px 8px;
}
.channel-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.channel-list li { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; }
.channel-list small { display: block; font-size: 11px; opacity: .8; }

.scale-panel { padding: 14px; }
.scale-notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(38px, 1fr)); gap: 6px; }
.scale-note {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--raise);
}
.scale-note .deg { font: 600 11px ui-monospace, "SF Mono", Menlo, monospace; color: var(--violet); }
.scale-note .nt { font-size: 18px; font-weight: 700; }
.scale-note.is-root { border-color: rgba(56, 189, 248, .6); box-shadow: 0 0 12px rgba(56, 189, 248, .2) inset; }
.scale-note.is-root .nt { color: var(--sky); }
.assist-panel .note, .fretboard-panel .note { margin-top: 2px; }

.library-panel { padding: 14px; }
.library { display: grid; gap: 6px; margin-bottom: 8px; max-height: 560px; overflow-y: auto; padding-right: 2px; }
.lib-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  width: 100%; padding: 8px 10px; text-align: left;
  border: 1px solid var(--line); border-radius: 10px; background: var(--raise);
}
.lib-item:hover, .lib-item:focus-visible { background: #2b2d33; }
.lib-symbol { font-size: 18px; font-weight: 700; white-space: nowrap; line-height: 1.2; }
.lib-symbol .sfx { font-size: .7em; font-weight: 600; }
.lib-body { display: flex; flex-direction: column; min-width: 0; }
.lib-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-notes { font-size: 12px; color: var(--muted); }
.lib-meta { display: flex; flex-direction: column; align-items: flex-end; }
.lib-roman { font: 12px ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); }
.lib-count { font-size: 11px; color: var(--muted); }
.lib-item.root { border-color: rgba(56, 189, 248, .6); }
.lib-item.root .lib-roman { color: var(--sky); }
.lib-item.colored .lib-symbol { color: var(--violet); text-shadow: 0 0 12px rgba(179, 136, 255, .45); }
.lib-item.borrowed { box-shadow: inset 3px 0 0 var(--yellow); }
.lib-item.outside { border: 1.5px dashed var(--red); }
.lib-item.pinned { outline: 2px solid var(--sky); outline-offset: 1px; background: #23303a; }
.lib-shape { display: grid; place-items: center; min-width: 64px; }

/* Chord Library tabs + "All chords" browser */
.lib-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.lib-head .panel-title { margin-bottom: 0; }
.browser { --dial: var(--sky); --glow: rgba(56, 189, 248, .3); display: grid; gap: 6px; margin-bottom: 8px; }
.browser[hidden], .library[hidden] { display: none; }
.br-label { color: var(--muted); margin-top: 4px; }
.browser .chip { text-decoration: none; font-weight: 600; }
.browser .chip.in-key:not(.on) { color: var(--ink); border-color: #4a4d55; }
.browser .chip.in-key::after { content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 5px; border-radius: 50%; background: var(--sky); vertical-align: middle; }
.br-card {
  margin-top: 8px; padding: 12px; display: grid; gap: 8px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--raise);
}
.br-card.pinned { outline: 2px solid var(--sky); outline-offset: 1px; }
.br-card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.br-symbol { font-size: 24px; }
.br-name { color: var(--muted); font-size: 14px; }
.fit-badge { justify-self: start; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px dashed var(--red); color: var(--red); }
.fit-badge.fits { border: 1px solid rgba(56, 189, 248, .6); color: var(--sky); }
.br-shapes { display: flex; flex-wrap: wrap; gap: 12px; }
.br-shape { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.br-shape span { font-size: 11px; color: var(--muted); }
.no-shape { font-size: 11px; color: var(--muted); text-align: center; }

/* --- Instrument Assist ---------------------------------------------------- */
.assist-panel { padding: 14px; }
.assist-fields { display: grid; gap: 8px; }
.field { display: grid; gap: 4px; }
.field select { width: 100%; }
.field[hidden], .check[hidden] { display: none; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.text-btn {
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--muted); font-size: 13px;
}
.text-btn:hover:not(:disabled) { color: var(--sky); border-color: rgba(56, 189, 248, .5); }
.text-btn:disabled { opacity: .4; cursor: default; }
.string-editor { display: grid; gap: 6px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.string-editor[hidden] { display: none; }
.string-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) 56px 28px; gap: 6px; align-items: center; }
.string-row .remove { width: 28px; height: 28px; padding: 0; font-size: 16px; line-height: 1; }
.string-row select { padding-left: 6px; padding-right: 2px; }
.string-num { font: 600 11px ui-monospace, "SF Mono", Menlo, monospace; color: var(--muted); text-align: right; }
.string-row select { min-width: 0; }
.string-editor .add { justify-self: start; }
.string-head span { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.string-head span:first-child { text-align: right; }

/* --- Fretboard / keyboard view -------------------------------------------- */
.fretboard-panel { padding: 14px; min-width: 0; }
.fb-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.fb-head .panel-title { margin-bottom: 8px; }
.fb-tools { display: flex; align-items: center; gap: 8px; }
.seg-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-toggle button { padding: 4px 10px; border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.seg-toggle button.on { background: var(--sky); color: #04121b; font-weight: 700; }
/* The neck can be wider than the screen: it scrolls sideways inside its own box. */
.fretboard-scroll { overflow-x: auto; padding-bottom: 4px; margin-bottom: 6px; }
.fretboard-scroll svg { display: block; width: 100%; height: auto; }
.fb-board { fill: #1a1b1f; }
.fb-fret { stroke: #4a4d55; stroke-width: 1.5; }
.fb-nut { stroke: #d6d6d6; stroke-width: 4; }
.fb-string { stroke: #8d919a; }
/* The peg a short string (banjo g) starts from. */
.fb-peg { fill: #2a2c31; stroke: #b5b9c2; stroke-width: 1.4; }
.fb-marker { fill: #2c2e34; }
.fb-fretnum { fill: var(--muted); font: 11px ui-monospace, "SF Mono", Menlo, monospace; text-anchor: middle; }
.fb-open { fill: var(--muted); font-size: 11px; font-weight: 600; text-anchor: middle; dominant-baseline: central; }
.fb-dot circle { fill: #3a3d44; stroke: #121214; stroke-width: 1; }
.fb-dot text { fill: #ffffff; font-size: 10px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.fb-dot.tone circle { fill: #f2f2f2; }
.fb-dot.tone text { fill: #000000; }
.fb-dot.root circle { fill: var(--sky); filter: drop-shadow(0 0 4px rgba(56, 189, 248, .7)); }
.fb-dot.root text { fill: #04121b; }
circle.fb-dot.dim { fill: #3a3d44; opacity: .7; }
/* CAGED boxes: one neon color per shape */
.caged-C { --cg: var(--red); }
.caged-A { --cg: var(--yellow); }
.caged-G { --cg: var(--lime); }
.caged-E { --cg: var(--sky); }
.caged-D { --cg: var(--violet); }
/* Numbered positions (tunings where the CAGED letters don't apply) reuse the same colors. */
.caged-1 { --cg: var(--red); }
.caged-2 { --cg: var(--yellow); }
.caged-3 { --cg: var(--lime); }
.caged-4 { --cg: var(--sky); }
.caged-5 { --cg: var(--violet); }
.caged-6 { --cg: #ff8a3d; }
.caged-7 { --cg: #f0abfc; }
.caged { cursor: pointer; }
/* Frets, strings and dots sit on top of the boxes; let clicks fall through to the box. */
/* On wide screens the neck would grow very tall; cap its height (it stays
   centered) so the song still fits under it when Play scrolls it to the top. */
.fretboard-svg { display: block; width: 100%; height: auto; max-height: 280px; }
.fretboard-svg line, .fretboard-svg .fb-dot, .fretboard-svg .fb-marker,
.fretboard-svg .fb-fretnum, .fretboard-svg .fb-open { pointer-events: none; }
.caged-band { fill: var(--cg); fill-opacity: .13; stroke: var(--cg); stroke-opacity: .55; stroke-width: 1.2; }
.caged:hover .caged-band { fill-opacity: .2; }
.caged.sel .caged-band { fill-opacity: .24; stroke-opacity: 1; stroke-width: 2; }
.caged.off .caged-band { fill-opacity: .03; stroke-opacity: .15; }
.caged-tab { fill: var(--cg); }
.caged.off .caged-tab { opacity: .3; }
.caged-letter { fill: #04121b; font-size: 9px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.fb-dot.faded, circle.fb-dot.faded { opacity: .15; }
.caged-btn.on, .caged-btn.on:hover { color: #04121b; background: var(--sky); border-color: var(--sky); font-weight: 700; }
.caged-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 8px; }
.caged-bar[hidden] { display: none; }
.caged-bar .label { margin-right: 2px; }
.caged-chip {
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--cg); color: var(--cg); background: transparent;
}
.caged-chip.sel { background: var(--cg); color: #04121b; box-shadow: 0 0 10px var(--cg); }
.kb-white { fill: #e9e9ea; stroke: #121214; }
.kb-black { fill: #1b1c20; stroke: #000; }
.kb-oct { fill: var(--muted); font-size: 10px; text-anchor: middle; }

/* Chord boxes and mini keys in the Chord Library */
.cb-line { stroke: #5a5d66; stroke-width: 1; }
.cb-nut { stroke: #d6d6d6; stroke-width: 3; }
.cb-start { fill: var(--muted); font-size: 9px; dominant-baseline: central; }
.cb-x { fill: var(--muted); font-size: 10px; text-anchor: middle; dominant-baseline: central; }
.cb-open { fill: none; stroke: #d6d6d6; stroke-width: 1.2; }
.cb-open.root { stroke: var(--sky); }
.cb-dot circle { fill: #f2f2f2; }
.cb-dot text { fill: #000; font-size: 6.5px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.cb-dot.root circle { fill: var(--sky); }
.mk-white { fill: #e9e9ea; }
/* Lit keys are filled, not outlined: chord tones in orange, the root in sky
   blue. Black keys get a light edge so two lit keys side by side stay apart. */
.mk-white.on { fill: #ff9f4a; }
.mk-black { fill: #1b1c20; }
.mk-black.on { fill: #ff7a1a; stroke: #ffe3c7; stroke-width: .8; }
.mk-white.root { fill: var(--sky); }
.mk-black.root { fill: #0ea5e9; stroke: #e0f6ff; stroke-width: .8; }

/* --- Chart ------------------------------------------------------------- */
.section { margin-bottom: 10px; padding: 10px 14px 12px; }
#chart .section:last-child { margin-bottom: 0; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.section-name { font-weight: 700; min-width: 96px; letter-spacing: .01em; }
.bars { font-size: 12px; color: var(--muted); }
.bars input { width: 52px; margin-left: 4px; }
.reroll {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.reroll:hover { color: var(--sky); border-color: rgba(56, 189, 248, .5); }

.bars-row {
  /* 4 bars per line, like a chord chart: one phrase per row. */
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.bar {
  position: relative;
  display: grid;
  /* play button | chord | staff. On a narrow tile (phones), the chord goes
     on top and the play button and staff sit side by side under it. */
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "play mid staff";
  align-items: center;
  column-gap: 4px;
  cursor: pointer;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raise);
  min-width: 0;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.bar:hover { background: #2b2d33; }
.bar .chord { font-size: 20px; font-weight: 700; white-space: nowrap; text-align: center; }
.bar .chord .sfx { font-size: .7em; font-weight: 600; margin-left: 1px; }
.bar .roman { font-size: 12px; color: var(--muted); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.bar .from { text-align: center; font-size: 10px; color: var(--yellow); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Root chord: sky blue */
.bar.root { border-color: rgba(56, 189, 248, .6); box-shadow: 0 0 14px rgba(56, 189, 248, .18) inset; }
.bar.root .roman { color: var(--sky); }
/* Jazz color: violet */
.bar.colored .chord { color: var(--violet); text-shadow: 0 0 12px rgba(179, 136, 255, .45); }
/* Borrowed: yellow underline */
.bar.borrowed { box-shadow: inset 0 -2px 0 var(--yellow); }
.bar.root.borrowed { box-shadow: inset 0 -2px 0 var(--yellow), 0 0 14px rgba(56, 189, 248, .18) inset; }
/* Locked: lime border */
.bar.locked { border-color: var(--lime); box-shadow: 0 0 12px rgba(163, 230, 53, .2); }
/* The bar the band is playing right now */
.bar.playing {
  border-color: var(--sky);
  box-shadow: 0 0 0 2px var(--sky), 0 0 18px rgba(56, 189, 248, .5);
  background: #23303a;
}
.repeat-select { padding: 2px 4px; margin-left: 4px; }
/* Chord library hover: the bars that use that chord */
.bar.match { outline: 2px solid var(--sky); outline-offset: 2px; }
/* Outside the key: red dashed border */
.bar.outside { border: 1.5px dashed var(--red); }

.bar-mid { grid-area: mid; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bar-staff { grid-area: staff; line-height: 0; }
.bar-staff .mini-staff { display: block; }
.bar-play {
  grid-area: play; width: 30px; height: 30px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  border: 1px solid rgba(163, 230, 53, .55); background: transparent; color: var(--lime);
}
.bar-play:hover, .bar-play:focus-visible { background: rgba(163, 230, 53, .14); box-shadow: 0 0 10px rgba(163, 230, 53, .35); }
.bar-play:active { background: var(--lime); color: #0f1a00; }
.bar:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.bar .pin { position: absolute; bottom: 5px; left: 6px; color: var(--lime); line-height: 0; }
.bar .pin svg { width: 13px; height: 13px; }
/* Narrow tiles: chord on top, play + staff underneath. */
@media (max-width: 700px) {
  .bar { grid-template-columns: auto auto; grid-template-areas: "mid mid" "play staff"; justify-content: center; row-gap: 4px; padding: 8px 2px 6px; }
  .bar-play { width: 26px; height: 26px; }
  .bar .chord { font-size: 16px; }
  .bar .pin { top: 5px; right: 5px; bottom: auto; left: auto; }
}
.empty { color: var(--muted); font-style: italic; }

/* --- Circle of fifths -------------------------------------------------- */
/* Monochrome: dark slices with white text, your key in faded white with
   black text, chords in your song boxed in white, the root in sky blue. */
.circle-panel { padding: 12px 14px 14px; }
.circle-panel summary { font-weight: 700; cursor: pointer; }
#circle svg { display: block; width: 100%; max-width: 432px; margin: 8px auto 12px; }
.seg { fill: #2a2a2a; stroke: #121214; stroke-width: 1.5; transition: fill .15s; cursor: help; outline: none; }
.seg.inkey { fill: #b4b4b4; }
.seg.hover { fill: #4a4a4a; }
.seg.inkey.hover { fill: #d6d6d6; }
.used { fill: none; stroke: #ffffff; stroke-width: 3; }
.tonic { fill: none; stroke: var(--sky); stroke-width: 5; filter: drop-shadow(0 0 6px rgba(56, 189, 248, .7)); }
.seg-label { fill: #ffffff; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-weight: 500; }
.seg-label.inkey { fill: #000000; font-weight: 700; }
.hub { fill: #121214; stroke: #3a3a3a; }
.hub-key { fill: #ffffff; font-size: 22px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.hub-mode { fill: #b5b5b5; font-size: 11px; text-anchor: middle; dominant-baseline: central; }

/* Key under the circle: label on the left, short items on the right. */
.circle-key {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.circle-key dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding-top: 2px;
}
.circle-key dd { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.circle-key span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; flex: none; background: #2a2a2a; box-shadow: 0 0 0 1px #121214; }
.swatch.lit { background: #b4b4b4; }
.swatch.used { border: 2.5px solid #ffffff; }
.swatch.tonic { border: 3px solid var(--sky); }

/* --- Chord readout ------------------------------------------------------ */
.chord-tip {
  position: absolute;
  z-index: 50;
  max-width: min(320px, calc(100vw - 16px));
  padding: 10px 12px;
  background: rgba(14, 15, 18, .97);
  color: var(--ink);
  border: 1px solid #3a3d44;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
  font-size: 14px;
  pointer-events: none;
}
.chord-tip[hidden] { display: none; }
.tip-head { margin-bottom: 6px; }
.tip-head b { font-size: 16px; color: var(--sky); }
.tip-tones { border-collapse: collapse; margin-bottom: 6px; }
.tip-tones th { text-align: left; font-size: 10px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px 2px 0; }
.tip-tones td { text-align: center; min-width: 30px; padding: 2px 4px; border-left: 1px solid var(--line); font-weight: 600; }
.tip-tones tr:first-child td { color: var(--violet); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.tip-role { color: var(--muted); font-size: 13px; }
.tip-lock { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* --- Dialog ------------------------------------------------------------ */
dialog {
  max-width: 560px;
  width: calc(100% - 32px);
  border: 1px solid #3a3d44;
  border-radius: 16px;
  background: #151619;
  color: var(--ink);
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
.sync-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 15px; }
.sync-table th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.sync-table th, .sync-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tag { font-size: 11px; color: var(--red); border: 1px dashed var(--red); border-radius: 4px; padding: 0 4px; }
.dialog-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-buttons button:not(.primary) {
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raise);
}

footer { margin-top: 28px; color: var(--muted); font-size: 13px; }
footer a { color: var(--sky); }
code { background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 12px; }

/* --- Band (transport + mixer) ---------------------------------------------- */
.band-panel { padding: 14px 12px; display: grid; gap: 10px; }
.band-panel .panel-title { margin-bottom: 0; }
.play-btn { flex: 1; min-width: 110px; padding: 11px; font-size: 16px; }
/* Band: Loop, Count-in and Master on one line; then the groove grid and the
   mixer side by side, wrapping under each other when the panel is narrow. */
.band-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.band-head .panel-title { margin: 0 6px 0 0; }
.band-head .fader.master { flex: 1; min-width: 180px; }
.band-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px 22px; align-items: start; }
/* Wide: groove grid | drum kit | bass, guitar, keys, kept short (no taller than the settings box). */
@media (min-width: 1280px) {
  .band-body { grid-template-columns: minmax(240px, 280px) minmax(220px, 280px) minmax(0, 1fr); }
  .band-panel .groove-grid { max-width: 240px; }
}
.band-drums, .band-players { display: grid; gap: 8px; align-content: start; }
.band-body > .groove { border-top: 0; padding-top: 0; margin: 0; }

/* Play sits under Randomize (#generate): lime so the two big buttons don't look alike. */
.controls .play-btn { flex: none; margin-top: 8px; background: var(--lime); color: #0f1a00; box-shadow: 0 0 18px rgba(163, 230, 53, .35); }
.controls .play-btn:hover { box-shadow: 0 0 26px rgba(163, 230, 53, .55); }
.controls .play-btn.on,
.play-btn.on { background: var(--red); color: #1a0006; box-shadow: 0 0 18px rgba(255, 77, 109, .5); }
.play-btn:disabled { opacity: .4; cursor: default; box-shadow: none; }
.arrangement { margin: 0; font-size: 12px; color: var(--muted); }
.now-playing { margin: 0; font-size: 13px; color: var(--sky); font-weight: 600; }
.now-playing[hidden] { display: none; }
.fader { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.fader input, .channel input[type="range"] { width: 100%; min-width: 0; accent-color: var(--sky); }
.fader.small { grid-template-columns: 74px minmax(0, 1fr); font-size: 12px; }
.channels { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.channel { display: grid; grid-template-columns: 40px 52px minmax(0, 1fr); align-items: center; gap: 8px; }
.channel .ch-opts { grid-column: 2 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.channel .rate { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.channel .rate-select { padding: 3px 6px; font-size: 12px; }
.channel.muted .ch-name, .channel.muted input { opacity: .4; }
.ch-name { font-weight: 700; font-size: 14px; }
.ch-on {
  padding: 3px 0; border-radius: 6px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.ch-on.on { border-color: var(--lime); color: var(--lime); box-shadow: 0 0 8px rgba(163, 230, 53, .25); }
.kit { display: grid; gap: 5px; margin: 0 0 0 20px; padding-left: 10px; border-left: 1px solid var(--line); }
/* Each drum: its groove-grid chip (the legend; click to pick its dot) and its fader. */
.kit-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 8px; }
.kit-row .piece-chip { justify-self: start; }
.kit-row input[type="range"] { accent-color: var(--pc); }
.kit-row.muted .piece-chip i { opacity: .35; }
/* Bass, guitar and keys: colored like the drum they follow. */
.channel.player { padding: 6px 0 8px; border-bottom: 1px solid var(--line); }
.channel.player:last-child { border-bottom: 0; }
.channel.player .ch-name { color: var(--pc); }
.channel.player .ch-vol { accent-color: var(--pc); }
.channel.player .role-toggle button.on { background: var(--pc); color: #121214; }
.follows { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); cursor: help; }
.follows i {
  font-style: normal; font-weight: 800; font-size: 10px; width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center; background: var(--pc); color: #121214;
}

/* --- Groove grid ------------------------------------------------------------ */
.groove { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.groove-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.presets { --dial: var(--sky); --glow: rgba(56, 189, 248, .3); gap: 4px; }
.presets .chip.random { border-color: rgba(163, 230, 53, .6); color: var(--lime); }
.presets .chip { text-decoration: none; padding: 2px 8px; font-size: 12px; color: var(--ink); }
.presets .chip:hover { border-color: var(--sky); color: var(--sky); }
.groove-grid { width: 100%; max-width: 280px; justify-self: center; display: block; touch-action: none; outline: none; border-radius: 10px; }
.groove-grid:focus-visible { box-shadow: 0 0 0 2px var(--sky); }
.g-cell { fill: rgba(255, 255, 255, var(--a)); stroke: #3a3d44; stroke-width: 1; cursor: pointer; }
.g-cell:hover { fill: rgba(56, 189, 248, .12); }
.g-axis { fill: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; text-anchor: middle; }
.g-tick { fill: #6b6f78; font-size: 8.5px; }
.g-dot { cursor: grab; }
.g-dot circle { fill: var(--pc); stroke: #121214; stroke-width: 1.5; filter: drop-shadow(0 0 4px var(--pc)); }
.g-dot.sel circle { stroke: #ffffff; stroke-width: 2.2; }
.g-dot.muted circle { opacity: .3; filter: none; }
.g-dot text { fill: #121214; font-size: 9.5px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.piece-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 3px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); font-size: 12px;
}
.piece-chip i {
  font-style: normal; font-weight: 800; font-size: 10px; width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center; background: var(--pc); color: #121214;
}
.piece-chip.on { border-color: var(--pc); color: var(--ink); box-shadow: 0 0 8px var(--pc); }
.groove-readout { margin: 0; font-size: 12px; color: var(--ink); }
.band-drums .groove-readout { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.band-drums .note { margin: 0; }

/* --- Notation --------------------------------------------------------------- */
.notation-panel { padding: 10px 12px 10px; margin-top: 14px; }
.notation-panel summary { font-weight: 700; cursor: pointer; }
.notation-scroll { overflow-x: auto; margin: 4px 0 2px; }
.nt-lefthand { font-size: 13px; margin-top: 6px; }
.notation-svg { display: block; color: #e9e9ea; }
.nt-line, .nt-ledger { stroke: #9a9ea6; stroke-width: 1; }
.nt-bar { stroke: #c8cad0; stroke-width: 1.2; }
.nt-thick { stroke: #e9e9ea; stroke-width: 3.2; }
.nt-head { fill: #f2f2f2; stroke: #f2f2f2; stroke-width: 1; }
.nt-head.hollow { fill: none; stroke-width: 1.8; }
.nt-head.whole { stroke-width: 2.4; }
.nt-stem { stroke: #f2f2f2; stroke-width: 1.4; }
.nt-dot { fill: #f2f2f2; }
.nt-tie { fill: none; stroke: #c8cad0; stroke-width: 1.2; }
.nt-acc { fill: #f2f2f2; font-size: 15px; text-anchor: middle; dominant-baseline: central; font-family: "Apple Symbols", "Noto Music", "Segoe UI Symbol", serif; }
.nt-clef { fill: #f2f2f2; font-size: 58px; font-family: "Noto Music", "Bravura", "Apple Symbols", "Segoe UI Symbol", serif; }
.nt-clef-path { fill: none; stroke: #f2f2f2; stroke-width: 2.2; stroke-linecap: round; }
.nt-time { fill: #f2f2f2; font: 800 21px Georgia, "Times New Roman", serif; text-anchor: middle; dominant-baseline: central; }
.nt-symbol { fill: var(--sky); font-size: 15px; font-weight: 700; }
.nt-sfx { font-size: 11px; }
.nt-section { fill: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.nt-times { fill: var(--yellow); font-size: 11px; font-weight: 700; text-anchor: end; }
.nt-playing { fill: rgba(56, 189, 248, .14); stroke: var(--sky); stroke-width: 1; }
.nt-hit { fill: transparent; }
.nt-guide { border-top: 1px solid var(--line); padding-top: 6px; }
.nt-guide summary { font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.nt-guide[open] summary { margin-bottom: 8px; }
.nt-key { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; font-size: 13px; }
.nt-key dt { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding-top: 2px; }
.nt-key dd { margin: 0; color: var(--ink); max-width: 70ch; }
@media (max-width: 520px) { .nt-key { grid-template-columns: 1fr; } .nt-key dd { margin-bottom: 4px; } }

/* --- Mini staffs (chord shapes and note readouts) ---------------------------- */
.mini-staff { display: block; flex: none; }
.nt-clef.mini { font-size: 41px; }
.nt-acc.mini { font-size: 11px; }
.nt-head.mini { stroke-width: 1.8; }
.nt-eight { fill: #f2f2f2; font: 700 8px Georgia, serif; text-anchor: middle; }
.nt-clef-fill { fill: #f2f2f2; }
.nt-brace { fill: none; stroke: #c8cad0; stroke-width: 2.4; stroke-linecap: round; }
.lib-shape { display: flex; align-items: center; gap: 4px; }
.br-shape .mini-staff { margin: 2px auto 0; }
.tip-staff { margin: 2px 0 6px; }
.tip-shape { margin: 2px 0 8px; line-height: 0; }
.tip-shape .minikeys-svg { width: 220px; height: auto; }
.tip-head sub { font-size: 11px; }
.fretboard-svg [data-midi], .keyboard-svg [data-midi] { pointer-events: auto; cursor: help; }

/* --- Fretboard while the band plays ------------------------------------------ */
/* The chord fades in quickly; the next chord's notes brighten over the bar. */
#fretboard.live .fb-dot.tone { animation: fb-fade-in .22s ease-out both; animation-delay: var(--elapsed, 0s); }
#fretboard.live .fb-dot.upcoming { animation: fb-upcoming var(--lead, 2s) linear both; animation-delay: var(--elapsed, 0s); }
.fb-dot.upcoming circle { fill: rgba(56, 189, 248, .12); stroke: var(--sky); stroke-width: 1.6; }
.fb-dot.upcoming text { fill: #dff4ff; }
.fb-dot.upcoming.root circle { fill: rgba(56, 189, 248, .35); }
@keyframes fb-fade-in { from { opacity: .15; } to { opacity: 1; } }
@keyframes fb-upcoming { from { opacity: .05; } to { opacity: .75; } }
@media (prefers-reduced-motion: reduce) {
  #fretboard.live .fb-dot.tone, #fretboard.live .fb-dot.upcoming { animation: none; }
  .fb-dot.upcoming { opacity: .45; }
}
.fb-lock { display: inline-flex; align-items: center; gap: 5px; }
.fb-lock svg { width: 13px; height: 13px; }
.fb-lock.on { border-color: var(--lime); color: var(--lime); }

/* While the band plays, the fretboard's hint line steps aside to save room. */
body.band-playing .fretboard-panel > .note { display: none; }
