:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --line: #e3e5e9;
  --text: #16181d;
  --muted: #6b7180;
  --accent: #2f6fde;
  --accent-text: #ffffff;
  --mine: #2f6fde;
  --mine-text: #ffffff;
  --theirs: #eceef2;
  --theirs-text: #16181d;
  --danger: #c93838;
  --ok: #1f9d55;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a20;
    --line: #262a33;
    --text: #e8eaef;
    --muted: #8a909e;
    --accent: #4c86f0;
    --mine: #3a6fd4;
    --theirs: #232731;
    --theirs-text: #e8eaef;
    --danger: #ef6a6a;
    --ok: #3ccf7f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }

button {
  font: inherit; cursor: pointer; border: 0; border-radius: 10px;
  padding: 9px 14px; background: var(--accent); color: var(--accent-text); font-weight: 600;
}
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.ghost:hover { background: var(--bg); }
button.wide { width: 100%; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, .conv-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
select { width: auto; padding: 4px 6px; }

/* Giriş */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card {
  width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px; display: grid; gap: 14px;
}
.card h1 { margin: 0; font-size: 22px; }
.card p { margin: 0; }
.card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.logo {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
}

/* Uygulama düzeni */
.app { display: grid; grid-template-columns: 290px 1fr; height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.me { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.me-name { font-weight: 700; font-size: 16px; }
.side-actions { padding: 12px 12px 4px; display: grid; gap: 8px; }
.conv-list { flex: 1; overflow-y: auto; padding: 6px; }
.side-foot { padding: 12px 16px; margin: 0; border-top: 1px solid var(--line); }
.conv-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px;
  background: transparent; color: var(--text); font-weight: 500; text-align: left; border: 0;
}
.conv-item:hover { background: var(--bg); }
.conv-item.active { background: var(--bg); box-shadow: inset 3px 0 0 var(--accent); }
.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--theirs); color: var(--text); font-weight: 700; position: relative;
}
.avatar .dot { position: absolute; right: -1px; bottom: -1px; border: 2px solid var(--panel); }
.conv-meta { flex: 1; min-width: 0; }
.conv-meta .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-meta .pv { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.badge { background: var(--accent); color: var(--accent-text); border-radius: 999px; font-size: 12px; padding: 1px 7px; font-weight: 700; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.section-label { padding: 10px 10px 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Sohbet */
.chat { min-width: 0; min-height: 0; display: flex; }
.empty { margin: auto; text-align: center; padding: 24px; }
.conv { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.conv-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.conv-title { flex: 1; min-width: 0; font-weight: 700; }
.conv-title > div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { display: flex; align-items: center; gap: 6px; }
.back { display: none; font-size: 22px; line-height: 1; padding: 4px 12px; }
.messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: min(560px, 80%); padding: 8px 12px; border-radius: var(--radius); white-space: pre-wrap; word-wrap: break-word; }
.msg .from { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.msg .time { font-size: 11px; opacity: .7; margin-top: 2px; text-align: right; }
.msg.theirs { align-self: flex-start; background: var(--theirs); color: var(--theirs-text); border-bottom-left-radius: 4px; }
.msg.mine { align-self: flex-end; background: var(--mine); color: var(--mine-text); border-bottom-right-radius: 4px; }
.msg.mine .from { display: none; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 13px; text-align: center; }
.composer { display: flex; gap: 10px; padding: 12px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { resize: none; max-height: 160px; overflow-y: hidden; }
.composer button { flex: none; width: 46px; display: grid; place-items: center; padding: 0; }

/* Pencereler */
dialog {
  border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text);
  padding: 24px; width: min(440px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 6px; font-size: 18px; }
.safety {
  font: 600 20px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em;
  background: var(--bg); border-radius: 12px; padding: 14px; text-align: center; white-space: pre-wrap;
}
.group-people { display: grid; gap: 6px; margin: 12px 0; max-height: 300px; overflow-y: auto; }
.group-people label { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; background: var(--bg); }
.group-people input { width: auto; }
.row { display: flex; gap: 10px; justify-content: flex-end; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 10; max-width: calc(100% - 32px); }
.toast { background: var(--text); color: var(--panel); padding: 10px 14px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; }

/* Dar ekran */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .app.in-conv .side { display: none; }
  .app:not(.in-conv) .chat { display: none; }
  .back { display: block; }
  .conv-head { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .conv-title { flex-basis: calc(100% - 60px); }
  .conv-head .timer { margin-left: 52px; }
  .conv-head #verifyBtn { margin-left: auto; padding: 6px 10px; font-size: 13px; }
  .messages { padding: 12px; }
  .composer { padding: 10px 12px; }
  .msg { max-width: 88%; }
}
