:root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1f232c;
    --line: #2a2f3a;
    --text: #e8eaf0;
    --muted: #949bab;
    --accent: #4a9eff;
    --ok: #35c07a;
    --err: #ef5a5a;
    --radius: 14px;
}

* { box-sizing: border-box; }

/* display:flex/grid tanimlari hidden niteligini eziyor; onu geri aliyoruz. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    position: sticky; top: 0; z-index: 10;
    padding-top: max(14px, env(safe-area-inset-top));
}

.brand { color: var(--text); font-weight: 650; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

.wrap { max-width: 640px; margin: 0 auto; padding: 18px 16px 48px; }

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

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

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 14px;
}
.card-narrow { max-width: 380px; margin: 48px auto; }
.empty { text-align: center; color: var(--muted); }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

input {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    font-size: 16px;   /* iOS'ta odaklaninca zoom yapmamasi icin 16px'in altina inme */
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
    padding: 11px 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    font-size: 15px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #05122a; font-weight: 600; }
.btn-danger { background: transparent; border-color: var(--err); color: var(--err); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 8px 12px; font-size: 14px; }
.btn-block { width: 100%; margin-top: 18px; }

.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.controls .btn { padding: 12px 6px; font-size: 14px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-top: 12px; background: var(--surface-2); }
.alert-ok { background: rgba(53,192,122,.12); color: var(--ok); }
.alert-err { background: rgba(239,90,90,.12); color: var(--err); }

.device-card { display: flex; align-items: center; justify-content: space-between; color: var(--text); }
.device-main { display: flex; align-items: center; gap: 12px; }
.device-name { font-weight: 600; }
.chev { color: var(--muted); font-size: 22px; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px rgba(53,192,122,.18); }
.dot-off { background: #4a5162; }

.pill { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13px; color: var(--muted); white-space: nowrap; }
.pill-on { background: rgba(53,192,122,.14); color: var(--ok); }
.pill-off { background: var(--surface-2); color: var(--muted); }

.progress { height: 6px; background: var(--surface-2); border-radius: 999px; margin: 10px 0 6px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); width: 0; transition: width .4s linear; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* --- canli baglanti gostergesi --- */
.brand-dot { transition: background .3s; }
.brand-dot-off { background: #4a5162; }

/* --- oynatma --- */
.np-title {
    font-size: 15px; margin-bottom: 10px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.np-times { display: flex; justify-content: space-between; }

/* --- gecmis / favoriler --- */
.media-row {
    display: flex; align-items: stretch; gap: 8px;
    border-top: 1px solid var(--line);
}
.media-row:first-child { border-top: 0; }

.media-play {
    flex: 1; display: flex; flex-direction: column; gap: 2px;
    padding: 12px 2px; background: none; border: 0; color: var(--text);
    font-size: 15px; text-align: left; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.media-title {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 68vw;
}
.media-fav {
    background: none; border: 0; color: var(--muted);
    font-size: 22px; padding: 0 6px; cursor: pointer;
}
.media-fav.is-fav { color: #f5c542; }

/* --- PWA: ana ekrandan acildiginda alt guvenli alan --- */
@supports (padding: max(0px)) {
    .wrap { padding-bottom: max(48px, env(safe-area-inset-bottom)); }
}

/* --- APK indirme sayfasi --- */
.steps { margin: 0; padding-left: 20px; color: var(--text); font-size: 15px; }
.steps li { margin-bottom: 12px; }

.code-big {
    margin: 10px 0 2px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 19px;
    color: var(--accent);
    word-break: break-all;
    user-select: all;
}

/* ==========================================================================
   Panel kabugu: solda menu, sagda icerik
   Mobilde menu uste yatay seride doner.
   ========================================================================== */

.has-shell { background: var(--bg); }

.shell { display: flex; min-height: 100vh; }

.side {
    width: 220px; flex: none;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    padding: 18px 14px;
    padding-top: max(18px, env(safe-area-inset-top));
}

.side-brand {
    display: flex; align-items: center; gap: 9px;
    color: var(--text); font-weight: 650; font-size: 15px;
    letter-spacing: .02em; margin-bottom: 22px;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.side-link {
    padding: 10px 12px; border-radius: 9px;
    color: var(--muted); font-size: 15px;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.is-active { background: var(--surface-2); color: var(--text); font-weight: 600; }

.side-foot { padding-top: 12px; border-top: 1px solid var(--line); }

.main {
    flex: 1; min-width: 0;
    padding: 18px 22px 28px;
    display: flex; flex-direction: column;
}

.main-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 16px;
}
.main-head h1 { font-size: 20px; margin: 0; }

.tv-picker { display: flex; align-items: center; gap: 8px; }
.tv-picker select {
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--line); border-radius: 9px;
    padding: 9px 12px; font-size: 15px; max-width: 220px;
}

/* --- kumanda ekrani --- */

.remote { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }

.urlbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.urlbar form { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.urlbar input { margin: 0; }
.urlbar-tools { display: flex; gap: 8px; }

.screen-wrap { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }

.screen {
    position: relative;
    background: #000;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    cursor: crosshair;
    outline: none;
}
.screen:focus { border-color: var(--accent); }

.screen img {
    width: 100%; height: 100%;
    object-fit: contain;
    display: block;
    -webkit-user-drag: none; user-select: none;
}

.screen-empty {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; text-align: center; padding: 20px;
}
.screen-empty .big { font-size: 19px; margin: 0; }
.screen-empty p { margin: 0; }

.screen-badge {
    position: absolute; top: 10px; right: 12px;
    background: rgba(239,90,90,.16); color: #ef5a5a;
    padding: 4px 10px; border-radius: 999px;
    font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
}

/* tiklanan noktayi kisa sure gosteren isaret */
.tap-dot {
    position: absolute; width: 18px; height: 18px;
    margin: -9px 0 0 -9px;
    border: 2px solid var(--accent); border-radius: 50%;
    pointer-events: none;
    animation: tap-fade .5s ease-out forwards;
}
@keyframes tap-fade {
    from { transform: scale(.4); opacity: 1; }
    to   { transform: scale(1.6); opacity: 0; }
}

.playbar {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: 14px 16px;
}
.np { font-size: 15px; margin-bottom: 8px;
      overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.playbar .controls { grid-template-columns: repeat(8, 1fr); }

@media (max-width: 900px) {
    .shell { flex-direction: column; }

    .side {
        width: auto; flex-direction: row; align-items: center; gap: 14px;
        border-right: 0; border-bottom: 1px solid var(--line);
        padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top));
        overflow-x: auto;
    }
    .side-brand { margin-bottom: 0; white-space: nowrap; }
    .side-nav { flex-direction: row; gap: 4px; }
    .side-link { white-space: nowrap; padding: 8px 10px; font-size: 14px; }
    .side-foot { padding-top: 0; border-top: 0; }

    .main { padding: 14px 14px 26px; }
    .main-head { flex-wrap: wrap; }
    .playbar .controls { grid-template-columns: repeat(4, 1fr); }
    .screen { cursor: pointer; }
}
