:root {
  --bg: #0b1d19;
  --bar: #0a1815;
  --surface: #12302a;
  --surface-2: #17392f;
  --bubble-in: #1b2f2b;
  --bubble-out: #0f6e56;
  --green: #1d9e75;
  --green-soft: #9fe1cb;
  --gold: #e3c27a;
  --gold-soft: #f3dba4;
  --text: #ecf3ef;
  --muted: #9cc3b4;
  --faint: #6e948a;
  --danger: #f08c7a;
  --border: #1c3a33;
  --radius: 14px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; overscroll-behavior: none; }
body { position: fixed; inset: 0; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.error { color: var(--danger); font-size: 14px; }
[hidden] { display: none !important; }

/* Screens */
.screen { position: absolute; top: var(--vvt, 0px); left: 0; right: 0; height: var(--vvh, 100%); display: flex; flex-direction: column; background: var(--bg); padding-top: var(--sat); }
.screen.center { align-items: center; justify-content: center; text-align: center; padding: 24px; padding-top: calc(24px + var(--sat)); }
.form-page { padding: 20px 20px calc(24px + var(--sab)); overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1; }
.form-page.tight { padding-top: 8px; }
.form-page.center-col { align-items: center; text-align: center; display: flex; flex-direction: column; }
.form-page h1 { font-size: 26px; margin: 8px 0 6px; }
.lead { font-size: 17px; margin: 8px 0 16px; max-width: 320px; }
.brand { font-size: 30px; letter-spacing: 0.3px; margin: 6px 0 8px; color: var(--gold-soft); }

/* Star mark */
.star-mark { width: 44px; height: 44px; margin: 0 auto 12px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23e3c27a' stroke-width='2.4' stroke-linejoin='round'%3E%3Crect x='18' y='18' width='28' height='28'/%3E%3Crect x='18' y='18' width='28' height='28' transform='rotate(45 32 32)'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat; }
.star-mark.big { width: 72px; height: 72px; }

/* Bars */
.bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 12px; min-height: 56px; background: var(--bar); border-bottom: 1px solid var(--border); flex: none; }
.bar-title { flex: 1; font-size: 20px; font-weight: 600; }
.brand-title { color: var(--gold-soft); font-size: 22px; letter-spacing: 0.2px; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: var(--green-soft); flex: none; }
.icon-btn:active { background: var(--surface); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.back::before { content: ""; width: 12px; height: 12px; border-left: 2.2px solid currentColor; border-bottom: 2.2px solid currentColor; transform: rotate(45deg); margin-left: 6px; }
.icon-btn.dismiss { width: 36px; height: 36px; font-size: 16px; color: var(--muted); }
.chat-bar { padding-left: 4px; }
.chat-head { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; padding: 4px 8px 4px 0; border-radius: 12px; }
.chat-head-text { display: flex; flex-direction: column; min-width: 0; }
.chat-head .row-name { font-size: 17px; }
.chat-head .row-sub { font-size: 13px; color: var(--green-soft); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 500; border: 1px solid var(--border); }
.btn.primary { background: var(--green); color: #052a20; border-color: transparent; width: 100%; margin-top: 8px; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn:active { filter: brightness(1.15); }
.btn[disabled] { opacity: 0.5; }
.row-btns { display: flex; gap: 10px; margin-top: 14px; }

/* Fields */
.field { display: block; margin: 0 0 16px; }
.field span { display: block; font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); outline: none; font-size: 17px; }
.field input:focus { border-color: var(--green); }

/* PIN */
.pin-dots { display: flex; gap: 14px; margin: 18px 0 8px; height: 20px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--gold); }
.pin-dots i.on { background: var(--gold); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; margin-top: 18px; }
.pin-pad button { height: 68px; border-radius: 50%; background: var(--surface); font-size: 26px; font-weight: 500; color: var(--text); }
.pin-pad button:active { background: var(--surface-2); }
.pin-pad .pad-text { background: none; font-size: 15px; color: var(--muted); }
.pin-pad button[data-k="del"] { background: none; color: var(--muted); font-size: 22px; }
.pin-pad[data-busy] button { opacity: 0.4; pointer-events: none; }

/* Lists & rows */
.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--sab); }
.list-heading { font-size: 13px; color: var(--faint); padding: 14px 16px 6px; text-transform: none; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; text-align: left; min-height: 68px; border-bottom: 1px solid var(--border); }
.row:active { background: var(--surface); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.row-name { font-size: 16.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 12.5px; color: var(--faint); flex: none; }
.row-time.unread { color: var(--green); }
.row-sub { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub.typing { color: var(--green-soft); }
.row-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--green); color: #052a20; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.row-action .row-name { color: var(--green-soft); }
.check { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--faint); flex: none; display: inline-flex; align-items: center; justify-content: center; }
.row.selected .check { background: var(--green); border-color: var(--green); }
.row.selected .check::after { content: ""; width: 6px; height: 11px; border-right: 2px solid #052a20; border-bottom: 2px solid #052a20; transform: rotate(45deg) translate(-1px,-1px); }
.row .tag { font-size: 12px; color: var(--gold); border: 1px solid var(--gold); border-radius: 8px; padding: 1px 6px; margin-left: 6px; }

/* Avatars */
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); color: var(--gold-soft); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 17px; flex: none; }
.avatar.group { background: #2c2a55; color: #cfcbf6; }
.avatar.invite { background: #3a2f18; color: var(--gold-soft); }
.avatar.large { width: 84px; height: 84px; font-size: 30px; }
.chat-head .avatar { width: 40px; height: 40px; font-size: 15px; }
.avatar.sm { width: 40px; height: 40px; font-size: 15px; }

/* Banners */
.banner { display: flex; align-items: center; gap: 10px; margin: 10px 12px 0; padding: 12px 6px 12px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); flex: none; }
.banner-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.banner-text strong { font-weight: 600; font-size: 15px; }
.banner-text span { font-size: 13.5px; color: var(--muted); }
.ios-share { display: inline-block; width: 13px; height: 15px; vertical-align: -2px; margin: 0 2px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 28'%3E%3Cg fill='none' stroke='%239cc3b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v15M6 9l6-6 6 6'/%3E%3Cpath d='M4 13v10a2 2 0 002 2h12a2 2 0 002-2V13'/%3E%3C/g%3E%3C/svg%3E") center/contain no-repeat; }
.empty { padding: 60px 30px; text-align: center; }

/* Messages area */
.messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 10px 10px 6px; position: relative;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%23e3c27a' stroke-opacity='0.075' stroke-width='1'%3E%3Crect x='18' y='18' width='28' height='28'/%3E%3Crect x='18' y='18' width='28' height='28' transform='rotate(45 32 32)'/%3E%3Cpath d='M32 0V12M32 52V64M0 32H12M52 32H64'/%3E%3Cpath d='M0 0L9 9M64 0L55 9M0 64L9 55M64 64L55 55'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 64px 64px; }
.messages.plain { background-image: none; }
.load-more { display: block; margin: 4px auto 10px; min-height: 36px; font-size: 14px; }
.day { text-align: center; margin: 12px 0 8px; }
.day span { display: inline-block; font-size: 12.5px; color: var(--green-soft); background: var(--bar); border: 1px solid var(--border); border-radius: 10px; padding: 3px 10px; }
.msg { display: flex; margin: 3px 0; }
.msg.out { justify-content: flex-end; }
.bubble { max-width: 82%; padding: 7px 10px 6px; border-radius: 16px; background: var(--bubble-in); border: 1px solid var(--border); position: relative; user-select: none; -webkit-user-select: none; }
.msg.in .bubble { border-bottom-left-radius: 5px; }
.msg.out .bubble { background: var(--bubble-out); border-color: transparent; border-bottom-right-radius: 5px; }
.msg.first .bubble { margin-top: 5px; }
.bubble .sender { font-size: 12.5px; font-weight: 600; color: var(--gold); margin-bottom: 2px; }
.bubble .text { white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 1.38; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1; }
.msg.out .meta { color: #bfe9d9; }
.meta .edited { font-style: italic; }
.ticks { display: inline-block; width: 18px; height: 11px; }
.ticks svg { width: 18px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ticks.read { color: var(--gold-soft); }
.ticks.pending { opacity: 0.6; }
.msg.pending .bubble { opacity: 0.7; }
.system { text-align: center; font-size: 13px; color: var(--muted); margin: 8px 0; }
.bubble.failed { border-color: var(--danger); }

.typing-line { padding: 2px 16px 4px; font-size: 13px; color: var(--green-soft); background: var(--bg); flex: none; }

/* Composer */
.composer { flex: none; background: var(--bar); border-top: 1px solid var(--border); padding: 6px 8px calc(8px + var(--sab)); }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea { flex: 1; resize: none; max-height: 132px; min-height: 44px; padding: 11px 14px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); outline: none; line-height: 1.35; }
.composer textarea:focus { border-color: var(--green); }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--green); color: #052a20; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; }
.send[disabled] { opacity: 0.45; }
.editing { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: var(--gold); padding: 2px 6px 4px 14px; }

/* Info & settings */
.info-head { text-align: center; padding: 16px 0 4px; }
.info-head h2 { margin-top: 10px; font-size: 22px; }
.info-retention { text-align: center; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 14px 4px; border-bottom: 1px solid var(--border); min-height: 60px; }
.setting-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.setting-main .l { font-size: 16px; }
.setting-main .s { font-size: 13.5px; color: var(--muted); }
.setting .chev { width: 10px; height: 10px; border-right: 2px solid var(--faint); border-top: 2px solid var(--faint); transform: rotate(45deg); flex: none; margin-right: 8px; }
.setting.danger .l { color: var(--danger); }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--surface-2); position: relative; flex: none; border: 1px solid var(--border); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.switch.on { background: var(--green); border-color: var(--green); }
.switch.on::after { background: #052a20; transform: translateX(18px); }
.settings-section { font-size: 13px; color: var(--gold); padding: 22px 4px 4px; }

/* Share (QR) */
.qr { background: #fff; padding: 14px; border-radius: 16px; margin: 10px auto; display: inline-block; }
.qr svg { display: block; width: 240px; height: 240px; }
.link-box { font-size: 13px; color: var(--muted); word-break: break-all; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-top: 8px; max-width: 100%; }

/* Sheet & toast */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; z-index: 50; }
.sheet { width: 100%; background: var(--surface); border-radius: 18px 18px 0 0; padding: 8px 8px calc(12px + var(--sab)); animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } .switch::after { transition: none; } }
.sheet .sheet-title { font-size: 14px; color: var(--muted); padding: 10px 14px 6px; }
.sheet .sheet-msg { font-size: 16px; padding: 12px 14px 14px; }
.sheet button.item { display: block; width: 100%; text-align: left; padding: 15px 14px; font-size: 17px; border-radius: 12px; }
.sheet button.item:active { background: var(--surface-2); }
.sheet button.item.danger { color: var(--danger); }
.sheet button.item.cancel { color: var(--muted); text-align: center; margin-top: 4px; }
.sheet .field { margin: 8px 6px 4px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%); background: var(--surface-2); color: var(--text); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; border: 1px solid var(--border); z-index: 60; max-width: 90vw; text-align: center; }

