:root {
  color-scheme: dark;
  --bg: #07090d;
  --bg-elev: rgba(255, 255, 255, 0.04);
  --bg-elev-2: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eef1f6;
  --muted: #8b93a3;
  --accent: #22d3ee;
  --accent-2: #8b5cf6;
  --live: #ff4d5e;
  --ok: #34d399;
  --warn: #fbbf24;
  --radius: 18px;
  --shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f6fa;
    --bg-elev: rgba(255, 255, 255, 0.75);
    --bg-elev-2: rgba(15, 23, 42, 0.05);
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.16);
    --text: #0f172a;
    --muted: #64748b;
    --accent: #0891b2;
    --accent-2: #7c3aed;
    --shadow: 0 30px 80px -30px rgba(15, 23, 42, 0.35);
  }
}

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

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }

button { font: inherit; color: inherit; cursor: pointer; }

/* Arka plan ışıkları */
.backdrop { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.backdrop span {
  position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%;
  filter: blur(120px); opacity: 0.18;
  animation: drift 24s ease-in-out infinite alternate;
}
.backdrop span:nth-child(1) { background: var(--accent); top: -30vmax; left: -20vmax; }
.backdrop span:nth-child(2) { background: var(--accent-2); bottom: -35vmax; right: -25vmax; animation-delay: -12s; }
@keyframes drift { to { transform: translate(8vmax, 6vmax) scale(1.1); } }

/* Marka */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; letter-spacing: -0.01em; white-space: nowrap; }
.brand b { font-weight: 700; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 20px -6px var(--accent);
}
.brand-mark span { width: 10px; height: 10px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.brand-lg { font-size: 18px; margin-bottom: 28px; }
.brand-lg .brand-mark { width: 36px; height: 36px; border-radius: 11px; }

/* Ortak butonlar */
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 48px; border: 0; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 600; letter-spacing: 0.01em;
  box-shadow: 0 10px 30px -10px var(--accent-2);
  transition: transform .15s ease, filter .15s ease, opacity .15s;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: scale(0.98); }
.primary:disabled { opacity: .6; cursor: default; }

.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid transparent; background: transparent;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--bg-elev-2); }
.ghost { border: 1px solid var(--border); background: var(--bg-elev); backdrop-filter: blur(12px); }
.lang-toggle { height: 38px; padding: 0 12px; border-radius: 10px; font-size: 13px; font-weight: 600; letter-spacing: .04em; }

.muted { color: var(--muted); }

/* Giriş */
.login { position: relative; z-index: 1; min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login .lang-toggle { position: absolute; top: 16px; right: 16px; }
.login-card {
  width: 100%; max-width: 400px; padding: 36px 32px 32px;
  border-radius: 24px; border: 1px solid var(--border);
  background: var(--bg-elev); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  box-shadow: var(--shadow);
  animation: rise .5s cubic-bezier(.2,.8,.2,1);
}
.login-card h1 { font-size: 24px; line-height: 1.25; margin: 0 0 6px; letter-spacing: -0.02em; }
.login-card p { margin: 0 0 24px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input-wrap { position: relative; }
.input-wrap input {
  width: 100%; height: 48px; padding: 0 48px 0 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--bg-elev-2); color: var(--text);
  font: inherit; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.input-wrap .icon-btn { position: absolute; right: 5px; top: 5px; color: var(--muted); }
.error { color: var(--live); font-size: 14px; margin: -4px 0 14px !important; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* Uygulama */
.app { position: relative; z-index: 1; min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.streams { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.streams::-webkit-scrollbar { display: none; }
.stream-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-elev);
  font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s;
}
.stream-chip:hover { border-color: var(--border-strong); }
.stream-chip[aria-current="true"] { background: var(--bg-elev-2); border-color: var(--accent); }
.stream-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.stream-chip.is-live .dot { background: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 25%, transparent); }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev);
  font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted);
}

.stage-wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 16px 40px; flex: 1; }

.stage {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  border-radius: var(--radius); overflow: hidden;
  background: #000; border: 1px solid var(--border);
  box-shadow: var(--shadow);
  isolation: isolate;
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage:fullscreen { border-radius: 0; border: 0; aspect-ratio: auto; }

.hud {
  position: absolute; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px; padding: 14px;
  transition: opacity .3s ease, transform .3s ease;
  color: #fff;
}
.hud-top { top: 0; background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent); }
.hud-bottom { bottom: 0; background: linear-gradient(to top, rgba(0,0,0,.65), transparent); }
.stage.idle .hud-bottom { opacity: 0; transform: translateY(8px); pointer-events: none; }
.stage.idle { cursor: none; }
.hud .icon-btn:hover { background: rgba(255,255,255,.14); }
.spacer { flex: 1; }
.stream-name { font-weight: 600; font-size: 14px; letter-spacing: .01em; opacity: .9; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px;
  border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .08em;
  background: rgba(255,255,255,.12); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.pill.subtle { font-weight: 600; letter-spacing: .02em; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.live-pill { background: rgba(255,255,255,.12); color: rgba(255,255,255,.7); }
.live-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.stage[data-state="live"] .live-pill { background: var(--live); color: #fff; box-shadow: 0 6px 20px -6px var(--live); }
.stage[data-state="live"] .live-pill .dot { background: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.8); } }

/* Durum katmanları */
.overlay {
  position: absolute; inset: 0; z-index: 2;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; padding: 24px; color: #fff;
  background: radial-gradient(ellipse at center, #10141c 0%, #05070a 75%);
}
.overlay h2 { margin: 18px 0 0; font-size: clamp(18px, 2.4vw, 24px); letter-spacing: -0.01em; }
.overlay p { margin: 0; color: #9aa3b2; font-size: 14px; max-width: 360px; }
.stage[data-state="connecting"] .overlay-connecting,
.stage[data-state="waiting"] .overlay-waiting,
.stage[data-state="unsupported"] .overlay-unsupported { display: flex; animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; } }

.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.overlay-connecting p { margin-top: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.radar { position: relative; width: 96px; height: 96px; display: grid; place-items: center; }
.radar span {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid var(--accent); opacity: 0;
  animation: ripple 3s cubic-bezier(.2,.6,.4,1) infinite;
}
.radar span:nth-child(2) { animation-delay: 1s; }
.radar span:nth-child(3) { animation-delay: 2s; }
.radar i { width: 14px; height: 14px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 24px var(--accent); }
@keyframes ripple { 0% { transform: scale(.2); opacity: .9; } 100% { transform: scale(1); opacity: 0; } }

/* Bilgi şeridi */
.meta {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 16px;
  border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--border);
}
.meta-item { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: color-mix(in srgb, var(--bg) 88%, var(--text) 3%); }
.meta-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.meta-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.meta-value.ok { color: var(--ok); }
.meta-value.live { color: var(--live); }
.meta-value.warn { color: var(--warn); }

/* Bildirim */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 20;
  transform: translateX(-50%);
  padding: 10px 16px; border-radius: 12px; font-size: 14px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  animation: rise .25s ease;
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .streams { order: 3; flex-basis: 100%; }
  .brand-text { font-size: 15px; }
  .stage-wrap { padding: 12px 0 24px; }
  .stage { border-radius: 0; border-left: 0; border-right: 0; }
  .meta { grid-template-columns: repeat(2, 1fr); margin: 12px 16px 0; }
  .login-card { padding: 28px 22px 24px; }
}

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