* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font-family: var(--body); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; font-size: 17px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2 { font-family: var(--display); font-weight: var(--display-weight); line-height: 1.1; margin: 0; }
h2 { font-size: 21px; margin-bottom: 6px; }
[data-theme="marquee"] h1, [data-theme="marquee"] h2 { text-transform: uppercase; letter-spacing: .02em; }
[data-theme="marquee"] h2 { font-size: 26px; }
p { margin: 0; }
.hint { color: var(--muted); font-size: 15px; margin-bottom: 18px; max-width: 60ch; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---- form controls ---- */
label { display: block; font-size: 15px; color: var(--muted); margin-bottom: 14px; }
input[type=text], input[type=password], input[type=url], input:not([type]) {
  display: block; width: 100%; margin-top: 6px; padding: 13px 14px; font: inherit; font-size: 17px; color: var(--text);
  background: var(--raised); border: 1.5px solid var(--line); border-radius: var(--radius-md); outline: none;
}
input:focus { border-color: var(--focus); }
.primary, .ghost, .pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: var(--radius-md); border: 0; font-weight: 700; white-space: nowrap;
}
.primary { background: var(--focus); color: var(--on-focus); }
.ghost { background: var(--raised); border: 1.5px solid var(--line); font-weight: 600; }
.ghost.danger { color: #ff8a80; }
.primary:active, .ghost:active, .pill:active { transform: scale(.97); }
.form-error { color: #ff8a80; font-size: 15px; margin-top: 12px; min-height: 1.4em; }
.check { display: inline-flex; align-items: center; gap: 10px; margin: 0; color: var(--text); }
.check input { width: 20px; height: 20px; accent-color: var(--focus); }

/* ---- gate (setup / sign in) ---- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(420px, 100%); }
.gate-card h1 { font-size: 40px; margin-bottom: 14px; letter-spacing: -0.01em; }
[data-theme="marquee"] .gate-card h1 { font-size: 64px; letter-spacing: .01em; }
.gate-card p { color: var(--muted); margin-bottom: 26px; }
.gate-card .primary { width: 100%; margin-top: 8px; }

/* ---- shell ---- */
.shell { max-width: 760px; margin: 0 auto; padding: 0 20px calc(110px + env(safe-area-inset-bottom)); }
.masthead { display: flex; align-items: center; justify-content: space-between; padding: 26px 0 22px; }
.masthead h1 { font-size: 28px; }
[data-theme="marquee"] .masthead h1 { font-size: 40px; }
.panel { animation: in 220ms ease; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }
.block { margin-top: 40px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); background: var(--raised); border-top: 1px solid var(--line);
}
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 64px; padding: 6px 8px; border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; border-radius: var(--radius-md); }
.tabs button[aria-current="page"] { color: var(--text); }
.tabs button[aria-current="page"] svg { stroke-width: 2.4; }

@media (min-width: 900px) {
  .shell { max-width: 1040px; display: grid; grid-template-columns: 200px 1fr; column-gap: 56px; padding-bottom: 60px; }
  .masthead { grid-column: 1 / -1; padding: 40px 0 34px; }
  .tabs { position: sticky; top: 24px; align-self: start; flex-direction: column; gap: 4px; padding: 0; background: none; border: 0; }
  .tabs button { flex-direction: row; gap: 12px; font-size: 16px; padding: 12px 14px; justify-content: flex-start; }
  .tabs button[aria-current="page"] { background: var(--raised); }
}

