/* iPad remote. Evergreen night, Christmas red for actions, gold for "this is on". */
:root {
  --bg: #0a2a1e;
  --surface: #11382a;
  --surface-2: #164634;
  --line: #22573f;
  --text: #f5f1e6;
  --muted: #a9c3b4;
  --red: #c8202f;
  --red-press: #a51825;
  --gold: #f2c14e;
  --ok: #5fd08a;
  --err: #ff8f8f;
  --radius: 14px;
  --shadow: 0 10px 30px -8px rgba(0, 0, 0, .55);
  font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
  color-scheme: dark;
  accent-color: var(--gold);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
::selection { background: var(--gold); color: #1d1600; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
svg .solid { fill: currentColor; stroke: none; }

/* ---- Header ---- */
header {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 20px 14px;
}
header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: repeating-linear-gradient(90deg, var(--red) 0 14px, var(--text) 14px 28px);
}
.logo { height: 22px; }
.brand { font-weight: 700; font-size: 20px; color: var(--gold); letter-spacing: -.01em; }
#conn { margin-left: auto; width: 10px; height: 10px; border-radius: 50%; background: var(--err); }
#conn.on { background: var(--ok); }

/* ---- Tabs ---- */
#layout { overflow: hidden; position: relative; }
.tab { display: none; height: 100%; overflow-y: auto; padding: 24px 20px 32px; -webkit-overflow-scrolling: touch; }
.tab.active { display: block; }
h2 { margin: 0 0 16px; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }

/* ---- Search ---- */
#search-form { display: flex; gap: 10px; }
.field { flex: 1; position: relative; display: flex; align-items: center; }
.field .i { position: absolute; left: 16px; color: var(--muted); pointer-events: none; }
#q {
  width: 100%; font-size: 20px; padding: 14px 16px 14px 48px; min-height: 56px;
  border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
}
#q::placeholder { color: var(--muted); }
#q:focus { outline: none; border-color: var(--gold); }
.primary {
  border: 0; border-radius: var(--radius); padding: 0 24px; min-height: 56px;
  background: var(--red); color: #fff; font-weight: 650; font-size: 18px;
}
.primary:active { background: var(--red-press); }
.ghost { border: 1.5px solid var(--line); border-radius: var(--radius); background: none; padding: 0 22px; min-height: 52px; font-size: 17px; }
.tip { color: var(--muted); font-size: 14px; margin: 12px 2px 0; }
.tag {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px; background: rgba(95,208,138,.16); color: var(--ok); vertical-align: 1px;
}

/* ---- Karaoke classics ---- */
#classics { margin-top: 28px; }
#classics h2 { font-size: 22px; margin-bottom: 10px; }
.classics { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); border-top: 1px solid var(--line); }
.classic {
  width: 100%; min-height: 64px; padding: 10px 4px; text-align: left; background: none;
  border: 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; gap: 2px;
}
.classics li:nth-child(odd) .classic { padding-right: 16px; }
.classic:active { background: var(--surface); }
.c-title { font-size: 17px; font-weight: 600; }
.c-artist { font-size: 14px; color: var(--muted); }

