/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #0b0b0b;
  --surface-1: #141414;
  --surface-2: #1c1c1c;
  --surface-3: #242424;
  --surface-4: #2e2e2e;

  --border:    #282828;
  --border-hi: #3c3c3c;

  --text-hi:   #f0f0f0;
  --text:      #9a9a9a;
  --text-lo:   #4a4a4a;

  --accent:    #e07840;
  --accent-hi: #f08848;
  --accent-lo: rgba(224,120,64,.14);

  --hit:       #4ab86a;
  --miss:      #cc4444;
  --warm:      #c49018;

  --shadow-lg: 0 12px 48px rgba(0,0,0,.72);

  --r-sm: 4px;
  --r:    6px;
  --r-lg: 10px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; overflow: hidden; }

/* ── Shared atoms ──────────────────────────────────────────────────────────── */
.cap {
  display: block;
  font-size: 10px; font-weight: 600;
  color: var(--text-lo);
  letter-spacing: .09em; text-transform: uppercase;
  margin-bottom: 5px; user-select: none;
}
.cap-hint { font-weight: 400; letter-spacing: .04em; text-transform: none; }

.text-input {
  width: 100%; background: var(--surface-2); color: var(--text-hi);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  outline: none; font-family: var(--font); font-size: 14px; padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.text-input::placeholder { color: var(--text-lo); }
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-lo); }

select {
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  outline: none; font-family: var(--font); font-size: 13px;
  padding: 6px 26px 6px 9px; cursor: pointer; min-width: 88px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234a4a4a'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  transition: border-color .15s, color .15s;
}
select:focus { border-color: var(--accent); color: var(--text-hi); }
select:hover { border-color: var(--border-hi); }

/* Buttons */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border: none; border-radius: var(--r);
  font-family: var(--font); font-size: 13px; font-weight: 700;
  padding: 9px 22px; cursor: pointer; letter-spacing: .04em; white-space: nowrap;
  box-shadow: 0 2px 10px rgba(224,120,64,.3);
  transition: background .15s, box-shadow .15s;
}
.btn-primary:hover { background: var(--accent-hi); box-shadow: 0 4px 18px rgba(224,120,64,.42); }
.btn-primary:active { opacity: .85; }
.btn-primary:disabled { opacity: .4; cursor: default; box-shadow: none; }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-lo); border: 1px solid var(--border);
  border-radius: var(--r); font-family: var(--font); font-size: 13px;
  padding: 9px 16px; cursor: pointer; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hi); }

.btn-ghost-sm {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--text-lo); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-family: var(--font); font-size: 11px;
  font-weight: 600; padding: 4px 10px; cursor: pointer; letter-spacing: .04em;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.btn-ghost-sm:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-lo); }

.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 100%;
  background: var(--surface-3); color: var(--text-lo);
  border: 1px solid var(--border); border-left: none;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.icon-btn svg { width: 13px; height: 13px; }
.icon-btn:hover { color: var(--accent); background: var(--accent-lo); border-color: var(--accent); }

.ctrl-inline { display: flex; align-items: stretch; }
.ctrl-inline select { border-radius: var(--r-sm) 0 0 var(--r-sm); }

.form-error   { font-size: 12px; color: var(--miss); min-height: 1.4em; }
.form-success { font-size: 12px; color: var(--hit);  min-height: 1.4em; }
.form-group   { display: flex; flex-direction: column; gap: 7px; }
.form-actions { display: flex; gap: 8px; align-items: center; }

/* ── Interval toggle grid ────────────────────────────────────────────────────── */
.interval-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px;
}
.interval-btn {
  background: var(--surface-2); color: var(--text-lo);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 9px 4px 8px; cursor: pointer; text-align: center;
  user-select: none; line-height: 1;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}
.interval-btn:hover:not(.root):not(:disabled) {
  background: var(--surface-3); border-color: var(--border-hi); color: var(--text);
}
.interval-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 0 12px rgba(224,120,64,.26);
}
.interval-btn.root {
  background: var(--warm); border-color: var(--warm); color: #111;
  cursor: default; box-shadow: 0 0 8px rgba(196,144,24,.2);
}
.iv-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.iv-num   { display: block; font-size: 9px; opacity: .45; margin-top: 3px; }