/* Wider screens: keep it phone-shaped in the middle */
@media (min-width: 720px) {
  body { background: #071410; }
  .screen { left: 50%; transform: translateX(-50%); width: 480px; max-width: 100%; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .sheet-backdrop { justify-content: center; }
  .sheet { width: 480px; border-radius: 18px; margin-bottom: 40px; }
}

/* Welcome paste box & iOS steps */
.paste-box { width: 100%; max-width: 340px; margin: 6px auto 10px; display: flex; flex-direction: column; gap: 8px; }
.paste-box input { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); outline: none; font-size: 15px; }
.paste-box input:focus { border-color: var(--green); }
.paste-box .btn.primary { margin-top: 0; }
.steps { padding-left: 22px; margin: 4px 0 18px; color: var(--text); }
.steps li { margin: 8px 0; }
.steps strong { color: var(--gold-soft); font-weight: 600; }
#ios-continue { color: var(--green-soft); }

/* ===== v2: attachments, replies, reactions, search, viewer ===== */
.send.mic { background: var(--surface-2); color: var(--green-soft); }
.composer-row.has-text #btn-mic, .composer-row:not(.has-text) #btn-send { display: none; }
.reply-bar { gap: 6px; padding-left: 10px; border-left: 3px solid var(--gold); margin: 0 4px 6px; color: var(--text); }
.reply-bar .reply-who { color: var(--gold); font-weight: 600; white-space: nowrap; }
.reply-bar .reply-text { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recording { display: flex; align-items: center; gap: 10px; padding: 4px 2px 4px 10px; min-height: 44px; }
.recording #rec-time { font-variant-numeric: tabular-nums; font-size: 16px; min-width: 42px; }
.recording .muted { flex: 1; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.bubble.media { padding: 4px; max-width: 78%; }
.bubble.media .sender { padding: 3px 6px 0; }
.bubble.media .caption { padding: 4px 6px 0; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; line-height: 1.38; }
.bubble.media .meta { padding: 0 6px 2px; }
.thumb { position: relative; display: block; width: 100%; border-radius: 12px; overflow: hidden; background: var(--surface-2); min-width: 160px; }
.thumb img, .thumb video { display: block; width: 100%; height: auto; max-height: 360px; object-fit: cover; }
.thumb img.blur { filter: blur(6px); transform: scale(1.04); }
.thumb .overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px; background: rgba(4, 20, 16, 0.35); color: #fff; font-size: 14px; }
.thumb .overlay .play { width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; }
.thumb .overlay .play svg { width: 24px; height: 24px; fill: #fff; margin-left: 3px; }
.thumb .overlay.expired { background: rgba(4, 20, 16, 0.75); color: var(--muted); }
.progress { width: 70%; height: 4px; background: rgba(255,255,255,0.25); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.2s; }
.filecard { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 6px; min-width: 200px; }
.filecard .ficon { width: 42px; height: 42px; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.filecard .fmain { min-width: 0; flex: 1; }
.filecard .fname { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filecard .fsize { font-size: 12.5px; color: var(--muted); }
.msg.out .filecard .fsize { color: #bfe9d9; }
.filecard .fbtn { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.08); color: var(--green-soft); display: flex; align-items: center; justify-content: center; flex: none; }
.filecard .fbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.audio { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 6px; min-width: 220px; }
.audio .fbtn { width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #052a20; display: flex; align-items: center; justify-content: center; flex: none; }
.audio .fbtn svg { width: 18px; height: 18px; fill: currentColor; }
.audio .track { flex: 1; height: 4px; background: rgba(255,255,255,0.2); border-radius: 2px; position: relative; }
.audio .track i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--gold); border-radius: 2px; }
.audio .dur { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.msg.out .audio .dur { color: #bfe9d9; }
.expiry { font-size: 11px; color: var(--faint); }
.msg.out .expiry { color: #9fd7c3; }
.expiry.kept { color: var(--gold); }
.quote { display: block; border-left: 3px solid var(--gold); background: rgba(0,0,0,0.18); border-radius: 8px; padding: 5px 8px; margin: 0 0 5px; font-size: 13.5px; }
.bubble.media .quote { margin: 4px 4px 2px; }
.quote .qwho { color: var(--gold); font-weight: 600; font-size: 12.5px; }
.quote .qtext { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.msg.out .quote .qtext { color: #cfe9df; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.msg.out .reacts { justify-content: flex-end; }
.reacts .pill { font-size: 13px; padding: 2px 7px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.reacts .pill.mine { border-color: var(--gold); }
.emoji-row { display: flex; justify-content: space-around; padding: 8px 6px 12px; }
.emoji-row button { font-size: 28px; width: 46px; height: 46px; border-radius: 50%; }
.emoji-row button.on { background: var(--surface-2); outline: 2px solid var(--gold); }
.msg.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--gold); } 100% { box-shadow: none; } }
.search-input { flex: 1; min-width: 0; height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); font-size: 16px; }
.search-input:focus { border-color: var(--green); outline: none; }
.search-note { padding: 8px 16px 0; margin: 0; }
.result .row-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.viewer { background: #000; }
.viewer-bar { background: rgba(0,0,0,0.6); border: 0; position: absolute; top: 0; left: 0; right: 0; z-index: 2; padding-top: calc(6px + var(--sat)); }
.viewer-body { flex: 1; display: flex; align-items: center; justify-content: center; overflow: auto; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.storage-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.storage-bar i { display: block; height: 100%; background: var(--green); }
.storage-bar i.warn { background: var(--gold); }
.storage-bar i.full { background: var(--danger); }
.code-box { font-family: ui-monospace, Menlo, monospace; font-size: 17px; letter-spacing: 1px; line-height: 1.7; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin: 10px 0; word-spacing: 6px; }
.sheet .sheet-msg { white-space: pre-wrap; }
.uploading { font-size: 12px; color: var(--gold-soft); padding: 2px 6px; }

/* ===== v3 ===== */
.offline-bar { flex: none; background: #3a2f18; color: var(--gold-soft); font-size: 13px; padding: 7px 14px; text-align: center; border-bottom: 1px solid var(--border); }
.meta .queued { color: var(--gold-soft); font-style: italic; }
.bubble.failed .queued { color: var(--danger); font-style: normal; font-weight: 600; }
.info-table { padding: 4px 8px 10px; }
.info-table .ir { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.info-table .ik { font-size: 12.5px; color: var(--muted); }
.info-table .iv { font-size: 15px; }
.preview { background: #000; }
.preview .bar { background: rgba(0,0,0,0.7); }
.preview-main { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; min-height: 0; }
.preview-main img, .preview-main video { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-main .fileprev { color: var(--muted); text-align: center; padding: 20px; }
.preview-strip { flex: none; display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto; background: rgba(0,0,0,0.7); }
.preview-strip button { width: 56px; height: 56px; border-radius: 8px; overflow: hidden; flex: none; border: 2px solid transparent; background: var(--surface-2); color: var(--muted); font-size: 22px; }
.preview-strip button.on { border-color: var(--gold); }
.preview-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-strip .remove { position: relative; }
.system { text-align: center; font-size: 12.5px; color: var(--muted); margin: 8px 16px; }
.system::before { content: ''; }
#s-notify .btn.ghost.small { width: auto; padding: 8px 18px; }
.bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.bubble .text { -webkit-user-select: text; user-select: text; }
/* ===== 3.1: media UX ===== */
.thumb .overlay.light { background: transparent; align-items: flex-end; justify-content: flex-end; padding: 8px; }
.thumb .overlay.light .dlbadge { background: rgba(0,0,0,0.55); color: #fff; font-size: 12.5px; padding: 4px 9px; border-radius: 12px; }
.viewer-body { position: relative; }
.viewer-body .vthumb { max-width: 100%; max-height: 100%; object-fit: contain; filter: brightness(0.7); }
.viewer-body video { background: #000; }
.vload { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 70%; max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: #fff; font-size: 14px; text-shadow: 0 1px 3px #000; pointer-events: none; }
.vload .progress { width: 100%; }
.icon-btn.busy, .fbtn.busy { opacity: 0.5; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 1; } }
/* ===== 4.0: status pill, transfers, viewer nav ===== */
.status-pill { flex: none; font-size: 12px; padding: 4px 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-pill.live { color: #052a20; background: var(--green); border-color: var(--green); }
.status-pill.ok { color: var(--green-soft); }
.status-pill.stale { color: var(--gold-soft); border-color: var(--gold); }
.status-pill.off { color: #fff; background: var(--danger); border-color: var(--danger); }
.status-pill.conn { color: var(--muted); }
.status-pill.compact { max-width: 34vw; }
.row-btns { display: flex; gap: 8px; margin-top: 8px; }
.row-btns .btn.small { width: auto; }
.viewer-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; font-size: 34px; color: #fff; background: rgba(0,0,0,0.35); border-radius: 10px; z-index: 3; }
.viewer-nav.prev { left: 6px; } .viewer-nav.next { right: 6px; }
.viewer-note { position: absolute; bottom: calc(14px + var(--sab)); left: 0; right: 0; text-align: center; color: #ddd; font-size: 12.5px; text-shadow: 0 1px 3px #000; z-index: 3; pointer-events: none; }
#owner-body .ir { padding: 10px 16px; }
/* the thumbnail shown while a photo loads sits underneath, never beside */
.viewer-body .vthumb { position: absolute; inset: 0; margin: auto; z-index: 0; }
.viewer-body img:not(.vthumb), .viewer-body video { position: relative; z-index: 1; }
