/* TSEYE web izleyici — modern NVR arayüzü.
   Stil: OLED koyu zemin + yumuşak renk ışıması, video üstünde yüzen buzlu cam kontroller,
   katmanlı kartlar. Mavi-indigo vurgu = seçim; yeşil = canlı; kehribar = kayıt. */
:root {
  color-scheme: dark;
  --bg: #07090d;
  --rail: #0b0e14;
  --surface: #11161f;
  --surface-2: #171e2a;
  --surface-3: #212a39;
  --line: rgb(255 255 255 / .07);
  --line-2: rgb(255 255 255 / .12);
  --line-3: rgb(255 255 255 / .2);
  --text: #f4f6fb;
  --text-2: #c3cbd8;
  --muted: #8a95a8;
  --primary: #7c93ff;
  --primary-2: #9aabff;
  --primary-soft: rgb(124 147 255 / .16);
  --primary-grad: linear-gradient(180deg, #8ea2ff, #6a83fb);
  --on-primary: #0a0f24;
  --live: #34d399;
  --live-soft: rgb(52 211 153 / .15);
  --rec: #fbbf24;
  --rec-soft: rgb(251 191 36 / .16);
  --danger: #fb7185;
  --danger-soft: rgb(251 113 133 / .14);
  --ring: #c7d2fe;
  --glass-bg: rgb(17 22 31 / .58);
  --glass-line: rgb(255 255 255 / .09);
  --glass-blur: saturate(160%) blur(18px);

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "SF Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;

  --r-xs: 8px; --r-sm: 10px; --r: 14px; --r-lg: 18px; --r-xl: 22px;
  --e1: 0 1px 2px rgb(0 0 0 / .4);
  --e2: 0 8px 24px rgb(0 0 0 / .35), 0 2px 6px rgb(0 0 0 / .3);
  --e3: 0 24px 60px rgb(0 0 0 / .55), 0 6px 18px rgb(0 0 0 / .35);
  --hi: inset 0 1px 0 rgb(255 255 255 / .06);
  --ease: cubic-bezier(.22, .8, .24, 1);
  --t1: 140ms; --t2: 220ms; --t3: 320ms;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; height: 100dvh; overflow: hidden;
  font: 400 14px/1.5 var(--font); letter-spacing: -.003em;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.skip { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 8px 12px; background: var(--surface-2); border-radius: var(--r-xs); }
.skip:focus { top: 12px; }

/* ---------- Ortak bileşenler ---------- */
.glass {
  background: var(--glass-bg); border: 1px solid var(--glass-line);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--e2), var(--hi);
}
@media (prefers-reduced-transparency: reduce) { .glass { background: var(--surface); backdrop-filter: none; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface-2); box-shadow: var(--hi);
  font-weight: 600; white-space: nowrap;
  transition: background-color var(--t1) var(--ease), border-color var(--t1) var(--ease), transform var(--t1) var(--ease), box-shadow var(--t1) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-3); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--primary-grad); border-color: transparent; color: var(--on-primary); box-shadow: 0 6px 20px rgb(124 147 255 / .35), inset 0 1px 0 rgb(255 255 255 / .35); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #a3b3ff, #7a91ff); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; flex: none;
  border-radius: var(--r-sm); border: 0; background: transparent; color: var(--text-2);
  transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease), transform var(--t1) var(--ease);
}
.icon-btn:hover:not(:disabled) { background: rgb(255 255 255 / .08); color: var(--text); }
.icon-btn:active:not(:disabled) { transform: scale(.94); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: .35; }
.icon-btn-sm { width: 32px; height: 32px; border-radius: var(--r-xs); }
.icon-btn-sm .ic { width: 16px; height: 16px; }

