:root {
  color-scheme: dark;
  --bg: #05080e; --panel: #0a0f19; --raised: #121a29; --line: #1b2638;
  --text: #eaf0fa; --dim: #8b9ab3; --blue: #2f7bff; --sky: #6db3ff; --mine: #12408f; --red: #f0475b; --green: #27b973;
  --hover: #0f1624; --on: #10264c; --meta: #a9b9d4; --read: #6fd0ff; --track: #ffffff30; --warn: #ff8795; --offbg: #3a2a08; --offtext: #ffd88a;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fb; --panel: #ffffff; --raised: #eaf0f8; --line: #d8e1ed;
  --text: #101828; --dim: #56647a; --blue: #1667e0; --sky: #0b5bc4; --mine: #cfe4ff; --red: #d92d45; --green: #178a52;
  --hover: #f0f5fc; --on: #dceaff; --meta: #4d5f7a; --read: #0b5bc4; --track: #00000022; --warn: #b4152e; --offbg: #fff0c9; --offtext: #6b4a00;
}
.msg:not(.mine) { border: 1px solid transparent; }
:root[data-theme="light"] .msg:not(.mine) { background: #fff; border-color: var(--line); }
.auth h1 { margin: 0; font-size: 22px; }
.settings { overflow: auto; display: grid; gap: 8px; }
.settings form { display: grid; gap: 10px; }
.setting { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 0; }
.setting .grow { min-width: 0; }
.tabs button.on { color: #fff; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; display: block; }
.dim { color: var(--dim); }
.cut { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mark { font-weight: 800; letter-spacing: -.04em; color: var(--blue); }

/* Giriş */
.auth { height: 100dvh; display: grid; place-items: center; padding: 16px; overflow: auto; }
.auth form { width: min(360px, 100%); display: grid; gap: 12px; }
.auth .mark { font-size: 76px; line-height: 1; }
.auth p { margin: 0 0 12px; color: var(--dim); }
.field { width: 100%; background: var(--raised); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 16px; }
.primary { background: var(--blue); color: #fff; font-weight: 600; border-radius: 10px; padding: 12px 18px; }
.primary:hover { filter: brightness(1.12); }
.primary:disabled { opacity: .5; cursor: default; }
.link { color: var(--sky); padding: 8px; }
.error { color: var(--warn); min-height: 1.4em; }

/* Yerleşim */
.shell { height: 100dvh; display: grid; grid-template-columns: minmax(280px, 360px) 1fr; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 8px; height: 64px; padding: 0 14px; flex: none; }
.side .mark { font-size: 30px; flex: 1; }
.icon { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; color: var(--dim); }
.icon:hover { background: var(--raised); color: var(--text); }
.search { padding: 0 14px 10px; }
.search .field { padding: 9px 13px; }
.list { flex: 1; overflow: auto; padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
.row { width: 100%; display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 12px; text-align: left; }
.row:hover { background: var(--hover); }
.row.on { background: var(--on); }
.row .grow, .head .grow { flex: 1; min-width: 0; }
.row .line { display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.row small { color: var(--dim); flex: none; }
.row strong, .head strong { font-weight: 600; display: block; }
.badge { background: var(--blue); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; font-weight: 700; flex: none; }
.avatar { position: relative; width: 46px; height: 46px; border-radius: 15px; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; }
.c0 { background: #1d5fd6; } .c1 { background: #0f7c9e; } .c2 { background: #3f4fd1; } .c3 { background: #27608f; } .c4 { background: #4668a8; }
.avatar.online::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); border: 2px solid var(--panel); }
.empty { padding: 32px 20px; color: var(--dim); text-align: center; }
.offline { background: var(--offbg); color: var(--offtext); text-align: center; padding: 5px; font-size: 13px; }

/* Sohbet */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.blank { margin: auto; text-align: center; color: var(--dim); padding: 24px; }
.blank .mark { font-size: 96px; opacity: .9; }
.head { border-bottom: 1px solid var(--line); background: var(--panel); }
.head .avatar { width: 40px; height: 40px; border-radius: 13px; }
.head .info { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; text-align: left; }
.head small { color: var(--dim); display: block; }
.back { display: none; }
.msgs { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 18px max(16px, 5%); display: flex; flex-direction: column; gap: 3px; }
.msgs > :first-child { margin-top: auto; }
.day { align-self: center; color: var(--dim); font-size: 12.5px; padding: 12px; }
.note { align-self: center; background: var(--raised); color: var(--dim); border-radius: 10px; padding: 6px 14px; font-size: 13.5px; margin: 6px; }
.msg { max-width: min(560px, 82%); align-self: flex-start; background: var(--raised); border-radius: 6px 16px 16px 16px; padding: 8px 12px; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; background: var(--mine); border-radius: 16px 6px 16px 16px; }
.msg .who { color: var(--sky); font-weight: 600; font-size: 13px; }
.msg .text { white-space: pre-wrap; }
.msg .meta { float: right; margin: 6px 0 -2px 12px; font-size: 11.5px; color: var(--meta); }
.tick.read { color: var(--read); font-weight: 700; }
.msg img { display: block; max-width: 100%; max-height: 340px; border-radius: 10px; cursor: zoom-in; min-height: 60px; }
.file { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; }
.voice { display: flex; align-items: center; gap: 10px; width: min(250px, 60vw); }
.voice button { color: #fff; width: 38px; height: 38px; border-radius: 50%; background: var(--blue); display: grid; place-items: center; flex: none; }
.voice progress { flex: 1; min-width: 0; height: 5px; appearance: none; border: 0; border-radius: 3px; overflow: hidden; background: var(--track); }
.voice progress::-webkit-progress-bar { background: var(--track); }
.voice progress::-webkit-progress-value { background: var(--sky); }
.voice progress::-moz-progress-bar { background: var(--sky); }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-width: 0; resize: none; max-height: 140px; border-radius: 14px; padding: 10px 14px; line-height: 1.4; }
.composer .go { background: var(--blue); color: #fff; }
.rec { flex: 1; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 8px; }
.rec i { width: 11px; height: 11px; border-radius: 50%; background: var(--red); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .rec i { animation: none; } }

/* Pencereler */
#overlay:not(:empty) { position: fixed; inset: 0; z-index: 10; background: #000b; display: grid; place-items: center; padding: 16px; }
.dialog { width: min(440px, 100%); max-height: 86dvh; display: flex; flex-direction: column; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.dialog header { display: flex; align-items: center; justify-content: space-between; }
.dialog h2 { margin: 0; font-size: 19px; }
.dialog .list { min-height: 120px; padding: 0; }
.tabs { display: flex; gap: 8px; }
.tabs button { flex: 1; padding: 9px; border-radius: 10px; background: var(--raised); }
.tabs .on { background: var(--blue); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { background: var(--on); border-radius: 9px; padding: 4px 10px; }
.danger { color: var(--warn); padding: 8px; }
.big { max-width: 100%; max-height: 92dvh; border-radius: 10px; }

/* Arama */
#call:not(:empty) { color: #eaf0fa; --dim: #8b9ab3; position: fixed; inset: 0; z-index: 20; background: #03050a; }
.callbox { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.callbox .avatar { width: 116px; height: 116px; border-radius: 38px; font-size: 42px; }
.callbox h2 { margin: 0; font-size: 26px; }
#remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#local { position: absolute; right: 16px; top: calc(16px + env(safe-area-inset-top)); width: min(26vw, 200px); border-radius: 14px; background: #111; z-index: 2; }
.controls { position: absolute; left: 0; right: 0; bottom: calc(36px + env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 18px; z-index: 3; }
.controls button { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: #24324b; }
.controls .off { background: #eaf0fa; color: #05080e; }
.controls .hang { background: var(--red); }
.controls .take { background: var(--green); }
[hidden] { display: none !important; }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 30; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; max-width: 88vw; }
#toast:empty { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 100%; }
  .shell .main, .shell.open .side { display: none; }
  .shell.open .main { display: flex; }
  .back { display: grid; }
  .head { padding: 0 6px; gap: 2px; }
  .msgs { padding: 14px 10px; }
}

.linkbox { width: min(380px, 100%); display: grid; gap: 12px; }
.linkbox ol { margin: 0; padding-left: 20px; }
.qr { width: 260px; height: 260px; border-radius: 14px; background: #fff; image-rendering: pixelated; }
.scan { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 14px; background: #000; }
