:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #22242a;
  background: #f7f6f2;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { cursor: pointer; }

.toolbar {
  min-height: 68px;
  padding: 12px clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #fff;
  border-bottom: 1px solid #dedbd0;
  color: #22242a;
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand { color: #f7b800; font-size: 1.4rem; font-weight: 850; letter-spacing: -0.08em; text-decoration: none; }
.toolbar nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar-button, .icon-button {
  color: #3d3a31; background: transparent; border: 1px solid #cfcabf; border-radius: 8px; min-height: 36px; padding: 0 10px;
}
.toolbar-button:disabled { cursor: not-allowed; opacity: .45; }
.toolbar-button:hover, .icon-button:hover, .toolbar-button.active { background: #f1eee7; border-color: #b8b1a4; color: #22242a; }
.toolbar-button[data-action="scroll-toggle"].active { background: #238636; border-color: #2ea043; color: white; }
.scroll-toggle { overflow: hidden; position: relative; }
.scroll-toggle::after {
  background: #d49d00;
  bottom: 0;
  content: "";
  height: 3px;
  left: 0;
  position: absolute;
  transition: width .15s ease;
  width: var(--scroll-progress, 0%);
}
.scroll-toggle.active::after { background: #b7f7c2; }
.icon-button:disabled { cursor: not-allowed; opacity: .4; }
.toolbar-divider { height: 28px; width: 1px; background: #d6d1c6; margin: 0 4px; }
.toolbar-zoom { align-items: center; display: inline-flex; gap: 2px; }
.toolbar-zoom-label { color: #cbd5e1; font-size: .78rem; font-weight: 700; margin: 0 2px 0 5px; }
.selection-note-button {
  position: fixed;
  z-index: 20;
  box-shadow: 0 3px 10px rgb(47 43 29 / 18%);
}
.icon-button { font-size: 1.25rem; min-width: 36px; }
.key-label { color: #6a5011; display: inline-flex; align-items: center; min-height: 36px; padding: 0 10px; font-variant-numeric: tabular-nums; }
.mobile-scroll-controls {
  align-items: center;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  z-index: 10;
}
.mobile-scroll-toggle,
.mobile-scroll-speed {
  align-items: center;
  border: 1px solid #cfcabf;
  border-radius: 50%;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  line-height: 1;
  padding: 0;
  text-align: center;
  box-shadow: 0 4px 12px rgb(15 23 42 / 28%);
}
.mobile-scroll-toggle {
  background: rgb(232 174 0 / 60%);
  color: #251f0d;
  height: 58px;
  width: 58px;
}
.mobile-scroll-toggle.active {
  background: rgb(35 134 54 / 60%);
  border-color: #2ea043;
  color: #052e16;
}
.mobile-scroll-speed {
  background: rgb(17 24 39 / 60%);
  border-color: #030712;
  color: #fff;
  font-size: 1.86rem;
  height: 41px;
  width: 41px;
  padding-bottom: 3px;
}
.mobile-scroll-icon {
  display: block;
  flex: 0 0 auto;
}
.mobile-scroll-icon-play {
  border-bottom: 13px solid transparent;
  border-left: 19px solid currentColor;
  border-top: 13px solid transparent;
  height: 0;
  margin-left: 4px;
  width: 0;
}
.mobile-scroll-icon-pause {
  display: inline-flex;
  gap: 7px;
  height: 25px;
  width: 19px;
}
.mobile-scroll-icon-pause::before,
.mobile-scroll-icon-pause::after {
  background: currentColor;
  border-radius: 3px;
  content: "";
  display: block;
  height: 25px;
  width: 6px;
}
.mobile-scroll-toggle:hover,
.mobile-scroll-speed:hover { filter: brightness(.96); }
.mobile-scroll-toggle:focus-visible,
.mobile-scroll-speed:focus-visible { outline: 3px solid #d49d00; outline-offset: 3px; }
.mobile-scroll-toggle:disabled,
.mobile-scroll-speed:disabled { cursor: not-allowed; opacity: .45; }

.landing, .reader { width: min(1120px, calc(100% - 36px)); margin: 0 auto; padding: 64px 0; }
.landing-intro { max-width: 600px; }
.eyebrow { color: #7c5e10; font-size: .75rem; font-weight: 800; letter-spacing: .13em; margin: 0 0 8px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2.25rem, 5vw, 4rem); line-height: 1; letter-spacing: -.055em; margin-bottom: 14px; }
h2 { font-size: 1.35rem; margin-bottom: 0; }
.landing-intro > p:last-child { color: #5d6067; font-size: 1.08rem; line-height: 1.55; }
.playlist-actions { align-items: end; display: flex; gap: 14px; justify-content: space-between; margin: 42px 0 26px; }
.search { flex: 1; max-width: none; }
.search span { display: block; font-size: .85rem; font-weight: 700; margin-bottom: 7px; }
.search input { background: white; border: 1px solid #dedbd0; border-radius: 9px; padding: 12px 14px; width: 100%; }
.primary-button, .secondary-button { border-radius: 9px; font-weight: 750; min-height: 43px; padding: 0 16px; }
.primary-button { background: #e8ae00; border: 1px solid #e8ae00; color: #251f0d; }
.secondary-button { background: white; border: 1px solid #d9d5c9; color: #3d3a31; }
.extension-download { align-items: center; display: inline-flex; text-decoration: none; }
.secondary-button:disabled { cursor: not-allowed; opacity: .55; }
.playlist-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.playlist-card { background: #fff; border: 1px solid #e4e0d6; border-radius: 12px; display: flex; min-height: 110px; overflow: hidden; }
.playlist-card.selected { border-color: #d49d00; box-shadow: 0 0 0 2px #f9e8b7; }
.playlist-open { align-items: center; background: none; border: 0; color: inherit; display: flex; flex: 1; gap: 14px; padding: 16px; text-align: left; }
.playlist-open strong, .playlist-open small { display: block; }
.playlist-open small { color: #73757a; margin-top: 5px; }
.playlist-art { align-items: center; background: #fae6a1; border-radius: 9px; color: #805a00; display: inline-flex; font-size: 1.5rem; height: 54px; justify-content: center; width: 54px; }
.delete-button { align-self: flex-start; background: transparent; border: 0; color: #a0a1a5; font-size: 1.5rem; padding: 8px 11px; }
.manage-link { text-decoration: none; }
.sync-status { color: #765615; font-size: .9rem; margin: 14px 0 0; width: 100%; }
.sync-progress { align-items: center; display: flex; gap: 12px; margin: 14px 0 0; width: 100%; }
.sync-progress-track { background: #efe9dc; border-radius: 999px; flex: 1; height: 8px; overflow: hidden; }
.sync-progress-bar { background: #b8860b; border-radius: 999px; height: 100%; transition: width .15s ease; }
.sync-progress-label { color: #765615; font-size: .9rem; white-space: nowrap; }
.song-results { border-top: 1px solid #ddd8cb; margin-top: 56px; padding-top: 26px; }
.song-row { align-items: center; background: white; border: 1px solid #e4e0d6; border-radius: 10px; display: flex; justify-content: space-between; margin-top: 18px; padding: 14px; gap: 16px; }
.song-row[data-action="open-song"] { cursor: pointer; }
.song-row[data-action="open-song"]:hover { background: #fffaf0; border-color: #d49d00; box-shadow: 0 4px 14px rgb(47 43 29 / 10%); transform: translateY(-1px); }
.song-row[data-action="open-song"]:focus-visible { outline: 3px solid #d49d00; outline-offset: 2px; }
.song-summary { flex: 1; min-width: 0; }
.song-row strong, .song-row span { display: block; }
.song-row span { color: #73757a; font-size: .9rem; margin-top: 4px; }
.empty-state { color: #73757a; }

.reader { max-width: 850px; padding-top: 42px; position: relative; }
.reader-with-notes { max-width: min(1120px, calc(100% - 36px)); padding-right: clamp(230px, 23vw, 280px); }
.reader-topbar { align-items: center; display: flex; justify-content: space-between; margin-bottom: 38px; min-height: 24px; position: relative; }
.back-link { background: none; border: 0; color: #6a5011; font-size: 1.15rem; font-weight: 700; padding: 0; }
.back-link:hover { color: #a87900; text-decoration: underline; text-underline-offset: 3px; }
.song-navigation { align-items: center; display: flex; gap: 10px; justify-content: flex-end; }
.song-nav-link, .song-nav-menu { background: transparent; border: 0; border-radius: 6px; color: #3d3a31; min-height: 28px; padding: 3px 6px; }
.song-nav-link { font-size: 1.15rem; }
.song-nav-link { max-width: 220px; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.song-nav-next { text-align: right; }
.song-nav-menu { color: #6a5011; font-size: 1.15rem; line-height: 1; min-width: 28px; padding: 3px 5px; }
.song-nav-link:hover, .song-nav-menu:hover, .song-nav-menu[aria-expanded="true"] { background: #fffaf0; color: #6a5011; }
.song-nav-link:disabled { cursor: not-allowed; opacity: .35; }
.song-navigation-menu { background: white; border: 1px solid #d9d5c9; border-radius: 12px; box-shadow: 0 12px 28px rgb(47 43 29 / 16%); max-height: min(60vh, 520px); overflow: hidden; position: absolute; right: 0; top: 42px; width: min(440px, calc(100vw - 36px)); z-index: 5; }
.song-navigation-menu-header { align-items: center; border-bottom: 1px solid #eeeae1; display: flex; justify-content: space-between; padding: 12px 14px; }
.song-navigation-menu-list { max-height: min(52vh, 460px); overflow-y: auto; padding: 6px; }
.song-navigation-item { background: transparent; border: 0; border-radius: 8px; display: block; padding: 10px 12px; text-align: left; width: 100%; }
.song-navigation-item:hover, .song-navigation-item.active { background: #fffaf0; }
.song-navigation-item strong, .song-navigation-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-navigation-item span { color: #73757a; font-size: .85rem; margin-top: 3px; }
.song-nav-link:focus-visible, .song-nav-menu:focus-visible, .back-link:focus-visible { outline: 2px solid #d49d00; outline-offset: 3px; }
.song-heading > p:not(.eyebrow) { color: #60636a; font-size: 1.2rem; }
.song-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 18px 0 12px; }
.song-controls label { align-items: center; color: #6b6e74; display: inline-flex; font-size: .85rem; font-weight: 700; gap: 8px; }
.song-controls select { background: #fff; border: 1px solid #d9d5c9; border-radius: 7px; color: #3d3a31; font: inherit; font-weight: 500; min-height: 34px; padding: 0 8px; }
.song-meta { color: #6b6e74; display: grid; font-size: .9rem; gap: 4px; }
.reader-notice { background: #fff7df; border: 1px solid #f1d27b; border-radius: 8px; color: #765615; font-size: .9rem; margin: 30px 0 18px; padding: 12px 14px; }
.chord-diagrams { display: flex; flex-wrap: wrap; gap: 18px 24px; margin: 28px 0 18px; }
.chord-diagram { margin: 0; width: 78px; }
.chord-diagram figcaption { color: #22242a; font-weight: 750; margin-bottom: 2px; text-align: center; }
.chord-diagram svg { display: block; height: 104px; overflow: visible; width: 78px; }
.diagram-grid line { stroke: #34383d; stroke-width: 1.4; }
.diagram-dot { fill: #34383d; }
.diagram-barre { fill: #34383d; }
.diagram-open { fill: #fff; stroke: #34383d; stroke-width: 1.4; }
.diagram-mark, .diagram-fret { fill: #34383d; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; text-anchor: middle; }
.diagram-fret { font-size: 9px; }
.diagram-finger { fill: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 7px; font-weight: 700; text-anchor: middle; }
.diagram-position { fill: #34383d; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; text-anchor: start; }
.tab-sheet { background: white; border: 1px solid #e2ded5; border-radius: 12px; box-shadow: 0 10px 30px rgb(47 43 29 / 5%); overflow: visible; padding: clamp(22px, 5vw, 52px); }
.editor-panel { background: #fff; border: 1px solid #e2ded5; border-radius: 12px; padding: 22px; }
.editor-help { color: #60636a; margin: 0 0 14px; }
.song-editor { box-sizing: border-box; display: block; font: 1rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; min-height: 60vh; padding: 16px; resize: vertical; width: 100%; }
.editor-actions { display: flex; gap: 10px; margin-top: 14px; }
.inline-note { align-items: start; background: #fffaf0; border: 1px solid #f1d27b; border-radius: 8px; display: flex; gap: 10px; justify-content: space-between; left: calc(100% + clamp(22px, 5vw, 52px) + 20px); max-height: 80px; overflow: auto; padding: 10px; position: absolute; top: calc(var(--note-index) * 72px); width: 220px; z-index: 1; }
.inline-note::before { border-top: 1px solid #d8b65d; content: ""; left: calc(-20px - clamp(22px, 5vw, 52px)); position: absolute; top: 16px; width: calc(20px + clamp(22px, 5vw, 52px)); }
.inline-note-lyric { top: calc(30px + var(--note-index) * 72px); }
.inline-note-section { top: calc(var(--note-index) * 72px); }
.inline-note strong { color: #765615; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.inline-note p { color: #31343a; font-size: .9rem; margin: 5px 0 0; white-space: pre-wrap; }
.note-remove { background: none; border: 0; color: #765615; cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 0; }
.note-anchor { background: #ffe08a; border-radius: 3px; color: inherit; padding: 0 2px; }
.song-section { margin-bottom: 42px; position: relative; }
.song-section:last-child { margin-bottom: 0; }
.song-section h3 { color: #777971; font-size: .95rem; letter-spacing: .12em; text-transform: uppercase; }
.lyric-line { margin: 0 0 6px; min-height: 36px; position: relative; }
.chord-line, .progression-row { display: flex; flex-wrap: wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; gap: 8px clamp(16px, 5vw, 56px); min-height: 23px; max-width: 100%; }
.chord-line { display: block; min-height: calc(27px * var(--content-zoom, 1)); overflow-x: clip; overflow-y: visible; position: relative; }
.chord-line.chord-only { overflow-x: clip; overflow-y: visible; }
.chord { background: #e5e7eb; border-radius: 4px; color: #b65609; font-size: calc(1rem * var(--content-zoom, 1)); font-weight: 750; min-width: 20px; padding: 1px 4px; position: absolute; white-space: nowrap; }
.lyric-line p { color: #31343a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: calc(1.02rem * var(--content-zoom, 1)); line-height: 1.55; margin: 2px 0 0; max-width: 100%; overflow-wrap: anywhere; white-space: pre-wrap; }
.chord-section { border-bottom: 1px solid #eeeae1; padding-bottom: 28px; }
.chord-section:last-child { border-bottom: 0; padding-bottom: 0; }
.chord-progression { display: grid; gap: 15px; }
.progression-row { background: #fbfaf7; border-radius: 7px; padding: 14px 16px; }
.source-link { color: #6a5011; display: inline-block; font-weight: 700; margin-top: 26px; }

@media (max-width: 720px) {
  .toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar nav { justify-content: flex-start; }
  .playlist-actions, .song-row { align-items: stretch; flex-direction: column; }
  .search { max-width: none; }
  .reader-topbar { gap: 8px; }
  .song-navigation { flex: 1; min-width: 0; }
  .song-nav-link { flex: 1; max-width: none; min-width: 0; }
  .inline-note { left: calc(100% + 22px + 20px); width: 200px; }
  .reader-with-notes { max-width: min(1120px, calc(100% - 36px)); padding-right: 0; }
  .reader-with-notes .inline-note { left: auto; right: 0; width: min(200px, calc(100vw - 52px)); }
}

[data-theme="dark"] {
  color-scheme: dark;
  background: #111827;
  color: #e5e7eb;
}

[data-theme="dark"] body { background: #111827; }
[data-theme="dark"] .toolbar { background: #0b1220; border-bottom-color: #1f2937; }
[data-theme="dark"] .toolbar-button,
[data-theme="dark"] .icon-button { border-color: #4b5563; color: #e5e7eb; }
[data-theme="dark"] .toolbar-divider { background: #4b5563; }
[data-theme="dark"] .key-label { color: #fbbf24; }
[data-theme="dark"] .toolbar-button:hover,
[data-theme="dark"] .icon-button:hover,
[data-theme="dark"] .toolbar-button.active { background: #263449; border-color: #40516b; }
[data-theme="dark"] .toolbar-button[data-action="scroll-toggle"].active { background: #238636; border-color: #2ea043; color: white; }
[data-theme="dark"] .mobile-scroll-speed { background: rgb(0 0 0 / 60%); border-color: #000; color: #fff; }
[data-theme="dark"] .mobile-scroll-toggle.active { background: rgb(35 134 54 / 85%); color: #fff; }
[data-theme="dark"] .search input,
[data-theme="dark"] .song-controls select,
[data-theme="dark"] .playlist-card,
[data-theme="dark"] .song-row,
[data-theme="dark"] .tab-sheet,
[data-theme="dark"] .editor-panel,
[data-theme="dark"] .song-navigation-menu,
[data-theme="dark"] .secondary-button { background: #1f2937; border-color: #374151; color: #e5e7eb; }
[data-theme="dark"] .search input { color: #e5e7eb; }
[data-theme="dark"] .playlist-card.selected { border-color: #d49d00; box-shadow: 0 0 0 2px #59460f; }
[data-theme="dark"] .playlist-open small,
[data-theme="dark"] .song-row span,
[data-theme="dark"] .song-navigation-item span,
[data-theme="dark"] .song-heading > p:not(.eyebrow),
[data-theme="dark"] .song-meta,
[data-theme="dark"] .landing-intro > p:last-child,
[data-theme="dark"] .empty-state,
[data-theme="dark"] .song-section h3,
[data-theme="dark"] .editor-help { color: #aeb6c2; }
[data-theme="dark"] .sync-status,
[data-theme="dark"] .sync-progress-label { color: #f4c44e; }
[data-theme="dark"] .song-row[data-action="open-song"]:hover,
[data-theme="dark"] .song-navigation-item:hover,
[data-theme="dark"] .song-navigation-item.active,
[data-theme="dark"] .song-nav-link:hover,
[data-theme="dark"] .song-nav-menu:hover,
[data-theme="dark"] .song-nav-menu[aria-expanded="true"] { background: #2b2412; }
[data-theme="dark"] .song-results,
[data-theme="dark"] .chord-section { border-color: #374151; }
[data-theme="dark"] .chord-diagram figcaption,
[data-theme="dark"] .lyric-line p { color: #e5e7eb; }
[data-theme="dark"] .diagram-grid line { stroke: #d1d5db; }
[data-theme="dark"] .diagram-dot,
[data-theme="dark"] .diagram-barre { fill: #d1d5db; }
[data-theme="dark"] .diagram-open { fill: #1f2937; stroke: #d1d5db; }
[data-theme="dark"] .diagram-mark,
[data-theme="dark"] .diagram-fret,
[data-theme="dark"] .diagram-position { fill: #d1d5db; }
[data-theme="dark"] .diagram-finger { fill: #1f2937; }
[data-theme="dark"] .chord { background: #374151; color: #f4b84c; }
[data-theme="dark"] .progression-row { background: #172033; }
[data-theme="dark"] .reader-notice,
[data-theme="dark"] .inline-note { background: #2b2412; border-color: #8a6814; color: #f5df9b; }
[data-theme="dark"] .inline-note p { color: #e5e7eb; }
[data-theme="dark"] .song-editor { background: #111827; border-color: #4b5563; color: #e5e7eb; }
[data-theme="dark"] .back-link,
[data-theme="dark"] .song-nav-link,
[data-theme="dark"] .song-nav-menu,
[data-theme="dark"] .source-link { color: #f4c44e; }
[data-theme="dark"] .eyebrow { color: #e8b83f; }
[data-theme="dark"] .note-anchor { background: #80651c; color: #fff4c4; }
[data-theme="dark"] .song-navigation-menu-header { border-color: #374151; }
[data-theme="dark"] .song-navigation-menu { box-shadow: 0 12px 28px rgb(0 0 0 / 40%); }