.seg { position: relative; display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: rgb(0 0 0 / .28); box-shadow: inset 0 0 0 1px var(--line); }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px;
  transition: background-color var(--t2) var(--ease), color var(--t2) var(--ease), box-shadow var(--t2) var(--ease);
}
.seg button .ic { width: 16px; height: 16px; }
.seg button:hover:not(:disabled):not([aria-pressed=true]) { color: var(--text); }
.seg button[aria-pressed=true] { background: rgb(255 255 255 / .12); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .35), inset 0 1px 0 rgb(255 255 255 / .1); }
.seg button:disabled { opacity: .4; }
.seg-sm button { height: 28px; padding: 0 10px; font: 600 12px var(--mono); }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font: 700 10.5px/1 var(--font); letter-spacing: .08em; text-transform: uppercase; flex: none; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.badge.live { background: var(--live-soft); color: var(--live); }
.badge.live::before { animation: pulse 1.8s ease-in-out infinite; }
.badge.rec { background: var(--rec-soft); color: var(--rec); }
@keyframes pulse { 50% { opacity: .3; box-shadow: none; } }

.spinner { width: 24px; height: 24px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .1); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Yerleşim ---------- */
.app { height: 100%; display: grid; grid-template-columns: 300px 1fr; }

/* ---------- Kenar çubuğu ---------- */
.rail { min-height: 0; display: flex; flex-direction: column; background: var(--rail); border-right: 1px solid var(--line); }
.rail-head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; }
.logo {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: #fff;
  background: radial-gradient(120% 120% at 20% 0%, #a5b4fc 0%, #6366f1 45%, #4338ca 100%);
  box-shadow: 0 8px 24px rgb(99 102 241 / .45), inset 0 1px 0 rgb(255 255 255 / .35);
}
.logo .ic { width: 20px; height: 20px; }
.brand-text h1 { font: 650 16px/1.2 var(--font-display); letter-spacing: -.01em; }
.brand-text span { font-size: 12px; }

.rail-section-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 8px 20px; }
.rail-section-head h2 { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.count { min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--surface-2); color: var(--text-2); font: 600 11px/18px var(--mono); text-align: center; letter-spacing: 0; }
.rail-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 12px; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

.cam-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cam {
  border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--hi);
  transition: border-color var(--t2) var(--ease), background-color var(--t2) var(--ease), box-shadow var(--t2) var(--ease);
}
.cam:hover { border-color: var(--line-2); }
.cam.active { background: linear-gradient(180deg, rgb(124 147 255 / .09), rgb(124 147 255 / 0) 120px), var(--surface); border-color: rgb(124 147 255 / .35); box-shadow: var(--e1), var(--hi); }
.cam-head { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 6px; }
.cam-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 6px; border: 0; background: transparent; text-align: left; border-radius: var(--r-sm); }
.cam-avatar { position: relative; display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--surface-3); color: var(--text-2); }
.cam.active .cam-avatar { background: var(--primary-soft); color: var(--primary-2); }
.cam-avatar .dot { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; background: var(--live); border: 2px solid var(--surface); box-shadow: 0 0 10px rgb(52 211 153 / .7); }
.cam-text { min-width: 0; display: grid; gap: 1px; }
.cam-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-meta { font: 12px/1.3 var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam-edit { color: var(--muted); opacity: .8; }
.cam:hover .cam-edit { opacity: 1; }

/* Kanal önizlemeleri */
.channels { display: grid; gap: 8px; padding: 2px 10px 12px; }
.ch-all {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface-2); font-weight: 600; text-align: left;
  transition: background-color var(--t1) var(--ease), border-color var(--t1) var(--ease);
}
.ch-all .n { margin-left: auto; font: 600 12px var(--mono); color: var(--muted); }
.ch-all:hover { border-color: var(--line-3); }
.ch-all[aria-pressed=true] { background: var(--primary-soft); border-color: rgb(124 147 255 / .55); color: var(--primary-2); }
.ch-all[aria-pressed=true] .n { color: var(--primary-2); }
.ch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ch {
  position: relative; aspect-ratio: 16 / 9; padding: 0; border: 0; border-radius: var(--r-sm); overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, #1b2333, #0d1118); box-shadow: inset 0 0 0 1px var(--line-2);
  transition: box-shadow var(--t2) var(--ease), transform var(--t2) var(--ease);
}
.ch img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; opacity: .9; transition: opacity var(--t2) var(--ease); }
.ch::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgb(0 0 0 / .7)); }
.ch .ch-n { position: absolute; z-index: 1; left: 7px; bottom: 5px; font: 600 11.5px/1 var(--font); color: #fff; text-shadow: 0 1px 2px rgb(0 0 0 / .8); }
.ch .ch-ic { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); color: rgb(255 255 255 / .22); }
.ch:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--line-3), var(--e1); }
.ch:hover img { opacity: 1; }
.ch[aria-pressed=true] { box-shadow: inset 0 0 0 2px var(--primary), 0 0 0 3px rgb(124 147 255 / .2); }
.ch-loading { display: flex; align-items: center; gap: 10px; padding: 6px 4px; font-size: 13px; color: var(--muted); }
.ch-loading .spinner { width: 16px; height: 16px; }

