:root {
    color-scheme: dark;
    --bg: #0f1420;
    --card: #182031;
    --card-2: #1e2940;
    --border: #2c3a55;
    --text: #e7edf8;
    --muted: #93a1bb;
    --accent: #5b9cff;
    --ok: #43d18a;
    --warn: #ffbf47;
    --err: #ff6b6b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(1200px 600px at 50% -20%, #1d2b47 0%, var(--bg) 60%);
    color: var(--text);
    font: 15px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
}

.wrap {
    width: min(920px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0 32px;
}

.header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

h1 { margin: 0; font-size: 30px; letter-spacing: -0.5px; }
h1 span { color: var(--accent); }
.header p { margin: 6px 0 0; color: var(--muted); }

.badge {
    flex: none;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    margin-bottom: 18px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

.input-row { display: flex; gap: 10px; flex-wrap: wrap; }

.suggest-wrap { position: relative; flex: 1 1 320px; min-width: 0; }
.suggest-wrap input[type="text"] { width: 100%; }

.suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 390px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .5);
}
.suggestion-item {
    display: flex;
    gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
}
.suggestion-item:hover,
.suggestion-item.active { background: var(--card-2); }
.suggestion-thumb {
    width: 44px;
    height: 66px;
    object-fit: cover;
    border-radius: 6px;
    background: #000;
    flex: none;
}
.suggestion-body { min-width: 0; }
.suggestion-title {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.suggestion-meta {
    color: var(--accent);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.suggestion-desc {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.suggestion-empty {
    padding: 12px;
    color: var(--muted);
    font-size: 13px;
}
.suggestion-footer {
    padding: 8px 12px;
    color: var(--muted);
    font-size: 11px;
    border-top: 1px solid var(--border);
}

input[type="text"] {
    flex: 1 1 320px;
    min-width: 0;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #111827;
    color: var(--text);
    font: inherit;
}
input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Widoczny fokus jest wazny przy sterowaniu telewizorem (pilot). */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Dotykowe cele min. 44px. */
.btn { min-height: 44px; }

.btn {
    border: 0;
    border-radius: 10px;
    padding: 12px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #071021; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: .55; cursor: wait; }
.btn-ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #273550; }

.hint { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .93em; }

.status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: var(--muted);
}
.spinner {
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.pill {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.pill.ok { color: #06251a; background: var(--ok); }
.pill.unsupported, .pill.failed, .pill.captcha { color: #2a1d00; background: var(--warn); }
.pill.error { color: #2a0808; background: var(--err); }
.meta { color: var(--muted); font-size: 13px; }

.kv {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 8px 14px;
    margin-bottom: 16px;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.captcha-box {
    margin: 8px 0 4px;
    padding: 14px 16px;
    border: 1px solid var(--warn);
    border-radius: 10px;
    background: rgba(255, 191, 71, .08);
}
.captcha-box p { margin: 0 0 12px; }
.captcha-box .clip-status {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 191, 71, .14);
    color: var(--warn);
    font-weight: 700;
    min-height: 22px;
}
.captcha-box .btn + .btn { margin-left: 8px; }

.stream-box { margin-top: 10px; }
.stream-box input { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

details {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
summary { cursor: pointer; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
    padding: 3px 9px;
    border-radius: 6px;
    background: var(--card-2);
    border: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
}
.sub-list { margin: 10px 0 0; padding-left: 18px; }
.sub-list a { color: var(--accent); }

.error-box { border-color: rgba(255, 107, 107, .45); }
.error-box strong { color: var(--err); }

.footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 26px;
    color: var(--muted);
    font-size: 12px;
}

/* ------------------------------------------------------------------ */
/* Telefony i male tablety                                             */
/* ------------------------------------------------------------------ */
@media (max-width: 700px) {
    .wrap {
        width: 100%;
        padding: 16px 12px 24px;
    }
    .header {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 18px;
    }
    h1 { font-size: 25px; }
    .card { padding: 16px; border-radius: 12px; }
    .input-row { flex-direction: column; align-items: stretch; }
    .suggest-wrap { flex: 1 1 auto; width: 100%; }
    /* 16px zapobiega automatycznemu powiekszaniu pola w iOS. */
    input[type="text"] { width: 100%; font-size: 16px; }
    .input-row .btn { width: 100%; }
    .suggestions { max-height: min(52vh, 340px); }
    .suggestion-item { padding: 9px 10px; }
    .suggestion-thumb { width: 38px; height: 56px; }
    .suggestion-title, .suggestion-meta { font-size: 13px; }
    .kv { grid-template-columns: 1fr; gap: 2px; }
    .kv dd { margin-bottom: 8px; }
    .actions .btn { flex: 1 1 140px; }
    .footer { flex-direction: column; gap: 4px; }
    .fs-exit { font-size: 16px; padding: 12px 16px; }
}

/* Telefon w poziomie, gdy nie jestesmy jeszcze w pelnym ekranie. */
@media (max-height: 520px) and (orientation: landscape) {
    .wrap { padding: 6px 0 12px; }
    .header { display: none; }
    .card { padding: 8px; border: 0; box-shadow: none; background: transparent; }
    .hint { display: none; }
}

/* ------------------------------------------------------------------ */
/* Telewizory i duze ekrany                                            */
/* ------------------------------------------------------------------ */
@media (min-width: 1600px) {
    .wrap { width: min(1400px, calc(100% - 64px)); padding-top: 64px; }
    body { font-size: 18px; }
    h1 { font-size: 42px; }
    .header p { font-size: 20px; }
    .card { padding: 30px; border-radius: 20px; }
    .btn { font-size: 19px; padding: 16px 26px; }
    input[type="text"] { font-size: 19px; padding: 16px 18px; }
    .suggestions { max-height: 62vh; }
    .suggestion-item { padding: 14px 16px; }
    .suggestion-thumb { width: 60px; height: 90px; }
    .suggestion-title { font-size: 18px; }
    .suggestion-meta, .suggestion-desc { font-size: 15px; }
    .footer { font-size: 15px; }
}
