/* Band Charts. The look follows the band's old app: slate chrome, a black chart area,
   big bold monospace chords in the band's own notation, and small yellow section pills.
   Phones first: one spacing scale (4/8/12/16/24/32), one type scale, 44px tap targets,
   safe areas for the notch and home bar, and bottom sheets for dialogs. */
:root {
  --accent-text: #ffd65c; /* yellow as text: links, repeat counts */
  --bg: #0f1729;          /* app background */
  --bar: #374151;         /* header and bottom bar */
  --surface: #151e30;
  --surface-2: #1f2a3d;
  --line: #2b3646;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --chart-bg: #000;
  --chord: #fff;
  --pill: #ffd65c;        /* section pills, current section, primary action */
  --pill-text: #111;
  --sync: #10b981;        /* band sync on */
  --claude: #b9a5f0;      /* anything Claude is doing or suggesting */
  --warn: #f5b14c;        /* unsure */
  --error: #ff5a5f;       /* failures only */
  --icon-tint: #ffd65c;   /* icon tiles on cards */
  --tile: rgba(255, 214, 92, .12);
  --sheet: #232d3d;       /* dialogs and sheets */
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 -8px 40px rgba(0, 0, 0, .45);
  --chart-size: 32px;
  --chart-weight: 700;
  --chart-font: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ui-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --head: 56px;           /* app bar height, without the notch */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 var(--ui-font);
  -webkit-tap-highlight-color: transparent;
  padding: 0 var(--safe-r) 0 var(--safe-l);
  overflow-x: clip; /* never a sideways scroll; clip keeps sticky headers working */
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
h1, h2, h3 { letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--pill); outline-offset: 2px; }
svg { flex-shrink: 0; }

.wrap { max-width: 860px; margin: 0 auto; padding: 16px 16px calc(40px + var(--safe-b)); }

