:root {
  color-scheme: light;
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-soft: #f4f5f9;
  --line: #e6e8ef;
  --text: #171923;
  --muted: #737785;
  --blue: #1677ff;
  --blue-dark: #075fd1;
  --blue-soft: #eaf3ff;
  --purple: #7357d8;
  --red: #df3e46;
  --green: #23a26d;
  --shadow: 0 18px 60px rgb(37 42 63 / 12%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 0; max-width: 100%; min-height: 100%; margin: 0; overflow-x: hidden; }
body { color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }

.auth-page {
  display: grid;
  min-height: 100svh;
  place-content: center;
  gap: 18px;
  padding: 28px 18px;
  background:
    radial-gradient(circle at 12% 12%, rgb(22 119 255 / 13%), transparent 28rem),
    radial-gradient(circle at 88% 90%, rgb(115 87 216 / 10%), transparent 26rem),
    #f6f7fb;
}
.auth-card { width: min(440px, calc(100vw - 32px)); padding: 38px; border: 1px solid rgb(255 255 255 / 85%); border-radius: 30px; background: rgb(255 255 255 / 94%); box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 34px; font-size: 21px; font-weight: 800; letter-spacing: -.04em; }
.brand-logo, .rail-brand { display: grid; place-items: center; color: white; background: linear-gradient(145deg, #2b8cff, #6556e8); box-shadow: 0 9px 20px rgb(32 113 242 / 25%); }
.brand-logo { width: 43px; height: 43px; border-radius: 15px; }
.brand-logo svg { width: 24px; height: 24px; }
.auth-copy { margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.auth-copy h1 { margin: 0; font-size: 32px; line-height: 1.1; letter-spacing: -.045em; }
.auth-copy > p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.auth-form, .stack-form { display: grid; gap: 13px; }
.auth-form label, .stack-form label { display: grid; gap: 7px; color: #414552; font-size: 12px; font-weight: 700; }
.auth-form label small { color: var(--muted); font-size: 9px; font-weight: 500; line-height: 1.4; }
input, textarea { border: 1px solid #dfe2ea; border-radius: 12px; outline: none; color: var(--text); background: white; transition: border-color .16s ease, box-shadow .16s ease; }
input { min-height: 47px; padding: 0 13px; }
textarea { padding: 10px 12px; }
input:focus, textarea:focus { border-color: #82b6ff; box-shadow: 0 0 0 4px rgb(22 119 255 / 10%); }
input::placeholder, textarea::placeholder { color: #a0a4b0; }
.password-field { position: relative; display: block; }
.password-field input { width: 100%; padding-right: 70px; }
.password-field button { position: absolute; inset: 6px 7px 6px auto; border: 0; border-radius: 9px; color: var(--blue); background: transparent; font-size: 12px; font-weight: 750; cursor: pointer; }
.password-field button:hover { background: var(--blue-soft); }
.primary-button, .secondary-button, .danger-button, .danger-outline-button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border-radius: 12px; font-size: 13px; font-weight: 750; cursor: pointer; transition: transform .14s ease, background .14s ease, border-color .14s ease; }
.primary-button { border: 0; color: white; background: var(--blue); box-shadow: 0 7px 18px rgb(22 119 255 / 19%); }
.primary-button:hover { background: var(--blue-dark); transform: translateY(-1px); }
.primary-button:disabled { opacity: .55; transform: none; cursor: default; }
.secondary-button { border: 1px solid #dfe2ea; color: #303440; background: white; }
.secondary-button:hover { border-color: #cbd0dc; background: #f8f9fb; }
.danger-button { border: 0; color: white; background: var(--red); }
.danger-outline-button { border: 1px solid #f0c9cc; color: var(--red); background: #fff; }
.auth-submit { width: 100%; min-height: 49px; margin-top: 3px; font-size: 14px; }
.form-message { margin: 0; padding: 10px 12px; border: 1px solid #f0d3d5; border-radius: 10px; color: #a3343b; background: #fff7f7; font-size: 12px; line-height: 1.45; }
.form-message.success { border-color: #bee7d4; color: #19724d; background: #f1fbf6; }
.auth-switch { margin: 18px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.auth-switch button { padding: 4px; border: 0; color: var(--blue); background: transparent; font-weight: 750; cursor: pointer; }
.auth-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 20px 0 0; color: #898d99; font-size: 11px; }
.auth-note svg { width: 15px; height: 15px; }
.auth-footer { margin: 0; color: #8a8e9c; font-size: 11px; text-align: center; }

.app-shell { display: grid; width: 100%; height: 100svh; grid-template-columns: 82px minmax(280px, 340px) minmax(0, 1fr); overflow: hidden; background: var(--surface); }
.app-shell.panel-mode { grid-template-columns: 82px minmax(0, 1fr); }
.nav-rail { z-index: 4; display: flex; flex-direction: column; align-items: center; padding: 18px 10px max(18px, env(safe-area-inset-bottom)); border-right: 1px solid var(--line); background: #fbfbfd; }
.rail-brand { width: 45px; height: 45px; flex: 0 0 auto; border: 0; border-radius: 15px; cursor: pointer; }
.nav-rail nav { display: grid; width: 100%; gap: 8px; margin-top: 38px; }
.rail-button { position: relative; display: grid; width: 100%; min-height: 59px; place-items: center; align-content: center; gap: 4px; border: 0; border-radius: 14px; color: #858a98; background: transparent; cursor: pointer; }
.rail-button svg { width: 21px; height: 21px; }
.rail-button span:last-child { font-size: 9px; font-weight: 750; }
.rail-button:hover { color: #434855; background: #f0f2f7; }
.rail-button.is-active { color: var(--blue); background: var(--blue-soft); }
.badge { position: absolute; top: 6px; right: 13px; min-width: 17px; height: 17px; padding: 0 4px; border: 2px solid #fbfbfd; border-radius: 9px; color: white; background: var(--red); font-size: 9px; line-height: 13px; }
.rail-profile { display: grid; width: 42px; height: 42px; place-items: center; margin-top: auto; border: 0; border-radius: 50%; color: #445064; background: #e9edf5; font-size: 12px; font-weight: 800; cursor: pointer; }

.chat-sidebar { z-index: 3; display: flex; min-width: 0; flex-direction: column; border-right: 1px solid var(--line); background: white; }
.sidebar-header { display: flex; min-height: 91px; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.sidebar-header p { margin: 0 0 2px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.sidebar-header h1 { margin: 0; font-size: 24px; letter-spacing: -.045em; }
.round-button, .icon-button { display: grid; place-items: center; border: 0; cursor: pointer; }
.round-button { width: 40px; height: 40px; border-radius: 13px; color: var(--blue); background: var(--blue-soft); }
.round-button:hover { background: #dcecff; }
.sidebar-actions { padding: 7px 15px 10px; }
.sidebar-actions > button { display: flex; width: 100%; align-items: center; gap: 11px; padding: 12px; border: 1px solid #d9e8fd; border-radius: 14px; color: var(--blue); background: #f5f9ff; text-align: left; cursor: pointer; }
.sidebar-actions > button > svg { width: 20px; flex: 0 0 auto; }
.sidebar-actions > button > span { display: grid; gap: 2px; }
.sidebar-actions strong { font-size: 12px; }
.sidebar-actions small { color: #75849a; font-size: 9px; font-weight: 500; }
.search-field { display: flex; min-height: 39px; align-items: center; gap: 8px; margin: 0 15px 8px; padding: 0 11px; border-radius: 11px; color: #8b8f9c; background: #f1f2f6; }
.search-field svg { width: 16px; height: 16px; }
.search-field input { width: 100%; min-height: auto; padding: 0; border: 0; box-shadow: none; background: transparent; font-size: 12px; }
.conversation-list { min-height: 0; flex: 1; overflow: auto; padding: 4px 9px 14px; scrollbar-width: thin; }
.conversation-row { display: flex; width: 100%; align-items: center; gap: 11px; padding: 10px; border: 0; border-radius: 14px; background: transparent; text-align: left; cursor: pointer; }
.conversation-row:hover { background: #f7f8fb; }
.conversation-row.is-active { background: var(--blue-soft); }
.avatar { display: grid; width: 43px; height: 43px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #30405a; background: linear-gradient(145deg, #dce9ff, #dcd8ff); font-size: 12px; font-weight: 800; }
.avatar:nth-child(4n+2) { background: linear-gradient(145deg, #d9f4ea, #d9e8f8); }
.avatar:nth-child(4n+3) { background: linear-gradient(145deg, #ffe4db, #ffeccd); }
.avatar-small { width: 36px; height: 36px; font-size: 10px; }
.conversation-copy { display: grid; min-width: 0; flex: 1; gap: 5px; }
.conversation-title, .conversation-preview { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 7px; }
.conversation-title strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-title time { flex: 0 0 auto; color: #999eaa; font-size: 9px; }
.conversation-preview > span:first-child { overflow: hidden; color: #7d818e; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.unread-count { display: grid; min-width: 18px; height: 18px; flex: 0 0 auto; place-items: center; padding: 0 5px; border-radius: 9px; color: white; background: var(--blue); font-size: 9px; }
.conversation-empty { padding: 40px 20px; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }
.sidebar-profile { display: flex; align-items: center; gap: 10px; padding: 13px 15px max(13px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sidebar-profile > span:nth-child(2) { display: grid; min-width: 0; flex: 1; gap: 2px; }
.sidebar-profile strong, .sidebar-profile small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-profile strong { font-size: 11px; }
.sidebar-profile small { color: var(--muted); font-size: 9px; }
.icon-button { width: 36px; height: 36px; border-radius: 10px; color: #7b808e; background: transparent; }
.icon-button:hover { background: var(--surface-soft); }

.workspace { position: relative; min-width: 0; min-height: 0; background: var(--bg); }
.chat-view { display: grid; height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-header { z-index: 2; display: flex; min-height: 76px; align-items: center; gap: 12px; padding: 12px clamp(14px, 2.3vw, 30px); border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 92%); backdrop-filter: blur(18px); }
.mobile-back { display: none; }
.chat-heading { min-width: 0; flex: 1; }
.chat-heading h2 { overflow: hidden; margin: 0 0 3px; font-size: 15px; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.chat-heading p { margin: 0; color: var(--muted); font-size: 10px; }
.notification-pill { display: inline-flex; min-height: 38px; align-items: center; gap: 7px; padding: 0 12px; border: 1px solid #dfe3eb; border-radius: 20px; color: #626775; background: white; font-size: 10px; font-weight: 700; cursor: pointer; }
.notification-pill:hover { color: var(--blue); border-color: #bdd7fb; }
.notification-pill svg { width: 16px; height: 16px; }
.chat-options-button { flex: 0 0 auto; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #c8cbd3; }
.notification-pill.is-on .status-dot { background: var(--green); box-shadow: 0 0 0 3px rgb(35 162 109 / 12%); }
.message-stage { position: relative; min-height: 0; overflow: hidden; background: linear-gradient(180deg, #fafbfe, #f7f8fb); }
.message-list { display: flex; width: 100%; min-width: 0; max-width: 100%; height: 100%; flex-direction: column; gap: 8px; overflow-x: hidden; overflow-y: auto; padding: 22px clamp(15px, 5vw, 70px) 18px; scroll-behavior: smooth; scrollbar-width: thin; }
/* History must scroll, not shrink its rows to fit the viewport. This also
   preserves full bubble height after media loads or a link card is added. */
.message-list > .message-row, .message-list > .day-label { flex: 0 0 auto; }
.empty-chat { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 24px; text-align: center; }
.empty-chat > span { display: grid; width: 66px; height: 66px; place-items: center; border-radius: 23px; color: var(--blue); background: white; box-shadow: 0 12px 34px rgb(55 63 91 / 10%); }
.empty-chat > span svg { width: 31px; height: 31px; }
.empty-chat h2 { margin: 19px 0 7px; font-size: 18px; letter-spacing: -.03em; }
.empty-chat p { margin: 0; color: var(--muted); font-size: 12px; }
.day-label { display: flex; align-items: center; justify-content: center; margin: 4px 0 12px; color: #969aa6; font-size: 9px; font-weight: 750; }
.day-label span { padding: 5px 9px; border: 1px solid #e7e9ef; border-radius: 10px; background: rgb(255 255 255 / 80%); }
.message-row { display: flex; width: 100%; min-width: 0; max-width: 100%; align-items: flex-end; gap: 6px; }
.message-row.is-mine { justify-content: flex-end; }
.message-block { display: flex; width: 70%; min-width: 0; max-width: 560px; flex: 0 0 auto; flex-direction: column; align-items: flex-start; gap: 3px; }
.is-mine .message-block { align-items: flex-end; }
.message-sender { margin: 0 0 1px 10px; color: #747988; font-size: 9px; font-weight: 700; }
.bubble-wrap { display: grid; width: 100%; min-width: 0; max-width: 100%; grid-template-columns: minmax(0, 1fr) 28px; align-items: center; gap: 4px; }
.is-mine .bubble-wrap { grid-template-columns: 28px minmax(0, 1fr); }
.message-menu { width: 28px; height: 28px; grid-column: 2; grid-row: 1; opacity: 0; }
.is-mine .message-menu { grid-column: 1; }
.message-row:hover .message-menu, .message-menu:focus-visible { opacity: 1; }
.bubble { width: auto; min-width: 0; max-width: 100%; grid-column: 1; grid-row: 1; justify-self: start; padding: 9px 13px; border: 1px solid #e2e4eb; border-radius: 18px 18px 18px 6px; color: #242833; background: white; box-shadow: 0 3px 11px rgb(44 50 73 / 5%); font-size: 14px; line-height: 1.42; overflow-wrap: anywhere; white-space: pre-wrap; }
.is-mine .bubble { grid-column: 2; justify-self: end; }
.is-mine .bubble { color: white; border-color: var(--blue); border-radius: 18px 18px 6px 18px; background: var(--blue); box-shadow: 0 5px 14px rgb(22 119 255 / 16%); }
.bubble.has-media { display: flex; width: 100%; max-width: 370px; flex-direction: column; align-items: stretch; padding: 4px; overflow: hidden; }
.bubble.has-media .message-text { display: block; padding: 6px 9px 7px; }
.message-link { color: #1268d8; font-weight: 650; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.is-mine .message-link { color: white; }
.message-link:hover { text-decoration-thickness: 2px; }
.message-media { display: block; width: 100%; height: auto; min-height: 1px; max-width: 100%; max-height: none; flex: none; border-radius: 14px; object-fit: contain; background: #e9ebf1; }
.link-preview-card { display: block; width: 340px; max-width: 100%; margin-top: 9px; overflow: hidden; border: 1px solid #dfe3eb; border-radius: 14px; color: #232733; background: white; box-shadow: 0 4px 13px rgb(27 34 52 / 9%); text-decoration: none; white-space: normal; }
.link-preview-card:hover { border-color: #b9cce7; }
.link-preview-card:first-child { margin-top: 0; }
.link-preview-image { display: block; width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; background: #edf0f5; }
.link-preview-copy { display: grid; gap: 4px; padding: 10px 11px 11px; }
.link-preview-site { overflow: hidden; color: #777d8a; font-size: 9px; font-weight: 750; letter-spacing: .02em; text-overflow: ellipsis; white-space: nowrap; }
.link-preview-title { display: -webkit-box; overflow: hidden; color: #252934; font-size: 12px; font-weight: 780; line-height: 1.3; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.link-preview-description { display: -webkit-box; overflow: hidden; color: #6f7480; font-size: 10px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.is-mine .link-preview-card { border-color: rgb(255 255 255 / 55%); color: #232733; }
.deleted-bubble { display: inline-flex; align-items: center; gap: 7px; color: #898d99; border-style: dashed; background: transparent; box-shadow: none; font-size: 11px; font-style: italic; }
.is-mine .deleted-bubble { color: #8c909b; border-color: #d6d9e0; background: transparent; box-shadow: none; }
.deleted-bubble svg { width: 14px; height: 14px; }
.message-meta { display: flex; align-items: center; gap: 5px; padding: 0 4px; color: #9397a3; font-size: 8px; }
.receipt.read { color: var(--blue); }
.composer-wrap { padding: 11px clamp(14px, 3vw, 38px) max(11px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: white; }
.composer { display: flex; align-items: flex-end; gap: 7px; }
.composer-button { display: grid; width: 39px; height: 39px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 50%; color: var(--blue); background: #edf5ff; cursor: pointer; }
.composer-button:disabled { opacity: .45; cursor: default; }
.draft-wrap { position: relative; display: flex; min-width: 0; flex: 1; align-items: flex-end; border: 1px solid #dfe2ea; border-radius: 21px; background: #fbfbfd; }
.draft-wrap:focus-within { border-color: #a8cafa; box-shadow: 0 0 0 3px rgb(22 119 255 / 8%); }
.draft-wrap textarea { width: 100%; min-height: 40px; max-height: 130px; resize: none; padding: 10px 42px 9px 14px; border: 0; box-shadow: none; background: transparent; font-size: 13px; line-height: 1.45; }
.draft-wrap .composer-button { position: absolute; right: 2px; bottom: 1px; color: #8b8f9c; background: transparent; }
.send-button { display: grid; width: 39px; height: 39px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 50%; color: white; background: var(--blue); cursor: pointer; }
.send-button svg { width: 18px; height: 18px; }
.send-button:disabled { background: #c8d8ed; cursor: default; }
.file-preview { display: flex; align-items: center; gap: 9px; margin: 0 45px 9px; padding: 8px 10px; border: 1px solid #dfe5ef; border-radius: 12px; color: #525765; background: #f8f9fb; font-size: 10px; }
.file-preview > span { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview button { width: 28px; height: 28px; }
.emoji-picker { position: absolute; z-index: 9; right: 0; bottom: 48px; display: grid; width: 230px; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 10px; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: var(--shadow); }
.emoji-picker button { display: grid; width: 31px; height: 31px; place-items: center; border: 0; border-radius: 8px; background: transparent; font-size: 19px; cursor: pointer; }
.emoji-picker button:hover { background: var(--surface-soft); }

.panel-view { height: 100%; overflow-y: auto; padding: clamp(22px, 4vw, 48px); background: #f8f9fc; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; max-width: 1100px; margin: 0 auto 26px; }
.panel-header h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.045em; }
.panel-header p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.panel-header .secondary-button svg { width: 16px; height: 16px; }
.tab-bar { display: flex; max-width: 1100px; gap: 4px; margin: 0 auto 20px; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: white; overflow-x: auto; }
.tab-bar button { display: inline-flex; min-height: 36px; flex: 0 0 auto; align-items: center; gap: 6px; padding: 0 14px; border: 0; border-radius: 9px; color: #6f7481; background: transparent; font-size: 11px; font-weight: 750; cursor: pointer; }
.tab-bar button.is-active { color: var(--blue); background: var(--blue-soft); }
.tab-bar button span { min-width: 17px; padding: 2px 5px; border-radius: 8px; color: white; background: var(--red); font-size: 8px; }
.admin-content { max-width: 1100px; margin: auto; }
.loading-card, .empty-card { padding: 60px 20px; border: 1px solid var(--line); border-radius: 18px; color: var(--muted); background: white; font-size: 12px; text-align: center; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.stat-card { display: grid; gap: 8px; padding: 19px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.stat-card span { color: var(--muted); font-size: 10px; font-weight: 700; }
.stat-card strong { font-size: 28px; letter-spacing: -.04em; }
.stat-card small { color: #9a9eaa; font-size: 9px; }
.admin-note { display: flex; align-items: flex-start; gap: 12px; margin-top: 14px; padding: 17px; border: 1px solid #dce8fa; border-radius: 15px; color: #42516a; background: #f3f8ff; }
.admin-note svg { flex: 0 0 auto; color: var(--blue); }
.admin-note h3 { margin: 0 0 4px; font-size: 12px; }
.admin-note p { margin: 0; color: #70798a; font-size: 10px; line-height: 1.55; }
.admin-table-wrap { border: 1px solid var(--line); border-radius: 17px; background: white; overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 13px 15px; border-bottom: 1px solid #eef0f4; text-align: left; }
.admin-table th { color: #868a96; background: #fafbfc; font-size: 9px; letter-spacing: .05em; text-transform: uppercase; }
.admin-table td { font-size: 11px; }
.admin-table tr:last-child td { border-bottom: 0; }
.user-cell { display: flex; align-items: center; gap: 9px; }
.user-cell > span:last-child { display: grid; gap: 2px; }
.user-cell small { color: var(--muted); }
.status-chip { display: inline-flex; padding: 4px 7px; border-radius: 8px; color: #19724d; background: #e9f8f0; font-size: 9px; font-weight: 750; }
.status-chip.off { color: #8a4e52; background: #fff0f1; }
.role-chip { display: inline-flex; margin-left: 5px; padding: 2px 5px; border-radius: 6px; color: var(--purple); background: #f0edff; font-size: 8px; }
.small-action { min-height: 32px; padding: 0 10px; border: 1px solid #dfe2ea; border-radius: 9px; color: #555a67; background: white; font-size: 9px; font-weight: 750; cursor: pointer; }
.deleted-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.deleted-card { display: grid; grid-template-columns: 138px minmax(0, 1fr); gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.deleted-media { display: grid; width: 138px; height: 116px; place-items: center; overflow: hidden; border-radius: 12px; color: #8b8f9a; background: #eef0f4; }
.deleted-media img, .deleted-media video { width: 100%; height: 100%; object-fit: cover; }
.deleted-copy { display: flex; min-width: 0; flex-direction: column; }
.deleted-copy h3 { overflow: hidden; margin: 2px 0 5px; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.deleted-copy p { margin: 0 0 4px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.deleted-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 9px; }
.deleted-actions button { min-height: 31px; flex: 1; padding: 0 8px; }
.audit-list { display: grid; border: 1px solid var(--line); border-radius: 17px; background: white; overflow: hidden; }
.audit-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; padding: 14px 16px; border-bottom: 1px solid #eef0f4; }
.audit-row:last-child { border-bottom: 0; }
.audit-row time { color: var(--muted); font-size: 9px; }
.audit-row strong { display: block; margin-bottom: 4px; font-size: 11px; }
.audit-row p { margin: 0; color: var(--muted); font-size: 9px; }

.settings-grid { display: grid; max-width: 900px; gap: 13px; margin: 0 auto; }
.settings-card { display: flex; align-items: flex-start; gap: 16px; padding: 21px; border: 1px solid var(--line); border-radius: 18px; background: white; }
.settings-card > div { min-width: 0; flex: 1; }
.settings-card h2 { margin: 1px 0 6px; font-size: 14px; }
.settings-card p { margin: 0 0 14px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.settings-icon { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 13px; }
.settings-icon.blue { color: var(--blue); background: var(--blue-soft); }
.settings-icon.purple { color: var(--purple); background: #f0edff; }
.settings-icon.red { color: var(--red); background: #fff0f1; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.helper { margin-top: 10px !important; font-size: 9px !important; }
.settings-card .stack-form { max-width: 460px; }
.danger-card { border-color: #f1dfe1; }

dialog { color: var(--text); }
dialog::backdrop { background: rgb(21 25 38 / 46%); backdrop-filter: blur(6px); }
.modal, .confirm-dialog { width: min(440px, calc(100vw - 28px)); padding: 28px; border: 1px solid rgb(255 255 255 / 80%); border-radius: 22px; background: white; box-shadow: 0 24px 80px rgb(18 22 35 / 28%); }
.modal-close { position: absolute; top: 12px; right: 12px; display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: 10px; color: #818591; background: #f2f3f6; cursor: pointer; }
.modal-icon, .confirm-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 14px; color: var(--purple); background: #f0edff; }
.modal-icon.blue { color: var(--blue); background: var(--blue-soft); }
.modal h2, .confirm-dialog h2 { margin: 18px 0 7px; font-size: 21px; letter-spacing: -.035em; }
.modal > p, .confirm-dialog > p { margin: 0 0 18px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.wide-button { width: 100%; }
.invite-result { display: flex; align-items: center; gap: 7px; margin: 17px 0 9px; padding: 11px; border: 1px dashed #9ebfec; border-radius: 12px; background: #f4f8ff; }
.invite-result code { min-width: 0; flex: 1; overflow-wrap: anywhere; color: #194f96; font-size: 12px; }
.modal-helper { margin-bottom: 15px !important; font-size: 9px !important; }
.phone-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.phone-search-row button { white-space: nowrap; }
.search-helper { margin: -4px 0 2px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.member-picker { display: grid; max-height: 260px; gap: 5px; padding: 3px; overflow-y: auto; }
.member-option { display: flex; align-items: center; gap: 9px; padding: 9px; border-radius: 10px; background: #f8f9fb; color: #4d5260; font-size: 11px; cursor: pointer; }
.member-option input { min-height: auto; accent-color: var(--blue); }
.action-sheet { width: min(370px, calc(100vw - 24px)); padding: 8px; border: 0; border-radius: 20px; background: #f4f5f8; box-shadow: var(--shadow); }
.action-sheet > button { display: flex; width: 100%; align-items: center; gap: 11px; padding: 13px; border: 0; border-bottom: 1px solid #e2e4ea; color: #343844; background: white; text-align: left; cursor: pointer; }
.action-sheet > button:first-of-type { border-radius: 14px 14px 0 0; }
.action-sheet > button:last-of-type { border-bottom: 0; border-radius: 0 0 14px 14px; }
.action-sheet > button svg { flex: 0 0 auto; }
.action-sheet > button span { display: grid; gap: 2px; }
.action-sheet strong { font-size: 12px; }
.action-sheet small { color: var(--muted); font-size: 9px; }
.action-sheet .danger-action { color: var(--red); }
.sheet-preview { margin: 0 0 8px; padding: 12px; border-radius: 14px; color: #5d6270; background: white; font-size: 10px; line-height: 1.5; }
.sheet-cancel { width: 100%; margin-top: 8px; padding: 12px; border: 0; border-radius: 14px; color: var(--blue); background: white; font-weight: 750; cursor: pointer; }
.user-modal { max-height: calc(100svh - 30px); overflow-y: auto; }
.user-modal hr { margin: 22px 0; border: 0; border-top: 1px solid var(--line); }
.user-modal h3 { margin: 0; font-size: 13px; }
.user-modal .stack-form p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.switch-row { display: flex !important; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch-row[hidden] { display: none !important; }
.switch-row > span { display: grid; gap: 3px; }
.switch-row small { color: var(--muted); font-weight: 500; }
.switch-row input { width: 20px; min-height: auto; accent-color: var(--blue); }
.confirm-dialog { text-align: center; }
.confirm-icon { margin: auto; color: var(--red); background: #fff0f1; }
.confirm-dialog > div:last-child { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toast { position: fixed; z-index: 50; right: 20px; bottom: 20px; display: flex; max-width: min(390px, calc(100vw - 32px)); align-items: center; gap: 9px; padding: 11px 15px 11px 11px; border: 1px solid #dfe4ec; border-radius: 14px; background: white; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.toast > span { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; color: var(--green); background: #e9f8f0; }
.toast svg { width: 14px; height: 14px; }
.toast p { margin: 0; color: #505561; font-size: 11px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.mobile-nav { display: none; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 72px 300px minmax(0, 1fr); }
  .deleted-grid { grid-template-columns: 1fr; }
  .admin-table th:nth-child(3), .admin-table td:nth-child(3) { display: none; }
}

@media (max-width: 760px) {
  html, body { min-height: 100%; }
  body.app-open { position: fixed; inset: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
  .app-shell { position: fixed; inset: var(--chatably-viewport-top, 0px) auto auto var(--chatably-viewport-left, 0px); display: block; width: var(--chatably-viewport-width, 100dvw); min-width: 0; max-width: var(--chatably-viewport-width, 100dvw); height: var(--chatably-viewport-height, 100dvh); padding-bottom: calc(59px + env(safe-area-inset-bottom)); overflow: hidden; }
  body.keyboard-open .app-shell { padding-bottom: 0; }
  body.keyboard-open .mobile-nav { display: none; }
  body.keyboard-open .composer-wrap { padding-bottom: 8px; }
  .app-shell.panel-mode { display: block; }
  .nav-rail { display: none; }
  .chat-sidebar { width: 100%; height: 100%; border: 0; }
  .chat-sidebar.mobile-hidden { display: none; }
  .workspace, .chat-view, .message-stage, .message-list { width: 100%; min-width: 0; max-width: 100%; overflow-x: hidden; }
  .workspace { height: 100%; }
  .workspace.sidebar-visible { display: none; }
  .chat-view { height: 100%; }
  .mobile-back { display: grid; width: 34px; height: 38px; margin-left: -8px; color: var(--blue); }
  .chat-header { min-height: 67px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; }
  .chat-header .avatar { width: 38px; height: 38px; }
  .notification-pill { width: 38px; min-height: 38px; justify-content: center; padding: 0; }
  .notification-pill > span:not(.status-dot) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .status-dot { position: absolute; margin: -23px -23px 0 0; border: 2px solid white; }
  .message-list { padding: 16px 11px 12px; }
  .message-block { width: 82%; max-width: 82%; }
  .bubble { font-size: 14px; }
  .auth-form input, .stack-form input, .search-field input, .draft-wrap textarea { font-size: 16px; }
  .message-menu { opacity: .75; }
  .composer-wrap { padding: 8px 9px max(8px, env(safe-area-inset-bottom)); }
  .composer-button, .send-button { width: 37px; height: 37px; }
  .file-preview { margin-right: 40px; margin-left: 40px; }
  .panel-view { padding: max(22px, env(safe-area-inset-top)) 14px 20px; }
  .panel-header { display: grid; }
  .panel-header .secondary-button { width: fit-content; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-table-wrap { overflow-x: auto; }
  .admin-table { min-width: 620px; }
  .admin-table th:nth-child(3), .admin-table td:nth-child(3) { display: table-cell; }
  .deleted-card { grid-template-columns: 105px minmax(0, 1fr); }
  .deleted-media { width: 105px; height: 105px; }
  .settings-card { padding: 17px; }
  .settings-icon { width: 38px; height: 38px; }
  .mobile-nav { position: absolute; z-index: 20; inset: auto 0 0; display: flex; height: calc(59px + env(safe-area-inset-bottom)); align-items: flex-start; justify-content: space-around; padding: 6px 10px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgb(255 255 255 / 95%); backdrop-filter: blur(18px); }
  .mobile-nav button { display: grid; min-width: 70px; place-items: center; gap: 2px; border: 0; color: #8c909d; background: transparent; font-size: 9px; font-weight: 700; cursor: pointer; }
  .mobile-nav svg { width: 21px; height: 21px; }
  .mobile-nav button.is-active { color: var(--blue); }
  .toast { right: 16px; bottom: calc(72px + env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .phone-search-row { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
  .auth-card { padding: 27px 21px; border-radius: 23px; }
  .auth-brand { margin-bottom: 27px; }
  .auth-copy h1 { font-size: 28px; }
  .sidebar-header { min-height: 83px; }
  .deleted-card { grid-template-columns: 1fr; }
  .deleted-media { width: 100%; height: 190px; }
  .audit-row { grid-template-columns: 1fr; gap: 6px; }
  .settings-card { gap: 12px; }
  .button-row > button { flex: 1; }
}

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