/* Ovladač TV: tmavý standardní ovladač. */

@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree-latin-ext.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Figtree";
  src: url("fonts/figtree-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;

  /* graphite */
  --ground: #0f1012;
  --body: #17191c;
  --key: #24272c;
  --key-hi: #2d3137;
  --key-press: #383d45;
  --seam: #2a2d33;
  --ink: #f4f5f7;
  --ink-2: #a8aeb9;
  --ink-3: #7d8490;

  /* role colours */
  --blue: #2563eb;
  --blue-hi: #1d56d8;
  --ring: #60a5fa;
  --ring-soft: rgba(96, 165, 250, .35);
  --lift: inset 0 1px 0 rgba(255, 255, 255, .05), inset 0 -1px 0 rgba(0, 0, 0, .25);
  --red: #f87171;
  --red-ground: #2b1719;
  --red-face: #3a1d20;
  --green: #22c55e;
  --amber: #f59e0b;

  --c-red: #e5484d;
  --c-green: #30a46c;
  --c-yellow: #f5c518;
  --c-blue: #3e7bf2;

  --font: "Figtree", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  --u: 48px;                       /* výška kláves */
  --gap: 14px;
  --dpad: 228px;
  --radius-panel: 20px;

  --step: 60ms linear;             /* stisk: okamžitý krok dolů */
  --bloom: 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--blue); color: #fff; }
* { scrollbar-width: thin; scrollbar-color: var(--key-hi) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--key-hi); border-radius: 10px; border: 2px solid var(--ground); }
::-webkit-scrollbar-track { background: transparent; }
input { caret-color: var(--ring); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }

/* ------------------------------------------------------------------ rozvržení */

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 40px;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 40px;
  min-height: 100dvh;
  align-items: start;
}

.view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.top { display: flex; align-items: center; gap: 14px; min-height: 52px; }
.dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--ink-3);
}
[data-tv="online"] .dot { background: var(--green); }
[data-tv="offline"] .dot, [data-tv="server"] .dot, [data-tv="agent"] .dot { background: var(--red); }
[data-tv="waiting"] .dot, [data-tv="unpaired"] .dot { background: var(--amber); }