/* ── App Header ─────────────────────────────────────────────────────────────── */
#app-header {
  display: flex; align-items: center; height: 44px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  padding: 0 16px; gap: 16px; flex-shrink: 0;
}
#app-brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
#brand-icon { width: 18px; height: 18px; color: var(--accent); }
#app-name { font-size: 13px; font-weight: 700; letter-spacing: .05em; color: var(--text-hi); white-space: nowrap; }

#app-nav {
  display: flex; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 3px; gap: 2px;
}
.nav-tab {
  display: flex; align-items: center; gap: 6px;
  background: transparent; color: var(--text-lo); border: none;
  border-radius: var(--r-sm); font-family: var(--font); font-size: 12px;
  font-weight: 600; padding: 5px 12px; cursor: pointer; letter-spacing: .04em;
  transition: color .15s, background .15s; white-space: nowrap;
}
.nav-tab svg { width: 13px; height: 13px; flex-shrink: 0; }
.nav-tab:hover { color: var(--text); }
.nav-tab.active { background: var(--surface-4); color: var(--text-hi); box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* ── Views ──────────────────────────────────────────────────────────────────── */
#views-container {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.app-view {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  pointer-events: none;
  overflow-y: auto;
}
.app-view.active {
  visibility: visible;
  pointer-events: auto;
}

/* ── Practice control bar ───────────────────────────────────────────────────── */
#ctrl-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  background: var(--surface-1); padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.ctrl-group { display: flex; flex-direction: column; }
.ctrl-group .cap { margin-bottom: 4px; }
.ctrl-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 6px; }

#bpm {
  width: 68px; background: var(--surface-3); color: var(--text-hi);
  border: 1px solid var(--border); border-radius: var(--r-sm); outline: none;
  font-family: var(--font); font-size: 22px; font-weight: 700; padding: 4px 8px;
  -moz-appearance: textfield; transition: border-color .15s;
}
#bpm::-webkit-outer-spin-button, #bpm::-webkit-inner-spin-button { -webkit-appearance: none; }
#bpm:focus { border-color: var(--accent); }

#toggle {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
  background: #163624; color: var(--text-hi);
  border: 1px solid #224d34; border-radius: var(--r); outline: none;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  padding: 0 20px; cursor: pointer; height: 36px; min-width: 96px;
  letter-spacing: .04em; white-space: nowrap; flex-shrink: 0;
  transition: background .15s, border-color .15s;
  box-shadow: 0 1px 6px rgba(0,0,0,.4);
}
#toggle .btn-icon-start { width: 9px; height: 11px; }
#toggle .btn-icon-stop  { width: 9px; height: 9px; display: none; }
#toggle:hover { background: #1d4a2e; }
#toggle:active { opacity: .85; }
#toggle.stop { background: #3d1212; border-color: #5a1e1e; }
#toggle.stop:hover { background: #4d1818; }
#toggle.stop .btn-icon-start { display: none; }
#toggle.stop .btn-icon-stop  { display: block; }

/* ── Beat track ─────────────────────────────────────────────────────────────── */
#beat-track {
  display: block; width: 100%; height: 72px;
  background: #0d0d0d; border-bottom: 1px solid var(--border);
}

/* ── Fretboard (practice) ───────────────────────────────────────────────────── */
#fretboard {
  display: block; width: 100%; height: 400px;
  background: #0c0905; border-bottom: 1px solid var(--border);
}

/* ── Bottom panels ──────────────────────────────────────────────────────────── */
#bottom { display: flex; align-items: stretch; flex-wrap: wrap; background: var(--bg); }
.panel { padding: 14px 20px; border-right: 1px solid var(--border); }
.panel:last-child { border-right: none; }

#sequence-panel { min-width: 120px; flex-shrink: 0; }
#seq-boxes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.seq-box {
  background: var(--surface-3); color: var(--text-lo);
  font-size: 13px; font-weight: 700; min-width: 34px; text-align: center;
  padding: 5px 4px; border-radius: var(--r-sm); border: 1px solid var(--border);
  transition: background .1s, color .1s, border-color .1s;
}

#note-panel {
  flex: 1; min-width: 160px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding-top: 10px; padding-bottom: 14px;
}
#note-name {
  font-size: 68px; font-weight: 800; color: var(--text-lo);
  line-height: 1; letter-spacing: -0.02em; transition: color .12s;
}
#note-info {
  font-size: 12px; color: var(--text-lo); margin-top: 6px; min-height: 1.5em;
  font-variant-numeric: tabular-nums; letter-spacing: .03em; transition: color .12s;
}
#note-status {
  font-size: 11px; font-weight: 600; color: var(--text-lo); margin-top: 3px;
  min-height: 1.4em; letter-spacing: .06em; text-transform: uppercase; transition: color .12s;
}

