/* finesse · register=product · shell=responsive-chat-triptych · palette=sage-ledger · themes=light+dark+ink · SOUL=6 SPECTACLE=1 DENSITY=8 */
:root,
[data-theme="bean-light"] {
  --page: #e7ece7;
  --bg: #f8faf7;
  --panel: #f1f5f1;
  --panel-2: #e9efe9;
  --panel-3: #dfe8e0;
  --ink-1: #142019;
  --ink-2: #3b4b42;
  --ink-3: #66766d;
  --ink-4: #88968e;
  --accent: #2f6b4f;
  --accent-hover: #275c44;
  --accent-soft: #dcebe2;
  --accent-faint: #edf6f0;
  --on-accent: #f7faf7;
  --border: rgba(20, 32, 26, .075);
  --border-strong: rgba(20, 32, 26, .14);
  --up: #2c7181;
  --down: #b4443c;
  --warn: #9b6b17;
  --shadow: 0 1px 3px rgba(20, 40, 30, .055);
  --shadow-lg: 0 40px 90px -50px rgba(20, 40, 30, .38);
  --scrim: rgba(12, 22, 16, .45);
  --rail: #17241d;
  --rail-2: #20342a;
  --rail-ink: #9baca2;
  --rail-active: #edf5ef;
  --bubble-in: #f1f5f1;
  --bubble-out: #d9eadf;
  --record: #b4443c;
  --selection: rgba(47, 107, 79, .16);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --r-xs: 8px;
  --r-sm: 12px;
  --r: 18px;
  --r-lg: 28px;
  --rail-w: 72px;
  --list-w: 326px;
  --details-w: 310px;
  --header-h: 68px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --app-height: 100dvh;
  --viewport-top: 0px;
}

[data-theme="bean-dark"] {
  --page: #101411;
  --bg: #171d19;
  --panel: #1c241f;
  --panel-2: #253129;
  --panel-3: #2e3c33;
  --ink-1: #edf2ee;
  --ink-2: #c0cbc3;
  --ink-3: #95a49a;
  --ink-4: #738177;
  --accent: #69bf8f;
  --accent-hover: #7dcca0;
  --accent-soft: rgba(105, 191, 143, .18);
  --accent-faint: rgba(105, 191, 143, .09);
  --on-accent: #102016;
  --border: rgba(237, 242, 238, .075);
  --border-strong: rgba(237, 242, 238, .14);
  --up: #71bac7;
  --down: #ee7a70;
  --warn: #d7a94d;
  --shadow: 0 1px 3px rgba(5, 9, 7, .35);
  --shadow-lg: 0 40px 90px -50px rgba(3, 8, 5, .75);
  --scrim: rgba(4, 8, 5, .68);
  --rail: #0c100d;
  --rail-2: #18211b;
  --rail-ink: #8b9b90;
  --rail-active: #e9f1eb;
  --bubble-in: #253029;
  --bubble-out: #315f46;
  --record: #ee7a70;
  --selection: rgba(105, 191, 143, .22);
}

[data-theme="ink"] {
  --page: #eae9e5;
  --bg: #f8f7f3;
  --panel: #f0efeb;
  --panel-2: #e5e4df;
  --panel-3: #d9d8d2;
  --ink-1: #1d1d1b;
  --ink-2: #454541;
  --ink-3: #696964;
  --ink-4: #8b8b85;
  --accent: #2b3030;
  --accent-hover: #1d2222;
  --accent-soft: #dddeda;
  --accent-faint: #edede9;
  --on-accent: #f5f5f1;
  --border: rgba(24, 24, 22, .08);
  --border-strong: rgba(24, 24, 22, .15);
  --up: #2c7181;
  --down: #ac433c;
  --warn: #8f671d;
  --shadow: 0 1px 3px rgba(25, 25, 20, .055);
  --shadow-lg: 0 40px 90px -50px rgba(25, 25, 20, .36);
  --scrim: rgba(15, 15, 13, .45);
  --rail: #1a1b19;
  --rail-2: #282a27;
  --rail-ink: #a5a6a0;
  --rail-active: #f1f1ed;
  --bubble-in: #ededE9;
  --bubble-out: #dadbd6;
  --record: #ac433c;
  --selection: rgba(43, 48, 48, .14);
}

[data-theme="admin-light"] {
  --page: #e8ece8;
  --bg: #f8faf7;
  --panel: #f0f4f0;
  --panel-2: #e6ece7;
  --panel-3: #dae4dc;
  --ink-1: #17231c;
  --ink-2: #405047;
  --ink-3: #6b7b72;
  --ink-4: #8b9991;
  --accent: #2f6b4f;
  --accent-hover: #275c44;
  --accent-soft: #dbeae1;
  --accent-faint: #edf5f0;
  --on-accent: #f7faf7;
  --border: rgba(20, 32, 26, .075);
  --border-strong: rgba(20, 32, 26, .14);
  --up: #2c7181;
  --down: #b4443c;
  --warn: #9b6b17;
  --shadow: 0 1px 3px rgba(20, 40, 30, .055);
  --shadow-lg: 0 40px 90px -50px rgba(20, 40, 30, .38);
  --scrim: rgba(12, 22, 16, .45);
  --rail: #16231c;
  --rail-2: #21342a;
  --rail-ink: #a5b5ab;
  --rail-active: #f0f6f2;
  --bubble-in: #f0f4f0;
  --bubble-out: #d9eadf;
  --record: #b4443c;
  --selection: rgba(47, 107, 79, .16);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --r-xs: 8px;
  --r-sm: 12px;
  --r: 18px;
  --r-lg: 28px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overflow-x: clip; overscroll-behavior: none; }