.tv { min-width: 0; }
.tv h1 { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); }
[data-tv="offline"] .conn, [data-tv="server"] .conn, [data-tv="agent"] .conn { color: #fca5a5; }
[data-tv="waiting"] .conn, [data-tv="unpaired"] .conn { color: #fcd34d; }
.model { margin: 0 0 0 auto; font-size: 13px; color: var(--ink-3); white-space: nowrap; }

.ghost {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: 12px;
  color: var(--ink-2); font-size: 14px; font-weight: 550;
  transition: background var(--step), color var(--step);
}
.ghost:hover { background: var(--key); color: var(--ink); }
.ghost[aria-expanded="true"] { background: var(--key); color: var(--ink); }
.ghost .ic { width: 20px; height: 20px; }
.ghost.icon-only { width: 40px; padding: 0; justify-content: center; }

/* ------------------------------------------------------------------ obrazovka */

.screen {
  aspect-ratio: 16 / 9;
  max-height: calc(100dvh - 210px);
  min-height: 240px;
  width: 100%;
  background: var(--body);
  border-radius: var(--radius-panel);
  box-shadow: inset 0 0 0 1px var(--seam);
  display: grid; place-items: center;
  overflow: hidden;
}
.screen-empty { text-align: center; padding: 24px; max-width: 46ch; }
.screen-icon { width: 40px; height: 40px; color: var(--ink-3); fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.screen-title { margin: 14px 0 6px; font-size: 18px; font-weight: 600; text-wrap: balance; }
.screen-sub { margin: 0; color: var(--ink-2); text-wrap: balance; }

/* ------------------------------------------------------------------ stavový řádek */

.status {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 12px 18px;
  background: var(--body); border-radius: 14px;
  box-shadow: inset 0 0 0 1px var(--seam);
  font-size: 15px; color: var(--ink-2);
}
.status b { color: var(--ink); font-weight: 600; }
.status-text { min-width: 0; flex: 1; }
.status-time { color: var(--ink-3); font-size: 13px; white-space: nowrap; }
.lamp {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: var(--key-press);
  transition: background var(--step);
}
.status.is-sending .lamp { background: var(--ink-3); }
.lamp.is-flash { background: var(--ring); animation: lamp var(--bloom); }
.status.is-failed { background: var(--red-ground); box-shadow: inset 0 0 0 1px #4a2327; color: #fca5a5; }
.status.is-failed b { color: var(--red); }
.status.is-failed .lamp { background: var(--red); animation: none; }
@keyframes lamp {
  from { box-shadow: 0 0 0 0 rgba(96, 165, 250, .7); }
  to { box-shadow: 0 0 0 10px rgba(96, 165, 250, 0); }
}

/* ------------------------------------------------------------------ nastavení */

.setup {
  background: var(--body); border-radius: var(--radius-panel);
  box-shadow: inset 0 0 0 1px var(--seam);
  padding: 20px 24px 24px;
  display: grid; gap: 20px;
}
.setup[hidden] { display: none; }
.setup-head { display: flex; align-items: center; justify-content: space-between; }
.setup h2 { margin: 0; font-size: 18px; font-weight: 650; }
.setup h3 { margin: 0 0 8px; font-size: 15px; font-weight: 650; }
.setup p { margin: 0 0 12px; color: var(--ink-2); max-width: 65ch; }

.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 24px; }
.facts div { min-width: 0; }
.facts dt { font-size: 13px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 550; overflow-wrap: anywhere; }

.pair { border-top: 1px solid var(--seam); padding-top: 18px; }
.pair-note { border-top: 1px solid var(--seam); padding-top: 18px; }
.pair-note[hidden], .pair[hidden] { display: none; }
.pin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.pin-row label { font-size: 14px; color: var(--ink-2); }
.pin-row input {
  width: 7.5ch; height: 44px; padding: 0 12px;
  font: inherit; font-size: 20px; font-weight: 600; letter-spacing: .2em; text-align: center;
  color: var(--ink); background: var(--ground);
  border: 1px solid var(--key-hi); border-radius: 12px;
}
.pin-row input:focus-visible { outline-offset: 1px; border-color: var(--ink); }
.pair-msg { margin: 10px 0 0 !important; min-height: 1.45em; }

.btn {
  height: 44px; padding: 0 18px; border-radius: 12px;
  background: var(--key); color: var(--ink); font-weight: 600;
  transition: background var(--step);
}
.btn:hover { background: var(--key-hi); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-hi); }

.shortcuts { border-top: 1px solid var(--seam); padding-top: 18px; }
.shortcuts dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 24px; }
.shortcuts div { display: flex; align-items: baseline; gap: 10px; }
.shortcuts dt { flex: none; }
.shortcuts dd { margin: 0; color: var(--ink-2); }
kbd {
  display: inline-block; min-width: 26px; padding: 1px 6px;
  font: inherit; font-size: 13px; font-weight: 600; text-align: center;
  color: var(--ink); background: var(--key); border-radius: 6px;
  box-shadow: inset 0 -1px 0 var(--key-press);
}

/* ------------------------------------------------------------------ ovladač */

.remote {
  position: sticky; top: 28px;
  background: var(--body);
  border-radius: 32px;
  box-shadow: inset 0 0 0 1px var(--seam), 0 24px 48px -24px rgba(0, 0, 0, .7);
  padding: 22px 24px 24px;
  display: flex; flex-direction: column; gap: var(--gap);
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
.remote button { touch-action: manipulation; }

.r-top { display: flex; justify-content: space-between; align-items: flex-start; }
.r-row { display: flex; justify-content: space-between; gap: 10px; }

/* kulaté klávesy s popiskem */
.rk { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 72px; }
.rk .face {
  position: relative;
  width: var(--u); height: var(--u); border-radius: 50%;
  display: grid; place-items: center;
  background: var(--key);
  box-shadow: var(--lift);
  transition: background var(--step), transform var(--step);
}
.rk:hover .face { background: var(--key-hi); }
.rk .cap { font-size: 12px; font-weight: 550; color: var(--ink-2); line-height: 1.2; }
.rk.power .face { background: var(--red-face); color: var(--red); }
.rk.power:hover .face { background: #47232a; }
.rk.power .cap { color: #fca5a5; }
/* vypnutá TV: stejné tlačítko zapíná po síti; červená patří jen vypnutí */
.rk.power[data-mode="wake"] .face { background: var(--key); color: var(--ink); }
.rk.power[data-mode="wake"]:hover .face { background: var(--key-hi); }
.rk.power[data-mode="wake"] .cap { color: var(--ink-2); }
.rk.power[data-mode="wake"].is-pressed .face { background: var(--key-press); }

/* směrový kříž */
.dpad { position: relative; width: var(--dpad); height: var(--dpad); align-self: center; margin: 2px 0; }
/* čtvrtiny čtverce otočeného o 45° = výseče kruhu, mezera mezi nimi = šev */
.dpad-ring {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  display: grid; grid-template: 1fr 1fr / 1fr 1fr; gap: 3px;
  background: var(--body);
  transform: rotate(45deg);
}
.wedge {
  display: grid; place-items: center;
  background: var(--key);
  transition: background var(--step);
}
.wedge.up { grid-area: 1 / 1; }
.wedge.right { grid-area: 1 / 2; }
.wedge.left { grid-area: 2 / 1; }
.wedge.down { grid-area: 2 / 2; }
.wedge .ic { transform: rotate(-45deg); width: 26px; height: 26px; }
.wedge:hover { background: var(--key-hi); }
.ok {
  position: absolute; inset: 30%;
  border-radius: 50%;
  background: var(--blue); color: #fff;
  font-size: 18px; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 0 0 6px var(--body);
  transition: background var(--step), transform var(--step);
}
.ok:hover { background: var(--blue-hi); }

/* hlasitost a programy */
.r-rockers { display: grid; grid-template-columns: 76px 1fr 76px; align-items: center; gap: 10px; }
.r-mid { display: flex; justify-content: center; gap: 6px; }
.pill {
  display: grid; grid-template-rows: 1fr auto 1fr;
  height: calc(var(--u) * 3); border-radius: 32px; overflow: hidden;
  background: var(--key);
}
.pill button {
  display: grid; place-items: center;
  transition: background var(--step);
}
.pill button:hover { background: var(--key-hi); }
.pill-label {
  font-size: 12px; font-weight: 600;
  color: var(--ink-2); text-align: center; padding: 4px 8px;
}

/* textové klávesy */
.r-text { gap: 8px; }
.tk {
  position: relative;
  flex: 1; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--key); font-size: 13px; font-weight: 600; color: var(--ink);
  box-shadow: var(--lift);
  transition: background var(--step), transform var(--step);
}
.tk .ic { width: 18px; height: 18px; color: var(--ink-2); }
.tk:hover { background: var(--key-hi); }

/* barevná tlačítka */
.r-colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ck { position: relative; height: 22px; border-radius: 11px; background: var(--key); transition: background var(--step), transform var(--step); }
.ck::before { content: ""; position: absolute; left: 50%; top: 50%; width: 28px; height: 8px; margin: -4px 0 0 -14px; border-radius: 4px; }
.ck.red::before { background: var(--c-red); }
.ck.green::before { background: var(--c-green); }
.ck.yellow::before { background: var(--c-yellow); }
.ck.blue::before { background: var(--c-blue); }
.ck:hover { background: var(--key-hi); }

/* čísla */
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.nk {
  position: relative;
  height: 42px; border-radius: 12px;
  background: var(--key);
  box-shadow: var(--lift);
  font-size: 18px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--step), transform var(--step);
}
.nk:hover { background: var(--key-hi); }
.nk.fn { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.nk.fn .ic { width: 18px; height: 18px; }

/* aplikace */
.r-apps { gap: 8px; }
.ak {
  position: relative;
  flex: 1; height: 44px; border-radius: 12px;
  background: var(--key); font-size: 15px; font-weight: 650;
  box-shadow: var(--lift);
  transition: background var(--step), transform var(--step);
}
.ak:hover { background: var(--key-hi); }

/* ------------------------------------------------------------------ stisk a potvrzení */

.rk.is-pressed .face, .tk.is-pressed, .nk.is-pressed, .ak.is-pressed, .ck.is-pressed,
.pill button.is-pressed, .wedge.is-pressed { background: var(--key-press); }
.rk.is-pressed .face, .tk.is-pressed, .nk.is-pressed, .ak.is-pressed, .ck.is-pressed { transform: scale(.94); }
.ok.is-pressed { transform: scale(.94); background: #1d4fc4; }
.rk.power.is-pressed .face { background: #522830; }

/* čeká na potvrzení TV: slabý kroužek; potvrzeno: kroužek vykvete a zůstane na klávese */
.rk.is-pending .face::after, .tk.is-pending::after, .nk.is-pending::after, .ak.is-pending::after, .ck.is-pending::after, .ok.is-pending::after,
.rk.is-last .face::after, .tk.is-last::after, .nk.is-last::after, .ak.is-last::after, .ck.is-last::after, .ok.is-last::after {
  content: ""; position: absolute; inset: -4px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 2px var(--ring-soft);
}
.rk.is-last .face::after, .tk.is-last::after, .nk.is-last::after, .ak.is-last::after, .ck.is-last::after, .ok.is-last::after {
  box-shadow: 0 0 0 2px var(--ring);
  animation: bloom var(--bloom);
}
.ok.is-pending::after, .ok.is-last::after { inset: -9px; }

/* výseče kříže a půlky kolébek: kroužek kreslený uvnitř tvaru klávesy (obal je ořezává) */
.wedge { position: relative; overflow: hidden; --bw: 3px; }
.pill button { position: relative; --bw: 2px; }
.pill button:first-child { border-radius: 32px 32px 0 0; }
.pill button:last-child { border-radius: 0 0 32px 32px; }
.wedge::before, .wedge::after {
  content: ""; position: absolute; width: 200%; height: 200%; border-radius: 50%; pointer-events: none;
}
.wedge.up::before, .wedge.up::after { left: 0; top: 0; }
.wedge.right::before, .wedge.right::after { left: -100%; top: 0; }
.wedge.left::before, .wedge.left::after { left: 0; top: -100%; }
.wedge.down::before, .wedge.down::after { left: -100%; top: -100%; }
.pill button.is-pending::after, .pill button.is-last::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
}
.wedge.is-pending::after, .pill button.is-pending::after { box-shadow: inset 0 0 0 var(--bw) var(--ring-soft); }
.wedge.is-last::after, .pill button.is-last::after {
  box-shadow: inset 0 0 0 var(--bw) var(--ring);
  animation: bloom-in var(--bloom);
}
.wedge.is-last, .pill button.is-last { color: #cfe1ff; }

@keyframes bloom {
  from { box-shadow: 0 0 0 10px rgba(96, 165, 250, 0); }
  to { box-shadow: 0 0 0 2px var(--ring); }
}
@keyframes bloom-in {
  from { box-shadow: inset 0 0 0 14px rgba(96, 165, 250, 0); }
  to { box-shadow: inset 0 0 0 var(--bw) var(--ring); }
}

/* fokus z klávesnice je bílý, modrá znamená jen „TV potvrdila“ */
.rk:focus-visible { outline: none; }
.rk:focus-visible .face { outline: 2px solid var(--ink); outline-offset: 3px; }
.wedge:focus-visible, .pill button:focus-visible { outline: none; }
.wedge:focus-visible::before { box-shadow: inset 0 0 0 2px var(--ink); }
.pill button:focus-visible { box-shadow: inset 0 0 0 2px var(--ink); }

/* aplikace: dlaždice v barvách a s logy služeb (záměrná výjimka z palety: barvy patří službám) */
.ak.brand-tile { display: flex; align-items: center; justify-content: center; padding: 0 10px; min-width: 0; }
.ak .brand { display: block; height: var(--logo-h, 18px); width: auto; max-width: 100%; pointer-events: none; -webkit-user-drag: none; }
.ak.app-oneplay { background: #010114; box-shadow: inset 0 0 0 1px #262645, var(--lift); --logo-h: 22px; }
.ak.app-oneplay:hover { background: #0d0d2b; }
.ak.app-ivysilani { background: #ffffff; --logo-h: 17px; }
.ak.app-ivysilani:hover { background: #e9edf3; }
.ak.app-youtube { background: #ff0000; --logo-h: 17px; }
.ak.app-youtube:hover { background: #e00000; }
.ak.brand-tile.is-pressed { filter: brightness(.82); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
  .rk .face, .tk, .nk, .ak, .ck, .ok { transition: none; }
}

/* ------------------------------------------------------------------ výška monitoru: ovladač se vejde */

@media (min-width: 900px) and (max-height: 960px) {
  :root { --u: clamp(38px, 4.6vh, 48px); --dpad: clamp(176px, 22.4vh, 228px); --gap: clamp(9px, 1.25vh, 14px); }
  .app { padding-top: 22px; padding-bottom: 22px; }
  .remote { top: 22px; padding: 18px 22px 20px; }
  .nk { height: clamp(34px, 4.4vh, 42px); }
  .tk { height: clamp(34px, 4.2vh, 40px); }
  .ak { height: clamp(36px, 4.6vh, 44px); }
  .rk .cap { font-size: 11.5px; }
}

/* ------------------------------------------------------------------ telefon */

@media (max-width: 899px) {
  :root { --u: 54px; --dpad: min(72vw, 268px); --gap: 16px; }
  .app { grid-template-columns: 1fr; gap: 14px; padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); }
  .view { display: contents; }
  .top { order: 1; }
  .model { display: none; }
  .ghost span { display: none; }
  #setup-toggle { width: 44px; height: 44px; padding: 0; justify-content: center; margin-left: auto; }
  .screen { order: 2; aspect-ratio: auto; min-height: 0; max-height: none; border-radius: 14px; }
  .screen-empty { display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-align: left; max-width: none; }
  .screen-icon { width: 24px; height: 24px; }
  .screen-title { margin: 0; font-size: 14px; font-weight: 550; color: var(--ink-2); }
  .screen-sub { display: none; }
  .status { order: 3; position: sticky; top: 0; z-index: 2; height: 62px; min-height: 0; padding: 10px 14px; font-size: 14px; box-shadow: inset 0 0 0 1px var(--seam), 0 10px 18px -8px var(--ground); }
  .status-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .remote { order: 4; position: static; width: 100%; max-width: 440px; margin: 0 auto; padding: 22px 20px 24px; border-radius: 28px; }
  .setup { order: 5; padding: 18px; }
  .shortcuts { display: none; }
  .rk { width: 76px; }
  .rk .cap { font-size: 12.5px; }
  .tk { height: 48px; font-size: 14px; }
  .nk { height: 52px; font-size: 20px; }
  .nk.fn { font-size: 12.5px; flex-direction: column; gap: 2px; }
  .ak { height: 52px; }
  .ak.app-oneplay { --logo-h: 26px; }
  .ak.app-ivysilani { --logo-h: 20px; }
  .ak.app-youtube { --logo-h: 20px; }
  .ck { height: 30px; border-radius: 15px; }
  .r-rockers { grid-template-columns: 72px minmax(0, 1fr) 72px; }
  .r-mid { gap: 4px; }
  .r-mid .rk { width: 64px; }
}

@media (max-width: 360px) {
  .rk { width: 64px; }
  .nk.fn span { display: none; }
}