#accuracy-panel { min-width: 200px; flex-shrink: 0; }
.stat-row { display: flex; align-items: center; gap: 10px; margin-top: 9px; }
.stat-lbl {
  font-size: 10px; font-weight: 600; color: var(--text-lo);
  width: 52px; flex-shrink: 0; letter-spacing: .04em; text-transform: uppercase;
}
.acc-bar { flex: 1; height: 5px; background: var(--surface-3); border-radius: 99px; overflow: hidden; min-width: 60px; }
.acc-fill { height: 100%; width: 0%; border-radius: 99px; background: var(--hit); transition: width .4s cubic-bezier(.4,0,.2,1); }
.acc-fill.accent { background: var(--accent); }
.stat-pct { font-size: 12px; font-weight: 700; width: 38px; text-align: right; color: var(--hit); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.stat-pct.accent { color: var(--accent); }
#total-notes { font-size: 10px; color: var(--text-lo); margin-top: 8px; }

/* ── Riff Builder ─────────────────────────────────────────────────────────── */
#riff-ctrl-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--surface-1); padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.riff-transport { display: flex; align-items: center; gap: 6px; }

.btn-record {
  display: flex; align-items: center; gap: 8px;
  background: #3a1414; color: var(--miss);
  border: 1px solid #5a2020; border-radius: var(--r);
  font-family: var(--font); font-size: 13px; font-weight: 700;
  padding: 0 18px; height: 36px; cursor: pointer;
  letter-spacing: .04em; white-space: nowrap;
  transition: background .15s, box-shadow .15s;
}
.btn-record:hover:not(:disabled) { background: #4a1818; box-shadow: 0 0 12px rgba(204,68,68,.3); }
.btn-record:disabled { opacity: .4; cursor: default; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}
.rec-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--miss); flex-shrink: 0;
}
.recording .rec-dot { animation: pulse-dot 1s ease-in-out infinite; }

.btn-stop-riff {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r);
  font-family: var(--font); font-size: 13px; font-weight: 600;
  padding: 0 18px; height: 36px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn-stop-riff svg { width: 9px; height: 9px; }
.btn-stop-riff:hover:not(:disabled) { background: var(--surface-4); border-color: var(--border-hi); }
.btn-stop-riff:disabled { opacity: .35; cursor: default; }

.riff-timer {
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text-lo); letter-spacing: .08em; margin-left: auto;
}
.riff-timer.active { color: var(--miss); }

.riff-live-note {
  font-size: 28px; font-weight: 800; color: var(--text-lo);
  letter-spacing: -0.02em; min-width: 64px; text-align: center;
  transition: color .1s;
}

/* Interactive fretboard wrapper */
#riff-fb-wrap {
  position: relative;
  background: #0c0905;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#riff-fretboard {
  display: block; width: 100%; height: 220px; cursor: crosshair;
}
#riff-fb-hint {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--text-lo); letter-spacing: .04em;
  pointer-events: none; white-space: nowrap;
}

/* Sequence strip */
#riff-seq-strip {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  padding: 8px 14px; min-height: 52px;
}
#riff-seq-scroll { flex: 1; overflow-x: auto; overflow-y: hidden; min-height: 36px; }
#riff-seq-chips {
  display: flex; align-items: center; gap: 4px;
  flex-wrap: nowrap; padding: 2px 0;
}
.riff-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 4px 7px; cursor: pointer;
  flex-shrink: 0; transition: border-color .12s, background .12s;
  min-width: 40px;
}
.riff-chip:hover { border-color: var(--miss); background: rgba(204,68,68,.08); }
.riff-chip.active { border-color: var(--accent); background: var(--accent-lo); }
.riff-chip .chip-note { font-size: 13px; font-weight: 700; color: var(--text-hi); line-height: 1; }
.riff-chip .chip-oct  { font-size: 9px; color: var(--text-lo); margin-top: 2px; }
.riff-chip .chip-del  { font-size: 9px; color: var(--miss); margin-top: 2px; display: none; }
.riff-chip:hover .chip-oct { display: none; }
.riff-chip:hover .chip-del { display: block; }

