:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f4f5;
  --ink: #000000;
  --muted: #555b63;
  --line: #d8dadd;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e2f2ec;
  --hi: #d9480f;
  --hi-soft: #ffeadc;
  --hole: #000000;
  --hole-open: #ffffff;
  --upper: #6741d9;
  --warn: #b35c00;
  --rest: #7c8086;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 3px 12px rgba(0,0,0,.05);
  --radius: 10px;
  --foot-h: 34px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
/* Light is the default; dark only when chosen with the toggle (data-theme="dark"). */
:root[data-theme="dark"] {
  --bg: #15171a; --surface: #1d2024; --surface-2: #262a2f; --ink: #e8e6e1; --muted: #9aa0a8;
  --line: #353a41; --accent: #4fb89c; --accent-ink: #0d1f1a; --accent-soft: #1d3a32;
  --hi: #ff8a4c; --hi-soft: #3d261a; --hole: #e8e6e1; --hole-open: #1d2024; --upper: #a78bfa;
  --warn: #f0a050; --rest: #7c8189; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }
/* App pages stay blank until the sign-in check passes, so signed-out visitors only ever see the login page. */
.auth-pending body { visibility: hidden; }

/* ---------- top bar */
/* #top holds the top bar (and the player on tune pages) and stays fixed to the top of the screen.
   The safe-area insets keep it clear of the status bar / notch when the site runs full screen from a phone's home screen. */
:root { --safe-top: env(safe-area-inset-top, 0px); --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-padding-top: calc(var(--head-h, 64px) + 8px); }
#top { position: sticky; top: 0; z-index: 50; padding-top: var(--safe-top); background: var(--surface); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px calc(20px + var(--safe-right)) 12px calc(20px + var(--safe-left)); border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand svg { flex: 0 0 auto; width: 26px; height: 26px; }
.topbar nav { margin-left: auto; display: flex; gap: 8px; align-items: center; }

main { max-width: 1280px; margin: 0 auto; padding: 20px calc(16px + var(--safe-right)) 60px calc(16px + var(--safe-left)); }
.site-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--foot-h) + var(--safe-bottom, 0px)); padding: 0 calc(16px + var(--safe-right)) var(--safe-bottom, 0px) calc(16px + var(--safe-left)); text-align: center; line-height: calc(var(--foot-h) - 1px); font-size: .85rem; color: var(--muted); background: var(--surface); border-top: 1px solid var(--line); }
body { padding-bottom: calc(var(--foot-h) + var(--safe-bottom, 0px)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 16px; }

/* ---------- controls */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .92rem; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: #c92a2a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
input[type=text], input[type=search], input[type=email], input[type=password], select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.45; }
label { font-size: .88rem; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- library */
.lib-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.lib-head input { min-width: 240px; }
.tune-table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tune-table { width: 100%; border-collapse: collapse; }
.tune-table th, .tune-table td { padding: 9px 14px; text-align: left; vertical-align: top; }
.tune-table th { font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tune-table td { border-top: 1px solid var(--line); }
.tune-table tbody tr:first-child td { border-top: none; }
.tune-table tbody tr { cursor: pointer; }
.tune-table.static tbody tr { cursor: default; }
.tune-table tbody tr:hover { background: var(--accent-soft); }
.tune-table td a { color: inherit; font-weight: 600; text-decoration: none; }
.tune-table td a:hover { color: var(--accent); text-decoration: underline; }
.tune-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tune-table th .sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.tune-table th .sort:hover, .tune-table th .sort.on { color: var(--ink); }
.tune-table th .sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.tune-table th .arrow { font-size: .65rem; min-width: .7em; }
.tune-table td.small { padding-top: 11px; }
.tune-table .fav-cell { width: 1%; padding-right: 0; }
.fav-star { all: unset; cursor: pointer; font-size: 1.15rem; line-height: 1; color: var(--muted); padding: 2px; border-radius: 4px; }
.fav-star:hover { color: var(--ink); }
.fav-star[aria-pressed="true"] { color: #e0a100; }
.fav-star:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn .fav-icon { font-size: 1.05rem; line-height: 1; }
.btn[aria-pressed="true"] .fav-icon { color: #e0a100; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.empty { text-align: center; padding: 48px 16px; }

/* ---------- editor */
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; cursor: pointer; background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { color: var(--accent); }
.status { display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: #c92a2a; }
.stats { display: flex; flex-wrap: wrap; gap: 6px; }
.stat { font-size: .8rem; padding: 3px 9px; border-radius: 6px; background: var(--surface-2); }
.stat.good { background: var(--accent-soft); color: var(--accent); }
.stat.warn { background: var(--hi-soft); color: var(--warn); }
details > summary { cursor: pointer; font-weight: 600; }
.approve-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }

/* ---------- split layout: original | tab */
.split { display: grid; gap: 16px; grid-template-columns: 1fr; }
.split.with-original { grid-template-columns: minmax(280px, 42%) 1fr; }
@media (max-width: 960px) { .split.with-original { grid-template-columns: 1fr; } }
.original-pane { position: sticky; top: calc(var(--head-h, 64px) + 8px); max-height: calc(100vh - var(--head-h, 64px) - var(--foot-h) - 16px); overflow: auto; padding: 10px; background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--line); }
@media (max-width: 960px) { .original-pane { position: static; max-height: 70vh; } }
.page { margin: 0 0 12px; }
.page canvas, .page img { width: 100%; height: auto; display: block; background: #fff; border-radius: 4px; box-shadow: var(--shadow); }
.page figcaption { font-size: .75rem; color: var(--muted); padding: 4px 2px; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0; }
.thumbs .page { flex: 0 0 120px; margin: 0; }
.thumb-file { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.thumb-file-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .8rem; }
.thumb-file-head span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb-pages { display: flex; gap: 8px; }

/* ---------- tab view */
.tab-pane { min-width: 0; }
.tabview { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 8px; box-shadow: var(--shadow); overflow-x: auto; }
.score-wrap { position: relative; min-width: 300px; }
.fit-box { overflow: hidden; } /* Fit screen: holds the shrunk score at its shrunk size (see TabView.render) */
.score-wrap svg { display: block; color: var(--ink); cursor: pointer; }
.score-wrap svg path, .score-wrap svg text { fill: currentColor; }
.score-wrap svg .abcjs-staff path, .score-wrap svg .abcjs-staff-extra path { fill: currentColor; }
.score-wrap svg .abcjs-chord { fill: var(--accent); font-weight: 700; }
.score-wrap svg .note-active, .score-wrap svg .note-active path { fill: var(--hi); color: var(--hi); }
.tab-row { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.cell { position: absolute; top: 4px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 2px 2px 3px; margin: 0; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--ink); font: inherit; cursor: pointer; min-width: 18px; }
.cell:hover { background: var(--surface-2); }
.cell.active { background: var(--hi-soft); border-color: var(--hi); }
.cell .nn { font-size: 11px; font-weight: 700; line-height: 1.1; height: 13px; }
.cell.upper .nn { color: var(--upper); }
.cell.half .nn { text-decoration: underline dotted var(--warn); }
.cell .reg { font-size: 17px; font-weight: 900; color: var(--upper); line-height: 1; height: 13px; }
.cell .shift { font-size: 9px; color: var(--warn); font-weight: 700; }
.count { font: 800 15px/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; padding: 4px 0 2px; }
.count .oct { color: var(--upper); font-weight: 900; }
.count.open-top small { font-size: inherit; font-weight: inherit; color: var(--warn); }
.cell.active .count { color: var(--hi); }
.cell.tight .count.open-top { display: flex; flex-direction: column; align-items: center; padding-top: 0; line-height: 1; }
.cell.tight .count.open-top small { font-size: 9px; line-height: 9px; }
.cell.style-numbers .rest-mark, .cell.style-numbers .hold-mark { height: 26px; }
.digits { display: flex; flex-direction: column; align-items: center; font-size: 11.5px; line-height: 10.6px; font-variant-numeric: tabular-nums; min-height: 69px; }
.digits b { font-weight: 800; }
.digits b.half { color: var(--warn); font-size: 9px; }
.digits i { font-style: normal; color: var(--muted); opacity: .55; }
.digits > :nth-child(4) { margin-top: 5px; }
.cell.active .digits b { color: var(--hi); }
.holes .h-closed { fill: var(--hole); }
.holes .h-open { fill: var(--hole-open); stroke: var(--hole); stroke-width: 1.3; }
.holes .h-half { fill: var(--hole); }
.cell.active .holes .h-closed, .cell.active .holes .h-half { fill: var(--hi); }
.cell.active .holes .h-open { stroke: var(--hi); }
.rest-mark, .hold-mark { writing-mode: vertical-rl; font-size: 11px; color: var(--rest); letter-spacing: 2px; height: 72px; display: flex; align-items: center; justify-content: center; }
.hold-mark { color: var(--muted); }
.cell.rest .rest-mark { border-left: 2px dotted var(--rest); padding-left: 2px; }


/* ---------- player: thin bar under the top bar, hidden and shown with the ♪ button in the top bar */
body:not(.has-player) .player, body:not(.has-player) .player-toggle, .player.collapsed { display: none !important; }
.player { position: relative; height: 50px; display: flex; align-items: center; gap: 10px;
  padding: 0 calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left)); background: var(--surface); border-bottom: 1px solid var(--line); }
.player .controls { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.player .btn { min-height: 34px; padding: 4px 12px; }
.player .settings { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); }
.player .settings select { min-height: 32px; padding: 3px 8px; }
.player .settings #instrument { max-width: 11em; }
.player .settings #style { display: contents; } /* its Tab picker and Note names box lay out with the rest */
.player .settings .btn { white-space: nowrap; }
.player input[type=range] { width: 100px; accent-color: var(--accent); }
.player .settings-toggle { display: none; }
.player .mute-toggle { padding: 4px 8px; }
.player .mute-toggle svg { display: block; }
.score-zoom { justify-content: center; padding-left: 9px; padding-right: 9px; }
.score-zoom svg { display: block; }
.now { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.now .mini-holes svg { display: block; }
.now .mini-holes .h-closed, .now .mini-holes .h-half { fill: var(--hi); }
.now .mini-holes .h-open { stroke: var(--hi); }
.now .n-name { font-weight: 800; font-size: 1.1rem; }
.now .fingers { font: 800 1.15rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--hi); }
.now .n-sub { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.now .n-chord { font-size: .82rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.empty-now { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; }

/* wide screens: the settings sit in two rows (tempo / instrument / tab, then the check boxes and download) so the bar never runs off the edge */
@media (min-width: 1021px) {
  .player { height: auto; min-height: 50px; padding-top: 6px; padding-bottom: 6px; }
  .player .controls { flex: 1 1 auto; min-width: 0; }
  .player .settings { flex: 1 1 auto; min-width: 0; flex-wrap: wrap; row-gap: 6px; }
  .player .settings::before { content: ''; flex-basis: 100%; order: 1; } /* the line break */
  .player .settings .check, .player .settings .btn { order: 2; }
  .player .settings .check .check { order: 0; } /* Chords box, then its instrument */
}

/* narrower screens: tempo / tab / sound move into a drop-down under the bar */
@media (max-width: 1020px) {
  .player .settings-toggle { display: inline-flex; justify-content: center; }
  .player .settings { display: none; }
  /* a grid: label | control | value, with the check boxes and the download in full rows, left-aligned */
  .player.show-settings .settings { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px 12px; position: absolute; top: 100%; left: 0; right: 0; padding: 10px calc(14px + var(--safe-right)) 10px calc(14px + var(--safe-left));
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 6px 14px rgba(0,0,0,.1); }
  .player.show-settings .settings input[type=range] { width: 100%; }
  .player.show-settings .settings select { justify-self: start; }
  .player.show-settings .settings #instrument { grid-column: 2 / -1; max-width: 100%; }
  .player.show-settings .settings .check, .player.show-settings .settings .btn { grid-column: 1 / -1; justify-self: start; }
  .player.show-settings .settings-toggle { background: var(--accent-soft); border-color: var(--accent); }
  /* never taller than the screen below the bar (a phone held sideways) */
  .player.show-settings .settings { max-height: calc(100vh - var(--head-h, 64px)); max-height: calc(100dvh - var(--head-h, 64px)); overflow-y: auto; overscroll-behavior: contain; }
}
@media (max-width: 640px) {
  .player { gap: 6px; padding-right: 8px; }
  .player .btn { padding: 4px 10px; }
  .player .mute-toggle { padding: 4px 7px; }
  .now .n-sub { display: none; }
}

/* chord diagrams */
.chord-list { display: flex; flex-wrap: wrap; gap: 10px; }
.chord-list figure { margin: 0; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.cd-name { font: 700 12px var(--font); fill: var(--ink); }
.cd-line { stroke: var(--muted); stroke-width: 1; }
.cd-nut { stroke: var(--ink); stroke-width: 3; }
.cd-dot { fill: var(--ink); }
.cd-open { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.cd-mark, .cd-fret, .cd-muted { font: 10px var(--font); fill: var(--muted); }


.tune-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: start; justify-content: space-between; margin-bottom: 14px; }
.tune-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- "More" menu (tune page) */
.more { position: relative; }
.more > summary { list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; display: flex; flex-direction: column; gap: 2px; min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.more .menu .btn { border-color: transparent; justify-content: flex-start; width: 100%; }

/* ---------- player settings group */
.check { display: inline-flex; align-items: center; gap: 6px; }
.brand-short { display: none; }

/* ---------- touch devices: bigger targets */
@media (pointer: coarse) {
  .btn, select, input[type=text], input[type=search], input[type=email], input[type=password] { min-height: 42px; }
  input[type=range] { height: 32px; }
  input[type=checkbox] { width: 20px; height: 20px; }
  .kbd-tip { display: none; }
  .cell { min-width: 24px; }
}

/* ---------- tablets (portrait) and small laptops */
@media (max-width: 960px) {
  .original-pane { max-height: 45vh; }
  .tune-head { flex-direction: column; }
}

/* ---------- phones */
@media (max-width: 640px) {
  body { font-size: 15px; }
  input[type=text], input[type=search], input[type=email], input[type=password], select, textarea { font-size: 16px; } /* stops iOS zooming on focus */
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand { gap: 8px; font-size: .98rem; white-space: nowrap; }
  .brand-long, .wide-only { display: none; }
  .brand-short { display: inline; }
  .topbar nav { gap: 6px; }
  .topbar nav .btn { padding: 7px 10px; }
  main { padding: 12px calc(10px + var(--safe-right)) 24px calc(10px + var(--safe-left)); }
  h1 { font-size: 1.35rem; }
  .card { padding: 14px; }
  .lib-head .row, .lib-head input { width: 100%; }
  .lib-head input { min-width: 0; }
  .tune-table th, .tune-table td { padding: 8px 10px; }
  .tune-head .actions { width: 100%; }
  .tune-head .actions > .btn, .tune-head .actions > .more { flex: 1 1 auto; justify-content: center; }
  .tune-head .actions > .more > summary { width: 100%; justify-content: center; }
  .row > .field { min-width: 0 !important; flex: 1 1 100%; }
  .row > .btn { flex: 1 1 auto; justify-content: center; }
  .approve-bar .row { width: 100%; }
  .approve-bar .row .btn { flex: 1; justify-content: center; }
  .dropzone { padding: 20px 12px; }
  .tabview { padding: 6px 2px; border-radius: 8px; }
  .original-pane { max-height: 50vh; }

}

/* ---------- phones held sideways: little height to spare, so the top bar scrolls away (only the
   player stays stuck to the top) and the footer sits at the end of the page instead of over it */
@media (orientation: landscape) and (max-height: 500px) {
  #top { top: calc(-1 * var(--bar-h, 0px)); }
  html { scroll-padding-top: calc(var(--head-h, 64px) - var(--bar-h, 0px) + 8px); }
  .topbar { padding-top: 4px; padding-bottom: 4px; }
  main { padding-top: 12px; padding-bottom: 16px; }
  .site-footer { position: static; }
  body { padding-bottom: 0; }
  .original-pane { top: calc(var(--head-h, 64px) - var(--bar-h, 0px) + 8px); max-height: 80vh; }
}

@media print {
  #top, .no-print, .original-pane, .tune-head .actions { display: none !important; }
  body { background: #fff; padding-bottom: 0; }
  .tabview, .card { box-shadow: none; border: none; }
  .split.with-original { grid-template-columns: 1fr; }
  main { max-width: none; padding: 0; }
}

/* ---- account menu (topbar) */
.account > summary { padding: 4px; }
.account .avatar { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600; }
.account > summary { position: relative; }
.account .dot { position: absolute; top: 2px; right: 2px; width: 9px; height: 9px; border-radius: 50%; background: #e8590c; border: 2px solid var(--surface); }
.account .who { display: flex; flex-direction: column; padding: 6px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-wrap: anywhere; }
.signin-needed { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
#save-status:not(:empty) { margin-top: 10px; }
/* phones: keep the Library button; the logo gives up its name first to make room */
@media (max-width: 640px) {
  .topbar nav { flex: 0 0 auto; }
  .brand { min-width: 0; overflow: hidden; }
}
@media (max-width: 380px) {
  .brand .brand-short { display: none; }
}
/* the score zoom button (touch screens, tune page) takes the name's room on phones: the logo alone links to the library */
@media (max-width: 440px) {
  .topbar:has(.score-zoom) .brand-short { display: none; }
}

/* ---- library sections (yours, then each friend's) */
.lib-section + .lib-section { margin-top: 28px; }
.lib-section > h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0 0 10px; }
.lib-section > h2 .small { font-weight: 400; }

/* ---- friends page */
.friends-page { max-width: 720px; }
.friends-page .card + .card { margin-top: 16px; }
.add-friend { display: flex; flex-wrap: wrap; gap: 8px; }
.add-friend input { flex: 1 1 220px; min-width: 0; }
.person-list { list-style: none; margin: 0; padding: 0; }
.person { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 0; }
.person + .person { border-top: 1px solid var(--line); }
.person .avatar { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 600; object-fit: cover; }
.person .who { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.person .acts { display: flex; align-items: center; gap: 8px; margin-left: auto; }
@media (max-width: 640px) {
  .person .acts { width: 100%; }
  .person .acts .btn { flex: 1; justify-content: center; }
}

/* ---------- editor steps: one block open at a time */
.step { padding: 0; }
.step-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 18px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: var(--radius); }
.step-head:disabled { cursor: default; opacity: .55; }
.step-head:not(:disabled):hover { background: var(--surface-2); }
.step-num { flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); font-weight: 700; font-size: .9rem; }
.step.open .step-num { border-color: var(--accent); color: var(--accent); }
.step.done .step-num { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.step-title { font-size: 1.1rem; font-weight: 700; }
.step-summary { margin-left: auto; color: var(--muted); font-size: .9rem; text-align: right; }
.step-head::after { content: "›"; flex: 0 0 auto; color: var(--muted); font-size: 1.3rem; line-height: 1; transition: transform .15s; }
.step.open .step-head::after { transform: rotate(90deg); }
.step-head:disabled::after { visibility: hidden; }
.step.open .step-head { border-radius: var(--radius) var(--radius) 0 0; }
.step-body { padding: 0 18px 18px; }
@media (max-width: 640px) {
  .step-head { flex-wrap: wrap; padding: 12px; }
  .step-summary { flex-basis: 100%; margin-left: 40px; text-align: left; order: 3; }
  .step-body { padding: 0 12px 12px; }
}

/* License status */
.badge.lic { font-weight: 600; white-space: nowrap; }
.badge.lic-free { background: var(--accent-soft); color: var(--accent); }
.badge.lic-attribution { background: color-mix(in srgb, var(--upper) 14%, var(--surface)); color: var(--upper); }
.badge.lic-restricted { background: var(--hi-soft); color: var(--hi); }
.btn.compact { font-size: .78rem; padding: 2px 10px; min-height: 0; }
.lic-checking { display: inline-flex; align-items: center; gap: 6px; }
.lic-checking .spinner { width: 12px; height: 12px; }
.license-card .lic-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; }
.license-card .lic-head h2 { margin: 0; }
.license-card dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.license-card dt { color: var(--muted); }
.license-card dd { margin: 0; }
.license-card ul { margin: 4px 0 0; padding-left: 20px; }
@media (max-width: 640px) { .license-card dl { grid-template-columns: 1fr; } .license-card dd { margin-bottom: 6px; } }
button.badge.lic { border: none; font: inherit; font-size: .75rem; font-weight: 600; cursor: pointer; }
button.badge.lic:hover { text-decoration: underline; }
.license-card h3 { font-size: .95rem; margin: 18px 0 6px; }
.license-card .lic-sources li + li { margin-top: 6px; }
/* Safari before 15.4 has no <dialog>: createDialog() in ui.js gives pop-ups these classes instead */
.dialog-shim { display: block; position: fixed; top: 50%; left: 50%; z-index: 1001; margin: 0; transform: translate(-50%, -50%); max-height: calc(100vh - 32px); overflow: auto; -webkit-overflow-scrolling: touch; }
.dialog-backdrop { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1000; background: rgba(0, 0, 0, .4); }
.license-dialog { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 18px; box-shadow: var(--shadow); }
.license-dialog::backdrop { background: rgba(0, 0, 0, .4); }
.license-dialog .row { margin-top: 14px; }

/* Confirm pop-up (instead of the browser's confirm()) */
.confirm-dialog { width: min(420px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 20px; box-shadow: var(--shadow); }
.confirm-dialog::backdrop { background: rgba(0, 0, 0, .4); }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 1.15rem; overflow-wrap: anywhere; }
.confirm-dialog p { margin: 0; color: var(--muted); }
.confirm-dialog .row { margin-top: 18px; justify-content: flex-end; }
.btn.danger-fill { background: #c92a2a; border-color: #c92a2a; color: #fff; font-weight: 600; }
.btn.danger-fill:hover { filter: brightness(1.1); background: #c92a2a; }

/* Delete button on your own tunes in the library */
.tune-table .del-cell { width: 1%; padding-left: 0; }
.del-tune { all: unset; cursor: pointer; display: inline-grid; place-items: center; color: var(--muted); padding: 3px; border-radius: 4px; opacity: .6; }
.del-tune svg { width: 16px; height: 16px; }
.tune-table tbody tr:hover .del-tune { opacity: 1; }
.del-tune:hover { color: #c92a2a; opacity: 1; }
.del-tune:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; opacity: 1; }
