/* Colours follow the Reign logo: black with a muted gold (measured in tools/icons/make-icons.js).
   Contrast: dark text on gold 8.9:1, gold on panel 8.7:1, muted text on panel 6.2:1. */
:root {
  --bg: #0b0b0c; --panel: #141415; --panel2: #1c1c1e; --line: #2e2c27; --text: #efebe2; --muted: #9b968b;
  --accent: #c2b280; --on-accent: #14110a; --track: #6f6955; --good: #37c98b; --warn: #f0b03f; --bad: #ef5b5b;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 12px; }
button { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font: inherit; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.danger:hover { border-color: var(--bad); color: var(--bad); }
button.icon { width: 38px; height: 38px; padding: 0; font-size: 16px; color: var(--accent); }
/* Icons are drawn in the button's text colour: gold normally, dark on a gold (active) button. */
.ico { display: block; width: 20px; height: 20px; margin: auto; pointer-events: none; }
.ico .fill { fill: currentColor; }
.ico .stroke { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button, input, select, label { touch-action: manipulation; }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
label input { margin-top: 5px; }
.error { color: var(--bad); min-height: 1.2em; margin: 0 0 10px; font-size: 13px; }

.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  padding: calc(20px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px; width: 100%; max-width: 360px; }
.panel button { width: 100%; }

header { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
  padding: calc(12px + env(safe-area-inset-top)) calc(22px + env(safe-area-inset-right)) 12px calc(22px + env(safe-area-inset-left)); }
.brand { font-weight: 700; font-size: 17px; }
nav { display: flex; gap: 6px; flex: 1; }
.tab { border-color: transparent; background: transparent; color: var(--muted); }
.tab.active { color: var(--text); background: var(--panel2); border-color: var(--line); }
.me { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; }
#menuBtn { display: none; }
.pill { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; margin-left: 8px; vertical-align: middle; background: var(--panel2); color: var(--warn); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--good); } .pill.bad { color: var(--bad); }

main { max-width: 1300px; margin: 0 auto;
  padding: 0 calc(22px + env(safe-area-inset-right)) calc(60px + env(safe-area-inset-bottom)) calc(22px + env(safe-area-inset-left)); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.empty { color: var(--muted); padding: 6px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.group { border-color: #5a5137; }
.card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.name { font-weight: 650; font-size: 16px; }
.sub { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.leader { color: var(--accent); border-color: var(--accent); }
.badge.play { color: var(--good); }
.now { background: var(--panel2); border-radius: 10px; padding: 9px 11px; font-size: 13px; min-height: 52px; display: flex; gap: 10px; align-items: center; }
.now img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; }
.now .t { font-weight: 600; overflow-wrap: anywhere; } .now .a { color: var(--muted); overflow-wrap: anywhere; }
.row { display: flex; gap: 8px; align-items: center; }
.row .spacer { flex: 1; }
.vol { width: 30px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.solo { display: flex; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 12px; }
input.mins { width: 80px; }
.solo button { white-space: nowrap; }
.members { display: flex; flex-wrap: wrap; gap: 6px; }
.card-head .members { justify-content: flex-end; flex-shrink: 0; }

/* Volume slider: a plain track with a gold thumb big enough for a thumb. */
input[type=range] { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 28px; padding: 0; margin: 0; background: transparent; border: 0; border-radius: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--track); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; border: 0; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--accent); }
input[type=range]:disabled { opacity: .45; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
.toolbar { margin-bottom: 12px; }
.url { color: var(--muted); font-size: 12px; word-break: break-all; }
td select { width: auto; max-width: 220px; margin-right: 6px; }
.badge.off { color: var(--warn); border-color: var(--warn); }
.warnbox { border: 1px solid var(--warn); color: var(--warn); border-radius: 8px; padding: 9px 11px; font-size: 13px; margin: 0 0 12px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(440px, 92vw); max-height: 90vh; max-height: 90dvh; overflow: auto; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin: 0 0 14px; }
.checks { display: grid; gap: 6px; margin-bottom: 14px; max-height: 260px; overflow: auto; }
.check { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 14px; margin: 0; padding: 7px 10px; background: var(--panel2); border-radius: 8px; }
.check input { width: auto; margin: 0; accent-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.toast { position: fixed; bottom: calc(22px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--bad); color: var(--text); padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: 90vw; }
.toast.ok { border-color: var(--good); }

/* ---- touch screens: targets a thumb can hit ---- */
@media (pointer: coarse) {
  input, select { font-size: 16px; }                      /* smaller text makes iPhones zoom the page on focus */
  button, select, input:not([type=checkbox]):not([type=range]) { min-height: 44px; }
  button.icon { width: 44px; height: 44px; }
  .check { min-height: 44px; }
  .check input { width: 20px; height: 20px; }
  input[type=range] { height: 44px; }
  input[type=range]::-webkit-slider-thumb { width: 30px; height: 30px; margin-top: -12px; }
  input[type=range]::-moz-range-thumb { width: 30px; height: 30px; }
}

/* ---- the account menu as a drop-down: on phones, and always on the my-room screen ---- */
body.room nav { display: none; }
body.room #refresh { display: none; }
body.room .brand { flex: 1; }
body.room #menuBtn { display: block; }
body.room .me { display: none; }
body.room .me.open { display: flex; flex-direction: column; align-items: stretch; gap: 8px; position: absolute; top: 100%; right: calc(10px + env(safe-area-inset-right));
  min-width: 220px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 14px 14px; box-shadow: 0 12px 30px rgba(0,0,0,.6); }
body.room .me.open #who { padding: 2px 4px 6px; }

/* ---- phones ---- */
@media (max-width: 640px) {
  header { gap: 10px 12px; padding-left: calc(14px + env(safe-area-inset-left)); padding-right: calc(14px + env(safe-area-inset-right)); }
  .brand { flex: 1; font-size: 16px; }
  nav { order: 3; flex-basis: 100%; }
  nav .tab { flex: 1; }
  #menuBtn { display: block; }
  .me { display: none; }
  .me.open { display: flex; flex-direction: column; align-items: stretch; gap: 8px; position: absolute; top: 100%; right: calc(10px + env(safe-area-inset-right));
    min-width: 220px; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 0 0 14px 14px; box-shadow: 0 12px 30px rgba(0,0,0,.6); }
  .me.open #who { padding: 2px 4px 6px; }

  main { padding-left: calc(14px + env(safe-area-inset-left)); padding-right: calc(14px + env(safe-area-inset-right)); }
  h2 { margin-top: 22px; }
  .grid { grid-template-columns: 1fr; }
  .toolbar.row { flex-wrap: wrap; }
  .toolbar.row .spacer { flex-basis: 100%; height: 0; }

  /* tables become one card per row, each cell labelled with its column heading */
  table, tbody, tr, td { display: block; width: 100%; }
  table { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  thead { display: none; }
  tr { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 0; margin-bottom: 12px; }
  td { border-bottom: 0; padding: 8px 14px; }
  td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px; }
  td.actions { text-align: left; white-space: normal; }
  td.actions:empty { display: none; }
  td select { display: block; width: 100%; max-width: none; margin: 0 0 8px; }

  dialog { padding: 18px; }
  .dialog-actions button { flex: 1; }
}

/* ---- my room: one large card for a user with a single speaker ---- */
#tab-room { padding-top: 22px; }
.card.room { max-width: 520px; margin: 0 auto; gap: 16px; padding: 20px; }
.room-name { font-size: 22px; font-weight: 700; line-height: 1.2; }
.room-line { color: var(--muted); margin-top: -10px; }
.card.room .hint { margin: 0; }
.card.room .row.transport { justify-content: center; gap: 16px; }
.card.room .row.transport button.icon { width: 56px; height: 56px; }
.card.room .row.transport .ico { width: 28px; height: 28px; }
.card.room button.big { width: 100%; min-height: 52px; font-size: 16px; }
.stations { display: grid; gap: 8px; }
.station { display: flex; gap: 8px; align-items: center; background: var(--panel2); border-radius: 10px; padding: 8px 8px 8px 12px; }
.station-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }

/* ---- "add to home screen" bar ---- */
.install-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center;
  background: var(--panel); border-top: 1px solid var(--accent);
  padding: 12px calc(14px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); }
.install-bar span { flex: 1 1 200px; font-size: 14px; }
body.has-install-bar main { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
body.has-install-bar .toast { bottom: calc(140px + env(safe-area-inset-bottom)); }
