:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --bg-soft: #eceef3;
  --surface: rgba(255, 255, 255, .9);
  --surface-solid: #fff;
  --surface-2: #f1f2f6;
  --surface-3: #e8eaf0;
  --text: #17181c;
  --text-2: #555963;
  --text-3: #8a8f99;
  --line: rgba(29, 31, 38, .09);
  --line-strong: rgba(29, 31, 38, .15);
  --accent: #625cf6;
  --accent-2: #8a62ff;
  --accent-soft: #eeedff;
  --accent-text: #514aec;
  --success: #25a66a;
  --danger: #d94b63;
  --shadow: 0 24px 70px rgba(31, 34, 46, .12);
  --shadow-sm: 0 8px 28px rgba(31, 34, 46, .08);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1116;
  --bg-soft: #171a21;
  --surface: rgba(25, 28, 36, .9);
  --surface-solid: #1a1d25;
  --surface-2: #222630;
  --surface-3: #2b303c;
  --text: #f6f7fb;
  --text-2: #b1b5c0;
  --text-3: #747a87;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --accent: #827dff;
  --accent-2: #a06fff;
  --accent-soft: #29264a;
  --accent-text: #b9b6ff;
  --shadow: 0 28px 80px rgba(0, 0, 0, .34);
  --shadow-sm: 0 10px 34px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; -webkit-user-drag: none; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); }
