:root {
  --petrol: #073638;
  --gold: #E9B657;
  --cream: #F8F2DF;
  --ink: #163637;
  --muted: #536666;
  --surface: #fffcf3;
  --line: #ded7c4;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background: var(--cream);
  font-family: var(--sans);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; }
button, .button { cursor: pointer; }
button:disabled, input:disabled { opacity: .6; cursor: wait; }
:focus-visible { outline: 3px solid #a46a12; outline-offset: 4px; }
.rail :focus-visible, .hero :focus-visible { outline-color: var(--gold); }
h1, h2, p { margin: 0; }
h1, h2 { overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.skip-link {
  position: fixed;
  z-index: 3;
  top: 10px;
  left: 10px;
  transform: translateY(-160%);
  background: var(--surface);
  padding: 12px 16px;
}
.skip-link:focus { transform: none; }

.layout { min-height: 100vh; }
.rail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding: calc(12px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  color: var(--cream);
  background: var(--petrol);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.06rem;
  min-height: 44px;
  text-decoration: none;
  white-space: nowrap;
}
.brand strong { font-weight: 780; }
.rail nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  text-decoration: none;
  font-size: .91rem;
  font-weight: 660;
  color: #e2ece6;
}
.nav-link:hover { background: #184647; }
.nav-link[aria-current] { color: var(--gold); background: #1b4748; }
.workspace {
  min-width: 0;
  padding: 0 max(18px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
.toolbar, main { max-width: 1080px; margin: 0 auto; }
.toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.location-label { font-size: .9rem; font-weight: 690; }
.connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid #c1d2be;
  border-radius: 999px;
  background: #e7efde;
  color: #244b37;
  font-size: .78rem;
  font-weight: 720;
}
.signal { width: 8px; height: 8px; border-radius: 50%; background: #3e7853; }
.connection[data-offline] { color: #684709; background: #ffedc4; border-color: #d9bf88; }
.connection[data-offline] .signal { background: #a26d16; }

.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 286px;
  border: 1px solid #184749;
  border-radius: 20px;
  background: radial-gradient(ellipse at 95% 65%, #27615b, transparent 68%), var(--petrol);
  color: var(--cream);
}
.hero-copy { z-index: 1; padding: 34px clamp(28px, 6vw, 78px); }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.75rem, 7vw, 5.25rem);
  font-weight: 400;
  line-height: .97;
  letter-spacing: -.055em;
}
.hero p {
  margin-top: 18px;
  color: var(--gold);
  font-family: var(--serif);
  font-size: clamp(1.13rem, 2.9vw, 1.65rem);
  font-style: italic;
}
.record {
  position: absolute;
  right: -18px;
  bottom: -105px;
  width: clamp(315px, 43vw, 525px);
  aspect-ratio: 1;
  border: 1px solid #61938a;
  border-radius: 50%;
  background:
    conic-gradient(from 50deg, transparent, #77a09740 19%, transparent 31% 51%, #78ab9f40 65%, transparent 78%),
    repeating-radial-gradient(circle, #245051 0 2px, #143c3e 3px 5px, #204849 6px 8px);
  display: grid;
  place-items: center;
  box-shadow: 0 0 50px #00191d88;
  transform: rotate(-26deg);
}
.record > div {
  width: 38%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #edc97d;
  background: repeating-radial-gradient(circle, #cf9542 0 1px, #e9b657 2px 20px, #dca754 21px 22px);
  box-shadow: 0 0 0 9px #103a3a;
}
.record > div::after {
  content: "";
  display: block;
  width: 9px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--petrol);
}
.collection { margin-top: 32px; }
.section-heading, .view-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.section-heading h2, .view-heading h1, .play-sheet h1 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -.035em;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.08;
}
.section-heading p { margin-top: 5px; font-size: .88rem; }
.button, .back-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: .91rem;
  font-weight: 710;
  text-decoration: none;
}
.button {
  padding: 7px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: center;
}
.primary { background: var(--gold); border-color: #cc983d; color: #172e2c; }
.primary:hover { background: #f1c572; }
.outline { color: var(--petrol); border-color: #c6c6b3; background: var(--surface); }
.outline:hover, .quiet:hover { background: #f1ecd9; }
.quiet { color: var(--petrol); background: transparent; }
.back-link { justify-content: flex-start; padding-right: 12px; }
.back-link:hover, .song-title:hover { text-decoration: underline; }
.search { display: flex; align-items: center; position: relative; margin: 18px 0 12px; }
.search .icon { position: absolute; left: 14px; pointer-events: none; color: var(--muted); }
input, textarea {
  color: var(--ink);
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  background: #fffdf7;
  border: 1px solid #beb9a7;
  border-radius: 8px;
}
.search input { padding-left: 42px; border-color: var(--line); }
.song-list { padding: 0; margin: 0; list-style: none; }
.song-row {
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.song-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #f7e7b9;
  color: #634916;
  font-size: 1.35rem;
}
.song-meta { overflow-wrap: anywhere; }
.song-title { display: flex; align-items: center; min-height: 28px; font-weight: 730; text-decoration: none; }
.song-artist { font-size: .86rem; }
.empty { padding: 20px 0; color: var(--muted); }

.view-heading { margin: 8px 0 18px; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.editor, .play-sheet, .settings { padding: clamp(17px, 4vw, 34px); }
.editor, .form-grid, .settings { display: grid; gap: 16px; }
.form-grid, .backup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.editor label, .settings label { font-weight: 690; }
.editor label .muted { font-size: .86rem; font-weight: 400; }
#notation-hint { display: block; margin-top: 5px; line-height: 1.5; }
.editor input, textarea { display: block; margin-top: 6px; }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; line-height: 1.5; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.view-actions { margin-bottom: 12px; }
.play-sheet > header { border-bottom: 1px solid var(--line); padding-bottom: 18px; margin-bottom: 22px; }
.play-sheet > header p { margin-top: 7px; }
.score { font-size: clamp(1.18rem, 3.2vw, 1.75rem); line-height: 1.5; }
.score-line { min-height: 1.5em; white-space: pre-wrap; overflow-wrap: anywhere; }
.score-line + .score-line { margin-top: .12em; }
.chord-pair {
  display: inline-grid;
  max-width: 100%;
  vertical-align: bottom;
}
.chord {
  color: #77520b;
  line-height: 1.35;
  font-weight: 770;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .8em;
}
.backup-grid { display: grid; gap: 12px; }
.settings { justify-items: start; align-content: start; gap: 12px; }
.settings h2 { font-family: var(--serif); font-weight: 500; font-size: 1.6rem; }
.settings p { line-height: 1.5; }
.restore-panel { grid-column: 1 / -1; }
.restore-panel input { max-width: 450px; }
.restore-panel .form-actions { justify-content: flex-start; }
.feedback { color: #7f381f; }
.announcement:empty { display: none; }
.announcement {
  position: fixed;
  z-index: 2;
  max-width: min(440px, calc(100vw - 32px));
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  border-radius: 8px;
  background: var(--petrol);
  color: var(--cream);
  padding: 12px 16px;
  box-shadow: 0 3px 18px #0736383d;
}

.icon { position: relative; display: inline-block; flex: 0 0 18px; width: 18px; height: 18px; }
.icon::before, .icon::after { position: absolute; content: ""; }
.icon-library::before { inset: 2px 3px 2px 3px; border: 1.5px solid; border-radius: 2px; }
.icon-library::after { inset: 6px 6px 6px 6px; border-top: 1.5px solid; border-bottom: 1.5px solid; }
.icon-backup::before { inset: 4px 1px 2px 1px; border: 1.5px solid; border-radius: 2px; }
.icon-backup::after { inset: 8px 6px 0 6px; border-top: 1.5px solid; }
.icon-plus::before, .icon-back::before { inset: 8px 2px; background: currentColor; }
.icon-plus::after { inset: 2px 8px; background: currentColor; }
.icon-search::before { inset: 1px 4px 4px 1px; border: 1.5px solid; border-radius: 50%; }
.icon-search::after { width: 6px; height: 1.5px; left: 11px; top: 13px; background: currentColor; transform: rotate(45deg); }
.icon-play::before { left: 6px; top: 3px; border-block: 6px solid transparent; border-left: 9px solid; }
.icon-edit::before { width: 4px; height: 13px; top: 2px; left: 7px; border: 1.4px solid; transform: rotate(43deg); }
.icon-edit::after { top: 14px; left: 2px; width: 4px; border-top: 1.4px solid; transform: rotate(-25deg); }
.icon-back::after { top: 5px; left: 2px; width: 8px; height: 8px; border-left: 1.5px solid; border-bottom: 1.5px solid; transform: rotate(45deg); }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: 228px minmax(0, 1fr); }
  .rail {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 32px;
    padding: calc(24px + env(safe-area-inset-top)) 16px 24px max(16px, env(safe-area-inset-left));
  }
  .rail nav { display: grid; }
  .workspace { padding: env(safe-area-inset-top) max(30px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) 30px; }
  .toolbar { min-height: 72px; }
}

@media (max-width: 590px) {
  .rail { gap: 2px 16px; }
  .rail nav { flex-basis: 100%; }
  .toolbar { min-height: 53px; }
  .hero { min-height: 236px; }
  .hero-copy { padding: 28px 22px; }
  .record { right: -132px; bottom: -95px; opacity: .53; }
  .collection { margin-top: 24px; }
  .song-row { grid-template-columns: 38px minmax(0, 1fr) 44px auto; gap: 6px; padding: 7px; }
  .song-icon { width: 36px; height: 36px; }
  .song-title { min-height: 44px; }
  .row-edit { padding: 0; }
  .row-edit span { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .row-play { padding: 5px 8px; gap: 3px; }
  .form-grid, .backup-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 375px) {
  .hero h1 { font-size: 2.46rem; }
  .section-heading .primary { padding-inline: 9px; }
  .song-row { grid-template-columns: minmax(0, 1fr) 44px auto; }
  .song-icon { display: none; }
  .song-meta { padding-left: 5px; }
}
