:root {
  color-scheme: light dark;
  --ink: #292728;
  --muted: #706b68;
  --meta: #7e7773;
  --line: #e3dfda;
  --line-strong: #d3cdc7;
  --surface: #fbfaf8;
  --surface-strong: #ffffff;
  --app-bg: #efede9;
  --chat-bg: #f4f2ef;
  --soft: #f1eeeb;
  --soft-strong: #e8e2dc;
  --control-bg: #f7f5f2;
  --accent: #fb7299;
  --accent-solid: #fb7299;
  --accent-dark: #f0648d;
  --accent-ink: #8a2446;
  --accent-soft: #fff0f4;
  --on-accent: #ffffff;
  --mine-bg: #fb7299;
  --mine-bg-hover: #fb7299;
  --mine-ink: #ffffff;
  --unread-bg: #d82f49;
  --unread-ink: #ffffff;
  --focus: #8a2446;
  --danger: #9c3947;
  --danger-solid: #9c3947;
  --danger-dark: #82303b;
  --danger-soft: #f3e5e7;
  --avatar-bg: #ffd3e0;
  --avatar-ink: #8a2446;
  --focus-ring: rgba(251, 114, 153, .24);
  --glass: rgba(251, 250, 248, .92);
  --overlay: rgba(29, 26, 25, .46);
  --shadow-soft: 0 8px 24px rgba(38, 32, 30, .08);
  --shadow-panel: 0 24px 70px rgba(31, 26, 24, .18);
  --camouflage-ink: #222222;
  --camouflage-copy: #555555;
  --camouflage-code: #666666;
  --camouflage-signature: #888888;
  --camouflage-line: #dddddd;
  --camouflage-bg: #ffffff;
  --camouflage-gate: #333333;
  --camouflage-color-scheme: light;
  --vh: 100vh;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #f1efec;
    --muted: #aaa5a1;
    --meta: #aaa39f;
    --line: #373431;
    --line-strong: #48433f;
    --surface: #201f1e;
    --surface-strong: #252321;
    --app-bg: #171716;
    --chat-bg: #1a1918;
    --soft: #2a2826;
    --soft-strong: #35312e;
    --control-bg: #272522;
    --accent: #fb7299;
    --accent-solid: #fb7299;
    --accent-dark: #f0648d;
    --accent-ink: #ffc0d2;
    --accent-soft: #482531;
    --on-accent: #ffffff;
    --mine-bg: #fb7299;
    --mine-bg-hover: #fb7299;
    --mine-ink: #ffffff;
    --unread-bg: #d82f49;
    --unread-ink: #ffffff;
    --focus: #fb7299;
    --danger: #e07a88;
    --danger-solid: #98404e;
    --danger-dark: #7d3340;
    --danger-soft: #3d292d;
    --avatar-bg: #542233;
    --avatar-ink: #ffc0d2;
    --focus-ring: rgba(251, 114, 153, .30);
    --glass: rgba(32, 31, 30, .92);
    --overlay: rgba(5, 5, 5, .72);
    --shadow-soft: 0 10px 28px rgba(0, 0, 0, .22);
    --shadow-panel: 0 28px 80px rgba(0, 0, 0, .42);
    --camouflage-ink: #e8eaed;
    --camouflage-copy: #bdc1c6;
    --camouflage-code: #bdc1c6;
    --camouflage-signature: #9aa0a6;
    --camouflage-line: #3c4043;
    --camouflage-bg: #202124;
    --camouflage-gate: #e8eaed;
    --camouflage-color-scheme: dark;
  }
}

