/* StreamDeck Hub — web & phone companion. Same visual world as the TV app (deep navy, teal), built for touch and mouse. */
:root {
  --bg: #090d16; --bg-2: #0f1522; --surface: #141c2b; --surface-2: #1a2436; --surface-3: #22304a; --line: rgba(148, 163, 184, .14);
  --text: #eef2f7; --muted: #9aa8bd; --dim: #64748b; --accent: #2dd4bf; --accent-ink: #052e2b; --accent-2: #38bdf8; --star: #fbbf24; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24;
  --radius: 14px; --radius-s: 10px; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: 'Manrope', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; --display: 'Outfit', 'Manrope', 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.45; min-height: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
h1 { font-size: 28px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 13px; }
.hidden { display: none !important; }

/* ---- top bar ---- */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 18px; background: rgba(9, 13, 22, .96); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 8px; font-family: var(--display); font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); font-size: 13px; transform: translateY(4px); }
.brand-sub { color: var(--muted); font-weight: 500; font-size: 13px; }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tabs a .ico { font-size: 15px; }
.tabs a:hover { color: var(--text); background: var(--surface); }
.tabs a.active { color: var(--accent-ink); background: var(--accent); }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.status i { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); box-shadow: 0 0 0 3px rgba(100, 116, 139, .2); }
.status.ok i { background: var(--ok); box-shadow: 0 0 0 3px rgba(74, 222, 128, .2); }
.status.err i { background: var(--danger); box-shadow: 0 0 0 3px rgba(248, 113, 113, .2); }
@media (max-width: 760px) {
  .top { padding: 10px 14px; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: rgba(9, 13, 22, .92); backdrop-filter: blur(14px); border-top: 1px solid var(--line); justify-content: space-around; }
  .tabs a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 10.5px; border-radius: 10px; }
  .tabs a .ico { font-size: 18px; }
  .tabs a.active { background: transparent; color: var(--accent); }
  .status span { display: none; }
  .status { margin-left: auto; }
  .brand-sub { display: none; }
}

