/* Nagori — design tokens and layout. Vanilla CSS, no build step. */

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

:root {
  --bg: #0e1013;
  --surface: #171a20;
  --surface-2: #1f232b;
  --surface-3: #272c36;
  --border: #2b303a;
  --text: #e8eaf0;
  --text-dim: #8d95a5;
  --text-faint: #8a91a0;
  --accent: #f2b544;
  --accent-text: #f2b544;
  --on-accent: #1a1400;
  --accent-soft: rgba(242, 181, 68, 0.16);
  --accent-line: rgba(242, 181, 68, 0.55);
  --finger: #6fb7ff;
  --finger-bg: rgba(111, 183, 255, 0.14);
  --on-finger: #0b1a2e;
  --danger: #ff6b6b;
  --video-bg: #000;
  --tab-line: #3a404c;
  --tab-ink: #eef0f5;
  --tab-dim: #7a8292;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Roboto, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 380px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --surface-3: #e6e6e1;
  --border: #dcdcd6;
  --text: #1b1e25;
  --text-dim: #5f6675;
  --text-faint: #656b79;
  --accent: #b8780a;
  --accent-text: #8a5a06;
  --accent-soft: rgba(184, 120, 10, 0.14);
  --accent-line: rgba(184, 120, 10, 0.6);
  --finger: #1a63c4;
  --finger-bg: rgba(31, 111, 214, 0.12);
  --on-finger: #ffffff;
  --danger: #c62828;
  --tab-line: #c9cbc6;
  --tab-ink: #15181e;
  --tab-dim: #656b79;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

svg {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Header --- */

.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.3px;
  font-size: 17px;
}

.brand svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.site-nav {
  display: flex;
  gap: 2px;
}

.site-nav a {
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--surface-3);
}

.icon-btn.text {
  width: auto;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-dim);
  transition: color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* --- Generic controls --- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.2;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  min-height: 32px;
}

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

.chip[aria-pressed="true"],
.chip.is-active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

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

.chip[aria-pressed="true"] .sub {
  color: var(--text-dim);
}

.meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12.5px;
}

a.meta-chip {
  text-decoration: none;
  transition: background 0.15s;
}

a.meta-chip:hover {
  background: var(--surface-3);
}

.meta-chip b {
  color: var(--text);
  font-weight: 600;
}

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

.segmented button {
  padding: 7px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 14px;
  min-height: 36px;
  transition: background 0.15s, color 0.15s;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--text);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
  min-height: 32px;
}

.toggle input {
  appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}

.toggle input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.15s, background 0.15s;
}

.toggle input:checked {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.toggle input:checked::after {
  transform: translateX(14px);
  background: var(--accent);
}

.select {
  padding: 6px 30px 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238d95a5' stroke-width='1.5'/></svg>") no-repeat right 10px center;
  color: var(--text);
  font-size: 13px;
  appearance: none;
  min-height: 32px;
}

:root[data-theme="light"] .select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%235f6675' stroke-width='1.5'/></svg>");
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  min-height: 36px;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--text-dim);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn.small {
  padding: 4px 10px;
  min-height: 30px;
  font-size: 12.5px;
}

/* --- Home --- */

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.hero {
  padding: 48px 0 32px;
  max-width: 720px;
}

.hero h1 {
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.5px;
  margin-bottom: 14px;
}

.hero p {
  color: var(--text-dim);
  font-size: 17px;
}

.hero.compact {
  padding: 32px 0 20px;
}

/* --- Tools page --- */

.tools-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 8px;
}

@media (min-width: 1024px) {
  .tools-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tool.wide {
    grid-column: 1 / -1;
  }
}

.tool {
  scroll-margin-top: 16px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}

.tool h2 {
  font-size: 20px;
  margin-bottom: 4px;
}

.tool h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  font-weight: 600;
  margin: 18px 0 8px;
}

.tool .lead {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 16px;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 12px;
}

.tool-row .spacer {
  flex: 1;
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  max-width: 100%;
}

.field .select {
  min-width: 0;
}

.metro-tempo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.metro-bpm {
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  min-width: 112px;
  text-align: center;
}

.metro-bpm small {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  margin-left: 6px;
}

.range {
  width: 100%;
  margin: 14px 0 4px;
  accent-color: var(--accent);
}

