/* KOVO — light, calm, fast. One stylesheet, no web fonts (system UI fonts load instantly). */
:root {
  --bg: #f6f7fb; --panel: #ffffff; --panel-2: #f1f3f8; --line: #e6e8f0; --text: #12141a; --muted: #6b7280;
  --accent: #5b4bff; --accent-2: #12c2a6; --accent-soft: #eeecff; --out: #5b4bff; --out-text: #fff; --in: #ffffff;
  --danger: #e5484d; --ok: #12a37f; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  --radius: 18px; --grad: linear-gradient(135deg, #5b4bff 0%, #7b5cff 45%, #12c2a6 100%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d12; --panel: #13161d; --panel-2: #1a1e27; --line: #232835; --text: #eceef3; --muted: #8b93a7;
    --accent: #8b7dff; --accent-soft: #221f3d; --out: #5b4bff; --in: #1a1e27; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Noto Sans", sans-serif; overflow: hidden; }
#app { height: 100dvh; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
input, textarea, select { font: inherit; color: var(--text); }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 10px; }
.ic { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.ic svg { width: 100%; height: 100%; }
[dir="rtl"] .ic.flipx, [dir="rtl"] .back .ic, [dir="rtl"] .send .ic { transform: scaleX(-1); }
.muted { color: var(--muted); }
.accent { color: var(--accent) !important; }
.center { height: 100%; display: grid; place-items: center; align-content: center; gap: 16px; }

/* logo: a rounded tile with two interlocking rings (two people connected) */
.logo { width: 36px; height: 36px; border-radius: 11px; background: var(--grad); position: relative; flex: none; box-shadow: 0 6px 18px rgba(91,75,255,.35); }
.logo::before, .logo::after { content: ""; position: absolute; top: 50%; width: 42%; height: 42%; border: 3px solid #fff; border-radius: 50%; transform: translateY(-50%); }
.logo::before { left: 17%; } .logo::after { right: 17%; border-color: rgba(255,255,255,.75); }
.logo.sm { width: 24px; height: 24px; border-radius: 8px; box-shadow: none; } .logo.sm::before, .logo.sm::after { border-width: 2px; }
.logo.big { width: 76px; height: 76px; border-radius: 24px; } .logo.big::before, .logo.big::after { border-width: 5px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 20px; border-radius: 14px; font-weight: 600; text-decoration: none; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--panel-2); }
.btn.sm { height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.btn.danger-bg { background: var(--danger); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* sign-in + terms */
.welcome { height: 100%; overflow: auto; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 10% -10%, rgba(91,75,255,.14), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(18,194,166,.12), transparent 60%), var(--bg); }
.welcome-card { width: min(420px, 100%); background: var(--panel); border-radius: 28px; padding: 36px 28px; box-shadow: var(--shadow); display: grid; gap: 14px; justify-items: center; text-align: center; }
.welcome-card h1 { margin: 6px 0 0; font-size: 30px; letter-spacing: .14em; }
.welcome-card p { margin: 0; }
.btn.google { width: 100%; background: var(--text); color: var(--panel); height: 52px; margin-top: 8px; }
.g { width: 20px; height: 20px; border-radius: 50%; background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0); -webkit-mask: radial-gradient(circle, transparent 38%, #000 40%); mask: radial-gradient(circle, transparent 38%, #000 40%); }
.devform { display: grid; gap: 8px; width: 100%; }
.devform input, .add input, .field-l input, .field-l select { height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--panel-2); width: 100%; }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); text-align: start; background: var(--panel-2); padding: 12px 14px; border-radius: 14px; }
.note .ic { color: var(--ok); width: 18px; height: 18px; }
.error { color: var(--danger); }
.legal { font-size: 12px; color: var(--muted); }
.langs { display: flex; gap: 4px; background: var(--panel-2); border-radius: 12px; padding: 4px; }
.langs button { padding: 6px 12px; border-radius: 9px; font-size: 13px; color: var(--muted); }
.langs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.terms { text-align: start; justify-items: stretch; }
.terms .logo { justify-self: center; }
.terms h1 { text-align: center; letter-spacing: 0; font-size: 24px; }
.terms ol { margin: 0; padding-inline-start: 20px; display: grid; gap: 10px; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; }