/* ---- layout ---- */
.view { max-width: 1180px; margin: 0 auto; padding: 22px 18px 96px; }
@media (min-width: 761px) { .view { padding-bottom: 40px; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 62ch; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.posters { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px 12px; }
@media (max-width: 480px) { .grid.posters { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 12px; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.flat { background: transparent; }
.card h3 { margin-bottom: 6px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat b { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---- buttons & inputs ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .12s, transform .08s; }
.btn:hover { background: var(--surface-3); } .btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; } .btn.primary:hover { background: #5eead4; }
.btn.danger { color: var(--danger); } .btn.danger:hover { background: rgba(248, 113, 113, .12); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); } .btn.ghost:hover { color: var(--text); background: var(--surface); }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input::placeholder { color: var(--dim); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
label.field .input { font-weight: 500; color: var(--text); }
.form { display: grid; gap: 14px; }
.form .two { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .form .two { grid-template-columns: 1fr; } }
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.seg button.active { background: var(--surface-3); color: var(--text); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.switch .t { font-weight: 600; } .switch .s { color: var(--muted); font-size: 13px; }
.switch i { flex: 0 0 44px; width: 44px; height: 26px; border-radius: 13px; background: var(--surface-3); position: relative; transition: background .15s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on i { background: var(--accent); } .switch.on i::after { transform: translateX(18px); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.chip.accent { background: rgba(45, 212, 191, .16); color: var(--accent); }
.chip.warn { background: rgba(251, 191, 36, .14); color: var(--warn); }
.chip.ok { background: rgba(74, 222, 128, .14); color: var(--ok); }
.chip.danger { background: rgba(248, 113, 113, .14); color: var(--danger); }
.chip.star { color: var(--star); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.badge-n { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 800; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 42px; margin-bottom: 8px; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input { width: auto; flex: 1 1 220px; }
.toolbar select.input { flex: 0 1 190px; }
.note { padding: 12px 14px; border-radius: 12px; background: rgba(56, 189, 248, .1); border: 1px solid rgba(56, 189, 248, .25); color: #c9e9fb; font-size: 14px; }
.note.warn { background: rgba(251, 191, 36, .1); border-color: rgba(251, 191, 36, .3); color: #fde68a; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--bg-2); padding: 2px 6px; border-radius: 6px; }

/* ---- playlists ---- */
.pl-card { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; }
.pl-ico { width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.pl-main { min-width: 0; } .pl-main h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-stats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pl-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) { .pl-card { grid-template-columns: 44px 1fr; } .pl-actions { grid-column: 1 / -1; justify-content: flex-start; } }

/* ---- library ---- */
.poster-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; cursor: pointer; transition: transform .12s, box-shadow .12s; display: flex; flex-direction: column; }
.poster-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.poster-card .img { position: relative; aspect-ratio: 2 / 3; background: var(--surface-2); overflow: hidden; }
.poster-card.live .img { aspect-ratio: 16 / 10; display: flex; align-items: center; justify-content: center; padding: 14px; }
.poster-card .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-card.live .img img { object-fit: contain; }
.poster-card .img .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--dim); }
.poster-card .img .n { position: absolute; top: 8px; right: 8px; }
.poster-card .img .r { position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, .7); color: var(--star); padding: 2px 7px; border-radius: 7px; font-size: 12px; font-weight: 700; }
.poster-card .meta { padding: 9px 10px 10px; }
.poster-card .t { font-weight: 700; font-size: 13.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.poster-card .s { color: var(--muted); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pager { display: flex; justify-content: center; gap: 8px; margin-top: 18px; align-items: center; color: var(--muted); font-size: 13px; }

/* ---- variants (item drawer) ---- */
.drawer { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end; background: rgba(3, 6, 12, .6); }
.drawer .panel { width: min(560px, 100%); height: 100%; overflow: auto; background: var(--bg-2); border-left: 1px solid var(--line); padding: 20px 20px 40px; animation: slide .18s ease; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 560px) { .drawer { align-items: flex-end; } .drawer .panel { height: 92%; border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; animation: rise .2s ease; } @keyframes rise { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } } }
.d-head { display: flex; gap: 14px; }
.d-head .img { width: 110px; flex: 0 0 110px; aspect-ratio: 2 / 3; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.d-head .img img { width: 100%; height: 100%; object-fit: cover; }
.d-head h2 { font-size: 22px; }
.variant { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.variant.primary { border-color: rgba(45, 212, 191, .5); }
.variant .name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.variant .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.variant .acts { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.variant .key { font-family: ui-monospace, monospace; font-size: 11px; color: var(--dim); }

/* ---- devices ---- */
.dev-card { display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center; cursor: pointer; }
.dev-ico { width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 26px; position: relative; }
.dev-ico i { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--surface); background: var(--dim); }
.dev-ico i.on { background: var(--ok); }
.dev-main h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-box { background: #fff; padding: 10px; border-radius: 14px; display: inline-block; line-height: 0; }
.pair-code { font-family: var(--display); font-size: 34px; font-weight: 700; letter-spacing: 6px; }

/* ---- remote ---- */
.remote { max-width: 380px; margin: 0 auto; display: grid; gap: 14px; }
.remote .rrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.remote .rrow.four { grid-template-columns: repeat(4, 1fr); }
.rbtn { min-height: 56px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 18px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; touch-action: manipulation; transition: transform .06s, background .1s; }
.rbtn:active { transform: scale(.94); background: var(--accent); color: var(--accent-ink); }
.rbtn.small { font-size: 12px; font-weight: 700; letter-spacing: .5px; min-height: 48px; }
.rbtn.c-red { background: #dc2626; border-color: transparent; } .rbtn.c-green { background: #16a34a; border-color: transparent; } .rbtn.c-yellow { background: #eab308; border-color: transparent; } .rbtn.c-blue { background: #2563eb; border-color: transparent; }
.rbtn.c-red, .rbtn.c-green, .rbtn.c-yellow, .rbtn.c-blue { min-height: 30px; border-radius: 15px; }
.dpad { display: grid; grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; gap: 6px; aspect-ratio: 1; }
.dpad .rbtn { min-height: 0; border-radius: 14px; }
.dpad .ok { border-radius: 50%; background: var(--surface-2); font-size: 20px; }
.now-playing { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.now-playing .p { width: 44px; height: 44px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; }

/* ---- modal ---- */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(3, 6, 12, .7); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(640px, 100%); max-height: 92vh; overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.modal h2 { margin-bottom: 14px; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* ---- toasts ---- */
.toasts { position: fixed; right: 14px; top: 64px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100% - 28px)); }
.toast { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); box-shadow: var(--shadow); font-size: 14px; animation: slide .18s ease; }
.toast.err { border-left-color: var(--danger); } .toast.ok { border-left-color: var(--ok); }
@media (max-width: 760px) { .toasts { top: auto; bottom: 84px; left: 14px; right: 14px; max-width: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
