/* Mobile remote. Shaped after a physical remote: graphite body, raised keys,
   volume and channel rockers either side of a d-pad. Amber marks whatever is
   active, matching the focus color on the TV guide. */

:root {
  --body: #1f232b;
  --body-2: #262b34;
  --key: #2e343f;
  --key-hi: #3b4250;
  --line: #363c48;
  --text: #eef1f6;
  --muted: #9aa3b5;
  --accent: #ffb627;
  --accent-ink: #1f232b;
  --accent-soft: rgba(255, 182, 39, 0.15);
  --red: #e5484d;
  --green: #4cd08a;
  --cobalt: #13306f;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { background: var(--body); color: var(--text); }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Barlow", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding-top: var(--safe-t); }

.cond { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; }

/* ------------------------------------------------------------- top bar */
.top {
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  gap: 8px; padding: 10px 12px 6px;
}
.top h1 { margin: 0; font: 600 22px/1.1 "Barlow Condensed", sans-serif; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sub { display: block; font: 500 13px/1.2 "Barlow", sans-serif; color: var(--muted); margin-top: 2px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: transparent; display: grid; place-items: center; color: var(--muted);
}
.icon-btn:active { background: var(--key); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--green); }
.dot.standby { background: var(--accent); }

/* -------------------------------------------------------- now playing */
.now {
  margin: 6px 16px 12px;
  display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--body-2);
  border: 1px solid var(--line);
}
.now .badge {
  width: 64px; height: 64px; border-radius: 12px; background: var(--cobalt);
  display: grid; place-items: center; overflow: hidden;
  font: 700 26px/1 "Barlow Condensed", sans-serif;
}
.now .badge img { width: 100%; height: 100%; object-fit: contain; padding: 6px; background: #f3f5fa; }
.now .meta { min-width: 0; }
.now .ch { font: 600 15px/1.2 "Barlow Condensed", sans-serif; color: var(--muted); }
.now .title { font-weight: 600; font-size: 18px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now .time { font-size: 13px; color: var(--muted); }
.bar { height: 4px; border-radius: 4px; background: var(--key-hi); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.now.off { opacity: 0.6; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 0 16px; background: var(--body-2); border-radius: 12px; padding: 4px; }
.tabs a {
  text-align: center; padding: 9px 0; border-radius: 9px; text-decoration: none; color: var(--muted);
  font: 600 17px/1 "Barlow Condensed", sans-serif;
}
.tabs a[aria-current="page"] { background: var(--key-hi); color: var(--text); }

/* -------------------------------------------------------------- remote */
.remote { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; gap: 18px; padding: 18px 20px calc(18px + var(--safe-b)); }
.row { display: flex; justify-content: space-between; align-items: center; }
.key {
  border: 0; border-radius: 16px; background: var(--key);
  min-width: 64px; height: 56px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 16px/1 "Barlow Condensed", sans-serif; color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 0 rgba(0, 0, 0, 0.35);
  transition: transform 60ms ease, background 60ms ease;
}
.key:active, .key.pressed { transform: translateY(1px); background: var(--key-hi); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04); }
.key svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.key.power { width: 64px; padding: 0; border-radius: 50%; height: 64px; color: var(--red); }
.key.power.on { background: var(--red); color: #fff; }
.key.active { color: var(--accent); }
.key:disabled { opacity: 0.4; }

.cluster { display: grid; grid-template-columns: 72px minmax(0, 1fr) 72px; align-items: center; gap: 12px; }

.rocker {
  display: grid; grid-template-rows: 1fr auto 1fr;
  width: 72px; height: 212px; border-radius: 36px;
  background: var(--key);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 0 rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.rocker button {
  border: 0; background: transparent; display: grid; place-items: center; color: var(--text);
}
.rocker button:active { background: var(--key-hi); }
.rocker button svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.rocker .label { text-align: center; font: 600 15px/1 "Barlow Condensed", sans-serif; color: var(--muted); padding: 6px 0; }

.dpad {
  position: relative; justify-self: center;
  width: min(212px, 100%); aspect-ratio: 1; border-radius: 50%;
  background: var(--key);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 2px 0 rgba(0, 0, 0, 0.35);
  display: grid; grid-template: 1fr 1.15fr 1fr / 1fr 1.15fr 1fr;
}
.dpad button { border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.dpad button:active { color: var(--text); }
.dpad button svg { width: 24px; height: 24px; fill: currentColor; }
.dpad .up { grid-area: 1 / 2; } .dpad .left { grid-area: 2 / 1; }
.dpad .right { grid-area: 2 / 3; } .dpad .down { grid-area: 3 / 2; }
.dpad .ok {
  grid-area: 2 / 2; border-radius: 50%; background: var(--key-hi); color: var(--text);
  font: 700 18px/1 "Barlow Condensed", sans-serif;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.dpad .ok:active { background: #4a5263; }

.volume-row { display: grid; grid-template-columns: 28px 1fr 40px; align-items: center; gap: 12px; color: var(--muted); }
.volume-row svg { width: 22px; height: 22px; fill: currentColor; }
.volume-row output { font: 600 18px/1 "Barlow Condensed", sans-serif; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 32px; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(to right, var(--accent) var(--fill, 40%), var(--key-hi) var(--fill, 40%)); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: var(--key-hi); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: var(--text); border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--text); border: 0; }

.offline-note { margin: 0 16px; padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-size: 14px; }

/* --------------------------------------------------------------- guide */
.guide { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.guide-tools { padding: 12px 16px 6px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; background: var(--body); z-index: 2; }
.search {
  width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--body-2); padding: 0 14px; font-size: 16px;
}
.search::placeholder { color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font: 600 15px/1 "Barlow Condensed", sans-serif;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.list { list-style: none; margin: 0; padding: 4px 0 calc(16px + var(--safe-b)); }
.ch-row {
  display: grid; grid-template-columns: 44px 1fr 40px; gap: 12px; align-items: center;
  padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line);
  content-visibility: auto; contain-intrinsic-size: auto 72px;
}
.ch-row.current { background: linear-gradient(90deg, var(--accent-soft), transparent 70%); }
.ch-row.current .num { color: var(--accent); }
.ch-row .tap { display: contents; }
.ch-row .num { font: 700 20px/1 "Barlow Condensed", sans-serif; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.ch-row .info { min-width: 0; border: 0; background: none; padding: 0; text-align: left; }
.ch-row .name { font: 600 15px/1.2 "Barlow Condensed", sans-serif; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.ch-row .name img { height: 18px; max-width: 48px; object-fit: contain; }
.ch-row .prog { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-row .next { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-row .bar { margin-top: 5px; height: 3px; }
.ch-row .more { width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.ch-row .more:active { background: var(--key); }
.ch-row .more svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); }

/* -------------------------------------------------------------- TV list */
.page { padding: 8px 16px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.page h2 { margin: 18px 0 4px; font: 600 28px/1.1 "Barlow Condensed", sans-serif; }
.page p.lead { margin: 0 0 8px; color: var(--muted); }
.tv-card {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 16px; border-radius: var(--radius); background: var(--body-2); border: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.tv-card:active { background: var(--key); }
.tv-card .tv-name { font: 600 21px/1.15 "Barlow Condensed", sans-serif; }
.tv-card .tv-status { font-size: 14px; color: var(--muted); }
.tv-card .tv-now { grid-column: 1 / -1; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-card svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; grid-row: 1 / span 2; grid-column: 2; }

.btn {
  height: 52px; border-radius: 14px; border: 0; padding: 0 18px;
  font: 600 18px/1 "Barlow Condensed", sans-serif;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:active { filter: brightness(0.92); }
.btn.secondary { background: var(--key); color: var(--text); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid rgba(229, 72, 77, 0.5); }
.btn:disabled { opacity: 0.5; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
a.btn { text-decoration: none; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--muted); }
.input {
  height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--body-2);
  padding: 0 14px; font-size: 17px;
}
.input:focus { border-color: var(--accent); outline: none; }
.error { color: #ff8a8d; font-size: 14px; min-height: 20px; margin: 0; }

.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 24px calc(40px + var(--safe-b)); gap: 16px; }
.login-brand { height: calc(44px * var(--logo-scale, 1)); font: 700 calc(34px * var(--logo-scale, 1))/1 "Barlow Condensed", sans-serif; margin-bottom: 4px; }
.login .tagline { margin: -6px 0 10px; color: var(--muted); }
.login h1 { margin: 6px 0 0; font: 600 34px/1.05 "Barlow Condensed", sans-serif; }
.login p { margin: 0 0 8px; color: var(--muted); }

.code-boxes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.code-boxes input {
  width: 100%; height: 64px; text-align: center; border-radius: 12px; border: 1px solid var(--line);
  background: var(--body-2); font: 700 30px/1 "Barlow Condensed", sans-serif; text-transform: uppercase;
  padding: 0;
}
.code-boxes input:focus { border-color: var(--accent); outline: none; }
.code-boxes input:nth-child(3) { margin-right: 6px; }

/* --------------------------------------------------------------- sheets */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 40; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 480px; margin: 0 auto; max-height: 86dvh; overflow-y: auto;
  background: var(--body-2); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + var(--safe-b));
  animation: sheet-up 200ms ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.grab { width: 40px; height: 5px; border-radius: 4px; background: var(--key-hi); margin: 0 auto 12px; }
.sheet-title { margin: 0 0 4px; font: 600 24px/1.15 "Barlow Condensed", sans-serif; }
.sheet-sub { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.keypad-display { text-align: center; padding: 6px 0 14px; }
.keypad-display .digits { font: 700 48px/1 "Barlow Condensed", sans-serif; letter-spacing: 0.06em; min-height: 48px; font-variant-numeric: tabular-nums; }
.keypad-display .match { color: var(--muted); min-height: 22px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keypad .key { height: 60px; font-size: 26px; }
.keypad .key.go { background: var(--accent); color: var(--accent-ink); }

.sched { list-style: none; margin: 0 0 14px; padding: 0; }
.sched li { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sched .t { font: 600 16px/1.3 "Barlow Condensed", sans-serif; color: var(--muted); }
.sched li.live .t { color: var(--accent); }
.sched .pt { font-weight: 600; }
.sched .pd { font-size: 14px; color: var(--muted); margin-top: 2px; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--safe-b)); z-index: 60;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
  background: #f3f5fa; color: #1f232b; font-weight: 600; font-size: 15px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

@media (prefers-reduced-motion: reduce) {
  #sheet { animation: none; }
  .key { transition: none; }
}

/* ----------------------------------------------------------- branding */
.brand-logo { display: block; height: 100%; width: auto; max-width: min(300px, 80vw); object-fit: contain; }
.brand-word { display: block; white-space: nowrap; }
.list-top { grid-template-columns: 1fr 44px; }
.top-brand { height: calc(30px * min(var(--logo-scale, 1), 1.6)); padding-left: 4px; font: 700 calc(24px * min(var(--logo-scale, 1), 1.6))/1 "Barlow Condensed", sans-serif; overflow: hidden; display: flex; align-items: center; }

/* "Changed by Jane" under now playing */
.now .by { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--accent); }
.now .by svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; }

/* ------------------------------------------------------------ settings */
.group h3 { margin: 10px 4px 8px; font: 600 15px/1.2 "Barlow Condensed", sans-serif; color: var(--muted); }
.card-list { border-radius: var(--radius); background: var(--body-2); border: 1px solid var(--line); overflow: hidden; }
.row-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: inherit; text-decoration: none; text-align: left; font-size: 16px;
}
.row-item:last-child { border-bottom: 0; }
a.row-item:active, button.row-item:active { background: var(--key); }
.row-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; }
.row-item .sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.row-item.manage { flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; }
.btn.small { height: 36px; padding: 0 14px; font-size: 16px; border-radius: 10px; }
.lead.small { font-size: 14px; margin-top: 4px; }
.brand-foot { margin-top: 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; text-align: center; }
.brand-foot p { margin: 0; }
.foot-mark { height: calc(24px * var(--logo-scale, 1)); font: 700 calc(20px * var(--logo-scale, 1))/1 "Barlow Condensed", sans-serif; opacity: 0.7; }

/* Household switcher, subtitles sheet */
.house-switch {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 4px;
  margin: 0 0 8px; padding: 6px 10px 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--body-2); color: var(--text); font-size: 15px;
}
.house-switch svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.row.four { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.row.four .key { min-width: 0; padding: 0 8px; gap: 6px; }
.row-item .value { color: var(--muted); font-variant-numeric: tabular-nums; }
.row-item.opt svg { stroke: var(--accent); stroke-width: 2.6; }
.row-item.opt[aria-pressed="true"] { color: var(--text); font-weight: 600; }
.sheet-h3 { margin: 18px 0 8px; font: 600 15px/1.2 "Barlow Condensed", sans-serif; color: var(--muted); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; gap: 4px; border-radius: 12px; background: var(--body); }
.segmented button { height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 600 16px/1 "Barlow Condensed", sans-serif; }
.segmented button[aria-pressed="true"] { background: var(--key-hi); color: var(--text); }
select.input { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px; background-size: 6px 6px; background-repeat: no-repeat; }
