:root {
  color-scheme: light;
  --ink: #171511;
  --paper: #ebe3d6;
  --panel: #fffaf1;
  --white: #fffdf9;
  --muted: #746f67;
  --line: #d8d0c3;
  --accent: #ed5a2a;
  --accent-dark: #a93a18;
  --green: #2e7d5b;
  --shadow: 0 18px 60px rgba(42, 35, 25, .12);
  --sheet-font-size: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { width: 100%; max-width: 100%; overflow-x: hidden; scroll-behavior: smooth; overscroll-behavior-x: none; }
body { width: 100%; max-width: 100%; margin: 0; overflow-x: hidden; color: var(--ink); background: var(--panel); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overscroll-behavior-x: none; }
main { width: 100%; min-width: 0; max-width: 100%; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid rgba(237, 90, 42, .32); outline-offset: 2px; }

.public-header { position: absolute; inset: 0 0 auto; z-index: 5; height: 76px; padding: 16px clamp(20px, 4vw, 58px); display: flex; align-items: center; justify-content: space-between; }
.mini-brand, .compact-brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.mini-brand img { width: 38px; height: 38px; }
.mini-brand strong, .mini-brand small { display: block; }
.mini-brand strong { font: 700 17px Georgia, serif; }
.mini-brand small { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }

.search-stage { width: 100%; min-width: 0; min-height: calc(100vh - 48px); min-height: calc(100dvh - 48px); padding: 24vh 20px 80px; display: flex; align-items: center; flex-direction: column; background-image: radial-gradient(circle at 50% 22%, rgba(237,90,42,.1), transparent 26%), linear-gradient(rgba(216,208,195,.18) 1px, transparent 1px), linear-gradient(90deg, rgba(216,208,195,.12) 1px, transparent 1px); background-size: auto, 32px 32px, 32px 32px; transition: padding .25s ease, min-height .25s ease; }
.search-brand { text-align: center; }
.search-brand img { display: block; margin: 0 auto 18px; }
.search-brand h1 { margin: 0; font: 700 clamp(46px, 7vw, 76px)/.95 Georgia, serif; letter-spacing: -.045em; }
.search-brand p { margin: 16px 0 34px; color: var(--muted); font-size: 17px; }
.search-shell { position: relative; width: min(720px, 100%); display: flex; align-items: center; gap: 10px; }
.compact-brand { display: none; flex: 0 0 auto; }
.search-control { position: relative; flex: 1; min-width: 0; }
.search-box { height: 62px; padding: 0 18px; display: flex; align-items: center; gap: 13px; background: var(--white); border: 1px solid #cfc4b4; border-radius: 17px; box-shadow: var(--shadow); transition: border-color .2s, box-shadow .2s; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 18px 60px rgba(42,35,25,.13), 0 0 0 4px rgba(237,90,42,.1); }
.search-box svg { width: 22px; flex: 0 0 auto; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.search-box input { width: 100%; min-width: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 17px; }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 32px; height: 32px; padding: 0; flex: 0 0 auto; color: var(--muted); background: transparent; border: 0; border-radius: 50%; cursor: pointer; font-size: 24px; }
.search-clear:hover { color: var(--ink); background: var(--paper); }
.search-submit { height: 54px; padding: 0 22px; color: var(--panel); background: var(--ink); border: 0; border-radius: 14px; cursor: pointer; font-weight: 800; }
.search-submit:hover { background: var(--accent-dark); }
.search-status { min-height: 20px; margin: 16px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.public-stats { margin: 8px 0 0; color: #9b9388; font-size: 11px; text-align: center; }

.suggestions { position: absolute; top: calc(100% + 9px); left: 0; right: 0; z-index: 30; max-height: min(520px, 60vh); overflow-y: auto; padding: 7px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 70px rgba(35,29,22,.18); }
.suggestion { width: 100%; padding: 12px 13px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 3px 14px; color: inherit; background: transparent; border: 0; border-radius: 9px; cursor: pointer; text-align: left; }
.suggestion:hover, .suggestion.active { background: #f7eee3; }
.suggestion strong { overflow: hidden; font: 700 17px Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.suggestion small { grid-column: 1; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.suggestion-meta { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); font-size: 10px; font-weight: 800; text-align: right; text-transform: uppercase; letter-spacing: .05em; }
.correction { display: block; margin-top: 3px; color: var(--accent-dark); font-size: 9px; }
.suggestion-empty { padding: 20px; color: var(--muted); font-size: 13px; text-align: center; }
.suggestion-group-title { margin: 4px 6px 2px; padding: 8px 7px 6px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); border-top: 1px solid var(--line); font-size: 9px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.suggestion-group-title:first-child { margin-top: 0; border-top: 0; }
.suggestion-group-title span { min-width: 22px; height: 22px; display: grid; place-items: center; color: var(--accent-dark); background: #f7dfd2; border-radius: 999px; letter-spacing: 0; }
.artist-suggestion { background: #f8f2e9; }
.artist-suggestion strong { color: var(--accent-dark); }
.artist-suggestion .suggestion-meta { color: var(--accent-dark); }

.suggestions-open:not(.reading) .search-stage { min-height: calc(100vh - 48px); padding-top: clamp(130px, 15vh, 210px); align-items: center; }
.suggestions-open:not(.reading) .search-shell { align-items: flex-start; }
.suggestions-open:not(.reading) .suggestions { position: static; max-height: none; margin-top: 9px; overflow: visible; }
.suggestions-open:not(.reading) .search-submit { margin-top: 4px; }

.reading .public-header { display: none; }
.reading .search-stage { position: sticky; top: 0; z-index: 20; min-height: 0; padding: 11px 20px; align-items: stretch; background: rgba(255,250,241,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.reading .search-brand, .reading .public-stats { display: none; }
.reading .search-shell { width: min(1120px, 100%); margin: 0 auto; }
.reading .compact-brand { display: inline-flex; }
.reading .search-box { height: 48px; border-radius: 13px; box-shadow: none; }
.reading .search-submit { height: 46px; }
.reading .search-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.reader-shell { width: 100%; min-width: 0; max-width: 100%; min-height: 80vh; padding: 44px clamp(18px, 4vw, 62px) 100px; overflow-x: hidden; background-color: var(--panel); background-image: linear-gradient(rgba(216,208,195,.17) 1px, transparent 1px), linear-gradient(90deg, rgba(216,208,195,.12) 1px, transparent 1px); background-size: 30px 30px; }
.song-reader { width: min(1320px, 100%); min-width: 0; max-width: 100%; margin: 0 auto; }
.breadcrumbs { margin-bottom: 22px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.breadcrumbs a { color: var(--accent-dark); text-decoration: none; font-weight: 800; }
.song-header { padding-bottom: 26px; display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; border-bottom: 2px solid var(--ink); }
.eyebrow { margin: 0 0 10px; color: var(--accent-dark); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .16em; }
.song-header h2 { margin: 0; font: 700 clamp(42px, 6vw, 74px)/.95 Georgia, serif; letter-spacing: -.035em; }
.composers { margin: 13px 0 0; color: var(--muted); font-size: 13px; }
.version-switcher { padding: 18px 0; border-bottom: 1px solid var(--line); }
.section-heading { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; }
.section-heading strong { color: var(--accent-dark); }
.version-list { display: flex; flex-wrap: wrap; gap: 7px; }
.version-button { padding: 8px 10px; display: inline-flex; gap: 8px; color: var(--muted); background: var(--white); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: 11px; }
.version-button.active { color: var(--panel); background: var(--ink); border-color: var(--ink); }
.version-key { font-weight: 900; }

.reader-toolbar { position: static; z-index: 15; margin: 18px 0; padding: 9px 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 0; background: rgba(235,227,214,.94); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 30px rgba(43,35,25,.08); backdrop-filter: blur(12px); }
.tool-cluster { min-height: 38px; padding: 0 12px; display: flex; align-items: center; flex: 0 0 auto; gap: 7px; border-right: 1px solid #ccc2b3; }
.tool-cluster:first-child { padding-left: 0; }
.tool-cluster:last-child { padding-right: 0; border-right: 0; }
.tool-label { color: var(--muted); font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.stepper { display: flex; overflow: hidden; background: var(--white); border: 1px solid #c9bdae; border-radius: 7px; }
.stepper button, .square-button, .layout-button { height: 34px; min-width: 34px; padding: 0 9px; color: var(--accent-dark); background: var(--white); border: 0; cursor: pointer; font-weight: 900; }
.stepper button:hover, .square-button:hover, .layout-button:hover { color: var(--panel); background: var(--accent); }
.stepper output { min-width: 52px; height: 34px; display: grid; place-items: center; color: var(--panel); background: var(--ink); font: 800 13px ui-monospace, monospace; }
.text-button, .tool-button { height: 34px; padding: 0 11px; color: var(--accent-dark); background: var(--white); border: 1px solid #d8b09b; border-radius: 7px; cursor: pointer; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.tool-button[aria-pressed="true"] { color: var(--panel); background: var(--accent); border-color: var(--accent); }
.primary-tool { color: var(--panel); background: var(--ink); border-color: var(--ink); }
.primary-tool:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.speed-control { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.speed-control input { width: 76px; accent-color: var(--accent); }
.font-output { min-width: 24px; color: var(--muted); font: 700 10px ui-monospace, monospace; text-align: center; }
.segmented-control { display: flex; overflow: hidden; background: var(--white); border: 1px solid #c9bdae; border-radius: 7px; }
.layout-button { border-left: 1px solid var(--line); }
.layout-button:first-child { border-left: 0; }
.layout-button.active { color: var(--panel); background: var(--ink); }
.view-status { max-width: 150px; overflow: hidden; color: var(--muted); font-size: 9px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.tool-button:disabled, .square-button:disabled { cursor: not-allowed; opacity: .38; }
.columns-mode #autoscroll-cluster { opacity: .45; }

.badges { padding: 2px 0 17px; display: flex; flex-wrap: wrap; gap: 7px; }
.badge { padding: 6px 9px; color: var(--muted); background: var(--white); border: 1px solid var(--line); border-radius: 5px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.badge.accent { color: var(--panel); background: var(--accent); border-color: var(--accent); }
.chord-index { padding: 17px 0; display: flex; align-items: flex-start; gap: 18px; border-block: 1px solid var(--line); }
.chord-index > span { padding-top: 5px; flex: 0 0 auto; color: var(--muted); font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: .09em; }
.chords { display: flex; flex-wrap: wrap; gap: 6px; }
.chord { min-width: 34px; padding: 4px 7px; color: var(--accent-dark); background: #f9e5da; border: 0; border-radius: 5px; font: 800 12px ui-monospace, monospace; text-align: center; }
.chord-trigger { cursor: pointer; transition: color .16s ease, background .16s ease, transform .16s ease; }
.chord-trigger:hover, .chord-trigger:focus-visible, .chord-trigger[aria-expanded="true"] { color: var(--panel); background: var(--accent-dark); outline: 0; transform: translateY(-1px); }
.chord-trigger:focus-visible { box-shadow: 0 0 0 3px rgba(229,83,38,.22); }
.chord-popover { position: fixed; z-index: 300; width: 184px; padding: 14px 12px 11px; color: var(--ink); background: rgba(255,253,249,.98); border: 1px solid #d7cdbf; border-radius: 12px; box-shadow: 0 18px 50px rgba(30,24,17,.2); pointer-events: none; }
.chord-popover[hidden] { display: none; }
.chord-diagram { display: grid; justify-items: center; }
.chord-diagram-title { margin-bottom: 2px; font: 800 18px/1.1 ui-monospace, monospace; letter-spacing: -.03em; }
.chord-diagram-svg { width: 164px; height: 174px; overflow: visible; }
.chord-fret, .chord-string { stroke: #776f66; stroke-width: 1.25; }
.chord-nut { stroke: var(--ink); stroke-width: 5; }
.chord-barre { stroke: var(--ink); stroke-width: 15; stroke-linecap: round; }
.chord-finger { fill: var(--ink); }
.chord-string-marker { fill: var(--muted); font: 700 15px ui-monospace, monospace; text-anchor: middle; }
.chord-fret-number { fill: var(--muted); font: 700 10px ui-monospace, monospace; text-anchor: middle; }
.chord-diagram-unavailable { max-width: 145px; padding: 16px 6px 7px; color: var(--muted); font-size: 11px; line-height: 1.35; text-align: center; }

.sheet-grid { width: 100%; min-width: 0; max-width: 100%; margin-top: 24px; display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 16px; }
.sheet-page { width: 100%; min-width: 0; max-width: 100%; margin: 0; padding: clamp(20px, 3vw, 38px); overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; color: #25211c; background: rgba(255,253,249,.9); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 12px 34px rgba(38,31,23,.07); font: 500 var(--sheet-font-size)/1.58 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; white-space: pre; tab-size: 4; }
.columns-mode .sheet-grid { gap: 8px; }
.columns-mode .sheet-page { padding: clamp(7px, .8vw, 12px); overflow: hidden; line-height: 1.25; }
.public-footer { min-height: 48px; padding: 12px 20px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); background: var(--paper); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.focus-mode { background: var(--white); }
.focus-mode .search-stage, .focus-mode .public-footer,
.focus-mode .breadcrumbs, .focus-mode .song-header,
.focus-mode .version-switcher, .focus-mode .badges,
.focus-mode .chord-index { display: none; }
.focus-mode .reader-shell { min-height: 100vh; min-height: 100dvh; padding: 0; background: var(--white); }
.focus-mode .song-reader { width: 100%; max-width: none; }
.focus-mode .reader-toolbar { position: fixed; top: auto; right: auto; bottom: 10px; left: 50%; z-index: 100; width: max-content; max-width: calc(100vw - 20px); margin: 0; transform: translateX(-50%); transition: opacity .22s ease, transform .22s ease; }
.focus-mode .reader-toolbar, .columns-mode .reader-toolbar { overflow-x: auto; }
.focus-mode.controls-hidden .reader-toolbar { opacity: 0; pointer-events: none; transform: translate(-50%, 16px); }
.focus-mode .sheet-grid { width: 100%; max-width: 100vw; min-height: 100vh; min-height: 100dvh; margin: 0; padding: 4px; overflow-x: hidden; gap: 6px; background: var(--ink); }
.focus-mode .sheet-page { width: 100%; max-width: 100%; min-height: calc(100vh - 8px); min-height: calc(100dvh - 8px); padding: 10px 12px; background: var(--white); border: 0; border-radius: 0; box-shadow: none; }
.focus-mode.columns-mode .sheet-page { padding: 8px 10px; }
.focus-mode .primary-tool { color: var(--panel); background: var(--accent); border-color: var(--accent); }

body.columns-mode { overflow: hidden; background: var(--white); }
.columns-mode .search-stage, .columns-mode .public-footer,
.columns-mode .breadcrumbs, .columns-mode .song-header,
.columns-mode .version-switcher, .columns-mode .badges,
.columns-mode .chord-index { display: none; }
.columns-mode .reader-shell { height: 100vh; min-height: 100vh; padding: 0; overflow: hidden; background: var(--white); }
.columns-mode .song-reader { width: 100%; max-width: none; }
.columns-mode .reader-toolbar { position: fixed; top: auto; right: auto; bottom: 10px; left: 50%; z-index: 100; width: max-content; max-width: calc(100vw - 20px); margin: 0; transform: translateX(-50%); transition: opacity .22s ease, transform .22s ease; }
.columns-mode.controls-hidden .reader-toolbar { opacity: 0; pointer-events: none; transform: translate(-50%, 16px); }
.columns-mode .sheet-grid { height: 100vh; min-height: 100vh; margin: 0; padding: 4px; gap: 6px; overflow: hidden; background: var(--ink); }
.columns-mode .sheet-page { height: calc(100vh - 8px); min-height: 0; padding: 7px 9px; background: var(--white); border: 0; border-radius: 0; box-shadow: none; }

@media (max-width: 900px) {
  .public-header { padding-inline: 18px; }
  .mini-brand small { display: none; }
  .search-stage { padding-top: 20vh; }
  .search-submit { display: none; }
  .reading .search-stage { padding-inline: 10px; }
  .reading .compact-brand img { width: 38px; height: 38px; }
  .reader-shell { padding-inline: 14px; }
  .song-header { display: block; }
  .reader-toolbar { width: 100%; max-width: 100%; position: static; overflow: visible; }
  .reader-toolbar::-webkit-scrollbar { display: none; }
  .focus-mode .reader-toolbar, .columns-mode .reader-toolbar { position: fixed; top: auto; right: auto; bottom: calc(72px + env(safe-area-inset-bottom)); left: 8px; width: calc(100vw - 16px); max-width: none; overflow-x: auto; flex-wrap: nowrap; transform: none; }
  .focus-mode.controls-hidden .reader-toolbar, .columns-mode.controls-hidden .reader-toolbar { transform: translateY(16px); }
  .tool-cluster { border-right: 0; }
  .song-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 1280px) and (min-width: 901px) {
  .reader-toolbar { flex-wrap: wrap; row-gap: 8px; }
  .layout-control { border-right: 0; }
}

@media (max-width: 540px) {
  .public-header { height: 64px; padding: 12px 14px; }
  .mini-brand img { width: 34px; height: 34px; }
  .mini-brand strong { font-size: 16px; }
  .search-stage { min-height: 100dvh; padding: max(112px, 18dvh) 12px 48px; }
  .search-brand img { width: 58px; height: 58px; margin-bottom: 14px; }
  .search-brand h1 { font-size: 40px; }
  .search-brand p { margin: 12px 0 26px; font-size: 13px; }
  .search-shell { width: 100%; gap: 0; }
  .search-box { height: 54px; padding: 0 13px; gap: 10px; border-radius: 14px; }
  .search-box input { font-size: 16px; }
  .search-box svg { width: 20px; }
  .search-clear { width: 38px; height: 38px; }
  .suggestion { min-height: 60px; padding: 11px 10px; gap: 3px 8px; }
  .suggestion-group-title { position: sticky; top: 0; z-index: 1; margin-inline: 2px; background: var(--white); }
  .suggestion strong { font-size: 16px; }
  .suggestion-meta { font-size: 9px; }
  .suggestions-open:not(.reading) .search-stage { padding-top: 78px; }
  .suggestions-open:not(.reading) .search-brand { display: none; }
  .reading .search-stage { padding: 8px; }
  .reading .search-box { height: 50px; border-radius: 12px; }
  .reading .suggestions { position: fixed; top: 66px; right: 8px; left: 8px; width: auto; max-height: calc(100dvh - 78px); margin: 0; }
  .compact-brand { display: none !important; }
  .song-header h2 { font-size: 42px; }
  .reader-shell { padding: 28px 10px 72px; }
  .reader-toolbar { margin: 14px 0; padding: 7px; gap: 6px 2px; border-radius: 10px; touch-action: pan-y; }
  .performance-cluster, .focus-mode .performance-cluster { width: auto; }
  .tool-cluster { width: auto; padding: 0 5px; }
  .tool-cluster:first-child { padding-left: 0; }
  .tool-cluster:last-child { padding-right: 0; }
  .text-button, .tool-button { padding-inline: 9px; white-space: nowrap; }
  .speed-control { display: none; }
  .layout-control { display: none; }
  .chord-index { display: block; }
  .chord-index > span { display: block; margin-bottom: 10px; }
  .sheet-grid { margin-top: 14px; }
  .sheet-page { padding: 15px 10px; line-height: 1.5; }
  .focus-mode .sheet-page { padding: 10px 8px; }
  .focus-mode .reader-toolbar, .columns-mode .reader-toolbar { padding: 7px; touch-action: pan-x; }
  .public-footer { padding-inline: 12px; font-size: 8px; text-align: center; }
}

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