:root {
  color-scheme: dark;
  --bg: #0b0f12;
  --surface: #12181c;
  --surface-2: #192126;
  --surface-3: #222c32;
  --line: #ffffff12;
  --line-strong: #ffffff22;
  --ink: #eef3f0;
  --muted: #8b989e;
  --faint: #5f6d73;
  --accent: #b9f2a9;
  --accent-ink: #13230f;
  --accent-soft: #b9f2a914;
  --red: #f59e97;
  --red-soft: #f59e9714;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --gutter: 14px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(120% 60% at 50% -10%, #17241f 0, transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 15px;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button, a, input, label { -webkit-tap-highlight-color: transparent; }
button {
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  padding: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color .15s, border-color .15s, color .15s, transform .12s;
}
button:active:not(:disabled) { transform: scale(.94); }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg {
  width: 20px; height: 20px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* ---------- App shell (phone first) ---------- */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 8px) var(--gutter) 8px;
  min-height: 56px;
}
.brand { flex: none; display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: -.5px; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.brand-mark svg { width: 18px; height: 18px; stroke-width: 2; }
.brand-name span { color: var(--muted); font-weight: 400; }

/* TV switcher: the main control of the top bar */
.tv-switch {
  flex: 1; min-width: 0; max-width: 340px;
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 12px 0 6px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  text-align: left;
}
.tv-switch:hover { background: var(--surface-2); }
.tv-switch:active:not(:disabled) { transform: scale(.98); }
.tv-switch-icon { position: relative; width: 34px; height: 34px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: #c9d4d7; }
.tv-switch-icon svg { width: 18px; height: 18px; }
.tv-switch-icon .status-dot, .tv-card-icon .status-dot { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border: 2px solid var(--surface); }
.tv-switch-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.tv-switch-name { font-weight: 650; font-size: 15px; letter-spacing: -.2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-switch-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-switch .chevron { width: 18px; height: 18px; color: var(--muted); }
.tv-switch.online .tv-switch-sub { color: var(--accent); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.tv-switch.online .status-dot, .tv-card.online .status-dot { background: var(--accent); }
.tv-switch.online .status-dot { box-shadow: 0 0 0 3px #b9f2a922; animation: pulse 2.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px #b9f2a900; } }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.brand-name { display: none; }
.icon-button {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); color: #b7c3c8;
}
.icon-button:hover { background: #ffffff0a; color: #fff; }
.power-button {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--red-soft); border-color: #f59e9733; color: var(--red);
}
.power-button:hover { background: #f59e9726; }
.power-button.on { background: var(--accent-soft); border-color: #b9f2a933; color: var(--accent); }
.desktop-only { display: none; }

.layout { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Viewer ---------- */
.stage { flex: none; padding: 0 var(--gutter); }
.viewer {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #040606;
  border: 1px solid var(--line-strong);
  box-shadow: 0 18px 50px #0006;
}
.screen-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at center, #16211d 0%, #050807 75%);
}
#screen { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; transition: opacity .3s; }
#screen.offline { opacity: .15; }
.screen-empty { position: relative; z-index: 1; text-align: center; padding: 12px 18px; display: flex; flex-direction: column; align-items: center; }
.empty-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #b9f2a912; border: 1px solid #b9f2a926; color: var(--accent); margin-bottom: 10px; }
.empty-icon svg { width: 22px; height: 22px; }
.screen-empty h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.3px; }
.screen-empty p { margin: 4px 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.45; max-width: 280px; }

.viewer-overlay {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 8px 22px 12px;
  background: linear-gradient(#000a, #0000);
  pointer-events: none;
}
.viewer-overlay > * { pointer-events: auto; }
.overlay-spacer { flex: 1; }
.live-badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px; border-radius: 99px;
  background: #0009; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 10.5px; font-weight: 700; letter-spacing: .8px; color: #a9b4b8;
}
.live-badge > span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.live-badge.active { color: var(--accent); }
.live-badge.active > span { background: #ff5b55; box-shadow: 0 0 6px #ff5b55; }
.overlay-tv {
  display: none; align-items: center; gap: 6px; min-width: 0;
  height: 30px; padding: 0 8px 0 10px; border-radius: 99px;
  background: #0009; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  font-size: 12.5px; font-weight: 600; color: #eef3f0;
}
.overlay-tv span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.overlay-tv svg { width: 15px; height: 15px; }
.overlay-tv .chevron { color: #a9b4b8; }
.viewer:fullscreen .overlay-tv, .viewer.pseudo-full .overlay-tv { display: inline-flex; }
.technical { font-size: 10.5px; color: #c8d2d4b0; font-variant-numeric: tabular-nums; white-space: nowrap; text-shadow: 0 1px 2px #000; }
.overlay-button {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: #0008; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: #e6ecea;
}
.overlay-button svg { width: 17px; height: 17px; }
.overlay-button:hover { background: #000c; }

.stage-note { display: none; margin: 10px 4px 0; font-size: 12px; color: var(--faint); }
.dot-sep { margin: 0 6px; }

/* Fullscreen (native and iOS fallback) */
.viewer:fullscreen, .viewer.pseudo-full { border-radius: 0; border: 0; background: #000; display: flex; align-items: center; justify-content: center; }
.viewer.pseudo-full { position: fixed; inset: 0; z-index: 40; padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); }
.viewer:fullscreen .screen-stage, .viewer.pseudo-full .screen-stage { width: 100%; height: 100%; aspect-ratio: auto; background: #000; }
.viewer:fullscreen .viewer-overlay, .viewer.pseudo-full .viewer-overlay { padding: 14px 14px 30px; }

/* ---------- Deck / tabs ---------- */
.deck { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panels { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.panel { min-height: 100%; padding: 14px var(--gutter) 18px; display: flex; flex-direction: column; }

.tabs {
  order: 2; flex: none;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: #0d1215f2;
  border-top: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; border-radius: 12px;
  color: #7f8d93; font-size: 11px; font-weight: 500;
}
.tabs button svg { width: 22px; height: 22px; }
.tabs [aria-selected=true] { color: var(--accent); }
.tabs [aria-selected=true] svg { background: var(--accent-soft); border-radius: 99px; width: 46px; padding: 0 12px; box-sizing: content-box; margin: 0 -12px; }
.tabs button:active { transform: none; }

/* ---------- Generic buttons ---------- */
.primary, .secondary, .danger, .danger-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 13px;
  font-size: 14px; font-weight: 600;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.primary:hover { background: #cdfbbf; }
.primary.small { min-height: 38px; font-size: 13px; padding: 0 14px; border-radius: 11px; }
.primary.small svg { width: 16px; height: 16px; }
.secondary { background: var(--surface-2); border-color: var(--line); color: #d8e1e2; }
.secondary:hover { background: var(--surface-3); }
.danger { background: #f0a39c; color: #3a1512; }
.danger-outline { background: var(--red-soft); border-color: #f59e972a; color: var(--red); }
.full-width { width: 100%; }
.subtle { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.3px; }

/* ---------- Controle ---------- */
.panel-controls { justify-content: space-evenly; gap: 12px; }
.nav-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pill-key {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  height: 46px; border-radius: 14px;
  background: var(--surface-2); border-color: var(--line);
  font-size: 13px; font-weight: 500; color: #cfd9db;
}
.pill-key:hover { background: var(--surface-3); }
.pill-key svg { width: 18px; height: 18px; }
.accent-key { color: var(--accent); background: var(--accent-soft); border-color: #b9f2a926; }

.dpad-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
.dpad {
  --size: clamp(148px, min(100vw - 170px, 100dvh - 281px - (100vw - 28px) * .5625), 250px);
  width: var(--size); height: var(--size); flex: none;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #2a363c, #182025);
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 #ffffff10, 0 10px 30px #0005;
}
.dpad button { display: grid; place-items: center; color: #b2c1c6; border: 0; }
.dpad button:active { transform: none; background: #ffffff14; color: #fff; }
.dpad button:hover { color: #fff; }
.dpad svg { width: 28px; height: 28px; stroke-width: 2.2; }
.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 .dpad-center {
  grid-area: 2 / 2; margin: 4px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  font-size: 17px; font-weight: 700; letter-spacing: .5px;
  box-shadow: 0 6px 18px #0006, inset 0 -2px 0 #0002;
}
.dpad .dpad-center:active { transform: scale(.94); background: #d4fdc7; color: var(--accent-ink); }

.rocker {
  width: 56px; flex: none; display: flex; flex-direction: column; align-items: center;
  padding: 4px; border-radius: 30px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.rocker button { width: 46px; height: 50px; border-radius: 24px; display: grid; place-items: center; font-size: 26px; font-weight: 300; }
.rocker button:active { transform: none; background: #ffffff14; }
.rocker > span { font-size: 10.5px; font-weight: 600; letter-spacing: .6px; color: var(--faint); padding: 4px 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
#volumeLabel { color: #a4b1b5; }

.media-controls { display: flex; justify-content: space-between; gap: 4px; padding: 4px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.media-controls button { flex: 1; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #c0ccd0; }
.media-controls button:hover { background: #ffffff0a; }
.media-controls svg { width: 18px; height: 18px; }
.media-controls .mute-key { flex: 1.3; background: var(--surface-2); margin-right: 4px; }
.media-controls .mute-key svg { width: 20px; height: 20px; }
.mute-key[aria-pressed=true] { background: var(--red-soft); color: var(--red); }

/* ---------- Touchpad ---------- */
.panel-touch { gap: 10px; }
#touchpad {
  flex: 1; min-height: 180px;
  position: relative; display: grid; place-items: center;
  border-radius: 20px;
  border: 1px solid #b9f2a922;
  background:
    radial-gradient(circle, #ffffff10 1px, transparent 1.5px) 0 0 / 22px 22px,
    radial-gradient(circle at 50% 40%, #1f3129, #111a17);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  cursor: crosshair; overflow: hidden;
}
.touch-ring { width: 54px; height: 54px; border-radius: 50%; border: 1.5px solid #b9f2a955; box-shadow: 0 0 30px #b9f2a920; transition: transform .15s, background .15s; }
#touchpad.active .touch-ring { transform: scale(.8); background: #b9f2a922; }
.touch-label { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 12px; color: #7f9b8a; }
.touch-actions { display: grid; grid-template-columns: 1fr auto auto 1.2fr; gap: 8px; }
.icon-only { width: 52px; padding: 0; }

/* ---------- Apps ---------- */
.panel-apps { gap: 0; }
.search {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 12px; margin-bottom: 12px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  color: var(--muted);
}
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; }
.search:focus-within { border-color: #b9f2a955; }
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.app-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-width: 0; padding: 14px 6px 11px;
  border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line);
}
.app-card:hover { background: var(--surface-3); border-color: #b9f2a933; }
.app-logo {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 800; letter-spacing: -.5px;
  background: #ffffff0a; color: var(--accent);
}
.app-logo.netflix { background: #141414; color: #e50914; font-size: 26px; }
.app-logo.youtube { background: #ff0033; color: #fff; }
.app-logo.youtube svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.app-logo.prime { background: #0f1c2e; color: #49b6ff; font-size: 13px; }
.app-logo.disney { background: #0b1a4a; color: #cfd8ff; font-size: 12px; }
.app-logo.globo { background: #fb0234; color: #fff; font-size: 13px; }
.app-logo.browser { background: #1d3a5c; color: #9fd0ff; }
.app-name { font-size: 12px; color: #c3ced1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inputs-head { margin-top: 22px; }
.input-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.input-list.subtle { display: block; }
.input-chip {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  height: 46px; padding: 0 12px; border-radius: 13px;
  background: var(--surface-2); border-color: var(--line);
  font-size: 13px; color: #c8d3d6; white-space: nowrap;
}
.input-chip:hover { border-color: #b9f2a944; }
.input-chip.selected { background: var(--accent-soft); border-color: #b9f2a955; color: var(--accent); }
.plug-dot { width: 7px; height: 7px; border-radius: 50%; background: #7fc070; }

/* ---------- Teclado ---------- */
.panel-text { gap: 0; }
#textForm { display: flex; gap: 8px; margin: 14px 0 10px; }
#textForm input {
  flex: 1; min-width: 0; height: 50px; padding: 0 14px;
  border-radius: 13px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 16px; color: var(--ink);
}
#textForm input:focus { outline: 0; border-color: #b9f2a977; }
#textForm .primary { min-height: 50px; }
input::placeholder { color: #66757b; }
.text-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ---------- Mais ---------- */
.panel-more { gap: 14px; }
.volume-slider {
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.volume-slider input { flex: 1; accent-color: var(--accent); height: 28px; cursor: pointer; }
.volume-slider output { min-width: 26px; text-align: right; font-size: 13px; color: #c3ced1; font-variant-numeric: tabular-nums; }
.utility-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.utility-grid .secondary { justify-content: flex-start; padding: 0 14px; font-weight: 500; font-size: 13.5px; }
.utility-grid svg { width: 18px; height: 18px; color: var(--accent); }
.number-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.number-pad button { height: 52px; border-radius: 14px; background: var(--surface-2); border-color: var(--line); font-size: 21px; font-weight: 500; color: #dbe4e4; }
.number-pad button:hover { background: var(--surface-3); }
.number-pad button.small-number { font-size: 13px; color: var(--muted); }
.color-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.color-keys button { height: 34px; border-radius: 11px; }
.color-keys button:nth-child(1) { background: #e0646a; }
.color-keys button:nth-child(2) { background: #6fb784; }
.color-keys button:nth-child(3) { background: #dcb85c; }
.color-keys button:nth-child(4) { background: #6895d0; }

/* ---------- Toast & dialogs ---------- */
.toast {
  position: fixed; z-index: 60;
  left: 50%; transform: translateX(-50%);
  bottom: calc(84px + var(--safe-bottom));
  max-width: calc(100vw - 32px); width: max-content;
  padding: 12px 18px; border-radius: 14px;
  background: #e1f8da; color: #172a14;
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 10px 40px #0007;
  animation: toast-in .2s ease-out;
}
.toast.error { background: #ffd9d5; color: #521f1b; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

dialog {
  width: min(420px, calc(100% - 28px));
  padding: 24px; border-radius: 22px;
  background: #161e23; color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: 0 40px 120px #000a;
}
dialog::backdrop { background: #04080acc; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; letter-spacing: -.4px; }
dialog p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--muted); }
.dialog-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); margin-bottom: 16px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.dialog-actions > * { flex: 1; }
.dialog-actions.stacked { flex-direction: column; }
.shortcuts { margin: 18px 0 22px; }
.shortcuts > div { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.shortcuts dt { font-family: ui-monospace, monospace; color: var(--accent); }
.shortcuts dd { margin: 0; color: #b5c2c6; }
.tv-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.tv-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 72px; padding: 12px 14px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid var(--line); text-align: left;
}
.tv-card:hover { background: var(--surface-3); }
.tv-card:active:not(:disabled) { transform: scale(.98); }
.tv-card.current { border-color: #b9f2a966; background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface-2); }
.tv-card-icon { position: relative; width: 46px; height: 46px; flex: none; border-radius: 13px; display: grid; place-items: center; background: var(--surface-3); color: #c9d4d7; }
.tv-card.current .tv-card-icon { background: var(--accent); color: var(--accent-ink); }
.tv-card-icon svg { width: 24px; height: 24px; }
.tv-card-icon .status-dot { border-color: var(--surface-2); width: 13px; height: 13px; }
.tv-card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.tv-card-text strong { font-size: 16.5px; font-weight: 650; letter-spacing: -.3px; }
.tv-card-text span { font-size: 12.5px; color: var(--muted); }
.tv-card.online .tv-card-text span { color: #a8d99b; }
.tv-card-check { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); }
.tv-card-check svg { width: 16px; height: 16px; stroke-width: 2.6; }
.tv-hint { margin-top: 14px !important; font-size: 12.5px !important; }
.channel-list { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; margin-top: 14px; }
.channel-list button { text-align: left; padding: 14px; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.channel-list button:hover { background: var(--surface-3); }

/* ---------- Login & acesso ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #b5c2c6; }
.field input, .field select {
  height: 50px; padding: 0 14px; border-radius: 13px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px; width: 100%;
}
.field input:focus, .field select:focus { outline: 0; border-color: #b9f2a977; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-error { margin: 0; padding: 11px 14px; border-radius: 12px; background: var(--red-soft); border: 1px solid #f59e972a; color: var(--red); font-size: 13.5px; }
.login { min-height: 100%; display: grid; place-items: center; padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px); }
.login-card { width: min(400px, 100%); }
.login-card .brand { margin-bottom: 28px; }
.login-card .brand-name { display: inline; }
.login-card h1 { margin: 0 0 6px; font-size: 26px; font-weight: 650; letter-spacing: -.7px; }
.login-card > .subtle { margin-bottom: 24px; }
.login-card .primary { margin-top: 6px; min-height: 50px; font-size: 15px; }
.account-head { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); margin-top: 6px; }
.avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); border: 1px solid #b9f2a933; color: var(--accent); font-weight: 650; text-transform: uppercase; }
.account-head div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.account-head strong, .user-row strong { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-head span, .user-row span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 99px; font-size: 10.5px; font-weight: 650; letter-spacing: .3px; vertical-align: 2px; background: var(--accent-soft); color: var(--accent); }
.sheet .dialog-actions { margin-top: 16px; }
.user-list { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 6px; max-height: 42vh; overflow: auto; }
.user-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); text-align: left; }
.user-row:hover { background: var(--surface-3); }
.user-row .avatar { width: 36px; height: 36px; font-size: 14px; }
.user-row div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-row > svg { color: var(--muted); transform: rotate(-90deg); }
.section-title { margin: 20px 0 10px; font-size: 13px; font-weight: 600; color: #b5c2c6; text-transform: uppercase; letter-spacing: .6px; }

@media (max-width: 899px) {
  /* Sheets slide up from the bottom on phones */
  dialog { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 24px 24px 0 0; border-width: 1px 0 0; padding-bottom: calc(24px + var(--safe-bottom)); animation: sheet-in .22s ease-out; }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
}

/* Small phones: tighten */
@media (max-width: 360px) {
  :root { --gutter: 10px; }
  .pill-key span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .tv-switch { height: 42px; gap: 8px; }
  .tv-switch-icon { width: 30px; height: 30px; }
  .empty-icon { display: none; }
  .tabs button { font-size: 10px; }
}

/* Short screens in portrait: give space to the remote */
@media (max-height: 640px) and (orientation: portrait) {
  .topbar { min-height: 48px; padding-top: calc(var(--safe-top) + 4px); padding-bottom: 4px; }
  .tv-switch { height: 40px; }
  .tv-switch-icon { width: 30px; height: 30px; }
  .tabs button { min-height: 46px; }
  .tabs button span { display: none; }
  .panel-controls { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .rocker button { height: 40px; }
}

/* ---------- Phone in landscape ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  .app { height: 100dvh; }
  .topbar { display: none; }
  .overlay-tv { display: inline-flex; }
  .layout { flex-direction: row; padding-top: var(--safe-top); }
  .stage { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 10px; }
  .viewer { width: 100%; max-height: 100%; aspect-ratio: 16 / 9; max-width: calc((100dvh - 20px) * 16 / 9); }
  .deck { flex: none; width: min(46vw, 360px); border-left: 1px solid var(--line); background: #0d1215; }
  .tabs { order: 0; border-top: 0; border-bottom: 1px solid var(--line); padding: 4px; }
  .tabs button { min-height: 40px; }
  .tabs button span { display: none; }
  .panel { padding: 10px 12px calc(10px + var(--safe-bottom)); }
  .panel-controls { gap: 8px; }
  .dpad { --size: clamp(120px, min(100dvh - 190px, 46vw - 150px), 210px); }
  .rocker { width: 48px; }
  .rocker button { width: 40px; height: 40px; font-size: 22px; }
  .pill-key, .media-controls button { height: 38px; }
  .toast { bottom: 16px; }
}

/* ---------- Tablet & desktop ---------- */
@media (min-width: 900px) and (min-height: 561px) {
  :root { --gutter: 28px; }
  body { font-size: 14px; }
  .app { height: auto; min-height: 100vh; max-width: 1480px; margin: 0 auto; }
  .topbar { min-height: 76px; padding-top: 16px; padding-bottom: 16px; }
  .brand { font-size: 21px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 12px; }
  .brand-name { display: inline; }
  .tv-switch { margin-left: 18px; height: 50px; max-width: 360px; }
  .desktop-only { display: inline-grid; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; padding: 0 var(--gutter) 32px; }
  .stage { padding: 0; position: sticky; top: 16px; }
  .viewer { border-radius: 20px; }
  .stage-note { display: block; }
  .viewer-overlay { padding: 14px 14px 30px 18px; }
  .overlay-button { width: 38px; height: 38px; }
  .live-badge { height: 28px; padding: 0 12px; font-size: 11px; }
  .technical { font-size: 11.5px; margin-right: 4px; }
  .screen-empty h2 { font-size: 20px; }
  .screen-empty p { font-size: 13.5px; }
  .empty-icon { width: 54px; height: 54px; border-radius: 16px; margin-bottom: 16px; }
  .empty-icon svg { width: 28px; height: 28px; }
  .primary.small { min-height: 44px; padding: 0 18px; }

  .deck { position: sticky; top: 16px; max-height: calc(100vh - 32px); border-radius: 22px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
  .tabs { order: 0; background: transparent; border-top: 0; border-bottom: 1px solid var(--line); padding: 8px; backdrop-filter: none; }
  .tabs button { min-height: 58px; font-size: 11.5px; }
  .tabs button:hover { color: #c7d2d5; background: #ffffff06; }
  .panel { min-height: 0; padding: 20px; }
  .panel-controls { gap: 20px; }
  .dpad { --size: 236px; }
  .apps-grid { grid-template-columns: repeat(3, 1fr); }
  .toast { bottom: 28px; }
}
@media (min-width: 1280px) and (min-height: 561px) {
  .layout { grid-template-columns: minmax(0, 1fr) 400px; gap: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Mostrar senha no login */
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 52px; }
.reveal { position: absolute; top: 3px; right: 3px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; }
.reveal svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.reveal[aria-pressed="true"] { color: var(--accent); }
.reveal:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Instalar como app */
.install-hero { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); margin-top: 6px; }
.install-hero img { width: 56px; height: 56px; border-radius: 14px; flex: none; }
.install-hero p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--ink); }
.install-steps { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.install-steps li { display: flex; gap: 12px; align-items: flex-start; }
.install-steps li > span { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; }
.install-steps p { margin: 3px 0 0; font-size: 14px; line-height: 1.45; color: var(--muted); }
.install-steps strong { color: var(--ink); font-weight: 600; }
.inline-icon { width: 17px; height: 17px; vertical-align: -3px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* TV desligada ou sem conexão: controles esmaecidos, aviso no topo do controle */
.offline-note { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 9px; margin: 10px var(--gutter) 0; padding: 9px 14px; border-radius: 12px; background: var(--red-soft); border: 1px solid #f59e9733; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.offline-note[hidden] { display: none; }
.offline-note .status-dot { flex: none; background: var(--red); }
.offline-note p { margin: 0; font-size: 12.5px; line-height: 1.3; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offline-note strong { color: var(--ink); font-weight: 600; }
.tv-offline .panel :is(button, input, select, textarea, .touchpad, #touchpad):not([data-power]) { opacity: .32; filter: grayscale(1); cursor: not-allowed; transition: opacity .2s; }
.tv-offline .panel .subtle, .tv-offline .panel h2 { opacity: .55; }