@supports (height: 100dvh) { :root { --vh: 100dvh; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; color: var(--ink); background: var(--app-bg); }
body { min-width: 320px; }
button, input, textarea { font: inherit; }
button { min-width: 40px; min-height: 40px; cursor: pointer; }
button:disabled { cursor: default; opacity: .58; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; outline: 0; color: var(--ink); background: var(--control-bg); }
input { height: 44px; padding: 0 12px; }
textarea { min-height: 40px; max-height: 120px; padding: 9px 11px; overflow-x: hidden; overflow-y: hidden; resize: none; line-height: 1.45; scrollbar-width: none; -ms-overflow-style: none; }
textarea::-webkit-scrollbar { display: none; width: 0; height: 0; }
input:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--focus-ring); }
button:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
label { display: grid; gap: 6px; margin: 12px 0; color: var(--muted); font-size: 13px; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.primary, .secondary, .ghost, .danger { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 14px; border: 1px solid transparent; border-radius: 10px; font-size: 13px; font-weight: 650; }
.primary { width: 100%; color: var(--on-accent); background: var(--accent-solid); }
.primary:hover { background: var(--accent-dark); }
.secondary { color: var(--accent-ink); border-color: var(--line-strong); border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); background: var(--accent-soft); }
.secondary:hover { border-color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.ghost { color: var(--muted); border-color: var(--line); background: var(--surface); }
.ghost:hover { color: var(--ink); background: var(--soft); }
.danger { color: #fff; background: var(--danger-solid); }
.danger:hover { background: var(--danger-dark); }
.compact-button { min-height: 36px; margin-top: 8px; padding: 0 12px; font-size: 12px; }
.form-error { min-height: 20px; margin: 10px 0 0 !important; color: var(--danger) !important; font-size: 13px; }

/* The public disguise stays plain while following the device light/dark preference. */
.camouflage { position: relative; min-height: var(--vh); overflow: hidden; color: var(--camouflage-ink); background: var(--camouflage-bg); color-scheme: var(--camouflage-color-scheme); }
.error-card { width: min(680px, calc(100% - 48px)); margin: 12vh auto 0; font-family: Arial, sans-serif; }
.error-code { margin: 0; color: var(--camouflage-code); font-size: clamp(56px, 13vw, 112px); font-weight: 700; letter-spacing: -.06em; }
.error-card h1 { margin: 0 0 18px; font-size: clamp(25px, 5vw, 42px); font-weight: 500; }
.error-card p { color: var(--camouflage-copy); font-size: 15px; }
.error-card hr { margin-top: 32px; border: 0; border-top: 1px solid var(--camouflage-line); }
.server-signature { color: var(--camouflage-signature) !important; font-size: 12px !important; }
.gate-icons { position: absolute; inset: 0; pointer-events: none; }
.gate-icons [data-gate] { position: absolute; width: 46px; height: 46px; display: grid; place-items: center; padding: 0; border: 0; outline: 0; color: var(--camouflage-gate); background: transparent; box-shadow: none; opacity: .30; filter: grayscale(1); font-size: 18px; pointer-events: auto; cursor: default; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.gate-icons [data-gate]:hover, .gate-icons [data-gate]:active, .gate-icons [data-gate]:focus, .gate-icons [data-gate]:focus-visible { border: 0; outline: 0; background: transparent; box-shadow: none; }

.auth-shell { width: 100%; height: var(--vh); min-height: 0; display: grid; place-items: center; overflow-y: auto; overscroll-behavior: contain; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); background: var(--app-bg); }
.auth-card { width: min(380px, 100%); margin: auto; padding: 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-panel); }
.auth-mark { width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: 21px; border-radius: 11px; color: var(--accent-ink); background: var(--accent-soft); }
.auth-mark .icon { width: 20px; height: 20px; }
.auth-card h1 { margin: 0 0 7px; font-size: 24px; letter-spacing: -.025em; }
.auth-card > p { margin: 0 0 22px; color: var(--muted); font-size: 14px; line-height: 1.6; }

.app-shell { width: 100%; height: var(--vh); display: grid; grid-template-columns: 320px minmax(0, 1fr); background: var(--app-bg); }
.sidebar { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--surface); }
.sidebar-header, .chat-header { min-height: 68px; display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.sidebar-header { justify-content: space-between; }
.sidebar-profile { min-width: 0; display: flex; align-items: center; gap: 10px; }
.sidebar-my-avatar { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; background: var(--avatar-bg); }
.sidebar-identity { min-width: 0; }
.sidebar-header h1 { margin: 1px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; letter-spacing: -.02em; }
.eyebrow, .modal-eyebrow { margin: 0; color: var(--muted); text-transform: uppercase; font-size: 9px; font-weight: 650; letter-spacing: .14em; }
.icon-button { flex: 0 0 auto; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 10px; color: var(--muted); background: transparent; }
.icon-button:hover { color: var(--ink); background: var(--soft); }
.friend-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 10px 12px 6px; }
.friend-actions button { min-width: 0; min-height: 40px; padding: 0 9px; font-size: 12px; }
.friend-actions .icon { width: 16px; height: 16px; }
.friend-list-title { display: flex; align-items: center; gap: 6px; margin: 10px 14px 6px; color: var(--muted); font-size: 11px; font-weight: 650; }
.friend-list-title small { min-width: 18px; height: 18px; display: inline-grid; place-items: center; border-radius: 999px; color: var(--accent-ink); background: var(--accent-soft); font-size: 9px; }
.friend-list { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 0 8px 78px; }
.friend-row { position: relative; width: 100%; min-height: 62px; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px; border: 0; border-radius: 12px; text-align: left; color: inherit; background: transparent; }
.friend-row + .friend-row { margin-top: 2px; }
.friend-row:hover { background: var(--soft); background: color-mix(in srgb, var(--soft) 72%, transparent); }
.friend-row.active { background: var(--soft); box-shadow: inset 3px 0 var(--accent); }
.friend-row canvas { width: 42px; height: 42px; border-radius: 50%; background: var(--avatar-bg); }
.friend-row strong, .friend-row span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-row strong { font-size: 14px; }
.friend-row span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.unread-badge { min-width: 20px; height: 20px; display: inline-grid; place-items: center; padding: 0 6px; border-radius: 999px; color: var(--unread-ink); background: var(--unread-bg); font-size: 10px; line-height: 1; font-weight: 700; }
.empty-state { margin: auto; padding: 28px; text-align: center; color: var(--muted); }
.empty-state span, .empty-state small { display: block; }
.empty-state small { margin-top: 6px; line-height: 1.5; }

