/* Cairo, self-hosted (SIL OFL 1.1 — see fonts/OFL.txt). Variable weight 200–1000. */
@font-face { font-family: "Cairo"; font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url(fonts/cairo-arabic-wght-normal.woff2) format("woff2-variations"), url(fonts/cairo-arabic-wght-normal.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Cairo"; font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url(fonts/cairo-latin-wght-normal.woff2) format("woff2-variations"), url(fonts/cairo-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
/* =========================================================
   Ahmed Maher Chat — interface v2
   Same identity as ahmedmaher.online: black, brand yellow, Cairo.
========================================================= */
:root {
  --bg: #050505; --panel: #0b0b0b; --panel-2: #111; --panel-3: #181818; --panel-4: #202020;
  --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.16);
  --ink: #fff; --ink-2: #c8c8c8; --ink-3: #8f8f8f;
  --accent-rgb: 255 212 0; --yellow: rgb(var(--accent-rgb)); --yellow-2: color-mix(in srgb, var(--yellow) 75%, #fff); --yellow-soft: rgb(var(--accent-rgb) / .12);
  --on-accent: #050505; --accent-ink: var(--yellow); --field: #000; --tint: rgba(255,255,255,.06); --chat-scale: 1;
  --mine: var(--yellow); --mine-ink: #0a0a0a; --theirs: #171717;
  --danger: #ff6b5e; --ok: #3ecf8e; --read: #0b6bff;
  --side: 360px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { box-sizing: border-box; min-width: 0; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 450 15px/1.65 "Cairo", "Segoe UI", Tahoma, system-ui, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-kerning: normal; font-synthesis: none; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
mark { background: var(--yellow); color: var(--on-accent); border-radius: 3px; padding: 0 2px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

.logo { direction: ltr; font: 900 26px/1 Arial, sans-serif; letter-spacing: -2px; color: var(--ink); text-decoration: none; }
.logo b { color: var(--accent-ink); }
.logo.big { font-size: 54px; }

#app { height: 100%; height: 100dvh; }
.boot { height: 100%; display: grid; place-items: center; }
.boot .logo { font-size: 44px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Icons */
.ico, .icon-btn svg, .btn svg, .send svg, .hover-bar svg, .sheet-item svg { width: 20px; height: 20px; display: inline-grid; }
.ico svg { width: 100%; height: 100%; }
.mini-ico { width: 14px; height: 14px; display: inline-grid; color: var(--ink-3); flex: none; }
.mini-ico svg { width: 100%; height: 100%; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 2px solid var(--yellow); border-radius: 12px; background: var(--yellow); color: var(--on-accent); font-weight: 800; text-decoration: none; transition: background .2s, border-color .2s, transform .2s var(--ease); }
.btn:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(255,107,94,.4); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--ink); flex: none; transition: border-color .2s, color .2s, background .2s; }
.icon-btn:hover { border-color: var(--line-2); color: var(--accent-ink); }
.icon-btn.on { color: var(--accent-ink); }
.icon-btn.small { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.danger-ico { color: var(--danger); }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.input { width: 100%; min-height: 46px; padding: 10px 14px; font-size: 16px; background: var(--field); border: 1px solid var(--line-2); border-radius: 12px; color: var(--ink); }
.input:focus { border-color: var(--accent-ink); outline: none; }
.err { color: var(--danger); font-size: 14px; margin: 8px 0 0; min-height: 1.4em; }

/* ---------- Auth ---------- */
.auth { height: 100%; overflow-y: auto; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { padding: clamp(28px, 6vw, 72px); background: var(--yellow); color: var(--on-accent); display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .logo, .auth-side .logo b { color: var(--on-accent); }
.auth-side h1 { font-size: clamp(34px, 5vw, 58px); line-height: 1.1; margin: 0 0 14px; font-weight: 900; text-wrap: balance; }
.auth-side p { font-size: 17px; max-width: 34ch; margin: 0; font-weight: 600; }
.bubbles { width: min(300px, 70%); margin: 28px 0; align-self: flex-start; }
.bubbles svg { display: block; width: 100%; height: auto; }
.auth-main { display: grid; place-items: center; padding: 28px max(5vw, 18px); }
.auth-card { width: min(100%, 420px); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 22px; }
.tabs button { min-height: 42px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; color: var(--ink-2); }
.tabs button[aria-selected="true"] { background: var(--yellow); color: var(--on-accent); }
.auth-card h2 { margin: 0 0 4px; font-size: 26px; }
.auth-card .hint { margin: 0 0 20px; color: var(--ink-3); font-size: 14px; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; pointer-events: none; }

/* ---------- Shell ---------- */
.shell { height: 100%; display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
.side { display: flex; flex-direction: column; background: var(--panel); border-inline-end: 1px solid var(--line); min-height: 0; }
.side-top { display: flex; align-items: center; gap: 8px; padding: 14px 14px 10px; }
.side-top .logo { margin-inline-end: auto; }
.search { margin: 0 14px 8px; }
.filters { display: flex; gap: 6px; padding: 0 14px 8px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: 20px; border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 700; }
.filters button[aria-selected="true"] { background: var(--yellow); color: var(--on-accent); border-color: var(--accent-ink); }
.chip-n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--yellow); color: var(--on-accent); font-size: 11px; display: inline-grid; place-items: center; }
.filters button[aria-selected="true"] .chip-n { background: var(--on-accent); color: var(--accent-ink); }
.list { flex: 1; overflow-y: auto; padding: 2px 8px 12px; overscroll-behavior: contain; }
.conv { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px; border: 0; border-radius: 14px; background: transparent; text-align: start; transition: background .15s; -webkit-user-select: none; user-select: none; }
.conv:hover { background: var(--panel-2); }
.conv[aria-current="true"] { background: var(--panel-3); box-shadow: inset -3px 0 0 var(--yellow); }
.conv .meta { flex: 1; overflow: hidden; }
.conv .top { display: flex; gap: 6px; align-items: center; }
.conv .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv .time { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.conv.unread .time { color: var(--accent-ink); }
.conv .prev { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv.unread .name, .conv.unread .prev { color: var(--ink); }
.draft { color: var(--danger); font-style: normal; }
.typing-text { color: var(--accent-ink) !important; font-weight: 700; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--yellow); color: var(--on-accent); font-size: 12px; font-weight: 800; display: inline-grid; place-items: center; }
.badge.quiet { background: var(--panel-4); color: var(--ink-2); }
.avatar { position: relative; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(145deg, var(--panel-4), var(--panel-2)); border: 1px solid var(--line-2); font-weight: 800; color: var(--accent-ink); }
.avatar.ch { border-radius: 14px; color: var(--on-accent); background: var(--yellow); border: 0; font-size: 20px; }
.avatar.owner { border-color: var(--accent-ink); box-shadow: 0 0 0 2px rgb(var(--accent-rgb) / .15); }
.avatar.xl { width: 88px; height: 88px; font-size: 30px; }
.avatar .dot { position: absolute; bottom: 1px; inset-inline-start: 1px; width: 12px; height: 12px; border-radius: 50%; background: var(--ok); border: 2px solid var(--panel); }
.role { font-size: 11px; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.role.owner { background: var(--yellow); color: var(--on-accent); border-color: var(--accent-ink); font-weight: 800; }
.role.team { color: var(--accent-ink); border-color: rgb(var(--accent-rgb) / .4); }
.me-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
.me-bar .who { flex: 1; overflow: hidden; }
.me-bar .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-list { padding: 26px 12px; text-align: center; color: var(--ink-3); font-size: 14px; }

/* ---------- Chat panel ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); position: relative;
  background-image: radial-gradient(rgb(var(--accent-rgb) / .05) 1px, transparent 1px); background-size: 22px 22px; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(14px); z-index: 2; }
.head-who { flex: 1; display: flex; align-items: center; gap: 12px; border: 0; background: none; text-align: start; padding: 4px; border-radius: 12px; overflow: hidden; }
.head-who:hover { background: var(--panel-2); }
.head-who .avatar { width: 42px; height: 42px; }
.head-who .title { overflow: hidden; display: block; }
.head-who b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-who .nm { display: flex; }   /* long names get "…" and the badge stays visible */
.head-who small { color: var(--ink-3); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: none; }
.msgs-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.msgs { flex: 1; overflow-y: auto; padding: 14px clamp(10px, 3vw, 44px) 14px; overscroll-behavior: contain; scroll-behavior: auto; }
.loading { text-align: center; color: var(--ink-3); padding: 40px; }
.day { position: sticky; top: 6px; z-index: 1; text-align: center; margin: 14px 0 8px; pointer-events: none; }
.day span { font-size: 12px; color: var(--ink-2); background: color-mix(in srgb, var(--panel-3) 92%, transparent); border: 1px solid var(--line); padding: 3px 12px; border-radius: 20px; backdrop-filter: blur(6px); }
.unread-line { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--accent-ink); font-size: 12px; font-weight: 800; }
.unread-line::before, .unread-line::after { content: ""; flex: 1; height: 1px; background: rgb(var(--accent-rgb) / .4); }
.empty-chat { display: grid; place-items: center; text-align: center; padding: 60px 20px; color: var(--ink-3); }
.empty-chat .wave { font-size: 46px; animation: wave 2.2s ease-in-out infinite; transform-origin: 70% 80%; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } }

/* Rows + grouping */
.row { display: flex; margin-top: 2px; touch-action: pan-y; }
.row.first { margin-top: 10px; }
.row.mine { justify-content: flex-start; }
.row.theirs { justify-content: flex-end; }
.bubble-wrap { position: relative; max-width: min(76%, 600px); display: flex; flex-direction: column; }
.row.mine .bubble-wrap { align-items: flex-start; }
.row.theirs .bubble-wrap { align-items: flex-end; }
.bubble { position: relative; font-size: calc(15px * var(--chat-scale)); padding: 7px 11px 5px; border-radius: 18px; background: var(--theirs); border: 1px solid var(--line); overflow-wrap: anywhere; box-shadow: 0 1px 0 rgba(0,0,0,.4); }
.row.mine .bubble { background: var(--mine); color: var(--mine-ink); border-color: var(--mine); }
.row.mine.first .bubble { border-start-start-radius: 6px; }
.row.theirs.first .bubble { border-start-end-radius: 6px; }
.row.mine:not(.first) .bubble { border-start-start-radius: 8px; }
.row.mine:not(.last) .bubble { border-end-start-radius: 8px; }
.row.theirs:not(.first) .bubble { border-start-end-radius: 8px; }
.row.theirs:not(.last) .bubble { border-end-end-radius: 8px; }
.bubble .text { white-space: pre-wrap; font-size: 15px; line-height: 1.55; }
.bubble.jumbo { background: transparent !important; border-color: transparent !important; box-shadow: none; padding: 0 2px; }
.bubble.jumbo .text { font-size: 42px; line-height: 1.2; }
.bubble.jumbo .meta { color: var(--ink-3); }
.bubble .from { display: block; font-size: 12px; font-weight: 800; color: var(--accent-ink); margin-bottom: 1px; }
.bubble .meta { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; opacity: .72; margin-top: 1px; white-space: nowrap; float: inline-end; margin-inline-start: 10px; position: relative; top: 4px; }
.bubble::after { content: ""; display: block; clear: both; }
.row.mine .bubble a { color: var(--on-accent); text-decoration: underline; }
.edited { font-style: italic; }
.tick { display: inline-grid; width: 16px; height: 16px; }
.tick svg { width: 100%; height: 100%; }
.tick.read { color: var(--read); opacity: 1; }
.tick.failed { color: var(--danger); }
.bubble.failed { opacity: .75; border-style: dashed !important; }
.retry { display: block; margin-top: 4px; border: 0; background: none; color: inherit; text-decoration: underline; font-size: 12px; font-weight: 700; padding: 0; }
.bubble.deleted { background: transparent !important; border: 1px dashed var(--line-2) !important; color: var(--ink-3) !important; box-shadow: none; }
.deleted-text { font-style: italic; font-size: 14px; }

/* Quote (reply) */
.quote { display: block; width: 100%; text-align: start; margin: 2px 0 6px; padding: 5px 9px; border: 0; border-inline-start: 3px solid var(--yellow); border-radius: 8px; background: var(--tint); color: inherit; font-size: 13px; line-height: 1.4; }
.row.mine .quote { background: rgba(0,0,0,.1); border-inline-start-color: var(--on-accent); }
.quote b { display: block; font-size: 12px; color: var(--accent-ink); }
.row.mine .quote b { color: var(--on-accent); }
.quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; opacity: .85; }
.row.flash .bubble { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px rgb(var(--accent-rgb) / .7); } 100% { box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / 0); } }

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -6px; padding: 0 8px; position: relative; z-index: 1; }
.react-chip { display: inline-flex; align-items: center; gap: 3px; height: 26px; padding: 0 8px; border-radius: 13px; background: var(--panel-3); border: 1px solid var(--line-2); font-size: 14px; color: var(--ink); transition: transform .15s var(--ease); }
.react-chip:hover { transform: scale(1.06); }
.react-chip.mine { border-color: var(--accent-ink); background: var(--yellow-soft); }
.react-chip .n { font-size: 12px; font-weight: 700; }
.heart-burst { position: absolute; inset: 0; display: grid; place-items: center; font-size: 44px; pointer-events: none; animation: burst .7s var(--ease) forwards; z-index: 3; }
@keyframes burst { 0% { transform: scale(.2); opacity: 0; } 30% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }

/* Hover toolbar (desktop) */
.hover-bar { position: absolute; top: -18px; display: none; gap: 2px; padding: 3px; background: var(--panel-3); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 4; }
.row.mine .hover-bar { inset-inline-start: calc(100% + 6px); inset-inline-end: auto; transform: none; top: 4px; }
.row.theirs .hover-bar { inset-inline-end: calc(100% + 6px); top: 4px; }
.hover-bar button { width: 32px; height: 32px; border: 0; border-radius: 9px; background: none; color: var(--ink-2); display: grid; place-items: center; }
.hover-bar button:hover { background: var(--panel-4); color: var(--accent-ink); }
.hover-bar svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .bubble-wrap:hover .hover-bar, .bubble-wrap:focus-within .hover-bar { display: flex; }
}
.row.swipe-ready .bubble { box-shadow: 0 0 0 2px var(--yellow); }

/* Attachments */
.att-img { display: block; width: fit-content; margin: 2px -6px 4px; border-radius: 14px; overflow: hidden; background: #000; cursor: zoom-in; border: 0; padding: 0; max-width: calc(100% + 12px); }
.att-img img { display: block; max-width: 100%; height: auto; max-height: 440px; object-fit: cover; }
.att-video-wrap { margin: 2px -6px 2px; }
.att-video { display: block; width: 400px; max-width: 100%; max-height: 460px; border-radius: 14px; background: #000; }
.att-dl { display: inline-block; font-size: 12px; margin: 3px 6px 0; }
.att-audio { width: min(300px, 100%); margin: 4px 0; }
.att-file { display: flex; align-items: center; gap: 10px; padding: 10px; margin: 2px 0 4px; border-radius: 12px; background: var(--tint); text-decoration: none; color: inherit; }
.row.mine .att-file { background: rgba(0,0,0,.08); }
.file-ico { width: 32px; height: 32px; display: inline-grid; flex: none; }
.file-ico svg { width: 100%; height: 100%; }
.att-file b { display: block; font-size: 14px; overflow-wrap: anywhere; }
.att-file small { display: block; opacity: .7; font-size: 12px; }
.up-inline { margin: 4px 0; }
.up-inline .bar { height: 5px; border-radius: 3px; background: rgba(0,0,0,.2); overflow: hidden; }
.row.theirs .up-inline .bar { background: var(--panel-4); }
.up-inline .bar i { display: block; height: 100%; width: 0; background: currentColor; transition: width .25s; }

/* Voice note */
.voice { display: flex; align-items: center; gap: 10px; min-width: min(240px, 60vw); padding: 4px 0; }
.v-play { width: 38px; height: 38px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--yellow); color: var(--on-accent); flex: none; }
.row.mine .v-play { background: var(--on-accent); color: var(--accent-ink); }
.v-play svg { width: 16px; height: 16px; }
.v-bar { flex: 1; height: 26px; position: relative; cursor: pointer; }
.v-bar::before { content: ""; position: absolute; inset: 7px 0; background: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px); opacity: .3; border-radius: 2px; }
.v-bar i { position: absolute; inset-block: 7px; inset-inline-start: 0; width: 0; background: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 6px); border-radius: 2px; }
.v-time { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 34px; }

