:root {
  --bg: #fff1f5; --surface: #ffffff; --surface-2: #ffe3ec; --fg: #4a1d33; --muted: #8a5a70;
  --accent: #e0457b; --accent-ink: #ffffff; --accent-soft: #f9b8cf; --line: #f4cddb; --danger: #c0304f;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #240f1b; --surface: #34182a; --surface-2: #46213a; --fg: #ffe9f1; --muted: #d8a5bc; --accent: #ff7aa8; --accent-ink: #3a0f24; --accent-soft: #7a3556; --line: #532943; --danger: #ff8aa0; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #240f1b; --surface: #34182a; --surface-2: #46213a; --fg: #ffe9f1; --muted: #d8a5bc; --accent: #ff7aa8; --accent-ink: #3a0f24; --accent-soft: #7a3556; --line: #532943; --danger: #ff8aa0; color-scheme: dark; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.5; overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#screens { height: 100%; }
.screen { height: 100%; }
.center { display: grid; place-items: center; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 26px 22px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 10px; }
.card h1 { font-family: var(--display); font-size: 1.9rem; margin: 0; line-height: 1.15; }
.card p { margin: 0; color: var(--muted); }
.card .heart { color: var(--accent); font-size: 2.2rem; line-height: 1; }
.card label { font-weight: 600; font-size: .9rem; margin-top: 6px; }
input[type=email], input[type=password], textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--fg); padding: 12px 14px; font: inherit; }
.msg { min-height: 1.4em; font-size: .9rem; color: var(--danger) !important; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 12px 22px; font-weight: 600; }
.btn.ghost { background: var(--surface-2); color: var(--fg); }
.btn.small { padding: 8px 14px; font-size: .9rem; }
.btn[disabled] { opacity: .55; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#chat { display: flex; flex-direction: column; height: 100%; max-width: 760px; margin: 0 auto; background: var(--bg); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) 10px max(14px, env(safe-area-inset-left, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-family: var(--display); font-weight: 600; flex: none; }
.name { font-family: var(--display); font-weight: 600; font-size: 1.1rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state { font-size: .8rem; color: var(--muted); }
.link { background: none; border: 0; color: var(--muted); font-size: .85rem; padding: 6px; }
.banner { background: var(--surface-2); color: var(--fg); text-align: center; font-size: .85rem; padding: 6px 12px; }
.list { flex: 1; overflow-y: auto; padding: 12px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 6px; }
.more { align-self: center; background: var(--surface-2); border: 0; border-radius: 999px; padding: 6px 14px; font-size: .85rem; margin-bottom: 6px; }
.day { align-self: center; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.empty { align-self: center; text-align: center; color: var(--muted); margin: auto; max-width: 28ch; }
.msg-row { display: flex; flex-direction: column; max-width: 82%; min-width: 0; }
.msg-row.mine { align-self: flex-end; align-items: flex-end; }
.msg-row.theirs { align-self: flex-start; align-items: flex-start; }
.bubble { border-radius: 20px; padding: 9px 14px; overflow-wrap: anywhere; white-space: pre-wrap; max-width: 100%; }
.mine .bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.theirs .bubble { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble.gone { font-style: italic; opacity: .7; }
.bubble.media { padding: 4px; }
.bubble img { display: block; max-width: min(260px, 100%); max-height: 320px; border-radius: 16px; cursor: zoom-in; background: var(--surface-2); min-width: 120px; min-height: 80px; }
.bubble audio { width: min(240px, 60vw); height: 40px; display: block; }
.love-card { align-self: center; text-align: center; background: var(--surface-2); border-radius: 20px; padding: 14px 20px; margin: 6px 0; font-family: var(--display); font-style: italic; }
.love-card .big { color: var(--accent); font-size: 1.9rem; line-height: 1; display: block; animation: pop .6s ease; }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.meta { display: flex; align-items: center; gap: 6px; font-size: .72rem; color: var(--muted); margin-top: 2px; padding: 0 4px; }
.tick.read { color: var(--accent); font-weight: 700; }
.reactbtn { background: none; border: 0; color: var(--muted); font-size: .85rem; padding: 0 4px; line-height: 1; }
.reacts { display: flex; gap: 4px; margin-top: -6px; position: relative; z-index: 1; }
.reacts span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: .85rem; line-height: 1.5; }
.menu { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; margin-top: 4px; flex-wrap: wrap; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.menu button { background: none; border: 0; font-size: 1.25rem; padding: 2px 6px; border-radius: 999px; }
.menu button.del { font-size: .8rem; color: var(--danger); font-weight: 600; }

.composer { padding: 8px max(10px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px)); background: var(--surface); border-top: 1px solid var(--line); }
.composer .row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea { flex: 1; min-width: 0; resize: none; max-height: 120px; border-radius: 22px; padding: 10px 14px; line-height: 1.35; }
.icon { width: 42px; height: 42px; flex: none; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--accent); display: grid; place-items: center; font-size: 1.3rem; }
.icon.love { font-size: 1.4rem; }
.send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.rec { display: flex; align-items: center; gap: 10px; }
.rec .grow { flex: 1; color: var(--muted); font-size: .9rem; }
.rec .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: grid; place-items: center; z-index: 50; padding: 12px; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.viewer-close { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.2); color: #fff; font-size: 1.1rem; }
.toast { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .9rem; z-index: 60; max-width: 90vw; text-align: center; }
.hearts { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.hearts i { position: absolute; bottom: -30px; color: var(--accent); font-style: normal; animation: rise 2.4s ease-out forwards; }
@keyframes rise { to { transform: translateY(-110vh) rotate(18deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .hearts i, .love-card .big, .spinner, .rec .dot { animation: none; } }

/* ---------- v2: messenger ---------- */
.pane { display: flex; flex-direction: column; height: 100%; max-width: 760px; margin: 0 auto; background: var(--bg); position: relative; }
#chat { display: flex; }
.actions { display: flex; gap: 2px; }
.iconbtn { width: 42px; height: 42px; border: 0; border-radius: 50%; background: none; color: var(--fg); display: grid; place-items: center; flex: none; }
.iconbtn:hover { background: var(--surface-2); }
.iconbtn.small { width: 32px; height: 32px; font-size: .9rem; }
.who-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; text-align: left; min-width: 0; color: inherit; }
.who-btn:disabled { cursor: default; }
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-text .name { display: block; }
.badge-admin { font-family: var(--body); font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 2px 8px; vertical-align: middle; margin-left: 4px; }
.avatar.group { background: var(--accent-soft); color: var(--fg); font-size: 1.1rem; }
.avatar.off { opacity: .45; }
.convlist, .people, .checks { list-style: none; margin: 0; padding: 0; }
#convList { flex: 1; overflow-y: auto; }
.convrow { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px max(14px, env(safe-area-inset-left, 0px)); color: inherit; }
.convrow:hover { background: var(--surface-2); }
.convrow.static:hover { background: none; }
.cmid { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpreview { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpreview.bold { color: var(--fg); font-weight: 600; }
.cend { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.ctime { font-size: .75rem; color: var(--muted); }
.unread { background: var(--accent); color: var(--accent-ink); border-radius: 999px; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; font-size: .75rem; font-weight: 700; }
.fab { position: absolute; right: max(18px, env(safe-area-inset-right, 0px)); bottom: calc(22px + env(safe-area-inset-bottom, 0px)); width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.22); }
.body { flex: 1; overflow-y: auto; padding: 14px max(14px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 10px; }
.body > .convlist, .body > .people { margin: 0 calc(-1 * max(14px, env(safe-area-inset-left, 0px))); }
.rowbtn { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; font-weight: 600; text-align: left; }
.lbl { font-weight: 600; font-size: .9rem; margin-top: 6px; }
.muted { color: var(--muted); margin: 0; }
.body input[type=text], .body input[type=email], .body select, .sheet input[type=text] { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--fg); padding: 12px 14px; font: inherit; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input, .inline select { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500 !important; margin-top: 4px; }
.checks li { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.checks input, .check input { width: 20px; height: 20px; accent-color: var(--accent); }
.addbox { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; }
.addbox summary { font-weight: 600; cursor: pointer; padding: 4px 0; }
.addbox form { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.howto { margin: 8px 0 4px; padding-left: 20px; color: var(--muted); font-size: .9rem; }
.h2 { font-family: var(--display); font-size: 1.2rem; margin: 12px 0 0; }
.notes { margin: 0; padding-left: 18px; color: var(--muted); font-size: .92rem; display: flex; flex-direction: column; gap: 6px; }
.btn.danger { background: var(--danger); color: #fff; }
.danger-zone { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.sender { font-size: .75rem; font-weight: 700; margin: 0 6px 2px; }
.bubble .quote { display: flex; flex-direction: column; gap: 0; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--accent-soft); background: rgba(0,0,0,.07); border-radius: 8px; padding: 4px 8px; margin-bottom: 6px; font-size: .82rem; color: inherit; white-space: normal; }
.mine .bubble .quote { border-left-color: rgba(255,255,255,.7); background: rgba(255,255,255,.2); }
.bubble .quote span { opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.msg-row.flash .bubble { outline: 3px solid var(--accent); }
.bubble video { display: block; max-width: min(280px, 100%); max-height: 340px; border-radius: 16px; background: #000; }
.filecard { display: flex; align-items: center; gap: 10px; white-space: normal; }
.filecard .ftext { display: flex; flex-direction: column; min-width: 0; }
.filecard .ftext b { overflow: hidden; text-overflow: ellipsis; max-width: 160px; white-space: nowrap; }
.filecard small { opacity: .75; }
.mine .filecard .btn { background: var(--accent-ink); color: var(--accent); }
.replybar { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-left: 4px solid var(--accent); border-radius: 10px; padding: 6px 10px; margin-bottom: 6px; }
.replybar .rtext { flex: 1; min-width: 0; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reactbtn { opacity: .8; font-weight: 700; padding: 2px 6px; }
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 70; }
.sheet { background: var(--surface); width: min(520px, 100%); border-radius: 22px 22px 0 0; padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 4px; max-height: 85vh; overflow-y: auto; }
.sheet-title { text-align: center; color: var(--muted); font-size: .85rem; padding: 4px 6px 8px; }
.sheet-item { background: none; border: 0; text-align: left; padding: 14px 10px; border-radius: 12px; font-size: 1rem; width: 100%; }
.sheet-item:hover { background: var(--surface-2); }
.sheet-item.danger { color: var(--danger); font-weight: 600; }
.reactrow { display: flex; justify-content: space-around; padding: 6px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.reactrow button { background: none; border: 0; font-size: 1.7rem; border-radius: 50%; width: 46px; height: 46px; }
.reactrow button.on { background: var(--surface-2); }
.viewer { z-index: 80; }
#viewerBody { width: 100%; height: 100%; display: grid; place-items: center; }
#viewerBody iframe { width: 100%; height: calc(100% - 40px); border: 0; background: #fff; border-radius: 8px; }
.viewer-link { color: #fff; text-align: center; font-size: .9rem; }
.empty { align-self: center; text-align: center; color: var(--muted); margin: 40px auto; max-width: 30ch; }
select { appearance: auto; }

/* ---------- calls ---------- */
.call { position: fixed; inset: 0; z-index: 100; background: #1d0b15; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: calc(40px + env(safe-area-inset-top, 0px)) 16px calc(34px + env(safe-area-inset-bottom, 0px)); }
.call .remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #1d0b15; }
.call.audio .remote { width: 1px; height: 1px; opacity: 0; }
.call .local { position: absolute; right: 14px; top: calc(14px + env(safe-area-inset-top, 0px)); width: 28vw; max-width: 130px; aspect-ratio: 3/4; object-fit: cover; border-radius: 14px; border: 2px solid rgba(255,255,255,.7); background: #000; z-index: 2; transform: scaleX(-1); }
.call-top { position: relative; z-index: 1; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; text-shadow: 0 1px 8px rgba(0,0,0,.55); }
.avatar.big { width: 112px; height: 112px; font-size: 2.6rem; }
.call.live-video .avatar.big { display: none; }
.call-name { font-family: var(--display); font-size: 1.7rem; }
.call-status { opacity: .9; }
.call-bar { position: relative; z-index: 1; display: flex; gap: 18px; justify-content: center; align-items: center; }
.cbtn { width: 62px; height: 62px; border-radius: 50%; border: 0; background: rgba(255,255,255,.2); color: #fff; display: grid; place-items: center; }
.cbtn.end { background: #d92d4b; }
.cbtn.ok { background: #1fa65a; }
.cbtn[aria-pressed="true"] { background: #fff; color: #1d0b15; }
.cbtn .slash { display: none; }
.cbtn[aria-pressed="true"] .slash { display: inline; }
.callmsg { align-self: center; background: var(--surface-2); border-radius: 999px; padding: 6px 14px; font-size: .88rem; color: var(--muted); margin: 4px 0; }
.callmsg.missed { color: var(--danger); }
.callmsg .cdur { opacity: .8; }