/* main layout: list + conversation */
.shell { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; height: 100%; }
.side { background: var(--panel); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.side-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 8px; padding-top: max(12px, env(safe-area-inset-top)); }
.side-head .brand { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .14em; font-size: 17px; }
.me { border-radius: 50%; }
.search { margin: 4px 12px 8px; display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 12px; padding: 0 12px; color: var(--muted); }
.search .ic { width: 18px; height: 18px; }
.search input { flex: 1; height: 40px; border: 0; background: none; outline: none; min-width: 0; }
.offline-bar { display: none; margin: 0 12px 8px; padding: 8px 12px; border-radius: 10px; background: #fff4e5; color: #8a5300; font-size: 13px; }
body.offline .offline-bar { display: block; }
.list { flex: 1; overflow-y: auto; padding: 0 6px 12px; overscroll-behavior: contain; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border-radius: 14px; text-align: start; }
.row:hover { background: var(--panel-2); } .row.on { background: var(--accent-soft); }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-top, .row-bot { display: flex; align-items: center; gap: 8px; justify-content: space-between; min-width: 0; }
.row-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.row-top small { color: var(--muted); font-size: 12px; flex: none; }
.row-bot span { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main > small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.badge { font-style: normal; background: var(--accent); color: #fff; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; flex: none; }
.sec { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 14px 10px 6px; }
.list-empty { display: grid; place-items: center; padding: 40px 10px; }
.install { display: flex; gap: 12px; align-items: center; margin: 0 6px 8px; padding: 12px; border-radius: 14px; background: var(--accent-soft); text-align: start; width: calc(100% - 12px); }
.install .ic { color: var(--accent); }
.install span { display: grid; } .install small { color: var(--muted); font-size: 12.5px; }

.av { --s: 44px; width: var(--s); height: var(--s); border-radius: 50%; flex: none; position: relative; display: grid; place-items: center; font-weight: 700; font-size: calc(var(--s) * .4);
  color: #fff; background: linear-gradient(135deg, hsl(var(--h) 70% 62%), hsl(calc(var(--h) + 40) 70% 48%)); }
.av img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.av .dot { position: absolute; inset-inline-end: 0; bottom: 0; width: 28%; height: 28%; min-width: 10px; min-height: 10px; border-radius: 50%; background: var(--ok); border: 2px solid var(--panel); }

/* conversation */
.chat { display: flex; flex-direction: column; min-width: 0; height: 100%; background:
  radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--muted) 14%, transparent) 1px, transparent 0) 0 0 / 22px 22px, var(--bg); }
.empty { margin: auto; text-align: center; max-width: 380px; padding: 24px; display: grid; justify-items: center; gap: 8px; }
.empty h2 { margin: 8px 0 0; font-size: 20px; } .empty p { margin: 0; color: var(--muted); }
.empty-art { width: 84px; height: 84px; border-radius: 28px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.empty-art .ic { width: 40px; height: 40px; }
.e2e { display: flex; gap: 6px; align-items: center; font-size: 12.5px; margin-top: 18px !important; }
.e2e .ic { width: 15px; height: 15px; color: var(--ok); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.chat-head .who { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.chat-head .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .who small { color: var(--muted); font-size: 12.5px; }
.chat-head .icon-btn { color: var(--accent); }
.back { display: none; }
.msgs { flex: 1; overflow-y: auto; padding: 12px clamp(10px, 4vw, 48px) 16px; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.e2e-pill { align-self: center; display: flex; gap: 6px; align-items: center; text-align: center; font-size: 12px; color: #7a5a00; background: #fff7d6; padding: 8px 12px; border-radius: 12px; margin: 6px 0 12px; max-width: 420px; }
@media (prefers-color-scheme: dark) { .e2e-pill { background: #2a2614; color: #e7cf7a; } .offline-bar { background: #2b2111; color: #f3c27a; } }
.e2e-pill .ic { width: 14px; height: 14px; }
.day { align-self: center; margin: 10px 0 6px; } .day span { font-size: 12px; background: var(--panel); color: var(--muted); padding: 4px 12px; border-radius: 10px; box-shadow: var(--shadow); }
.msg { display: flex; } .msg.out { justify-content: flex-end; }
.bub { max-width: min(78%, 560px); padding: 7px 10px 6px 12px; border-radius: var(--radius); background: var(--in); box-shadow: 0 1px 1px rgba(16,24,40,.06); position: relative; animation: pop .16s ease-out; }
.msg.in .bub { border-start-start-radius: 6px; }
.msg.out .bub { background: var(--out); color: var(--out-text); border-start-end-radius: 6px; }
.msg.out a { color: #fff; }
.text { white-space: pre-wrap; overflow-wrap: anywhere; display: inline; }
.meta { float: inline-end; margin-inline-start: 10px; margin-top: 6px; font-size: 11px; opacity: .65; display: inline-flex; align-items: center; gap: 3px; line-height: 1; position: relative; top: 4px; }
.tick .ic { width: 15px; height: 15px; } .tick.read { color: #8ff0dc; opacity: 1; }
.msg.media .bub { padding: 4px; }
.msg.media img { display: block; max-width: min(320px, 70vw); max-height: 420px; width: 100%; border-radius: 14px; object-fit: cover; cursor: zoom-in; background: var(--panel-2); }
.msg.media .meta { position: absolute; inset-inline-end: 10px; bottom: 10px; background: rgba(0,0,0,.45); color: #fff; padding: 3px 6px; border-radius: 8px; opacity: 1; top: auto; }
img.blur { filter: blur(10px); } img.gone { opacity: .3; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.play { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; flex: none; }
.msg.in .play { background: var(--accent-soft); color: var(--accent); }
.wave { flex: 1; height: 4px; border-radius: 2px; background: currentColor; opacity: .3; position: relative; overflow: hidden; }
.wave i { position: absolute; inset: 0 auto 0 0; width: 0; background: currentColor; opacity: 1; }
[dir="rtl"] .wave i { inset: 0 0 0 auto; }
.voice small { font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }
.notice, .callrow { align-self: center; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); background: var(--panel); padding: 6px 12px; border-radius: 12px; margin: 6px 0; box-shadow: var(--shadow); }
.notice .ic, .callrow .ic { width: 16px; height: 16px; }
.callrow small { opacity: .7; } .callrow.missed { color: var(--danger); }
@keyframes pop { from { transform: translateY(4px); opacity: 0; } }

.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); position: relative; }
.composer .field { flex: 1; background: var(--panel-2); border-radius: 22px; padding: 2px 14px; display: flex; }
.composer textarea { flex: 1; border: 0; background: none; resize: none; outline: none; padding: 9px 0; max-height: 140px; line-height: 1.4; min-height: 40px; }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; transition: transform .1s; }
.send:active { transform: scale(.92); }
.composer.recording .field, .composer.recording > .icon-btn { display: none; }
.recbar { flex: 1; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px; }
.recbar span { flex: 1; color: var(--muted); font-size: 13.5px; } .recbar b { font-variant-numeric: tabular-nums; }
.recdot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* sheets */
.sheet-wrap { position: fixed; inset: 0; background: rgba(10,12,20,.42); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.sheet-wrap.out { animation: fade .18s reverse forwards; }
.sheet { width: min(460px, 100%); max-height: min(86dvh, 760px); background: var(--panel); border-radius: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; animation: rise .2s ease-out; }
.sheet header { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px 20px; }
.sheet h3 { margin: 0; font-size: 17px; }
.sheet-body { overflow-y: auto; padding: 6px 20px 22px; display: grid; gap: 12px; }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { transform: translateY(16px); opacity: 0; } }
.add { display: flex; gap: 8px; } .add input { flex: 1; min-width: 0; }
.add-msg p { margin: 0 0 8px; color: var(--muted); }
.invite { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite code { flex: 1; min-width: 0; font-size: 12px; background: var(--panel-2); padding: 10px 12px; border-radius: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile { display: grid; justify-items: center; gap: 4px; text-align: center; padding: 4px 0 8px; }
.profile small { color: var(--muted); } .profile p { margin: 4px 0 0; }
.menu-item { display: flex; gap: 12px; align-items: center; padding: 12px 10px; border-radius: 12px; text-align: start; text-decoration: none; color: var(--text); width: 100%; }
.menu-item:hover { background: var(--panel-2); } .menu-item.danger { color: var(--danger); }
.field-l { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.safety { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; font: 600 18px/1 ui-monospace, "Cascadia Mono", Consolas, monospace; text-align: center; padding: 10px 0; letter-spacing: .04em; direction: ltr; }
.devs { display: grid; gap: 2px; }
.dev { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); }
.dev b { flex: 1; font-weight: 600; } .dev small { color: var(--muted); }
.toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--panel); padding: 10px 18px; border-radius: 14px; z-index: 90; font-size: 14px; box-shadow: var(--shadow); animation: rise .2s; transition: opacity .3s; max-width: calc(100% - 32px); }
.toast.out { opacity: 0; }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 80; display: grid; place-items: center; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .close { position: absolute; top: max(14px, env(safe-area-inset-top)); inset-inline-end: 14px; color: #fff; }

/* calls */
.call { position: fixed; inset: 0; z-index: 70; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: max(40px, env(safe-area-inset-top)) 16px max(36px, env(safe-area-inset-bottom)); overflow: hidden; }
.call-bg { position: absolute; inset: 0; background: radial-gradient(800px 600px at 50% 0%, #3b2fd1 0%, transparent 70%), linear-gradient(180deg, #17133f, #0a0b14); z-index: -2; }
.call-top { display: grid; justify-items: center; gap: 10px; text-align: center; z-index: 1; }
.call-top small { display: flex; gap: 6px; align-items: center; opacity: .7; font-size: 12px; letter-spacing: .08em; }
.call-top small .ic { width: 14px; height: 14px; }
.call-top h2 { margin: 6px 0 0; font-size: 26px; font-weight: 700; }
.call-top .status, .call-top p { margin: 0; opacity: .8; } .timer { font-variant-numeric: tabular-nums; font-weight: 500; opacity: .9; }
.pulse { animation: blink 1.6s infinite; }
.call .av { box-shadow: 0 0 0 10px rgba(255,255,255,.06), 0 0 0 22px rgba(255,255,255,.03); }
.call-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; z-index: 1; }
.call-actions.two { gap: 72px; }
.round { display: grid; justify-items: center; gap: 8px; font-size: 12px; color: rgba(255,255,255,.85); }
.round .ic { width: 58px; height: 58px; padding: 16px; border-radius: 50%; background: rgba(255,255,255,.14); backdrop-filter: blur(10px); color: #fff; transition: background .15s, transform .1s; }
.round:active .ic { transform: scale(.94); }
.round.on .ic { background: #fff; color: #111; }
.round.red .ic { background: var(--danger); } .round.green .ic { background: #1fbf75; animation: bounce 1.2s infinite; }
@keyframes bounce { 50% { transform: translateY(-6px); } }
.call video.remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; display: none; background: #000; }
.call.has-video video.remote { display: block; }
.call.has-video .call-top .av { display: none; }
.call.has-video .call-top { text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.call video.local { position: absolute; width: 112px; aspect-ratio: 3/4; object-fit: cover; border-radius: 16px; top: max(20px, env(safe-area-inset-top)); inset-inline-end: 16px; display: none; transform: scaleX(-1); box-shadow: 0 8px 24px rgba(0,0,0,.45); background: #222; z-index: 2; }
.call.is-video video.local { display: block; }
.call .q { position: absolute; top: max(18px, env(safe-area-inset-top)); inset-inline-start: 18px; width: 10px; height: 10px; border-radius: 50%; background: transparent; }
.call .q.good { background: #1fbf75; } .call .q.fair { background: #f5b014; } .call .q.poor, .call .q.reconnecting { background: var(--danger); }
.call audio { display: none; }

/* phones: one column; the conversation slides over the list */
@media (max-width: 799px) {
  .shell { grid-template-columns: 1fr; }
  .chat { position: fixed; inset: 0; transform: translateX(100%); transition: transform .22s ease; z-index: 10; }
  [dir="rtl"] .chat { transform: translateX(-100%); }
  body.in-chat .chat { transform: none; }
  .back { display: inline-grid; }
  .bub { max-width: 86%; }
  .sheet-wrap { place-items: end center; padding: 0; }
  .sheet { width: 100%; border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