.beat-dots {
  display: flex;
  gap: 10px;
  margin: 10px 0 4px;
  min-height: 16px;
}

.beat-dots span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background 0.05s, transform 0.05s;
}

.beat-dots span.accent {
  border-color: var(--accent-line);
}

.beat-dots span.is-on {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.25);
}

.fretboard {
  margin-top: 14px;
  overflow-x: auto;
}

.fretboard svg {
  width: 100%;
  min-width: 720px;
  height: auto;
  display: block;
}

.fb-board {
  fill: var(--surface-2);
}

.fb-fret {
  stroke: var(--tab-line);
  stroke-width: 2;
}

.fb-nut {
  stroke: var(--text-dim);
  stroke-width: 6;
}

.fb-string {
  stroke: var(--tab-dim);
}

.fb-inlay {
  fill: var(--surface-3);
}

.fb-num {
  fill: var(--text-faint);
  font-size: 10px;
  font-family: var(--mono);
  text-anchor: middle;
}

.fb-note {
  cursor: pointer;
}

.fb-note circle {
  fill: var(--surface);
  stroke: var(--border);
  stroke-width: 1;
  transition: fill 0.1s, stroke 0.1s;
}

.fb-note text {
  fill: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
}

.fb-note.in-scale circle {
  fill: var(--surface-3);
  stroke: var(--text-dim);
}

.fb-note.is-root circle {
  fill: var(--accent);
  stroke: var(--accent);
}

.fb-note.is-root text {
  fill: var(--on-accent);
}

.fb-note.off {
  opacity: 0.5;
}

.fb-note:hover circle {
  stroke: var(--accent);
}

.root-chips .chip {
  padding: 4px 9px;
  min-height: 28px;
  font-size: 12.5px;
}

.tuner-display {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 18px;
  align-items: center;
  margin: 16px 0 4px;
}

.tuner-note {
  grid-row: span 2;
  font-size: 52px;
  font-weight: 700;
  line-height: 1;
  min-width: 96px;
  font-variant-numeric: tabular-nums;
}

.tuner-note small {
  font-size: 18px;
  color: var(--text-dim);
}

.tuner-note small.which {
  font-size: 13px;
  font-weight: 500;
}

.tuner-scale {
  position: relative;
  height: 34px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.tuner-scale .center {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent-line);
  transform: translateX(-50%);
}

.tuner-scale .needle {
  position: absolute;
  left: 50%;
  top: 5px;
  bottom: 5px;
  width: 4px;
  border-radius: 2px;
  background: var(--text-dim);
  transform: translateX(-50%);
  transition: left 0.08s, background 0.08s;
}

.tuner-scale.ok .needle {
  background: var(--accent);
}

.tuner-status {
  font-size: 14px;
  color: var(--text-dim);
}

.tuner-status.ok {
  color: var(--accent-text);
  font-weight: 600;
}

.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.song-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.song-card .song-title {
  font-size: 22px;
  line-height: 1.2;
}

.song-card .artist {
  color: var(--text-dim);
  font-size: 15px;
}

.song-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.song-card .actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.tools-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin: 0 0 28px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  font-size: 13px;
}

.tool-card b {
  font-size: 14.5px;
}

.tool-card:hover {
  border-color: var(--accent, currentColor);
}

/* The visitor's own songs: a folder picker and a drop zone above the list. */
.local-songs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin: 0 0 28px;
  padding: 16px 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.local-songs.is-drop {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.local-text {
  flex: 1 1 320px;
}

.local-text h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.local-text p {
  color: var(--text-dim);
  font-size: 14px;
}

.local-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.local-hint {
  color: var(--text-faint);
  font-size: 13px;
}

.local-status {
  flex-basis: 100%;
  font-size: 14px;
  color: var(--text-dim);
}

.local-status:empty {
  display: none;
}

.local-status.error {
  color: var(--danger);
}

.song-card .actions .remove {
  margin-left: auto;
}

.song-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 14px;
}

.song-toolbar h2:not(.sr-only) {
  margin: 0;
  font-size: 18px;
}

