:root {
  color-scheme: light;
  --paper: #f3efe5;
  --paper-deep: #e9e3d6;
  --ink: #191d1a;
  --muted: #686e68;
  --line: #d7d0c2;
  --line-strong: #b9b1a3;
  --card: #fffdf8;
  --coral: #e85f43;
  --coral-dark: #c94b34;
  --sage: #5d7463;
  --sage-soft: #e5ece4;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.77, 0, .175, 1);
  --ease-drawer: cubic-bezier(.32, .72, 0, 1);
  font-family: "Manrope", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(232, 95, 67, .26); outline-offset: 3px; }
svg { display: block; }

.app-shell { min-height: 100vh; overflow: clip; background: radial-gradient(circle at 12% 8%, rgba(232, 95, 67, .12), transparent 25rem), linear-gradient(180deg, rgba(255,255,255,.24), transparent 42rem); }
.topbar { position: sticky; z-index: 10; top: 0; height: 72px; padding: 0 clamp(18px, 5vw, 64px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(215, 208, 194, .74); background: rgba(243, 239, 229, .82); backdrop-filter: saturate(140%) blur(18px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: -.035em; }
.brand-mark { position: relative; width: 36px; aspect-ratio: 1; overflow: hidden; border-radius: 50%; background: var(--ink); box-shadow: inset 0 1px rgba(255,255,255,.18); }
.brand-mark::before { content: ""; position: absolute; z-index: 1; width: 13px; height: 13px; top: 50%; left: 50%; border: 2px solid var(--coral); border-radius: 50%; box-shadow: inset 0 0 0 2px var(--ink), 0 0 0 1px rgba(255,255,255,.24); transform: translate(-50%, -50%); }
.brand-mark::after { content: ""; position: absolute; z-index: 2; inset: 7px 0; background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(255,255,255,.86) 3px 4px); transform: rotate(-9deg); }
.top-actions { display: flex; align-items: center; gap: 24px; }
.save-state { color: var(--muted); font-size: 11px; font-weight: 600; }
.save-state i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #579068; box-shadow: 0 0 0 4px rgba(87, 144, 104, .1); }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 12px; padding: 0 18px; font-weight: 750; letter-spacing: -.015em; transition: transform 160ms var(--ease-out), background-color 180ms var(--ease-out), border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out), color 180ms var(--ease-out); }
.button:active:not(:disabled) { transform: scale(.97); }
.button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button-dark { color: white; background: var(--ink); box-shadow: 0 6px 18px rgba(25, 29, 26, .14); }
.button-coral { color: white; background: var(--coral); box-shadow: 0 8px 22px rgba(232, 95, 67, .2); white-space: nowrap; }
.button-outline { border: 1px solid var(--line); background: rgba(255, 253, 248, .45); color: var(--ink); }
.button-meter { width: 15px; height: 15px; display: none; align-items: center; justify-content: center; gap: 2px; }
.button-meter i { width: 2px; height: 12px; border-radius: 3px; background: currentColor; transform-origin: center; animation: meter-beat 540ms var(--ease-in-out) infinite alternate; }
.button-meter i:nth-child(2) { height: 8px; animation-delay: -180ms; }
.button-meter i:nth-child(3) { height: 5px; animation-delay: -360ms; }
.button.is-busy .button-meter { display: flex; }
.button.is-busy > svg { display: none; }

.hero { position: relative; max-width: 1040px; margin: 0 auto; padding: clamp(48px, 6vw, 72px) 24px clamp(42px, 5vw, 62px); text-align: center; }
.hero-score { position: absolute; z-index: 0; top: 36px; left: 50%; width: min(1120px, 112vw); height: 220px; color: var(--sage); opacity: .38; transform: translateX(-50%); pointer-events: none; clip-path: inset(0 0 0 0); animation: score-reveal 560ms var(--ease-in-out) both; }
.hero-score svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.staff-lines { fill: none; stroke: currentColor; stroke-width: 1; opacity: .38; }
.score-note { fill: currentColor; stroke: currentColor; stroke-width: 3; stroke-linecap: round; opacity: .62; transform-box: fill-box; transform-origin: center bottom; animation: note-land 240ms var(--ease-out) both; }
.score-note.note-one { animation-delay: 70ms; }
.score-note.note-two { animation-delay: 115ms; }
.score-note.note-three { animation-delay: 160ms; }
.score-note.note-four { animation-delay: 205ms; }
.score-signature { position: absolute; top: 76px; left: 3.5%; font: 600 20px/.72 "Newsreader", serif; }
.score-chord { position: absolute; top: 42px; padding: 3px 7px; border: 1px solid currentColor; border-radius: 6px; background: rgba(243,239,229,.82); font: 600 11px "DM Mono", monospace; opacity: .88; animation: chord-land 240ms var(--ease-out) both; }
.score-chord.chord-one { left: 7%; animation-delay: 90ms; }
.score-chord.chord-two { left: 25%; animation-delay: 135ms; }
.score-chord.chord-three { left: 71%; animation-delay: 180ms; }
.score-chord.chord-four { left: 88%; animation-delay: 225ms; }
.hero-copy, .url-form { position: relative; z-index: 1; }
.hero-copy { animation: hero-enter 280ms 60ms var(--ease-out) both; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 16px; color: var(--sage); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.eyebrow span { width: 27px; height: 27px; display: grid; place-items: center; border: 1px solid #aeb9af; border-radius: 50%; font-size: 13px; }
.hero h1 { margin: 0; font: 600 clamp(46px, 5.6vw, 68px)/.95 "Newsreader", Georgia, serif; letter-spacing: -.052em; }
.hero h1 em { color: var(--coral); font-weight: inherit; }
.hero-copy > p { max-width: 680px; margin: 18px auto 26px; color: var(--muted); font-size: clamp(14px, 1.6vw, 17px); line-height: 1.55; }
.url-form { max-width: 820px; margin: 0 auto; text-align: left; animation: form-enter 280ms 120ms var(--ease-out) both; }
.url-form > label { display: block; margin: 0 0 9px 4px; font-size: 11px; font-weight: 800; }
.url-field { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 7px 7px 7px 10px; border: 1px solid #c9c1b2; border-radius: 17px; background: rgba(255, 253, 248, .94); box-shadow: 0 18px 50px rgba(55, 47, 33, .1), 0 2px 5px rgba(55,47,33,.04); transition: border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out); }
.url-field:focus-within { border-color: var(--coral); box-shadow: 0 18px 50px rgba(55,47,33,.11), 0 0 0 4px rgba(232,95,67,.1); }
.source-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #f7e9e4; color: var(--coral); }
.source-icon svg { width: 17px; height: 17px; fill: currentColor; }
.url-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.url-field input::placeholder { color: #969990; }
.url-form small { display: block; min-height: 16px; margin: 10px 0 0 4px; color: #7d817c; font-size: 10px; line-height: 1.5; }
.hero-flow { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; color: var(--muted); font-size: 10px; font-weight: 650; }
.hero-flow span { display: inline-flex; align-items: center; gap: 6px; }
.hero-flow b { color: var(--coral); font: 500 10px "DM Mono", monospace; }
.hero-flow i { width: 20px; height: 1px; background: var(--line-strong); }
.has-repertoire .hero { padding-top: 28px; padding-bottom: 32px; }
.has-repertoire .hero-copy { display: none; }
.has-repertoire .hero-score { top: 0; height: 150px; opacity: .2; }

.workspace { position: relative; padding: 54px max(20px, calc((100vw - 1160px) / 2)) 100px; border-top: 1px solid var(--line); background: linear-gradient(180deg, #ebe5d9, var(--paper-deep)); }
.workspace::before { content: ""; position: absolute; top: 43px; right: max(20px, calc((100vw - 1160px) / 2)); width: min(28vw, 300px); height: 45px; opacity: .18; background: repeating-linear-gradient(to bottom, transparent 0 8px, var(--sage) 8px 9px); mask-image: linear-gradient(to right, transparent, black 32%); pointer-events: none; }
.section-heading { position: relative; z-index: 1; display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.section-heading p { margin: 0 0 6px; color: var(--coral); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.section-heading h2 { margin: 0; font: 600 34px/1.05 "Newsreader", serif; letter-spacing: -.03em; }
.section-heading h2 span { margin-left: 8px; color: var(--muted); font: 600 11px/1 "Manrope", sans-serif; letter-spacing: 0; }
.empty-state { min-height: 170px; display: grid; place-content: center; justify-items: center; padding: 26px; border: 1px dashed #bfb7aa; border-radius: 22px; background: rgba(255, 253, 248, .48); text-align: center; }
.empty-icon { position: relative; width: 48px; aspect-ratio: 1; display: grid; place-items: center; margin-bottom: 12px; border-radius: 50%; background: repeating-radial-gradient(circle, #2b302c 0 2px, var(--ink) 3px 6px); color: white; font-size: 18px; box-shadow: 5px 5px 0 var(--coral); }
.empty-icon i { position: absolute; width: 13px; height: 13px; border: 4px solid #d7c9aa; border-radius: 50%; background: var(--coral); }
.empty-icon span { position: relative; z-index: 1; transform: translate(14px, -12px); }
.empty-state h3 { margin: 0 0 6px; font: 600 21px "Newsreader", serif; letter-spacing: -.02em; }
.empty-state p { max-width: 520px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

.repertoire-grid { grid-template-columns: minmax(0, 1fr) 410px; gap: 26px; align-items: start; }
.repertoire-grid:not([hidden]) { display: grid; }
.song-list { display: grid; gap: 10px; }
.song-card { position: relative; display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; align-items: center; gap: 15px; min-height: 94px; padding: 14px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 253, 248, .9); box-shadow: 0 6px 18px rgba(55,47,33,.035); transition: border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out), background-color 180ms var(--ease-out); }
.song-card::before { content: ""; position: absolute; inset: 8px auto 8px 0; width: 3px; border-radius: 0 4px 4px 0; background: var(--coral); opacity: 0; transform: scaleY(.35); transition: opacity 180ms var(--ease-out), transform 220ms var(--ease-out); }
.song-card.is-selected { border-color: #b7ad9f; background: var(--card); box-shadow: 0 12px 28px rgba(55,47,33,.08); }
.song-card.is-selected::before { opacity: 1; transform: scaleY(1); }
.song-number { position: relative; isolation: isolate; width: 44px; height: 44px; display: grid; place-items: center; overflow: hidden; border: 1px solid #d8cfbf; border-radius: 12px; background: #f0ebe1; color: #405447; font: 700 16px "DM Mono", monospace; text-shadow: 0 1px rgba(255,255,255,.8); }
.song-number::before { content: ""; position: absolute; z-index: -1; inset: 5px; opacity: .28; background: repeating-linear-gradient(to right, transparent 0 4px, var(--sage) 4px 5px), repeating-linear-gradient(to bottom, transparent 0 7px, var(--sage) 7px 8px); }
.song-copy { min-width: 0; }
.song-copy h3 { margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 20px "Newsreader", serif; letter-spacing: -.02em; }
.song-copy p { margin: 0; color: var(--muted); font-size: 11px; }
.song-copy .song-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.pill { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 99px; background: #f0ece3; color: #656b65; font-size: 9px; font-weight: 750; }
.pill.key { background: var(--sage-soft); color: #486050; }
.song-actions { display: flex; align-items: center; gap: 2px; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 11px; background: transparent; color: var(--muted); transition: transform 160ms var(--ease-out), background-color 160ms var(--ease-out), color 160ms var(--ease-out); }
.icon-button:active:not(:disabled) { transform: scale(.92); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.move-buttons { display: flex; }
.move-buttons .icon-button { width: 36px; }

.preview-panel { position: sticky; top: 96px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 253, 248, .68); box-shadow: 0 14px 38px rgba(55,47,33,.06); backdrop-filter: blur(14px); }
.preview-toolbar { display: flex; justify-content: space-between; padding: 2px 3px; margin-bottom: 11px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.page-preview { aspect-ratio: 210 / 297; overflow: hidden; padding: 25px 22px; background: white; box-shadow: 0 12px 30px rgba(49,43,31,.13); color: #191919; transition: opacity 160ms var(--ease-out); }
.preview-title { padding-bottom: 8px; border-bottom: 1px solid #bbb; }
.preview-title h3 { margin: 0; font: 600 18px/1.1 "Newsreader", serif; }
.preview-title p { margin: 3px 0 0; color: #666; font-size: 7px; }
.preview-content { display: grid; gap: 8px; margin-top: 12px; }
.preview-content pre { min-width: 0; margin: 0; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; font-family: "DM Mono", monospace; font-size: calc(5.8px * var(--preview-font-scale, 1)); line-height: 1.38; }
.preview-panel > p { margin: 12px 5px 1px; color: var(--muted); font-size: 9px; line-height: 1.5; text-align: center; }

.modal { width: 100%; max-width: none; height: 100%; max-height: none; padding: 24px; border: 0; opacity: 0; background: transparent; transition: opacity 180ms var(--ease-out), display 180ms allow-discrete; }
.modal::backdrop { opacity: 0; background: rgba(20, 23, 20, .58); backdrop-filter: blur(6px); transition: opacity 180ms var(--ease-out), display 180ms allow-discrete; }
.modal[open] { display: grid; place-items: center; }
.modal.is-ready { opacity: 1; }
.modal.is-ready::backdrop { opacity: 1; }
.modal-card { position: relative; width: min(100%, 660px); max-height: calc(100dvh - 48px); overflow: auto; padding: 34px; border: 1px solid rgba(226, 221, 210, .9); border-radius: 22px; background: var(--card); box-shadow: 0 28px 90px rgba(20,22,19,.28); opacity: 0; transform: translateY(10px) scale(.96); transform-origin: center; transition: opacity 220ms var(--ease-out), transform 240ms var(--ease-out); scrollbar-width: thin; }
.modal.is-ready .modal-card { opacity: 1; transform: translateY(0) scale(1); }
.results-card { width: min(100%, 720px); padding-bottom: 0; }
.modal-close { position: absolute; z-index: 2; top: 14px; right: 14px; background: #f1ece3; color: var(--ink); }
.modal-kicker { margin: 0 0 8px; color: var(--coral); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.modal h2 { max-width: calc(100% - 44px); margin: 0; font: 600 32px/1.04 "Newsreader", serif; letter-spacing: -.03em; }
.modal-lead { margin: 10px 0 22px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.candidate-list { display: grid; gap: 9px; }
.candidate-group { display: grid; gap: 9px; }
.candidate-group + .candidate-group { margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.candidate-group > header { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-bottom: 2px; }
.candidate-group > header > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: #eee9df; color: var(--sage); font-size: 10px; font-weight: 800; }
.candidate-group > header h3 { margin: 0; font: 600 18px/1.1 "Newsreader", serif; }
.candidate-group > header p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.candidate-group > header strong { color: #4d7654; font-size: 10px; }
.candidate-group.is-added { padding: 12px; border: 1px solid #cbd8ca; border-radius: 13px; background: #f0f5ef; }
.candidate-group.is-added + .candidate-group { margin-top: 0; }
.candidate { width: 100%; min-width: 0; min-height: 64px; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: white; color: var(--ink); text-align: left; transition: border-color 180ms var(--ease-out), background-color 180ms var(--ease-out), transform 160ms var(--ease-out); }
.candidate:active:not(:disabled) { transform: scale(.985); }
.candidate > span { min-width: 0; }
.candidate-logo { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50% 50% 48% 52% / 42% 42% 58% 58%; background: #eee9df; color: var(--coral); font-weight: 800; transform: rotate(-8deg); }
.candidate-logo + span { transform: translateZ(0); }
.candidate strong { display: block; overflow-wrap: anywhere; font-size: 12px; }
.candidate small { color: var(--muted); font-size: 10px; }
.candidate > span:last-child { color: var(--coral); }
.candidate.is-loading { opacity: .55; pointer-events: none; }
.candidate-empty { padding: 24px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); font-size: 12px; text-align: center; }
.group-manual { min-height: 42px; justify-self: start; border: 0; background: transparent; color: var(--muted); font-size: 10px; text-decoration: underline; text-underline-offset: 3px; }
.modal-footer { margin-top: 18px; text-align: center; }
.text-button { min-height: 42px; border: 0; background: transparent; color: var(--muted); font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.results-dock { position: sticky; z-index: 4; bottom: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; margin: 18px -34px 0; padding: 14px 34px 18px; border-top: 1px solid rgba(215,208,194,.78); background: rgba(255,253,248,.94); box-shadow: 0 -12px 28px rgba(55,47,33,.07); backdrop-filter: saturate(140%) blur(16px); }
.selection-progress { min-width: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.selection-progress strong, .selection-progress span { display: block; }
.selection-progress strong { margin-bottom: 2px; color: var(--ink); font-size: 12px; }
.results-dock .button { min-width: 176px; }
.form-grid { display: grid; grid-template-columns: 1fr 90px 140px; gap: 15px; margin-top: 24px; }
.form-grid label { display: grid; gap: 7px; color: #555b55; font-size: 10px; font-weight: 800; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .span-two { grid-column: span 2; }
.form-grid input, .form-grid textarea, .form-grid select { width: 100%; border: 1px solid #d4cfc3; border-radius: 10px; outline: 0; background: white; color: var(--ink); transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out); }
.form-grid input, .form-grid select { height: 44px; padding: 0 12px; }
.form-grid textarea { min-height: 290px; resize: vertical; padding: 14px; font: 12px/1.5 "DM Mono", monospace; }
.form-grid input:focus, .form-grid textarea:focus, .form-grid select:focus { border-color: var(--coral); box-shadow: 0 0 0 4px rgba(232,95,67,.1); }
.editor-hint { margin-top: 10px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.editor-hint span { margin-right: 5px; color: var(--sage); }
.layout-estimate { margin-top: 12px; padding: 11px 12px; border-radius: 10px; background: var(--sage-soft); color: #47604d; font-size: 10px; font-weight: 750; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.pdf-card { width: min(100%, 520px); }
.pdf-file { display: flex; align-items: center; gap: 14px; margin-top: 24px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.pdf-file-icon { position: relative; width: 48px; height: 56px; display: grid; place-items: center; flex: 0 0 auto; overflow: hidden; border: 1px solid #cabfb2; border-radius: 9px; color: var(--coral); background: repeating-linear-gradient(to bottom, transparent 0 7px, rgba(93,116,99,.16) 7px 8px), white; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.pdf-file-icon::after { content: ""; position: absolute; top: -1px; right: -1px; border-style: solid; border-width: 0 12px 12px 0; border-color: transparent var(--paper-deep) transparent transparent; }
.pdf-file strong, .pdf-file small { display: block; }
.pdf-file strong { margin-bottom: 4px; overflow-wrap: anywhere; font-size: 13px; }
.pdf-file small { color: var(--muted); font-size: 10px; }
.share-guidance { display: flex; align-items: flex-start; gap: 11px; margin-top: 14px; padding: 13px 14px; border-radius: 12px; background: var(--sage-soft); color: #47604d; }
.share-guidance > span { width: 24px; height: 24px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid #aebbad; border-radius: 50%; font-size: 12px; font-weight: 700; }
.share-guidance p { margin: 0; font-size: 10px; line-height: 1.55; }
.share-guidance.is-fallback { background: #f1ece2; color: #695f51; }
.toast { position: fixed; z-index: 30; right: 24px; bottom: 24px; max-width: 360px; padding: 14px 17px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; background: var(--ink); color: white; box-shadow: 0 16px 45px rgba(0,0,0,.22); font-size: 11px; line-height: 1.45; opacity: 0; transform: translateY(14px) scale(.98); pointer-events: none; transition: opacity 200ms var(--ease-out), transform 240ms var(--ease-out); }
.toast.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.toast.is-error { background: #933d2e; }
.print-root { display: none; }

@keyframes meter-beat { 50% { transform: scaleY(.35); } }
@keyframes score-reveal { from { opacity: 0; clip-path: inset(0 100% 0 0); } }
@keyframes note-land { from { opacity: 0; transform: translateY(-10px) scale(.94); } }
@keyframes chord-land { from { opacity: 0; transform: translateY(-8px) scale(.96); } }
@keyframes hero-enter { from { opacity: 0; transform: translateY(10px); } }
@keyframes form-enter { from { opacity: 0; transform: translateY(12px); } }

@page { size: A4 portrait; margin: 0; }
@media print {
  body { background: white; }
  .app-shell, .modal, .toast { display: none !important; }
  .print-root { display: block; }
  .print-song { width: 210mm; height: 297mm; overflow: hidden; break-after: page; page-break-after: always; padding: 12mm 12mm 10mm; color: #151515; background: white; }
  .print-song:last-child { break-after: auto; page-break-after: auto; }
  .print-header { display: grid; grid-template-columns: 11mm 1fr auto; gap: 4mm; align-items: start; padding-bottom: 3mm; border-bottom: .25mm solid #aaa; }
  .print-number { width: 9mm; height: 9mm; display: grid; place-items: center; border: .25mm solid #202420; border-radius: 2mm; background: white; color: #202420; font: 700 9pt "Manrope", sans-serif; }
  .print-header h1 { margin: 0; font: 600 18pt/1 "Newsreader", Georgia, serif; }
  .print-header p { margin: 1.2mm 0 0; color: #555; font: 8pt "Manrope", sans-serif; }
  .print-key { padding: 1.5mm 2.4mm; border-radius: 9mm; background: #e8eee7; color: #415a46; font: 700 7.5pt "Manrope", sans-serif; }
  .print-columns { display: grid; gap: 5mm; margin-top: 4mm; }
  .print-columns pre { min-width: 0; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: "DM Mono", "Courier New", monospace; }
  .print-song[data-columns="1"] .print-columns pre { font-size: calc(9pt * var(--print-font-scale, 1)); line-height: 1.34; }
  .print-song[data-columns="2"] .print-columns pre { font-size: calc(7.6pt * var(--print-font-scale, 1)); line-height: 1.3; }
  .print-song[data-columns="3"] .print-columns pre { font-size: calc(6.5pt * var(--print-font-scale, 1)); line-height: 1.24; }
  .print-footer { position: absolute; left: 12mm; right: 12mm; bottom: 6mm; display: flex; justify-content: space-between; color: #999; font: 6.5pt "Manrope", sans-serif; }
  .print-song { position: relative; }
}

@media (hover: hover) and (pointer: fine) {
  .button:not(:disabled):hover { transform: translateY(-1px); }
  .button-dark:hover { background: #2a302b; box-shadow: 0 9px 24px rgba(25,29,26,.2); }
  .button-coral:hover { background: var(--coral-dark); box-shadow: 0 10px 26px rgba(232,95,67,.26); }
  .button-outline:hover { border-color: var(--line-strong); background: var(--card); }
  .icon-button:hover { background: #eee9df; color: var(--ink); }
  .song-card:hover { border-color: #bbb2a4; background: var(--card); }
  .candidate:hover { border-color: var(--coral); background: #fffaf7; }
}

@media (max-width: 820px) {
  .save-state { display: none; }
  .repertoire-grid:not([hidden]) { display: block; }
  .preview-panel { display: none; }
}

@media (max-width: 680px) {
  .topbar { height: 64px; padding: 0 14px; }
  .brand { gap: 9px; font-size: 14px; }
  .brand-mark { width: 33px; }
  .top-actions { gap: 8px; }
  .topbar .button { min-height: 40px; padding: 0 13px; border-radius: 11px; font-size: 12px; }
  .topbar .button svg { width: 15px; }
  .hero { padding: 24px 16px 28px; }
  .hero-score { top: 18px; width: 155vw; height: 180px; opacity: .3; }
  .score-signature { left: 18%; }
  .score-chord.chord-one { left: 21%; }
  .score-chord.chord-two { left: 42%; }
  .score-chord.chord-three { left: 67%; }
  .score-chord.chord-four { display: none; }
  .eyebrow { margin-bottom: 12px; font-size: 9px; letter-spacing: .09em; }
  .eyebrow span { width: 25px; height: 25px; }
  .hero h1 { font-size: clamp(34px, 10vw, 43px); line-height: .96; }
  .hero-copy > p { margin: 12px auto 17px; font-size: 12px; line-height: 1.48; }
  .url-form > label { margin-left: 2px; }
  .url-field { grid-template-columns: auto minmax(0, 1fr); gap: 7px; padding: 7px; border-radius: 16px; }
  .source-icon { width: 36px; height: 36px; }
  .url-field input { font-size: 13px; }
  .url-field .button { grid-column: 1 / -1; width: 100%; min-height: 46px; margin-top: 1px; }
  .url-form small { min-height: 0; margin: 8px 3px 0; }
  .hero-flow { align-items: flex-start; gap: 8px; margin-top: 14px; font-size: 9px; line-height: 1.35; }
  .hero-flow span { flex: 1 1 0; justify-content: center; }
  .hero-flow i { width: 10px; }
  .has-repertoire .hero { padding: 18px 16px 22px; }
  .has-repertoire .hero-score { top: -12px; height: 130px; opacity: .17; }
  .has-repertoire .hero-flow { display: none; }
  .has-repertoire .url-form small { margin-bottom: 0; }

  .workspace { padding: 30px 14px calc(64px + env(safe-area-inset-bottom)); }
  .workspace::before { top: 31px; right: 14px; width: 128px; opacity: .14; }
  .section-heading { align-items: stretch; flex-direction: column; gap: 17px; margin-bottom: 20px; }
  .section-heading h2 { font-size: 31px; }
  .section-heading .button { width: 100%; }
  .empty-state { min-height: 150px; padding: 22px 20px; border-radius: 18px; }
  .song-list { gap: 9px; }
  .song-card { grid-template-columns: 42px minmax(0, 1fr) 88px; gap: 10px; min-height: 108px; padding: 10px; border-radius: 15px; }
  .song-number { width: 42px; height: 42px; }
  .song-copy h3 { font-size: 19px; }
  .song-copy .pill.lines { display: none; }
  .song-actions { display: grid; grid-template-columns: repeat(2, 44px); gap: 0; align-self: center; }
  .move-buttons { display: contents; }
  .move-buttons .icon-button, .song-actions > .icon-button { width: 44px; }

  .modal { align-items: end; padding: 0; }
  .modal[open] { place-items: end stretch; }
  .modal-card { width: 100%; max-height: min(92dvh, 820px); padding: 28px 18px calc(18px + env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 24px 24px 0 0; opacity: 1; transform: translateY(100%); transform-origin: bottom; transition: transform 280ms var(--ease-drawer); }
  .modal-card::before { content: ""; position: sticky; z-index: 3; top: -17px; display: block; width: 38px; height: 4px; margin: -12px auto 18px; border-radius: 99px; background: #d5cec1; }
  .modal.is-ready .modal-card { transform: translateY(0); }
  .modal-close { top: 13px; right: 12px; }
  .modal h2 { font-size: 29px; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 13px 10px; margin-top: 21px; }
  .form-grid label:first-of-type, .form-grid .wide { grid-column: 1 / -1; }
  .form-grid textarea { min-height: 240px; }
  .modal-actions { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); margin: 20px -18px 0; padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(215,208,194,.7); background: rgba(255,253,248,.92); backdrop-filter: blur(14px); }
  .results-dock { grid-template-columns: 1fr; gap: 10px; margin: 18px -18px 0; padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); }
  .results-dock .button { width: 100%; min-width: 0; }
  .pdf-actions { flex-direction: column-reverse; }
  .pdf-actions .button { width: 100%; }
  .candidate { min-height: 68px; }
  .toast { left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; text-align: center; }
}

@media (max-width: 350px) {
  .brand > span:last-child { display: none; }
}

@media (max-width: 440px) {
  .hero-flow { justify-content: space-between; }
  .hero-flow i { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label, .form-grid label:first-of-type, .form-grid .wide, .form-grid .span-two { grid-column: 1; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero-score, .hero-copy, .url-form, .score-note, .score-chord { animation: none; clip-path: none; opacity: 1; transform: none; }
  .hero-score { transform: translateX(-50%); opacity: .28; }
  .button-meter i { animation: none; transform: none; }
  .button, .icon-button, .candidate { transition-property: background-color, border-color, color, opacity, box-shadow; }
  .song-card::before { transition-property: opacity; }
  .modal, .modal-card, .toast { transition-property: opacity; transform: none; }
  .modal-card, .modal.is-ready .modal-card, .toast, .toast.is-visible { transform: none; }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar, .preview-panel, .modal-actions, .results-dock { background: var(--paper); backdrop-filter: none; }
  .modal::backdrop { backdrop-filter: none; }
}

@media (prefers-contrast: more) {
  :root { --muted: #444944; --line: #aaa295; --line-strong: #777066; }
  .button-outline, .song-card, .url-field, .candidate { border-width: 2px; }
}