/* ---- top bars ---- */
.bar-top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  min-height: calc(var(--head) + var(--safe-t));
  padding: var(--safe-t) 8px 0 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.bar-top h1 { font-size: 20px; font-weight: 700; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-top .brand { display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; }
.back {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 10px 0 8px;
  color: var(--text); text-decoration: none; font-size: 16px; font-weight: 500; border-radius: var(--radius-sm); flex-shrink: 0;
}
.back:active { background: var(--surface-2); }

/* Song header: back, title and key on one row, the tools below on phones. */
.song-head {
  position: sticky; top: 0; z-index: 5; background: var(--bar);
  padding: calc(4px + var(--safe-t)) 8px 4px;
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 0 8px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .25);
}
.song-head > .btn.icon { color: var(--text); }
.song-head .titles { text-align: center; min-width: 0; }
.song-head h1 { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-head .titles p { margin: 1px 0 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.song-head .tools {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center;
  width: 100%; max-width: 400px; margin: 2px auto 0; padding-top: 2px; border-top: 1px solid rgba(255, 255, 255, .06);
}
.song-head .tools .btn.icon { flex-shrink: 1; min-width: 40px; }
.songstep { display: flex; align-items: center; padding-right: 6px; margin-right: 2px; border-right: 1px solid rgba(255, 255, 255, .1); }
.songstep .btn.icon:disabled { opacity: .3; }
.song-head .tools .sid { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
@media (min-width: 900px) {
  .song-head { grid-template-columns: 44px minmax(0, 1fr) auto auto; padding-left: 12px; padding-right: 12px; }
  .song-head .tools { grid-column: auto; margin: 0; border: 0; padding: 0; gap: 4px; }
}
.keysel {
  -webkit-appearance: none; appearance: none;
  min-height: 44px; min-width: 76px; border-radius: var(--radius-sm); background: var(--surface) no-repeat right 8px center / 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  border: 1px solid var(--line); padding: 0 30px 0 12px; font: 700 17px var(--chart-font); cursor: pointer;
}
.keysel:disabled { opacity: .6; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; font-size: 15px; white-space: nowrap; text-decoration: none; color: var(--text);
  transition: background-color .15s, transform .1s, opacity .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--pill); border-color: var(--pill); color: var(--pill-text); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.claude { border-color: var(--claude); color: var(--claude); }
.btn.danger { color: var(--error); }
.btn.icon { width: 44px; padding: 0; font-size: 19px; background: transparent; border-color: transparent; color: inherit; }
.btn.icon:hover { background: var(--surface-2); }
.btn.icon.on { background: var(--surface); border-color: var(--line); color: var(--accent-text); }
.btn.sync.on { background: var(--sync); border-color: var(--sync); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); padding: 2px; gap: 2px; }
.seg button { border: 0; border-radius: 8px; background: transparent; min-height: 38px; padding: 0 12px; cursor: pointer; font-size: 14px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--pill); color: var(--pill-text); font-weight: 700; }

/* ---- cards & lists ---- */
.eyebrow { margin: 8px 4px 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.card {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 12px 14px 14px; margin-bottom: 12px; border-radius: var(--radius); min-height: 72px;
  background: var(--surface); border: 1px solid var(--line); text-align: left; cursor: pointer; color: var(--text);
  box-shadow: var(--shadow);
}
.card:hover { background: var(--surface-2); }
.card.dashed { border-style: dashed; border-width: 2px; box-shadow: none; }
.card h3 { margin: 0; font-size: 18px; }
.card p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.grow { flex: 1; min-width: 0; }
.tile { width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; background: var(--tile); color: var(--icon-tint); }
.chev { color: var(--muted); display: grid; place-items: center; flex-shrink: 0; width: 24px; cursor: pointer; }

.list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.item {
  display: flex; align-items: center; gap: 8px; padding: 12px 6px 12px 4px; min-height: 64px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  touch-action: pan-y;
}
.item:last-child { border-bottom: 0; }
.item.dragging { opacity: .92; background: var(--surface-2); outline: 2px solid var(--pill); position: relative; z-index: 2; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.item .grip { color: var(--muted); cursor: grab; align-self: stretch; display: grid; place-items: center; width: 24px; margin: -12px 0; touch-action: none; user-select: none; font-size: 18px; opacity: .7; }
.item .num { color: var(--muted); min-width: 20px; text-align: right; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; align-self: flex-start; padding-top: 1px; }
.item .main { flex: 1; min-width: 0; cursor: pointer; padding-left: 4px; }
.item .btn.icon { flex-shrink: 0; color: var(--muted); }
.item .btn.icon.on { color: var(--accent-text); }
.item .tile { margin-left: 4px; }
.rowchips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.rowchips:empty { display: none; }
.rowchips .chip[data-match] { min-height: 28px; padding: 2px 10px; cursor: pointer; background: transparent; font: inherit; font-size: 12px; font-weight: 700; }
.noart { width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 20px; }
.linkbtn { background: none; border: 0; padding: 4px 2px; color: var(--accent-text); font: inherit; text-decoration: underline; cursor: pointer; }
input[type=search].sticky-search {
  position: sticky; top: calc(var(--head) + var(--safe-t) + 8px); z-index: 4;
  padding-left: 40px !important; box-shadow: 0 0 0 8px var(--bg), var(--shadow);
  background: var(--surface) no-repeat 12px center / 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}
.item h3 { margin: 0; font-size: 17px; line-height: 1.3; font-weight: 650; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.item p { margin: 2px 0 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; }
.empty-state { text-align: center; padding: 40px 24px 32px; color: var(--muted); }
.empty-state .tile { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px; }
.empty-state .tile svg { width: 30px; height: 30px; }
.empty-state h3 { margin: 0 0 4px; color: var(--text); font-size: 18px; }
.empty-state p { margin: 0; font-size: 15px; }

/* ---- status chips ---- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 22px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 700; line-height: 1.4; border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.key { color: var(--text); font-family: var(--chart-font); font-size: 13px; background: var(--surface-2); }
.chip.claude { color: var(--claude); border-color: var(--claude); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.chip.error { color: var(--error); border-color: var(--error); }
.chip.mine { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent-text) 55%, transparent); }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---- set page ---- */
.set-title { margin: 4px 0 14px; font-size: 30px; line-height: 1.15; font-weight: 800; cursor: pointer; overflow-wrap: anywhere; }
.set-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.set-actions .btn { padding: 0 10px; min-width: 0; }
@media (min-width: 640px) { .set-actions { display: flex; flex-wrap: wrap; } }

/* ---- song view ---- */
.song-body { background: var(--chart-bg); min-height: calc(100vh - 120px); }
.banner { margin: 12px 16px 0; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.banner .btn { margin-left: 0 !important; min-height: 38px; }
.banner.claude { border-color: var(--claude); color: var(--claude); }
.banner.error { border-color: var(--error); color: var(--error); }
.banner.warn { border-color: var(--warn); color: var(--warn); }

.layout { display: flex; gap: 24px; align-items: flex-start; max-width: 1400px; margin: 0 auto; padding: 20px 16px 0; }
.chart { flex: 1; min-width: 0; padding-bottom: 60vh; }
.structure {
  position: sticky; top: 90px; width: 220px; flex-shrink: 0;
  background: var(--bar); border-radius: 14px; padding: 12px;
}
.structure .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; padding: 2px 10px 8px; }
.structure .lbl { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.structure .snotes-btn { width: auto; min-height: 30px; padding: 2px 8px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-text); background: transparent; border: 1px solid var(--line); border-radius: 6px; }
.structure .snote { padding: 0 10px 6px; font-size: 13px; line-height: 1.35; color: var(--muted); white-space: pre-wrap; }
.structure .snote-in { width: 100%; min-height: 34px; margin: 2px 0 8px; padding: 4px 8px; font-size: 13px; }
.structure button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font-weight: 600; font-size: 17px; cursor: pointer;
  text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.structure button.active { background: var(--pill); color: var(--pill-text); }
.structure .off { display: block; padding: 8px 10px; color: var(--muted); font-weight: 600; font-size: 17px; text-transform: uppercase; }
.structure .hint { font-size: 12px; color: var(--muted); padding: 8px 10px 0; margin: 0; }
.structure .nav-close, .scroller .nowsec { display: none; }
.structure .snotes-btn { flex-shrink: 0; overflow: visible; }

/* Phones: the structure is a sheet above the bottom bar, opened from the current part
   shown in the bar. The chart above it stays readable and keeps scrolling. */
@media (max-width: 899px) {
  .scroller .sline { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; max-width: 460px; }
  .scroller .nowsec {
    display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 64%; min-height: 36px; margin-right: -6px; padding: 0 6px 0 10px;
    border: 0; border-radius: 10px; background: transparent; color: var(--accent-text); cursor: pointer;
    font: 700 13px var(--chart-font); text-transform: uppercase; letter-spacing: .08em;
  }
  .scroller .nowsec b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .scroller .nowsec svg { width: 18px; height: 18px; }
  .scroller .nowsec svg:last-child { width: 16px; height: 16px; transition: transform .2s; }
  .scroller .nowsec:active { background: var(--surface-2); }
  html.nav-open .scroller .nowsec { background: var(--surface); }
  html.nav-open .scroller .nowsec svg:last-child { transform: rotate(180deg); }

  .structure {
    display: none; position: fixed; z-index: 5; left: 0; right: 0; top: auto; width: auto;
    bottom: calc(108px + var(--safe-b)); max-height: 52dvh; overflow-y: auto; overscroll-behavior: contain;
    padding: 0 8px 10px calc(8px + var(--safe-l)); border-radius: 20px 20px 0 0;
    background: var(--sheet); border-top: 1px solid var(--line); box-shadow: var(--shadow-lg);
  }
  html.nav-open .structure { display: block; }
  .structure.anim { animation: sheet-in .22s var(--ease); }
  .structure .lbl {
    position: sticky; top: 0; z-index: 2; margin: 0 -8px 4px; padding: 16px 8px 6px 18px; background: var(--sheet);
    font-size: 12px; font-weight: 700; letter-spacing: .12em;
  }
  .structure .lbl::before { content: ""; position: absolute; top: 6px; left: 50%; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: var(--line); }
  .structure .lbl > span { flex: 1; }
  .structure .snotes-btn { min-height: 40px; padding: 0 14px; font-size: 13px; border-radius: 10px; }
  .structure .nav-close { display: inline-grid; place-items: center; width: 44px; min-height: 44px; padding: 0; font-size: 18px; text-align: center; color: var(--muted); }

  .structure .srow { position: relative; border-radius: 12px; }
  .structure .srow + .srow { margin-top: 2px; }
  .structure button[data-jump] {
    min-height: 52px; padding: 12px 14px; font: 700 18px/1.3 var(--chart-font); letter-spacing: .06em;
    color: var(--text); white-space: normal; border-radius: 12px;
  }
  .structure button[data-jump]::after { content: ""; position: absolute; inset: 0; border-radius: 12px; } /* the whole row, note too, is the target */
  .structure button[data-jump]:active::after { background: rgba(255, 255, 255, .06); }
  .structure button.active { background: none; }
  .structure .srow:has(.active) { background: var(--pill); }
  .structure .srow:has(.active) button, .structure .srow:has(.active) .snote, .structure .srow:has(.active) .sx { color: var(--pill-text); }
  .structure .sx { margin-left: 4px; color: var(--accent-text); }
  .structure .off { min-height: 52px; padding: 12px 14px; font: 700 18px/1.3 var(--chart-font); letter-spacing: .06em; text-transform: uppercase; color: var(--text); }
  .structure .off .sx { color: inherit; }
  .structure .snote { margin-top: -8px; padding: 0 14px 12px; font-size: 15px; line-height: 1.4; color: var(--muted); }
  .structure .hint { padding: 10px 14px 0; font-size: 13px; }

  /* Editing notes: the sheet grows over the bottom bar, with a dimmed page behind. */
  html.nav-open .structure.editing { z-index: 9; bottom: 0; max-height: calc(100dvh - var(--safe-t) - 56px); padding-bottom: calc(16px + var(--safe-b)); }
  html.nav-open:has(.structure.editing) body::after { content: ""; position: fixed; inset: 0; z-index: 8; background: rgba(0, 0, 0, .55); }
  .structure .snote-in { position: relative; z-index: 1; display: block; width: calc(100% - 28px); min-height: 44px; margin: -4px 14px 12px; padding: 8px 12px; font-size: 16px; }
  .structure.editing .srow:has(.active) .snote-in { background: rgba(0, 0, 0, .12); border-color: rgba(0, 0, 0, .3); color: var(--pill-text); }
  .structure.editing .srow:has(.active) .snote-in::placeholder { color: rgba(0, 0, 0, .5); }
}
@media (prefers-reduced-motion: reduce) { .structure.anim { animation: none; } }

/* A: compact chart */
.section { margin-bottom: 26px; scroll-margin-top: 140px; }
.section-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.pill {
  background: var(--pill); color: var(--pill-text); font: 700 14px/1 var(--chart-font); text-transform: uppercase;
  letter-spacing: .1em; padding: 6px 9px; border-radius: 6px; border: 0; cursor: pointer;
}
.pill.low { background: transparent; color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn); }
.xn { font: 700 calc(var(--chart-size) * .75) var(--chart-font); color: var(--accent-text); }
.lock { color: var(--muted); font-size: 13px; }
.same { color: var(--muted); font: 600 15px var(--chart-font); text-transform: uppercase; letter-spacing: .06em; }
.cue { color: var(--muted); font-style: italic; font-size: 15px; }
.chords { color: var(--chord); font: var(--chart-weight) var(--chart-size)/1.7 var(--chart-font); white-space: pre-wrap; overflow-wrap: anywhere; }
.chords .ln { display: block; }
.chords .bar { display: inline-block; max-width: 100%; }
.chords .t { white-space: nowrap; }
.chords .t { color: var(--accent-text); }
.note { color: var(--muted); font-size: 15px; margin-top: 2px; }
.suggest { margin-top: 6px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px dashed var(--claude); color: var(--claude); font-size: 15px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.suggest code { font: 700 17px var(--chart-font); color: var(--chord); }
.section.now .pill { outline: 3px solid var(--chord); outline-offset: 2px; }

/* B: song map */
.map { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.map button { font: 700 14px var(--chart-font); text-transform: uppercase; letter-spacing: .06em; padding: 7px 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; }
.map button.active { background: var(--pill); border-color: var(--pill); color: var(--pill-text); }
.map .xn { font-size: 15px; }
.map button.active .xn { color: var(--pill-text); }
.sheet-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.sheet-card.active { border-color: var(--pill); }
.sheet-card .count { color: var(--muted); font-size: 13px; }

/* C: now / next */
.nownext { display: grid; gap: 14px; padding: 16px; max-width: 1100px; margin: 0 auto; }
.nownext .now { border: 2px solid var(--pill); border-radius: 16px; padding: 16px; min-height: 45vh; }
.now .chords { font-size: calc(var(--chart-size) * 1.5); }
.next { border: 1px dashed var(--line); border-radius: 14px; padding: 12px 16px; opacity: .75; }
.next .chords { font-size: calc(var(--chart-size) * .8); }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--pill); }
#followbadge {
  position: fixed; left: calc(12px + var(--safe-l)); bottom: calc(118px + var(--safe-b)); z-index: 19;
  display: flex; align-items: center; gap: 2px; padding: 2px 2px 2px 12px; border-radius: 999px;
  background: var(--sheet); border: 1px solid var(--sync); color: var(--sync); font-size: 13px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
#followbadge button { border: 0; background: transparent; color: inherit; font: inherit; padding: 6px 8px; cursor: pointer; border-radius: 999px; }
#followbadge button:first-child:not([data-fb="stop"]) { padding-left: 0; }
/* Free-text chart editor: the text gets the screen. */
.editor-top { background: var(--bar); padding-left: 16px; }
.editor-top h1 { font-size: 17px; }
.editor-top .autosave { display: block; }
.editor { padding-top: 0; }
.editor .chart-text.free {
  display: block; min-height: 0; height: calc(100dvh - var(--head) - var(--safe-t) - 120px); width: calc(100% + 32px); margin: 0 -16px;
  padding: 16px; border: 0; border-radius: 0; box-shadow: none; resize: none;
  background: var(--chart-bg); color: var(--chord); caret-color: var(--pill);
  font: 700 22px/1.6 var(--chart-font); -webkit-text-size-adjust: 100%;
}
.editor .chart-text.free:focus, .editor .chart-text.free:focus-visible { box-shadow: none; border: 0; outline: none; }
.editor .chart-text.free::selection { background: color-mix(in srgb, var(--pill) 45%, transparent); }
.editor .hint { margin: 12px 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.song-details { margin-bottom: 40vh; border-top: 1px solid var(--line); }
.song-details summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; color: var(--muted); font-weight: 600; }
.song-details[open] summary { color: var(--text); }
.tap-edit { cursor: pointer; }
@media (hover: hover) { .tap-edit:hover .chords { outline: 1px dashed var(--line); outline-offset: 4px; border-radius: 4px; } }
.tapzone { position: fixed; top: 140px; bottom: 90px; width: 30%; z-index: 1; }
.tapzone.l { left: 0; } .tapzone.r { right: 0; }

/* Count-in flash */
.countin { position: fixed; inset: 0; display: grid; place-items: center; font: 800 30vmin var(--chart-font); color: var(--pill); background: rgba(0,0,0,.6); z-index: 40; pointer-events: none; }

.meta { margin-top: 40px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.meta h4 { margin: 0 0 6px; color: var(--text); font-size: 15px; display: flex; flex-wrap: wrap; gap: 6px; }
.meta ul { margin: 6px 0 12px; padding-left: 18px; }
.meta li { margin: 3px 0; }
.meta .src-bad { color: var(--warn); }

.lyrics { white-space: pre-wrap; font: var(--lyrics-weight, 700) var(--lyrics-size, 26px)/1.5 var(--ui-font); color: var(--chord); padding-bottom: 24px; }
.lyrics-tools { margin: 12px 0 50vh; }
.song-body .hint { color: var(--muted); font-size: 14px; }
.empty-actions { justify-content: center; }

/* Floating YouTube player, as in the old app: small, draggable by its title bar. */
.ytfloat { position: fixed; z-index: 20; border-radius: 14px; overflow: hidden; background: #000; border: 1px solid var(--line); box-shadow: 0 12px 36px rgba(0,0,0,.55); }
.ytbar { display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 2px 0 12px; background: var(--sheet); color: var(--text); cursor: grab; touch-action: none; user-select: none; }
.ytfloat.dragging .ytbar { cursor: grabbing; }
.ytfloat.dragging iframe { pointer-events: none; }
.yttitle { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ytbar button { width: 40px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font-size: 15px; cursor: pointer; }
.ytbar button:hover { background: var(--surface-2); }
.ytbody iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; }
.ytnone { aspect-ratio: 16 / 9; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 10px 12px; background: var(--surface); color: var(--muted); font-size: 13px; overflow: auto; }
.ytnone b { color: var(--text); font-size: 14px; }
.ytnone .btn { min-height: 34px; padding: 0 10px; font-size: 13px; }

/* Bottom bar, as in the old app: speed above, buttons below. */
.scroller {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; justify-items: center; gap: 4px;
  padding: 6px calc(12px + var(--safe-r)) calc(8px + var(--safe-b)) calc(12px + var(--safe-l));
  background: var(--bar); box-shadow: 0 -1px 0 rgba(0, 0, 0, .25), 0 -6px 20px rgba(0, 0, 0, .2);
}
.scroller .speed { color: var(--muted); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.scroller .row { display: grid; grid-template-columns: 1fr 1fr 1.7fr 1fr 1fr; gap: 8px; width: 100%; max-width: 460px; }
.scroller .btn { background: var(--surface); min-width: 0; min-height: 48px; padding: 0; font-size: 22px; font-weight: 600; }
.scroller .btn.play { font-size: 16px; background: var(--pill); border-color: var(--pill); color: var(--pill-text); gap: 6px; }

/* ---- forms, dialogs, sheets ---- */
input[type=text], input[type=password], input[type=search], input[type=number], input[type=url], textarea, select.field {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line); outline: none; font-size: 16px; /* 16px: iOS doesn't zoom */
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--pill); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pill) 22%, transparent); }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
select.field {
  -webkit-appearance: none; appearance: none; padding-right: 36px; cursor: pointer;
  background: var(--surface) no-repeat right 12px center / 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
textarea.chart-text { min-height: 50vh; font: 700 17px/1.7 var(--chart-font); resize: vertical; }
textarea.sec-text { min-height: 26vh; font: 700 20px/1.7 var(--chart-font); }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 12px; }
.grid2 label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
code { font-family: var(--chart-font); font-size: .92em; padding: 1px 4px; border-radius: 4px; background: var(--surface-2); }

dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); padding: 0;
  border: 1px solid var(--line); border-radius: 20px; background: var(--sheet); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45); overscroll-behavior: contain;
}
dialog.sheet { width: 100vw; max-width: 720px; margin: auto auto 0; border-radius: 20px 20px 0 0; max-height: 88dvh; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog[open] { animation: dlg-in .2s var(--ease); }
dialog[open]::backdrop { animation: fade-in .2s ease; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
.dlg { padding: 20px; padding-bottom: calc(20px + var(--safe-b)); }
.autosave { font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0; text-transform: none; }
.autosave.ok { color: var(--sync); } .autosave.warn { color: var(--warn); } .autosave.error { color: var(--error); }
.dlg h2 { margin: 0 0 6px; font-size: 20px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.dlg h2 > .btn { flex-shrink: 0; min-height: 38px; padding: 0 14px; }
.dlg h2 > .btn.icon { width: 38px; padding: 0; background: var(--surface); border-color: var(--line); font-size: 15px; border-radius: 999px; }
.dlg h3 { margin: 22px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.dlg .hint { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.dlg .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
dialog.create-set { width: calc(100vw - 24px); max-width: 640px; max-height: calc(100dvh - 24px); overflow-y: auto; }
textarea.paste-songs { width: 100%; font: 500 15px/1.5 var(--chart-font); resize: vertical; }
.paste-out { max-height: 30vh; overflow-y: auto; font-size: 14px; line-height: 1.6; }
.paste-out .weak { color: var(--warn); }
.dlg hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; min-height: 52px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.setrow > span { font-size: 15px; flex: 1 1 140px; min-width: 0; }
.setrow .row { flex-wrap: nowrap; gap: 6px; }
.setrow .row > span { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.setrow .row .btn { min-width: 48px; padding: 0 10px; }
.results { margin: 10px -8px 0; max-height: 50dvh; overflow: auto; overscroll-behavior: contain; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 8px; border: 0; border-radius: 12px;
  background: none; text-align: left; cursor: pointer;
}
.result:hover, .result:focus-visible { background: var(--surface-2); }
.result > div { min-width: 0; }
.result img { width: 44px; height: 44px; border-radius: 8px; background: var(--surface-2); flex-shrink: 0; object-fit: cover; }
.result b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result span { color: var(--muted); font-size: 13px; }
.result.in-set { opacity: .5; }

.menu { display: grid; gap: 8px; }
.menu .btn { justify-content: flex-start; min-height: 48px; padding: 0 14px; font-weight: 500; }
.history li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }

.login { max-width: 360px; margin: 0 auto; padding: calc(16vh + var(--safe-t)) 24px 24px; text-align: center; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.login h1 { margin: 0 0 6px; font-size: 28px; }
.login .hint { color: var(--muted); margin: 0 0 20px; }
.login .btn { width: 100%; margin-top: 12px; min-height: 48px; font-size: 16px; }

#toast {
  position: fixed; left: 50%; bottom: calc(118px + var(--safe-b)); transform: translateX(-50%) translateY(16px);
  width: max-content; max-width: calc(100vw - 32px); min-height: 48px;
  padding: 8px 8px 8px 16px; border-radius: 14px; background: var(--sheet); border: 1px solid var(--line);
  box-shadow: 0 10px 32px rgba(0, 0, 0, .4); font-size: 15px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease); z-index: 50;
  display: flex; gap: 8px; align-items: center;
}
#toast span { padding: 4px 8px 4px 0; }
#toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
#toast.error { border-color: var(--error); color: var(--error); }
#toast button { background: none; border: 0; color: var(--accent-text); font-weight: 700; cursor: pointer; min-height: 36px; padding: 0 10px; border-radius: 8px; text-transform: uppercase; letter-spacing: .04em; font-size: 14px; }

@media (max-width: 560px) {
  :root { --chart-size: 28px; }
  .wrap { padding-left: 12px; padding-right: 12px; }
  .editor .chart-text.free { width: calc(100% + 24px); margin: 0 -12px; padding: 14px 12px; }
}

/* Phones: every dialog is a bottom sheet with a grab handle. */
@media (max-width: 640px) {
  dialog, dialog.sheet, dialog.create-set {
    width: 100%; max-width: 100%; margin: auto 0 0; border-width: 1px 0 0;
    border-radius: 22px 22px 0 0; max-height: calc(100dvh - var(--safe-t) - 16px);
    box-shadow: var(--shadow-lg);
  }
  dialog[open] { animation: sheet-in .28s var(--ease); }
  .dlg { padding: 8px 16px calc(16px + var(--safe-b)); }
  .dlg::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
  .dlg .actions > .btn { flex: 1 1 0; }
  .dlg .actions > .row { flex: 1 1 100%; flex-wrap: nowrap; }
  .dlg .actions > .row > .btn { flex: 1 1 0; min-width: 0; padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  #toast, .btn { transition: none; }
  dialog[open], dialog[open]::backdrop { animation: none; }
  .btn:active:not(:disabled) { transform: none; }
}

/* Phones: keep song titles readable in lists. */
@media (max-width: 520px) { .item .chip.lyr { display: none; } }
@media (max-width: 420px) { .wide-only { display: none; } }

/* Big enough to hit on stage. */
.pill { min-height: 36px; }
#followbadge button { min-height: 40px; min-width: 40px; }

/* The toast is shown as a popover so it sits above open dialogs. */
#toast[popover] { inset: auto; margin: 0; left: 50%; bottom: calc(118px + var(--safe-b)); color: var(--text); overflow: visible; }
#toast[popover].error { color: var(--error); }

/* Stage-size targets for the small controls. */
.pill { min-height: 40px; }
.rowchips .chip[data-match] { min-height: 40px; }

/* Structure parts that aren't linked to the chart: a plain list, same look, no highlight. */
.structure .part { display: block; padding: 8px 10px; color: var(--text); font-weight: 600; font-size: 17px; text-transform: uppercase; }
@media (max-width: 899px) { .structure .part { min-height: 52px; padding: 12px 14px; font: 700 18px/1.3 var(--chart-font); letter-spacing: .06em; } }

/* Renaming parts in the structure panel. */
.structure .sname-in { width: 100%; min-height: 40px; margin: 6px 0 2px; padding: 6px 10px; font: 700 15px var(--chart-font); text-transform: uppercase; letter-spacing: .04em; }

/* Desktop sidebar: header buttons wrap, and a long structure scrolls inside it. */
@media (min-width: 900px) {
  .structure { max-height: calc(100vh - 200px); overflow-y: auto; overscroll-behavior: contain; }
  .structure .lbl { flex-wrap: wrap; }
}
.structure.editing .sname-in, .structure.editing .snote-in { margin-left: 0; margin-right: 0; width: 100%; }

/* The chart shows sections exactly as the editor writes them: names as typed. */
.section .pill, .sheet-card .pill, .now .pill, .next .pill { text-transform: none; letter-spacing: .02em; }

/* Structure header: the title and small icon buttons on one line. */
.structure .lbl { flex-wrap: nowrap !important; gap: 4px; }
.structure .lbl > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.structure .snotes-btn.icon-only { width: 36px; min-width: 36px; height: 32px; min-height: 32px; padding: 0; display: inline-grid; place-items: center; font-size: 16px; letter-spacing: 0; }
@media (max-width: 899px) { .structure .snotes-btn.icon-only { width: 44px; min-width: 44px; height: 40px; min-height: 40px; font-size: 18px; } }

/* Desktop: the structure header (✎ / ＋ / ✓) stays in view while the list scrolls. */
@media (min-width: 900px) {
  .structure .lbl { position: sticky; top: -12px; z-index: 1; background: var(--bar); margin: -12px -12px 0; padding: 12px 22px 8px; }
}

/* Structure names as typed, like the chart and the editor. */
.structure button, .structure .part, .structure .off, .structure .sname-in, #nowsec { text-transform: none !important; letter-spacing: .02em; }