/* Scroll-to-bottom */
.fab { position: absolute; bottom: 14px; left: 18px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel-3); color: var(--ink); display: grid; place-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 3; }
.fab svg { width: 22px; height: 22px; }
.fab .fab-n { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--yellow); color: var(--on-accent); font-size: 11px; font-weight: 800; display: none; place-items: center; }
.fab.has-n .fab-n { display: grid; }

.welcome { flex: 1; display: grid; place-items: center; text-align: center; padding: 30px; }
.welcome h2 { font-size: clamp(26px, 4vw, 40px); margin: 14px 0 6px; }
.welcome p { color: var(--ink-3); max-width: 40ch; margin: 0 auto 18px; }
.kbd-hint { font-size: 12px; margin-top: 18px !important; }
.load-older { display: block; margin: 0 auto 10px; }

/* In-chat search */
.chat-search { border-bottom: 1px solid var(--line); background: var(--panel); padding: 8px 14px; z-index: 2; }
.search-row { display: flex; gap: 8px; }
.search-results { max-height: 40vh; overflow-y: auto; margin-top: 6px; }
.result { display: block; width: 100%; text-align: start; padding: 8px 10px; border: 0; border-radius: 10px; background: none; }
.result:hover { background: var(--panel-2); }
.r-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.r-body { font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Composer */
.composer { padding: 8px clamp(10px, 3vw, 44px) calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 96%, transparent); }
.compose-row { display: flex; align-items: flex-end; gap: 6px; }
.compose-row textarea { flex: 1; resize: none; max-height: 160px; min-height: 46px; padding: 11px 14px; font-size: 16px; line-height: 1.5; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 22px; color: var(--ink); }
.compose-row textarea:focus { outline: none; border-color: var(--accent-ink); }
.send { width: 46px; height: 46px; border: 0; border-radius: 50%; background: var(--yellow); color: var(--on-accent); display: grid; place-items: center; flex: none; transition: transform .15s var(--ease); }
.send:active { transform: scale(.92); }
.send svg { width: 20px; height: 20px; }
.send:not(.mic) svg { transform: scaleX(-1); }
.send:disabled { opacity: .4; }
.ctx-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); border-inline-start: 3px solid var(--yellow); }
.ctx-ico { color: var(--accent-ink); }
.ctx-text { flex: 1; overflow: hidden; }
.ctx-text b { display: block; font-size: 13px; color: var(--accent-ink); }
.ctx-text span { display: block; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tray { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; flex-wrap: wrap; }
.tray-item { position: relative; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; background: var(--panel-3); border: 1px solid var(--line-2); flex: none; }
.tray-item img, .tray-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tray-file { height: 100%; display: grid; place-items: center; align-content: center; gap: 2px; color: var(--ink-2); font-size: 11px; font-weight: 800; }
.tray-size { position: absolute; bottom: 0; inset-inline: 0; padding: 2px 4px; font-size: 10px; background: rgba(0,0,0,.7); text-align: center; }
.tray-x { position: absolute; top: 4px; inset-inline-end: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.75); color: #fff; display: grid; place-items: center; padding: 4px; }
.tray-x svg { width: 14px; height: 14px; }
.tray-hint { width: 100%; margin: 0; font-size: 12px; color: var(--ink-3); }
.compose-row.recording { align-items: center; }
.rec-live { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 16px; border-radius: 22px; background: var(--panel-2); border: 1px solid rgba(255,107,94,.5); font-weight: 700; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
.rec-time { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.drop-hint { position: absolute; inset: 0; z-index: 20; display: none; place-items: center; background: color-mix(in srgb, var(--bg) 88%, transparent); border: 3px dashed var(--yellow); font-size: 22px; font-weight: 800; color: var(--accent-ink); }
.chat.dragging .drop-hint { display: grid; }
.blocked-note { padding: 14px; text-align: center; color: var(--ink-3); font-size: 14px; border-top: 1px solid var(--line); }
.uploads { display: grid; gap: 6px; margin-bottom: 8px; }
.uploads:empty { display: none; }
.up { display: flex; gap: 10px; align-items: center; padding: 6px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; font-size: 12px; }
.up .n { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-actions { display: flex; gap: 8px; align-items: center; }
.up button { border: 0; background: none; color: var(--ink-3); font-size: 12px; text-decoration: underline; padding: 0; }
.up.failed { border-color: rgba(255,107,94,.4); }

/* Popovers */
.react-pop, .emoji-pop { position: fixed; z-index: 70; background: var(--panel-3); border: 1px solid var(--line-2); box-shadow: 0 14px 40px rgba(0,0,0,.6); animation: pop .18s var(--ease); }
.react-pop { display: flex; gap: 2px; padding: 5px; border-radius: 30px; }
.react-pop button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: none; font-size: 24px; transition: transform .15s var(--ease); }
.react-pop button:hover, .react-pop button:focus-visible { transform: scale(1.25); background: var(--panel-4); }
.emoji-pop { display: grid; grid-template-columns: repeat(8, 38px); gap: 2px; padding: 8px; border-radius: 16px; max-width: calc(100vw - 16px); }
.emoji-pop button { width: 38px; height: 38px; border: 0; border-radius: 8px; background: none; font-size: 22px; }
.emoji-pop button:hover { background: var(--panel-4); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

/* Action sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet-menu { width: min(100%, 340px); background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 18px; padding: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: pop .2s var(--ease); }
.sheet-title { padding: 8px 12px; font-weight: 800; color: var(--ink-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-reacts { display: flex; justify-content: space-around; padding: 6px 4px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.sheet-reacts button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; font-size: 26px; }
.sheet-reacts button.on { background: rgb(var(--accent-rgb) / .18); }
.sheet-item { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border: 0; border-radius: 12px; background: none; text-align: start; font-weight: 600; }
.sheet-item:hover { background: var(--panel-4); }
.sheet-item.danger { color: var(--danger); }
.sheet-item.cancel { justify-content: center; color: var(--ink-3); margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }

/* Drawer (chat info) */
.drawer-wrap { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.5); animation: fade .15s; }
.drawer { position: absolute; top: 0; bottom: 0; left: 0; width: min(100%, 400px); background: var(--panel); border-inline-start: 1px solid var(--line-2); overflow-y: auto; padding: 18px; animation: slide .25s var(--ease); }
@keyframes slide { from { transform: translateX(-30px); opacity: 0; } }
.info-hero { text-align: center; padding: 6px 0 14px; }
.info-hero .avatar { margin: 0 auto 10px; }
.info-hero h3 { margin: 0; font-size: 22px; }
.info-hero p { margin: 2px 0 0; }
.info-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }
.info-actions .btn { min-height: 40px; padding: 0 12px; font-size: 13px; }
.info-sec { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.info-sec h4 { margin: 0 0 8px; font-size: 13px; color: var(--ink-3); }
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.media-cell { aspect-ratio: 1; border: 0; padding: 0; border-radius: 8px; overflow: hidden; background: var(--panel-3); display: grid; place-items: center; }
.media-cell img { width: 100%; height: 100%; object-fit: cover; }
.media-video { width: 36px; height: 36px; color: var(--accent-ink); display: grid; }
.media-video svg { width: 100%; height: 100%; }
.files-list { display: grid; gap: 4px; }

/* ---------- Modals ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.7); animation: fade .15s; }
.sheet { width: min(100%, 520px); max-height: min(88vh, 760px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 20px; padding: 22px; animation: pop .2s var(--ease); }
.sheet.wide { width: min(100%, 980px); }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 21px; }
.people { display: grid; gap: 4px; }
.person { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 1px solid transparent; border-radius: 12px; background: transparent; text-align: start; }
.person:not(.static):hover { background: var(--panel-2); border-color: var(--line); }
.person .meta { flex: 1; }
.checks { display: grid; gap: 4px; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.checks label { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.checks label:hover { background: var(--panel-2); }
.checks input { width: 20px; height: 20px; accent-color: var(--accent-ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* Admin */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
.stat { padding: 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; }
.stat b { display: block; font-size: 24px; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-3); }
.admin-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.admin-tabs button { min-height: 40px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 20px; background: transparent; color: var(--ink-2); font-weight: 700; }
.admin-tabs button[aria-selected="true"] { background: var(--yellow); color: var(--on-accent); border-color: var(--accent-ink); }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th { text-align: start; font-size: 12px; color: var(--ink-3); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--line); }
.users td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users td.num { text-align: end; font-variant-numeric: tabular-nums; }
.users select { min-height: 38px; padding: 4px 8px; background: var(--field); border: 1px solid var(--line-2); border-radius: 8px; font-size: 14px; }
.users .email { direction: ltr; text-align: end; color: var(--ink-3); font-size: 12px; display: block; }
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-inline-start: 6px; vertical-align: middle; }
.status-blocked { color: var(--danger); }
.filter-row { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.filter-row .input { flex: 1; min-width: 180px; }
.channel-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; }
.channel-item .meta { flex: 1; }