/* ---- Lists ---- */
.list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 14px;
  padding: 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
}
button.item:active { background: var(--surface-2); }
.item img { width: 104px; height: 58px; object-fit: cover; border-radius: 10px; flex: none; background: #000; }
.meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.title { font-size: 17px; font-weight: 600; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.title b { color: var(--gold); font-weight: 700; }
.sub { font-size: 14px; color: var(--muted); }
.add { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); color: var(--gold); flex: none; margin-right: 4px; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; list-style: none; font-size: 16px; }

.status { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status-ready { color: var(--ok); } .status-ready .dot { background: var(--ok); }
.status-error { color: var(--err); } .status-error .dot { background: var(--err); }
.status-downloading, .status-splitting, .status-lyrics { color: var(--gold); }
.status-downloading .dot, .status-splitting .dot, .status-lyrics .dot { background: var(--gold); animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .3; } }

.row-actions { display: flex; gap: 6px; }
.row-actions button {
  display: grid; place-items: center; width: 48px; height: 48px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.row-actions button:active { background: var(--surface-2); }
.row-actions button:disabled { opacity: .3; }
.row-actions .danger { color: var(--err); }

/* ---- Controls ---- */
#tab-control { padding-top: 20px; }
#np { display: flex; gap: 14px; align-items: center; }
#np-thumb { width: 112px; height: 63px; object-fit: cover; border-radius: 10px; background: var(--surface); flex: none; }
.np-text { min-width: 0; }
#np-singer { font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--gold); line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#np-title { font-size: 15px; margin-top: 4px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#np-status { font-size: 14px; color: var(--muted); margin-top: 2px; }
#scrub { margin-top: 12px; }
#s-pos { -webkit-appearance: none; appearance: none; width: 100%; height: 36px; background: none; margin: 0; }
#s-pos::-webkit-slider-runnable-track {
  height: 8px; border-radius: 4px;
  background:
    linear-gradient(90deg, transparent var(--fill, 0%), var(--surface) var(--fill, 0%)),
    repeating-linear-gradient(-45deg, var(--text) 0 6px, var(--red) 6px 12px);
}
#s-pos::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -8px; border-radius: 50%; background: var(--text); box-shadow: 0 2px 6px rgba(0,0,0,.4); }
#s-pos:disabled::-webkit-slider-thumb { opacity: 0; }
.times { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: -4px; }

.transport { display: flex; justify-content: center; align-items: center; gap: 28px; margin: 18px 0 10px; }
.transport button {
  display: grid; place-items: center; width: 64px; height: 64px;
  border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
}
.transport button .i { width: 26px; height: 26px; }
.transport button:active { background: var(--surface-2); transform: scale(.96); }
.transport button:disabled { opacity: .35; }
.transport .big { width: 92px; height: 92px; background: var(--red); border: 0; color: #fff; box-shadow: var(--shadow); }
.transport .big .i { width: 36px; height: 36px; }
.transport .big:active { background: var(--red-press); }

.slider { display: block; margin: 10px 0 4px; }
.slider-head { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.slider-head .i { color: var(--muted); width: 20px; height: 20px; }
.slider output { margin-left: auto; color: var(--gold); font-weight: 650; font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; height: 40px; margin: 0; }

.row-setting { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.row-label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px;
  border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); font-size: 16px;
}
.stepper button .i { width: 18px; height: 18px; }
.stepper button:active { background: var(--surface-2); }
.stepper output { min-width: 64px; text-align: center; font-size: 18px; font-weight: 650; color: var(--gold); font-variant-numeric: tabular-nums; }

#themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-opt {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  padding: 6px 6px 8px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg);
  font-size: 15px; font-weight: 600; text-align: center;
}
.theme-opt[aria-checked=true] { border-color: var(--gold); color: var(--gold); background: var(--surface-2); }
.swatch { height: 30px; border-radius: 7px; border: 1px solid rgba(255,255,255,.12); }
.swatch-tacky { background: linear-gradient(#0b6b2e 0 30%, transparent 30%), repeating-linear-gradient(45deg, #c8102e 0 7px, #a00d25 7px 14px); }
.swatch-zen { background: linear-gradient(90deg, transparent 22%, rgba(200,225,175,.8) 22% 78%, transparent 78%) center / 100% 3px no-repeat, linear-gradient(130deg, #1a2e2c, #2a3d30); }
.swatch-disco {
  background:
    repeating-linear-gradient(0deg, transparent 0 7px, rgba(255,79,216,.6) 7px 8px),
    repeating-linear-gradient(90deg, transparent 0 7px, rgba(0,240,255,.6) 7px 8px),
    linear-gradient(#12002b, #2a0040);
}

.switch { display: flex; align-items: center; gap: 12px; margin-top: 8px; min-height: 44px; font-size: 16px; cursor: pointer; }
.switch span { flex: 1; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i { width: 50px; height: 30px; border-radius: 15px; background: var(--surface-2); border: 1.5px solid var(--line); position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 23px; height: 23px; border-radius: 50%; background: var(--muted); transition: transform .2s cubic-bezier(.16,1,.3,1), background .2s; }
.switch input:checked + i { background: var(--red); border-color: var(--red); }
.switch input:checked + i::after { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + i { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---- Bottom nav ---- */
nav { display: flex; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: env(safe-area-inset-bottom); }
nav button {
  flex: 1; border: 0; background: none; padding: 10px 0 12px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted);
}
nav button span { font-size: 13px; font-weight: 500; }
nav button b { font-weight: 700; font-variant-numeric: tabular-nums; }
nav button.active { color: var(--gold); }

/* ---- Add dialog ---- */
dialog { border: 0; color: var(--text); background: var(--surface); box-shadow: var(--shadow); border-radius: 22px; padding: 28px; width: min(520px, 92vw); }
dialog::backdrop { background: rgba(3, 14, 10, .65); }
dialog h2 { margin: 0 0 4px; }
#add-song { color: var(--muted); margin: 0 0 18px; line-height: 1.4; }
#singer { width: 100%; font-size: 22px; padding: 14px 16px; border-radius: var(--radius); border: 1.5px solid var(--line); background: var(--bg); color: var(--text); }
#singer::placeholder { color: var(--muted); }
#singer:focus { outline: none; border-color: var(--gold); }
#people-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; max-height: 160px; overflow-y: auto; }
#people-chips:empty { display: none; }
.chip { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); min-height: 44px; }
.chip img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; object-position: top; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  background: var(--gold); color: #1d1600; font-weight: 650; padding: 14px 22px; border-radius: 99px;
  box-shadow: var(--shadow); animation: pop .3s cubic-bezier(.16, 1, .3, 1); z-index: 10;
}
@keyframes pop { from { transform: translate(-50%, 16px); opacity: 0; } }

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

/* iPad landscape: controls pinned on the right. */
@media (min-width: 900px) and (orientation: landscape) {
  #layout { display: grid; grid-template-columns: 1fr 420px; }
  #tab-control { display: block; grid-column: 2; grid-row: 1; border-left: 1px solid var(--line); background: rgba(0,0,0,.12); }
  #tab-search, #tab-queue { grid-column: 1; grid-row: 1; }
  nav button[data-tab=control] { display: none; }
  #layout:has(#tab-control.active) #tab-search { display: block; }
}

/* ---- Host vs guest ---- */
body:not(.host) #tab-control, body:not(.host) nav button[data-tab=control] { display: none !important; }
body:not(.host) #layout { grid-template-columns: 1fr !important; }
.tag.you { background: rgba(242,193,78,.18); color: var(--gold); }

#now-strip {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline;
  padding: 14px 16px; margin-bottom: 22px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line);
}
#now-strip[hidden] { display: none; }
.ns-label { grid-row: span 2; align-self: center; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--red); background: #fff; padding: 4px 8px; border-radius: 6px; }
.ns-singer { font-size: 20px; font-weight: 700; color: var(--gold); }
.ns-title { font-size: 15px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Phones ---- */
@media (max-width: 600px) {
  header { padding-left: 16px; padding-right: 16px; }
  .logo { height: 18px; }
  .brand { font-size: 17px; }
  .tab { padding: 18px 14px 28px; }
  h2 { font-size: 26px; }
  #search-form { gap: 8px; }
  #q { font-size: 17px; min-height: 50px; padding-left: 44px; }
  .field .i { left: 14px; }
  #search-form .primary { min-height: 50px; padding: 0 16px; font-size: 16px; }
  .item { gap: 10px; padding: 8px; }
  .item img { width: 72px; height: 41px; border-radius: 8px; }
  .title { font-size: 15px; }
  .sub { font-size: 13px; }
  .add { width: 40px; height: 40px; }
  .row-actions { gap: 4px; }
  .row-actions button { width: 40px; height: 40px; border-radius: 10px; }
  .classics { grid-template-columns: 1fr; }
  .c-title { font-size: 16px; }
  #np-thumb { width: 88px; height: 50px; }
  #np-singer { font-size: 22px; }
  .transport { gap: 20px; }
  dialog { padding: 22px; }
  #singer { font-size: 18px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
}
@media (min-width: 900px) and (orientation: landscape) {
  #np-title { -webkit-line-clamp: 1; }
  body.host #now-strip { display: none; }
}