/* ---- remote ---- */
.dpad {
  position: relative; width: min(300px, 78vw); aspect-ratio: 1; margin: 6px auto 0; border-radius: 50%;
  background: var(--raised); box-shadow: inset 0 0 0 1.5px var(--line);
}
.dpad button { position: absolute; border: 0; background: none; display: grid; place-items: center; color: var(--text); border-radius: 50%; }
.dpad button:active, .dpad button.hit { background: var(--raised-2); }
.dpad svg { width: 34px; height: 34px; stroke-width: 2.4; }
.dpad .up { left: 33%; top: 2%; width: 34%; height: 30%; }
.dpad .down { left: 33%; bottom: 2%; width: 34%; height: 30%; }
.dpad .left { left: 2%; top: 33%; width: 30%; height: 34%; }
.dpad .right { right: 2%; top: 33%; width: 30%; height: 34%; }
.dpad .ok { left: 32%; top: 32%; width: 36%; height: 36%; background: var(--focus); color: var(--on-focus); font-weight: 800; font-size: 20px; letter-spacing: .04em; }
.dpad .ok:active, .dpad .ok.hit { transform: scale(.95); background: var(--focus); }
.pair { display: flex; justify-content: center; gap: 14px; margin-top: 22px; }
.pill { background: var(--raised); border: 1.5px solid var(--line); border-radius: 999px; padding: 0 24px; font-weight: 600; }

.inline { display: flex; gap: 10px; align-items: center; }
.inline input { margin-top: 0; flex: 1; min-width: 0; }
.inline.small { margin-top: 14px; justify-content: space-between; flex-wrap: wrap; }
.inline.small .ghost { min-height: 40px; font-size: 15px; }

.launchers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.launcher { height: 84px; border: 0; border-radius: var(--radius-lg); background: var(--brand); display: grid; place-items: center; }
.launcher img { max-height: 34px; max-width: 70%; filter: brightness(0) invert(1); }
.launcher.disney img { max-height: 46px; }
.launcher.jellyfin img { max-height: 40px; }
.launcher:active { transform: scale(.97); }