.riff-seq-empty {
  font-size: 12px; color: var(--text-lo); padding: 8px 2px;
  white-space: nowrap;
}

#riff-seq-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.riff-note-count { font-size: 11px; color: var(--text-lo); white-space: nowrap; }

/* Save bar */
#riff-save-bar {
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 10px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  padding: 12px 16px;
}

/* Saved riffs list */
#riff-saved-section {
  padding: 16px 16px 20px;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; flex: 1;
}
.saved-list {
  display: flex; flex-direction: column; gap: 5px;
}
.saved-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 12px;
  transition: border-color .15s;
}
.saved-item:hover { border-color: var(--border-hi); }
.saved-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.saved-item-name { font-size: 13px; font-weight: 700; color: var(--text-hi); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-item-meta { font-size: 10px; color: var(--text-lo); letter-spacing: .03em; }
.saved-item-actions { display: flex; gap: 5px; flex-shrink: 0; }
.btn-sm {
  background: transparent; color: var(--text-lo); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-family: var(--font); font-size: 11px;
  font-weight: 600; padding: 4px 10px; cursor: pointer; letter-spacing: .04em;
  transition: color .15s, border-color .15s, background .15s; white-space: nowrap;
}
.btn-sm:hover        { color: var(--accent); border-color: var(--accent); background: var(--accent-lo); }
.btn-sm.danger:hover { color: var(--miss);   border-color: var(--miss);   background: rgba(204,68,68,.1); }
.empty-msg { color: var(--text-lo); font-size: 12px; padding: 6px 0; }

/* ── Scale Builder Modal ────────────────────────────────────────────────────── */
@keyframes overlay-in  { from { opacity: 0; }               to { opacity: 1; } }
@keyframes modal-slide {
  from { opacity: 0; transform: translateY(-14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1);   }
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.82);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 200; padding: 40px 16px 24px; overflow-y: auto;
  animation: overlay-in .18s ease;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface-1); border: 1px solid var(--border-hi);
  border-radius: var(--r-lg); width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modal-slide .22s cubic-bezier(.34,1.18,.64,1);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header-left { display: flex; align-items: center; gap: 10px; }
.modal-header-icon { width: 18px; height: 18px; color: var(--accent); }
.modal-title { font-size: 14px; font-weight: 700; color: var(--text-hi); letter-spacing: .04em; }
.modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; background: var(--surface-3);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-lo); cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.modal-close svg { width: 10px; height: 10px; }
.modal-close:hover { color: var(--text-hi); background: var(--surface-4); border-color: var(--border-hi); }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.sb-form-top { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.sb-divider { height: 1px; background: var(--border); margin: 2px 0; }
.sb-saved { display: flex; flex-direction: column; gap: 10px; }

/* ── Tap tempo button ───────────────────────────────────────────────────────── */
.btn-tap {
  background: var(--surface-3); color: var(--text-lo); border: 1px solid var(--border);
  border-radius: 0 var(--r-sm) var(--r-sm) 0; font-family: var(--font); font-size: 11px;
  font-weight: 700; padding: 0 10px; height: 100%; cursor: pointer; letter-spacing: .05em;
  transition: background .1s, color .1s, border-color .1s; white-space: nowrap;
}
.btn-tap:hover { background: var(--accent-lo); color: var(--accent); border-color: var(--accent); }
.btn-tap:active { background: var(--accent); color: #fff; }
#ctrl-bar .ctrl-inline { align-items: stretch; }
#ctrl-bar .ctrl-inline #bpm { border-radius: var(--r-sm) 0 0 var(--r-sm); }

/* ── Beat counter bar ───────────────────────────────────────────────────────── */
#beat-counter-bar {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  padding: 6px 16px; min-height: 32px; flex-shrink: 0;
}
#beat-dots { display: flex; gap: 6px; align-items: center; }
.beat-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--surface-4);
  transition: background .08s, transform .08s;
}
.beat-dot.accent { background: var(--accent); }
.beat-dot.active { background: var(--hit); transform: scale(1.35); }
#countdown-display {
  font-size: 22px; font-weight: 900; color: var(--accent);
  letter-spacing: -0.02em; min-width: 24px; text-align: center;
}