html { -webkit-text-size-adjust: 100%; background: var(--page); }
body { color: var(--ink-1); background: var(--page); font-family: var(--font-ui); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--selection); outline-offset: 2px; }
button:disabled { opacity: .5; cursor: not-allowed; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }
.skip-link { position: fixed; z-index: 9999; left: 16px; top: -60px; padding: 10px 14px; border-radius: var(--r-sm); color: var(--on-accent); background: var(--accent); transition: top .18s var(--ease); }
.skip-link:focus { top: 12px; }

.brand-mark { position: relative; display: inline-block; width: 36px; height: 36px; flex: 0 0 auto; }
.brand-mark i { position: absolute; display: block; width: 19px; height: 28px; top: 5px; border-radius: 65% 45% 60% 40%; background: var(--accent); transform: rotate(-26deg); }
.brand-mark i:first-child { left: 2px; }
.brand-mark i:last-child { right: 2px; transform: rotate(26deg); opacity: .76; }
.brand-mark--large { width: 66px; height: 66px; }
.brand-mark--large i { width: 34px; height: 52px; top: 7px; }

.toast { position: fixed; z-index: 3000; left: 50%; bottom: 28px; transform: translate(-50%, 20px); max-width: min(90vw, 440px); padding: 12px 16px; border-radius: var(--r-sm); color: var(--on-accent); background: var(--accent); box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease), transform .2s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--down); }