.empty-side { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 32px 12px; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); color: var(--muted); box-shadow: var(--hi); margin-bottom: 4px; }
.empty-icon .ic { width: 26px; height: 26px; }
.empty-title { font-weight: 600; }
.empty-side .muted { font-size: 13px; }
.empty-side .btn { margin-top: 8px; }

.rail-foot { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); color: var(--muted); }
.rail-foot .ic { color: var(--live); }
.clock { font: 600 15px/1.2 var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }
.rail-foot .muted { font-size: 12px; }

/* ---------- Görüntüleyici ---------- */
.viewer {
  position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 14px; outline: none;
  background:
    radial-gradient(900px 520px at 85% -12%, rgb(124 147 255 / .13), transparent 62%),
    radial-gradient(700px 480px at -5% 112%, rgb(52 211 153 / .07), transparent 60%),
    var(--bg);
}

/* Üst yüzen çubuk */
.hud { position: relative; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; transition: opacity var(--t3) var(--ease), transform var(--t3) var(--ease); }
.hud-left { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 16px 8px 8px; border-radius: var(--r-lg); margin-right: auto; }
.hud-left .title-block { padding-left: 8px; }
.title-block { min-width: 0; display: grid; gap: 1px; }
.title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.title-row h2 { font: 650 17px/1.3 var(--font-display); letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); min-height: 18px; white-space: nowrap; }
.sub-row #camSub:empty { display: none; }
.stats { font: 11.5px var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.stats:not(:empty)::before { content: '•'; margin-right: 10px; color: var(--line-3); }
.sub-row #camSub:empty + .stats::before { display: none; }
.hud-right { display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: var(--r-lg); }
.divider { width: 1px; height: 22px; background: var(--line-2); margin: 0 2px; }

/* Görünüme göre görünürlük */
.show-single, .show-live-single, .show-multi-single, .show-active { display: none !important; }
body:not([data-view=none]) .show-active { display: flex !important; }
body[data-view=single] .show-single { display: inline-flex !important; }
body[data-view=single][data-pb="0"] .show-live-single { display: inline-flex !important; }
body[data-view=single][data-multi="1"] .show-multi-single { display: inline-grid !important; }

/* Sahne + ızgara */
.stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; container-type: size; }
.grid {
  --cols: 1; --rows: 1; --gap: 10px;
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: var(--gap);
  width: min(100cqw, calc((100cqh - (var(--rows) - 1) * var(--gap)) * 16 / 9 * var(--cols) / var(--rows) + (var(--cols) - 1) * var(--gap)));
}
.tile {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--r);
  background: radial-gradient(120% 120% at 50% 0%, #121826, #05070b); box-shadow: var(--e2), inset 0 0 0 1px var(--line);
  animation: tile-in var(--t3) var(--ease) both;
}
.grid .tile:nth-child(2) { animation-delay: 30ms; } .grid .tile:nth-child(3) { animation-delay: 60ms; }
.grid .tile:nth-child(4) { animation-delay: 90ms; } .grid .tile:nth-child(5) { animation-delay: 120ms; }
.grid .tile:nth-child(6) { animation-delay: 150ms; } .grid .tile:nth-child(7) { animation-delay: 180ms; }
.grid .tile:nth-child(n+8) { animation-delay: 210ms; }
@keyframes tile-in { from { opacity: 0; transform: scale(.98); } }
.tile canvas { width: 100%; height: 100%; object-fit: fill; display: block; }
.tile::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .06); pointer-events: none; }
.tile .label {
  position: absolute; left: 10px; top: 10px; display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff;
  background: rgb(10 14 22 / .55); border: 1px solid rgb(255 255 255 / .1); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  pointer-events: none; transition: opacity var(--t3) var(--ease);
}
.tile .label:empty { display: none; }
.tile .label i { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 8px var(--live); }
.tile.rec .label i { background: var(--rec); box-shadow: 0 0 8px var(--rec); }
.tile .zoom {
  position: absolute; right: 10px; top: 10px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  background: rgb(10 14 22 / .55); border: 1px solid rgb(255 255 255 / .1); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  opacity: 0; transform: scale(.9); transition: opacity var(--t2) var(--ease), transform var(--t2) var(--ease); pointer-events: none;
}
.tile.clickable { cursor: zoom-in; transition: transform var(--t2) var(--ease), box-shadow var(--t2) var(--ease); }
.tile.clickable:hover { transform: translateY(-2px); box-shadow: var(--e3), inset 0 0 0 1px var(--line-3); }
.tile.clickable:hover .zoom, .tile.clickable:focus-visible .zoom { opacity: 1; transform: none; }
.tile .overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; padding: 12px; text-align: center; color: var(--text-2); font-size: 13px; pointer-events: none; }
.tile .overlay.error { color: var(--danger); }
.tile .overlay:empty { display: none; }