/* ── Fretboard label toggle ─────────────────────────────────────────────────── */
#fb-label-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-1); padding: 4px 14px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#fb-label-bar .cap { margin-bottom: 0; }
.toggle-group { display: flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.toggle-opt {
  background: transparent; color: var(--text-lo); border: none; border-right: 1px solid var(--border);
  font-family: var(--font); font-size: 11px; font-weight: 600; padding: 4px 10px;
  cursor: pointer; letter-spacing: .04em; transition: background .12s, color .12s;
}
.toggle-opt:last-child { border-right: none; }
.toggle-opt:hover { color: var(--text); background: var(--surface-3); }
.toggle-opt.active { background: var(--surface-4); color: var(--text-hi); }

/* ── Tuner view ─────────────────────────────────────────────────────────────── */
#tuner-ctrl-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface-1); padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
#tuner-toggle .btn-icon-start { width: 9px; height: 11px; }
#tuner-toggle .btn-icon-stop  { width: 9px; height: 9px;  display: none; }
#tuner-toggle.stop .btn-icon-start { display: none; }
#tuner-toggle.stop .btn-icon-stop  { display: block; }

#tuner-display {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; padding: 20px 16px 28px;
  overflow-y: auto;
}
#tuner-note-name {
  font-size: 96px; font-weight: 900; line-height: 1;
  letter-spacing: -0.04em; color: var(--text-lo);
  transition: color .15s;
}
#tuner-note-name.in-tune { color: var(--hit); }
#tuner-note-name.sharp   { color: var(--miss); }
#tuner-note-name.flat    { color: #4488cc; }
#tuner-octave { font-size: 18px; color: var(--text-lo); font-weight: 700; letter-spacing: .05em; }
#tuner-freq   { font-size: 12px; color: var(--text-lo); font-variant-numeric: tabular-nums; letter-spacing: .04em; min-height: 1.4em; }
#tuner-needle { width: 320px; max-width: 100%; height: 140px; }
#tuner-cents-label {
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text-lo); letter-spacing: .05em; min-height: 1.6em; text-align: center;
}
#tuner-direction {
  font-size: 22px; font-weight: 700; letter-spacing: .04em;
  min-height: 1.6em; text-align: center; transition: color .15s;
}
#tuner-string-guide {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-top: 12px; padding: 14px 20px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r);
}
#tuner-strings { display: flex; gap: 16px; }
.tuner-str {
  font-size: 14px; font-weight: 700; color: var(--text-lo);
  cursor: default; transition: color .12s;
  text-align: center; min-width: 24px;
}
.tuner-str.active { color: var(--hit); }

/* ── History view ────────────────────────────────────────────────────────────── */
#history-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  padding: 12px 20px; flex-shrink: 0;
}
#history-header .cap { margin-bottom: 0; font-size: 12px; }
#history-list {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.history-item {
  display: grid; grid-template-columns: 1fr auto;
  gap: 6px 16px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: 10px 14px;
}
.history-item-main { display: flex; flex-direction: column; gap: 3px; }
.history-item-title { font-size: 13px; font-weight: 700; color: var(--text-hi); }
.history-item-sub   { font-size: 11px; color: var(--text-lo); letter-spacing: .03em; }
.history-item-stats { display: flex; gap: 12px; align-items: center; flex-shrink: 0; }
.history-stat { display: flex; flex-direction: column; align-items: flex-end; }
.history-stat-val { font-size: 15px; font-weight: 800; color: var(--text-hi); font-variant-numeric: tabular-nums; }
.history-stat-val.hit    { color: var(--hit); }
.history-stat-val.accent { color: var(--accent); }
.history-stat-lbl { font-size: 9px; color: var(--text-lo); letter-spacing: .06em; text-transform: uppercase; }

/* ── Scale builder preview canvas ───────────────────────────────────────────── */
.sb-preview-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.sb-preview-header .cap { margin-bottom: 0; }
#sb-preview-canvas {
  display: block; width: 100%; height: 100px;
  background: #0c0905; border-radius: var(--r-sm);
}

/* ── Simple (Accessibility) view ────────────────────────────────────────────── */
#simple-ctrl-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--surface-1); padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}