/* Authentication */
.auth-screen { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr); }
.auth-brand { position: relative; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(34px, 5vw, 72px); color: var(--rail-active); background: var(--rail); overflow: clip; }
.auth-brand::before, .auth-brand::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.auth-brand::before { width: 44vw; height: 44vw; min-width: 480px; min-height: 480px; right: -24vw; top: -20vw; border: 1px solid var(--border-strong); box-shadow: 0 0 0 60px var(--border), 0 0 0 130px var(--border); }
.auth-brand::after { width: 240px; height: 240px; left: 16%; bottom: -150px; background: var(--rail-2); }
.auth-brand .brand-mark i { background: var(--rail-active); }
.auth-copy { position: relative; z-index: 1; max-width: 650px; }
.brand-name { margin: 0 0 26px; color: var(--rail-ink); font-weight: 650; letter-spacing: .04em; }
.auth-copy h1 { margin: 0; max-width: 620px; font-size: clamp(42px, 5.1vw, 76px); line-height: 1.06; letter-spacing: -.055em; font-weight: 760; text-wrap: balance; overflow-wrap: anywhere; }
.auth-copy > p:last-child { max-width: 520px; margin: 28px 0 0; color: var(--rail-ink); font-size: 16px; line-height: 1.8; text-wrap: pretty; }
.privacy-note { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; max-width: 480px; padding-top: 28px; border-top: 1px solid var(--border); }
.privacy-lock { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--rail-active); background: var(--rail-2); font-size: 24px; }
.privacy-note b, .privacy-note small { display: block; }
.privacy-note b { margin-bottom: 4px; }
.privacy-note small { color: var(--rail-ink); line-height: 1.55; }
.auth-panel { min-width: 0; display: grid; place-items: center; padding: 32px; background: var(--page); }
.auth-card { width: min(100%, 470px); padding: 32px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--shadow-lg); }
.auth-mobile-brand { display: none; align-items: center; gap: 8px; margin-bottom: 24px; font-size: 21px; }
.auth-tabs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 5px; padding: 4px; margin-bottom: 30px; border-radius: var(--r-sm); background: var(--panel); }
.auth-tab { min-height: 42px; border-radius: 9px; color: var(--ink-3); background: transparent; cursor: pointer; font-weight: 650; transition: background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease); }
.auth-tab.active { color: var(--ink-1); background: var(--bg); box-shadow: var(--shadow); }
.auth-form { display: flex; flex-direction: column; }
.auth-legal { display: flex; justify-content: center; gap: 10px; margin-top: 24px; color: var(--ink-4); font-size: 12px; }
.auth-legal a { color: var(--ink-3); }
.auth-legal a:hover { color: var(--accent); }
.form-heading { margin-bottom: 24px; }
.form-heading h1, .form-heading h2 { margin: 0 0 7px; font-size: 24px; letter-spacing: -.025em; text-wrap: balance; }
.form-heading p { margin: 0; color: var(--ink-3); line-height: 1.6; }
label, legend { margin: 0 0 7px; color: var(--ink-2); font-size: 13px; font-weight: 650; }
input, textarea, select { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--panel); transition: border-color .16s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease); }
input { min-height: 46px; padding: 0 13px; }
textarea { padding: 11px 13px; resize: vertical; }
input:hover, textarea:hover, select:hover { border-color: var(--ink-4); }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
.password-field { position: relative; }
.password-field input { padding-right: 64px; }
.password-field .text-button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.text-button { min-height: 36px; padding: 0 8px; color: var(--accent); background: transparent; cursor: pointer; font-size: 12px; font-weight: 700; white-space: nowrap; }
.field-help { display: block; margin: 7px 0 16px; color: var(--ink-3); line-height: 1.5; }
.field-error, .form-error { min-height: 17px; margin: 5px 0 10px; color: var(--down); font-size: 12px; line-height: 1.45; }
.form-error { margin: 12px 0 0; text-align: center; }
.two-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.two-fields > div { display: flex; min-width: 0; flex-direction: column; }
.captcha-field { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 10px; padding: 0; margin: 16px 0 20px; border: 0; }
.captcha-field legend { grid-column: 1 / -1; }
.captcha-image { height: 58px; padding: 0; border-radius: var(--r-sm); overflow: hidden; background: var(--panel); cursor: pointer; }
.captcha-image img { width: 100%; height: 100%; display: block; }
.captcha-field input { height: 58px; }
.legal-consent { display: flex; align-items: flex-start; gap: 9px; margin: -4px 0 18px; color: var(--ink-3); font-size: 12px; line-height: 1.55; }
.legal-consent input { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; accent-color: var(--accent); }
.legal-consent a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--r-sm); cursor: pointer; font-weight: 700; white-space: nowrap; transition: transform .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease); }
.primary-button { color: var(--on-accent); background: var(--accent); box-shadow: 0 9px 24px -10px var(--accent); }
.primary-button:hover { background: var(--accent-hover); }
.primary-button:active, .secondary-button:active, .danger-button:active { transform: scale(.98); }
.primary-button.wide { width: 100%; margin-top: 4px; }
.primary-button.small { min-height: 38px; padding: 0 13px; font-size: 12px; }
.secondary-button { color: var(--ink-2); background: var(--panel); border: 1px solid var(--border-strong); }
.secondary-button:hover { color: var(--ink-1); background: var(--panel-2); }
.danger-button { color: var(--on-accent); background: var(--down); }
.button-spinner { display: none; width: 15px; height: 15px; border: 2px solid var(--border); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
.loading .button-spinner { display: block; }
@keyframes spin { to { transform: rotate(1turn); } }

/* Chat app */
.app-shell { width: 100%; height: var(--app-height, 100dvh); display: grid; grid-template-columns: var(--rail-w) var(--list-w) minmax(0, 1fr); background: var(--bg); overflow: hidden; }
.app-shell.has-announcement { padding-top: 48px; }
.announcement-banner { position: fixed; z-index: 1100; inset: 0 0 auto; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 9px 18px; color: #f4fff8; background: #234637; box-shadow: 0 6px 18px rgba(9, 32, 21, .15); font-size: 12px; }
.announcement-banner strong { font-size: 13px; }
.announcement-banner > span:last-child { max-width: min(60vw, 800px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .86; }
.announcement-label { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 8px; border-radius: 999px; color: #244b39; background: #cff5dd; font-size: 10px; font-weight: 800; white-space: nowrap; }
.announcement-popup > p { color: var(--ink-2); line-height: 1.8; white-space: normal; }
body.has-announcement .page-view { top: 48px; }
.app-rail { display: flex; flex-direction: column; align-items: center; min-width: 0; padding: 16px 10px max(14px, env(safe-area-inset-bottom)); color: var(--rail-ink); background: var(--rail); }
.rail-brand { height: 50px; display: grid; place-items: center; margin-bottom: 18px; }
.rail-brand .brand-mark { transform: scale(.82); }
.rail-brand .brand-mark i { background: var(--rail-active); }
.rail-nav, .rail-bottom { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.rail-bottom { margin-top: auto; }
.rail-button { position: relative; width: 48px; min-height: 48px; display: grid; place-items: center; border-radius: 15px; color: inherit; background: transparent; cursor: pointer; transition: color .16s var(--ease), background .16s var(--ease); }
.rail-button svg { width: 21px; height: 21px; }
.rail-button:hover { color: var(--rail-active); background: var(--rail-2); }
.rail-button.active { color: var(--rail-active); background: var(--rail-2); }
.rail-button.active::after { content: ""; position: absolute; right: -10px; width: 3px; height: 20px; border-radius: 3px 0 0 3px; background: var(--accent); }
.nav-badge { position: absolute; top: 5px; right: 4px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--rail); border-radius: 999px; color: #fff; background: #e34a4a; font-size: 9px; font-weight: 800; line-height: 1; }
.nav-label { display: none; }
.rail-avatar { width: 42px; height: 42px; margin-top: 10px; border-radius: 14px; background: var(--panel-3); overflow: hidden; cursor: pointer; }
.rail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.conversation-column { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--panel); }
.column-header, .chat-header { height: var(--header-h); flex: 0 0 auto; display: flex; align-items: center; padding: 0 17px; border-bottom: 1px solid var(--border); }
.column-header { justify-content: space-between; }
.header-title { display: flex; align-items: center; gap: 9px; }
.header-title h2, .chat-title h2 { margin: 0; font-size: 17px; letter-spacing: -.015em; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px var(--panel-3); }
.connection-dot.online { background: var(--up); }
.header-actions { display: flex; gap: 5px; }
.icon-button { width: 42px; min-width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: var(--ink-2); background: transparent; cursor: pointer; transition: color .15s var(--ease), background .15s var(--ease), transform .15s var(--ease); }
.icon-button:hover { color: var(--ink-1); background: var(--panel-2); }
.icon-button:active { transform: scale(.94); }
.list-search { height: 58px; flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 9px 14px; }
.list-search svg { width: 17px; position: absolute; margin-left: 12px; color: var(--ink-4); pointer-events: none; }
.list-search input { min-height: 40px; padding-left: 38px; border: 0; background: var(--bg); }
.conversation-list { min-height: 0; flex: 1; overflow-y: auto; padding: 5px 9px 16px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
.conversation-item { width: 100%; min-width: 0; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 11px; margin-bottom: 3px; border-radius: 15px; text-align: left; color: var(--ink-1); background: transparent; cursor: pointer; content-visibility: auto; contain-intrinsic-size: 73px; }
.conversation-item:hover { background: var(--bg); }
.conversation-item.active { background: var(--bg); box-shadow: var(--shadow); }
.conversation-item .avatar { width: 48px; height: 48px; }
.conversation-copy { min-width: 0; }
.conversation-name-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conversation-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 680; }
.conversation-preview { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); font-size: 12.5px; }
.conversation-meta { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; color: var(--ink-4); font-size: 10.5px; }
.unread { min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 5px; border-radius: 10px; color: var(--on-accent); background: var(--accent); font-size: 10px; font-weight: 750; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; border-radius: 15px; overflow: hidden; color: var(--on-accent); background: var(--accent); font-size: 15px; font-weight: 760; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-column { min-width: 0; min-height: 0; position: relative; display: flex; flex-direction: column; background: var(--bg); }
.empty-state { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.empty-state .empty-bean { margin-bottom: 20px; opacity: .38; }
.empty-state h2 { margin: 0 0 9px; font-size: 20px; }
.empty-state p { max-width: 430px; margin: 0 0 22px; color: var(--ink-3); line-height: 1.7; text-wrap: pretty; }
.chat-active { min-height: 0; height: 100%; display: flex; flex-direction: column; }
.chat-header { gap: 12px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); }
.chat-header .avatar { width: 40px; height: 40px; border-radius: 13px; }
.chat-title { min-width: 0; flex: 1; }
.chat-title h2, .chat-title p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title p { margin: 3px 0 0; color: var(--ink-3); font-size: 11.5px; }
.message-list { min-height: 0; flex: 1; overflow-y: auto; padding: 24px clamp(18px, 4vw, 58px) 30px; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
.day-separator { display: flex; justify-content: center; margin: 10px 0 22px; color: var(--ink-4); font-size: 11px; }
.day-separator span { padding: 5px 9px; border-radius: 8px; background: var(--panel); }
.message-row { position: relative; display: flex; align-items: flex-start; gap: 9px; margin: 7px 0; }
.message-row.mine { justify-content: flex-end; }
.message-row .avatar { width: 34px; height: 34px; border-radius: 11px; font-size: 11px; }
.message-stack { max-width: min(72%, 620px); min-width: 0; }
.message-sender { margin: 0 0 4px 4px; color: var(--ink-4); font-size: 10.5px; }
.message-bubble { position: relative; min-width: 42px; padding: 10px 13px; border-radius: 6px 17px 17px 17px; color: var(--ink-1); background: var(--bubble-in); box-shadow: var(--shadow); line-height: 1.55; overflow-wrap: anywhere; }
.mine .message-bubble { border-radius: 17px 6px 17px 17px; background: var(--bubble-out); }
.message-bubble.emoji-only { padding: 4px 6px; background: transparent; box-shadow: none; font-size: 38px; }
.message-time { margin-top: 4px; color: var(--ink-4); font-size: 9.5px; text-align: right; }
.message-media { display: block; max-width: min(360px, 100%); max-height: 420px; border-radius: 12px; object-fit: contain; background: var(--panel-2); }
.audio-message { min-width: 180px; display: flex; align-items: center; gap: 10px; }
.audio-play { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--on-accent); background: var(--accent); cursor: pointer; }
.audio-wave { flex: 1; height: 24px; display: flex; align-items: center; gap: 2px; }
.audio-wave i, .recording-wave i { width: 2px; border-radius: 2px; background: var(--accent); }
.audio-wave i:nth-child(6n+1), .recording-wave i:nth-child(6n+1) { height: 8px; }
.audio-wave i:nth-child(6n+2), .recording-wave i:nth-child(6n+2) { height: 15px; }
.audio-wave i:nth-child(6n+3), .recording-wave i:nth-child(6n+3) { height: 22px; }
.audio-wave i:nth-child(6n+4), .recording-wave i:nth-child(6n+4) { height: 12px; }
.audio-wave i:nth-child(6n+5), .recording-wave i:nth-child(6n+5) { height: 19px; }
.audio-wave i:nth-child(6n), .recording-wave i:nth-child(6n) { height: 10px; }
.audio-duration { color: var(--ink-3); font-size: 11px; }
.message-menu { position: absolute; top: 0; opacity: 0; pointer-events: none; transition: opacity .15s var(--ease); }
.mine .message-menu { right: calc(100% + 5px); }
.message-row:not(.mine) .message-menu { left: calc(100% + 5px); }
.message-row:hover .message-menu, .message-row:focus-within .message-menu { opacity: 1; pointer-events: auto; }
.message-menu button { min-width: 40px; height: 34px; border-radius: 10px; color: var(--ink-3); background: var(--panel); cursor: pointer; font-size: 11px; }
.system-message { margin: 14px auto; color: var(--ink-4); text-align: center; font-size: 11px; }
.typing-indicator { height: 26px; display: flex; align-items: center; gap: 4px; padding: 0 clamp(18px, 4vw, 58px); color: var(--ink-4); font-size: 11px; }
.typing-indicator i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-4); animation: typing 1s ease-in-out infinite; }
.typing-indicator i:nth-child(2) { animation-delay: .14s; }
.typing-indicator i:nth-child(3) { animation-delay: .28s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }
.composer { position: relative; flex: 0 0 auto; padding: 10px clamp(12px, 2.5vw, 28px) max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 93%, transparent); backdrop-filter: blur(14px); }
.composer-main { display: flex; align-items: flex-end; gap: 7px; }
.composer-button { margin-bottom: 2px; }
.composer button:disabled, .composer textarea:disabled { cursor: not-allowed; opacity: .46; }
.composer-input-wrap { min-width: 0; flex: 1; position: relative; }
.composer-input-wrap textarea { min-height: 44px; max-height: 150px; padding: 11px 45px 10px 13px; border: 0; resize: none; overflow-y: auto; background: var(--panel); line-height: 1.45; }
.emoji-trigger { position: absolute; right: 5px; bottom: 4px; width: 36px; height: 36px; border-radius: 11px; color: var(--ink-3); background: transparent; cursor: pointer; font-size: 21px; }
.send-button { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: var(--on-accent); background: var(--accent); cursor: pointer; transition: transform .15s var(--ease), background .15s var(--ease); }
.send-button:active { transform: scale(.94); }
.send-button svg { width: 19px; }
.emoji-panel { position: absolute; right: 28px; bottom: calc(100% + 8px); width: min(360px, calc(100vw - 30px)); display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; padding: 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); box-shadow: var(--shadow-lg); }
.emoji-panel button { min-width: 40px; height: 40px; border-radius: 10px; background: transparent; cursor: pointer; font-size: 21px; }
.emoji-panel button:hover { background: var(--panel); }
.recording-panel { min-height: 62px; display: flex; align-items: center; gap: 12px; }
.recording-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--record); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.recording-wave { min-width: 0; height: 28px; flex: 1; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.recording-wave i { background: var(--record); }
.reply-preview { margin-bottom: 7px; padding: 8px 11px; border-radius: 10px; color: var(--ink-3); background: var(--panel); font-size: 11px; }
.detail-panel { width: var(--details-w); min-width: var(--details-w); display: flex; flex-direction: column; border-left: 1px solid var(--border); background: var(--panel); }
.detail-panel > header { height: var(--header-h); display: flex; align-items: center; justify-content: space-between; padding: 0 14px 0 18px; border-bottom: 1px solid var(--border); }
.detail-panel h2 { margin: 0; font-size: 16px; }
.detail-panel #detail-content { min-height: 0; overflow-y: auto; padding: 18px; }
.detail-profile { display: flex; flex-direction: column; align-items: center; padding: 16px 0 26px; text-align: center; }
.detail-profile .avatar { width: 72px; height: 72px; border-radius: 22px; margin-bottom: 12px; font-size: 23px; }
.detail-profile h3 { margin: 0 0 5px; }
.detail-profile p { margin: 0; color: var(--ink-3); line-height: 1.5; }
.detail-section { padding: 15px 0; border-top: 1px solid var(--border); }
.detail-section h4 { margin: 0 0 10px; font-size: 12px; color: var(--ink-3); }
.member-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.detail-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.detail-section-heading h4 { margin: 0; }
.official-badges { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: 5px; vertical-align: middle; }
.official-badge { --badge: #367b5a; display: inline-flex; align-items: center; gap: 4px; min-height: 20px; padding: 2px 7px 2px 3px; border: 1px solid color-mix(in srgb, var(--badge) 22%, transparent); border-radius: 999px; color: var(--badge); background: color-mix(in srgb, var(--badge) 10%, var(--bg)); font-size: 9.5px; font-weight: 750; line-height: 1; white-space: nowrap; }
.official-badge i { width: 15px; height: 15px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--badge); font-size: 8px; font-style: normal; }
.tone-jade { --badge: #257451; } .tone-blue { --badge: #3478c5; } .tone-navy { --badge: #294f8f; } .tone-orange { --badge: #c66b20; }
.tone-violet { --badge: #7857b8; } .tone-teal { --badge: #16837f; } .tone-rose { --badge: #c34f6d; } .tone-indigo { --badge: #565fc1; }
.tone-green { --badge: #378840; } .tone-slate { --badge: #596674; } .tone-gold { --badge: #9b7510; } .tone-pink { --badge: #b84f99; }
.tone-lime { --badge: #648214; } .tone-cyan { --badge: #167d9d; }
.profile-certifications { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px; margin: 14px 0; border-radius: 12px; background: var(--panel); }
.pending-card.has-pending { border-color: color-mix(in srgb, #e34a4a 35%, var(--border)); }
.pending-heading { display: flex; align-items: center; gap: 8px; }
.pending-heading h2 { margin: 0; }
.pending-count { min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 6px; border-radius: 999px; color: white; background: #e34a4a; font-size: 11px; font-weight: 800; }
.danger-zone { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.danger-zone p, .danger-notice p { color: var(--ink-3); font-size: 12px; line-height: 1.65; }
.danger-notice { padding: 13px; border: 1px solid color-mix(in srgb, var(--down) 24%, var(--border)); border-radius: 12px; background: color-mix(in srgb, var(--down) 7%, var(--bg)); }
.member-chip { min-width: 0; text-align: center; }
.member-chip .avatar { width: 44px; height: 44px; margin: 0 auto 5px; border-radius: 14px; font-size: 12px; }
.member-chip span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.detail-actions { display: flex; flex-direction: column; gap: 8px; }
.detail-actions button { width: 100%; }

.page-view { position: fixed; z-index: 700; inset: 0 0 0 var(--rail-w); display: flex; flex-direction: column; background: var(--page); }
.page-header { height: 78px; display: flex; align-items: center; gap: 12px; padding: 0 28px; border-bottom: 1px solid var(--border); background: var(--bg); }
.page-header > div { flex: 1; }
.page-context { margin: 0 0 3px; color: var(--ink-3); font-size: 11px; }
.page-header h1 { margin: 0; font-size: 21px; }
.page-content { min-height: 0; flex: 1; overflow-y: auto; width: 100%; padding: 28px; }
.page-grid { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .7fr); gap: 18px; align-items: start; }
.settings-card, .content-card { padding: 21px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); box-shadow: var(--shadow); }
.settings-card + .settings-card { margin-top: 14px; }
.settings-card h2, .content-card h2 { margin: 0 0 5px; font-size: 16px; }
.settings-card > p, .content-card > p { margin: 0 0 18px; color: var(--ink-3); line-height: 1.55; }
.settings-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; align-items: center; padding: 13px 0; border-top: 1px solid var(--border); }
.settings-row:first-of-type { border-top: 0; }
.settings-label b, .settings-label small { display: block; }
.settings-label small { margin-top: 4px; color: var(--ink-3); line-height: 1.4; }
.theme-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.theme-choice { min-height: 68px; display: flex; align-items: center; gap: 9px; padding: 10px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel); cursor: pointer; }
.theme-choice.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.theme-swatch { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); }
.theme-swatch.light { background: linear-gradient(135deg, var(--accent-soft) 50%, var(--bg) 50%); }
.theme-swatch.dark { background: linear-gradient(135deg, var(--rail) 50%, var(--accent) 50%); }
.theme-swatch.ink { background: linear-gradient(135deg, var(--ink-1) 50%, var(--panel-3) 50%); }
.profile-avatar-edit { display: flex; align-items: center; gap: 14px; }
.profile-avatar-edit .avatar { width: 72px; height: 72px; border-radius: 22px; font-size: 22px; }
.search-results, .contacts-list { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px; border-radius: 15px; background: var(--panel); }
.user-row .avatar { width: 48px; height: 48px; }
.user-row h3 { margin: 0 0 4px; font-size: 14px; }
.user-row p { margin: 0; color: var(--ink-3); font-size: 12px; }
.search-hit { padding: 12px 13px; border-radius: 13px; background: var(--panel); cursor: pointer; }
.search-hit h3 { margin: 0 0 5px; font-size: 13px; }
.search-hit p { margin: 0; color: var(--ink-3); line-height: 1.5; }

.modal-backdrop { position: fixed; z-index: 2000; inset: 0; display: grid; place-items: center; padding: 20px; background: var(--scrim); backdrop-filter: blur(6px); }
.modal { width: min(100%, 520px); max-height: min(88dvh, 740px); display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--shadow-lg); animation: modal-in .2s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.modal > header { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px 0 22px; border-bottom: 1px solid var(--border); }
.modal h2 { margin: 0; font-size: 17px; }
.modal-body { min-height: 0; overflow-y: auto; padding: 22px; }
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form label { margin: 0 0 -5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 8px; }
.modal-copy { margin: 0; color: var(--ink-3); line-height: 1.7; }
.search-user-result { margin-top: 10px; }
.checkbox-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 5px; border-radius: var(--r-sm); background: var(--panel); }
.checkbox-row { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 7px; border-radius: 10px; cursor: pointer; }
.checkbox-row:hover { background: var(--bg); }
.checkbox-row input { width: 18px; min-height: 18px; }

/* Admin */
.admin-body { min-height: 100dvh; }
.admin-login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--page); }
.admin-login-card { display: flex; flex-direction: column; }
.admin-login-card > .brand-mark { margin-bottom: 24px; }
.admin-app { min-height: 100dvh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.admin-sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 20px 14px; color: var(--rail-ink); background: var(--rail); }
.admin-logo { display: flex; align-items: center; gap: 10px; padding: 4px 9px 24px; color: var(--rail-active); }
.admin-logo .brand-mark { transform: scale(.82); }
.admin-logo .brand-mark i { background: var(--rail-active); }
.admin-logo b, .admin-logo small { display: block; }
.admin-logo b { font-size: 18px; }
.admin-logo small { margin-top: 2px; color: var(--rail-ink); }
.admin-sidebar nav { display: flex; flex-direction: column; gap: 5px; }
.admin-nav { min-height: 46px; display: flex; align-items: center; gap: 11px; padding: 0 13px; border-radius: 12px; color: inherit; background: transparent; cursor: pointer; font-weight: 650; text-align: left; }
.admin-nav svg { width: 18px; }
.admin-nav:hover, .admin-nav.active { color: var(--rail-active); background: var(--rail-2); }
.admin-nav.active { box-shadow: inset 3px 0 0 var(--accent); }
.admin-logout { margin-top: auto; width: 100%; }
.admin-main { min-width: 0; }
.admin-topbar { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--bg); }
.admin-topbar p { margin: 0 0 3px; color: var(--ink-3); font-size: 11px; }
.admin-topbar h1 { margin: 0; font-size: 22px; }
.privacy-badge { padding: 9px 12px; border-radius: 18px; color: var(--accent); background: var(--accent-soft); font-size: 12px; font-weight: 680; white-space: nowrap; }
.privacy-badge span { color: var(--up); }
.admin-content { padding: 24px 28px 50px; }
.stat-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.stat-card { min-height: 126px; display: flex; flex-direction: column; justify-content: space-between; padding: 18px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); box-shadow: var(--shadow); }
.stat-card.primary-stat { color: var(--on-accent); background: var(--accent); }
.stat-top { display: flex; justify-content: space-between; align-items: center; }
.stat-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--panel); }
.primary-stat .stat-icon { background: var(--selection); }
.stat-icon svg { width: 17px; }
.stat-card small { color: var(--ink-3); }
.primary-stat small { color: var(--on-accent); opacity: .75; }
.stat-card b { font-size: 27px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.admin-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .65fr); gap: 18px; align-items: start; }
.self-check-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 18px; padding: 26px; border: 1px solid var(--border); border-radius: 22px; background: linear-gradient(135deg, var(--bg), var(--panel)); box-shadow: var(--shadow); }
.self-check-hero h2 { margin: 4px 0 6px; font-size: 24px; }
.self-check-hero p { margin: 0; color: var(--ink-3); line-height: 1.55; }
.self-check-pulse { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 14%, transparent); }
.self-check-hero.attention .self-check-pulse { background: var(--danger); box-shadow: 0 0 0 7px color-mix(in srgb, var(--danger) 14%, transparent); }
.self-check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.check-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg); }
.check-card > span { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); font-weight: 800; }
.check-card.fail > span { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--panel)); }
.check-card h3 { margin: 0 0 3px; font-size: 13px; }
.check-card p { margin: 0; color: var(--ink-3); font-size: 11px; overflow-wrap: anywhere; }
.runtime-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.runtime-grid > div { padding: 14px; border-radius: 14px; background: var(--panel); }
.runtime-grid small, .runtime-grid b { display: block; }
.runtime-grid small { margin-bottom: 5px; color: var(--ink-4); }
.runtime-grid b { font-size: 14px; }
.admin-card { padding: 20px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); box-shadow: var(--shadow); }
.admin-card + .admin-card { margin-top: 14px; }
.admin-card-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.admin-card-header h2 { margin: 0; font-size: 16px; }
.admin-card-header p { margin: 4px 0 0; color: var(--ink-3); font-size: 12px; }
.admin-user-filter { width: min(100%, 260px); }

