/* BireBir (dış kullanım) — green, phone-first, WhatsApp/Telegram-like */
:root {
  --acc: #16a34a; --acc-d: #0f7a4a; --acc-fg: #fff;
  --bg: #eef3ee; --panel: #ffffff; --fg: #0b1f14; --mute: #5b6b61; --line: #dde7df;
  --me: #d9fdd3; --them: #ffffff; --bar: #0f7a4a; --bar-fg: #ffffff; --danger: #dc2626;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b141a; --panel: #111b21; --fg: #e9edef; --mute: #8696a0; --line: #222d34;
    --me: #005c4b; --them: #202c33; --bar: #1f2c33; --bar-fg: #e9edef; color-scheme: dark; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overflow: hidden; overflow: clip; }
#app { height: 100%; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--mute); } .small { font-size: 12.5px; } .err { color: var(--danger); min-height: 1.2em; font-size: 13.5px; }
button { font: inherit; color: inherit; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 14px; cursor: pointer; }
button.primary { background: var(--acc); color: var(--acc-fg); border-color: var(--acc); font-weight: 600; }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.wide { width: 100%; padding: 12px; }
button.link { border: 0; background: none; color: var(--acc); padding: 8px; }
button.icon { border: 0; background: transparent; font-size: 20px; padding: 6px 9px; color: inherit; }
input, textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; }
input:focus, textarea:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 22%, transparent); }
label { display: block; font-size: 13px; color: var(--mute); margin: 10px 0 4px; }
label input { margin-top: 4px; }
label.check { display: flex; gap: 10px; align-items: center; color: var(--fg); font-size: 15px; }
label.check input { width: auto; }

/* auth */
#auth { align-items: center; justify-content: center; overflow-y: auto; padding: 24px 18px; }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-card form { text-align: left; margin-top: 12px; }
.auth-logo { width: 76px; height: 76px; }
.auth-card h1 { margin: 8px 0 2px; font-size: 26px; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-top: 14px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 9px; }
.seg button.on { background: var(--acc); color: #fff; font-weight: 600; }
.srv { margin-top: 18px; text-align: left; color: var(--mute); font-size: 13px; }

/* bars, tabs, lists */
.bar { display: flex; align-items: center; gap: 6px; padding: calc(8px + var(--sat, 0px)) 6px 8px 8px; background: var(--bar); color: var(--bar-fg); min-height: 56px; }
.bar h1 { font-size: 20px; margin: 0 0 0 8px; font-weight: 600; }
.bar .title #chatName { font-weight: 600; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .sub { font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; background: var(--bar); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; color: var(--bar-fg); opacity: .75; padding: 12px; font-weight: 600; border-bottom: 3px solid transparent; }
.tabs button.on { opacity: 1; border-bottom-color: #fff; }
.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 10px; background: #25d366; color: #063; font-size: 12px; font-weight: 700; text-align: center; }
.list { flex: 1; overflow-y: auto; background: var(--panel); }
.row-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row-item .txt { flex: 1; min-width: 0; }
.row-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .prev { color: var(--mute); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--mute); }
.row-item .acts { display: flex; gap: 6px; }
.row-item .acts button { padding: 6px 10px; font-size: 13.5px; }
.group-h { padding: 12px 14px 6px; font-size: 12.5px; color: var(--acc); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; background: var(--bg); }
.empty { padding: 40px 24px; text-align: center; color: var(--mute); }
.avatar { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 18px; background: hsl(var(--hue, 140) 45% 42%); }
.bar .avatar { width: 38px; height: 38px; flex-basis: 38px; font-size: 16px; }
.avatar.big { width: 64px; height: 64px; flex-basis: 64px; font-size: 26px; }
.add-row { display: flex; gap: 8px; padding: 10px; background: var(--bg); }
.add-row button { flex: 0 0 auto; }
.fab { position: fixed; right: 18px; bottom: calc(22px + var(--sab, 0px)); width: 56px; height: 56px; border-radius: 16px; border: 0; background: var(--acc); color: #fff; font-size: 28px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }

/* chat */
.msgs { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px;
  background-image: radial-gradient(color-mix(in srgb, var(--line) 80%, transparent) 1px, transparent 1.3px); background-size: 18px 18px; }
.day-sep { align-self: center; margin: 8px 0; font-size: 12px; color: var(--mute); background: var(--panel); padding: 3px 12px; border-radius: 8px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.m { align-self: flex-start; max-width: 85%; background: var(--them); border-radius: 10px; border-top-left-radius: 0; padding: 6px 9px 7px; box-shadow: 0 1px 1px rgba(0,0,0,.10); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.m.me { align-self: flex-end; background: var(--me); border-radius: 10px; border-top-right-radius: 0; }
.m .stamp { float: right; margin: 8px 0 -5px 10px; font-size: 11px; line-height: 1; color: var(--mute); white-space: nowrap; }
.m .stamp .ok { color: #34b7f1; }
.m.locked { color: var(--mute); font-style: italic; }
.notice { align-self: center; max-width: 90%; text-align: center; font-size: 12.5px; color: var(--mute); background: color-mix(in srgb, #facc15 18%, var(--panel)); padding: 5px 10px; border-radius: 8px; margin: 6px 0; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 6px 8px calc(8px + var(--sab, 0px)); background: var(--bg); }
/* the textarea never scrolls itself; the pill wrapper does (keyboard-friendly) */
.input-wrap { flex: 1; min-width: 0; max-height: 160px; overflow-y: auto; overscroll-behavior: contain; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); }
.input-wrap:focus-within { border-color: var(--acc); }
#input { display: block; width: 100%; border: 0; background: transparent; box-shadow: none !important; padding: 11px 16px; min-height: 44px; resize: none; overflow: hidden; line-height: 1.4; field-sizing: content; border-radius: 0; }
.send { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 50%; border: 0; background: var(--acc); color: #fff; font-size: 18px; padding: 0; }

/* pages */
.page { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--panel); border-radius: 14px; padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card .row { display: flex; gap: 8px; } .card .row button { flex: 0 0 auto; }
.card form > * + * { margin-top: 8px; }
.me-card { display: flex; gap: 14px; align-items: center; }
.fp { font-family: ui-monospace, Menlo, monospace; font-size: 15px; letter-spacing: 1px; word-spacing: 6px; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 16px; letter-spacing: 1px; background: var(--bg); padding: 10px; border-radius: 8px; word-break: break-all; margin: 8px 0; }

/* menu, toast, lock */
.menu { position: fixed; top: 52px; right: 8px; z-index: 50; min-width: 210px; background: var(--panel); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.28); padding: 6px; }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 11px 12px; border-radius: 8px; }
.menu button:active { background: var(--bg); }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #111; color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 99; max-width: 90vw; text-align: center; }
#toast.show { opacity: .95; }
.lock { position: fixed; inset: 0; z-index: 200; background: var(--bar); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.lock img { width: 80px; }

/* new version bar */
.upd { position: fixed; left: 8px; right: 8px; bottom: calc(86px + var(--sab, 0px)); z-index: 60; display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--acc); border-radius: 14px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.upd small { display: block; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
