:root {
  --bg: #141414; --surface: #1f1f23; --surface2: #2a2a30; --text: #f2f2f2; --muted: #a3a3ab;
  --red: #e50914; --red-press: #b20710;
  --gutter: max(16px, env(safe-area-inset-left)); --gutter-r: max(16px, env(safe-area-inset-right));
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.top { padding: calc(env(safe-area-inset-top) + 14px) var(--gutter-r) 6px var(--gutter); }
.logo { color: var(--red); font-weight: 900; letter-spacing: .06em; font-size: 24px; }
.logo span { color: var(--text); font-weight: 600; letter-spacing: 0; font-size: 18px; margin-left: 4px; }

main { padding: 8px var(--gutter-r) calc(env(safe-area-inset-bottom) + 24px) var(--gutter); max-width: 560px; margin: 0 auto; }
h2 { font-size: 15px; color: var(--muted); font-weight: 600; margin: 14px 0 8px; }

.tvs { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tv { display: flex; align-items: center; background: var(--surface); border-radius: 14px; padding: 4px 4px 4px 0; }
.tv-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; background: none; border: 0; padding: 14px 8px 14px 16px; text-align: left; }
.tv-main:active { opacity: .7; }
.tv-icon { width: 42px; height: 42px; flex: none; border-radius: 10px; background: var(--surface2); display: grid; place-items: center; color: var(--red); }
.tv-icon svg { width: 24px; height: 24px; }
.tv-text { min-width: 0; display: flex; flex-direction: column; }
.tv-name { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-addr { color: var(--muted); font-size: 13px; }
.icon-btn { width: 44px; height: 44px; flex: none; border: 0; border-radius: 10px; background: none; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: var(--surface2); }
.icon-btn svg { width: 20px; height: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 0; border-radius: 12px;
  padding: 12px 20px; font-weight: 700; background: var(--surface2); color: var(--text);
}
.btn:active { filter: brightness(.85); }
.btn.primary { background: var(--red); color: #fff; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; }
.btn svg { width: 24px; height: 24px; }

.help, .note { color: var(--muted); font-size: 14px; }
.help { margin: 12px 2px 0; }
.help b { color: var(--text); }
.note { margin-top: 28px; text-align: center; font-size: 13px; }
.msg { min-height: 1.4em; margin: 14px 2px 0; color: #ffb4b8; font-size: 14px; }
.msg:empty { margin: 0; min-height: 0; }

.manual { margin-top: 18px; background: var(--surface); border-radius: 12px; padding: 0 14px; }
.manual summary { padding: 14px 0; font-weight: 600; cursor: pointer; }
.manual form { display: flex; gap: 8px; padding-bottom: 14px; }
.manual input {
  flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid #3a3a42; border-radius: 10px;
  padding: 11px 12px; font: inherit; font-size: 16px; /* 16px keeps iOS from zooming in */
}

.scanner { position: fixed; inset: 0; z-index: 10; background: #000; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame {
  position: absolute; left: 50%; top: 45%; width: min(70vw, 70vh, 320px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45);
}
.scan-hint {
  position: absolute; left: var(--gutter); right: var(--gutter-r); top: calc(env(safe-area-inset-top) + 24px);
  text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 4px #000; margin: 0;
}
.cancel { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 28px); min-width: 140px; background: rgba(40,40,46,.9); }