.chat-panel { min-width: 0; min-height: 0; background: var(--chat-bg); }
.chat-placeholder { height: 100%; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); }
.placeholder-symbol { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 8px; border-radius: 14px; color: var(--accent-ink); background: var(--accent-soft); }
.placeholder-symbol .icon { width: 21px; height: 21px; }
.chat-active { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; }
.chat-header { background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.avatar { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; background: var(--avatar-bg); }
.chat-person { min-width: 0; flex: 1; }
.chat-person strong, .chat-person span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-person strong { font-size: 15px; }
.chat-person span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.message-area { position: relative; min-height: 0; overflow: hidden; background: transparent; }
.message-list { width: 100%; height: 100%; min-height: 0; overflow-y: auto; overflow-anchor: none; overscroll-behavior: contain; padding: 20px 28px; padding-inline: max(24px, calc((100% - 900px) / 2)); scroll-behavior: auto; }
.message-list.instant-scroll { scroll-behavior: auto !important; }
.history-loader { display: block; margin: 0 auto 14px; color: var(--muted); font-size: 12px; line-height: 24px; text-align: center; }
.message { position: relative; max-width: min(74%, 620px); margin: 8px 0; }
.message.mine { margin-left: auto; }
.message-row { max-width: 100%; display: flex; align-items: flex-start; gap: 8px; }
.message.mine .message-row { flex-direction: row-reverse; }
.message-content { min-width: 0; max-width: calc(100% - 40px); display: flex; flex-direction: column; align-items: flex-start; }
.message.mine .message-content { align-items: flex-end; }
.message-avatar { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%; background: var(--avatar-bg); }
.bubble { position: relative; max-width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px 14px 14px 14px; color: var(--ink); background: var(--surface); box-shadow: 0 1px 5px rgba(36, 31, 29, .04); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.mine .bubble { color: var(--mine-ink); border-color: transparent; border-radius: 14px 7px 14px 14px; background: var(--mine-bg); }
.message-text { display: block; }
.message-reply-preview { width: 100%; min-width: 0; display: block; margin: 0 0 7px; padding: 6px 8px; overflow: hidden; border: 0; border-left: 2px solid var(--accent); border-left-color: color-mix(in srgb, var(--accent) 64%, transparent); border-radius: 6px; color: var(--accent-ink); background: var(--accent-soft); text-align: left; font: inherit; line-height: 1.35; cursor: pointer; }
.message-reply-preview strong, .message-reply-preview span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-reply-preview strong { margin-bottom: 2px; font-size: 11px; }
.message-reply-preview span { color: var(--muted); font-size: 11px; }
.mine .message-reply-preview { border-left-color: rgba(255, 255, 255, .62); color: var(--mine-ink); background: rgba(255, 255, 255, .16); }
.mine .message-reply-preview span { color: rgba(255, 255, 255, .82); }
.image-bubble { overflow: hidden; padding: 0; background: var(--soft-strong); cursor: zoom-in; }
.image-bubble .message-reply-preview { width: calc(100% - 16px); margin: 8px 8px 0; }
.image-bubble canvas { display: block; max-width: min(360px, 68vw); max-height: 360px; object-fit: contain; }
.image-bubble canvas[role="button"] { outline-offset: -3px; }
.sticker-bubble, .mine .sticker-bubble { padding: 0; border-color: transparent; background: transparent; box-shadow: none; cursor: zoom-in; }
.sticker-bubble .message-reply-preview { margin-bottom: 6px; background: var(--surface); }
.sticker-bubble .message-sticker-image { display: block; width: 144px; height: 144px; max-width: 38vw; max-height: 38vw; object-fit: contain; }
.sticker-bubble .message-sticker-image[role="button"] { outline-offset: 3px; cursor: zoom-in; }
.message-sticker-image[data-loading="true"] { border-radius: 12px; background: var(--soft-strong); }
.message-meta { margin: 4px 5px 0; color: var(--meta); font-size: 10px; line-height: 1.35; }
.message-actions-trigger { flex: 0 0 auto; width: 30px; min-width: 30px; height: 30px; min-height: 30px; display: grid; place-items: center; margin-top: 2px; padding: 0; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--surface); opacity: 0; pointer-events: none; transform: translateX(-4px); transition: opacity .18s ease, transform .18s ease; }
.mine .message-actions-trigger { transform: translateX(4px); }
.message-actions-trigger .icon { width: 16px; height: 16px; }
.message-actionable:hover .message-actions-trigger, .message-actions-trigger:focus-visible { opacity: 1; pointer-events: auto; transform: translateX(0); }
.message.message-target-flash::before { content: ""; position: absolute; z-index: 0; top: -7px; bottom: -7px; left: var(--target-flash-left, 0); width: var(--target-flash-width, 100%); pointer-events: none; border-radius: 15px; background: var(--accent-soft); background: color-mix(in srgb, var(--accent) 18%, transparent); animation: message-target-opacity 1s ease-out both; }
.message.message-target-flash .message-row { position: relative; z-index: 1; }
@keyframes message-target-opacity { 0%, 100% { opacity: 0; } 16%, 78% { opacity: 1; } }
.message-time-separator { display: block; width: 100%; margin: 18px 0 11px; color: var(--meta); text-align: center; font-size: 11px; line-height: 1.4; }
.new-message-indicator { position: absolute; z-index: 3; left: 50%; bottom: 10px; min-height: 38px; margin: 0; padding: 0 13px; transform: translateX(-50%); border: 0; border-radius: 999px; color: var(--unread-ink); background: var(--unread-bg); box-shadow: 0 7px 20px rgba(28, 25, 23, .18); white-space: nowrap; font-size: 12px; }
.new-message-indicator span, .new-message-indicator b { display: inline; }
.new-message-indicator b { margin-left: 7px; }

.composer { width: 100%; min-width: 0; padding: 7px clamp(10px, 2vw, 20px) calc(9px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--glass); }
.composer-main { width: 100%; max-width: 820px; min-width: 0; min-height: 44px; display: grid; grid-template-columns: minmax(0, 1fr) 36px 36px 40px; align-items: end; gap: 3px; margin: 0 auto; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--control-bg); }
.composer-main .icon-button { width: 36px; min-width: 36px; height: 36px; min-height: 36px; align-self: end; color: var(--accent-ink); }
.composer-main .icon-button .icon { width: 17px; height: 17px; }
.composer-main #image-button .icon { width: 19px; height: 19px; }
.composer-main #emoji-button .icon { width: 22px; height: 22px; }
.composer-main .icon-button.is-active { color: var(--accent-ink); background: var(--accent-soft); }
.composer-main textarea { min-height: 36px; padding: 7px 5px; border: 0; background: transparent; box-shadow: none; font-size: 14px; line-height: 1.4; }
.composer-main textarea:focus { border: 0; box-shadow: none; }
.composer-main textarea[data-emoji-focus="true"] { caret-color: var(--accent); }
.emoji-picker { position: relative; width: 100%; max-width: 820px; min-width: 0; margin: 7px auto 0; padding: 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-soft); }
.expression-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0 2px 7px; padding: 3px; border-radius: 10px; background: var(--soft); }
.expression-tab { min-height: 34px; padding: 0 12px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 13px; font-weight: 650; }
.expression-tab.is-active { color: var(--accent-ink); background: var(--surface); box-shadow: 0 1px 4px rgba(36,31,29,.09); }
.expression-viewport { width: 100%; overflow: hidden; touch-action: pan-y; }
.expression-track { width: 200%; display: flex; align-items: stretch; transform: translateX(0); transition: transform .2s ease; }
.expression-track[data-page="custom"] { transform: translateX(-50%); }
.expression-panel { width: 50%; min-width: 0; }
.emoji-sections { max-height: min(360px, 42vh); overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding: 1px 2px 4px; scrollbar-width: thin; }
.emoji-mobile-actions { display: none; }
.emoji-section + .emoji-section { margin-top: 9px; }
.emoji-section-title { margin: 3px 5px 5px; color: var(--muted); font-size: 11px; font-weight: 650; line-height: 1.4; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 2px; padding: 0 1px; }
.emoji-option { min-width: 40px; min-height: 40px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 9px; color: var(--ink); background: transparent; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 23px; line-height: 1; }
.emoji-option:focus-visible { background: var(--soft-strong); transform: translateY(-1px); }
.emoji-option:active { transform: scale(.94); }
@media (hover: hover) { .emoji-option:hover { background: var(--soft-strong); transform: translateY(-1px); } }
.sticker-library-heading { min-height: 26px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 5px 5px; color: var(--muted); font-size: 11px; }
.sticker-library-heading small { font-size: 10px; }
.sticker-grid { max-height: min(360px, 42vh); display: grid; grid-template-columns: repeat(auto-fill, minmax(min(72px, 100%), 1fr)); align-content: start; gap: clamp(3px, 1.2vw, 7px); overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; padding: 2px 3px 8px; }
.sticker-cell, .sticker-add { position: relative; width: 100%; max-width: 100%; min-width: 0; min-height: 0; height: auto; display: block; align-self: start; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--control-bg); }
.sticker-cell::before, .sticker-add::before { content: ""; display: block; width: 100%; padding-top: 100%; pointer-events: none; }
.sticker-cell canvas, .sticker-cell img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; object-position: center; }
.sticker-cell, .sticker-cell img { -webkit-user-drag: none; user-select: none; -webkit-user-select: none; }
.sticker-cell[data-loading="true"]::after { content: "…"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.sticker-add { color: var(--accent-ink); border-style: dashed; }
.sticker-add span, .sticker-add small { position: absolute; left: 50%; transform: translate(-50%, -50%); white-space: nowrap; }
.sticker-add span { top: 42%; font-size: 26px; line-height: 1; }
.sticker-add small { top: 68%; margin: 0; font-size: 10px; }
.sticker-operation-status { min-height: 18px; margin: 3px 5px 0; color: var(--muted); font-size: 11px; }
.composer-context-banner { max-width: 820px; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 auto 7px; padding: 8px 9px 8px 10px; border-left: 2px solid var(--accent); border-radius: 9px; color: var(--accent-ink); background: var(--accent-soft); }
.composer-context-banner span { min-width: 0; }
.composer-context-banner strong, .composer-context-banner small { display: block; }
.composer-context-banner strong { font-size: 13px; }
.composer-context-banner small { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.composer-context-banner button { flex: 0 0 auto; min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--accent-ink); background: var(--surface); font-size: 11px; }
.composer-reply-banner { border-left-color: var(--accent); }
.composer-image-placeholder { visibility: hidden; pointer-events: none; }
.send-button { width: 40px; min-width: 40px; height: 36px; min-height: 36px; display: grid; place-items: center; align-self: end; padding: 0; border: 0; border-radius: 10px; color: var(--mine-ink); background: var(--mine-bg); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.send-button .icon { width: 18px; height: 18px; }
.send-button:hover { background: var(--mine-bg-hover); }
.upload-progress { height: 3px; background: var(--soft-strong); }
.upload-progress span { display: block; width: 0; height: 100%; background: var(--accent); }

.background-detection-float { position: fixed; z-index: 20; left: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); min-width: 132px; min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 6px 7px 6px 11px; border: 1px solid var(--line-strong); border-color: color-mix(in srgb, var(--accent) 34%, var(--line)); border-radius: 999px; color: var(--ink); background: var(--glass); box-shadow: var(--shadow-soft); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.background-detection-copy { min-width: 0; text-align: left; line-height: 1.15; }
.background-detection-copy strong, .background-detection-copy small { display: block; white-space: nowrap; }
.background-detection-copy strong { font-size: 11px; }
.background-detection-copy small { margin-top: 2px; color: var(--accent-ink); font-size: 9px; }
.background-detection-track { position: relative; flex: 0 0 auto; width: 34px; height: 20px; border-radius: 999px; background: var(--accent); box-shadow: inset 0 0 0 1px rgba(28, 25, 23, .14); }
.background-detection-track i { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(20, 18, 17, .22); transform: translateX(14px); transition: transform .18s ease; }
.background-detection-float[aria-checked="false"] { color: var(--muted); border-color: var(--line-strong); }
.background-detection-float[aria-checked="false"] .background-detection-copy small { color: var(--muted); }
.background-detection-float[aria-checked="false"] .background-detection-track { background: #85817d; }
.background-detection-float[aria-checked="false"] .background-detection-track i { transform: translateX(0); }

.modal { max-width: none; max-height: none; overflow: visible; padding: 0; border: 0; background: transparent; color: var(--ink); }
.modal::backdrop, .image-viewer::backdrop { background: var(--overlay); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.dialog-fallback[open] { position: fixed; z-index: 9000; inset: 0; width: 100vw; height: var(--vh); display: grid; place-items: center; margin: 0; background: var(--overlay); }
.image-viewer.dialog-fallback[open] { display: block; }
.modal-card { width: min(480px, calc(100vw - 28px)); max-height: min(720px, calc(var(--vh) - 28px)); overflow-y: auto; overscroll-behavior: contain; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-panel); animation: modal-enter .18s ease-out both; }
@keyframes modal-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.compact-modal .modal-card { width: min(400px, calc(100vw - 28px)); }
.compact-modal .modal-card > .primary, .compact-modal .modal-card > .secondary, .compact-modal .modal-card > .ghost, .compact-modal .modal-card > .danger { width: 100%; margin-top: 7px; }
.modal-card header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.modal-card h2 { margin: 2px 0 0; font-size: 19px; letter-spacing: -.02em; }
.modal-card > p { color: var(--muted); line-height: 1.6; }
.danger-eyebrow { color: var(--danger); }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.confirm-actions button { width: 100%; }

.settings-dialog[open], .settings-dialog.dialog-fallback[open] { width: 100vw; height: var(--vh); display: flex; align-items: stretch; justify-content: flex-end; margin: 0; }
.settings-card { width: min(430px, 100vw); height: 100%; max-height: none; padding: 0 20px calc(20px + env(safe-area-inset-bottom)); border-width: 0 0 0 1px; border-radius: 18px 0 0 18px; animation: drawer-enter .18s ease-out both; }
@keyframes drawer-enter { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.settings-header { position: sticky; z-index: 2; top: 0; min-height: 72px; margin: 0 -20px; padding: calc(12px + env(safe-area-inset-top)) 20px 11px; border-bottom: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.settings-group { margin-top: 14px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-strong); }
.settings-group-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.settings-group-heading h3, .settings-group-heading p { margin: 0; }
.settings-group-heading h3 { font-size: 14px; }
.settings-group-heading p { margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.settings-group-icon { width: 34px; height: 34px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 10px; color: var(--accent-ink); background: var(--accent-soft); }
.settings-group-icon .icon { width: 16px; height: 16px; }
.settings-section { padding-bottom: 0; }
.settings-section label:first-of-type { margin-top: 0; }
.settings-help { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.avatar-setting-row { display: flex; align-items: center; gap: 13px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.avatar-setting-row > div { min-width: 0; }
.avatar-setting-row strong, .avatar-setting-row small { display: block; }
.avatar-setting-row small { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.profile-avatar { width: 68px; height: 68px; display: block; flex: 0 0 auto; border-radius: 50%; background: var(--avatar-bg); }
.setting-switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 12px 0; cursor: pointer; }
.setting-switch-copy { min-width: 0; }
.setting-switch-copy strong, .setting-switch-copy small { display: block; }
.setting-switch-copy small { margin-top: 5px; color: var(--muted); line-height: 1.45; }
.setting-switch input { position: relative; flex: 0 0 auto; width: 44px; height: 26px; margin: 0; padding: 0; appearance: none; -webkit-appearance: none; border: 1px solid var(--line-strong); border-radius: 999px; background: #85817d; box-shadow: none; cursor: pointer; }
.setting-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(25, 22, 21, .20); transition: transform .18s ease; }
.setting-switch input:checked { border-color: var(--accent-ink); background: var(--accent); }
.setting-switch input:checked::after { transform: translateX(18px); }
.setting-switch input:focus { box-shadow: none; }
.setting-switch input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; box-shadow: none; }
.settings-exit-group { margin-bottom: 0; }
.settings-exit-group .settings-group-icon { color: var(--danger); background: var(--danger-soft); }
.settings-exit-group > .danger { width: 100%; }
.friend-code { display: block; margin: 16px 0; padding: 14px; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 11px; text-align: center; color: var(--accent-ink); background: var(--soft); font-size: 13px; font-weight: 700; letter-spacing: .04em; cursor: text; user-select: text; -webkit-user-select: text; }
.dialog-status { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; line-height: 1.5; }
.dialog-status.success { color: var(--accent-ink); }
.danger-note { color: var(--danger) !important; font-size: 12px; }

.message-action-dialog { max-width: none; max-height: none; overflow: visible; padding: 0; border: 0; background: transparent; }
.message-action-dialog::backdrop { background: var(--overlay); }
.message-action-dialog.dialog-fallback[open] { position: fixed; z-index: 9000; inset: 0; width: 100vw; height: var(--vh); display: grid; place-items: center; margin: 0; background: var(--overlay); }
.message-action-card { width: min(290px, calc(100vw - 28px)); display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-panel); animation: modal-enter .16s ease-out both; }
.message-action-card > strong { padding: 4px 4px 9px; font-size: 14px; }
.message-action-card button { width: 100%; display: flex; align-items: center; justify-content: flex-start; gap: 8px; padding: 0 11px; border: 0; border-radius: 9px; color: var(--ink); background: var(--soft); }
.message-action-card .message-action-primary { color: var(--on-accent); background: var(--accent-solid); }
.message-action-card .icon { width: 17px; height: 17px; }

.image-viewer { width: 100vw; height: var(--vh); max-width: none; max-height: none; margin: 0; padding: 0; border: 0; color: #fff; background: #0f0d0d; color-scheme: dark; }
.viewer-toolbar { height: calc(58px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 14px calc(7px + env(safe-area-inset-bottom)); background: #181716; }
.viewer-toolbar > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d8cecb; }
.viewer-toolbar > div { flex: 0 0 auto; display: flex; gap: 7px; }
.viewer-toolbar button { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid #45413e; border-radius: 9px; color: #fff; background: #282624; }
.viewer-toolbar .icon { width: 17px; height: 17px; }
.viewer-stage { width: 100%; height: calc(var(--vh) - 58px - env(safe-area-inset-bottom)); display: grid; place-items: center; overflow: hidden; touch-action: none; }
.viewer-stage canvas { display: block; flex: none; }
.privacy-cover { position: fixed; z-index: 9999; inset: 0; display: block; overflow: hidden; color: var(--camouflage-ink); background: var(--camouflage-bg); color-scheme: var(--camouflage-color-scheme); opacity: 1; pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; transform: translateZ(0); will-change: opacity; contain: strict; }
/* Keep a transparent compositor layer ready so returning browsers never have to reuse the old chat frame. */
.privacy-cover[hidden] { display: block !important; opacity: 0; pointer-events: none; }
/* Native dialogs live in the top layer and toasts sit above the guard; hide every private surface while armed. */
html.privacy-locked #app-view, html.privacy-locked #login-view, html.privacy-locked dialog[open], html.privacy-locked #toast { visibility: hidden !important; }
html.privacy-locked dialog[open]::backdrop { display: none; }
.toast { position: fixed; z-index: 10000; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); padding: 9px 13px; transform: translateX(-50%); border: 1px solid rgba(255, 255, 255, .08); border-radius: 10px; color: #fff; background: rgba(36, 34, 32, .95); box-shadow: 0 9px 26px rgba(0, 0, 0, .25); font-size: 12px; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.mobile-only { display: none; }

@media (max-width: 767px) {
  button { min-width: 44px; min-height: 44px; }
  .app-shell { position: relative; display: block; height: var(--vh); max-height: var(--vh); }
  .sidebar, .chat-panel { position: absolute; inset: 0; }
  .sidebar { transition: transform .2s ease, opacity .2s ease; }
  .chat-panel { transform: translateX(100%); transition: transform .2s ease; }
  .app-shell.mobile-chat-open .sidebar { opacity: 0; transform: translateX(-18%); pointer-events: none; }
  .app-shell.mobile-chat-open .chat-panel { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .sidebar-header, .chat-header { min-height: calc(64px + env(safe-area-inset-top)); padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
  .sidebar-header { padding-inline: 14px; }
  .sidebar-my-avatar { width: 40px; height: 40px; }
  .sidebar-header h1 { font-size: 18px; }
  .friend-actions { padding: 8px 12px 6px; }
  .friend-actions button { min-height: 44px; }
  .friend-list-title { margin-top: 10px; }
  .friend-list { padding-inline: 8px; }
  .friend-row { min-height: 64px; }
  .message-list { padding: 13px 10px 15px; }
  .message { max-width: 88%; }
  .message-avatar { width: 30px; height: 30px; }
  .message-content { max-width: calc(100% - 38px); }
  .message-actions-trigger { display: none; }
  .message-actionable .bubble { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  .image-bubble canvas { max-width: 73vw; max-height: 300px; }
  .composer { padding: 6px 7px calc(7px + env(safe-area-inset-bottom)); }
  .composer-main { min-height: 44px; grid-template-columns: minmax(0, 1fr) 34px 34px 40px; gap: 2px; padding: 2px; border-radius: 11px; }
  .composer-main .icon-button { width: 34px; min-width: 34px; height: 34px; min-height: 34px; margin-bottom: 3px; border-radius: 8px; }
  .composer-main .icon-button:hover { color: var(--accent-ink); background: transparent; }
  .composer-main .icon-button.is-active, .composer-main .icon-button.is-active:hover { background: var(--accent-soft); }
  .composer-main textarea { min-height: 40px; padding: 8px 4px; font-size: 15px; line-height: 1.35; }
  .emoji-picker { height: min(var(--emoji-panel-height, 280px), var(--emoji-panel-max-height, calc(var(--vh) - 146px))); min-height: 0; display: flex; flex-direction: column; margin-top: 6px; padding: 6px 2px 2px; border-width: 1px 0 0; border-radius: 0; background: transparent; box-shadow: none; }
  .expression-tabs { flex: 0 0 auto; margin-inline: 2px; }
  .expression-viewport, .expression-track, .expression-panel { min-height: 0; height: 100%; }
  .expression-viewport { flex: 1 1 auto; }
  .emoji-sections { flex: 1 1 auto; height: 100%; min-height: 0; max-height: none; padding: 1px 1px 56px; scroll-padding-bottom: 56px; }
  #expression-panel-custom { display: flex; flex-direction: column; overflow: hidden; }
  .sticker-grid { min-height: 0; max-height: none; flex: 1 1 auto; grid-template-columns: repeat(5, minmax(0, 1fr)); overflow-y: auto; overscroll-behavior-y: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; padding-bottom: 58px; }
  .sticker-library-heading { padding-inline: 5px; }
  .emoji-mobile-actions { position: absolute; z-index: 2; right: 4px; bottom: 4px; display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--glass); box-shadow: var(--shadow-soft); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  .emoji-mobile-action { width: 44px; min-width: 44px; height: 44px; min-height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 9px; color: var(--accent-ink); background: var(--control-bg); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .emoji-mobile-action .icon { width: 21px; height: 21px; }
  .emoji-mobile-action:active { background: var(--accent-soft); transform: scale(.96); }
  .emoji-section + .emoji-section { margin-top: 8px; }
  .emoji-section-title { margin-inline: 5px; font-size: 11px; }
  .emoji-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; }
  .emoji-option { min-width: 40px; min-height: 40px; font-size: 23px; }
  .composer-context-banner { min-height: 46px; margin-bottom: 6px; }
  .composer-context-banner button { min-height: 44px; }
  .send-button { width: 40px; min-width: 40px; height: 40px; min-height: 40px; }
  .background-detection-float { left: auto; right: 8px; bottom: calc(10px + env(safe-area-inset-bottom)); min-width: 128px; min-height: 44px; padding: 6px 7px 6px 10px; }
  .app-shell.mobile-chat-open .background-detection-float { top: calc(70px + env(safe-area-inset-top)); bottom: auto; }
  .app-shell.mobile-chat-open .message-list { padding-top: 66px; }
  .modal { margin: auto; }
  .action-sheet[open], .action-sheet.dialog-fallback[open] { width: 100vw; height: var(--vh); display: flex; align-items: flex-end; margin: 0; }
  .action-sheet .modal-card { width: 100%; max-height: min(76vh, calc(var(--vh) - 10px)); padding: 18px 17px calc(17px + env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 18px 18px 0 0; animation-name: sheet-enter; }
  @keyframes sheet-enter { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
  .settings-dialog[open], .settings-dialog.dialog-fallback[open] { align-items: flex-end; }
  .settings-card { width: 100%; height: calc(var(--vh) - 8px); border-width: 1px 0 0; border-radius: 18px 18px 0 0; animation-name: sheet-enter; }
  .settings-header { min-height: calc(68px + env(safe-area-inset-top)); padding-top: calc(10px + env(safe-area-inset-top)); }
  .settings-group { padding: 14px; }
  .avatar-setting-row { align-items: flex-start; }
  .profile-avatar { width: 64px; height: 64px; }
  .danger-confirm-modal[open], .danger-confirm-modal.dialog-fallback[open] { width: 100vw; height: var(--vh); display: flex; align-items: flex-end; margin: 0; }
  .danger-confirm-modal .modal-card { width: 100%; padding: 18px 17px calc(17px + env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 18px 18px 0 0; animation-name: sheet-enter; }
  .message-action-dialog { width: 100vw; margin: auto 0 0; }
  .message-action-dialog.dialog-fallback[open] { place-items: end center; }
  .message-action-card { width: 100%; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 18px 18px 0 0; animation-name: sheet-enter; }
  .message-action-card button { min-height: 46px; }
  .new-message-indicator { min-height: 44px; }
}

@media (min-width: 768px) {
  .composer { display: flex; flex-direction: column; }
  .composer-context-banner { width: 100%; order: 0; }
  .emoji-picker { order: 1; margin: 0 auto 7px; }
  .composer-main { order: 2; }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .app-shell { grid-template-columns: 280px minmax(0, 1fr); }
  .sidebar-header { padding-inline: 13px; }
  .friend-actions { padding-inline: 9px; }
  .friend-actions button { font-size: 12px; }
  .friend-list { padding-inline: 7px; }
  .background-detection-float { left: 14px; }
}

@media (max-width: 420px) {
  .friend-actions button { padding: 0 8px; }
  .friend-actions .icon { width: 16px; height: 16px; }
  .message { max-width: 91%; }
  .bubble { padding: 9px 11px; }
  .avatar-setting-row { gap: 12px; }
}

@media (max-width: 767px) and (max-height: 620px) {
  .auth-shell { place-items: start center; }
  .auth-card { padding: 22px; }
  .auth-mark { margin-bottom: 14px; }
  .auth-card > p { margin-bottom: 16px; }
  .settings-card { height: var(--vh); border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