.legal-page { min-height: 100dvh; padding: clamp(22px, 5vw, 68px); background: var(--page); }
.legal-shell { width: min(100%, 820px); margin: 0 auto; }
.legal-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 42px; }
.legal-brand { display: flex; align-items: center; gap: 10px; color: var(--ink-1); font-weight: 750; }
.legal-card { padding: clamp(24px, 5vw, 54px); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--bg); box-shadow: var(--shadow-lg); }
.legal-card h1 { margin: 0 0 12px; font-size: clamp(30px, 5vw, 48px); letter-spacing: -.04em; }
.legal-card h2 { margin: 32px 0 8px; font-size: 17px; }
.legal-card p, .legal-card li { color: var(--ink-2); line-height: 1.8; }
.legal-card .legal-date { margin: 0; color: var(--ink-4); font-size: 13px; }
.legal-card ul { padding-left: 20px; }
.error-card { min-height: 54vh; display: grid; align-content: center; text-align: center; }
.error-code { margin: 0; color: var(--accent); font-size: 13px; font-weight: 800; letter-spacing: .16em; }
.error-card .primary-button { justify-self: center; margin-top: 22px; text-decoration: none; }
.privacy-panel { padding: 20px; border-radius: var(--r); color: var(--rail-active); background: var(--rail); }
.privacy-panel h2 { margin: 0 0 8px; }
.privacy-panel p { margin: 0 0 16px; color: var(--rail-ink); line-height: 1.65; }
.privacy-list { display: flex; flex-direction: column; gap: 9px; }
.privacy-list span { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.privacy-list i { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; color: var(--rail); background: var(--rail-active); font-style: normal; font-size: 10px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th { padding: 10px 12px; color: var(--ink-3); background: var(--panel); text-align: left; font-size: 11px; font-weight: 650; white-space: nowrap; }
.data-table th:first-child { border-radius: 10px 0 0 10px; }
.data-table th:last-child { border-radius: 0 10px 10px 0; }
.data-table td { min-height: 48px; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: 0; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 10px; color: var(--accent); background: var(--accent-soft); font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.status-badge.off { color: var(--down); background: color-mix(in srgb, var(--down) 13%, transparent); }
.status-badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.admin-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 16px; }
.admin-toolbar label { min-width: 130px; flex: 1; }
.admin-toolbar label span { display: block; margin-bottom: 6px; }
.admin-toolbar input, .admin-toolbar select { min-height: 42px; }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.admin-form-grid label span { display: block; margin-bottom: 6px; }
.admin-form-grid .span-all { grid-column: 1 / -1; }
.admin-badges { display: flex; flex-wrap: wrap; gap: 4px; min-width: 150px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.badge-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-height: 50vh; overflow: auto; }
.badge-choice { display: flex; align-items: center; gap: 7px; padding: 9px; border: 1px solid var(--border); border-radius: 11px; cursor: pointer; }
.badge-choice input { width: 16px; height: 16px; accent-color: var(--accent); }
.created-codes { display: grid; gap: 7px; margin: 14px 0; }
.code-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 11px; background: var(--panel); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-row button { min-height: 34px; padding: 0 10px; border-radius: 9px; color: var(--accent); background: var(--accent-soft); cursor: pointer; }
.empty-table { padding: 34px; text-align: center; color: var(--ink-3); }

@media (max-width: 1180px) {
  :root { --list-w: 300px; }
  .detail-panel { position: fixed; z-index: 800; right: 0; top: 0; bottom: 0; box-shadow: var(--shadow-lg); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-layout { grid-template-columns: minmax(0, 1fr); }
  .self-check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runtime-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .auth-screen { min-height: var(--app-height, 100dvh); grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .auth-brand { display: none; }
  .auth-panel { min-height: var(--app-height, 100dvh); align-items: start; padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom)); }
  .auth-card { padding: 24px; }
  .auth-mobile-brand { display: flex; }
  input, textarea, select { font-size: 16px; }
  .auth-tab, .text-button { min-height: 44px; }
  .app-shell { position: fixed; inset: 0; grid-template-columns: minmax(0, 1fr); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .app-rail { position: fixed; z-index: 1000; left: 0; right: 0; bottom: 0; height: calc(64px + env(safe-area-inset-bottom)); flex-direction: row; justify-content: space-around; padding: 5px 10px env(safe-area-inset-bottom); border-top: 1px solid var(--border); }
  .rail-brand, .rail-avatar { display: none; }
  .rail-nav, .rail-bottom { width: auto; flex-direction: row; gap: 16px; margin: 0; }
  .rail-bottom { display: flex; }
  .rail-button { width: 58px; min-height: 54px; display: flex; flex-direction: column; gap: 3px; border-radius: 13px; font-size: 10px; }
  .rail-button.active::after { left: 50%; right: auto; top: -5px; width: 20px; height: 3px; transform: translateX(-50%); border-radius: 0 0 3px 3px; }
  .nav-label { display: block; }
  .conversation-column { grid-column: 1; border: 0; }
  .chat-column { position: absolute; z-index: 600; inset: 0 0 calc(64px + env(safe-area-inset-bottom)); transform: translate3d(100%, 0, 0); transition: transform .22s var(--ease); will-change: transform; }
  .app-shell.has-announcement .chat-column { top: 48px; }
  .app-shell.chat-open .chat-column { transform: translate3d(0, 0, 0); }
  .mobile-only { display: grid !important; }
  .message-list { padding: 20px 14px 24px; }
  .message-stack { max-width: 82%; }
  .composer { padding-left: 8px; padding-right: 8px; }
  .composer-button { width: 38px; min-width: 38px; }
  .page-view { inset: 0 0 auto; height: calc(var(--app-height, 100dvh) - 64px - env(safe-area-inset-bottom)); }
  body.has-announcement .page-view { height: calc(var(--app-height, 100dvh) - 112px - env(safe-area-inset-bottom)); }
  .page-header { height: 66px; padding: 0 12px; }
  .page-content { padding: 16px; }
  .page-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-row { grid-template-columns: minmax(0, 1fr); }
  .theme-options { grid-template-columns: minmax(0, 1fr); }
  .detail-panel { width: min(92vw, 360px); min-width: 0; bottom: calc(64px + env(safe-area-inset-bottom)); }
  .app-shell.has-announcement .detail-panel { top: 48px; }
  .admin-app { grid-template-columns: minmax(0, 1fr); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .admin-sidebar { position: fixed; z-index: 1000; top: auto; bottom: 0; left: 0; right: 0; height: calc(64px + env(safe-area-inset-bottom)); flex-direction: row; align-items: center; padding: 5px 8px env(safe-area-inset-bottom); }
  .admin-logo, .admin-logout { display: none; }
  .admin-sidebar nav { width: 100%; flex-direction: row; justify-content: space-around; }
  .admin-nav { min-width: 58px; min-height: 52px; flex-direction: column; justify-content: center; gap: 2px; padding: 0 6px; font-size: 10px; }
  .admin-nav.active { box-shadow: inset 0 3px 0 var(--accent); }
  .admin-topbar { padding: 13px 16px; }
  .privacy-badge { display: none; }
  .admin-content { padding: 16px 14px 30px; }
  .announcement-banner { justify-content: flex-start; padding-inline: 12px; }
  .announcement-banner > span:last-child { max-width: 45vw; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

@media (max-width: 520px) {
  .two-fields { grid-template-columns: minmax(0, 1fr); }
  .captcha-field { grid-template-columns: minmax(0, 1fr); }
  .captcha-field legend { grid-column: auto; }
  .captcha-image { width: 190px; }
  .admin-form-grid, .badge-picker { grid-template-columns: minmax(0, 1fr); }
  .auth-card { border-radius: 22px; }
  .chat-header { padding: 0 8px; gap: 8px; }
  .chat-header .avatar { width: 36px; height: 36px; }
  .composer-main { gap: 4px; }
  .composer-button { width: 40px; min-width: 40px; }
  .message-stack { max-width: 86%; }
  .message-media { max-height: 52dvh; }
  .emoji-panel { right: 8px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 88dvh; border-radius: 24px 24px 0 0; animation-name: sheet-in; }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-topbar h1 { font-size: 19px; }
  .admin-card { padding: 15px; }
  .self-check-hero { align-items: stretch; flex-direction: column; padding: 20px; }
  .self-check-grid, .runtime-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (hover: none) and (pointer: coarse) {
  .message-menu { position: static; align-self: flex-end; opacity: .62; pointer-events: auto; }
  .message-menu button { min-width: 44px; min-height: 44px; }
  button, a, input, textarea, select { touch-action: manipulation; }
}

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