:root {
  --paper: #eef1f4; --panel: #ffffff; --ink: #14202b; --muted: #5d6b79;
  --line: #d5dce3; --soft: #f5f7f9; --note: #fff3d6; --danger: #b3261e;
  --accent: #0b6e8a; --accent-ink: #ffffff;
  --fs: 15px; --font: system-ui, sans-serif; --radius: 12px; --pad: 8px;
  --maxw: 520px; --side-w: 320px;
}
:root[data-theme="dark"] {
  --paper: #11171d; --panel: #1a222a; --ink: #e8edf1; --muted: #93a1ae;
  --line: #2b3641; --soft: #212b34; --note: #3a3118; --danger: #ff8a80;
}
:root[data-contrast="1"] { --line: var(--ink); --muted: var(--ink); }
:root[data-theme="dark"][data-contrast="1"] { --line: #ffffff; }
:root[data-motion="reduce"] * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { font: var(--fs)/1.45 var(--font); background: var(--paper); color: var(--ink); -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); padding: 8px 12px; border-radius: calc(var(--radius) * .7); }
button:hover:not(:disabled) { background: var(--soft); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: calc(var(--radius) * .7); background: var(--panel); }
input[type="checkbox"], input[type="range"], input[type="color"] { width: auto; padding: 0; }
input[type="color"] { height: 32px; width: 44px; border: 1px solid var(--line); background: none; cursor: pointer; }
a { color: var(--accent); }
.muted { color: var(--muted); font-size: .87em; }
.err { color: var(--danger); font-size: .87em; margin: 0; }
.icon { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 50%; flex: none; }
.ic { display: inline-block; width: 20px; height: 20px; flex: none; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ic.big { width: 44px; height: 44px; display: block; margin: 0 auto 8px; }
.card .logo .ic { width: 28px; height: 28px; }

/* Giriş / ortalanmış kart */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: calc(var(--radius) * 1.3); padding: 26px; width: min(420px, 100%); display: grid; gap: 14px; }
.card h1 { margin: 0; font-size: 1.9em; letter-spacing: -.01em; }
.card .logo { width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 26px; }
.login-btn { display: block; text-align: center; text-decoration: none; padding: 11px 14px; border-radius: calc(var(--radius) * .7); background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* Ana yerleşim */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.me { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.me b { font-size: 1.15em; letter-spacing: .02em; }
.me .who { min-width: 0; }
.me .who .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: none; padding: 11px 4px; }
.tabs button[aria-selected="true"] { box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }
.pane { padding: 12px 12px 16px; overflow: auto; display: grid; gap: 8px; align-content: start; min-height: 0; flex: 1; }

.row { display: flex; align-items: center; gap: 10px; padding: var(--pad) 10px; border: 1px solid transparent; border-radius: var(--radius); text-align: left; width: 100%; background: none; }
.row:hover:not(:disabled) { background: var(--soft); }
.row[aria-current="true"] { background: var(--soft); border-color: var(--accent); }
.row .mid { flex: 1; min-width: 0; }
.row .top { display: flex; justify-content: space-between; gap: 8px; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .name, .row.unread .prev { color: var(--ink); font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }

/* Sohbet */
.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.head { padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.head .t { display: flex; align-items: center; gap: 10px; min-width: 0; }
.head .t b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { display: none; }
.msgs { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.b { max-width: min(var(--maxw), 82%); padding: var(--pad) 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; align-self: flex-start; }
.b.mine { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
:root[data-mine="left"] .b.mine { align-self: flex-start; }
.b.sys { align-self: center; background: var(--note); text-align: center; }
.b.legacy { font-style: italic; color: var(--muted); }
.b a { color: inherit; text-decoration: underline; }
.b small { display: flex; gap: 8px; justify-content: flex-end; opacity: .75; margin-top: 3px; font-size: .76em; white-space: normal; }
.b small button { border: 0; background: none; padding: 0; font-size: 1em; color: inherit; text-decoration: underline; }
.day { align-self: center; margin: 10px 0 4px; padding: 2px 12px; border-radius: 99px; background: var(--soft); color: var(--muted); font-size: .8em; border: 1px solid var(--line); }
.compose { display: flex; gap: 8px; align-items: flex-end; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.compose textarea { resize: none; max-height: 140px; min-height: 40px; line-height: 1.4; }
.compose .count { font-size: .75em; color: var(--muted); position: absolute; }
.empty { margin: auto; color: var(--muted); text-align: center; padding: 20px; }

/* Duvar kağıtları */
:root[data-wallpaper="dots"] .msgs { background-image: radial-gradient(var(--line) 1.2px, transparent 1.2px); background-size: 20px 20px; }
:root[data-wallpaper="grid"] .msgs { background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 28px 28px; background-color: var(--paper); }
:root[data-wallpaper="tint"] .msgs { background: color-mix(in srgb, var(--accent) 9%, var(--paper)); }
:root[data-wallpaper="fade"] .msgs { background: linear-gradient(165deg, color-mix(in srgb, var(--accent) 20%, var(--paper)), var(--paper) 70%); }
:root[data-wallpaper="aurora"] .msgs { background: radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--accent) 28%, transparent), transparent 45%), radial-gradient(circle at 85% 85%, color-mix(in srgb, #c06 18%, transparent), transparent 45%), var(--paper); }

/* Ayarlar penceresi */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: calc(var(--radius) * 1.4); width: min(860px, 100%); height: min(640px, 100%); display: grid; grid-template-columns: 210px 1fr; grid-template-rows: auto 1fr; overflow: hidden; }
.sheet header { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.sheet header h2 { margin: 0; font-size: 1.15em; }
.snav { border-right: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.snav button { border: 0; background: none; text-align: left; display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: calc(var(--radius) * .7); }
.snav button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.scontent { overflow: auto; padding: 8px 20px 24px; }
.scontent h3 { margin: 16px 0 4px; font-size: 1.05em; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set .info { min-width: 0; }
.set .info .muted { display: block; }
.set .ctl { flex: none; display: flex; align-items: center; gap: 8px; max-width: 55%; }
.set .ctl select { width: auto; }
.set .ctl input[type="range"] { width: 140px; accent-color: var(--accent); }
.set .ctl .val { min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.swatch { width: 26px; height: 26px; padding: 0; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stack { display: grid; gap: 10px; padding: 12px 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.reqbox { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; gap: 8px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 99px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .app.chat-open .side { display: none; }
  .app:not(.chat-open) .main { display: none; }
  .back { display: inline-grid; }
  .modal { padding: 0; }
  .sheet { height: 100%; border-radius: 0; grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; border: 0; }
  .snav { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .snav button { white-space: nowrap; }
  .set { flex-wrap: wrap; }
  .set .ctl { max-width: 100%; }
}

/* Sesli arama */
.callbox { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 70; width: min(360px, calc(100% - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: calc(var(--radius) * 1.5); padding: 16px; display: grid; gap: 12px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.callbox .who { font-weight: 700; font-size: 1.15em; }
.callbox .btns { justify-content: center; gap: 14px; }
.callbox .round { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; padding: 0; border: 0; }
.callbox .round .ic { width: 24px; height: 24px; }
.callbox .accept { background: #2f8f5b; color: #fff; }
.callbox .reject { background: #c0392b; color: #fff; }
.callbox .muted-on { background: var(--ink); color: var(--paper); }
.callbox .round:hover:not(:disabled) { filter: brightness(1.1); }

/* --- Kişi menüsü, engel çubuğu, zil sesi listesi --- */
[hidden] { display: none !important; }
.who-btn { display: flex; align-items: center; gap: 10px; min-width: 0; background: none; border: 0; padding: 4px 8px; border-radius: var(--radius); color: inherit; font: inherit; text-align: left; }
button.who-btn:hover { background: var(--soft); }
.mini { background: var(--panel); border: 1px solid var(--line); border-radius: calc(var(--radius) * 1.4); width: min(380px, 100%); padding: 16px; display: grid; gap: 10px; }
.mini header { display: flex; justify-content: space-between; align-items: center; }
.mini .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.blockbar { align-items: center; justify-content: center; gap: 12px; }
.rtlist { display: grid; gap: 6px; width: 100%; }
.rt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.rt.on { border-color: var(--accent); }
.rt .rtname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt em { font-style: normal; color: var(--muted); font-size: .85em; }
.delchoice { display: grid; gap: 8px; }

/* --- Görüntülü arama --- */
.callbox.video { inset: 0; left: 0; bottom: 0; transform: none; width: auto; border-radius: 0; padding: 0; background: #000; color: #fff; grid-template-rows: 1fr auto auto; gap: 0; border: 0; }
.callbox.video .stage { position: relative; min-height: 0; background: #000; }
.callbox.video .remote { width: 100%; height: 100%; object-fit: contain; background: #000; }
.callbox.video .local { position: absolute; right: 12px; bottom: 12px; width: min(28vw, 180px); aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius); border: 2px solid rgba(255, 255, 255, .6); background: #222; transform: scaleX(-1); }
.callbox.video .callinfo { padding: 10px 16px 0; }
.callbox.video .muted { color: #cfd6dc; }
.callbox.video .btns { padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.callbox.video .round:not(.reject):not(.accept) { background: rgba(255, 255, 255, .16); color: #fff; }
.callbox.video .muted-on { background: #fff !important; color: #000 !important; }