.song-filter {
  flex: 1 1 220px;
  max-width: 360px;
  min-height: 34px;
  padding: 4px 10px;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.song-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.song-sort select {
  min-height: 34px;
  padding: 4px 8px;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.song-count {
  font-size: 12.5px;
  opacity: 0.7;
}

.song-group {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 10px 0 -4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.song-group:first-child {
  margin-top: 0;
}

.song-group-count {
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.7;
}

.empty-note {
  color: var(--text-dim);
  padding: 12px 0;
}

/* --- Song page layout --- */

.song-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 80px;
}

.song-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
}

.song-title h1 {
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.4px;
}

.song-title .artist {
  color: var(--text-dim);
  font-size: 16px;
  margin-top: 2px;
}

.song-title .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.song-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

@media (min-width: 1024px) {
  .song-layout {
    grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  }

  .sidebar {
    order: 1; /* first in the DOM (reading order), beside the content on wide screens */
    position: sticky;
    top: 16px;
  }
}

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

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

.panel-body {
  padding: 14px;
}

.panel h2,
.panel h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 10px;
}

/* --- Video panel --- */

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--video-bg);
}

.video-frame iframe,
.video-frame > div {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 13px;
}

.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.transport .spacer {
  flex: 1;
}

.now-playing {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.now-playing .chord {
  grid-row: span 2;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  min-width: 72px;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

.now-playing .chord.idle {
  color: var(--text-faint);
}

.now-playing .where {
  font-size: 14px;
  font-weight: 600;
}

.now-playing .next {
  color: var(--text-dim);
  font-size: 13px;
}

.now-playing .next b {
  color: var(--text);
  font-weight: 600;
}

.sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}

.sync-row .offset {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 52px;
  text-align: center;
}

.sync-row .spacer {
  flex: 1;
}

/* --- Playback source and part mixer --- */

.source-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.source-row .toggle {
  margin-left: auto;
}

.segmented.small button {
  padding: 4px 12px;
  font-size: 12.5px;
  min-height: 28px;
}

.mixer {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.chip.mini {
  padding: 3px 9px;
  min-height: 26px;
  font-size: 11.5px;
}

.chip.mini[aria-pressed="false"] {
  text-decoration: line-through;
  opacity: 0.85;
}

.sound-field {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.sound-field select {
  flex: 0 1 220px;
  min-height: 28px;
  padding: 3px 8px;
  font: inherit;
  font-size: 12.5px;
  color: inherit;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* --- Progress bar of sections --- */

.section-bar {
  display: flex;
  gap: 2px;
  height: 26px;
  padding: 0 14px 12px;
}

.section-bar button {
  position: relative;
  flex-grow: var(--w, 1);
  border: 0;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0 4px;
  min-width: 0;
}

.section-bar button.is-active {
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.section-bar button .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--p, 0%);
  background: var(--accent-line);
  opacity: 0.5;
}

/* --- Toolbar --- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.toolbar .spacer {
  flex: 1;
}

.track-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* --- Tab view --- */

.tab-view {
  min-width: 0;
}

.tab-system {
  position: relative;
  margin-bottom: 4px;
}

.tab-system svg {
  width: 100%;
  height: auto;
  overflow: visible;
  font-family: var(--font);
}

.tab-svg .string-line {
  stroke: var(--tab-line);
  stroke-width: 1;
}

.tab-svg .barline {
  stroke: var(--tab-dim);
  stroke-width: 1;
}

.tab-svg .barline.final {
  stroke-width: 2.5;
}

.tab-svg .string-name {
  fill: var(--tab-dim);
  font-size: 9px;
  font-weight: 600;
}

.tab-svg .bar-number {
  fill: var(--text-faint);
  font-size: 9px;
}

.tab-svg .fret-bg {
  fill: var(--bg);
}

.tab-svg .fret {
  fill: var(--tab-ink);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-anchor: middle;
}

.tab-svg .fret.tied,
.tab-svg .fret.ghost {
  fill: var(--tab-dim);
  font-weight: 500;
}

.tab-svg .fret.dead {
  fill: var(--tab-dim);
}

.tab-svg .finger {
  fill: var(--finger);
  font-size: 7.5px;
  font-weight: 700;
  text-anchor: middle;
}

.tab-svg .chord-name {
  fill: var(--text);
  font-size: 12.5px;
  font-weight: 700;
}

.tab-svg .marker {
  fill: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.tab-svg .time-sig {
  fill: var(--tab-ink);
  font-size: 11px;
  font-weight: 700;
}

.tab-svg .ring-line {
  stroke: var(--tab-dim);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.tab-svg .ring-label {
  fill: var(--tab-dim);
  font-size: 8px;
  font-style: italic;
}

.tab-svg .stem,
.tab-svg .beam,
.tab-svg .flag {
  stroke: var(--tab-ink);
  stroke-width: 1.2;
  fill: none;
}

.tab-svg .beam {
  stroke-width: 2.6;
}

.tab-svg .half-head {
  stroke: var(--tab-ink);
  stroke-width: 1;
  fill: none;
}

.tab-svg .dot {
  fill: var(--tab-ink);
}

.tab-svg .rest {
  fill: var(--tab-dim);
  stroke: var(--tab-dim);
}

.tab-svg .tuplet {
  fill: var(--tab-dim);
  font-size: 8px;
  font-style: italic;
  text-anchor: middle;
}

.tab-svg .tie,
.tab-svg .slur {
  stroke: var(--tab-dim);
  stroke-width: 1;
  fill: none;
}

.tab-svg .tech {
  fill: var(--tab-dim);
  font-size: 8px;
  text-anchor: middle;
}

.tab-svg .slide {
  stroke: var(--tab-ink);
  stroke-width: 1;
}

.tab-svg .bend {
  stroke: var(--tab-ink);
  stroke-width: 1;
  fill: none;
}

.tab-svg .bend-arrow {
  fill: var(--tab-ink);
}

.tab-svg .measure-hit {
  fill: transparent;
  cursor: pointer;
}

.tab-svg .measure-hit:hover {
  fill: var(--accent-soft);
  opacity: 0.5;
}

.tab-svg .measure-bg {
  fill: transparent;
  pointer-events: none;
}

.tab-svg .measure-bg.is-active {
  fill: var(--accent-soft);
}

.tab-svg .cursor {
  fill: var(--accent);
  opacity: 0.28;
  pointer-events: none;
}

.tab-view.hide-fingers .finger {
  display: none;
}

/* --- Positions gallery --- */

.positions {
  margin-top: 32px;
}

.positions h2,
.chords-strip h2,
.sheet h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.positions .lead,
.chords-strip .lead {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 16px;
}

.position-section {
  margin-bottom: 22px;
}

.position-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-text);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.position-section h3 span {
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.position-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.position-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 10px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.position-card:hover {
  border-color: var(--text-dim);
}

.position-card.is-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.position-card .name {
  font-weight: 700;
  font-size: 15px;
}

.position-card .name small {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
  margin-left: 4px;
}

.position-card .bars {
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.3;
}

.position-card .fingers {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--finger);
  letter-spacing: 1px;
}

.diagram {
  width: 108px;
  height: auto;
}

.diagram .grid-line {
  stroke: var(--tab-line);
  stroke-width: 1;
}

.diagram .nut {
  stroke: var(--tab-ink);
  stroke-width: 3;
}

.diagram .dot {
  fill: var(--finger);
}

.diagram .dot.repeat {
  fill: var(--tab-dim);
}

.diagram .dot-label {
  fill: var(--on-finger);
  font-size: 8.5px;
  font-weight: 700;
  text-anchor: middle;
}

.diagram .open,
.diagram .mute {
  fill: var(--tab-dim);
  font-size: 9px;
  text-anchor: middle;
}

.diagram .fret-label {
  fill: var(--text-dim);
  font-size: 9px;
}

.diagram .barre {
  fill: var(--finger);
  opacity: 0.85;
}

.diagram .string-label {
  fill: var(--text-faint);
  font-size: 7.5px;
  text-anchor: middle;
}

/* Sidebar positions (current section) */

.sidebar .position-grid {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.sidebar .position-card {
  padding: 8px 6px 6px;
}

.sidebar .diagram {
  width: 76px;
}

.sidebar .position-card .name {
  font-size: 13px;
}

.sidebar .position-card .bars {
  display: none;
}

/* --- Chord view --- */

.chords-strip {
  margin-bottom: 28px;
}

.chord-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.chord-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.chord-card.playable {
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: center;
}

.chord-card.playable:hover {
  border-color: var(--accent-line);
}

.chord-card.is-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.chord-card .name {
  font-weight: 700;
  font-size: 15px;
}

.chord-card .frets {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.sheet {
  font-size: 15px;
  max-width: 760px;
}

.sheet-section {
  padding: 14px 16px;
  margin: 0 -16px 8px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.2s, border-color 0.2s;
}

.sheet-section.is-active {
  background: var(--surface);
  border-color: var(--border);
}

.sheet-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-text);
  margin-bottom: 10px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.sheet-section h3 span {
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

/* The heading stays a heading; the button inside it is what seeks. */
.sheet-section h3 .sheet-jump {
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.sheet-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 6px;
  line-height: 1.35;
}

.sheet-line.chords-only {
  gap: 0 18px;
}

.sheet-seg {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  white-space: pre;
}

.sheet-seg .c {
  font-weight: 700;
  color: var(--text);
  font-size: 14px;
  padding: 1px 5px;
  margin: 0 2px 2px -5px;
  border-radius: 4px;
  min-height: 21px;
  transition: background 0.15s, color 0.15s;
}

.sheet-seg .c.is-now {
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.sheet-seg .c:empty {
  visibility: hidden;
}

.sheet-seg .t {
  color: var(--text);
  display: block;
  min-height: 1.35em;
}

.sheet-line.no-chords .sheet-seg .c {
  display: none;
}

.bar-grid {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.bar-grid .bar {
  flex: 1 1 0;
  min-width: 96px;
  padding: 6px 10px;
  border-left: 2px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  display: flex;
  gap: 12px;
  align-items: baseline;
  transition: background 0.15s;
}

.bar-grid .bar:last-child {
  border-right: 2px solid var(--border);
}

.bar-grid .bar .n {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 500;
}

.bar-grid .bar .c {
  padding: 1px 5px;
  margin-left: -5px;
  border-radius: 4px;
}

.bar-grid .bar .c.is-now {
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.bar-grid .bar .rep {
  color: var(--text-faint);
  font-weight: 500;
}

/* --- Footer --- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px 32px;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.6;
}

.site-footer a {
  color: var(--text-dim);
}

/* --- Loading / errors --- */

.status {
  padding: 40px 0;
  color: var(--text-dim);
  text-align: center;
}

.status.error {
  color: var(--danger);
}

/* --- Small screens --- */

@media (max-width: 1023px) {
  .sidebar .positions-panel {
    display: none;
  }

  .video-sticky {
    position: sticky;
    top: 0;
    z-index: 5;
    box-shadow: var(--shadow);
  }
}

@media (max-width: 640px) {
  .site-header,
  .site-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page,
  .song-page {
    padding-left: 16px;
    padding-right: 16px;
  }

  .sheet-section {
    margin-left: -8px;
    margin-right: -8px;
    padding: 10px 8px;
  }

  .now-playing .chord {
    font-size: 26px;
    min-width: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Print: the song head, the chord sheet or the tab, and the positions, on a light page. The page
   switches to the light tokens on beforeprint (util.js setupPrintTheme). */
@media print {
  .site-header,
  .site-footer,
  .sidebar,
  .track-picker,
  .toolbar,
  .transport,
  .tools-strip,
  .song-toolbar,
  .song-card .actions {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .page,
  .song-page {
    max-width: none;
    padding: 0;
  }

  .song-layout {
    display: block;
  }

  .sheet {
    max-width: none;
  }

  .sheet-section,
  .chord-card,
  .position-section,
  .tab-system {
    break-inside: avoid;
  }

  .panel,
  .tool,
  .song-card {
    box-shadow: none;
  }
}

.tab-svg .cursor.is-hidden {
  display: none;
}

.tab-svg .tuplet-bracket {
  fill: none;
  stroke: var(--tab-dim);
  stroke-width: 1;
}

.bar-grid button.bar {
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  background: transparent;
}

.chord-card .name a {
  color: inherit;
  text-decoration: none;
}

.chord-card .name a:hover {
  text-decoration: underline;
}

/* --- Focus ------------------------------------------------------------------ */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.tab-svg .measure-hit:focus-visible {
  fill: var(--accent-soft);
  outline: none;
}

.fb-note:focus-visible {
  outline: none;
}

.fb-note:focus-visible circle {
  stroke: var(--accent);
  stroke-width: 3;
}