.msg { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; pointer-events: none; }
.msg:empty { display: none; }
.msg .msg-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; margin-bottom: 6px; color: var(--primary-2); background: linear-gradient(180deg, rgb(124 147 255 / .18), rgb(124 147 255 / .05)); box-shadow: inset 0 0 0 1px rgb(124 147 255 / .25), 0 20px 50px rgb(124 147 255 / .15); }
.msg .msg-icon .ic { width: 32px; height: 32px; stroke-width: 1.6; }
.msg.error .msg-icon { color: var(--danger); background: linear-gradient(180deg, rgb(251 113 133 / .18), rgb(251 113 133 / .05)); box-shadow: inset 0 0 0 1px rgb(251 113 133 / .25); }
.msg .msg-title { font: 650 18px/1.3 var(--font-display); color: var(--text); letter-spacing: -.01em; }
.msg .msg-sub { font-size: 13.5px; color: var(--muted); max-width: 44ch; }

/* PTZ */
.ptz {
  position: absolute; right: 18px; bottom: 18px; z-index: 4; display: none;
  flex-direction: column; align-items: stretch; gap: 8px; width: 196px; padding: 10px; border-radius: 22px;
  max-height: calc(100% - 36px); overflow-y: auto; scrollbar-width: none;
  transition: opacity var(--t3) var(--ease);
}
body[data-view=single][data-pb="0"] .ptz { display: flex; }
.ptz button { font: inherit; color: var(--text); border: 0; background: transparent; }

/* Yön tuşları: dairesel kumanda */
.ptz-pad {
  position: relative; align-self: center; display: grid; grid-template: repeat(3, 48px) / repeat(3, 48px); place-items: center;
  border-radius: 50%; background: radial-gradient(circle at 50% 35%, rgb(255 255 255 / .07), rgb(0 0 0 / .25) 70%);
  box-shadow: inset 0 0 0 1px var(--line-2), inset 0 1px 0 rgb(255 255 255 / .06);
}
.ptz-pad button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; touch-action: none; user-select: none; -webkit-user-select: none; transition: background-color var(--t1) var(--ease), transform var(--t1) var(--ease), color var(--t1) var(--ease); }
.ptz-pad button .ic { width: 20px; height: 20px; }
.ptz-pad button.diag { width: 36px; height: 36px; color: var(--muted); }
.ptz-pad button.diag .ic { width: 16px; height: 16px; }
.ptz-pad [data-ptz=upLeft] .ic { transform: rotate(-45deg); } .ptz-pad [data-ptz=upRight] .ic { transform: rotate(45deg); }
.ptz-pad [data-ptz=downLeft] .ic { transform: rotate(45deg); } .ptz-pad [data-ptz=downRight] .ic { transform: rotate(-45deg); }
.ptz-pad .hub { width: 40px; height: 40px; background: rgb(255 255 255 / .06); box-shadow: inset 0 0 0 1px var(--line-2); }
.ptz-pad .hub span { width: 12px; height: 12px; border-radius: 50%; background: rgb(255 255 255 / .35); box-shadow: 0 0 10px rgb(255 255 255 / .2); }
.ptz button:hover:not(:disabled) { background: rgb(255 255 255 / .1); color: var(--text); }
.ptz button.pressing, .ptz-pad button:active { background: var(--primary); color: var(--on-primary); transform: scale(.92); box-shadow: 0 0 18px rgb(124 147 255 / .55); }
.ptz-pad .hub.pressing span { background: var(--on-primary); }

