:root {
  --bg: #1C1510;
  --surface: #261D17;
  --surface-2: #31251D;
  --surface-3: #3D2E24;
  --border: rgba(245, 224, 194, 0.12);
  --text: #F7EFE4;
  --text-muted: #B9A896;
  --amber: #E8A849;
  --amber-glow: rgba(232, 168, 73, 0.25);
  --terracotta: #D96B38;
  --sage: #72A875;
  --danger: #E06C65;
  --radius: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100%;
  overscroll-behavior-y: contain;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(134px + env(safe-area-inset-bottom));
}

/* ---- Top Header ---- */
.top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(28, 21, 16, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.song-id h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.song-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chord-pill-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px 3px 4px;
}

.chord-badge {
  background: var(--amber);
  color: #1A120B;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 3px 10px;
  border-radius: 999px;
  min-width: 34px;
  text-align: center;
}

.next-chord-chip {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.tab-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
  background: var(--surface);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.tab-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 8px 4px;
  border-radius: 9px;
  cursor: pointer;
  min-height: 38px;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn.active {
  background: var(--surface-3);
  color: var(--amber);
  box-shadow: inset 0 0 0 1px rgba(232, 168, 73, 0.25);
}

/* ---- Main Views ---- */
.main-content {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.view {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.view.active {
  display: flex;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.card h2, .card h3 {
  margin: 0 0 6px;
  font-size: 1.04rem;
}

/* ---- Buttons ---- */
.icon-btn, .pill-btn, .toggle-chip, .step-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.82rem;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:active, .pill-btn:active, .play-btn:active, .step-btn:active {
  transform: scale(0.96);
}

.mixer-trigger {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.pill-btn.primary {
  background: var(--amber);
  color: #1A120B;
  border-color: transparent;
}

.pill-btn.active, .toggle-chip.active, .toggle-btn.active {
  background: rgba(232, 168, 73, 0.18);
  color: var(--amber);
  border-color: rgba(232, 168, 73, 0.5);
}

/* ---- Section Strip & Drill Banner ---- */
.section-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.section-strip::-webkit-scrollbar { display: none; }

.section-chip {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
}

.section-chip.active {
  background: var(--terracotta);
  color: #FFF7EE;
  border-color: transparent;
}

.drill-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(114, 168, 117, 0.14);
  border: 1px solid rgba(114, 168, 117, 0.4);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.drill-banner-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.drill-tag {
  background: var(--sage);
  color: #112012;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}

.speed-trainer-pill {
  font-size: 0.74rem;
  color: var(--amber);
  background: rgba(232, 168, 73, 0.15);
  padding: 2px 8px;
  border-radius: 999px;
}

.countin-banner {
  text-align: center;
  background: rgba(232, 168, 73, 0.2);
  border: 1px solid var(--amber);
  color: var(--amber);
  border-radius: 12px;
  padding: 8px;
  font-size: 1rem;
  font-weight: 700;
}

/* ---- Lyric Card ---- */
.lyric-card {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
}

.bar-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.bar-counter {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pattern-badge {
  font-size: 0.73rem;
  color: var(--text-muted);
  background: var(--surface-3);
  padding: 2px 8px;
  border-radius: 999px;
}

.lyric-current {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  color: #FFF7EC;
}

.lyric-next {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.coach-hint {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 0.8rem;
  color: var(--sage);
  font-weight: 600;
}

/* ---- Controls Strip ---- */
.controls-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.segmented {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  min-height: 34px;
}

.seg-btn.active {
  background: var(--surface-3);
  color: var(--amber);
}

/* ---- Fretboard Diagram ---- */
.fretboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.fretboard-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.slide-alert {
  background: rgba(217, 107, 56, 0.22);
  border: 1px solid var(--terracotta);
  color: #FFB28E;
  font-size: 0.73rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.fretboard-svg-wrap {
  width: 100%;
  overflow: hidden;
}

.fretboard-svg-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ---- Live Tab Stage ---- */
.tab-stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.stage-label {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.beat-dots {
  display: flex;
  gap: 4px;
}

.b-dot {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.b-dot.half {
  width: 20px;
  font-size: 0.68rem;
  opacity: 0.8;
}

.b-dot.active {
  background: var(--amber);
  color: #1A120B;
  border-color: transparent;
  box-shadow: 0 0 12px var(--amber-glow);
}

.tab-bars-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 620px) {
  .tab-bars-grid {
    grid-template-columns: 1.15fr 0.85fr;
  }
}

.tab-bar-box {
  background: #140F0B;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  overflow: hidden;
}

.tab-bar-box.is-current {
  border-color: rgba(232, 168, 73, 0.55);
  box-shadow: 0 0 0 1px rgba(232, 168, 73, 0.18);
}

.tab-bar-box.is-next {
  opacity: 0.78;
}

.tab-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  font-size: 0.76rem;
}

.tab-box-head strong {
  color: var(--amber);
}

.tab-grid {
  display: grid;
  grid-template-columns: 22px repeat(8, 1fr);
  row-gap: 2px;
  align-items: center;
  font-family: var(--font-mono);
}

.tab-str-lbl {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.tab-cell {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
}

.tab-cell::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(245, 224, 194, 0.2);
  z-index: 0;
}

.tab-cell.beat-active {
  background: rgba(232, 168, 73, 0.14);
}

.note-pill {
  position: relative;
  z-index: 1;
  background: var(--surface-3);
  border: 1px solid rgba(232, 168, 73, 0.45);
  color: #FFF4E0;
  border-radius: 6px;
  padding: 0 5px;
  line-height: 20px;
  min-width: 22px;
  text-align: center;
  font-size: 0.82rem;
}

.note-pill.bass-hop {
  border-color: var(--terracotta);
  color: #FFC4A8;
}

.tab-cell.beat-active .note-pill {
  background: var(--amber);
  color: #1A120B;
  border-color: #FFF3DC;
  box-shadow: 0 0 12px var(--amber-glow);
  transform: scale(1.08);
}

.tab-pick-cell {
  text-align: center;
  font-size: 0.72rem;
  color: var(--sage);
  font-weight: 700;
  padding-top: 4px;
}

.tab-pick-cell.beat-active {
  color: var(--amber);
}

/* ---- Scrubber ---- */
.bar-scrubber-wrap {
  margin-top: 10px;
}

.bar-scrubber {
  display: flex;
  gap: 2px;
  height: 16px;
  align-items: center;
}

.scrub-seg {
  flex: 1;
  height: 8px;
  background: var(--surface-3);
  border-radius: 3px;
  cursor: pointer;
  border: 0;
  padding: 0;
}

.scrub-seg.is-done {
  background: rgba(232, 168, 73, 0.42);
}

.scrub-seg.is-active {
  height: 14px;
  background: var(--amber);
}

/* ---- Drills View ---- */
.drills-top-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.switch-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.switch-card input {
  width: 20px;
  height: 20px;
  accent-color: var(--amber);
}

.switch-card span {
  display: flex;
  flex-direction: column;
}

.switch-card small {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.drills-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drill-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drill-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.drill-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-badge {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--amber);
  padding: 3px 8px;
  border-radius: 999px;
}

/* ---- Full Tab View ---- */
.fulltab-header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tips-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tip-box {
  background: var(--surface-2);
  border-left: 3px solid var(--sage);
  padding: 10px 12px;
  border-radius: 0 10px 10px 0;
}

.tip-box strong {
  display: block;
  margin-bottom: 4px;
  color: var(--amber);
  font-size: 0.9rem;
}

.tip-box p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.ascii-tab-pre {
  background: #130E0A;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.45;
  overflow-x: auto;
  color: #F4E7D4;
  margin: 0;
}

.full-lyrics-map {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lyric-sec-block h4 {
  margin: 0 0 6px;
  color: var(--amber);
  font-size: 0.92rem;
}

.lyric-line-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(245, 224, 194, 0.06);
  font-size: 0.84rem;
}

.lyric-line-chord {
  min-width: 54px;
  color: var(--terracotta);
  font-weight: 800;
  font-family: var(--font-mono);
}

/* ---- Tuner View ---- */
.tuner-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tuner-gauge {
  background: #140F0B;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 14px;
  margin: 12px 0;
  text-align: center;
}

.tuner-note-readout {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--amber);
  line-height: 1;
}

.tuner-freq-readout {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.tuner-meter-track {
  position: relative;
  height: 14px;
  background: var(--surface-2);
  border-radius: 999px;
  margin: 14px 0 6px;
  overflow: hidden;
}

.tuner-center-mark {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  background: var(--sage);
}

.tuner-needle {
  position: absolute;
  top: 2px;
  left: 50%;
  width: 14px;
  height: 10px;
  border-radius: 999px;
  background: var(--amber);
  transform: translateX(-50%);
  transition: left 0.08s linear, background 0.12s ease;
}

.tuner-cents-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.ref-strings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ref-string-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 62px;
}

.ref-string-btn strong {
  font-size: 1.15rem;
  color: var(--amber);
}

.ref-string-btn span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.tap-tempo-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
}

.tap-pad-btn {
  flex: 1;
  min-height: 64px;
  border: 2px solid var(--amber);
  background: rgba(232, 168, 73, 0.14);
  color: var(--amber);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  border-radius: 14px;
  cursor: pointer;
}

.tap-bpm-readout {
  min-width: 78px;
  text-align: center;
}

.tap-bpm-readout strong {
  display: block;
  font-size: 1.8rem;
  line-height: 1;
}

.tap-bpm-readout span {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* ---- Bottom Transport Dock ---- */
.transport-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(24, 18, 13, 0.96);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom));
}

.transport-dock > * {
  max-width: 732px;
  margin-left: auto;
  margin-right: auto;
}

.bpm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.bpm-slider-wrap {
  flex: 1;
}

.bpm-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.bpm-label-row strong {
  color: var(--amber);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
  height: 22px;
  margin: 0;
  cursor: pointer;
}

.step-btn {
  min-width: 44px;
  min-height: 36px;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.transport-row {
  display: grid;
  grid-template-columns: 46px 64px 1fr 72px 66px;
  gap: 8px;
  align-items: center;
}

.play-btn {
  border: 0;
  background: linear-gradient(135deg, #F0B65A 0%, #D96B38 100%);
  color: #1A120B;
  font-weight: 800;
  font-size: 0.98rem;
  min-height: 48px;
  border-radius: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(217, 107, 56, 0.3);
}

.mute-tag {
  font-size: 0.72rem;
}

.icon-btn.is-muted {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---- Mixer Sheet ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  z-index: 50;
}

.mixer-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 85dvh;
  overflow-y: auto;
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 0 auto 10px;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.sheet-header h3 {
  margin: 0;
}

.mixer-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.86rem;
}

.slider-label strong {
  color: var(--amber);
}

.capo-pills {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-top: 4px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--surface-3);
  border: 1px solid var(--amber);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

@media print {
  .top-header, .transport-dock, .controls-strip, .section-strip, .bar-scrubber-wrap {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
  .card {
    border-color: #ccc;
    background: #fff;
  }
}