body {
  background:
    radial-gradient(circle at 10% 0, color-mix(in srgb, var(--accent) 10%, transparent), transparent 32rem),
    radial-gradient(circle at 90% 100%, color-mix(in srgb, var(--accent-2) 8%, transparent), transparent 28rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { color: inherit; font: inherit; }
button { border: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .5; }
input, textarea { appearance: none; }
button, input, textarea, [tabindex] { outline: none; }
:focus-visible { outline: none !important; box-shadow: none !important; }
::selection { color: inherit; background: transparent; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn {
  width: 42px; height: 42px; min-width: 42px; padding: 0; border-radius: 13px;
  display: grid; place-items: center; background: transparent; color: var(--text-2);
  transition: background .18s, color .18s, transform .18s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.primary-btn, .secondary-btn, .quiet-btn {
  min-height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 680;
  transition: transform .18s var(--ease), filter .18s, background .18s;
}
.primary-btn { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 24%, transparent); }
.primary-btn:hover { filter: brightness(1.04); transform: translateY(-1px); }
.primary-btn:active { transform: scale(.98); }
.secondary-btn { color: var(--text); background: var(--surface-2); border: 1px solid var(--line); }
.quiet-btn { color: var(--text-2); background: transparent; }
.danger-btn { color: var(--danger); }
.field { position: relative; display: grid; gap: 7px; }
.field > label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.field input, .field textarea, .search-input {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface-solid);
  min-height: 50px; padding: 12px 14px; transition: border .18s, box-shadow .18s, background .18s;
}
.field input:focus, .field textarea:focus, .search-input:focus { border-color: var(--line-strong); box-shadow: none; }
.field input::placeholder, .field textarea::placeholder, .search-input::placeholder { color: var(--text-3); }
.field-hint { color: var(--text-3); font-size: 12px; line-height: 1.45; }
.error-text { min-height: 19px; margin: 0; color: var(--danger); font-size: 13px; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Authentication */
.auth-page { min-height: 100dvh; display: grid; grid-template-columns: minmax(360px, 1.05fr) minmax(400px, .95fr); }
.auth-showcase { position: relative; overflow: hidden; padding: clamp(38px, 6vw, 88px); display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: #171529; }
.auth-showcase::before, .auth-showcase::after { content: ""; position: absolute; border-radius: 50%; filter: blur(2px); }
.auth-showcase::before { width: 520px; height: 520px; left: -190px; top: -170px; background: radial-gradient(circle, #776eff 0, transparent 68%); opacity: .52; }
.auth-showcase::after { width: 460px; height: 460px; right: -170px; bottom: -180px; background: radial-gradient(circle, #c073ff 0, transparent 67%); opacity: .4; }
.auth-art { position: relative; z-index: 1; width: min(38vw, 520px); aspect-ratio: 1; margin: auto; }
.art-bubble { position: absolute; display: block; border: 1px solid rgba(255,255,255,.22); box-shadow: inset 0 1px rgba(255,255,255,.28), 0 30px 80px rgba(0,0,0,.22); backdrop-filter: blur(14px); }
.art-bubble::before, .art-bubble::after { content: ""; position: absolute; height: 9%; border-radius: 8px; background: rgba(255,255,255,.62); }
.art-bubble::before { width: 55%; left: 18%; top: 33%; }
.art-bubble::after { width: 34%; left: 18%; top: 51%; opacity: .55; }
.art-bubble-a { width: 58%; height: 40%; left: 4%; top: 17%; border-radius: 24% 24% 24% 7%; background: linear-gradient(145deg, rgba(128,119,255,.84), rgba(95,78,215,.52)); transform: rotate(-7deg); }
.art-bubble-b { width: 55%; height: 36%; right: 2%; bottom: 15%; border-radius: 24% 24% 7% 24%; background: linear-gradient(145deg, rgba(196,113,255,.82), rgba(116,83,225,.56)); transform: rotate(7deg); }
.art-bubble-c { width: 21%; height: 16%; right: 11%; top: 11%; border-radius: 35%; background: rgba(255,255,255,.14); transform: rotate(12deg); }
.art-bubble-c::before { width: 45%; height: 12%; top: 42%; left: 27%; }
.art-bubble-c::after { display: none; }
.art-orbit { position: absolute; inset: 7%; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; transform: rotate(-18deg); }
.auth-main { display: grid; place-items: center; padding: 32px max(24px, 6vw); }
.auth-card, .identity-card { width: min(430px, 100%); }
.identity-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 12px; }
.identity-option { min-width: 0; padding: 8px 2px; display: flex; flex-direction: column; align-items: center; gap: 9px; border-radius: 18px; color: var(--text); background: transparent; transition: background .18s, transform .18s; }
.identity-option:hover { background: var(--surface-2); transform: translateY(-2px); }
.identity-option:active { transform: scale(.96); }
.identity-option strong { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; text-align: center; }
.identity-option small, .selected-identity small { margin-top: -6px; color: var(--text-3); font-size: 10px; }
.add-identity .avatar { color: var(--text-3); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.add-identity .icon { width: 26px; height: 26px; }
.identity-form { position: relative; display: grid; gap: 14px; }
.auth-back { position: absolute; left: -8px; top: -5px; }
.selected-identity { min-height: 116px; padding-bottom: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.selected-identity strong { font-size: 16px; }
.selected-identity .icon { width: 30px; height: 30px; }
.auth-go { width: 100%; margin-top: 2px; }
.auth-card h2 { margin: 0; font-size: 32px; letter-spacing: -.035em; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 22px; border-radius: 14px; background: var(--surface-2); }
.auth-tab { min-height: 42px; border-radius: 11px; color: var(--text-3); background: transparent; font-weight: 670; }
.auth-tab.active { color: var(--text); background: var(--surface-solid); box-shadow: 0 3px 12px rgba(31,34,46,.08); }
.auth-form { display: grid; gap: 16px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 48px; }
.password-toggle { position: absolute; right: 5px; bottom: 5px; }
.auth-submit { width: 100%; margin-top: 2px; }
.auth-footnote { margin: 20px 0 0; text-align: center; color: var(--text-3); font-size: 12px; line-height: 1.55; }
.mobile-auth-visual { display: none; }
.register-avatar-section { display: grid; gap: 9px; }
.register-avatar-presets { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.register-avatar-preset { position: relative; width: 100%; aspect-ratio: 1; padding: 0; overflow: hidden; border-radius: 13px; background: var(--surface-2); transition: transform .18s var(--ease), box-shadow .18s; }
.register-avatar-preset img { width: 100%; height: 100%; display: block; object-fit: cover; }
.register-avatar-preset:hover { transform: translateY(-2px); }
.register-avatar-preset.selected { box-shadow: 0 0 0 3px var(--surface-solid), 0 0 0 5px var(--accent); transform: scale(.92); }
.register-avatar-upload { min-height: 42px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: 13px; color: var(--text-3); background: var(--surface-2); transition: color .18s, border-color .18s, background .18s; }
.register-avatar-upload:hover, .register-avatar-section.has-avatar .register-avatar-upload:hover { color: var(--accent-text); border-color: var(--accent); background: var(--accent-soft); }
.register-avatar-section:not(.has-avatar) .register-avatar-upload { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.register-avatar-upload .icon { width: 19px; height: 19px; }
.admin-toggle {
  position: fixed; z-index: 24; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom));
  border: 1px solid var(--line); color: var(--text-3); background: color-mix(in srgb, var(--surface-solid) 88%, transparent);
  box-shadow: var(--shadow-sm); backdrop-filter: blur(16px);
}
.admin-toggle:hover, .admin-toggle.active { color: var(--accent-text); background: var(--accent-soft); }
.admin-gate-panel { position: relative; width: min(330px, 100%); padding: 28px; display: grid; gap: 14px; overflow: visible; }
.admin-corner-close { position: absolute; right: 8px; top: 8px; }
.admin-shield { width: 70px; height: 70px; margin: 2px auto 8px; border-radius: 23px; display: grid; place-items: center; color: var(--accent-text); background: var(--accent-soft); }
.admin-shield .icon { width: 31px; height: 31px; }
.admin-enter { width: 100%; }
.admin-console { position: fixed; z-index: 45; inset: 0; overflow-y: auto; background: var(--bg); animation: fadeIn .2s both; }
.admin-console-head { position: sticky; z-index: 2; top: 0; width: min(920px, 100%); height: 76px; margin: auto; padding: max(14px, env(safe-area-inset-top)) 22px 10px; display: flex; align-items: center; justify-content: space-between; background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(20px); }
.admin-console-mark { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: var(--accent-text); background: var(--accent-soft); }
.admin-users { width: min(920px, 100%); margin: auto; padding: 12px 22px max(32px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.admin-user-card { min-width: 0; min-height: 80px; padding: 12px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; border: 1px solid var(--line); border-radius: 20px; color: inherit; background: var(--surface-solid); box-shadow: 0 5px 20px rgba(31,34,46,.04); text-align: left; transition: border-color .18s, transform .18s, box-shadow .18s; }
.admin-user-card:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.admin-user-card:active { transform: scale(.99); }
.admin-user-copy { min-width: 0; }
.admin-user-copy strong, .admin-user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-user-copy strong { font-size: 14px; }
.admin-user-copy small { margin-top: 5px; color: var(--text-3); font-size: 11px; }
.admin-user-card > .icon { width: 17px; height: 17px; color: var(--text-3); }
.admin-edit { z-index: 60; }
.admin-edit .modal-head { align-items: center; padding-bottom: 4px; }
.admin-edit .modal-head .profile-preview { flex: 1; padding-left: 42px; }
.admin-edit-actions { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 9px; }
.admin-edit-actions button { width: 100%; }
.admin-edit-actions .confirming { color: #fff; border-color: transparent; background: var(--danger); }

/* Conversation list */
.app-shell { width: min(1040px, 100%); min-height: 100dvh; margin: auto; padding: 22px 22px max(22px, env(safe-area-inset-bottom)); }
.app-panel { min-height: calc(100dvh - 44px); border: 1px solid var(--line); border-radius: var(--radius-xl); display: flex; flex-direction: column; background: var(--surface); backdrop-filter: blur(24px); box-shadow: var(--shadow); overflow: hidden; }
.list-header { padding: 26px 30px 18px; }
.list-top { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.list-title-wrap h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.list-title-wrap p { margin: 5px 0 0; color: var(--text-3); font-size: 14px; }
.profile-trigger { display: flex; align-items: center; gap: 11px; padding: 5px 6px 5px 12px; border-radius: 16px; background: var(--surface-2); text-align: right; }
.profile-trigger:hover { background: var(--surface-3); }
.self-text strong, .self-text span { display: block; }
.self-text strong { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.self-text span { margin-top: 2px; color: var(--text-3); font-size: 11px; }
.avatar { position: relative; flex: none; width: 48px; height: 48px; aspect-ratio: 1; border-radius: 17px; display: grid; place-items: center; overflow: hidden; background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 760; text-transform: uppercase; box-shadow: inset 0 1px rgba(255,255,255,.28); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.small { width: 42px; height: 42px; border-radius: 14px; }
.avatar.large { width: 78px; height: 78px; border-radius: 24px; font-size: 25px; }
.status-dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border: 3px solid var(--surface-solid); border-radius: 50%; background: var(--text-3); }
.status-dot.online { background: var(--success); }
.list-tools { display: flex; gap: 10px; margin-top: 24px; }
.search { position: relative; flex: 1; }
.search .icon { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-input { padding-left: 44px; background: var(--surface-2); border-color: transparent; }
.filter-button { width: auto; padding: 0 16px; gap: 8px; display: flex; }
.filter-button.active { color: var(--accent-text); background: var(--accent-soft); }
.conversation-section { flex: 1; padding: 4px 18px 14px; }
.section-label { margin: 12px 12px 8px; color: var(--text-3); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.conversation-list { display: grid; gap: 4px; }
.person { position: relative; width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 13px 14px; border-radius: 18px; color: inherit; background: transparent; text-align: left; transition: background .18s, transform .18s; }
.person:hover { background: var(--surface-2); }
.world-person { margin-bottom: 7px; border: 1px solid color-mix(in srgb,var(--accent) 16%,var(--line)); background: linear-gradient(120deg,color-mix(in srgb,var(--accent-soft) 66%,var(--surface-solid)),color-mix(in srgb,var(--surface-solid) 90%,transparent)); box-shadow: 0 8px 24px color-mix(in srgb,var(--accent) 7%,transparent); }
.world-person:hover { background: linear-gradient(120deg,var(--accent-soft),var(--surface-solid)); }
.world-logo { position: relative; flex: none; width: 48px; height: 48px; display: grid; place-items: center; }
.world-logo svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 7px 13px color-mix(in srgb,var(--accent) 24%,transparent)); }
.world-logo svg ellipse, .world-logo svg path { fill: none; stroke: rgba(255,255,255,.9); stroke-width: 1.5; stroke-linecap: round; }
.world-logo.world-logo-custom { overflow: hidden; border-radius: 16px; }
.world-logo.world-logo-custom img { width: 100%; height: 100%; display: block; object-fit: cover; }
.world-logo-large.world-logo-custom { border-radius: 25px; }
.world-pin { width: 12px; height: 12px; color: var(--accent-text); transform: rotate(-12deg); }
.world-live { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb,var(--success) 13%,transparent); }
.list-signature { flex: none; padding: 7px 18px 15px; text-align: center; }
.list-signature button { padding: 5px 12px; border-radius: 10px; color: var(--text-3); background: transparent; font-size: 9px; font-weight: 720; letter-spacing: .22em; opacity: .72; transition: color .18s, background .18s, opacity .18s; }
.list-signature button:hover, .list-signature button:active { color: var(--accent-text); background: var(--accent-soft); opacity: 1; }
.person > .avatar { overflow: visible; cursor: pointer; }
.person > .avatar img { border-radius: inherit; }
.person:active { transform: scale(.992); }
.person-copy { min-width: 0; }
.person-title { display: flex; align-items: center; gap: 8px; }
.person-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.person-sub { margin-top: 5px; min-width: 0; overflow: hidden; display: flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 13px; white-space: nowrap; }
.person-sub span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.person-sub .preview-icon { width: 13px; height: 13px; flex: none; }
.preview-count { flex: none; font-size: 10px; font-weight: 700; }
.person.unread .person-sub { color: var(--text-2); font-weight: 550; }
.person-meta { align-self: stretch; min-width: 55px; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 8px; color: var(--text-3); font-size: 11px; }
.person-last-seen { display: inline-flex; align-items: center; gap: 3px; color: var(--text-3); font-size: 9px; line-height: 1; white-space: nowrap; }
.person-last-seen .icon { width: 11px; height: 11px; stroke-width: 1.9; }
.person-last-seen b { font-weight: 720; }
.person-last-seen.online { color: var(--success); }
.person-last-seen.online i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb,var(--success) 12%,transparent); }
.unread-badge { min-width: 21px; height: 21px; padding: 0 6px; display: grid; place-items: center; border-radius: 11px; color: #fff; background: var(--accent); font-size: 11px; font-weight: 750; }
.empty-state { min-height: 380px; padding: 60px 24px; display: grid; place-items: center; text-align: center; }
.empty-state-inner { max-width: 330px; }
.empty-graphic { width: 82px; height: 82px; margin: 0 auto 18px; border-radius: 26px; display: grid; place-items: center; color: var(--accent-text); background: var(--accent-soft); transform: rotate(-4deg); }
.empty-graphic .icon { width: 34px; height: 34px; }
.empty-state h2 { margin: 0; font-size: 20px; letter-spacing: -.025em; }
.empty-state p { margin: 8px 0 0; color: var(--text-3); font-size: 14px; line-height: 1.6; }

/* Modal / sheets */
.modal { position: fixed; z-index: 50; inset: 0; padding: 20px; display: grid; place-items: center; background: rgba(9, 10, 14, .52); backdrop-filter: blur(10px); animation: fadeIn .18s both; }
.modal-panel { width: min(450px, 100%); max-height: min(760px, calc(100dvh - 32px)); overflow: auto; border: 1px solid var(--line); border-radius: 24px; background: var(--surface-solid); box-shadow: 0 30px 90px rgba(0,0,0,.25); animation: modalIn .26s var(--ease) both; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 22px 22px 12px; }
.modal-head h2 { margin: 0; font-size: 21px; letter-spacing: -.025em; }
.modal-head p { margin: 5px 0 0; color: var(--text-3); font-size: 13px; line-height: 1.5; }
.modal-head p { display: flex; align-items: center; gap: 5px; }
.modal-head p .icon { width: 12px; height: 12px; }
.modal-body { padding: 10px 22px 22px; display: grid; gap: 16px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions > * { flex: 1; }
.profile-preview { display: flex; justify-content: center; padding: 6px 0 4px; }
.world-settings-panel .modal-head { align-items: center; padding-bottom: 4px; }
.world-settings-panel .modal-head .profile-preview { flex: 1; padding-left: 42px; }
.world-avatar-presets { grid-template-columns: repeat(5,minmax(42px,1fr)); }
.signature-panel { width: min(330px,100%); }
.signature-panel .modal-body { padding-top: 22px; }
.signature-mark { width: 52px; height: 52px; margin: 0 auto 2px; border-radius: 17px; display: grid; place-items: center; color: var(--accent-text); background: var(--accent-soft); }
.signature-mark .icon { width: 23px; height: 23px; }
.avatar-presets { display: grid; grid-template-columns: repeat(auto-fit,minmax(42px,1fr)); gap: 8px; }
.avatar-preset { width: 100%; aspect-ratio: 1; min-width: 42px; border-radius: 13px; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); font-size: 21px; }
.avatar-preset img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.avatar-preset.selected { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.profile-file-actions { display: flex; justify-content: center; gap: 8px; }
.profile-file-actions .secondary-btn { padding: 0; }
.crop-modal { z-index: 65; place-items: center; }
.crop-panel { width: min(390px,100%); padding: 16px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface-solid); box-shadow: var(--shadow); }
.crop-stage { position: relative; width: min(320px,76vw); max-width: 100%; aspect-ratio: 1; margin: auto; overflow: hidden; border-radius: 19px; background: #111319; touch-action: none; cursor: grab; }
.crop-stage:active { cursor: grabbing; }
.crop-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; border: 1px solid rgba(255,255,255,.35); border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.crop-stage img { position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; object-fit: contain; transform-origin: center; user-select: none; -webkit-user-drag: none; }
.crop-controls { display: grid; grid-template-columns: 18px 1fr 24px; align-items: center; gap: 10px; padding: 16px 5px 12px; color: var(--text-3); }
.crop-controls .icon { width: 16px; height: 16px; }
.crop-controls .crop-large-icon { width: 22px; height: 22px; }
.crop-controls input { width: 100%; accent-color: var(--accent); }
.crop-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.person-edit { width: 30px; height: 28px; min-width: 30px; border-radius: 9px; opacity: 0; }
.person:hover .person-edit, .person:focus-within .person-edit { opacity: 1; }
.icon-only-primary { display: grid; place-items: center; }
.icon-only-primary .icon { width: 21px; height: 21px; }
.settings-row { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); }
.settings-row span { color: var(--text-2); font-size: 14px; }
.segmented { display: flex; padding: 3px; border-radius: 11px; background: var(--surface-2); }
.segmented button { min-height: 32px; padding: 0 11px; border-radius: 8px; background: transparent; color: var(--text-3); font-size: 12px; }
.segmented button.active { color: var(--text); background: var(--surface-solid); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.toast-region { position: fixed; z-index: 100; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: min(420px, calc(100vw - 32px)); padding: 11px 15px; border: 1px solid var(--line); border-radius: 13px; background: color-mix(in srgb, var(--surface-solid) 94%, transparent); box-shadow: var(--shadow-sm); color: var(--text); font-size: 13px; backdrop-filter: blur(18px); animation: toastIn .25s var(--ease) both; }

/* Chat */
.chat-page { height: 100dvh; padding: 14px; overflow: hidden; }
.chat-shell { width: min(1120px, 100%); height: calc(100dvh - 28px); margin: auto; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--surface); backdrop-filter: blur(24px); box-shadow: var(--shadow); }
.chat-header { flex: none; min-height: 62px; padding: 7px 12px; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface-solid) 78%, transparent); }
.chat-header .back-button { background: var(--surface-2); }
.chat-header .back-button { width: 36px; height: 36px; min-width: 36px; border-radius: 12px; }
.chat-person { min-width: 0; display: flex; align-items: center; gap: 12px; }
.chat-person .avatar { width: 38px; height: 38px; border-radius: 12px; }
.world-logo-header { width: 38px; height: 38px; }
.world-logo-large { width: 84px; height: 84px; margin: auto; }
.chat-person-copy { min-width: 0; }
.chat-person-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.presence { display: flex; align-items: center; gap: 5px; margin-top: 2px; color: var(--text-3); font-size: 11px; }
.presence i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.presence.online { color: var(--success); }
.presence.online i { background: var(--success); }
.chat-header-actions { display: flex; gap: 4px; }
.encryption-chip { height: 34px; padding: 0 11px; display: flex; align-items: center; gap: 6px; border-radius: 11px; color: var(--text-3); background: var(--surface-2); font-size: 11px; font-weight: 650; }
.encryption-chip .icon { width: 14px; height: 14px; }
.connection-banner { flex: none; padding: 7px 16px; text-align: center; color: #8d5a00; background: #fff0c9; font-size: 12px; }
[data-theme="dark"] .connection-banner { color: #ffd788; background: #3a2d14; }
.messages { position: relative; flex: 1; overflow: auto; overscroll-behavior: contain; scroll-behavior: smooth; padding: 24px clamp(16px, 5vw, 64px) 32px; display: flex; flex-direction: column; gap: 1px; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.messages::before { content: ""; margin-top: auto; }
.day-divider { align-self: center; margin: 15px 0 11px; padding: 5px 10px; border-radius: 9px; color: var(--text-3); background: var(--surface-2); font-size: 10px; font-weight: 650; }
.message-row { position: relative; max-width: min(76%, 620px); margin-top: 2px; display: flex; flex-direction: column; align-self: flex-start; animation: messageIn .22s var(--ease) both; -webkit-touch-callout: none; }
.message-row.mine { align-self: flex-end; align-items: flex-end; }
.message-author { max-width: 100%; padding: 0 7px 3px; overflow: hidden; color: var(--text-3); font-size: 9px; font-weight: 720; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.message-row.mine .message-author { text-align: right; }
.bubble { position: relative; padding: 10px 14px; border: 1px solid var(--line); border-radius: 7px 19px 19px 19px; background: var(--surface-solid); box-shadow: 0 4px 14px rgba(31,34,46,.04); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.message-row.mine .bubble { color: #fff; border-color: transparent; border-radius: 19px 7px 19px 19px; background: linear-gradient(145deg, var(--accent), var(--accent-2)); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 18%, transparent); }
.message-row.group-first { margin-top: 4px; }
.message-row.group-middle, .message-row.group-last { margin-top: 2px; }
.message-row.group-first .bubble, .message-row.group-middle .bubble { border-radius: 7px 19px 19px 7px; }
.message-row.group-last .bubble { border-radius: 7px 19px 19px 19px; }
.message-row.mine.group-first .bubble, .message-row.mine.group-middle .bubble { border-radius: 19px 7px 7px 19px; }
.message-row.mine.group-last .bubble { border-radius: 19px 7px 19px 19px; }
.world-mode .messages { background: radial-gradient(circle at 50% 0,color-mix(in srgb,var(--accent) 7%,transparent),transparent 30rem); }
.world-message .bubble, .world-message.mine .bubble { color: var(--text); border-color: color-mix(in srgb,var(--world-color) 24%,var(--line)); background: color-mix(in srgb,var(--world-color) 12%,var(--surface-solid)); box-shadow: 0 5px 18px color-mix(in srgb,var(--world-color) 9%,transparent); }
.world-message .message-author { color: color-mix(in srgb,var(--world-color) 78%,var(--text)); }
.world-message .world-bubble-content { display: block; min-width: 0; }
.world-message .world-bubble-content.media-ready .media-view { animation: mediaReveal .2s var(--ease) both; }
.message-row.group-first .message-meta, .message-row.group-middle .message-meta { display: none; }
.message-meta { min-height: 14px; padding: 2px 4px 0; display: flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 9px; opacity: .7; }
.message-read { display: inline-flex; align-items: center; gap: 1px; color: var(--text-3); }
.message-read.is-read { color: var(--accent-text); }
.message-read .icon { width: 13px; height: 13px; stroke-width: 2.1; }
.message-read b { min-width: 8px; font-size: 9px; line-height: 1; }
.message-read.world-read { gap: 2px; }
.read-role { width: 14px; height: 14px; display: grid; place-items: center; border: 1.5px solid var(--surface-solid); border-radius: 50%; color: #fff; background: var(--reader-color); font-size: 7px; font-style: normal; font-weight: 780; line-height: 1; letter-spacing: -.03em; }
.world-message.mine .read-role { border-color: color-mix(in srgb,var(--world-color) 12%,var(--surface-solid)); }
.message-row:hover .message-meta, .message-row:focus-within .message-meta { opacity: 1; }
.message-actions { position: absolute; z-index: 20; left: 4px; bottom: calc(100% + 6px); padding: 4px; display: flex; gap: 3px; border: 1px solid color-mix(in srgb,var(--line) 78%,transparent); border-radius: 14px; background: color-mix(in srgb,var(--surface-solid) 88%,transparent); box-shadow: 0 9px 26px rgba(21,23,32,.16); backdrop-filter: blur(16px); opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(5px) scale(.96); transform-origin: left bottom; transition: opacity .15s var(--ease),transform .15s var(--ease),visibility .15s; }
.message-row.mine .message-actions { right: 4px; left: auto; transform-origin: right bottom; }
.message-row.actions-open { z-index: 12; }
.message-row.actions-open .message-actions { opacity: 1; visibility: visible; pointer-events: auto; transform: none; }
.message-actions button { width: 31px; height: 31px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 10px; color: var(--text-2); background: transparent; }
.message-actions button:hover, .message-actions button:focus-visible { color: var(--accent-text); background: var(--accent-soft); }
.message-actions button:nth-child(3):hover, .message-actions button:nth-child(3):focus-visible { color: var(--danger); background: color-mix(in srgb,var(--danger) 10%,transparent); }
.message-actions button.copied { color: var(--success); background: color-mix(in srgb,var(--success) 11%,transparent); }
.message-actions button:disabled { opacity: .25; pointer-events: none; }
.message-actions .icon { width: 16px; height: 16px; }
.collapsed-marker { display: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 12px; color: color-mix(in srgb,var(--accent) 72%,var(--text-2)); background: color-mix(in srgb,var(--accent-soft) 56%,transparent); filter: drop-shadow(0 3px 7px color-mix(in srgb,var(--accent) 16%,transparent)); touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.collapsed-marker:active { transform: scale(.9); }
.collapsed-marker:focus-visible { outline: none; }
.collapsed-marker svg { width: 16px; height: 16px; fill: currentColor; }
.message-collapsed .bubble, .message-collapsed .message-author, .message-collapsed .message-meta { display: none; }
.message-collapsed .collapsed-marker { display: grid; place-items: center; }
.world-message.message-collapsed.group-first .message-author, .world-message.message-collapsed.group-single .message-author { display: block; }
.message-collapsed.group-last .group-time, .message-collapsed.group-single .group-time { display: block; }
.message-collapsed.collapsed-peek .collapsed-marker { display: none; }
.message-collapsed.collapsed-peek .bubble { display: block; border-style: dashed; border-color: color-mix(in srgb,var(--accent) 45%,var(--line)); background: color-mix(in srgb,var(--accent-soft) 58%,var(--surface-solid)); box-shadow: 0 7px 22px color-mix(in srgb,var(--accent) 10%,transparent), inset 0 0 0 1px color-mix(in srgb,var(--accent) 8%,transparent); animation: collapsedReveal .18s var(--ease) both; }
.message-collapsed.collapsed-peek .message-author, .message-collapsed.collapsed-peek .message-meta { display: block; animation: fadeIn .16s both; }
.message-collapsed.mine.collapsed-peek .bubble { color: var(--text); border-color: color-mix(in srgb,var(--accent) 48%,var(--line)); background: color-mix(in srgb,var(--accent) 9%,var(--surface-solid)); }
.message-revoked .bubble, .message-revoked.mine .bubble { min-width: 38px; min-height: 28px; padding: 5px 9px; display: grid; place-items: center; color: var(--text-3); border: 1px dashed color-mix(in srgb,var(--text-3) 35%,var(--line)); border-radius: 12px; background: color-mix(in srgb,var(--surface-2) 68%,transparent); box-shadow: none; }
.message-collapsed.message-revoked .bubble { display: none; }
.message-collapsed.message-revoked.collapsed-peek .bubble { display: grid; }
.revoked-icon { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .72; }
.message-row.pending { opacity: .72; }
.message-row.failed .message-meta { color: var(--danger); opacity: 1; }
.reaction { position: absolute; right: -7px; bottom: -9px; padding: 2px 6px; border: 2px solid var(--bg); border-radius: 10px; background: var(--surface-solid); box-shadow: var(--shadow-sm); font-size: 12px; }
.bubble.media { cursor: zoom-in; }
.bubble.media.video-media { cursor: default; }
.bubble.single-media { padding: 5px; overflow: hidden; }
.bubble.multi-media, .message-row.mine .bubble.multi-media { padding: 4px 8px 12px 4px; overflow: visible; border: 0; background: transparent; box-shadow: none; }
.world-message .bubble.single-media { padding: 6px; }
.world-message .bubble.multi-media, .world-message.mine .bubble.multi-media { padding: 6px 10px 13px 6px; border: 1px solid color-mix(in srgb,var(--world-color) 20%,var(--line)); background: color-mix(in srgb,var(--world-color) 9%,var(--surface-solid)); box-shadow: 0 5px 18px color-mix(in srgb,var(--world-color) 8%,transparent); }
.media-view { display: block; width: auto; height: auto; max-width: min(48vw, 340px); max-height: 40dvh; object-fit: contain; border-radius: 14px; background: #101116; }
.bubble.media-ready .media-view { animation: mediaReveal .2s var(--ease) both; }
.media-loading { display: block; width: 180px; height: 120px; border-radius: 14px; background: linear-gradient(105deg, var(--surface-2) 20%, var(--surface-3) 40%, var(--surface-2) 60%); background-size: 220% 100%; animation: shimmer 1.25s linear infinite; }
.media-error { padding: 24px; color: var(--danger); font-size: 13px; }
.media-stack { position: relative; width: min(48vw, 290px); aspect-ratio: 4/3; margin: 0 12px 12px 0; isolation: isolate; }
.media-stack-cover, .media-stack-back { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 18px; object-fit: cover; background: #101116; box-shadow: 0 8px 24px rgba(0,0,0,.16); }
.media-stack-cover { z-index: 3; }
.media-stack-back.back-0 { z-index: 2; transform: translate(7px,7px) rotate(1.6deg); opacity: .94; }
.media-stack-back.back-1 { z-index: 1; transform: translate(13px,13px) rotate(3deg); opacity: .78; }
.media-stack-count { position: absolute; z-index: 4; right: 9px; top: 9px; min-width: 27px; height: 27px; padding: 0 7px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: rgba(12,13,17,.62); backdrop-filter: blur(10px); font-size: 11px; font-weight: 750; }
.media-stack-loading { width: min(48vw,290px); height: auto; aspect-ratio: 4/3; }
.media-send-status { position: absolute; z-index: 7; right: 8px; bottom: 8px; min-width: 53px; height: 31px; padding: 3px 7px 3px 4px; display: flex; align-items: center; gap: 4px; border: 1px solid rgba(255,255,255,.15); border-radius: 11px; color: #fff; background: rgba(8,9,13,.7); box-shadow: 0 5px 16px rgba(0,0,0,.18); backdrop-filter: blur(10px); }
.media-send-status svg { width: 23px; height: 23px; flex: none; transform: rotate(-90deg); }
.media-progress-track, .media-progress-value { fill: none; stroke-width: 3; }
.media-progress-track { stroke: rgba(255,255,255,.2); }
.media-progress-value { stroke: #fff; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .18s linear; }
.media-progress-label { min-width: 19px; font-size: 9px; font-weight: 760; line-height: 1; text-align: center; }
.media-send-status.failed { background: color-mix(in srgb,var(--danger) 82%,#111); }
.qa-card { position: relative; width: min(520px, 88vw); margin: 8px 0; padding: 17px; align-self: flex-start; border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line)); border-radius: 21px; background: linear-gradient(145deg, var(--accent-soft), var(--surface-solid) 78%); box-shadow: var(--shadow-sm); }
.qa-card.mine { align-self: flex-end; }
.qa-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.qa-label { display: flex; align-items: center; gap: 6px; color: var(--accent-text); font-size: 11px; font-weight: 760; letter-spacing: .04em; }
.qa-label .icon { width: 15px; height: 15px; }
.qa-time { color: var(--text-3); font-size: 10px; }
.qa-question { position: relative; font-size: 16px; font-weight: 720; line-height: 1.5; }
.qa-results { margin-top: 14px; display: grid; gap: 8px; }
.qa-answer { position: relative; padding: 10px 12px; border-radius: 13px; background: color-mix(in srgb, var(--surface-solid) 72%, transparent); line-height: 1.45; }
.qa-answer small { display: block; margin-bottom: 3px; color: var(--text-3); font-size: 10px; font-weight: 700; }
.qa-state { margin-top: 13px; padding: 9px 11px; border-radius: 12px; color: var(--text-2); background: color-mix(in srgb, var(--surface-solid) 60%, transparent); font-size: 12px; line-height: 1.45; }
.qa-actions { display: flex; gap: 8px; margin-top: 13px; }
.qa-actions button { min-height: 38px; padding: 0 13px; border-radius: 12px; }
.empty-chat { margin: auto; max-width: 430px; padding: 40px 10px; text-align: center; }
.empty-chat .avatar { margin: auto; }
.empty-chat h2 { margin: 16px 0 7px; font-size: 21px; letter-spacing: -.025em; }
.empty-chat p { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.6; }
.quick-prompts { margin-top: 18px; display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; }
.quick-prompt { padding: 8px 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--text-2); background: var(--surface-solid); font-size: 12px; }
.quick-prompt:hover { border-color: var(--accent); color: var(--accent-text); }
.scroll-bottom { position: absolute; z-index: 4; right: 24px; bottom: 96px; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 14px; display: grid; place-items: center; color: var(--text-2); background: var(--surface-solid); box-shadow: var(--shadow-sm); }
.composer-area { position: relative; flex: none; padding: 7px clamp(10px,2vw,18px) calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface-solid) 84%, transparent); }
.tool-panel { display: flex; gap: 6px; padding: 0 2px 10px; overflow-x: auto; scrollbar-width: none; }
.tool-panel::-webkit-scrollbar { display: none; }
.emoji-panel { max-height: 190px; margin-bottom: 7px; padding: 9px; display: grid; grid-template-columns: repeat(auto-fill,minmax(38px,1fr)); gap: 6px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb,var(--surface-solid) 92%,transparent); box-shadow: var(--shadow-sm); backdrop-filter: blur(18px); scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
.emoji-option { min-width: 0; height: 38px; padding: 0; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); font-size: 20px; transition: transform .15s var(--ease),background .15s; }
.emoji-option:hover { background: var(--accent-soft); transform: translateY(-1px) scale(1.04); }
.emoji-option:active { transform: scale(.9); }
.emoji-option.emoji-wide { grid-column: span 2; padding: 0 7px; font-size: 12px; white-space: nowrap; }
.composer { display: grid; grid-template-columns: 36px 36px minmax(0,1fr) 40px; align-items: end; gap: 5px; }
.world-mode .composer { grid-template-columns: 36px minmax(0,1fr) 40px; }
.composer > .icon-btn { width: 36px; height: 40px; min-width: 36px; border-radius: 12px; }
.composer-input-wrap { min-height: 40px; padding: 2px 3px 2px 11px; display: flex; align-items: flex-end; gap: 3px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.composer-input-wrap > .icon-btn { width: 34px; height: 34px; min-width: 34px; margin-bottom: 1px; border-radius: 10px; }
.composer textarea { width: 100%; max-height: 108px; min-height: 34px; resize: none; overflow-y: auto; border: 0; padding: 7px 0 5px; background: transparent; line-height: 1.35; }
.composer textarea:focus-visible { box-shadow: none !important; }
.composer textarea::placeholder { color: var(--text-3); }
.send-button { width: 40px; height: 40px; min-width: 40px; padding: 0; border-radius: 13px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 7px 16px color-mix(in srgb, var(--accent) 20%, transparent); }
.send-button .icon { width: 20px; height: 20px; }
.composer-hint { margin: 6px 4px 0; color: var(--text-3); font-size: 10px; text-align: center; }
.media-draft { position: relative; width: min(560px,calc(100% - 82px)); margin: 0 0 7px 82px; padding: 7px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-2); box-shadow: 0 5px 18px rgba(0,0,0,.04); }
.world-mode .media-draft { width: min(560px,calc(100% - 41px)); margin-left: 41px; }
.media-draft-toolbar { height: 26px; margin-bottom: 6px; display: flex; align-items: center; justify-content: flex-end; gap: 3px; }
.media-draft-count { margin-right: auto; min-width: 24px; height: 22px; padding: 0 7px; display: grid; place-items: center; border-radius: 8px; color: var(--accent-text); background: var(--accent-soft); font-size: 10px; font-weight: 750; }
.media-draft-toolbar .icon-btn { width: 26px; height: 26px; min-width: 26px; border-radius: 8px; }
.media-draft-toolbar .icon { width: 14px; height: 14px; }
.media-draft-content { display: flex; gap: 6px; width: 100%; overflow-x: auto; border-radius: 11px; scroll-snap-type: x proximity; scrollbar-width: none; }
.media-draft-content::-webkit-scrollbar { display: none; }
.media-draft-item { position: relative; flex: none; width: 74px; height: 74px; aspect-ratio: 1; overflow: hidden; border-radius: 11px; background: #101116; scroll-snap-align: start; }
.media-draft-item img, .media-draft-item video { width: 100%; height: 100%; display: block; object-fit: cover; }
.draft-item-remove { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; padding: 0; display: grid; place-items: center; border-radius: 8px; color: #fff; background: rgba(8,9,12,.58); backdrop-filter: blur(8px); }
.draft-item-remove .icon { width: 12px; height: 12px; }
.question-preset-nav { display: flex; gap: 5px; margin: 0 -1px 8px; overflow-x: auto; padding: 1px; scrollbar-width: none; }
.question-preset-nav::-webkit-scrollbar { display: none; }
.question-preset-tab { flex: none; min-height: 28px; padding: 5px 9px; border: 1px solid transparent; border-radius: 9px; color: var(--text-3); background: transparent; font-size: 11px; font-weight: 720; line-height: 1; transition: color .16s,background .16s,border-color .16s; }
.question-preset-tab.active { color: var(--preset-ink,var(--accent-text)); border-color: var(--preset-stroke,transparent); background: var(--preset-fill,var(--accent-soft)); }
.question-presets { display: grid; grid-template-rows: repeat(4,34px); grid-auto-flow: column; align-content: start; gap: 3px; max-height: 145px; overflow-x: auto; overflow-y: hidden; padding: 2px 1px 5px; scrollbar-width: none; }
.question-presets::-webkit-scrollbar { display: none; }
.question-preset-lane { display: flex; align-items: center; gap: 3px; width: max-content; min-width: max-content; }
.question-preset-lane:nth-child(2) { padding-left: 16px; }
.question-preset-lane:nth-child(3) { padding-left: 5px; }
.question-preset-lane:nth-child(4) { padding-left: 25px; }
.question-preset { flex: 0 0 auto; width: fit-content; min-height: 30px; padding: 6px 9px; border: 1px solid var(--preset-stroke,transparent); border-radius: var(--preset-radius,10px); color: var(--preset-ink,var(--accent-text)); background: var(--preset-fill,color-mix(in srgb,var(--accent-soft) 80%,var(--surface-solid))); font-size: 11px; line-height: 1.2; white-space: nowrap; scroll-snap-align: start; transition: transform .16s var(--ease),background .16s,border-color .16s,box-shadow .16s; }
.question-preset-lane:nth-child(even) .question-preset:not(.question-preset-random) { transform: translateY(1px); }
.question-preset:hover, .question-preset.selected { border-color: var(--preset-active,var(--accent)); background: var(--preset-active-fill,color-mix(in srgb,var(--accent-soft) 72%,var(--surface-solid))); box-shadow: 0 4px 10px var(--preset-shadow,transparent); transform: translateY(-1px); }
.question-preset:active { transform: scale(.96); }
.question-preset-random { position: sticky; z-index: 3; left: 1px; width: 34px; min-width: 34px; padding: 0; display: grid; place-items: center; color: #fff; background: var(--preset-random,linear-gradient(135deg,var(--accent),var(--accent-2))); box-shadow: 5px 0 12px color-mix(in srgb,var(--surface-solid) 82%,transparent); }
.question-preset-random .icon { width: 16px; height: 16px; }
.preset-theme-0 { --preset-ink:#32729c; --preset-fill:#eaf7ff; --preset-stroke:#bce6fa; --preset-active:#54b6e8; --preset-active-fill:#d9f2ff; --preset-shadow:#b8e9ff88; --preset-random:linear-gradient(135deg,#3daee4,#78d6ee); --preset-radius:11px; }
.preset-theme-1 { --preset-ink:#397b66; --preset-fill:#e9f8ef; --preset-stroke:#c1ebd2; --preset-active:#63b98c; --preset-active-fill:#d8f4e4; --preset-shadow:#b9eaca88; --preset-random:linear-gradient(135deg,#50ad82,#91d5a5); --preset-radius:999px; }
.preset-theme-2 { --preset-ink:#98724b; --preset-fill:#fff6e8; --preset-stroke:#f2d8af; --preset-active:#d6a060; --preset-active-fill:#ffedcf; --preset-shadow:#f6d39a88; --preset-random:linear-gradient(135deg,#d19552,#efbf7b); --preset-radius:7px; }
.preset-theme-3 { --preset-ink:#b45e5e; --preset-fill:#fff0ee; --preset-stroke:#f4c9c2; --preset-active:#df7c70; --preset-active-fill:#ffe0da; --preset-shadow:#fac2b888; --preset-random:linear-gradient(135deg,#d96f69,#f29b82); --preset-radius:15px; }
.preset-theme-4 { --preset-ink:#af5685; --preset-fill:#fff0f7; --preset-stroke:#f3c5dc; --preset-active:#e175aa; --preset-active-fill:#ffdaed; --preset-shadow:#f7bedc88; --preset-random:linear-gradient(135deg,#d95e9b,#f39ac3); --preset-radius:999px; }
.preset-theme-5 { --preset-ink:#7060ae; --preset-fill:#f2f0ff; --preset-stroke:#d8d0fb; --preset-active:#9280d8; --preset-active-fill:#e5e0ff; --preset-shadow:#d1c7ff88; --preset-random:linear-gradient(135deg,#806fc8,#b3a1e9); --preset-radius:13px 6px 13px 6px; }
.preset-theme-6 { --preset-ink:#7f4f7e; --preset-fill:linear-gradient(115deg,#f7e8f4,#f3ecff); --preset-stroke:#dfbfe0; --preset-active:#a35f9d; --preset-active-fill:linear-gradient(115deg,#f4d8ef,#e9deff); --preset-shadow:#d7b4dc99; --preset-random:linear-gradient(135deg,#7e3e80,#ba719f); --preset-radius:999px 9px 999px 9px; }
.preset-theme-7 { --preset-ink:#68727c; --preset-fill:#f2f5f7; --preset-stroke:#bfc9d0; --preset-active:#818f9b; --preset-active-fill:#e3eaee; --preset-shadow:#c7d0d666; --preset-random:linear-gradient(135deg,#687782,#9baab5); --preset-radius:8px; }
.preset-theme-7 .question-preset { border-style:dashed; }
.preset-theme-8 { --preset-ink:#a06e35; --preset-fill:#fff9e5; --preset-stroke:#eddaa0; --preset-active:#cb973d; --preset-active-fill:#fff0bf; --preset-shadow:#f6d98788; --preset-random:linear-gradient(135deg,#c88c2d,#edc35e); --preset-radius:5px 14px 5px 14px; }
.preset-theme-9 { --preset-ink:#337c91; --preset-fill:#e9f8fa; --preset-stroke:#b8e2e9; --preset-active:#55aebf; --preset-active-fill:#d6f1f4; --preset-shadow:#aee3ea88; --preset-random:linear-gradient(135deg,#3b9bae,#75cbd0); --preset-radius:12px; }
.image-viewer { position: fixed; z-index: 90; inset: 0; overflow: hidden; color: #fff; background: rgba(5,6,9,.94); backdrop-filter: blur(14px); touch-action: none; user-select: none; }
.viewer-close { position: absolute; z-index: 5; right: max(18px,env(safe-area-inset-right)); top: max(18px,env(safe-area-inset-top)); color: #fff; background: rgba(255,255,255,.12); backdrop-filter: blur(12px); }
.zoom-stage { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; touch-action: none; }
.zoom-image { max-width: 92vw; max-height: 88dvh; object-fit: contain; border-radius: 10px; transform-origin: center; will-change: transform; touch-action: none; -webkit-user-drag: none; }
.zoom-image.loading { opacity: 0; }
.gallery-viewer .zoom-stage { bottom: 104px; }
.gallery-viewer .zoom-image { max-height: calc(100dvh - 138px); }
.gallery-arrow { position: absolute; z-index: 4; top: calc(50% - 72px); width: 46px; height: 46px; color: #fff; background: rgba(255,255,255,.1); backdrop-filter: blur(10px); }
.gallery-prev { left: max(16px,env(safe-area-inset-left)); }
.gallery-next { right: max(16px,env(safe-area-inset-right)); }
.gallery-rail-wrap { position: absolute; z-index: 4; left: 0; right: 0; bottom: 0; padding: 12px max(16px,env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent,rgba(0,0,0,.5)); }
.gallery-rail { display: flex; justify-content: safe center; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; }
.gallery-rail::-webkit-scrollbar { display: none; }
.gallery-thumb { flex: none; width: 64px; height: 64px; padding: 2px; overflow: hidden; border: 2px solid transparent; border-radius: 12px; background: rgba(255,255,255,.1); scroll-snap-align: center; opacity: .55; }
.gallery-thumb.active { border-color: #fff; opacity: 1; }
.gallery-thumb img { width: 100%; height: 100%; display: block; border-radius: 8px; object-fit: cover; }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes messageIn { from { opacity: 0; transform: translateY(5px); } }
@keyframes shimmer { to { background-position: -220% 0; } }
@keyframes mediaReveal { from { opacity: 0; transform: scale(.99); } }
@keyframes collapsedReveal { from { opacity: 0; transform: translateY(3px) scale(.97); } }
@keyframes mobileBubbleFloat { 50% { transform: translateY(-5px) rotate(.8deg); } }

@media (max-width: 760px) {
  .auth-page { display: block; min-height: 100dvh; }
  .auth-showcase { display: none; }
  .auth-main { position: relative; min-height: 100dvh; padding: max(28px, env(safe-area-inset-top)) 18px max(76px, calc(28px + env(safe-area-inset-bottom))); display: flex; flex-direction: column; justify-content: center; gap: clamp(14px, 3dvh, 26px); overflow: hidden; }
  .auth-main::before, .auth-main::after { content: ""; position: absolute; pointer-events: none; border-radius: 50%; filter: blur(1px); }
  .auth-main::before { width: 300px; height: 300px; left: -190px; top: -150px; background: radial-gradient(circle, color-mix(in srgb,var(--accent) 19%,transparent), transparent 68%); }
  .auth-main::after { width: 330px; height: 330px; right: -210px; bottom: -170px; background: radial-gradient(circle, color-mix(in srgb,var(--accent-2) 15%,transparent), transparent 68%); }
  .mobile-auth-visual { position: relative; z-index: 1; display: block; width: min(62vw, 238px); margin: 0 auto; flex: none; }
  .mobile-auth-visual svg { width: 100%; height: auto; display: block; overflow: visible; }
  .mobile-auth-orbit { fill: none; stroke: color-mix(in srgb,var(--accent) 17%,transparent); stroke-width: 1.3; stroke-dasharray: 4 8; }
  .mobile-auth-dot { fill: var(--accent); opacity: .25; }
  .mobile-auth-dot.dot-b { fill: var(--accent-2); }
  .mobile-bubble { transform-origin: center; animation: mobileBubbleFloat 5s ease-in-out infinite; }
  .mobile-bubble.bubble-b { animation-delay: -2.5s; }
  .identity-card { position: relative; z-index: 2; width: min(390px, 100%); padding: 18px; border: 1px solid var(--line); border-radius: 28px; background: color-mix(in srgb,var(--surface-solid) 83%,transparent); box-shadow: 0 18px 55px rgba(31,34,46,.1); backdrop-filter: blur(22px); }
  .identity-grid { max-height: 44dvh; padding: 2px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
  .identity-grid::-webkit-scrollbar { display: none; }
  .identity-card.is-empty { padding: 0; border: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
  .identity-card.is-empty .identity-grid { display: flex; justify-content: center; overflow: visible; }
  .identity-card.is-empty .add-identity { width: min(228px, 78vw); min-height: 76px; padding: 9px 18px 9px 10px; flex-direction: row; justify-content: center; gap: 14px; border: 1px solid color-mix(in srgb,var(--accent) 24%,var(--line)); border-radius: 25px; background: color-mix(in srgb,var(--surface-solid) 88%,transparent); box-shadow: 0 14px 38px color-mix(in srgb,var(--accent) 14%,transparent); backdrop-filter: blur(20px); }
  .identity-card.is-empty .add-identity .avatar { width: 56px; height: 56px; border-radius: 18px; color: #fff; background: linear-gradient(135deg,var(--accent),var(--accent-2)); box-shadow: 0 8px 20px color-mix(in srgb,var(--accent) 24%,transparent); }
  .identity-card.is-empty .add-identity strong { width: auto; font-size: 15px; }
  .auth-main.many-identities .mobile-auth-visual { width: 128px; }
  .auth-main.many-identities { gap: 8px; }
  .auth-main.auth-active { justify-content: flex-start; overflow: visible; padding-top: max(20px, env(safe-area-inset-top)); }
  .auth-main.auth-active .mobile-auth-visual { display: none; }
  .auth-main.auth-active .identity-card { margin: auto 0; }
  .auth-main.auth-active .identity-form { gap: 12px; }
  .auth-main.auth-active .selected-identity { min-height: 92px; }
  .register-avatar-presets { grid-template-columns: repeat(6,minmax(0,1fr)); gap: 6px; }
  .register-avatar-preset { border-radius: 11px; }
  .register-avatar-upload { min-height: 40px; }
  .auth-card h2 { font-size: 27px; }
  .admin-toggle { right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); }
  .admin-gate-panel { width: 100%; padding: 30px 22px calc(24px + env(safe-area-inset-bottom)); }
  .admin-console-head { height: calc(64px + env(safe-area-inset-top)); padding: max(10px, env(safe-area-inset-top)) 14px 8px; }
  .admin-users { grid-template-columns: 1fr; padding: 7px 10px max(22px, env(safe-area-inset-bottom)); }
  .admin-user-card { min-height: 74px; padding: 10px; border-radius: 18px; }
  .app-shell { padding: 0; }
  .app-panel { min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .list-header { padding: max(20px, env(safe-area-inset-top)) 18px 13px; }
  .list-title-wrap h1 { font-size: 26px; }
  .self-text { min-width: 0; display: block; }
  .self-text strong { max-width: min(30vw,130px); font-size: 13px; }
  .self-text span { display: none; }
  .profile-trigger { max-width: 48vw; gap: 8px; padding: 4px 4px 4px 9px; background: var(--surface-2); }
  .list-tools { margin-top: 19px; }
  .conversation-section { padding: 4px 7px 16px; }
  .list-signature { padding: 3px 12px max(11px,env(safe-area-inset-bottom)); }
  .person { padding: 12px 11px; }
  .modal { padding: 0; align-items: end; }
  .modal-panel { width: 100%; max-height: calc(92dvh - env(safe-area-inset-top)); border-radius: 25px 25px 0 0; padding-bottom: env(safe-area-inset-bottom); animation-name: sheetIn; }
  .chat-page { padding: 0; }
  .chat-shell { width: 100%; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .crop-modal { padding: 16px; align-items: center; }
  .chat-header { min-height: calc(54px + env(safe-area-inset-top)); padding: max(5px,env(safe-area-inset-top)) 8px 5px; grid-template-columns: 36px 1fr auto; gap: 7px; }
  .chat-header .back-button { width: 34px; height: 34px; min-width: 34px; }
  .chat-person { gap: 9px; }
  .chat-person .avatar { width: 34px; height: 34px; border-radius: 11px; }
  .world-logo-header { width: 34px; height: 34px; }
  .encryption-chip span { display: none; }
  .encryption-chip { width: 36px; padding: 0; justify-content: center; background: transparent; }
  .messages { padding: 15px 12px 24px; }
  .message-row { max-width: 87%; }
  .collapsed-marker { width: 42px; height: 38px; border-radius: 13px; }
  .world-message { max-width: 90%; }
  .bubble { padding: 9px 12px; }
  .message-meta { opacity: .75; }
  .media-view { width: auto; height: auto; max-width: min(68vw,320px); max-height: 34dvh; }
  .media-stack { width: min(64vw,270px); }
  .media-stack-loading { width: min(64vw,270px); }
  .composer-area { padding: 6px 7px calc(7px + env(safe-area-inset-bottom)); }
  .emoji-panel { max-height: min(212px,32dvh); grid-template-columns: repeat(8,minmax(0,1fr)); padding: 8px; gap: 5px; border-radius: 16px; }
  .emoji-option { height: 36px; font-size: 19px; }
  .media-draft { width: calc(100% - 77px); margin-left: 77px; }
  .composer { gap: 5px; }
  .composer { grid-template-columns: 34px 34px minmax(0,1fr) 38px; }
  .world-mode .composer { grid-template-columns: 34px minmax(0,1fr) 38px; }
  .composer > .icon-btn { width: 34px; height: 38px; min-width: 34px; }
  .composer-input-wrap { min-height: 38px; padding-left: 9px; }
  .composer textarea { min-height: 32px; padding: 6px 0 4px; }
  .send-button { width: 38px; height: 38px; min-width: 38px; }
  .composer-hint { display: none; }
  .scroll-bottom { right: 15px; bottom: 82px; }
  .gallery-arrow { display: none; }
  .zoom-image { max-width: 96vw; }
}

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