/* ---- look picker ---- */
.looks { display: grid; gap: 14px; }
@media (min-width: 640px) { .looks { grid-template-columns: repeat(3, 1fr); } }
.look { display: flex; flex-direction: column; gap: 14px; padding: 12px 12px 18px; text-align: left; background: var(--raised); border: 1.5px solid var(--line); border-radius: var(--radius-lg); }
.look[aria-pressed="true"] { border-color: var(--focus); box-shadow: 0 0 0 2px var(--focus); }
.look span { padding: 0 6px; color: var(--muted); font-size: 15px; }
.look strong { display: block; color: var(--text); font-size: 18px; margin-bottom: 2px; }
.mini {
  position: relative; aspect-ratio: 16 / 9; border-radius: calc(var(--radius-md) + 2px); overflow: hidden; background: var(--bg); color: var(--text);
  display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: 38% 26% 1fr; column-gap: 4%; padding: 6% 6% 0; align-items: end;
}
.mini b { grid-column: 1 / -1; align-self: start; font-family: var(--clock-font, var(--display)); font-stretch: var(--clock-stretch, 100%); font-weight: var(--clock-weight); font-size: clamp(22px, 7vw, 30px); line-height: 1; letter-spacing: -0.02em; }
.mini b small { font-size: .38em; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.mini em { grid-column: 1 / -1; align-self: start; font-style: normal; font-family: "Big Shoulders"; font-weight: 800; font-size: clamp(20px, 6vw, 26px); line-height: .9; }
.mini .t { height: 82%; border-radius: 3px; grid-row: 2; }
.mini .t.jf { background: var(--jellyfin); grid-column: 1 / span 2; margin-right: 8%; }
.mini .t.dp { background: var(--disney); grid-column: 3 / span 2; margin-right: 8%; outline: 2px solid var(--focus); outline-offset: 2px; }
.mini .t.bn { background: var(--binge); grid-column: 5; }
.mini s { grid-row: 3; height: 70%; align-self: start; margin-top: 10%; border-radius: 2px; background: var(--raised-2); }
.mini[data-theme="daylight"] .t { background: var(--raised); box-shadow: inset 0 -2px 0 var(--line); }
.mini[data-theme="marquee"] { background: #000; }
.mini[data-theme="marquee"]::before { content: ""; position: absolute; inset: 0 0 45% 0; background: #3b3a35; }
.mini[data-theme="marquee"] em { position: relative; }
.mini[data-theme="marquee"] .t { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35); position: relative; }
.mini[data-theme="marquee"] .t.dp { background: var(--disney); box-shadow: none; }

/* ---- apps ---- */
.applist { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 12px; }
.applist li { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 14px; background: var(--raised); border: 1.5px solid var(--line); border-radius: var(--radius-lg); }
.applist .chip { width: 64px; height: 44px; border-radius: var(--radius-md); background: var(--brand); display: grid; place-items: center; }
.applist .chip img { max-width: 44px; max-height: 22px; filter: brightness(0) invert(1); }
.applist b { display: block; font-size: 17px; }
.applist input { margin-top: 4px; padding: 8px 10px; font-size: 14px; color: var(--muted); }
.switch { position: relative; width: 52px; height: 32px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--raised-2); box-shadow: inset 0 0 0 1.5px var(--line); transition: background 160ms ease; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform 160ms ease, background 160ms ease; }
.switch input:checked + i { background: var(--focus); }
.switch input:checked + i::after { transform: translateX(20px); background: var(--on-focus); }
.switch input:focus-visible + i { outline: 3px solid var(--focus); outline-offset: 3px; }

.status-line { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }

/* ---- alerts ---- */
.tries { display: grid; gap: 12px; }
@media (min-width: 640px) { .tries { grid-template-columns: repeat(3, 1fr); } }
.try { display: flex; align-items: center; gap: 14px; padding: 12px; text-align: left; background: var(--raised); border: 1.5px solid var(--line); border-radius: var(--radius-lg); }
.try:active { transform: scale(.98); }
.try img, .try .bulb { width: 56px; height: 56px; border-radius: var(--radius-md); flex: none; }
.try span { color: var(--muted); font-size: 14.5px; }
.try strong { display: block; color: var(--text); font-size: 16.5px; }
.bulb { display: block; border-radius: 50% !important; background: var(--raised-2) center / 30px no-repeat; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='none' stroke='%23999' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M17 33.5c0-4-5-7.2-5-14a12 12 0 0 1 24 0c0 6.8-5 10-5 14M18 38h12M20 43h8'/%3E%3C/svg%3E"); }
.bulb.on { background-color: #ffc94d; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='none' stroke='%233b2a00' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M17 33.5c0-4-5-7.2-5-14a12 12 0 0 1 24 0c0 6.8-5 10-5 14M18 38h12M20 43h8'/%3E%3C/svg%3E"); }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history img, .history .bulb { width: 44px; height: 44px; border-radius: var(--radius-md); object-fit: cover; flex: none; }
.history .txt { flex: 1; min-width: 0; }
.history b { display: block; font-size: 15.5px; }
.history span { display: block; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history time { font-size: 13.5px; color: var(--muted); flex: none; }
.history .empty { color: var(--muted); border: 0; }
.code { margin: 14px 0; padding: 14px; overflow-x: auto; font-size: 13px; line-height: 1.5; background: var(--raised); border: 1.5px solid var(--line); border-radius: var(--radius-md); color: var(--muted); white-space: pre; }

form > .primary { margin-top: 4px; }
#pwForm, #jfForm { max-width: 420px; }
.block .ghost + .ghost { margin-left: 8px; }

/* ---- snack ---- */
.snack {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 20; transform: translate(-50%, 20px);
  padding: 12px 20px; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity 200ms ease, transform 200ms ease; max-width: calc(100vw - 40px);
}
.snack.show { opacity: 1; transform: translate(-50%, 0); }
.snack.bad { background: #ff8a80; color: #2a0000; }
@media (min-width: 900px) { .snack { bottom: 32px; } }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 1ms !important; transition-duration: 1ms !important; } }