#simple-toggle {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
  background: #163624; color: var(--text-hi);
  border: 1px solid #224d34; border-radius: var(--r); outline: none;
  font-family: var(--font); font-size: 13px; font-weight: 700;
  padding: 0 20px; cursor: pointer; height: 36px; min-width: 96px;
  letter-spacing: .04em; white-space: nowrap; flex-shrink: 0;
  transition: background .15s, border-color .15s;
  box-shadow: 0 1px 6px rgba(0,0,0,.4);
}
#simple-toggle .btn-icon-start { width: 9px; height: 11px; }
#simple-toggle .btn-icon-stop  { width: 9px; height: 9px; display: none; }
#simple-toggle:hover { background: #1d4a2e; }
#simple-toggle.stop { background: #3d1212; border-color: #5a1e1e; }
#simple-toggle.stop:hover { background: #4d1818; }
#simple-toggle.stop .btn-icon-start { display: none; }
#simple-toggle.stop .btn-icon-stop  { display: block; }

#simple-pos-bar {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  padding: 8px 16px; flex-shrink: 0;
}
#simple-pos-label {
  font-size: 13px; font-weight: 700; color: var(--text);
  letter-spacing: .04em; min-width: 110px; text-align: center;
}

#simple-fretboard {
  display: block; width: 100%;
  flex: 1; min-height: 240px;
  background: #0c0905;
  border-bottom: 1px solid var(--border);
}

#simple-feedback {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 18px 16px 22px; gap: 4px; background: var(--bg); flex-shrink: 0;
}
#simple-note-name {
  font-size: 80px; font-weight: 900; color: var(--text-lo);
  line-height: 1; letter-spacing: -0.02em; transition: color .1s;
}
#simple-note-status {
  font-size: 13px; font-weight: 700; color: var(--text-lo);
  letter-spacing: .08em; text-transform: uppercase;
  min-height: 1.5em; text-align: center; transition: color .1s;
}

/* ── Mobile ─────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #ctrl-bar, #riff-ctrl-bar { padding: 8px 12px 10px; }
  .ctrl-sep { display: none; }
  #device-group, #riff-device-group { display: none; }

  #beat-track { height: 60px; }
  #fretboard  { height: 300px; }

  #bottom { flex-direction: column; }
  .panel  { border-right: none; border-bottom: 1px solid var(--border); }
  .panel:last-child { border-bottom: none; }
  #note-name  { font-size: 56px; }

  #riff-fretboard { height: 170px; }
  #tuner-device-group { display: none; }
  #tuner-note-name { font-size: 72px; }
  #tuner-needle { width: 260px; }
  .history-item-stats { gap: 8px; }
  #simple-device-group { display: none; }
  #simple-note-name { font-size: 60px; }

  .modal-overlay { padding: 12px 8px; }
  .sb-form-top   { flex-direction: column; }
  .interval-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 400px) {
  #note-name { font-size: 44px; }
  select { font-size: 12px; padding: 5px 24px 5px 7px; }
}

/* ============================================================
   AI Tutor Tab
   ============================================================ */

.ai-tutor-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-section {
  background: var(--surface-1, #1e1e2e);
  border: 1px solid var(--border, #333);
  border-radius: 8px;
  padding: 16px;
}

.ai-section-title {
  margin: 0 0 12px 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.7;
}

/* Context row */
.ai-context-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.ai-context-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  opacity: 0.8;
}

.ai-context-row select,
.ai-context-row input {
  background: #2a2a3e;
  border: 1px solid #444;
  border-radius: 4px;
  color: inherit;
  padding: 4px 8px;
  font-size: 0.9rem;
}

/* Metronome row */
.ai-metro-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-beat-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ai-beat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3a3a5c;
  transition: background 0.05s;
}