/* Açılır ayarlar */
.ptz-extra { display: none; flex-direction: column; gap: 12px; padding: 4px 2px 10px; border-bottom: 1px solid var(--line); }
.ptz[data-open="1"] .ptz-extra { display: flex; animation: ptz-in var(--t2) var(--ease); }
@keyframes ptz-in { from { opacity: 0; transform: translateY(6px); } }
.ptz-rows { display: grid; gap: 6px; }
.ptz-row { display: grid; grid-template-columns: 1fr 40px 40px; align-items: center; gap: 6px; }
.ptz-row > span, .ptz-speed > span, .ptz-preset > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.ptz-row button { height: 34px; display: grid; place-items: center; border-radius: 10px; background: rgb(255 255 255 / .06); box-shadow: inset 0 0 0 1px var(--line); touch-action: none; user-select: none; -webkit-user-select: none; transition: background-color var(--t1) var(--ease), transform var(--t1) var(--ease); }
.ptz-row button .ic { width: 16px; height: 16px; }
.ptz-speed { display: grid; gap: 6px; }
.ptz-speed > span { display: flex; justify-content: space-between; }
.ptz-speed output { font: 600 12px var(--mono); color: var(--primary-2); }
.ptz-speed input { width: 100%; accent-color: var(--primary); }
.ptz-preset { display: grid; gap: 6px; }
.ptz-preset-row { display: grid; grid-template-columns: 48px 1fr 1fr 32px; gap: 4px; }
.ptz-preset input { height: 32px; min-width: 0; padding: 0 6px; border-radius: 9px; border: 1px solid var(--line-2); background: rgb(0 0 0 / .35); color: var(--text); font: 600 13px var(--mono); text-align: center; }
.ptz-preset input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.chip { height: 32px; display: grid; place-items: center; padding: 0 6px; border-radius: 9px; background: rgb(255 255 255 / .07) !important; box-shadow: inset 0 0 0 1px var(--line); font-size: 12px !important; font-weight: 600 !important; white-space: nowrap; transition: background-color var(--t1) var(--ease), transform var(--t1) var(--ease); }
.chip:hover { background: rgb(255 255 255 / .13) !important; }
.chip:active { transform: scale(.95); }
.chip.danger { color: var(--danger) !important; }
.chip.danger .ic { width: 15px; height: 15px; }
.chip.done { background: var(--live-soft) !important; color: var(--live) !important; }