/* Gallery */
.lightbox { position: fixed; inset: 0; z-index: 75; background: rgba(0,0,0,.96); display: grid; grid-template-rows: auto 1fr; animation: fade .15s; }
.lightbox .bar { display: flex; gap: 8px; justify-content: space-between; align-items: center; padding: 12px 16px; }
.lightbox .bar > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: 14px; }
.bar-actions { display: flex; gap: 8px; }
.stage-wrap { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; min-height: 0; gap: 8px; padding: 0 10px 10px; }
.stage { display: grid; place-items: center; height: 100%; min-height: 0; overflow: hidden; }
.stage img, .stage video { max-width: 100%; max-height: calc(100dvh - 90px); object-fit: contain; border-radius: 6px; }
.nav-btn:disabled { opacity: .2; }

/* Toast */
#toast { position: fixed; z-index: 90; bottom: calc(96px + var(--safe-b)); left: 50%; transform: translate(-50%, 160%); padding: 11px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: 0 12px 40px rgba(0,0,0,.5); transition: transform .25s var(--ease), visibility .25s; max-width: 92vw; visibility: hidden; }
#toast.show { transform: translate(-50%, 0); visibility: visible; }
#toast.bad { background: var(--danger); color: #fff; }

/* ---------- Narrow screens ---------- */
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .bubbles { width: min(200px, 55%); margin: 16px 0; }
  .shell { grid-template-columns: 1fr; }
  .shell.open .side { display: none; }
  .shell:not(.open) .chat { display: none; }
  .back { display: inline-grid; }
  .chat-head { padding: 8px 8px; gap: 4px; }
  .chat-head .icon-btn { width: 40px; height: 40px; border: 0; background: none; }
  .bubble-wrap { max-width: 84%; }
  .composer { padding-inline: 8px; }
  .compose-row { gap: 4px; }
  .compose-row .icon-btn { width: 40px; height: 46px; border: 0; background: none; color: var(--ink-2); }
  .sheet-wrap { place-items: end center; padding: 0; }
  .sheet-menu { width: 100%; border-radius: 20px 20px 0 0; padding-bottom: calc(10px + var(--safe-b)); animation: up .22s var(--ease); }
  @keyframes up { from { transform: translateY(40px); opacity: .5; } }
  .drawer { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.users thead { display: none; }
  table.users tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.users td { border: 0; padding: 0; }
  table.users td:first-child { grid-column: 1 / -1; }
  table.users td.num { text-align: start; }
  .stage-wrap { grid-template-columns: 1fr; }
  .nav-btn { display: none; }
  .fab { left: 12px; }
  /* Slide between list and chat, WhatsApp-style (RTL: the chat comes in from the left). */
  .shell.nav-in .chat { animation: navChatIn .3s var(--ease); }
  .shell.nav-back .side { animation: navSideBack .3s var(--ease); }
  @keyframes navChatIn { from { transform: translateX(-32%); opacity: 0; } }
  @keyframes navSideBack { from { transform: translateX(22%); opacity: .3; } }
  .chat { will-change: auto; }
  .chat.swiping { transition: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .shell.open { overflow: hidden; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (hover: none) { .bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; } .bubble a, .bubble img { -webkit-touch-callout: none; } }

/* ---------- Typography ---------- */
h1, h2, h3, h4, .sheet-head h2 { font-weight: 800; letter-spacing: 0; }
.auth-side h1 { font-weight: 900; line-height: 1.15; }
.btn, .tabs button, .filters button, .admin-tabs button { font-weight: 750; }
.bubble .text { font-size: 15.5px; line-height: 1.62; font-weight: 450; }
.row.mine .bubble .text { font-weight: 550; }
.conv .name, .head-who .nm, .me-bar .nm { font-weight: 750; }
.conv .prev { font-weight: 450; }
.conv.unread .prev { font-weight: 650; }
.time, .bubble .meta, .v-time, .stat b, .badge, .chip-n, .day span, .tray-size, .r-top { font-variant-numeric: tabular-nums; }
.bubble .meta { font-weight: 600; letter-spacing: .1px; }
.day span { font-weight: 700; font-size: 11.5px; }
.compose-row textarea, .input { font-weight: 500; }
.compose-row textarea::placeholder, .input::placeholder { color: var(--ink-3); font-weight: 450; opacity: 1; }
.quote b, .ctx-text b { font-weight: 800; }
.empty-chat, .welcome p { font-weight: 500; }

/* ---------- Names + verified seal ---------- */
.nm { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; min-width: 0; vertical-align: middle; }
.nm-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.conv .name.nm { flex: 1 1 auto; display: flex; }
.seal { flex: none; display: inline-grid; width: 17px; height: 17px; color: var(--accent-ink); filter: drop-shadow(0 0 6px rgb(var(--accent-rgb) / .35)); }
.seal svg { width: 100%; height: 100%; }
h3.nm .seal { width: 22px; height: 22px; }
.info-hero h3.nm { justify-content: center; display: flex; }
.bubble .from.nm { display: flex; margin-bottom: 2px; font-size: 12.5px; }
.bubble .from .seal { width: 14px; height: 14px; }
.from.role-team { color: #7fd4ff; }
.from.role-visitor { color: #c7a6ff; }

/* ---------- Role badges ---------- */
.role { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 750; line-height: 1; white-space: nowrap; flex: none;
  color: var(--ink-2); background: var(--tint); border: 1px solid var(--line-2); }
.role-ico { width: 12px; height: 12px; display: inline-grid; }
.role-ico svg { width: 100%; height: 100%; stroke-width: 2.4; }
.role.owner { color: var(--on-accent); background: linear-gradient(135deg, var(--yellow-2), var(--yellow) 55%, color-mix(in srgb, var(--yellow) 88%, #000)); border-color: transparent; box-shadow: 0 2px 10px rgb(var(--accent-rgb) / .25), inset 0 1px 0 rgba(255,255,255,.45); }
.role.owner .role-ico svg path:last-child { stroke: var(--yellow); }
.role.team { color: var(--accent-ink); background: rgb(var(--accent-rgb) / .08); border-color: rgb(var(--accent-rgb) / .45); }
.role.team .role-ico svg { fill: currentColor; stroke: none; }
.role.visitor { color: var(--ink-2); }
.me-bar .who { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.me-bar .who .nm { display: flex; }

/* ---------- Unread + filter counters ---------- */
.badge { min-width: 21px; height: 21px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; font-weight: 850; line-height: 21px; text-align: center; display: inline-block;
  background: var(--yellow); color: var(--on-accent); flex: none; }
.badge.wide { padding: 0 7px; }
.badge.quiet { background: var(--panel-4); color: var(--ink-2); box-shadow: none; }
.badge.bump { animation: bump .45s var(--ease); }
@keyframes bump { 0% { transform: scale(.6); } 55% { transform: scale(1.22); } 100% { transform: scale(1); } }
.chip-n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; font-size: 10.5px; font-weight: 850; line-height: 18px; display: inline-block; text-align: center; }
.fab .fab-n { font-weight: 850; box-shadow: 0 0 0 2px var(--bg); border-radius: 999px; }

/* Channel avatar + online dot polish */
.avatar { font-weight: 850; letter-spacing: 0; }
.avatar.ch { font-weight: 900; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.avatar .dot { width: 13px; height: 13px; border-width: 2.5px; box-shadow: 0 0 0 0 rgba(62,207,142,.5); }
.conv[aria-current="true"] .avatar .dot { border-color: var(--panel-3); }

/* ---------- Install (PWA) ---------- */
.install-slot:empty { display: none; }
.install-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid rgb(var(--accent-rgb) / .5); background: rgb(var(--accent-rgb) / .08); color: var(--accent-ink); font-weight: 800; font-size: 13px; }
.install-btn .ico { width: 16px; height: 16px; }
.install-btn:hover { background: var(--yellow); color: var(--on-accent); }
.install-nudge { position: fixed; z-index: 80; inset-inline: 10px; bottom: calc(12px + var(--safe-b)); display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 8px; border-radius: 18px; background: color-mix(in srgb, var(--panel-3) 97%, transparent); border: 1px solid var(--line-2); box-shadow: 0 16px 48px rgba(0,0,0,.6); backdrop-filter: blur(12px); animation: up .3s var(--ease); }
.install-nudge img { border-radius: 10px; flex: none; }
.install-nudge .txt { flex: 1; min-width: 0; }
.install-nudge b { display: block; font-size: 14px; }
.install-nudge span { display: block; font-size: 12px; color: var(--ink-3); }
.install-nudge .btn { min-height: 38px; padding: 0 14px; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.ios-guide ol { padding-inline-start: 22px; margin: 0 0 14px; display: grid; gap: 10px; font-size: 15px; }
.ios-guide .warn { background: rgba(255,107,94,.12); border: 1px solid rgba(255,107,94,.4); color: #ffb4ab; padding: 10px 12px; border-radius: 12px; }
.ios-guide .mini-ico { vertical-align: middle; color: var(--accent-ink); }

/* ---------- Call buttons in the chat header ---------- */
.call-btn { color: var(--yellow); }

/* ---------- Call log line ---------- */
.row.call-log { justify-content: center; margin: 12px 0; }
.call-pill { display: inline-flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; padding-inline-start: 12px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line); max-width: 92%; }
.cl-ico { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgb(var(--accent-rgb) / .12); color: var(--accent-ink); flex: none; }
.cl-ico svg { width: 18px; height: 18px; }
.call-log.missed .cl-ico { background: rgba(255,107,94,.14); color: var(--danger); }
.cl-text b { display: block; font-size: 14px; }
.call-log.missed .cl-text b { color: #ffb4ab; }
.cl-text time { display: block; font-size: 11px; color: var(--ink-3); }
.cl-again { border: 0; background: var(--yellow); color: var(--on-accent); font-weight: 800; font-size: 12px; height: 32px; padding: 0 12px; border-radius: 10px; margin-inline-start: 6px; }

/* ---------- Call screen ---------- */
.call-screen { position: fixed; inset: 0; z-index: 100; background: radial-gradient(120% 80% at 50% 0%, #1d1a05 0%, #050505 55%); color: #fff; display: flex; flex-direction: column; align-items: center; overflow: hidden; animation: fade .2s; padding: env(safe-area-inset-top, 0) 0 calc(18px + var(--safe-b)); }
.call-screen video.remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; opacity: 0; transition: opacity .4s; }
.call-screen.video.connected video.remote { opacity: 1; }
.call-screen.audio video.remote, .call-screen.peer-cam-off video.remote { opacity: 0 !important; }
.call-top { position: relative; z-index: 2; width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.call-kind { font-size: 13px; font-weight: 700; color: var(--ink-2); background: rgba(0,0,0,.35); padding: 4px 12px; border-radius: 20px; backdrop-filter: blur(8px); }
.call-mini-btn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(0,0,0,.35); color: #fff; display: grid; place-items: center; backdrop-filter: blur(8px); }
.call-mini-btn svg { width: 22px; height: 22px; }
.call-center { position: relative; z-index: 2; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 0 20px; transition: opacity .3s, transform .3s; }
.call-screen.video.connected:not(.peer-cam-off) .call-center { flex: 0; justify-content: flex-start; transform: translateY(-6px); }
.call-screen.video.connected:not(.peer-cam-off) .call-avatar { display: none; }
.call-avatar { position: relative; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(145deg, #262626, #111); border: 2px solid rgb(var(--accent-rgb) / .6); font-size: 46px; font-weight: 900; color: var(--yellow); margin-bottom: 10px; }
.call-avatar.owner { border-color: var(--yellow); }
.call-screen:not(.connected) .call-avatar::before, .call-screen:not(.connected) .call-avatar::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid rgb(var(--accent-rgb) / .5); animation: ripple 2.2s ease-out infinite; }
.call-screen:not(.connected) .call-avatar::after { animation-delay: 1.1s; }
@keyframes ripple { to { transform: scale(1.7); opacity: 0; } }
.call-name { font-size: 28px; margin: 0; font-weight: 900; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.call-name .seal { width: 22px; height: 22px; }
.call-status { font-size: 15px; color: var(--ink-2); min-height: 1.4em; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.call-timer { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.6); }
.peer-state { font-size: 13px; color: #ffd98a; min-height: 1.2em; }
.call-screen.weak .call-status { color: #ffb4ab; }
.call-screen video.local { position: absolute; z-index: 3; width: 112px; height: 160px; top: calc(70px + env(safe-area-inset-top, 0px)); left: 14px; border-radius: 18px; object-fit: cover; background: #111; border: 2px solid rgb(var(--accent-rgb) / .7); box-shadow: 0 10px 30px rgba(0,0,0,.5); touch-action: none; cursor: grab; }
.call-screen video.local.mirror { transform: scaleX(-1); }
.call-screen.audio video.local, .call-screen.incoming video.local, .call-screen.self-cam-off video.local { display: none; }
.call-controls { position: relative; z-index: 2; display: flex; gap: 14px; align-items: flex-start; justify-content: center; flex-wrap: wrap; padding: 14px 18px; margin-top: auto; border-radius: 28px; background: rgba(15,15,15,.55); backdrop-filter: blur(18px); transition: opacity .3s, transform .3s; }
.call-screen.chrome-hidden .call-controls, .call-screen.chrome-hidden .call-top { opacity: 0; transform: translateY(16px); pointer-events: none; }
.cbtn { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; color: #fff; padding: 0; min-width: 64px; }
.cbtn .cico { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.16); transition: transform .15s var(--ease), background .2s; }
.cbtn .cico svg { width: 26px; height: 26px; }
.cbtn:active .cico { transform: scale(.92); }
.cbtn small { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.cbtn.on .cico { background: #fff; color: #050505; }
.cbtn.end .cico, .cbtn.decline .cico { background: #ff3b30; }
.cbtn.end .cico svg, .cbtn.decline .cico svg { width: 30px; height: 30px; }
.cbtn.accept .cico { background: #34c759; }
.cbtn.accept-audio .cico { background: rgba(52,199,89,.25); color: #34c759; }
.call-screen.incoming .cbtn .cico { width: 72px; height: 72px; }
.call-screen.incoming .call-controls { gap: 48px; background: none; backdrop-filter: none; margin-bottom: 30px; }
.call-screen.incoming .cbtn.accept .cico { animation: pulse-green 1.4s infinite; }
@keyframes pulse-green { 0% { box-shadow: 0 0 0 0 rgba(52,199,89,.6); } 100% { box-shadow: 0 0 0 22px rgba(52,199,89,0); } }
.call-mini-bar { display: none; }
/* Minimised: a slim bar on top of the chat, like WhatsApp's "return to call". */
.call-screen.mini { inset: auto 0 auto 0; top: 0; height: auto; background: #1f8f3a; padding: 0; animation: none; }
.call-screen.mini > :not(.call-mini-bar):not(video.remote) { display: none !important; }
.call-screen.mini video.remote { display: none; }
.call-screen.mini .call-mini-bar { display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; border: 0; background: none; color: #fff; font-weight: 800; padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px; }
.call-mini-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: pulse 1s infinite; }
.call-mini-bar .mini-time { font-variant-numeric: tabular-nums; opacity: .85; }
/* While a call is shrunk to the bar, push the app down so the bar never covers the chat header (back arrow, call buttons). */
body:has(.call-screen.mini) .shell { box-sizing: border-box; padding-top: calc(42px + env(safe-area-inset-top, 0px)); }
@media (min-width: 861px) {
  .call-screen video.local { width: 200px; height: 130px; top: auto; bottom: 120px; left: 24px; }
  .call-controls { margin-bottom: 18px; }
}

/* ---------- Continue with Google / Apple / Facebook ---------- */
.social { display: grid; gap: 8px; margin-bottom: 6px; }
.social-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; border-radius: 12px; font-weight: 800; text-decoration: none; border: 1px solid var(--line-2); background: #fff; color: #111; transition: transform .15s var(--ease), filter .2s; }
.social-btn:hover { filter: brightness(.94); }
.social-btn:active { transform: scale(.98); }
.social-btn.apple { background: #000; color: #fff; border-color: #333; }
.social-btn.facebook { background: #1877f2; color: #fff; border-color: #1877f2; }
.sb-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 900 14px/1 Arial, sans-serif; background: rgba(0,0,0,.08); }
.social-btn.apple .sb-mark, .social-btn.facebook .sb-mark { background: rgba(255,255,255,.18); }
.or { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12px; margin: 10px 0 8px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }

/* =========================================================
   DEVICE FIT — notch, home bar, keyboard, iOS auto-zoom, any phone size
========================================================= */
:root {
  --safe-t: env(safe-area-inset-top, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --app-h: 100dvh;
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { overscroll-behavior: none; }
/* The real visible height (set from visualViewport in pwa.js): shrinks when the keyboard opens, so the composer stays above it. */
#app { height: var(--app-h); }
/* Keep content out from under the notch / status bar and the rounded corners in landscape. */
.shell, .auth { padding-top: var(--safe-t); padding-left: var(--safe-l); padding-right: var(--safe-r); }
/* On the sign-in screen the yellow panel runs up behind the status bar instead of leaving a black strip. */
.auth { padding-top: 0; }
.auth-side { padding-top: calc(clamp(28px, 6vw, 72px) + var(--safe-t)); }
@media (min-width: 861px) { .auth-main { padding-top: calc(28px + var(--safe-t)); } }
.modal { padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l)); }
.sheet { max-height: min(calc(var(--app-h) - 32px - var(--safe-t) - var(--safe-b)), 760px); }
.drawer { padding-top: calc(18px + var(--safe-t)); padding-bottom: calc(18px + var(--safe-b)); }
.lightbox { padding-bottom: var(--safe-b); }
.lightbox .bar { padding-top: calc(12px + var(--safe-t)); padding-inline: calc(16px + var(--safe-l)) calc(16px + var(--safe-r)); }
.react-pop, .emoji-pop { max-width: calc(100vw - 16px); }
/* iPhone zooms the whole page when a text field under 16px gets focus; that is what threw the layout off. */
@media (pointer: coarse) { input, textarea, select { font-size: max(16px, 1em) !important; } }
/* Keyboard open: the home bar is hidden behind it, so drop the bottom safe-area padding. */
.kb-open .composer { padding-bottom: 8px; }
.kb-open .me-bar { display: none; }

/* Small phones (iPhone SE / mini, 320–375 px) */
@media (max-width: 380px) {
  .side-top { padding: 10px 10px 8px; gap: 4px; }
  .chat-head { padding: 6px 4px; gap: 2px; }
  .chat-head .icon-btn { width: 36px; height: 40px; }
  .head-who { gap: 8px; }
  .composer { padding-inline: 4px; }
  .compose-row .icon-btn { width: 36px; }
  .bubble-wrap { max-width: 88%; }
  .auth-card h2 { font-size: 22px; }
  .install-btn span { display: none; }
}
/* Phone on its side: short screen — tighten vertical space so messages still have room. */
@media (max-height: 500px) and (orientation: landscape) {
  .side-top { padding-top: 6px; padding-bottom: 6px; }
  .chat-head { padding-top: 4px; padding-bottom: 4px; }
  .composer { padding-top: 4px; }
  .me-bar { padding-top: 6px; padding-bottom: calc(6px + var(--safe-b)); }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-main { padding-top: calc(12px + var(--safe-t)); padding-bottom: calc(12px + var(--safe-b)); }
}


/* =========================================================
   APPEARANCE — light theme, accent colours, text size (v2.2)
   The dark theme above is the default; these only override variables.
========================================================= */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f1; --panel: #ffffff; --panel-2: #f3f3f0; --panel-3: #eaeae6; --panel-4: #dfdfda;
  --line: rgba(0,0,0,.08); --line-2: rgba(0,0,0,.16);
  --ink: #121212; --ink-2: #3d3d3d; --ink-3: #6e6e6e;
  --theirs: #ffffff; --field: #ffffff; --tint: rgba(0,0,0,.05);
  --accent-ink: color-mix(in srgb, var(--yellow) 45%, #000);  /* readable on white */
}
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] .bubble { box-shadow: 0 1px 2px rgba(0,0,0,.08); }
html[data-theme="light"] .row.mine .bubble a { color: var(--on-accent); }

/* Appearance sheet */
.look { display: grid; gap: 18px; }
.look-preview { display: grid; gap: 6px; padding: 14px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); }
.look-preview .bubble { max-width: 80%; }
.look-preview .lp-theirs { justify-self: end; }
.look-preview .lp-mine { justify-self: start; background: var(--mine); color: var(--mine-ink); border-color: var(--mine); }
.look-row { display: grid; gap: 8px; }
.look-row > b { font-size: 13px; color: var(--ink-2); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 4px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.seg button { min-height: 40px; border: 0; border-radius: 10px; background: none; color: var(--ink-2); font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--yellow); color: var(--on-accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--panel); background: var(--c); box-shadow: 0 0 0 1px var(--line-2); display: grid; place-items: center; color: #050505; transition: transform .15s var(--ease); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); transform: scale(1.06); }
.swatch svg { width: 18px; height: 18px; }
.sizes button { font-weight: 800; }
.sizes button:nth-child(1) { font-size: 12px; } .sizes button:nth-child(2) { font-size: 14px; }
.sizes button:nth-child(3) { font-size: 17px; } .sizes button:nth-child(4) { font-size: 20px; }
.look-bar { position: sticky; bottom: calc(-1 * var(--safe-b)); display: flex; align-items: center; gap: 8px; margin: 4px -4px 0; padding: 10px 12px calc(10px + var(--safe-b)); border-radius: 14px; background: var(--panel-3); border: 1px solid var(--line-2); animation: lookIn .25s var(--ease); }
.look-bar .n { flex: 1; font-weight: 700; color: var(--ink-2); }
.look-bar .btn { min-height: 38px; padding: 0 14px; }
@keyframes lookIn { from { transform: translateY(12px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .look-bar { animation: none; } }

/* Notifications prompt card (shares .install-nudge layout) */
.notify-ask .ask-ico, .verify-ask .ask-ico { width: 40px; height: 40px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--yellow); color: var(--on-accent); }
.notify-ask .ask-ico svg, .verify-ask .ask-ico svg { width: 22px; height: 22px; }

/* Profile photos */
.avatar.has-img { background: var(--panel-3); }
.avatar.has-img img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.avatar.has-img .dot { z-index: 1; }
.call-avatar.has-img { overflow: hidden; }
.call-avatar.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-edit { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.photo-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-btns .btn { min-height: 40px; padding: 0 14px; }

/* Language switch + English (LTR) */
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lang-btn { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--ink); font: 700 13px/1 inherit; cursor: pointer; }
.lang-btn:hover { border-color: var(--accent-ink); color: var(--accent-ink); }
.profile-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.profile-row .look-open { flex: 1; }
.profile-row .lang-btn { min-height: 44px; border-radius: 12px; }
[dir="ltr"] .send:not(.mic) svg { transform: none; }
[dir="ltr"] [data-icon="back"] svg, [dir="ltr"] [data-icon="reply"] svg,
[dir="ltr"] [data-icon="left"] svg, [dir="ltr"] [data-icon="right"] svg { transform: scaleX(-1); }
[dir="ltr"] .fab { left: auto; right: 18px; }
[dir="ltr"] .fab .fab-n { right: auto; left: -4px; }
[dir="ltr"] .drawer { left: auto; right: 0; }
[dir="ltr"] .call-screen video.local { left: auto; right: 14px; }
@media (min-width: 861px) { [dir="ltr"] .call-screen video.local { right: 24px; } }
[dir="ltr"] .drawer { animation-name: slideL; }
@keyframes slideL { from { transform: translateX(30px); opacity: 0; } }
@media (max-width: 860px) {
  [dir="ltr"] .fab { left: auto; right: 12px; }
  [dir="ltr"] .shell.nav-in .chat { animation-name: navChatInL; }
  [dir="ltr"] .shell.nav-back .side { animation-name: navSideBackL; }
  @keyframes navChatInL { from { transform: translateX(32%); opacity: 0; } }
  @keyframes navSideBackL { from { transform: translateX(-22%); opacity: .3; } }
}

.auth-legal { margin: 14px 0 0; text-align: center; font-size: 13px; color: var(--ink-3); }
.auth-legal a { color: var(--accent-ink); }

.link-btn { background: none; border: 0; padding: 6px 0; color: var(--accent-ink); font: inherit; font-size: 14px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.auth-card .forgot { display: block; margin: -4px 0 6px; margin-inline-start: auto; }
.auth-card .sent p { margin: 10px 0; }
/* Prompt bars (install / notifications / confirm email) never cover the composer or the account row. */
.install-nudge { bottom: calc(76px + var(--safe-b)); }
@media (min-width: 861px) {
  .install-nudge { inset-inline-end: auto; width: calc(var(--side) - 20px); flex-wrap: wrap; row-gap: 8px; }
  .install-nudge .txt { flex-basis: calc(100% - 100px); }
  .install-nudge > .btn { margin-inline-start: 50px; }
}
.install-nudge span { overflow-wrap: anywhere; }
@media (max-width: 860px) { body:has(.shell.open) .install-nudge { display: none; } }
/* Brand logo (text mark or picture) */
.logo-link { text-decoration: none; display: inline-flex; }
.side-top .logo-link { margin-inline-end: auto; }
.logo.has-img { display: inline-flex; align-items: center; gap: 10px; letter-spacing: 0; font: 900 20px/1 Cairo, Arial, sans-serif; direction: inherit; }
.logo.has-img img { border-radius: 50%; flex: none; }
.logo.big.has-img { flex-direction: column; font-size: 26px; gap: 14px; }
.boot-logo { width: 96px; height: 96px; border-radius: 50%; animation: pulse 1.2s ease-in-out infinite; }
/* ---------- Courses (ABQOR) ---------- */
.courses .muted, .courses-intro { color: var(--ink-3); }
.course-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 12px; }
.course-card { display: grid; gap: 8px; text-align: start; padding: 18px; border-radius: 18px; border: 1px solid var(--line-2); background: linear-gradient(160deg, var(--yellow-soft), transparent 60%), var(--panel-2); color: var(--ink); font: inherit; cursor: pointer; transition: transform .2s var(--ease), border-color .2s; }
.course-card:hover { transform: translateY(-2px); border-color: var(--accent-ink); }
.course-card h3 { margin: 0; font-size: 19px; line-height: 1.35; }
.cc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cc-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--yellow); color: var(--on-accent); }
.cc-ico svg { width: 20px; height: 20px; }
.cc-meta { margin: 0; color: var(--ink-2); font-size: 14px; }
.cc-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.cc-price b { font-size: 22px; }
.cc-price s, .course-facts s { color: var(--ink-3); }
.cc-seats { font-size: 12px; color: var(--ink-3); margin-inline-start: auto; }
.cc-state { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--panel-4); color: var(--ink-2); white-space: nowrap; }
.cc-state.pending { background: rgba(255,170,0,.16); color: #ffbf47; }
.cc-state.active { background: rgba(62,207,142,.16); color: var(--ok); }
.cc-state.cancelled { background: rgba(255,107,94,.14); color: var(--danger); }
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px; }
[dir="ltr"] .back-link .ico { transform: scaleX(-1); }
.course-head h3 { margin: 0 0 10px; font-size: clamp(22px, 3vw, 28px); }
.course-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.course-facts .fact { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 13px; color: var(--ink-2); }
.course-facts .fact b { color: var(--ink); }
.course-facts .fact.hot { border-color: var(--accent-ink); color: var(--accent-ink); }
.course-summary { white-space: pre-line; color: var(--ink-2); margin: 0 0 16px; }
.enroll-box { display: grid; gap: 10px; padding: 16px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line-2); margin-bottom: 18px; }
.enroll-box p { margin: 0; }
.enroll-box .btn { justify-self: start; }
.enroll-box.ok { border-color: rgba(62,207,142,.45); }
.enroll-box.wait { border-color: rgba(255,170,0,.45); }
.lessons-wrap h4 { margin: 6px 0 10px; font-size: 17px; }
.lessons { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lesson details { border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); padding: 12px 14px; }
.lesson.draft details { border-style: dashed; opacity: .85; }
.lesson summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; font-weight: 800; }
.lesson summary::-webkit-details-marker { display: none; }
.lesson .ln { width: 28px; height: 28px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--yellow-soft); color: var(--accent-ink); font-size: 13px; }
.lesson .lt { flex: 1; }
.lesson-body { white-space: pre-line; color: var(--ink-2); margin: 10px 0 0; }
.lesson-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.lesson-links:empty { display: none; }
.course-form textarea.input { min-height: 110px; resize: vertical; padding-top: 10px; }
.course-form.two { display: grid; gap: 0 14px; grid-template-columns: 1fr 1fr; }
.course-form .span2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .course-form.two { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; font-weight: 700; }
.check input { width: 20px; height: 20px; accent-color: var(--yellow); }
.enr-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.enr { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); }
.enr-who { display: grid; } .enr-who .muted { font-size: 13px; direction: ltr; text-align: start; }
.enr-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; }
.enr-act { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.enr-act .btn { min-height: 38px; padding: 0 14px; }
.course-summary, .lesson-body, .enroll-box p { unicode-bidi: plaintext; }
