:root {
  --ink: #111; --muted: #6b6b6b; --line: #e6e6e6; --bg: #fff; --accent: #b3121f;
  --dark: #0f1115; --dark2: #1b1e25; --me: #2563eb; --them: #2a2e37;
  --safe-top: env(safe-area-inset-top); --safe-bot: env(safe-area-inset-bottom);
  font-size: 16px;
}
html.large { font-size: 19px; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- news ---------- */
.mast { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: calc(var(--safe-top) + 10px) 16px 0; border-bottom: 1px solid var(--line); }
.mast-row { display: flex; align-items: center; justify-content: space-between; }
.brand { font-family: Georgia, "Times New Roman", serif; font-size: 1.9rem; font-weight: 700; margin: 0; letter-spacing: -.5px; }
.brand.small { font-size: 1.25rem; }
.icon-btn { padding: 8px; color: var(--muted); font-size: 1.4rem; line-height: 1; }
.dateline { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; padding: 2px 0 8px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tabs { display: flex; gap: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 0; font-size: .92rem; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; }
.tab.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.feed { padding: 0 16px; }
.story { display: block; padding: 16px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.story h3 { margin: 0 0 6px; font-family: Georgia, "Times New Roman", serif; font-size: 1.12rem; line-height: 1.3; font-weight: 600; }
.story.lead h3 { font-size: 1.45rem; }
.story .meta { color: var(--muted); font-size: .8rem; }
.story .meta b { color: var(--accent); font-weight: 600; }
.skeleton { height: 64px; margin: 16px 0; border-radius: 6px; background: linear-gradient(90deg,#f1f1f1,#f8f8f8,#f1f1f1); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }
.foot { color: var(--muted); font-size: .75rem; text-align: center; padding: 24px 16px calc(var(--safe-bot) + 24px); }

/* sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; z-index: 20; }
.sheet-card { background: #fff; width: 100%; border-radius: 16px 16px 0 0; padding: 20px 20px calc(var(--safe-bot) + 20px); }
.sheet-card h2 { margin: 0 0 12px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.hint { color: var(--muted); font-size: .85rem; }

/* ---------- shared dark layers ---------- */
.layer { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column; }
.layer.dark { background: var(--dark); color: #f2f2f2; }
.layer.dark .hint { color: #9aa0aa; }
.btn { background: #f2f2f2; color: #111; border-radius: 12px; padding: 14px 18px; font-weight: 600; margin: 8px 0; }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; color: inherit; border: 1px solid #3a3f4a; }
.link-btn { color: #8ab4ff; padding: 12px; display: block; margin: 0 auto; }
.link-btn.danger { color: #e5484d; }

/* lock */
.lock-wrap { margin: auto; width: 100%; max-width: 340px; text-align: center; padding: 20px; }
.lock-title { font-size: 1.1rem; margin-bottom: 18px; }
.dots { display: flex; justify-content: center; gap: 12px; min-height: 16px; }
.dots i { width: 13px; height: 13px; border-radius: 50%; background: #f2f2f2; display: block; }
.dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-10px) } 75% { transform: translateX(10px) } }
.lock-msg { min-height: 22px; margin: 10px 0; color: #ff8a8a; font-size: .9rem; }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px; justify-content: center; margin: 10px 0 18px; }
.pad button { width: 76px; height: 76px; border-radius: 50%; background: var(--dark2); font-size: 1.7rem; }
.pad button:active { background: #3a3f4a; }
.pad button.fn { background: transparent; font-size: 1.2rem; }

/* setup */
.setup-wrap { margin: auto; width: 100%; max-width: 420px; padding: calc(var(--safe-top) + 20px) 22px calc(var(--safe-bot) + 20px); overflow-y: auto; }
.setup-wrap h2 { margin-top: 0; }
.setup-wrap input, .setup-wrap textarea { width: 100%; font: inherit; padding: 14px; border-radius: 12px; border: 1px solid #3a3f4a; background: var(--dark2); color: #fff; }
.setup-wrap input { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
.qr { background: #fff; padding: 14px; border-radius: 12px; width: fit-content; margin: 10px auto; }
.qr img, .qr svg { display: block; width: 240px; height: 240px; image-rendering: pixelated; }
video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 1; object-fit: cover; }
.safety { font-size: 2.6rem; font-weight: 700; letter-spacing: .12em; text-align: center; padding: 24px 0; font-variant-numeric: tabular-nums; }

/* ---------- chat ---------- */
#chat { background: #0b0d11; color: #eee; }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: calc(var(--safe-top) + 8px) 12px 8px; border-bottom: 1px solid #222; }
.chat-head .brand { color: #eee; }
.menu-card { background: var(--dark2); padding: 6px 16px; border-bottom: 1px solid #222; }
.menu-card .row { border-color: #2c313b; }
.menu-card select { font: inherit; background: #0b0d11; color: #eee; border: 1px solid #3a3f4a; border-radius: 8px; padding: 6px; }
.msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 18px; line-height: 1.35; white-space: pre-wrap; word-wrap: break-word; transition: opacity .6s; }
.bubble.me { align-self: flex-end; background: var(--me); color: #fff; border-bottom-right-radius: 5px; }
.bubble.them { align-self: flex-start; background: var(--them); border-bottom-left-radius: 5px; }
.bubble .st { display: block; font-size: .68rem; opacity: .7; margin-top: 3px; text-align: right; }
.bubble.fade { opacity: 0; }
.sys { align-self: center; color: #7b818c; font-size: .78rem; padding: 8px; text-align: center; }
.composer { display: flex; gap: 8px; padding: 8px 10px calc(var(--safe-bot) + 8px); border-top: 1px solid #222; background: #0b0d11; }
.composer textarea { flex: 1; resize: none; font: inherit; color: #eee; background: #1b1e25; border: 1px solid #2c313b; border-radius: 20px; padding: 9px 14px; max-height: 120px; }
.send { width: 42px; height: 42px; border-radius: 50%; background: var(--me); color: #fff; font-size: 1.1rem; flex: none; align-self: flex-end; }

/* ---------- v2: devices, attachments, voice notes, calls ---------- */
.head-actions { display: flex; align-items: center; gap: 2px; }
.icon-btn.light { color: #cfd3da; }
.row.col { flex-direction: column; align-items: stretch; }
.dev-list { list-style: none; margin: 6px 0 0; padding: 0; font-size: .88rem; }
.dev-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; color: #c9cdd4; }
.dev-list li small { color: #7b818c; }
.dev-list button { color: #e5484d; font-size: .82rem; }
.composer { align-items: flex-end; }
.round { width: 40px; height: 40px; border-radius: 50%; background: #1b1e25; color: #cfd3da; flex: none; font-size: 1.3rem; display: grid; place-items: center; }
.attach-menu { display: flex; flex-direction: column; background: var(--dark2); border-top: 1px solid #222; }
.attach-menu button { text-align: left; padding: 14px 18px; border-bottom: 1px solid #2c313b; color: #e7e9ee; }
.rec-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px calc(var(--safe-bot) + 10px); border-top: 1px solid #222; background: #0b0d11; }
.rec-bar #rec-time { flex: 1; font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e5484d; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2 } }
.bubble.media { padding: 4px; }
.bubble.media .st { padding: 0 8px 4px; }
.bubble img, .bubble video { display: block; max-width: 100%; max-height: 360px; border-radius: 14px; }
.bubble audio { display: block; width: 240px; max-width: 100%; }
.bubble .file { display: flex; gap: 10px; align-items: center; padding: 6px 8px; color: inherit; text-decoration: none; }
.bubble .file .ico { font-size: 1.6rem; }
.bubble .file small { display: block; opacity: .75; }
.bubble .loading { padding: 8px 10px; opacity: .8; font-size: .9rem; }

.call { background: #000; color: #fff; z-index: 30; align-items: center; justify-content: center; }
#remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; aspect-ratio: auto; border-radius: 0; }
#local-video { position: absolute; right: 14px; top: calc(var(--safe-top) + 14px); width: 28vw; max-width: 140px; aspect-ratio: 3/4; height: auto; object-fit: cover; border-radius: 12px; z-index: 2; transform: scaleX(-1); }
.call-info { position: absolute; top: calc(var(--safe-top) + 40px); left: 0; right: 0; text-align: center; z-index: 1; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.call-title { font-size: 1.5rem; font-weight: 600; }
.call-status { color: #c9cdd4; margin-top: 6px; font-variant-numeric: tabular-nums; }
.call-bar { position: absolute; bottom: calc(var(--safe-bot) + 30px); left: 0; right: 0; display: flex; justify-content: center; gap: 18px; z-index: 2; }
.cbtn { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.18); font-size: 1.4rem; backdrop-filter: blur(6px); }
.cbtn.off { background: #fff; filter: grayscale(1); }
.cbtn.end { background: #e5484d; }
.cbtn.ok { background: #2fb36a; }
.cbtn.big { width: 72px; height: 72px; font-size: 1.7rem; }
.ring { background: #111418; }
.ring-wrap { text-align: center; }
.ring-actions { display: flex; gap: 34px; justify-content: center; margin-top: 70px; }
#setup { z-index: 12; }
#lock { z-index: 13; }