.osd { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.osd-title { font-size: 12px; font-weight: 600; color: var(--text-2); }
.osd-top { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.osd-pad { display: grid; grid-template-areas: ". u ." "l o r" ". d ."; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.osd-pad button { height: 32px; display: grid; place-items: center; border-radius: 9px; background: rgb(255 255 255 / .06); box-shadow: inset 0 0 0 1px var(--line); transition: background-color var(--t1) var(--ease), transform var(--t1) var(--ease); }
.osd-pad button .ic { width: 16px; height: 16px; }
.osd-pad .ok { font-size: 12px; font-weight: 700; background: var(--primary-soft); color: var(--primary-2); }
.osd-hint { margin: 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
.osd button:active { transform: scale(.94); }
.ptz-extra { max-height: min(62vh, 560px); overflow-y: auto; scrollbar-width: thin; }
.ptz-more { display: flex; align-items: center; justify-content: center; gap: 8px; height: 32px; border-radius: 10px; font-size: 12.5px !important; font-weight: 600; color: var(--text-2) !important; }
.ptz-more .ic { width: 16px; height: 16px; }
.ptz-more .chev { transition: transform var(--t2) var(--ease); }
.ptz[data-open="1"] .ptz-more .chev { transform: rotate(180deg); }

/* ---------- Kayıt oynatma ---------- */
.pb { position: relative; z-index: 5; display: grid; gap: 12px; padding: 12px 14px 14px; border-radius: var(--r-xl); transition: opacity var(--t3) var(--ease), transform var(--t3) var(--ease); }
.pb-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.pb-center { display: flex; align-items: center; gap: 14px; }
.pb-right { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.date-group { justify-self: start; display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; background: rgb(0 0 0 / .28); box-shadow: inset 0 0 0 1px var(--line); }
.date-field { display: inline-flex; align-items: center; gap: 8px; padding: 0 8px; color: var(--muted); border-radius: var(--r-xs); }
.date-field input { height: 32px; border: 0; background: transparent; color: var(--text); font: 600 13px var(--mono); color-scheme: dark; }
.date-field input:focus-visible { outline: none; }
.date-field:focus-within { outline: 2px solid var(--ring); outline-offset: 1px; }
.play-btn {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; border: 0; color: #261a00;
  background: linear-gradient(180deg, #fcd34d, #f59e0b); box-shadow: 0 8px 24px rgb(245 158 11 / .35), inset 0 1px 0 rgb(255 255 255 / .45);
  transition: transform var(--t1) var(--ease), filter var(--t1) var(--ease);
}
.play-btn .ic { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.play-btn:hover:not(:disabled) { filter: brightness(1.08); }
.play-btn:active:not(:disabled) { transform: scale(.94); }
.play-btn:disabled { background: var(--surface-3); color: var(--muted); box-shadow: none; }
.pb-time { font: 600 22px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; min-width: 9ch; }
.pb-time .d { display: block; margin-bottom: 4px; font: 500 11px/1 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pb-info { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

.timeline { position: relative; height: 58px; cursor: pointer; touch-action: none; border-radius: var(--r); background: rgb(0 0 0 / .3); box-shadow: inset 0 0 0 1px var(--line); }
.timeline:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.tl-track {
  position: absolute; left: 10px; right: 10px; top: 12px; height: 18px; border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(90deg, rgb(255 255 255 / .035) 0 calc(100% / 24 - 1px), rgb(255 255 255 / .09) calc(100% / 24 - 1px) calc(100% / 24));
}
.tl-segs { position: absolute; inset: 0; }
.tl-segs span { position: absolute; top: 0; bottom: 0; min-width: 2px; background: linear-gradient(180deg, rgb(52 211 153 / .55), rgb(16 185 129 / .4)); box-shadow: inset 0 1px 0 rgb(255 255 255 / .2); }
.tl-segs span.alarm { background: linear-gradient(180deg, rgb(251 191 36 / .7), rgb(217 119 6 / .55)); }
.tl-played { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, rgb(124 147 255 / 0), rgb(124 147 255 / .35)); pointer-events: none; }
.tl-cursor { position: absolute; top: 6px; bottom: 22px; width: 2px; margin-left: -1px; background: #fff; border-radius: 2px; box-shadow: 0 0 10px rgb(255 255 255 / .6); pointer-events: none; transition: left 300ms linear; }
.tl-cursor::before { content: ''; position: absolute; left: 50%; top: -4px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgb(124 147 255 / .45); }
.tl-hover { position: absolute; top: 6px; bottom: 22px; width: 1px; background: rgb(255 255 255 / .5); pointer-events: none; }
.tl-hover::after {
  content: attr(data-t); position: absolute; bottom: calc(100% + 8px); left: 0; transform: translateX(-50%);
  padding: 4px 8px; border-radius: 8px; background: var(--surface-3); border: 1px solid var(--line-2);
  font: 600 12px var(--mono); white-space: nowrap; box-shadow: var(--e2);
}
.tl-ticks { position: absolute; left: 10px; right: 10px; bottom: 5px; height: 14px; font: 500 10.5px var(--mono); color: var(--muted); pointer-events: none; }
.tl-ticks span { position: absolute; transform: translateX(-50%); }
.tl-ticks span:first-child { transform: none; }

/* ---------- Diyalog ---------- */
dialog {
  width: min(480px, calc(100vw - 32px)); padding: 0; border-radius: var(--r-xl); color: var(--text);
  background: linear-gradient(180deg, rgb(124 147 255 / .06), transparent 120px), var(--surface);
  border: 1px solid var(--line-2); box-shadow: var(--e3), var(--hi);
}
dialog::backdrop { background: rgb(3 5 10 / .7); backdrop-filter: blur(6px); }
dialog[open] { animation: dlg-in var(--t3) var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.dlg-head { display: flex; align-items: center; gap: 14px; padding: 20px 16px 4px 22px; }
.dlg-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; color: var(--primary-2); background: var(--primary-soft); box-shadow: inset 0 0 0 1px rgb(124 147 255 / .25); }
.dlg-icon .ic { width: 22px; height: 22px; }
.dlg-head h2 { font: 650 18px/1.3 var(--font-display); }
.dlg-head p { font-size: 13px; }
.dlg-body { display: grid; gap: 16px; padding: 18px 22px; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.field { display: grid; gap: 7px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: rgb(0 0 0 / .3); color: var(--text);
  transition: border-color var(--t1) var(--ease), box-shadow var(--t1) var(--ease), background-color var(--t1) var(--ease);
}
.field input:hover { border-color: var(--line-3); }
.field input::placeholder { color: #5f6b80; }
.field input:focus { outline: none; border-color: var(--primary); background: rgb(0 0 0 / .4); box-shadow: 0 0 0 4px var(--primary-soft); }
.field input:user-invalid { border-color: var(--danger); }
.help { font-size: 12px; color: var(--muted); }
.pw { position: relative; }
.pw input { padding-right: 46px; }
.pw .icon-btn { position: absolute; right: 5px; top: 5px; }

/* ---------- Tam ekran / sürükleyici mod ---------- */
/* Gerçek tam ekran mümkün değilse (ör. gömülü tarayıcı) görüntüleyici pencereyi kaplar. */
body.immersive .app { grid-template-columns: 1fr; }
body.immersive .rail, body.immersive .scrim { display: none; }
body.immersive .viewer { position: fixed; inset: 0; z-index: 50; padding: 12px; background: #000; }
body.immersive .grid { --gap: 4px; }
body.immersive .tile { border-radius: 8px; box-shadow: none; }
body.immersive.idle .viewer { cursor: none; }
body.immersive.idle .hud, body.immersive.idle .pb { opacity: 0; transform: translateY(-6px); pointer-events: none; }
body.immersive.idle .pb { transform: translateY(6px); }
body.immersive.idle .ptz, body.immersive.idle .tile .label { opacity: 0; pointer-events: none; }
body.immersive .hud { position: absolute; left: 12px; right: 12px; top: 12px; }
body.immersive .pb { position: absolute; left: 12px; right: 12px; bottom: 12px; }
body.immersive .stage { margin: 0; }

/* ---------- Mobil ---------- */
.only-mobile { display: none; }
.scrim { display: none; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid; }
  .rail {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(320px, 86vw);
    transform: translateX(-102%); transition: transform var(--t3) var(--ease); box-shadow: var(--e3);
  }
  body.nav-open .rail { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(3 5 10 / .6); backdrop-filter: blur(3px); }
  .viewer { padding: 10px; gap: 10px; }
  .hud-left { flex: 1 1 100%; padding-right: 12px; }
  .hud-right { flex: 1 1 100%; justify-content: space-between; }
  .seg button span { display: none; }
  .grid { --gap: 6px; }
  .tile { border-radius: 10px; }
  .ptz { right: 10px; bottom: 10px; width: 172px; padding: 8px; }
  .ptz-pad { grid-template: repeat(3, 46px) / repeat(3, 46px); }
  .pb { padding: 12px; }
  .pb-row { grid-template-columns: 1fr auto; }
  .pb-center { order: 2; }
  .pb-right { grid-column: 1 / -1; order: 3; justify-content: space-between; }
  .pb-time { font-size: 18px; }
  .tl-ticks span:nth-child(even) { display: none; }
  .field-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Görüntü iyileştirme paneli (yalnızca ekranda, tarayıcı filtreleri) */
.enh {
  position: absolute; top: 12px; right: 18px; z-index: 6; width: 236px; padding: 14px;
  display: grid; gap: 10px; border-radius: 18px; animation: ptz-in var(--t2) var(--ease);
}
.enh[hidden] { display: none; }
body[data-view=none] .enh { display: none; }
.enh-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.enh-head strong { font-size: 13.5px; }
.enh-scope { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.enh-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.enh-presets .chip { color: var(--text); border: 0; font: inherit; cursor: pointer; }
.enh-row { display: grid; gap: 4px; }
.enh-row > span { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--text-2); }
.enh-row output { font: 600 12px var(--mono); color: var(--primary-2); }
.enh-row input { width: 100%; accent-color: var(--primary); }
.enh-note { margin: 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
#enhBtn[aria-expanded="true"] { background: var(--primary-soft); color: var(--primary-2); }
body.immersive.idle .enh { opacity: 0; pointer-events: none; }
@media (max-width: 720px) { .enh { top: auto; bottom: 10px; left: 10px; right: auto; width: min(236px, calc(100% - 20px)); } }

/* Kanal filtresi */
.ch-all-row { display: grid; grid-template-columns: 1fr 40px; gap: 6px; }
.ch-filter { width: 40px; height: 40px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface-2); }
.ch-filter.on { color: var(--primary-2); border-color: rgb(124 147 255 / .55); background: var(--primary-soft); }
.ch-filter[aria-expanded=true] { border-color: var(--line-3); }
.ch-picker { margin: 0; padding: 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: rgb(0 0 0 / .25); display: grid; gap: 8px; min-width: 0; }
.ch-picker legend { padding: 0 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.ch-picker-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ch-picker label { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 8px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.ch-picker label:hover { background: rgb(255 255 255 / .06); }
.ch-picker input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.ch-picker-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ch-picker-foot .chip { color: var(--text); border: 0; font: inherit; cursor: pointer; }
.ch-picker-hint { margin: 0; font-size: 11.5px; color: var(--warn, #f5b84a); min-height: 0; }
.ch-picker-hint:empty { display: none; }

/* TV'ye gönder düğmesi (kenar çubuğu altı) */
.tv-send { margin-left: auto; }
.tv-send.done { color: var(--live); background: var(--live-soft); }

/* Kısa bilgi balonu (TV ipuçları, gönderim sonucu) */
.tv-hint {
  position: fixed; left: 50%; bottom: 28px; z-index: 50; transform: translate(-50%, 12px);
  max-width: min(90vw, 720px); padding: 12px 20px; border-radius: 999px;
  background: rgb(12 15 22 / .92); border: 1px solid var(--line-2); color: var(--text);
  font-size: 15px; font-weight: 600; text-align: center; box-shadow: var(--e3, 0 10px 30px rgb(0 0 0 / .5));
  opacity: 0; pointer-events: none; transition: opacity var(--t2) var(--ease), transform var(--t2) var(--ease);
}
.tv-hint.show { opacity: 1; transform: translate(-50%, 0); }

/* TV modu: kenar çubuğu yok, video tam genişlik, kumanda odağı belirgin */
body.tv .app { grid-template-columns: 1fr; }
body.tv .rail, body.tv #menuBtn, body.tv #stopBtn, body.tv #fsBtn { display: none !important; }
body.tv :focus-visible, body.tv :focus { outline: 4px solid var(--primary-2) !important; outline-offset: 3px; }
body.tv .tile:focus { outline: none !important; box-shadow: 0 0 0 4px var(--primary-2), 0 0 32px rgb(124 147 255 / .55) !important; transform: scale(1.015); z-index: 2; }
body.tv .tile .label { font-size: 15px; }
body.tv .grid { gap: 10px; }
body.tv .ptz { bottom: 22px; right: 22px; }
