*, *::before, *::after { box-sizing: border-box; }

  :root {
    color-scheme: dark;

    --ground:    #141110;
    --ground-2:  #191514;
    --panel:     #1F1A18;
    --panel-2:   #272120;
    --panel-3:   #2F2826;
    --line:      #342C29;
    --line-soft: #292220;

    --ink:   #F4EEE7;
    --ink-2: #BDB2AA;
    --ink-3: #8A7F79;
    --ink-4: #635A56;

    --brass:      #E0A951;
    --brass-soft: #F0C784;
    --brass-deep: #8A6528;
    --brass-wash: rgba(224, 169, 81, 0.10);

    --yes:   #63A375;
    --maybe: #8B93A8;
    --no:    #C0645C;

    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --sans:  "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono:  "Cascadia Mono", Consolas, "SF Mono", ui-monospace, Menlo, monospace;

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;

    --rail: 220px;
  }

  /* This app is dark by design — the viewer's light toggle must not undo it. */
  :root[data-theme="light"] { color-scheme: dark; }

  html, body {
    margin: 0;
    padding: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  body { min-height: 100vh; overflow-x: hidden; }

  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; border: 0; background: none; }

  :focus-visible {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
    border-radius: 3px;
  }

  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.001ms !important;
      transition-duration: 0.001ms !important;
    }
  }

  .u-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
  .u-label {
    font-size: 0.68rem;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--ink-3);
    font-weight: 600;
  }
  .u-hidden { display: none !important; }

  /* ─────────────────────────  GATE  ───────────────────────── */

  .gate {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
      radial-gradient(120% 90% at 50% -10%, #211a17 0%, var(--ground) 62%);
  }
  .gate.is-leaving { animation: gateOut 520ms ease forwards; }
  @keyframes gateOut {
    to { opacity: 0; transform: scale(1.03); visibility: hidden; }
  }

  .gate__card {
    width: 100%;
    max-width: 380px;
    text-align: center;
    animation: gateIn 620ms cubic-bezier(.2,.7,.3,1) both;
  }
  @keyframes gateIn {
    from { opacity: 0; transform: translateY(10px); }
  }

  .gate__rule {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--brass-deep) 25%, var(--brass-deep) 75%, transparent);
    margin: 20px 0;
  }
  .gate__mark {
    font-family: var(--serif);
    font-size: clamp(2rem, 9vw, 2.7rem);
    line-height: 1.1;
    margin: 0;
    font-weight: 400;
    letter-spacing: 0.01em;
  }
  /* "Oak Grove" in the off-white ink, "Song List" in brass italic serif. */
  .gate__mark em {
    display: block;
    font-style: italic;
    color: var(--brass);
    margin-top: 2px;
  }
  .gate__sub {
    font-size: 0.72rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin: 0;
  }
  .gate__msg {
    color: var(--ink-2);
    font-size: 0.9rem;
    margin: 0 0 20px;
    min-height: 2.6em;
  }
  .gate__msg strong { color: var(--ink); font-weight: 600; }

  .field {
    display: block;
    width: 100%;
    padding: 12px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    color: var(--ink);
    transition: border-color 140ms ease, background 140ms ease;
  }
  .field::placeholder { color: var(--ink-4); }
  .field:focus { border-color: var(--brass-deep); background: var(--panel-2); }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: var(--r-md);
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
  }
  .btn--primary {
    background: var(--brass);
    color: #23180A;
    width: 100%;
  }
  .btn--primary:hover { background: var(--brass-soft); }
  .btn--ghost {
    border: 1px solid var(--line);
    color: var(--ink-2);
    background: var(--panel);
  }
  .btn--ghost:hover { border-color: var(--ink-4); color: var(--ink); }

  /* Destructive actions read as destructive before they're tapped. */
  .btn--dangerghost { color: var(--no); border-color: rgba(192, 100, 92, 0.4); }
  .btn--dangerghost:hover { color: var(--no); border-color: var(--no); background: rgba(192, 100, 92, 0.1); }
  .btn--danger { background: var(--no); color: #1B0E0D; }
  .btn--danger:hover { background: #D07A72; }
  .btn--quiet { color: var(--ink-3); font-weight: 500; font-size: 0.82rem; padding: 6px 4px; }
  .btn--quiet:hover { color: var(--brass); }

  .gate__form { display: flex; flex-direction: column; gap: 10px; }

  .gate__note {
    margin: 22px 0 0;
    font-size: 0.74rem;
    line-height: 1.55;
    color: var(--ink-4);
    border-top: 1px solid var(--line-soft);
    padding-top: 14px;
  }
  .gate__err {
    text-align: left;
    font-size: 0.79rem;
    color: var(--no);
    margin: -2px 0 0;
  }

  .gate__card.is-wrong { animation: shake 400ms ease; }
  @keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-7px); }
    40%, 60% { transform: translateX(7px); }
  }

  .whogrid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 16px 0 12px;
  }
  .whobtn {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 11px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--panel);
    text-align: left;
    transition: border-color 130ms ease, background 130ms ease;
  }
  .whobtn:hover { border-color: var(--brass-deep); background: var(--panel-2); }
  .whobtn__n { font-size: 0.85rem; font-weight: 600; line-height: 1.2; }
  .whobtn__p { font-size: 0.67rem; color: var(--ink-3); }

  /* ─────────────────────────  SHELL  ───────────────────────── */

  .shell { display: flex; min-height: 100vh; }

  .rail {
    width: var(--rail);
    flex: 0 0 var(--rail);
    border-right: 1px solid var(--line-soft);
    background: var(--ground-2);
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .rail__brand {
    font-family: var(--serif);
    font-size: 1.28rem;
    line-height: 1.15;
    padding: 0 8px;
    margin: 0;
    font-weight: 400;
  }
  .rail__brand { color: var(--ink); }
  .rail__brand em {
    display: block;
    font-style: italic;
    color: var(--brass);
    margin-top: 1px;
  }

  .rail__nav { display: flex; flex-direction: column; gap: 2px; }

  .navlink {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 10px;
    border-radius: var(--r-md);
    color: var(--ink-2);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    transition: background 130ms ease, color 130ms ease;
  }
  .navlink:hover { background: var(--panel); color: var(--ink); }
  .navlink[aria-current="page"] {
    background: var(--brass-wash);
    color: var(--brass-soft);
  }
  .navlink svg { flex: 0 0 18px; }
  .navlink__count {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--ink-4);
  }
  .navlink[aria-current="page"] .navlink__count { color: var(--brass); }

  .rail__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

  .whoami {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-md);
    background: var(--panel);
    border: 1px solid var(--line-soft);
  }
  .whoami__name { font-size: 0.84rem; font-weight: 600; line-height: 1.2; }
  .whoami__role { font-size: 0.68rem; color: var(--ink-3); }

  .avatar {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.74rem;
    font-weight: 700;
    background: var(--panel-3);
    color: var(--brass-soft);
    border: 1px solid var(--line);
  }
  .avatar--sm { flex-basis: 24px; width: 24px; height: 24px; font-size: 0.64rem; }

  .main { flex: 1; min-width: 0; padding: 30px 34px 90px; }
  .wrap { max-width: 1060px; margin: 0 auto; }

  .topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 26px;
  }
  .topbar h1 {
    font-family: var(--serif);
    font-size: clamp(1.6rem, 3.6vw, 2.1rem);
    font-weight: 400;
    margin: 4px 0 0;
    text-wrap: balance;
    line-height: 1.15;
  }

  /* ─────────────────────────  CARDS  ───────────────────────── */

  .card {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-lg);
    padding: 18px;
  }

  .grid { display: grid; gap: 14px; }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--2 { grid-template-columns: repeat(2, 1fr); }

  .stack { display: flex; flex-direction: column; gap: 14px; }
  .row { display: flex; align-items: center; gap: 10px; }
  .row--wrap { flex-wrap: wrap; }
  .push { margin-left: auto; }

  .section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }
  .section-head h2 {
    font-family: var(--serif);
    font-size: 1.2rem;
    font-weight: 400;
    margin: 0;
  }

  /* Next-up hero */
  .nextup {
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background:
      linear-gradient(180deg, rgba(224,169,81,0.055), rgba(224,169,81,0) 55%),
      var(--panel);
    padding: 20px;
  }
  .nextup__date {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--brass);
    letter-spacing: 0.06em;
  }
  .nextup__title {
    font-family: var(--serif);
    font-size: 1.5rem;
    font-weight: 400;
    margin: 4px 0 2px;
  }
  .nextup__meta { color: var(--ink-3); font-size: 0.85rem; }

  /* Status control */
  .statusbar { display: flex; gap: 8px; flex-wrap: wrap; }
  .statusbtn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--ink-2);
    font-size: 0.82rem;
    font-weight: 600;
    transition: border-color 130ms ease, color 130ms ease, background 130ms ease;
  }
  .statusbtn:hover { border-color: var(--ink-4); color: var(--ink); }
  .statusbtn .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: currentColor; opacity: 0.55;
  }
  .statusbtn[data-on="true"] { background: var(--panel-3); }
  .statusbtn[data-on="true"] .dot { opacity: 1; }
  .statusbtn[data-s="yes"][data-on="true"]   { color: var(--yes);   border-color: var(--yes); }
  .statusbtn[data-s="maybe"][data-on="true"] { color: var(--maybe); border-color: var(--maybe); }
  .statusbtn[data-s="no"][data-on="true"]    { color: var(--no);    border-color: var(--no); }

  /* Tally chips */
  .tally { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; }
  .tally__item { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
  .tally__dot { width: 8px; height: 8px; border-radius: 50%; }
  .tally__n { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }

  /* Dashboard entry tiles */
  .tile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-lg);
    transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
  }
  .tile:hover { border-color: var(--brass-deep); background: var(--panel-2); transform: translateY(-2px); }
  .tile__icon { color: var(--brass); }
  .tile__n {
    font-family: var(--mono);
    font-size: 1.8rem;
    font-variant-numeric: tabular-nums;
    line-height: 1;
  }
  .tile__name { font-family: var(--serif); font-size: 1.1rem; }
  .tile__desc { font-size: 0.82rem; color: var(--ink-3); line-height: 1.45; }

  /* ─────────────────────────  SONGS  ───────────────────────── */

  .toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
  }
  .search { position: relative; flex: 1 1 240px; min-width: 0; }
  .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); }
  .search .field { padding-left: 38px; }

  .chipset { display: flex; gap: 6px; flex-wrap: wrap; }
  .chip {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink-3);
    font-size: 0.78rem;
    font-weight: 600;
    transition: color 130ms ease, border-color 130ms ease;
  }
  .chip:hover { color: var(--ink); }
  .chip[aria-pressed="true"] { color: var(--brass-soft); border-color: var(--brass-deep); background: var(--brass-wash); }

  .chip--alert { color: var(--no); border-color: rgba(192, 100, 92, 0.4); }
  .chip--alert:hover { color: var(--no); border-color: var(--no); }
  .chip--alert[aria-pressed="true"] {
    color: var(--no);
    border-color: var(--no);
    background: rgba(192, 100, 92, 0.12);
  }

  .addform { display: flex; flex-direction: column; gap: 15px; }
  .addform .u-label { display: block; margin-bottom: 6px; }
  .addform .modal__hint { margin: 0; }

  .songlist {
    /* Last column is fixed, not auto: an auto column sizes to its content, so the
       header ("Link") and the rows ("Listen"/"Find") would resolve the flexible
       columns differently and the labels would drift off their columns. */
    --songcols: 54px 112px minmax(0, 1.5fr) minmax(0, 1fr) 92px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--panel);
  }

  .songhead {
    display: grid;
    grid-template-columns: var(--songcols);
    align-items: center;
    gap: 14px;
    padding: 9px 16px;
    background: var(--ground-2);
    border-bottom: 1px solid var(--line);
  }

  .songrow {
    position: relative;
    display: grid;
    grid-template-columns: var(--songcols);
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line-soft);
    transition: background 120ms ease;
  }
  .songrow:last-child { border-bottom: 0; }
  .songrow:hover { background: var(--panel-2); }
  .songrow:focus-visible { background: var(--panel-2); }

  .songrow__song {
    font-family: var(--serif);
    font-size: 1.02rem;
    line-height: 1.25;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .songrow__artist {
    font-size: 0.82rem;
    color: var(--ink-3);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ytbtn {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--ink-2);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color 130ms ease, border-color 130ms ease, background 130ms ease;
  }
  .ytbtn:hover { color: var(--brass-soft); border-color: var(--brass-deep); background: var(--brass-wash); }
  .ytbtn--set { color: var(--brass-soft); border-color: var(--brass-deep); }
  .ytbtn--find { color: var(--ink-4); }
  .ytbtn--find:hover { color: var(--ink-2); }

  .keybadge {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    padding: 3px 8px;
    border-radius: var(--r-sm);
    background: var(--panel-3);
    border: 1px solid var(--line);
    color: var(--brass-soft);
    white-space: nowrap;
  }
  .keybadge--none {
    color: var(--ink-4);
    border-style: dashed;
    background: transparent;
  }

  .bpm { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-3); white-space: nowrap; }
  .lead { font-size: 0.79rem; color: var(--ink-2); white-space: nowrap; }

  .empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--ink-3);
    font-size: 0.9rem;
  }

  .empty-cta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 24px;
    border-style: dashed;
    border-color: var(--line);
  }
  .empty-cta h3 {
    font-family: var(--serif);
    font-size: 1.15rem;
    font-weight: 400;
    margin: 0;
  }
  .empty-cta p {
    margin: 0;
    color: var(--ink-3);
    font-size: 0.88rem;
    line-height: 1.55;
    max-width: 52ch;
  }

  /* ─────────────────────────  CALENDAR  ───────────────────────── */

  .calhead {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
  }
  .calhead h2 {
    font-family: var(--serif);
    font-size: 1.25rem;
    font-weight: 400;
    margin: 0;
    min-width: 190px;
  }
  .iconbtn {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink-2);
    transition: color 130ms ease, border-color 130ms ease;
  }
  .iconbtn:hover { color: var(--brass); border-color: var(--brass-deep); }

  .cal {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
  }
  .cal__dow {
    text-align: center;
    padding-bottom: 6px;
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-4);
    font-weight: 600;
  }
  .day {
    min-height: 86px;
    padding: 7px;
    border-radius: var(--r-md);
    border: 1px solid var(--line-soft);
    background: var(--ground-2);
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: left;
    transition: border-color 130ms ease;
  }
  .day--pad { background: transparent; border-color: transparent; }
  .day--today { border-color: var(--brass-deep); }
  .day__n {
    font-family: var(--mono);
    font-size: 0.76rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
  }
  .day--today .day__n { color: var(--brass); font-weight: 700; }

  .ev {
    width: 100%;
    text-align: left;
    padding: 5px 6px;
    border-radius: var(--r-sm);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--ink-4);
    font-size: 0.7rem;
    line-height: 1.25;
    color: var(--ink-2);
    transition: background 120ms ease, border-color 120ms ease;
  }
  .ev:hover { background: var(--panel-3); }
  .ev[data-mine="yes"]   { border-left-color: var(--yes); }
  .ev[data-mine="maybe"] { border-left-color: var(--maybe); }
  .ev[data-mine="no"]    { border-left-color: var(--no); }
  .ev__name {
    display: block;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .ev__time { font-family: var(--mono); font-size: 0.66rem; color: var(--ink-4); }

  .callist { display: none; }

  /* ─────────────────────────  REQUESTS  ───────────────────────── */

  .req {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-lg);
    background: var(--panel);
  }
  .req__body { flex: 1; min-width: 0; }
  .req__title { font-family: var(--serif); font-size: 1.1rem; line-height: 1.25; }
  .req__artist { font-size: 0.8rem; color: var(--ink-3); }
  .req__note {
    margin-top: 8px;
    font-size: 0.86rem;
    color: var(--ink-2);
    line-height: 1.5;
    border-left: 2px solid var(--line);
    padding-left: 10px;
  }
  .req__by { margin-top: 10px; font-size: 0.75rem; color: var(--ink-4); }

  .votebtn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 10px;
    border-radius: var(--r-md);
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--ink-3);
    min-width: 50px;
    transition: color 130ms ease, border-color 130ms ease;
  }
  .votebtn:hover { color: var(--ink); border-color: var(--ink-4); }
  .votebtn[aria-pressed="true"] { color: var(--brass); border-color: var(--brass-deep); background: var(--brass-wash); }
  .votebtn__n { font-family: var(--mono); font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
  .votebtn__l { font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; }

  .adminbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
  }
  .btn--sm { padding: 7px 12px; font-size: 0.8rem; }
  .btn--learned { background: var(--yes); color: #0E1A11; }
  .btn--learned:hover { background: #7BB886; }

  /* ─────────────────────────  PANEL  ───────────────────────── */

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(8, 6, 5, 0.66);
    animation: fade 180ms ease both;
  }
  @keyframes fade { from { opacity: 0; } }

  .panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    z-index: 45;
    width: min(430px, 100%);
    background: var(--ground-2);
    border-left: 1px solid var(--line);
    padding: 22px;
    overflow-y: auto;
    animation: slideIn 240ms cubic-bezier(.2,.7,.3,1) both;
  }
  @keyframes slideIn { from { transform: translateX(24px); opacity: 0; } }

  .panel__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
  }
  .panel__title { font-family: var(--serif); font-size: 1.35rem; line-height: 1.2; margin: 0; font-weight: 400; }
  .panel__sub { color: var(--ink-3); font-size: 0.85rem; margin-top: 2px; }

  .tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
  }
  .tabs button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ink-3);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 130ms ease, border-color 130ms ease;
  }
  .tabs button:hover { color: var(--ink); }
  .tabs button[aria-selected="true"] { color: var(--brass-soft); border-bottom-color: var(--brass); }

  .tabdot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brass);
    display: inline-block;
  }

  .tabcount {
    font-family: var(--mono);
    font-size: 0.68rem;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--panel-3);
    color: var(--ink-2);
  }
  .tabs button[aria-selected="true"] .tabcount { background: var(--brass-wash); color: var(--brass-soft); }

  /* ─────────  SETLIST  ───────── */

  .setlist {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .setrow {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-md);
    background: var(--panel);
  }
  .setrow__n {
    font-family: var(--mono);
    font-size: 0.76rem;
    color: var(--ink-4);
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .setrow__main { text-align: left; min-width: 0; }
  .setrow__title {
    display: block;
    font-family: var(--serif);
    font-size: 1rem;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .setrow__meta {
    display: block;
    font-size: 0.76rem;
    color: var(--ink-3);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .setrow__ctl { display: flex; gap: 4px; }
  .iconbtn--xs { width: 30px; height: 30px; border-radius: var(--r-sm); }

  /* ─────────  SONG PICKER  ───────── */

  .picklist { display: flex; flex-direction: column; gap: 6px; }
  .pickrow {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    width: 100%;
    text-align: left;
    padding: 11px 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-md);
    background: var(--panel);
    transition: border-color 130ms ease, background 130ms ease;
  }
  .pickrow:hover { border-color: var(--ink-4); }
  .pickrow[aria-pressed="true"] { border-color: var(--brass-deep); background: var(--brass-wash); }
  .pickrow__check {
    width: 21px;
    height: 21px;
    border-radius: 6px;
    border: 1px solid var(--line);
    display: grid;
    place-items: center;
    color: transparent;
    flex: 0 0 21px;
  }
  .pickrow[aria-pressed="true"] .pickrow__check {
    background: var(--brass);
    border-color: var(--brass);
    color: #23180A;
  }

  .lyrics {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    font-size: 1rem;
    line-height: 1.85;
    color: var(--ink);
  }
  .lyrics-input {
    font-family: var(--sans);
    line-height: 1.6;
    resize: vertical;
    min-height: 240px;
  }

  .deflist { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; font-size: 0.87rem; }
  .deflist dt { color: var(--ink-3); }
  .deflist dd { margin: 0; }

  .roster { display: flex; flex-direction: column; gap: 2px; }
  .roster__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 0.87rem;
  }
  .roster__row:last-child { border-bottom: 0; }
  .roster__status {
    margin-left: auto;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid currentColor;
  }
  .roster__status[data-s="yes"]   { color: var(--yes); }
  .roster__status[data-s="maybe"] { color: var(--maybe); }
  .roster__status[data-s="no"]    { color: var(--no); }
  .roster__status[data-s="none"]  { color: var(--ink-4); }

  /* ─────────────────────────  MODAL (admin PIN)  ───────────────────────── */

  .modal {
    position: fixed;
    inset: 0;
    z-index: 46;
    display: grid;
    place-items: center;
    padding: 20px;
    pointer-events: none;
  }
  .modal__card {
    pointer-events: auto;
    width: min(340px, 100%);
    background: var(--ground-2);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
    animation: popIn 200ms cubic-bezier(.2,.7,.3,1) both;
  }
  @keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } }

  .modal__title { font-family: var(--serif); font-size: 1.2rem; font-weight: 400; margin: 0 0 5px; }
  .modal__sub { font-size: 0.83rem; color: var(--ink-3); line-height: 1.45; margin: 0 0 14px; }
  .modal__hint { margin: 12px 0 0; font-size: 0.72rem; color: var(--ink-4); }

  .linkform {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
  }
  .linkform .modal__hint { margin: 2px 0 0; }

  .pin {
    text-align: center;
    font-family: var(--mono);
    font-size: 1.35rem;
    letter-spacing: 0.45em;
    text-indent: 0.45em;
  }

  .gate__note code, .modal__hint code {
    font-family: var(--mono);
    color: var(--brass-soft);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 5px;
  }

  /* ─────────────────────────  TOAST + PROTO BAR  ───────────────────────── */

  .toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 70;
    padding: 11px 18px;
    border-radius: 999px;
    background: var(--panel-3);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.45);
    animation: toastIn 220ms ease both;
  }
  @keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

  .protobar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 9px 12px;
    border: 1px dashed var(--brass-deep);
    border-radius: var(--r-md);
    background: var(--brass-wash);
    font-size: 0.76rem;
    color: var(--ink-2);
    margin-bottom: 22px;
  }
  .protobar b { color: var(--brass-soft); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.68rem; }
  .protobar select {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 4px 8px;
    font-size: 0.76rem;
  }

  /* ─────────────────────────  BOTTOM NAV (mobile)  ───────────────────────── */

  .tabbar { display: none; }

  @media (max-width: 900px) {
    .rail { display: none; }
    .main { padding: 20px 16px 96px; }

    .tabbar {
      position: fixed;
      left: 0; right: 0; bottom: 0;
      z-index: 30;
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      background: rgba(21, 17, 16, 0.96);
      backdrop-filter: blur(12px);
      border-top: 1px solid var(--line);
      padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    }
    .tabbar__btn {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 3px;
      padding: 7px 2px;
      color: var(--ink-3);
      font-size: 0.65rem;
      font-weight: 600;
      border-radius: var(--r-md);
    }
    .tabbar__btn[aria-current="page"] { color: var(--brass); }

    .mobrand {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 16px;
    }
    .grid--3, .grid--2 { grid-template-columns: 1fr; }

    .cal { display: none; }
    .callist { display: flex; flex-direction: column; gap: 8px; }

    .panel {
      top: auto;
      left: 0;
      width: 100%;
      max-height: 88vh;
      border-left: 0;
      border-top: 1px solid var(--line);
      border-radius: var(--r-lg) var(--r-lg) 0 0;
      animation: sheetIn 260ms cubic-bezier(.2,.7,.3,1) both;
      padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    }
    @keyframes sheetIn { from { transform: translateY(30px); opacity: 0; } }

    .songhead { display: none; }

    .songrow {
      grid-template-columns: auto minmax(0, 1fr) auto;
      column-gap: 12px;
      row-gap: 2px;
      align-items: start;
    }
    .songrow__key    { grid-area: 1 / 1 / 4 / 2; align-self: center; }
    .songrow__song   { grid-area: 1 / 2 / 2 / 3; white-space: normal; }
    .songrow__artist { grid-area: 2 / 2 / 3 / 3; }
    .songrow__lead   { grid-area: 3 / 2 / 4 / 3; }
    .songrow__linkcell { grid-area: 1 / 3 / 4 / 4; align-self: center; }
    .songrow__lead::before { content: "Led by "; color: var(--ink-4); }
  }

  .mobrand { display: none; }
  @media (max-width: 900px) { .mobrand { display: flex; } }

  /* Day list (mobile calendar) */
  .dayline {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border-radius: var(--r-md);
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--ink-4);
    background: var(--panel);
  }
  .dayline[data-mine="yes"]   { border-left-color: var(--yes); }
  .dayline[data-mine="maybe"] { border-left-color: var(--maybe); }
  .dayline[data-mine="no"]    { border-left-color: var(--no); }
  .dayline__date {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--brass);
    text-align: center;
    line-height: 1.2;
    flex: 0 0 34px;
  }
  .dayline__date b { display: block; font-size: 1.05rem; color: var(--ink); }
  .dayline__name { font-weight: 600; font-size: 0.92rem; }
  .dayline__meta { font-size: 0.75rem; color: var(--ink-3); }

  /* ─────────  PHONE / HOME-SCREEN APP  ─────────
     Last block on purpose: these override earlier sizing. */
  @media (max-width: 900px) {
    /* Room for the notch when launched from the home screen. */
    .main { padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
    .gate { padding-top: calc(24px + env(safe-area-inset-top, 0px)); }
    .panel { max-height: calc(88vh - env(safe-area-inset-top, 0px)); }

    /* Thumb-sized targets. */
    .btn, .statusbtn, .chip, .whobtn, .votebtn { min-height: 44px; }
    .iconbtn { width: 44px; height: 44px; }
    .chip { padding: 11px 14px; }
    .statusbtn { padding: 12px 16px; }
    .ytbtn { min-height: 38px; padding: 9px 13px; }
    .navlink, .tabbar__btn { min-height: 46px; }

    /* 16px keeps iOS Safari from zooming the page when a field is focused. */
    .field { font-size: 16px; padding: 13px 14px; }

    .empty-cta { padding: 20px; }
    .empty-cta .btn { width: 100%; }
    .topbar .btn { width: 100%; }

    /* Prototype-only switcher — still worth being tappable while testing. */
    .protobar { width: 100%; }
    .protobar select { min-height: 40px; flex: 1; font-size: 16px; }

    /* Setlist controls drop to their own row so titles keep the full width. */
    .setrow { grid-template-columns: 20px minmax(0, 1fr) auto; row-gap: 8px; }
    .setrow__ctl { grid-column: 1 / -1; justify-content: flex-end; gap: 8px; }
    .iconbtn--xs { width: 40px; height: 40px; }
    .pickrow { min-height: 52px; }
  }
