/* ==========================================================================
   Chord Generator — styles
   ========================================================================== */

:root {
  --bg: #0a0d16;
  --panel: #10141f;
  --panel-2: #141927;
  --panel-3: #1a2031;
  --panel-hover: #1d2437;
  --line: #20283a;
  --line-2: #2a3349;
  --text: #e8eaf2;
  --text-2: #b3b9ca;
  --muted: #7b8399;
  --icon: #9aa1b4;
  --accent: #3f7bff;
  --accent-2: #8bb2fa;
  --accent-3: #2866d9;
  --accent-soft: rgba(92, 146, 246, 0.14);
  --accent-glow: rgba(92, 146, 246, 0.45);
  --radius: 12px;
  --radius-sm: 8px;
  --hover: .1s; /* one timing for every hover/press response */
  --scale: #5eead4; /* scale overlay: a different family from the blue chord dots */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 60% -10%, rgba(40, 102, 217, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* No blinking caret anywhere but a real text field. */
* { caret-color: transparent; }
input[type="text"], input[type="search"], input[type="number"], input[type="email"], input[type="password"],
input:not([type]), textarea, [contenteditable="true"] { caret-color: auto; }
svg .fill { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 16px 18px;
  padding: 18px 20px 20px;
  max-width: 1600px;
  margin: 0 auto;
}
.topbar { grid-column: 1 / -1; }
.main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.02);
}
.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
}
.panel-title small { font-size: 12.5px; font-weight: 400; letter-spacing: 0; color: var(--muted); margin-left: 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-head-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: flex; align-items: center; gap: 4px; height: 34px; }
.brand-mark span {
  width: 7px; border-radius: 4px;
  background: linear-gradient(180deg, #b5cefd, var(--accent) 55%, var(--accent-3));
  box-shadow: 0 0 16px var(--accent-glow);
}
.brand-mark span:nth-child(1) { height: 20px; }
.brand-mark span:nth-child(2) { height: 34px; }
.brand-mark span:nth-child(3) { height: 25px; }
.brand-text h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: 0.05em; line-height: 1.1; }
.brand-text h1 span { font-weight: 300; color: #d8dbe6; }
.brand-text p { margin: 2px 0 0; font-size: 9.5px; letter-spacing: 0.18em; color: var(--muted); }

/* Grouped into one control, matching .segmented: the chrome lives on the container and the
   tabs themselves are borderless. */
.instrument-tabs {
  display: inline-flex;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 2px;
}
.inst-tab {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 124px; height: 30px;
  font-size: 13px;
  border-radius: 7px;
  color: var(--text-2);
  transition: background .15s, color .15s, box-shadow .15s;
}
.inst-tab svg { width: 18px; height: 18px; color: var(--icon); }
.inst-tab:hover { color: var(--text); }
.inst-tab.active {
  background: linear-gradient(180deg, rgba(92, 146, 246, 0.55), rgba(40, 102, 217, 0.45));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(139, 178, 250, 0.6);
}
.inst-tab.active svg { color: #c8dbff; }

.top-controls { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.top-controls .select-wrap select { height: 34px; font-size: 13px; padding-left: 12px; padding-right: 30px; }
#keySelect { min-width: 112px; }
#bpmSelect { min-width: 104px; }
#timeSelect { min-width: 74px; }

/* ── Form controls ──────────────────────────────────────────────────────── */
.select-wrap { position: relative; display: inline-flex; }
.select-wrap::after {
  content: "";
  position: absolute; right: 14px; top: 50%;
  width: 7px; height: 7px;
  border-right: 1.6px solid var(--text-2);
  border-bottom: 1.6px solid var(--text-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select {
  appearance: none; -webkit-appearance: none;
  height: 36px;
  padding: 0 38px 0 12px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.select-wrap select:hover { border-color: #3a4462; }
.select-wrap select option { background: #151a28; }
.select-wrap.wide select { min-width: 230px; }
.select-wrap.compact select { height: 32px; min-width: 76px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.small { width: 34px; height: 34px; border-radius: 8px; }
.icon-btn.small svg { width: 17px; height: 17px; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 18px;
  border-radius: 9px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  color: var(--text-2);
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.btn:hover { background: var(--panel-hover); color: var(--text); }
.btn svg { width: 18px; height: 18px; color: var(--icon); }
.btn.primary {
  background: linear-gradient(180deg, #6c9fff, var(--accent-3));
  border-color: #8bb2fa;
  color: #fff;
  box-shadow: 0 6px 22px rgba(58, 121, 237, 0.35);
}
.btn.primary svg { color: #fff; }
.btn.primary:hover { background: linear-gradient(180deg, #7dabff, #3a79ed); }

.stepper {
  display: inline-flex; align-items: center;
  height: 36px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.stepper button { width: 32px; height: 100%; color: var(--text-2); font-size: 18px; }
.stepper button:hover:not(:disabled) { background: var(--panel-hover); color: var(--text); }
.stepper button:disabled { opacity: .35; cursor: default; }
.stepper output { min-width: 46px; text-align: center; font-size: 15px; border-inline: 1px solid var(--line-2); line-height: 34px; }

.segmented { display: inline-flex; background: var(--panel-3); border: 1px solid var(--line-2); border-radius: 9px; padding: 2px; }
.seg { height: 30px; padding: 0 22px; border-radius: 7px; color: var(--text-2); font-size: 13.5px; }
.seg:hover { color: var(--text); }
.seg.active {
  background: linear-gradient(180deg, rgba(92, 146, 246, 0.55), rgba(40, 102, 217, 0.45));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(139, 178, 250, 0.6);
}
.segmented.small .seg { height: 28px; padding: 0 12px; font-size: 12.5px; }

.toggle-label, .inline-label { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.toggle { position: relative; width: 38px; height: 22px; border-radius: 11px; background: var(--line-2); transition: background .2s; }
.toggle span { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0,.4); }
.toggle.on { background: var(--accent); }
.toggle.on span { transform: translateX(16px); }

.v-divider { width: 1px; height: 26px; background: var(--line-2); }
.v-divider.tall { height: 40px; }

/* ── Sidebar / library ──────────────────────────────────────────────────── */
/* Full height of the main column: `contain: size` keeps the sidebar's own content from
   stretching the row, so it matches the main column and the mood list scrolls inside. */
.sidebar { padding: 18px 14px 14px; display: flex; flex-direction: column; min-height: 0; align-self: stretch; contain: size; }
.sidebar .panel-title { padding: 0 4px; margin-bottom: 12px; flex-shrink: 0; }
.search {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; /* only the mood list shrinks/scrolls when a mood opens */
  height: 34px; padding: 0 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  margin-bottom: 8px;
  transition: border-color .15s;
}
.search svg { width: 15px; height: 15px; }
.search:hover { border-color: var(--line-2); }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font-size: 13px; }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { filter: invert(.6); }

.mood-list, .search-results { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; min-height: 120px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.mood { border-bottom: 1px solid rgba(255, 255, 255, 0.035); }
.mood-head {
  display: flex; align-items: center; gap: 11px;
  width: 100%; height: 34px; padding: 0 6px 0 8px;
  color: var(--text-2);
  border-radius: 6px;
  text-align: left;
  transition: background .12s, color .12s;
}
.mood-head:hover { background: var(--panel-hover); color: var(--text); }
.mood-head .mood-icon { width: 17px; height: 17px; color: var(--icon); stroke-width: 1.7; }
.mood-head span { flex: 1; font-size: 13px; }
.mood-head .chev { width: 14px; height: 14px; color: var(--muted); transition: transform .15s; }
.mood.open .mood-head { color: var(--text); }
.mood.open .mood-head .chev { transform: rotate(180deg); }
.mood-body { padding: 4px 6px 12px; display: none; }
.mood.open .mood-body { display: block; animation: fadeIn .12s ease; }
.mood-sub { font-size: 10.5px; letter-spacing: .12em; color: var(--muted); margin: 6px 2px 6px; }
.chip-row + .mood-sub { margin-top: 14px; }
.prog-item {
  display: flex; align-items: stretch;
  margin-bottom: 4px;
  border-radius: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: border-color .15s;
}
.prog-item:hover { border-color: var(--line-2); }
.prog-item.playing { border-color: var(--accent); }
.prog-play { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; padding: 7px 9px; text-align: left; }
.prog-play:hover { background: var(--accent-soft); }
.prog-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--panel-3); color: var(--icon); }
.prog-icon svg { width: 11px; height: 11px; }
.prog-icon .i-stop, .prog-item.playing .prog-icon .i-play { display: none; }
.prog-item.playing .prog-icon .i-stop { display: block; }
.prog-item.playing .prog-icon { background: var(--accent); color: #fff; }
.prog-text { min-width: 0; }
.prog-text b { display: block; font-size: 12px; font-weight: 500; color: var(--text); }
.prog-text i { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-top: 2px; }
.pc { transition: color .15s; }
.pc.current { color: var(--accent-2); font-weight: 600; }
.prog-add { width: 30px; flex-shrink: 0; display: grid; place-items: center; border-left: 1px solid var(--line); color: var(--muted); }
.prog-add:hover { color: var(--text); background: var(--accent-soft); }
.prog-add svg { width: 15px; height: 15px; }
.chord-notes .omit { opacity: .35; text-decoration: line-through; }
.chord-notes .add { color: var(--accent-2); }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 5px 9px; border-radius: 6px;
  background: var(--panel-3); border: 1px solid var(--line-2);
  font-size: 12px; color: var(--text-2);
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { border-color: var(--accent); background: var(--accent-soft); color: #fff; }
.search-results { padding-top: 4px; }
.search-results .result-group { margin-bottom: 12px; }
.search-empty { color: var(--muted); font-size: 12.5px; padding: 8px 4px; }

.favorites { margin-top: 14px; flex-shrink: 0; }
.favorites h3 { display: flex; align-items: center; gap: 10px; margin: 0 4px 10px; font-size: 12px; font-weight: 600; letter-spacing: .08em; color: var(--text-2); }
.favorites h3 svg { width: 17px; height: 17px; color: var(--icon); }
#favoritesList { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); max-height: 190px; overflow-y: auto; }
.fav-item { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.fav-item:last-child { border-bottom: 0; }
.fav-item .fav-name { flex: 1; text-align: left; padding: 8px 12px; font-size: 13px; color: var(--text-2); }
.fav-item .fav-name:hover { color: var(--text); }
.fav-pos { margin-left: 8px; font-size: 11px; color: var(--muted); }
/* Library chords are draggable; clicking only auditions them. */
.chip, .fav-item .fav-name { cursor: grab; }
.chip:active, .fav-item .fav-name:active { cursor: grabbing; }
.chip.auditioned { animation: audition .5s ease-out; }
.fav-item .fav-name.auditioned { animation: flash .6s ease-out; }
@keyframes flash { from { background: rgba(92, 146, 246, .28); } to { background: transparent; } }
.fav-item .dots { padding: 4px 10px; color: var(--muted); }
.fav-item .dots:hover { color: var(--text); }
.fav-empty { padding: 10px 12px; font-size: 12px; color: var(--muted); }

/* ── Instrument panel ───────────────────────────────────────────────────── */
.instrument-panel { position: relative; padding: 14px 18px 12px; }
/* Drop affordance while a chord is being dragged: tinted dashed outline + a solid label pill. */
.instrument-panel::after,
.instrument-panel::before {
  position: absolute; z-index: 20;
  opacity: 0; pointer-events: none;
  transition: opacity .15s, background .15s;
}
.instrument-panel::after {
  content: "";
  inset: 0;
  border: 2px dashed var(--accent-2);
  border-radius: var(--radius);
  background: rgba(10, 13, 22, 0.55);
}
.instrument-panel::before {
  content: "Drop here to load this chord";
  z-index: 21;
  left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  padding: 10px 20px;
  border-radius: 999px;
  background: #151e30;
  border: 1px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  color: #fff; font-size: 15px; font-weight: 500; white-space: nowrap;
}
body.chord-dragging .instrument-panel::after,
body.chord-dragging .instrument-panel::before { opacity: .7; }
.instrument-panel.drop-target::after,
.instrument-panel.drop-target::before { opacity: 1; }
.instrument-panel.drop-target::after { background: rgba(44, 81, 150, 0.4); }
.instrument-panel.drop-target::before { background: var(--accent-3); }
.fb-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.tool-group { display: flex; align-items: center; gap: 8px; }
.tool-label { font-size: 10.5px; letter-spacing: .08em; color: var(--muted); }
.fb-toolbar .select-wrap select { height: 30px; font-size: 12.5px; padding: 0 28px 0 10px; }
.fb-toolbar .stepper { height: 30px; }
.fb-toolbar .stepper button { width: 26px; font-size: 16px; }
.fb-toolbar .stepper output { min-width: 34px; font-size: 13px; line-height: 28px; }
.fb-toolbar .v-divider { height: 20px; }
.fb-toolbar .dropdown-btn { height: 30px; min-width: 0; font-size: 12.5px; }

/* Tuning dropdown (custom, styled like the app's menus) */
.dropdown { position: relative; }
.dropdown-btn {
  display: flex; align-items: center; gap: 10px;
  height: 36px; min-width: 260px; padding: 0 12px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.dropdown-btn:hover { border-color: #3a4462; }
.dropdown-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dd-name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropdown-btn svg { width: 15px; height: 15px; color: var(--text-2); transition: transform .2s; }
.dropdown-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  width: 240px; max-height: 360px; overflow-y: auto;
  padding: 6px;
  background: #171c2b;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .6);
  animation: fadeIn .12s ease;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.dd-section { padding: 9px 10px 4px; font-size: 10.5px; letter-spacing: .12em; color: var(--muted); }
.dd-item { display: flex; align-items: center; border-radius: 7px; }
.dd-item:hover { background: var(--panel-hover); }
.dd-item.active { background: var(--accent-soft); }
.dd-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 7px 10px; text-align: left; }
.dd-item-name { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-item.active .dd-item-name { color: #fff; }
.dd-del { width: 26px; height: 26px; margin-right: 4px; border-radius: 6px; color: var(--muted); font-size: 16px; line-height: 1; }
.dd-del:hover { color: #fca5a5; background: rgba(239, 68, 68, .14); }
.dd-empty { padding: 4px 10px 8px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.dd-foot { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.dd-action { width: 100%; padding: 8px 10px; border-radius: 7px; text-align: left; font-size: 13px; color: var(--accent-2); }
.dd-action:hover:not(:disabled) { background: var(--accent-soft); color: #fff; }
.dd-action:disabled { color: var(--muted); opacity: .6; cursor: default; }
.dd-save { display: flex; gap: 6px; padding: 2px; }
.dd-save input { flex: 1; min-width: 0; height: 32px; padding: 0 10px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 7px; color: var(--text); font-size: 13px; outline: none; }
.dd-save input:focus { border-color: var(--accent); }
.btn.small { height: 32px; padding: 0 14px; font-size: 13px; }

/* String tuner popover */
.popover.tuner { width: 320px; }
.tuner-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tuner-head h3 { flex: 1; margin: 0; }
.tuner-all { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
.tuner-all .toggle { width: 32px; height: 18px; }
.tuner-all .toggle span { width: 12px; height: 12px; }
.tuner-all .toggle.on span { transform: translateX(14px); }
.tuner-close { width: 24px; height: 24px; border-radius: 6px; color: var(--muted); font-size: 19px; line-height: 1; }
.tuner-close:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.wheel-item:disabled { opacity: .22; cursor: default; }

/* Pitch wheel: a scrolling strip of semitones, the centre one framed as the current pitch. */
.wheel-wrap { position: relative; display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.wheel-wrap::after {
  content: "";
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 58px; transform: translateX(-50%);
  border: 1px solid var(--accent);
  border-radius: 9px;
  background: rgba(92, 146, 246, .16);
  box-shadow: inset 0 0 14px rgba(92, 146, 246, .25);
  pointer-events: none;
}
.wheel {
  flex: 1; display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-inline: calc(50% - 28px);
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 16%, #000 84%, transparent);
  outline: none;
}
.wheel::-webkit-scrollbar { display: none; }
.wheel:focus-visible + .wheel-arrow, .wheel:focus-visible { box-shadow: 0 0 0 2px var(--accent-2); border-radius: 9px; }
.wheel-item { flex: 0 0 56px; height: 48px; scroll-snap-align: center; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.wheel-note { font-size: 14px; line-height: 1.1; }
.wheel-oct { font-size: 10px; opacity: .7; }
.wheel-item.is-base { color: var(--accent-2); }
.wheel-item.current { color: #fff; }
.wheel-item.current .wheel-note { font-size: 17px; font-weight: 600; }
.wheel-arrow { width: 26px; height: 44px; flex-shrink: 0; border-radius: 7px; background: var(--panel-3); border: 1px solid var(--line-2); color: var(--text-2); font-size: 18px; line-height: 1; }
.wheel-arrow:hover:not(:disabled) { border-color: var(--accent); color: #fff; }
.wheel-arrow:disabled { opacity: .35; cursor: default; }
.tuner-delta { margin: 0 0 12px; min-height: 16px; text-align: center; font-size: 12px; color: var(--accent-2); }
.tuner-actions { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.tuner-actions .btn { flex: 1; justify-content: center; height: 32px; padding: 0 8px; font-size: 12.5px; }
.tuner-actions .btn:disabled { opacity: .45; cursor: default; }

.board-scroll { overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* Fretboard */
/* Fixed neck height (a 6-string guitar's); more strings sit closer together and --dot/--label shrink (set in render.js). */
.fretboard {
  --n: 6;
  --neck-h: 186px;
  --dot: 30px;
  --label: 28px;
  display: grid;
  grid-template-columns: 34px 28px minmax(0, 1fr);
  grid-template-rows: var(--neck-h) 30px;
  min-width: 900px;
  user-select: none;
}
.fb-labels, .fb-open, .fb-neck, .fb-numbers { position: relative; }
.string-label {
  position: absolute; left: calc((28px - var(--label)) / 2); top: var(--y);
  width: var(--label); height: var(--label); margin-top: calc(var(--label) / -2);
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--panel-3); border: 1px solid var(--line-2);
  font-size: calc(var(--label) * 0.45); color: var(--text-2);
}
.string-label:hover { border-color: var(--accent); color: var(--text); }
.string-label.muted { color: var(--muted); opacity: .6; }
.open-mark {
  position: absolute; left: 50%; top: var(--y);
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; line-height: 1; color: var(--muted);
}
.open-mark.open { border: 2px solid var(--accent-2); box-shadow: 0 0 8px var(--accent-glow); }
.open-mark.muted::before { content: "×"; font-size: 16px; }
.open-mark:hover { background: rgba(255, 255, 255,.06); }

.fb-neck {
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0,.45), rgba(0, 0, 0,0) 12%, rgba(0, 0, 0,0) 88%, rgba(0, 0, 0,.5)),
    repeating-linear-gradient(178.6deg, rgba(255, 255, 255,.03) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(181.2deg, rgba(0, 0, 0,.18) 0 2px, transparent 2px 13px),
    repeating-linear-gradient(179.4deg, rgba(120, 70, 40,.18) 0 3px, transparent 3px 21px),
    linear-gradient(90deg, #2e1b12, #3f261a 18%, #34201566 35%, #452a1c 55%, #362116 78%, #412719);
  background-color: #3a2317;
  box-shadow: 0 8px 26px rgba(0, 0, 0,.55), inset 0 0 0 1px rgba(0, 0, 0,.4);
  overflow: hidden;
}
.fb-nut {
  position: absolute; left: 0; top: 0; bottom: 0; width: 7px;
  background: linear-gradient(90deg, #cfc9bb, #f8f5ee 50%, #b3ad9f);
  box-shadow: 2px 0 4px rgba(0, 0, 0,.5);
  z-index: 3;
}
.fb-fret {
  position: absolute; top: 0; bottom: 0; left: var(--x);
  width: 3px; margin-left: -1.5px;
  background: linear-gradient(90deg, #5e6167, #eef0f3 45%, #a3a6ad 62%, #4d5055);
  box-shadow: 1px 0 3px rgba(0, 0, 0,.6);
  z-index: 1;
}
.fb-inlay {
  position: absolute; left: var(--x); top: var(--y);
  width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f1f3f7, #adb3bd 65%, #858b96);
  opacity: .72;
  z-index: 1;
}
.fb-string {
  position: absolute; left: 0; right: 0; top: var(--y);
  height: var(--g); margin-top: calc(var(--g) / -2);
  background: linear-gradient(180deg, #7c7f86, #f5f6f8 45%, #8d9097 70%, #54575d);
  box-shadow: 0 2px 3px rgba(0, 0, 0,.6);
  z-index: 2;
  pointer-events: none;
  transition: filter .2s;
}
.fb-string.wound {
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0,.28) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, #7c7f86, #eceef1 45%, #8d9097 70%, #54575d);
}
.fb-string.muted { filter: brightness(.55); }
.fb-string.ringing { animation: ring .6s ease-out; }
@keyframes ring { 0% { filter: brightness(1.6) drop-shadow(0 0 4px #b5cefd); } 100% { filter: none; } }

/* Capo: covers only its strings; the fret comes from the CAPO menu, the ends resize it. */
.fb-capo {
  position: absolute; left: var(--x); top: var(--y); height: var(--h);
  width: 16px; margin-left: -8px;
  border-radius: 5px;
  background: linear-gradient(90deg, #111216, #3b3d47 45%, #1a1b21);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 4px 0 10px rgba(0, 0, 0, .6);
  z-index: 8;
  touch-action: none;
  pointer-events: none; /* the bar is scenery: only its ends are grabbable */
}
.fb-capo-handle {
  position: absolute; left: 50%; width: 18px; height: 14px;
  transform: translateX(-50%);
  pointer-events: auto;
  border-radius: 4px;
  background: #4b4e5c;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .12);
  cursor: ns-resize;
  touch-action: none;
}
.fb-capo-handle.top { top: -7px; }
.fb-capo-handle.bottom { bottom: -7px; }
.fb-capo-handle:hover { background: var(--accent); }
.fb-shade { position: absolute; left: 0; top: var(--y); height: var(--h); width: var(--x); background: rgba(6, 7, 12, .55); z-index: 3; }
.capo-info { font-size: 11.5px; color: var(--text-2); white-space: nowrap; }

.fb-cell {
  position: absolute; left: var(--x); top: var(--y);
  width: var(--w); height: var(--h);
  z-index: 5;
}
.fb-cell::after {
  content: attr(data-note);
  position: absolute; left: 50%; top: 50%;
  --ghost: calc(var(--dot) - 4px);
  width: var(--ghost); height: var(--ghost); margin: calc(var(--ghost) / -2) 0 0 calc(var(--ghost) / -2);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: calc(var(--dot) * 0.35); color: #fff;
  background: rgba(92, 146, 246, .35);
  border: 1px dashed rgba(181, 206, 253, .7);
  opacity: 0;
  transition: opacity var(--hover);
}
.fb-cell:hover::after { opacity: 1; }
/* The cell behind the capo is the click/drop target; the note itself draws at the capo (.capo-note). */
.fb-cell.at-capo.drop-cell::after { opacity: 1; border: 2px solid #f3f7ff; box-shadow: 0 0 12px rgba(139, 178, 250, .9); }

.fb-dot, .fb-barre {
  position: absolute;
  display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: calc(var(--dot) * 0.45);
  background: radial-gradient(circle at 35% 28%, #94b9ff, var(--accent) 55%, var(--accent-3));
  border: 2px solid rgba(214, 228, 254, .55);
  box-shadow: 0 0 16px var(--accent-glow), 0 3px 8px rgba(0, 0, 0,.55);
  z-index: 6;
  pointer-events: none;
  animation: pop .22s cubic-bezier(.3,1.6,.5,1);
}
.fb-dot { left: var(--x); top: var(--y); width: var(--dot); height: var(--dot); margin: calc(var(--dot) / -2) 0 0 calc(var(--dot) / -2); border-radius: 50%; }
.fb-dot.root { box-shadow: 0 0 0 2px rgba(255, 255, 255,.18), 0 0 20px rgba(139, 178, 250,.75), 0 3px 8px rgba(0, 0, 0,.55); }
/* Capo'd open notes sit above the bar, so the note reads rather than the capo hiding it. */
.fb-dot.capo-note { z-index: 9; }
.fb-barre { left: var(--x); top: var(--y1); height: calc(var(--y2) - var(--y1) + var(--dot)); width: var(--dot); margin: calc(var(--dot) / -2) 0 0 calc(var(--dot) / -2); border-radius: calc(var(--dot) / 2); }
/* Real dots: no pop when a redraw didn't change the shape; pulse when previewing the same chord. */
.fb-dot.still, .fb-barre.still { animation: none; }
.fb-dot.pulse, .fb-barre.pulse { animation: notePulse .7s ease-out 2; }
@keyframes notePulse {
  from { box-shadow: 0 0 0 0 rgba(214, 228, 254, .85), 0 3px 8px rgba(0, 0, 0, .55); }
  to { box-shadow: 0 0 0 12px rgba(214, 228, 254, 0), 0 3px 8px rgba(0, 0, 0, .55); }
}

/* Ghost preview: an auditioned chord drawn lightly, over the panel's own chord. */
.fb-dot.ghost, .fb-barre.ghost {
  z-index: 7;
  background: rgba(139, 178, 250, 0.3);
  border: 1.5px dashed rgba(214, 228, 254, 0.9);
  box-shadow: 0 0 10px rgba(92, 146, 246, 0.3);
  color: #f3f7ff;
  font-weight: 500;
  animation: ghostIn .25s ease-out;
}
.fb-dot.ghost.overlap { background: none; box-shadow: none; transform: scale(1.18); animation: none; }

/* Dragging a note to a new spot. */
.fb-cell.has-note, .open-mark.open, .key-white.on, .key-black.on { cursor: grab; touch-action: none; }
.note-dragging, .note-dragging * { cursor: grabbing !important; }
/* Hover hints are off mid-drag; the drop preview below shows the landing spot instead. */
.note-dragging .fb-cell::after, .note-dragging .fb-cell:hover::after { opacity: 0; }
/* …except the capo drop target, whose highlight has to stay visible mid-drag. */
.note-dragging .fb-cell.at-capo.drop-cell::after { opacity: 1; }
.fb-dot.drop-preview {
  z-index: 8;
  animation: none;
  background: radial-gradient(circle at 35% 28%, #b6d0ff, #6da0ff 55%, #3a79ed);
  border: 2px solid #f3f7ff;
  box-shadow: 0 0 0 4px rgba(139, 178, 250, .25), 0 0 20px rgba(139, 178, 250, .85);
  opacity: .92;
}
.open-mark.drop-cell { border: 2px solid #f3f7ff; box-shadow: 0 0 12px rgba(139, 178, 250, .9); }
.fb-dot.lifted, .fb-barre.lifted, .open-mark.lifted { opacity: .3; }
.key-white.drop-preview, .key-black.drop-preview {
  background: radial-gradient(circle at 50% 80%, #b6d0ff, #6da0ff 55%, #3a79ed);
  color: #fff; font-weight: 600;
  box-shadow: 0 0 18px var(--accent-glow);
  opacity: .9;
}
.key-white.lifted, .key-black.lifted { opacity: .45; }
.open-ghost {
  position: absolute; left: 50%; top: var(--y);
  width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 1.5px dashed rgba(181, 206, 253, 0.85);
  pointer-events: none;
  animation: ghostIn .25s ease-out;
}
.open-ghost { z-index: 1; }
.fretboard.ghost-out .ghost, .fretboard.ghost-out .open-ghost { opacity: 0; transition: opacity var(--ghost-fade, .3s) ease-in; }
@keyframes ghostIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }

/* Scale overlay: one playing position, under the chord's own dots. */
.fb-scale-band {
  position: absolute; top: 0; bottom: 0; left: var(--x); width: var(--w);
  background: linear-gradient(180deg, rgba(94, 234, 212, .1), rgba(94, 234, 212, .05));
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, .22);
  z-index: 3;
  pointer-events: none;
}
.fb-scale {
  position: absolute; left: var(--x); top: var(--y);
  width: calc(var(--dot) * .36); height: calc(var(--dot) * .36);
  margin: calc(var(--dot) * -.18) 0 0 calc(var(--dot) * -.18);
  border-radius: 50%;
  background: rgba(94, 234, 212, .45);
  box-shadow: 0 0 6px rgba(94, 234, 212, .3);
  z-index: 4;
  pointer-events: none;
  animation: ghostIn .2s ease-out;
}
.fb-scale.root {
  width: calc(var(--dot) * .54); height: calc(var(--dot) * .54);
  margin: calc(var(--dot) * -.27) 0 0 calc(var(--dot) * -.27);
  background: rgba(94, 234, 212, .9);
  box-shadow: 0 0 10px rgba(94, 234, 212, .6);
}
/* Sits left of the open/mute marker so the two never overlap. */
.open-scale {
  position: absolute; left: 22%; top: var(--y);
  width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: rgba(94, 234, 212, .55);
  pointer-events: none;
}
.open-scale.root { width: 10px; height: 10px; margin: -5px 0 0 -5px; background: rgba(94, 234, 212, .9); }
.scale-chip {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 7px; padding: 3px 4px 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(94, 234, 212, .45);
  background: rgba(94, 234, 212, .12);
  color: #a7f3e4; font-size: 11.5px;
}
.scale-chip button { width: 17px; height: 17px; border-radius: 50%; color: inherit; font-size: 13px; line-height: 1; }
.scale-chip button:hover { background: rgba(94, 234, 212, .28); color: #fff; }
body.scale-dragging .instrument-panel::before { content: "Drop to show this scale"; }

.fb-num {
  position: absolute; left: var(--x); top: 8px;
  transform: translateX(-50%);
  font-size: 12px; color: var(--muted);
}
.fb-num.marker { color: var(--text-2); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Piano */
.piano { position: relative; display: flex; height: 216px; /* = fretboard neck + fret numbers, so switching instruments doesn't jump */ min-width: 900px; user-select: none; border-radius: 6px; overflow: hidden; box-shadow: 0 8px 26px rgba(0, 0, 0,.55); border-top: 6px solid #1a1c25; }
.key-white {
  position: relative; flex: 1;
  background: linear-gradient(180deg, #e3e5ea, #f7f8fa 12%, #edeff2 88%, #d6d9de);
  border-right: 1px solid #a3a8b1;
  border-radius: 0 0 5px 5px;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 10px;
  font-size: 11px; color: #8a8f99;
}
.key-white:hover { background: linear-gradient(180deg, #dde1e9, #edf2fb); }
.key-black {
  position: absolute; top: 0; left: var(--x);
  width: var(--w); height: 62%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #252733, #0d0e13 85%, #2a2c38);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 6px rgba(0, 0, 0,.5), inset 0 -3px 0 rgba(255, 255, 255,.08);
  z-index: 2;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 8px;
  font-size: 10px; color: transparent;
}
.key-black:hover { background: linear-gradient(180deg, #34364a, #1a1b25); }
.key-white.on, .key-black.on {
  background: radial-gradient(circle at 50% 80%, #94b9ff, var(--accent) 50%, var(--accent-3));
  color: #fff; font-weight: 600;
  box-shadow: 0 0 20px var(--accent-glow);
}
.key-white.on { border-right-color: var(--accent-3); }
.key-white.ghost:not(.on) { background: linear-gradient(180deg, #e6efff, #cbddff); color: #2866d9; font-weight: 500; }
.key-black.ghost:not(.on) { background: linear-gradient(180deg, #4c6593, #2e4163); color: #e3edff; }
/* A preview note that is also in the panel's chord: dashed ring on top of the lit key. */
.key-white.on.ghost, .key-black.on.ghost { outline: 2px dashed #f3f7ff; outline-offset: -5px; }
.key-white.scale { background: linear-gradient(180deg, #dcf6f1, #b4ebe0 88%, #9fe0d4); }
.key-black.scale { background: linear-gradient(180deg, #2c6b60, #123a33 85%, #2f7568); }
/* Scale roots read at a glance: a deeper tint, not just a ring. */
.key-white.scale.root { background: linear-gradient(180deg, #9fe4d6, #6fd3c0 88%, #56c3ae); box-shadow: inset 0 0 0 2px var(--scale); }
.key-black.scale.root { background: linear-gradient(180deg, #3f9c8b, #1c5a4e 85%, #3f9c8b); box-shadow: inset 0 0 0 2px var(--scale), 0 4px 6px rgba(0, 0, 0, .5); }
.key-white.on.pulse, .key-black.on.pulse { animation: keyPulse .7s ease-out 2; }
@keyframes keyPulse { from { filter: brightness(1.35); } to { filter: none; } }
.piano.ghost-out .ghost { transition: background var(--ghost-fade, .3s) ease-in, color var(--ghost-fade, .3s) ease-in, outline-color var(--ghost-fade, .3s) ease-in; }
.piano.ghost-out .key-white.ghost:not(.on) { background: linear-gradient(180deg, #e3e5ea, #f7f8fa 12%, #edeff2 88%, #d6d9de); color: transparent; }
.piano.ghost-out .key-black.ghost:not(.on) { background: linear-gradient(180deg, #252733, #0d0e13 85%, #2a2c38); color: transparent; }
.piano.ghost-out .on.ghost { outline-color: transparent; }
.key-white.c-key::before { content: attr(data-oct); position: absolute; top: 8px; font-size: 10px; color: #a3a8b1; }

/* Chord bar */
.chord-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 10px; }
.voicing-info { font-size: 12px; color: var(--muted); line-height: 1.5; }
.voicing-info b { color: var(--text-2); font-weight: 500; }
.chord-nav { display: flex; align-items: center; gap: 16px; }
.round-btn { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-3); border: 1px solid var(--line); color: var(--text-2); }
.round-btn svg { width: 16px; height: 16px; }
.round-btn:hover { background: var(--panel-hover); color: var(--text); }
.chord-display { min-width: 140px; text-align: center; }
.chord-name-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.chord-name { font-size: 22px; font-weight: 500; letter-spacing: .01em; color: var(--text); }
.chord-name:hover { color: #ccdeff; }
.chord-name.empty { color: var(--muted); font-size: 17px; }
.fav-btn { color: var(--accent-2); display: grid; place-items: center; }
.fav-btn svg { width: 18px; height: 18px; }
.fav-btn[aria-pressed="true"] svg { fill: var(--accent); stroke: var(--accent-2); }
.fav-btn:hover { transform: scale(1.1); }
.chord-notes { display: flex; justify-content: center; gap: 16px; font-size: 13px; color: var(--muted); margin-top: 4px; letter-spacing: .06em; min-height: 18px; }
/* Scoped to the bar: `.btn` is shared with the transport and the MIDI button, which keep their size. */
.chord-actions { display: flex; justify-content: flex-end; gap: 10px; }
.chord-actions .btn { height: 32px; padding: 0 14px; gap: 8px; font-size: 13px; }
.chord-actions .btn svg { width: 15px; height: 15px; }
.chord-display { min-width: 124px; }
.chord-notes { font-size: 12px; gap: 14px; }

/* ── Suggestions ────────────────────────────────────────────────────────── */
.suggest-panel { padding: 14px 18px 16px; }
.suggest-row { display: grid; grid-template-columns: repeat(var(--cards, 7), minmax(112px, 1fr)); gap: 12px; overflow-x: auto; padding: 2px; }
.s-card { cursor: grab; }
.s-card:active { cursor: grabbing; }
.s-card.auditioned { animation: audition .5s ease-out; }
@keyframes audition { from { box-shadow: 0 0 0 0 rgba(92, 146, 246, .65); } to { box-shadow: 0 0 0 10px rgba(92, 146, 246, 0); } }
.s-card {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 64px; padding: 8px 12px 8px 14px;
  border-radius: 10px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  text-align: left;
  transition: border-color .15s, background .15s, transform .15s;
}
.s-card:hover { border-color: #445370; background: var(--panel-hover); transform: translateY(-1px); }
.s-card.active { border-color: var(--accent); background: linear-gradient(180deg, rgba(92, 146, 246,.16), rgba(92, 146, 246,.06)); box-shadow: 0 0 0 1px rgba(92, 146, 246,.4), 0 0 18px rgba(92, 146, 246,.2); }
.s-card .s-text { min-width: 0; }
.s-card b { display: block; font-size: 14.5px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-card i { display: block; font-style: normal; font-size: 12px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Card = [name + label | mini diagram]; the reason it fits shows in the hover chip. */
.s-card { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; align-content: center; }
/* Grip dots on hover: this card can be dragged. */
.s-grip {
  position: absolute; left: 50%; bottom: 4px;
  width: 17px; height: 7px;
  transform: translateX(-50%);
  background-image: radial-gradient(currentColor 1.1px, transparent 1.3px);
  background-size: 6px 4px;
  color: var(--muted);
  opacity: 0;
  transition: opacity var(--hover) ease;
  pointer-events: none;
}
.s-card:hover .s-grip, .s-card:focus-visible .s-grip { opacity: .95; }
/* Scale cards: not draggable, so no grip; names may wrap rather than truncate. */
.scale-card { cursor: pointer; grid-template-columns: minmax(0, 1fr); }
.scale-card .s-text b { white-space: normal; font-size: 13.5px; line-height: 1.2; }
.scale-card .s-text i { letter-spacing: .06em; font-size: 11.5px; }
.suggest-empty { grid-column: 1 / -1; padding: 20px 4px; font-size: 13px; color: var(--muted); }
/* The two chords a transition bridges: names only, not interactive. */
/* The pair being bridged, shown in the panel title; pickers when there's more than one choice. */
.bridge-host { display: inline-flex; align-items: center; gap: 7px; margin-left: 10px; vertical-align: middle; font-weight: 400; }
.bridge-static { font-size: 13px; color: var(--text-2); }
.bridge-host select {
  appearance: none; -webkit-appearance: none;
  height: 26px; padding: 0 24px 0 9px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: var(--panel-3) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a91a6' stroke-width='2.2' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 6px center / 11px;
  color: var(--text);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.bridge-host select:hover { border-color: var(--accent); }
.bridge-host select:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.bridge-host option { background: #151a28; }
.bridge-arrow { color: var(--muted); }


.info-pop { width: 330px; }

/* How chords are played: Finder-style columns that open to the right as you drill in.
   Outranks the shared .popover width/padding, which is defined later in this file. */
.popover.play-pop {
  width: auto; /* sized by its columns */
  max-width: calc(100vw - 32px);
  padding: 0; /* the header and columns carry their own */
  display: flex;
  flex-direction: column;
  overflow: hidden; /* keeps the header's fill inside the popup's rounded corners */
}
/* A distinct band across the top, taller than a default row. */
.play-head {
  position: relative; /* the close button sits out of the flow, pinned right */
  display: flex; align-items: center; justify-content: flex-start; gap: 12px;
  min-height: 50px;
  padding: 12px 44px 12px 16px;
  background: var(--panel-3);
  border-bottom: 1px solid var(--line-2);
  cursor: grab;
  user-select: none;
  touch-action: none; /* the header is a drag handle, not a scroll surface */
}
.play-pop.dragging .play-head { cursor: grabbing; }
.play-close { cursor: pointer; }
/* Outranks the shared `.popover h3`, which is defined later and adds a bottom margin. */
.play-pop .play-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text); letter-spacing: .01em; }
.play-chord .dropdown-btn { height: 28px; min-width: 104px; font-size: 12.5px; }
.play-close { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 7px; color: var(--muted); font-size: 19px; line-height: 1; }
.play-close:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
.play-cols { display: flex; align-items: stretch; overflow-x: auto; padding: 6px; }
.play-row { display: flex; align-items: center; border-radius: 8px; flex-shrink: 0; /* the column is a fixed-height flex box: rows must not be squashed to fit */ }
.play-row:hover { background: var(--panel-hover); }
.play-opt { flex: 1; min-width: 0; }
/* The circle is always drawn, so the preview reads as a control rather than appearing on hover. */
.play-prev {
  display: grid; place-items: center; /* without this the icon sits on the text baseline */
  width: 28px; height: 28px; flex-shrink: 0; margin-right: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line-2);
  color: var(--text-2);
  transition: color var(--hover), background var(--hover), border-color var(--hover);
}
.play-prev:hover { color: var(--accent-2); background: rgba(255, 255, 255, .11); border-color: var(--accent-2); }
.play-prev.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.play-row.active .play-prev { color: #fff; background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .28); }
.play-prev svg { width: 15px; height: 15px; }
/* position: relative makes each column the offsetParent, so scrolling a row into view
   measures against its own column rather than the whole popup. */
.play-col {
  position: relative;
  width: 216px; min-width: 216px;
  /* A fixed height, not a max: the popup must not resize as you move between branches,
     so a longer list scrolls inside its column instead. Deliberately not a whole number of
     rows — a clipped row is what tells you there is more below. */
  height: min(286px, 56vh);
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.play-col + .play-col { border-left: 1px solid var(--line); }
.play-arrow { color: var(--muted); font-size: 15px; line-height: 1; flex-shrink: 0; }
/* The branch you opened, and the branch that holds the current style. */
.play-row.open { background: var(--panel-hover); }
.play-row.open .play-opt { color: var(--text); }
.play-row.on-path .play-opt-label { color: var(--text); }
@media (max-width: 760px) {
  .play-col { width: 180px; min-width: 180px; }
}
/* State lives on the row so the highlight wraps the preview button as well as the label. */
.play-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 8px; text-align: left; color: var(--text-2); }
.play-row.active { background: var(--accent-soft); }
.play-row.active .play-opt { color: #fff; }
.play-opt-label { font-size: 13px; }
.play-opt-note { display: block; margin-top: 1px; font-size: 11px; color: var(--muted); }
.play-row.active .play-opt-note { color: var(--text-2); }
.play-glyph { font-size: 11px; letter-spacing: .08em; color: var(--accent-2); white-space: nowrap; flex-shrink: 0; }
.play-row.active .play-glyph { color: #fff; }
/* What the suggestions are based on right now (the Transition pickers live here too). */
.info-context { margin: 0 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); }
.info-list { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.7; color: var(--text-2); }
.info-list b { color: var(--text); font-weight: 500; }
.info-hint { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
/* Divides the library's moods from its genres. */
.lib-head {
  padding: 10px 6px 5px;
  font-size: 10px;
  letter-spacing: .14em;
  color: var(--muted);
  font-weight: 600;
}
.lib-head:first-child { padding-top: 2px; }

.mini { width: 34px; height: 36px; flex-shrink: 0; }
.mini .m-line { stroke: #3a4260; stroke-width: 1; }
.mini .m-nut { stroke: #6b7394; stroke-width: 2; }
.mini .m-dot { fill: var(--accent-2); stroke: none; }
.mini .m-open { fill: none; stroke: var(--accent-2); stroke-width: 1; }
.mini .m-mute { stroke: #5a6282; stroke-width: 1; }
/* Without an explicit width these inherit the global svg rule (1.8, in currentColor),
   which outlines the keys in near-white. */
.mini .m-white { fill: #2b3350; stroke: #1a2031; stroke-width: .5; }
.mini .m-black { fill: #0d1019; stroke-width: .5; }
.mini .m-on { fill: var(--accent-2); stroke-width: .5; }

/* ── Progression ────────────────────────────────────────────────────────── */
.progression-panel { padding: 14px 18px 16px; }
.prog-scroll { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.prog-track { display: flex; gap: 4px; min-width: 620px; }
.prog-slots { position: relative; display: flex; gap: 4px; flex: var(--count) 1 0; }
.prog-col { flex: 1 1 0; min-width: 104px; display: flex; flex-direction: column; gap: 8px; }
.prog-col.add-col { flex: 1 1 0; }
/* Each slot is a single-column chord card: name, roman numeral, mini diagram. */
.slot {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 132px;
  padding: 24px 10px 12px;
  border-radius: 10px;
  background: var(--panel-3);
  border: 1px solid var(--line-2);
  text-align: center;
  width: 100%;
  overflow: hidden;
  transition: border-color .15s, background .15s;
}
.slot:hover { border-color: #445370; }
.slot.selected { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(92, 146, 246,.5), 0 0 18px rgba(92, 146, 246,.2); }
.slot.playing { background: linear-gradient(180deg, rgba(92, 146, 246,.28), rgba(92, 146, 246,.1)); }
.slot.drop-target { border-color: var(--accent-2); border-style: dashed; background: var(--accent-soft); }
.slot.dragging { opacity: .4; }
.slot-num { position: absolute; top: 8px; left: 12px; font-size: 13px; color: var(--text-2); }
.slot-name { max-width: 100%; font-size: 16px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-name.empty { color: var(--muted); font-size: 13px; font-weight: 400; }
.slot-roman { font-size: 12px; color: var(--muted); }
.slot-hint { font-size: 11px; color: var(--muted); opacity: .8; }
/* Offered on an empty slot that sits between two chords. */
.slot-action {
  margin-top: 8px; padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: #d6e4fe;
  font-size: 11.5px; white-space: nowrap;
  transition: background .15s, color .15s;
}
.slot-action:hover { background: rgba(92, 146, 246, .32); color: #fff; }
.slot .mini { order: -1; width: 44px; height: 50px; margin-bottom: 6px; } /* diagram on top */
.slot.is-empty { border-style: dashed; background: transparent; }
.slot-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; pointer-events: none; }
.slot-progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #3a79ed, #b5cefd); box-shadow: 0 0 8px rgba(139, 178, 250, .7); }
.slot-menu { position: absolute; top: 5px; right: 4px; width: 22px; height: 24px; display: grid; place-items: center; color: var(--accent-2); border-radius: 5px; }
.slot-menu:hover { background: rgba(255, 255, 255,.07); }
.slot-menu svg { width: 16px; height: 16px; }
.slot.add { display: grid; place-items: center; border-style: dashed; color: var(--muted); background: transparent; }
.slot.add:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.slot.add svg { width: 20px; height: 20px; }


/* ── Transport ──────────────────────────────────────────────────────────── */
.transport { display: flex; align-items: center; gap: 22px; padding: 12px 18px; flex-wrap: wrap; }
.play-btn {
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, #262d44, #151a28);
  border: 1px solid var(--line-2);
  color: #e3e6ef;
  box-shadow: 0 6px 18px rgba(0, 0, 0,.45);
  transition: transform .12s, box-shadow .2s;
}
.play-btn:hover { transform: scale(1.04); }
.play-btn svg { width: 26px; height: 26px; }
.play-btn .i-stop { display: none; }
.play-btn.playing { box-shadow: 0 0 0 1px var(--accent), 0 0 24px var(--accent-glow); color: #fff; }
.play-btn.playing .i-play { display: none; }
.play-btn.playing .i-stop { display: block; }
.transport-loop { margin-right: 2px; }
/* Sized to the transport's other buttons, not the larger play circle. */
.loop-btn { width: 44px; height: 44px; border-radius: 12px; }
.loop-btn svg { width: 20px; height: 20px; }
.loop-btn.on { background: var(--accent-soft); border-color: var(--accent); color: #fff; }
.dropdown-btn.compact { height: 32px; min-width: 0; padding: 0 10px; gap: 8px; font-size: 13px; white-space: nowrap; }
.dropdown-btn.compact .dd-name { font-weight: 400; color: var(--text); }
.volume { position: relative; display: flex; align-items: center; gap: 14px; color: var(--icon); }
.volume input {
  --val: 70%;
  -webkit-appearance: none; appearance: none;
  width: 160px; height: 5px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--val), #2a3149 var(--val));
  cursor: pointer;
}
.volume input::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #a3c3ff; border: 3px solid #e3edff; box-shadow: 0 0 10px var(--accent-glow); }
.volume input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #a3c3ff; border: 3px solid #e3edff; }
/* A bubble that rides above the thumb while the level is moving. Out of the flow, so it can
   never shift the transport; `left` is set from the thumb position in app.js. */
.volume-db {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 0;
  transform: translateX(-50%);
  padding: 3px 8px;
  border-radius: 6px;
  background: #1d2437;
  border: 1px solid var(--line-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
  z-index: 40;
  visibility: hidden;
  opacity: 0;
  transition: opacity var(--hover);
}
.volume-db.on { visibility: visible; opacity: 1; }
.transport-right { margin-left: auto; display: flex; gap: 22px; }
.transport .btn { height: 44px; padding: 0 26px; }
.drag-midi { cursor: grab; }
.drag-midi:active { cursor: grabbing; }

/* ── Popover / menu / toast ─────────────────────────────────────────────── */
.popover {
  position: fixed; z-index: 50;
  width: 330px; padding: 16px;
  background: #151a28;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0,.6);
  animation: fadeIn .1s ease;
}
.popover h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-size: 13px; color: var(--text-2); }
.setting-hint { margin: 12px 0 0; font-size: 11.5px; color: var(--muted); line-height: 1.8; }
kbd { display: inline-block; padding: 0 5px; border: 1px solid var(--line-2); border-radius: 4px; font-family: inherit; font-size: 11px; background: var(--panel-3); color: var(--text-2); }

.menu {
  position: fixed; z-index: 60;
  min-width: 180px; padding: 5px;
  background: #171c2b;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0,.6);
  animation: fadeIn .12s ease;
}
.menu button { display: block; width: 100%; text-align: left; padding: 8px 12px; border-radius: 6px; font-size: 13px; color: var(--text-2); }
.menu button:hover { background: var(--accent-soft); color: var(--text); }
.menu button.danger:hover { background: rgba(239, 68, 68, .14); color: #fca5a5; }
.menu button.has-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-arrow { color: var(--muted); font-size: 15px; line-height: 1; }
.menu-back { color: var(--muted) !important; font-size: 12px !important; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* Hover chip: styled replacement for native title tooltips. */
.tip {
  position: fixed; z-index: 80;
  max-width: 260px; padding: 7px 11px;
  border-radius: 8px;
  background: #1d2336;
  border: 1px solid var(--line-2);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .55);
  color: var(--text);
  font-size: 12px; line-height: 1.45;
  pointer-events: none;
  opacity: 0; transform: translateY(-3px);
  transition: opacity var(--hover) ease, transform var(--hover) ease;
}
.tip.show { opacity: 1; transform: none; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 70;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  border-radius: 10px;
  background: #1d2336;
  border: 1px solid var(--line-2);
  box-shadow: 0 12px 30px rgba(0, 0, 0,.5);
  font-size: 13px; color: var(--text);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* ── Hover feedback ─────────────────────────────────────────────────────────
   One quick timing everywhere, plus hover states for controls that lacked one. */
.btn, .icon-btn, .seg, .chip, .round-btn, .inst-tab, .mood-head, .prog-item, .prog-play, .prog-add,
.s-card, .slot, .slot-menu, .slot-action, .fav-item .fav-name, .fav-item .dots, .dd-item, .dd-del, .dd-action,
.wheel-item, .wheel-arrow, .tuner-close, .tuner-notes button, .string-label, .open-mark,
.key-white, .key-black, .dropdown-btn, .search, .select-wrap select, .stepper button, .play-btn, .toggle, .toggle span {
  transition: background-color var(--hover) ease, background-image var(--hover) ease, border-color var(--hover) ease,
    color var(--hover) ease, box-shadow var(--hover) ease, transform var(--hover) ease, opacity var(--hover) ease;
}
.seg:hover:not(.active), .inst-tab:hover:not(.active) { background: rgba(255, 255, 255, .05); }
.chip:hover { background: var(--panel-hover); }
.round-btn:hover { transform: scale(1.06); border-color: var(--line-2); }
.fav-item .fav-name:hover { background: rgba(255, 255, 255, .04); }
.string-label:hover { background: var(--panel-hover); }
.slot:hover:not(.selected):not(.playing) { background: var(--panel-hover); }
.wheel-item:hover:not(:disabled):not(.current) { background: rgba(255, 255, 255, .06); color: var(--text-2); }
.prog-item:hover .prog-icon { color: var(--text); }
.play-btn:hover { transform: scale(1.05); }
.volume input:hover::-webkit-slider-thumb { background: #b6d0ff; }
.s-card:active, .chip:active, .btn:active, .slot:active { transform: translateY(1px); }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .inst-tab { width: 104px; gap: 7px; }
  .brand-text h1 { font-size: 17px; }
  .brand-text p { display: none; }
}
@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { order: 3; contain: none; }
  .sidebar .mood-list { max-height: none; }
  .mood-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); column-gap: 12px; }
  .topbar { grid-template-columns: 1fr auto; }
  /* justify-self, not just justify-content: as a stretched grid item the group would draw a
     full-width empty pill now that the chrome lives on the container. */
  .instrument-tabs { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .suggest-row { grid-template-columns: repeat(var(--cards, 7), 124px); }
}
@media (max-width: 720px) {
  .app { padding: 14px 16px; }
  .topbar { grid-template-columns: 1fr; }
  .top-controls { justify-content: flex-start; flex-wrap: wrap; }
  /* Full width here is wanted, but keep it one group: no gaps between the tabs. */
  .instrument-tabs { grid-row: auto; justify-self: stretch; }
  .inst-tab { width: auto; flex: 1; padding: 0 10px; }
  .fb-toolbar { gap: 12px 18px; }
  .fb-toolbar .v-divider { display: none; }
  #tuningGroup { flex: 1 1 100%; }
  #tuningGroup .dropdown { flex: 1; min-width: 0; }
  #tuningGroup .dropdown-btn { min-width: 0; width: 100%; }
  .dropdown-menu { width: min(240px, calc(100vw - 32px)); }
  .chord-bar { grid-template-columns: 1fr; justify-items: center; }
  .voicing-info { text-align: center; order: 3; }
  .chord-actions { justify-content: center; }
  .transport-right { margin-left: 0; width: 100%; flex-wrap: wrap; gap: 10px; }
  .transport-right .btn { flex: 1; justify-content: center; }
  .volume input { width: 110px; }
}
