/* Дистанционно: изглед по Vercel Geist (тъмна тема, тънки линии 1px, деликатно заоблени ъгли 6-12px, шрифт Geist). */
:root {
  --bg: #0a0a0a; --bg2: #111111; --surface: #161616; --surface2: #1f1f1f;
  --line: rgba(255, 255, 255, .10); --line2: rgba(255, 255, 255, .16); --line3: rgba(255, 255, 255, .26);
  --text: #ededed; --muted: #a1a1a1; --faint: #707070;
  --accent: #0a72ef; --accent-soft: rgba(10, 114, 239, .14); --red: #e5484d; --red-soft: rgba(229, 72, 77, .12);
  --ok: #45a557; --warn: #f5a524;
  --r-sm: 6px; --r: 8px; --r-lg: 12px;
  --ease: cubic-bezier(.3, 1.5, .5, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.5 "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-wrap: pretty; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased; }
#app { max-width: 460px; margin: 0 auto; padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 24px); }
.hidden { display: none !important; }
h1 { font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; margin: 0; }
h2 { font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 10px; }
h2.first { margin-top: 0; }
h3 { margin: 0 0 6px; font-weight: 600; letter-spacing: -.01em; }
p { margin: 6px 0; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line3); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.err { color: var(--red); }
.top { display: flex; gap: 14px; align-items: center; padding-top: 24px; }
.logo { width: 48px; height: 48px; border-radius: var(--r-lg); border: 1px solid var(--line); }
.note { display: flex; gap: 12px; align-items: center; justify-content: space-between; border: 1px solid var(--line); background: var(--bg2);
  border-radius: var(--r-lg); padding: 12px 14px; margin-top: 16px; font-size: .9rem; }
.card { border: 1px solid var(--line); background: var(--bg2); border-radius: var(--r-lg); padding: 16px; margin-top: 18px; }

/* бутони */
.btn { appearance: none; border: 1px solid var(--line2); border-radius: var(--r); background: var(--surface); color: var(--text); font: inherit;
  font-weight: 500; padding: 10px 16px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; transition: background .15s, border-color .15s, transform .12s var(--ease); }
.btn:hover { border-color: var(--line3); background: var(--surface2); }
.btn:active { transform: scale(.98); }
.btn.accent { background: var(--text); color: #0a0a0a; border-color: var(--text); }
.btn.accent:hover { background: #fff; }
.btn.danger { color: var(--red); border-color: rgba(229, 72, 77, .35); background: var(--red-soft); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; white-space: nowrap; }
.btn.wide { width: 100%; }
.row { display: flex; gap: 8px; }
.row.end { justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
input { flex: 1; min-width: 0; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line2); border-radius: var(--r);
  padding: 10px 12px; min-height: 44px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus { border-color: var(--line3); box-shadow: 0 0 0 3px rgba(255, 255, 255, .06); }
input::placeholder { color: var(--faint); }

/* телевизори в списъка: карта + молив (преименуване) или × (махане от намерените) */
.tv { display: flex; align-items: stretch; border: 1px solid var(--line); background: var(--bg2); border-radius: var(--r-lg); margin-top: 8px;
  transition: border-color .15s, background .15s; }
.tv:hover { border-color: var(--line2); }
.tv .main { flex: 1; min-width: 0; appearance: none; background: none; border: 0; color: var(--text); text-align: left; font: inherit;
  padding: 12px 14px; cursor: pointer; border-radius: var(--r-lg) 0 0 var(--r-lg); }
.tv .main:active { background: var(--surface); }
.tv b { display: block; font-weight: 500; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv span { color: var(--muted); font-size: .82rem; }
.tv .tool { appearance: none; background: none; border: 0; border-left: 1px solid var(--line); color: var(--muted); width: 48px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; }
.tv .tool:last-child { border-radius: 0 var(--r-lg) var(--r-lg) 0; }
.tv .tool:hover { color: var(--text); background: var(--surface); }
.tv .tool svg { width: 18px; height: 18px; }
.tv .badge { display: inline-block; margin-left: 6px; font-size: .72rem; color: var(--ok); border: 1px solid rgba(69, 165, 87, .35);
  border-radius: 999px; padding: 0 7px; vertical-align: 1px; }
footer { margin-top: 36px; line-height: 1.9; }

/* дистанционно */
.bar { display: flex; align-items: center; gap: 4px; padding: 10px 0 8px; }
.icon { appearance: none; background: none; border: 1px solid transparent; border-radius: var(--r); color: var(--text); font-size: 24px;
  width: 44px; height: 44px; cursor: pointer; }
.icon:hover { border-color: var(--line); }
.titles { flex: 1; min-width: 0; }
.name { font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { font-size: .8rem; color: var(--muted); }
.status::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); margin-right: 6px; vertical-align: 1px; }
.status.live { color: var(--ok); }
.status.live::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(69, 165, 87, .18); }
.pad { border: 1px solid var(--line); background: var(--bg2); border-radius: 20px; padding: 18px; transition: opacity .2s; max-width: 380px; margin: 6px auto 0; }
.pad.off { opacity: .5; }

/* бутоните на дистанционното: тънка рамка, леко хлътване и пружиниране */
.k { appearance: none; border: 1px solid var(--line2); border-radius: var(--r-lg); background: var(--surface); color: var(--text); font: inherit;
  font-size: .95rem; font-weight: 500; min-height: 52px; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 2px 0 rgba(0, 0, 0, .5);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .12s, border-color .12s; }
.k.red { color: var(--red); border-color: rgba(229, 72, 77, .4); background: var(--red-soft); }
.k.is-pressed { transform: translateY(2px) scale(.94); box-shadow: 0 0 0 3px rgba(255, 255, 255, .10); background: #2a2a2a; border-color: rgba(255, 255, 255, .7);
  transition-duration: .04s; }
.k svg { display: block; margin: auto; pointer-events: none; width: 22px; height: 22px; }
.keys3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.keys2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }

.dpad { position: relative; aspect-ratio: 1; margin: 20px 18px; border-radius: 50%; border: 1px solid var(--line2); background: var(--surface);
  overflow: hidden; touch-action: none; box-shadow: 0 2px 0 rgba(0, 0, 0, .5); transition: transform .2s var(--ease); }
.dpad::before, .dpad::after { content: ''; position: absolute; left: 50%; top: 50%; width: 141%; height: 1px; background: var(--line);
  transform: translate(-50%, -50%) rotate(45deg); pointer-events: none; }
.dpad::after { transform: translate(-50%, -50%) rotate(-45deg); }
.dpad.tilt-up { transform: perspective(600px) rotateX(6deg); } .dpad.tilt-down { transform: perspective(600px) rotateX(-6deg); }
.dpad.tilt-left { transform: perspective(600px) rotateY(-6deg); } .dpad.tilt-right { transform: perspective(600px) rotateY(6deg); }
.dir { position: absolute; appearance: none; border: 0; background: transparent; cursor: pointer; user-select: none; -webkit-user-select: none; z-index: 1; }
.dir.up, .dir.down { left: 25%; width: 50%; height: 31%; }
.dir.left, .dir.right { top: 25%; height: 50%; width: 31%; }
.dir.up { top: 0; } .dir.down { bottom: 0; } .dir.left { left: 0; } .dir.right { right: 0; }
.dir i { position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; border: solid var(--text); border-width: 1.5px 1.5px 0 0; }
.dir.up i { transform: translate(-50%, -30%) rotate(-45deg); }
.dir.down i { transform: translate(-50%, -70%) rotate(135deg); }
.dir.left i { transform: translate(-30%, -50%) rotate(-135deg); }
.dir.right i { transform: translate(-70%, -50%) rotate(45deg); }
.dir.is-on { background: radial-gradient(circle at center, rgba(10, 114, 239, .38) 0 72%, transparent 73%); }
.dir.is-on i { border-color: #fff; }
.ok { position: absolute; left: 31%; top: 31%; width: 38%; height: 38%; border-radius: 50%; border: 1px solid var(--line3); background: var(--bg2);
  color: var(--text); font: 600 1rem "Geist", system-ui, sans-serif; letter-spacing: .04em; cursor: pointer; z-index: 2;
  transition: transform .18s var(--ease), background .12s, border-color .12s; }
.ok.is-on { transform: scale(.9); background: rgba(10, 114, 239, .45); border-color: #fff; color: #fff; transition-duration: .04s; }

.mid { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 8px; margin-top: 12px; align-items: start; }
.rocker { display: flex; flex-direction: column; border: 1px solid var(--line2); background: var(--surface); border-radius: 26px; overflow: hidden;
  text-align: center; box-shadow: 0 2px 0 rgba(0, 0, 0, .5); }
.rocker .k { min-height: 56px; font-size: 1.3rem; font-weight: 400; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.rocker .k.is-pressed { background: #2a2a2a; transform: scale(.92); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .55); }
.rocker span { font-size: .66rem; letter-spacing: .1em; color: var(--faint); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 2px 0; }
.media > .k { width: 100%; }
.numbers { margin-top: 12px; }
.numbers summary { list-style: none; text-align: center; border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px; cursor: pointer;
  font-weight: 500; color: var(--muted); }
.numbers summary:hover { color: var(--text); border-color: var(--line2); }
.numbers summary::-webkit-details-marker { display: none; }

/* картина от екрана */
.screen { max-width: 380px; margin: 0 auto 10px; }
.screen summary { list-style: none; cursor: pointer; border: 1px solid var(--line); background: var(--bg2); border-radius: var(--r-lg);
  padding: 10px 14px; font-weight: 500; font-size: .9rem; }
.screen summary::-webkit-details-marker { display: none; }
.screen summary::after { content: ''; float: right; width: 7px; height: 7px; margin-top: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg); transition: transform .2s; }
.screen[open] summary::after { transform: rotate(-135deg); margin-top: 9px; }
.shot { margin-top: 8px; }
.shot img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border: 1px solid var(--line); border-radius: var(--r-lg); }
.shot img.stale { opacity: .45; }
.shot p { margin: 6px 2px 0; }

dialog { background: var(--bg2); color: var(--text); border: 1px solid var(--line2); border-radius: var(--r-lg); padding: 20px; width: min(92vw, 380px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(2px); }
#codeIn { width: 100%; font-size: 1.6rem; letter-spacing: .3em; text-align: center; text-transform: uppercase; margin-top: 10px; font-variant-numeric: tabular-nums; }
#pairCode { text-transform: uppercase; letter-spacing: .15em; }

/* код за Downloader */
.dl { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin-top: 18px; padding: 14px 16px;
  border: 1px solid var(--line2); border-radius: var(--r-lg); background: linear-gradient(180deg, #141414, var(--bg2)); }
.dl-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dl-code { font: 600 1.9rem/1.15 "Geist Mono", "Geist", ui-monospace, monospace; letter-spacing: .08em; }
.dl p { margin: 0; flex: 1 1 180px; }

/* клавиатура */
.kbd .kbd-top { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.kbd-echo { flex: 1; min-width: 0; min-height: 40px; border: 1px solid var(--line2); border-radius: var(--r); padding: 8px 10px; font-size: .95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left; background: var(--bg); }
.kbd-keys { margin-top: 8px; display: grid; gap: 6px; }
.kbd-row { display: flex; gap: 4px; justify-content: center; }
.k.kk { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0; font-size: 1.02rem; border-radius: var(--r); }
.k.kk.wide { flex: 1.5 1 0; font-size: .9rem; }
.k.kk.space { flex: 4 1 0; font-size: .82rem; color: var(--muted); }
.k.kk.on { background: #2a2a2a; border-color: rgba(255, 255, 255, .7); }
.kbd p { margin-top: 8px; }

/* бутон за говорене */
.k.mic { width: 100%; margin-top: 12px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.k.mic svg { width: 20px; height: 20px; margin: 0; }
.k.mic.listening { color: #fff; border-color: var(--red); background: var(--red-soft); animation: micPulse 1.1s ease-in-out infinite; }
@keyframes micPulse { 50% { box-shadow: 0 0 0 6px rgba(229, 72, 77, .18); } }

/* Дистанционното се събира по височина: кръстът се смалява, за да се вижда „Задръж и говори“ без превъртане. */
#remote .bar { padding: 6px 0 4px; }
#remote .pad { padding: 14px; margin-top: 4px; }
#remote .k { min-height: 48px; }
#remote .rocker .k { min-height: 50px; }
#remote .keys3 { margin-top: 8px; }
#remote .mid { margin-top: 10px; }
#remote .k.mic { margin-top: 10px; min-height: 48px; }
#remote .dpad { width: min(100% - 28px, max(150px, 100vh - var(--dpad-rest, 410px))); margin: 12px auto; }
@supports (height: 100svh) { #remote .dpad { width: min(100% - 28px, max(150px, 100svh - var(--dpad-rest, 410px))); } }

/* панел при говорене */
.voice { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .55);
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); backdrop-filter: blur(2px); }
.voice-box { width: min(100%, 420px); border: 1px solid var(--line2); background: var(--bg2); border-radius: 16px; padding: 20px 18px; display: grid;
  gap: 10px; justify-items: center; text-align: center; box-shadow: 0 16px 48px rgba(0, 0, 0, .6); }
.voice-dot { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line3); color: var(--muted); }
.voice-dot svg { width: 28px; height: 28px; }
.voice.live .voice-dot { color: #fff; border-color: var(--red); background: var(--red-soft); animation: micPulse 1.1s ease-in-out infinite; }
.voice-state { font-weight: 600; font-size: 1.05rem; }
.voice-text { min-height: 1.5em; color: var(--muted); font-size: 1rem; word-break: break-word; }
.voice .btn { width: 100%; }
.voice-bars { width: 100%; height: 64px; display: block; }
.keys4 { grid-template-columns: 1fr .8fr 1fr 1fr; }
.k.sleep { position: relative; }
.k.sleep small { position: absolute; left: 0; right: 0; bottom: 3px; text-align: center; font-size: .66rem; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.k.sleep.is-on svg { margin-top: -8px; }
.k.sleep.is-on { color: #fff; border-color: var(--line3); }
.sleep-grid { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sleep-grid .btn { width: 100%; }
.scan-video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; border: 1px solid var(--line2); background: #000; }
#scanBtn { width: 100%; margin-top: 8px; }
