/* Shopol console. Always light (owner, 2026-10-30): white groups on soft grey, near-black text, one warm accent for
   progress. Phone first. */
:root {
  color-scheme: light;
  --bg: #f2f2f7; --surface: #ffffff; --surface2: #ececf1; --press: #e2e2e8; --line: rgba(60,60,67,.12);
  --text: #1c1c1e; --text2: rgba(28,28,30,.74); --muted: #8a8a8e; --ink: #1c1c1e; --on-ink: #ffffff;
  --accent: #d4880f; --ok: #248a3d; --warn: #b4610a; --bad: #d70015; --switch-on: #34c759;
  --r: 18px; --r-sm: 12px; --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, Vazirmatn, Tahoma, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* Top bar: brand + TV dot; tabs live here on wide screens, at the bottom on phones. */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: calc(10px + var(--safe-t)) 20px 10px;
  background: rgba(242,242,247,.82); backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; letter-spacing: -.2px; }
.brand img { border-radius: 7px; }
.tvdot { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.tvdot::before { content: ""; width: 8px; height: 8px; border-radius: 99px; background: currentColor; }
.tvdot.on { color: var(--ok); }
/* Outside the header: a backdrop-filter parent would trap a fixed bar. Wide screens: centred over the header. */
.tabs { position: fixed; z-index: 25; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 4px; }
.tabs a { display: flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 99px; color: var(--muted); font-weight: 550; font-size: 15px; }
.tabs a svg { width: 19px; height: 19px; }
.tabs a.on { color: var(--text); background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

main { max-width: 680px; margin: 0 auto; padding: 22px 16px calc(40px + var(--safe-b)); }
.loading { display: grid; place-items: center; min-height: 50vh; }
.spin { width: 26px; height: 26px; border-radius: 99px; border: 2.5px solid var(--surface2); border-top-color: var(--text2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

h1 { font-size: 32px; line-height: 1.15; margin: 4px 0 18px; font-weight: 700; letter-spacing: -.7px; }
.sec { font-size: 14px; font-weight: 600; color: var(--muted); margin: 28px 4px 8px; }
.foot { font-size: 13px; color: var(--muted); margin: 8px 4px 0; }
.muted { color: var(--muted); } .small { font-size: 13.5px; } .text2 { color: var(--text2); } .bad-text { color: var(--bad); }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--text2); font-size: 15px; margin: 0 0 6px -4px; }
.back svg { width: 20px; height: 20px; }

/* Cards and grouped lists (iOS-style inset groups). */
.card { background: var(--surface); border-radius: var(--r); padding: 18px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card + .card { margin-top: 12px; }
.group { background: var(--surface); border-radius: var(--r); overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.cell { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 12px 16px; position: relative; }
.cell + .cell::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 1px solid var(--line); }
.cell .grow { flex: 1; min-width: 0; }
.cell .sub { font-size: 13.5px; color: var(--muted); margin-top: 1px; }
.cell.link { cursor: pointer; } .cell.link:active { background: var(--surface2); }
.cell .chev { color: var(--muted); width: 18px; height: 18px; }
.cell.stack { display: block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
details.group > summary { list-style: none; cursor: pointer; } details.group > summary::-webkit-details-marker { display: none; }
details.group > summary .chev { transition: transform .2s; } details.group[open] > summary .chev { transform: rotate(90deg); }

/* Controls */
button { font: inherit; border: 0; cursor: pointer; color: inherit; background: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 99px; font-weight: 600; font-size: 15px;
  background: var(--ink); color: var(--on-ink); transition: transform .1s, background .15s; }
.btn.ghost { background: var(--surface2); color: var(--text); }
.btn.danger { background: rgba(215,0,21,.08); color: var(--bad); }
.btn.small { min-height: 34px; padding: 6px 13px; font-size: 14px; }
.btn.wide { width: 100%; min-height: 48px; }
.btn:active, .key:active, .seg button:active { transform: scale(.96); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
input, select { font: inherit; color: var(--text); background: var(--surface2); border: 1px solid transparent; border-radius: var(--r-sm); padding: 11px 14px; min-width: 0; width: 100%; font-size: 16px; }
input::placeholder { color: var(--muted); }
input:focus, select:focus { outline: none; border-color: rgba(212,136,15,.55); background: var(--surface); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cell select { width: auto; max-width: 52%; background: transparent; color: var(--text2); text-align: right; text-align-last: right; padding: 6px 22px 6px 6px; border: 0;
  appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a8e' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m8 10 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center; background-size: 18px; }
.cell select option { background: #fff; color: var(--text); }
.switch { width: 51px; height: 31px; border-radius: 99px; background: #e3e3e8; position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 99px; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.18), 0 0 0 .5px rgba(0,0,0,.04); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--switch-on); } .switch[aria-checked="true"]::after { transform: translateX(20px); }
.seg { display: flex; background: var(--surface2); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; min-height: 36px; padding: 6px 4px; border-radius: 9px; color: var(--text2); font-size: 14px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background .15s; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.field-row { display: flex; gap: 8px; } .field-row input { flex: 1; }
main > .field-row input { background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.code-input { font-size: 30px; letter-spacing: 12px; text-align: center; font-variant-numeric: tabular-nums; padding: 14px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--surface2); color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.pill.ok { color: var(--ok); background: rgba(36,138,61,.1); } .pill.warn { color: var(--warn); background: rgba(212,136,15,.12); } .pill.bad { color: var(--bad); background: rgba(215,0,21,.08); }

/* Status line and notices */
.status { display: flex; align-items: center; gap: 8px; color: var(--text2); font-size: 14.5px; margin: -8px 2px 16px; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 99px; background: var(--switch-on); }
.notice { display: block; background: rgba(212,136,15,.1); color: var(--warn); border-radius: 14px; padding: 12px 16px; font-weight: 550; font-size: 14.5px; margin-bottom: 12px; }
.notice + .notice { margin-top: -6px; }
.notice::after { content: " ›"; }

/* Now playing + remote */
.np .label { font-size: 13px; font-weight: 600; color: var(--warn); }
.np .label.paused { color: var(--muted); }
.np .title { font-size: 23px; font-weight: 700; letter-spacing: -.4px; line-height: 1.2; margin: 4px 0 2px; }
.np .meta { font-size: 14px; color: var(--muted); }
.bar { height: 4px; background: var(--surface2); border-radius: 99px; overflow: hidden; margin: 16px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.times { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.remote { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 20px 0 6px; }
.key { width: 62px; height: 62px; border-radius: 99px; background: var(--surface2); display: grid; place-items: center; position: relative; transition: transform .1s; }
.key svg { width: 26px; height: 26px; }
.key small { position: absolute; bottom: 9px; font-size: 10px; font-weight: 700; }
.key.main { width: 80px; height: 80px; background: var(--ink); color: var(--on-ink); }
.key.main svg { width: 32px; height: 32px; }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.idle { text-align: center; padding: 10px 0 4px; }
.idle svg { width: 34px; height: 34px; color: var(--muted); }
.idle .t { font-weight: 650; margin-top: 6px; } .idle .s { font-size: 14px; color: var(--muted); }
.subrow { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.subrow > span { font-size: 14px; color: var(--text2); flex: none; }
.subrow .seg { flex: 1; }

/* Recently watched */
.rw .ring { width: 34px; height: 34px; flex: none; }
.rw .ring circle { fill: none; stroke-width: 3.5; }
.rw .ring .bg { stroke: var(--surface2); } .rw .ring .fg { stroke: var(--accent); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }
.rw .done { width: 34px; height: 34px; border-radius: 99px; display: grid; place-items: center; background: rgba(36,138,61,.1); color: var(--ok); flex: none; }
.rw .done svg { width: 18px; height: 18px; stroke-width: 2.4; }
.t1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }

/* System page */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 14.5px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.log { font-size: 13px; }
.log .e { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.log .e:first-child { border-top: 0; }
.log .when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.log .area { font-weight: 600; color: var(--text2); } .log .area.lvl-error { color: var(--bad); } .log .area.lvl-warn { color: var(--warn); }
.log .msg { grid-column: 1 / -1; color: var(--text2); word-break: break-word; }
.rel { display: grid; grid-template-columns: auto auto 1fr; gap: 6px 12px; font-size: 13.5px; margin-top: 10px; }
code { display: block; background: var(--surface2); padding: 10px 12px; border-radius: 10px; word-break: break-all; font-size: 13px; margin-top: 8px; }
pre { background: var(--surface2); padding: 12px; border-radius: 12px; white-space: pre-wrap; }
.qr { background: #fff; padding: 12px; border-radius: 14px; display: inline-block; border: 1px solid var(--line); }
.qr img { display: block; }

/* Sign-in */
.auth { max-width: 380px; margin: 8vh auto 0; text-align: center; display: grid; gap: 14px; }
.auth img.logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto; box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.auth h1 { margin: 0; } .auth p { margin: 0; }
.auth details { font-size: 14px; } .auth summary { cursor: pointer; color: var(--muted); }
.auth details .field-row { margin-top: 10px; }
.auth .left { text-align: left; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 40; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--on-ink); padding: 11px 18px; border-radius: 99px; font-weight: 600; font-size: 14.5px; box-shadow: 0 10px 30px rgba(0,0,0,.18); text-align: center; }
[dir=auto] { unicode-bidi: plaintext; }

/* Phones: tabs move to a bottom bar. */
@media (max-width: 760px) {
  .top { padding: calc(8px + var(--safe-t)) 16px 8px; }
  .tabs { top: auto; transform: none; left: 0; right: 0; bottom: 0; margin: 0; z-index: 30; justify-content: space-around; gap: 0; height: calc(var(--tab-h) + var(--safe-b));
    padding: 6px 8px var(--safe-b); background: rgba(249,249,251,.9); backdrop-filter: saturate(160%) blur(22px); -webkit-backdrop-filter: saturate(160%) blur(22px); border-top: 1px solid var(--line); }
  .tabs a { flex: 1; flex-direction: column; gap: 2px; padding: 4px 0; border-radius: 12px; font-size: 11px; font-weight: 600; }
  .tabs a svg { width: 25px; height: 25px; }
  .tabs a.on { background: none; box-shadow: none; color: var(--text); }
  body.has-tabs main { padding-bottom: calc(var(--tab-h) + 28px + var(--safe-b)); }
  body.has-tabs .toast { bottom: calc(var(--tab-h) + 16px + var(--safe-b)); }
  h1 { font-size: 28px; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 10px; }
}
@media (max-width: 380px) { .subrow { flex-direction: column; align-items: stretch; gap: 8px; } }
body.auth-mode .top { display: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; } }

/* YouTube: the same cards and controls as the rest of the console. */
.yt-entry label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.yt-entry .btn, .yt-history-row .btn, .yt-confirm .btn, #ytRetry { min-height: 44px; }
.yt-entry .field-row input { min-height: 44px; }
.yt-preview { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; }
.yt-preview-info, .yt-history-head .grow { min-width: 0; flex: 1; }
.yt-preview .sub { font-size: 13.5px; color: var(--muted); }
.yt-link { overflow-wrap: anywhere; }
.yt-thumb { width: 96px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--surface2); flex: none; }
.yt-confirm { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.yt-history-head { display: flex; gap: 12px; align-items: center; }
.yt-history-head .pill { margin-top: 5px; }
.yt-history-row .actions { margin-top: 10px; }
.yt-focus { min-height: 44px; padding: 0 4px; color: var(--text); font-weight: 600; }