.ai-beat-dot.accent { background: #e2e8f0; transform: scale(1.3); }
.ai-beat-dot.beat   { background: #63b3ed; }

/* Fretboard section — no extra padding, canvas fills it */
#ai-fretboard-section {
  padding: 8px;
}

/* Record controls */
.ai-record-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-record {
  background: #c53030;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-record:hover { background: #e53e3e; }
.btn-record:disabled { background: #555; cursor: not-allowed; }

.ai-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  opacity: 0.9;
  min-width: 40px;
}

.ai-rec-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e53e3e;
  animation: ai-blink 1s step-start infinite;
}

@keyframes ai-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Progress bar */
.ai-progress-row {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-progress-track {
  height: 6px;
  background: #333;
  border-radius: 3px;
  overflow: hidden;
}

.ai-progress-fill {
  height: 100%;
  background: #4299e1;
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

.ai-status-text {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* Waveform */
.ai-waveform {
  width: 100%;
  height: 80px;
  border-radius: 4px;
  display: block;
  cursor: crosshair;
}

.ai-note-track {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  max-height: 80px;
  overflow-y: auto;
}

.ai-note-pill {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  cursor: default;
}

.ai-note-pill.good  { background: #22543d; color: #68d391; }
.ai-note-pill.late  { background: #744210; color: #f6e05e; }
.ai-note-pill.wrong { background: #742a2a; color: #fc8181; }

/* Metrics grid */
.ai-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

@media (max-width: 480px) {
  .ai-metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

.ai-metric-card {
  background: #16213e;
  border: 1px solid #2d3748;
  border-radius: 6px;
  padding: 10px 12px;
}

.ai-metric-overall {
  border-color: #4299e1;
  background: #1a365d;
}

.ai-metric-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
  margin-bottom: 4px;
}

.ai-metric-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #e2e8f0;
}

.ai-overall-value {
  font-size: 1.8rem;
  color: #63b3ed;
}

.ai-metric-bar-track {
  margin-top: 6px;
  height: 4px;
  background: #2d3748;
  border-radius: 2px;
  overflow: hidden;
}

.ai-metric-bar {
  height: 100%;
  border-radius: 2px;
  width: 0%;
  transition: width 0.6s ease;
}

/* Feedback section */
.ai-skeleton {
  height: 14px;
  background: linear-gradient(90deg, #2d3748 25%, #3a4a6b 50%, #2d3748 75%);
  background-size: 200% 100%;
  animation: ai-shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 8px;
  width: 100%;
}

@keyframes ai-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ai-unavailable-msg {
  opacity: 0.6;
  font-style: italic;
  font-size: 0.85rem;
  padding: 8px 0;
}

.ai-summary {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 14px;
  opacity: 0.9;
}

.ai-feedback-group {
  border: 1px solid #2d3748;
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}

.ai-group-header {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  user-select: none;
  background: #16213e;
  list-style: none;
}

.ai-strengths-header { color: #68d391; }
.ai-improvements-header { color: #fbd38d; }
.ai-exercises-header { color: #63b3ed; }

.ai-feedback-list {
  list-style: none;
  margin: 0;
  padding: 8px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-feedback-item {
  font-size: 0.85rem;
  line-height: 1.5;
}

.ai-feedback-aspect {
  font-weight: 600;
  margin-right: 6px;
}

.ai-severity-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
}

.ai-severity-high   { background: #742a2a; color: #fc8181; }
.ai-severity-medium { background: #744210; color: #f6e05e; }
.ai-severity-low    { background: #2d3748; color: #a0aec0; }

.ai-exercises-container {
  padding: 8px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-exercise-card {
  background: #1a365d;
  border: 1px solid #2c5282;
  border-radius: 6px;
  padding: 10px 12px;
}

.ai-exercise-title {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 4px;
  color: #90cdf4;
}

.ai-exercise-desc {
  font-size: 0.82rem;
  line-height: 1.5;
  opacity: 0.85;
}

.ai-exercise-duration {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: #2c5282;
  color: #bee3f8;
}

/* Recordings history */
.ai-recordings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-empty-msg {
  opacity: 0.5;
  font-size: 0.85rem;
  font-style: italic;
}

.ai-recording-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #16213e;
  border: 1px solid #2d3748;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s;
  font-size: 0.82rem;
}

.ai-recording-row:hover { border-color: #4299e1; }
.ai-recording-row .ai-rec-date { opacity: 0.6; flex: 1; }
.ai-recording-row .ai-rec-score { font-weight: 700; color: #63b3ed; }
.ai-recording-row .ai-rec-meta { opacity: 0.7; }
.ai-recording-row .ai-rec-status-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 700;
}
.ai-rec-status-done { background: #22543d; color: #68d391; }
.ai-rec-status-analyzing { background: #2a4365; color: #63b3ed; }
.ai-rec-status-error { background: #742a2a; color: #fc8181; }
.ai-rec-status-pending { background: #2d3748; color: #a0aec0; }

.ai-rec-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.4;
  font-size: 0.85rem;
  padding: 2px 6px;
  color: inherit;
  transition: opacity 0.15s;
}
.ai-rec-delete-btn:hover { opacity: 1; color: #fc8181; }
