@charset "UTF-8";

:root {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-size: 14px;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  --ink: #23323b;
  --accent: #087caf;
  --muted: #6e7a82;
  --line: #e0e6e7;
  --blue: #eaf4f9;
  --red: #ba4350;
  --surface: #fff;
  --canvas: #f6f7f5;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { outline-offset: 3px; }
button, a { -webkit-tap-highlight-color: transparent; }
button {
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
  line-height: 1.4;
}
button:disabled { cursor: default; opacity: .45; }
button[aria-busy="true"] { cursor: wait; opacity: .75; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
svg { flex-shrink: 0; }
button.primary, button.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color .16s, border-color .16s, box-shadow .16s;
}
button.primary { background: var(--accent); color: #fff; }
button.secondary { background: #fff; border-color: var(--line); color: #46565f; font-weight: 500; }
.danger { color: var(--red) !important; }
button.primary.danger { color: #fff !important; background: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.brand-logo { display: block; width: 40px; height: 40px; object-fit: cover; flex-shrink: 0; border-radius: 10px; border: 1px solid #dce7eb; }
.loading { display: grid; place-items: center; min-height: 80dvh; align-content: center; gap: 18px; }
.loading p { color: var(--muted); }

/* A compact identity and a focused sign-in form, without a marketing screen. */
.login { min-height: 100dvh; display: grid; grid-template-columns: minmax(260px, 400px) minmax(320px, 380px); align-items: center; justify-content: center; gap: clamp(50px, 9vw, 130px); padding: 64px 40px; background: var(--canvas); }
.login-story { align-self: center; padding: 20px 0; }
.login-illustration { width: 132px; height: 132px; border-radius: 26px; margin-bottom: 25px; border-color: #d8e4e7; }
.wordmark { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.wordmark h1 { font-size: 36px; line-height: 1.25; letter-spacing: 1px; font-weight: 650; margin: 0; }
.wordmark > span { font-size: 15px; color: #4c616c; }
.login-story > p { margin: 26px 0 24px; font-size: 13px; color: var(--muted); line-height: 1.9; }
.login-role-note { display: inline-block; border-top: 1px solid var(--line); padding-top: 18px; font-size: 11px; color: var(--muted); }
.login-form { padding: 32px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.login-form form { width: 100%; max-width: 100%; }
.login-form h2 { font-size: 23px; font-weight: 650; margin-bottom: 10px; letter-spacing: -.2px; }
.login-form form > p { color: var(--muted); font-size: 12px; line-height: 1.8; margin-bottom: 28px; }
.login-mobile-brand { display: none; }
.login-form form > .login-help { padding-top: 20px; margin: 20px 0 0; border-top: 1px solid var(--line); font-size: 11px; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; font-size: 13px; }
.field > span { color: #46565f; font-weight: 500; }
.field input, .field textarea, .field select, .search, .welcome-block textarea {
  border: 1px solid #dce3e5;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  min-width: 0;
  color: var(--ink);
  transition: border-color .16s, box-shadow .16s, background-color .16s;
}
.field input:focus, .field textarea:focus, .field select:focus, .search:focus, .welcome-block textarea:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px #087caf14;
}
input::placeholder, textarea::placeholder { color: #8b979e; opacity: 1; }
.login-form .primary { width: 100%; min-height: 40px; margin-top: 6px; }
.form-error { min-height: 20px; color: var(--red); font-size: 12px; line-height: 1.7; margin-top: 12px; overflow-wrap: anywhere; }

/* Full labels at desktop widths; compact navigation has its own short labels. */
.workspace { height: 100dvh; display: flex; overflow: hidden; }
.rail {
  width: 208px;
  min-height: 0;
  background: #fcfdfb;
  border-right: 1px solid var(--line);
  padding: 24px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 22px;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.rail-brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 8px; }
.rail .brand-logo { width: 42px; height: 42px; border-radius: 11px; }
.brand-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; line-height: 1.3; }
.brand-copy strong, .brand-copy > span:first-child { font-size: 18px; font-weight: 650; white-space: nowrap; }
.brand-copy > span, .brand-copy small, .brand-copy .small { color: var(--muted); font-size: 10px; font-weight: 400; }
.rail-nav { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.rail-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  color: #63747d;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  transition: background-color .16s, color .16s;
}
.rail-button svg { width: 20px; height: 20px; }
.rail-button .nav-label { white-space: nowrap; font-size: 13px; line-height: 1.4; }
.rail-button .nav-short { display: none; }
.rail-button.active { background: #e6f1f6; color: #0876a6; font-weight: 600; }
.rail-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); width: 100%; }
.rail-profile { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 10px 2px; }
.rail-profile .avatar { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.profile-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; line-height: 1.4; }
.profile-copy strong, .profile-copy > span:first-child { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy small, .profile-copy .small { color: var(--muted); font-size: 11px; }
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #eaf4f9;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar.green { background: #e8f4ee; color: #27856a; }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail-button { position: relative; }
.nav-unread { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; font-size: 10px; font-weight: 600; color: #fff; background: #e35b60; line-height: 1; }
.nav-unread[hidden] { display: none; }
.visitor-original, .visitor-origin { display: block; font-size: 10px; color: var(--muted); line-height: 1.5; margin-top: 3px; overflow-wrap: anywhere; }
.chat-person .visitor-origin { margin: -2px 0 4px; }
.chat-person .status-line { font-size: 10px; }
.sound-toggle.enabled { color: var(--accent); background: var(--blue); border-radius: 7px; }
.avatar-preview { display: flex; justify-content: center; margin-bottom: 20px; }
.avatar-preview .avatar, .profile-preview .avatar { width: 64px; height: 64px; border-radius: 18px; font-size: 32px; }
.avatar-options { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; margin: -4px 0 20px; max-width: 400px; }
.avatar-options button { min-height: 36px; min-width: 0; width: 100%; padding: 4px; border: 1px solid var(--line); border-radius: 7px; font-size: 21px; background: #fff; }
.avatar-options button:hover { background: var(--blue); border-color: #91bfd3; }
.settings-form.profile-form { max-width: 680px; }
.profile-preview { display: flex; align-items: center; gap: 18px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line); }
.profile-preview strong { display: block; margin-bottom: 7px; font-size: 14px; }
.profile-preview p { margin: 0; }
.profile-panel .field { max-width: 440px; }
.profile-photo-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 5px; }
.profile-panel .actions { display: flex; justify-content: flex-end; padding-top: 15px; margin-top: 15px; border-top: 1px solid var(--line); }

/* Inbox, conversation, and composer remain separate, stable scroll regions. */
.inbox { width: 300px; min-width: 0; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; flex-shrink: 0; }
.inbox-head { padding: 24px 20px 18px; }
.inbox-head h2 { font-size: 20px; line-height: 1.3; margin: 0 0 7px; font-weight: 650; }
.inbox-head .search { width: 100%; padding: 9px 11px; margin-top: 16px; background: var(--canvas); border-color: transparent; font-size: 13px; }
.inbox-head .search:focus { background: #fff; border-color: var(--accent); }
.inbox-head select.search { margin-top: 8px; }
.inbox-search { display: flex; align-items: center; gap: 3px; margin-top: 16px; min-width: 0; border: 1px solid transparent; border-radius: 8px; background: var(--canvas); transition: border-color .16s, box-shadow .16s; }
.inbox-search:focus-within { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px #087caf0c; }
.inbox-search > svg { width: 16px; height: 16px; margin-left: 11px; color: #8a989e; }
.inbox-head .inbox-search .search { flex: 1; width: 100%; min-width: 0; margin: 0; padding: 9px 6px; border: 0; background: transparent; box-shadow: none; }
.inbox-search .search::-webkit-search-cancel-button { display: none; }
.inbox-search .search-clear { flex-shrink: 0; width: 30px; height: 30px; margin-right: 3px; }
.inbox-search .search-clear svg { width: 15px; height: 15px; }
.inbox-search .search-clear[hidden] { display: none; }
.list-tabs { display: flex; gap: 20px; padding: 0 20px; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.list-tabs button { position: relative; padding: 10px 1px 12px; min-height: 40px; }
.list-tabs button.selected { color: var(--accent); font-weight: 600; }
.list-tabs button.selected::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.visitors { overflow: auto; overscroll-behavior-y: contain; flex: 1; min-height: 0; }
.visitor { display: flex; gap: 11px; padding: 17px 18px; border-bottom: 1px solid #eef1ef; width: 100%; text-align: left; transition: background-color .16s; }
.visitor.active { background: var(--blue); box-shadow: inset 3px 0 var(--accent); }
.visitor-text { flex: 1; min-width: 0; }
.visitor-name { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; line-height: 1.5; overflow-wrap: anywhere; }
.visitor-preview { font-size: 12px; color: #7b8991; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; margin-top: 6px; }
.admin-workspace .inbox { width: 328px; }
.admin-workspace .inbox-head { padding-bottom: 14px; }
.agent-selector { display: flex; flex-direction: column; gap: 7px; margin-top: 15px; font-size: 12px; color: var(--muted); }
.agent-selector > span { font-weight: 600; color: #46565f; }
.agent-selector { position: relative; }
.agent-select-trigger { display: flex; align-items: center; gap: 9px; width: 100%; min-width: 0; min-height: 46px; padding: 8px 10px; border: 1px solid #dce3e5; border-radius: 9px; background: #fff; color: var(--ink); text-align: left; font-size: 13px; }
.agent-select-trigger::after { content: ''; flex: 0 0 7px; height: 7px; margin: 0 3px 3px auto; border-right: 1.5px solid #7b8b93; border-bottom: 1.5px solid #7b8b93; transform: rotate(45deg); transition: transform .16s; }
.agent-select-trigger[aria-expanded="true"] { border-color: #7db7d0; box-shadow: 0 0 0 3px #087caf0c; }
.agent-select-trigger[aria-expanded="true"]::after { transform: rotate(225deg); margin-bottom: -3px; }
.agent-select-value { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.agent-select-trigger .avatar, .agent-select-option .avatar { width: 29px; height: 29px; border-radius: 8px; font-size: 13px; }
.agent-select-popover { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40; max-height: min(350px, 48dvh); overflow-y: auto; overscroll-behavior: contain; padding: 5px; border: 1px solid #dce4e7; border-radius: 11px; background: #fff; box-shadow: 0 12px 35px #1d365321; animation: menu-reveal .12s ease-out; }
.agent-select-option { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 46px; padding: 8px; border-radius: 7px; text-align: left; color: #263752; }
.agent-select-option:hover, .agent-select-option:focus-visible, .agent-select-option.active { background: #f1f5f5; outline: 0; }
.agent-select-option[aria-selected="true"] { background: #eaf4f9; color: var(--accent); }
.agent-select-option[aria-selected="true"]::after { content: '✓'; margin-left: auto; color: var(--accent); font-size: 15px; }
.agent-option-copy, .agent-select-copy { display: flex; flex: 1; flex-direction: column; gap: 3px; min-width: 0; }
.agent-option-copy strong, .agent-select-copy strong { font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.agent-option-copy > span, .agent-select-copy > span { font-size: 10px; color: #7c8c94; overflow-wrap: anywhere; }
.agent-select-trigger > span[aria-hidden="true"] { display: none; }
@keyframes menu-reveal { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: translateY(0); } }
.agent-scope { display: flex; align-items: center; gap: 9px; min-width: 0; margin-top: 12px; padding: 11px 10px; background: #f1f6f8; border-radius: 8px; }
.agent-scope .avatar { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
.scope-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.scope-copy strong { font-size: 12px; font-weight: 600; }
.scope-copy > span { font-size: 10px; color: var(--muted); line-height: 1.6; }
.scope-count { flex-shrink: 0; color: #577685; font-size: 10px; white-space: nowrap; }
.visitor-owner { margin-top: 5px; font-size: 10px; color: #577685; line-height: 1.7; overflow-wrap: anywhere; }
.admin-workspace .visitor { padding-top: 13px; padding-bottom: 13px; }
.conversation-context { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px 12px; min-height: 42px; padding: 9px 24px; border-bottom: 1px solid var(--line); background: #fff; font-size: 12px; color: var(--muted); }
.conversation-owner { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.conversation-owner svg { width: 15px; height: 15px; }
.conversation-owner strong { color: #46565f; font-weight: 600; }
.owner-account { color: #7b8991; }
.admin-identity { font-size: 11px; color: var(--accent); white-space: nowrap; }
.message-role { display: inline-block; border-radius: 4px; padding: 1px 5px; margin-right: 5px; color: #466ba4; background: #e8effb; font-size: 10px; font-weight: 600; }
.row-actions .view-chats { color: var(--accent); background: var(--blue); border-radius: 6px; margin-right: 4px; }
.visitor-time { font-size: 10px; color: #87939a; white-space: nowrap; padding-top: 2px; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; border-radius: 20px; font-size: 10px; min-width: 17px; height: 17px; padding: 0 5px; flex-shrink: 0; }
.status-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); min-width: 0; }
.dot { display: inline-block; border-radius: 50%; width: 6px; height: 6px; background: #279b79; flex-shrink: 0; }
.dot.off { background: #a0adbf; }
.list-more { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 13px; width: 100%; min-height: 42px; color: var(--accent); font-size: 12px; }
.conversation { display: flex; flex: 1; min-width: 0; min-height: 0; flex-direction: column; background: var(--canvas); }
.chat-header { height: 72px; padding: 0 24px; display: flex; align-items: center; gap: 12px; background: #fff; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.chat-header > div { min-width: 0; }
.chat-header h3 { font-size: 15px; font-weight: 600; margin: 0 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header .header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.icon-button { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: #7a899e; transition: color .16s, background-color .16s; }
.icon-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.chat-messages { flex: 1; overflow: auto; overscroll-behavior-y: contain; padding: 24px 26px 14px; scroll-behavior: auto; min-height: 0; }
.message-stage { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
.latest-messages { position: absolute; right: 20px; bottom: 14px; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 7px 12px; border: 1px solid #cbdde5; border-radius: 18px; background: #fff; color: var(--accent); box-shadow: 0 3px 14px #23323b14; font-size: 12px; font-weight: 500; z-index: 2; }
.latest-messages[hidden] { display: none; }
.latest-messages svg { width: 15px; height: 15px; }
.day-separator { width: fit-content; text-align: center; color: #7b8b92; background: #edf0ee; border-radius: 12px; padding: 3px 10px; font-size: 10px; line-height: 1.5; margin: 0 auto 22px; font-variant-numeric: tabular-nums; }
.message-row { display: flex; gap: 10px; margin: 0 0 20px; align-items: flex-start; }
.message-row.own { flex-direction: row-reverse; }
.message-row .avatar { height: 32px; width: 32px; border-radius: 10px; font-size: 12px; }
.message-body { max-width: min(76%, 620px); min-width: 40px; }
.message-bubble { background: #fff; border: 1px solid var(--line); padding: 11px 14px; border-radius: 4px 12px 12px 12px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.own .message-bubble { background: #e3f1f8; border-color: #cee3ee; border-radius: 12px 3px 12px 12px; }
.message-meta { font-size: 10px; color: #859198; margin-top: 5px; line-height: 1.5; overflow-wrap: anywhere; }
.own .message-meta { text-align: right; }
.message-bubble img { max-width: 100%; max-height: 340px; border-radius: 6px; display: block; cursor: zoom-in; }
.message-bubble video { max-width: 100%; max-height: 340px; display: block; border-radius: 6px; }
.empty { display: flex; flex: 1; align-items: center; justify-content: center; flex-direction: column; color: #8795a9; gap: 12px; text-align: center; padding: 28px 20px; line-height: 1.7; }
.empty svg { width: 48px; height: 48px; opacity: .5; }
.empty h3 { font-size: 16px; color: #5e708a; font-weight: 500; margin: 0; }
.empty p { margin: 0; max-width: 28em; }
.chat-messages > .empty { min-height: 100%; }
.composer { background: #fff; border-top: 1px solid var(--line); padding: 10px 22px 14px; flex-shrink: 0; position: relative; }
.composer:focus-within { box-shadow: inset 0 1px 0 #087caf26; }
.composer-tools { display: flex; align-items: center; gap: 5px; margin-bottom: 6px; }
.composer textarea { display: block; width: 100%; border: 0; resize: none; min-height: 56px; max-height: 140px; outline: none; padding: 3px 4px; font-size: 15px; line-height: 1.6; background: transparent; color: var(--ink); }
.composer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; color: #849197; }
.composer .primary { min-height: 34px; padding: 7px 18px; }
.pending-media { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.pending-media:not(:empty) { padding: 6px 0; }
.pending-media { align-items: flex-start; gap: 9px; max-height: 168px; overflow-y: auto; overscroll-behavior: contain; }
.pending-media[hidden] { display: none; }
.media-preview { position: relative; width: 88px; flex: 0 0 88px; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: #f6f8f7; }
.media-preview img, .media-preview video { display: block; width: 76px; height: 64px; border-radius: 6px; object-fit: cover; background: #e9eef6; }
.media-preview-name { display: block; max-width: 100%; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; color: #708099; }
.media-preview-remove { position: absolute; right: 1px; top: 1px; min-height: 26px; width: 26px; padding: 0; border: 1px solid #dce4f0; border-radius: 50%; background: #fff; color: #53647c; box-shadow: 0 2px 5px #1c31521a; }
.media-preview-remove:hover { color: #c94444; border-color: #e9b8b8; background: #fff6f6; }
.pending-media-status { align-self: center; width: 100%; font-size: 11px; color: #7b889d; }
.message-actions-trigger { display: inline-flex; width: 26px; height: 24px; min-height: 24px; padding: 2px; margin-left: 5px; align-items: center; justify-content: center; vertical-align: middle; border: 0; border-radius: 6px; background: transparent; color: #8a98ad; }
.message-actions-trigger:hover, .message-actions-trigger[aria-expanded="true"] { background: var(--blue); color: var(--accent); }
.message-actions-menu { display: flex; gap: 3px; padding: 5px; margin-top: 5px; width: fit-content; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 5px 18px #243d6312; }
.message-actions-menu button { padding: 5px 9px; min-height: 30px; border-radius: 6px; font-size: 12px; }
.own .message-actions-menu { margin-left: auto; }
.message-receipt { margin-left: 7px; color: #93a0b4; font-size: 10px; white-space: nowrap; }
.message-receipt.read { color: #25866e; }
.message-recalled { margin: 12px auto; width: fit-content; max-width: 85%; border-radius: 7px; padding: 5px 10px; color: #8b96a8; background: #edf1f6; font-size: 11px; text-align: center; }
.message-row.recalled { align-items: center; justify-content: center; gap: 4px; margin: 10px 0; }
.message-row.recalled .message-recalled { margin: 0; }
.message-actions { flex-shrink: 0; }
.message-media-trigger { display: block; max-width: 100%; padding: 0; text-align: left; border-radius: inherit; overflow: hidden; }
.message-media-trigger video { cursor: zoom-in; }
.message-video-trigger { position: relative; background: #172130; }
.message-video-trigger video { width: 260px; height: 195px; max-height: 260px; object-fit: cover; }
.media-preview-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 48px; height: 48px; padding-left: 3px; border: 1px solid #ffffff80; border-radius: 50%; background: #10182899; color: #fff; font-size: 20px; pointer-events: none; box-shadow: 0 2px 12px #0003; }
.arrival-dialog { position: fixed; inset: 84px 16px auto auto; margin: 0; padding: 0; width: min(390px, calc(100vw - 32px)); max-height: min(300px, calc(100dvh - 240px)); overflow: auto; border: 1px solid #cadde5; border-top: 3px solid var(--accent); border-radius: 10px; background: #fff; color: var(--ink); box-shadow: 0 10px 36px #23323b21; z-index: 30; animation: arrival-in .2s ease-out; }
.desk-chat-dialog > .arrival-dialog { position: absolute; right: 12px; width: min(390px, calc(100% - 24px)); }
.arrival-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.arrival-visitor { display: flex; gap: 10px; align-items: center; padding: 14px; }
.arrival-visitor .avatar { width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0; }
.arrival-copy { display: grid; gap: 4px; flex: 1; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.arrival-copy span { color: var(--muted); font-size: 11px; }
.arrival-visitor .primary { padding: 8px 10px; white-space: nowrap; font-size: 12px; }
@keyframes arrival-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .arrival-dialog { animation: none; } }
.message-media-trigger img { cursor: zoom-in; }
.desk-chat-dialog { width: min(1180px, calc(100vw - 40px)); max-width: none; height: min(850px, calc(100dvh - 48px)); max-height: none; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--canvas); }
.desk-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; height: 60px; border-bottom: 1px solid var(--line); background: #fff; }
.desk-dialog-header h2 { margin: 0; min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
.desk-dialog-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.desk-dialog-title .brand-logo { width: 30px; height: 30px; border-radius: 8px; }
.desk-dialog-header button { min-height: 32px; min-width: 32px; border-radius: 8px; }
.desk-dialog-header button:hover { background: #f0f3f9; }
.desk-dialog-workspace { display: flex; width: 100%; height: calc(100% - 60px); min-height: 0; overflow: hidden; }
.desk-dialog-workspace .inbox { width: 300px; }
.desk-dialog-workspace .inbox-head { padding: 19px 16px 13px; }
.desk-dialog-workspace .conversation { flex: 1; min-width: 0; min-height: 0; }
.desk-dialog-workspace > .empty { flex: 1; }
.media-viewer-dialog { width: min(1100px, calc(100vw - 32px)); max-width: none; height: min(860px, calc(100dvh - 40px)); max-height: none; padding: 0; border: 1px solid #35415b; border-radius: 13px; overflow: hidden; background: #121a29; color: #edf4f7; }
.media-viewer-dialog::backdrop { background: #111b30c9; backdrop-filter: blur(3px); }
.media-viewer-header { display: flex; align-items: center; justify-content: space-between; height: 56px; gap: 14px; padding: 12px 18px; border-bottom: 1px solid #ffffff14; }
.media-viewer-header h2 { margin: 0; font-size: 14px; font-weight: 500; }
.media-viewer-header button { min-height: 32px; min-width: 32px; border: 1px solid #ffffff24; border-radius: 7px; background: #ffffff0d; color: #e6ecf7; }
.media-viewer-header button:hover { background: #ffffff15; }
.media-viewer-content { display: flex; align-items: center; justify-content: center; height: calc(100% - 56px); min-height: 0; padding: 14px; }
.media-viewer-content img, .media-viewer-content video { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; }
@media (max-width: 650px) {
  .desk-chat-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; }
  .desk-dialog-header { height: 54px; padding: 11px 14px; }
  .desk-dialog-workspace { height: calc(100% - 54px); }
  .desk-dialog-workspace .inbox { width: 100%; border: 0; }
  .desk-dialog-workspace:not(.chat-open) > .conversation { display: none; }
  .desk-dialog-workspace.chat-open .inbox { display: none; }
  .desk-dialog-workspace.chat-open > .conversation { width: 100%; }
  .media-viewer-dialog { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .media-viewer-content { padding: 8px; }
  .agent-select-trigger { font-size: 14px; }
}
.emoji-picker { position: absolute; bottom: 100%; left: 21px; background: #fff; border: 1px solid var(--line); box-shadow: 0 8px 28px #23323b12; border-radius: 12px; padding: 10px; display: grid; grid-template-columns: repeat(8, 30px); z-index: 5; }
.emoji-picker button { font-size: 22px; padding: 4px; border-radius: 5px; }
.connection { font-size: 11px; color: #768890; line-height: 1.5; overflow-wrap: anywhere; }
.connection.error { color: #a4664d; }

/* Keep the visitor shell pinned to the actual visual viewport managed by JS. */
.visitor-shell { position: fixed; top: 0; left: 0; right: 0; width: 100%; max-width: 760px; height: 100vh; height: 100dvh; margin: 0 auto; display: flex; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.visitor-shell .conversation { width: 100%; }
.visitor-shell .chat-header { height: 76px; padding: 0 22px; }
.visitor-brand { display: inline-flex; align-items: center; gap: 7px; padding-left: 12px; border-left: 1px solid var(--line); color: var(--muted); font-size: 11px; white-space: nowrap; }
.visitor-brand .brand-logo { width: 30px; height: 30px; border-radius: 8px; }
.chat-person { flex: 1; min-width: 0; }
.chat-mobile-brand { display: none; }
.visitor-shell .chat-messages { padding: 24px 20px; }
.visitor-shell .composer { padding: 10px 18px calc(14px + env(safe-area-inset-bottom)); }
.visitor-shell .message-body { max-width: 78%; }
.visitor-shell .composer textarea { font-size: 16px; min-height: 45px; }
.visitor-shell .composer-bottom .hint { max-width: 65%; }

/* Settings and account management share the same content rhythm. */
.admin-main, .settings-main { flex: 1; min-width: 0; overflow: auto; overscroll-behavior-y: contain; padding: 32px; background: var(--canvas); }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.page-heading > div { min-width: 0; }
.page-heading h1 { font-size: 25px; font-weight: 650; line-height: 1.35; margin: 0 0 7px; letter-spacing: -.3px; }
.page-heading p { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 0; overflow-wrap: anywhere; }
.page-heading > button { flex-shrink: 0; }
.settings-main > .page-heading, .settings-form { width: 100%; max-width: 1024px; }
.admin-main > .page-heading, .admin-main > .table-wrap, .admin-main > .table-toolbar { max-width: 1240px; }
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; background: #fff; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; font-size: 12px; color: var(--muted); }
.table-toolbar + .table-wrap { border-radius: 0 0 10px 10px; }
.table-wrap { max-width: 100%; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { background: #f8faf9; text-align: left; font-size: 12px; font-weight: 500; color: #71818a; padding: 12px 18px; }
td { padding: 15px 18px; border-top: 1px solid var(--line); font-size: 13px; }
td .name-cell { display: flex; align-items: center; gap: 10px; }
td .avatar { width: 34px; height: 34px; border-radius: 10px; }
td strong { font-weight: 600; }
td .small, .pagination-controls { font-variant-numeric: tabular-nums; }
.account-meta { display: flex; flex-direction: column; gap: 4px; }
.account-username { font-size: 12px; color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 4px; }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; color: var(--accent); min-height: 30px; padding: 5px 9px; border-radius: 6px; font-size: 12px; line-height: 1.5; white-space: nowrap; transition: background-color .16s, color .16s; }
.admin-main > p.small { margin: 16px 0 5px; line-height: 1.7; }
.admin-main > .status-line { gap: 8px; }
.panel { background: #fff; border: 1px solid var(--line); padding: 24px; border-radius: 10px; margin-bottom: 18px; min-width: 0; }
.panel h3 { font-size: 15px; font-weight: 600; line-height: 1.5; margin-bottom: 10px; }
.panel > p, .panel-heading p { line-height: 1.8; margin-bottom: 14px; }
.panel-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 14px; }
.panel-heading h3 { margin: 0; }
.panel-heading p { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 12px; }
.link-row { display: flex; gap: 10px; align-items: center; background: var(--canvas); border: 1px solid #edf0f6; padding: 10px 12px; border-radius: 8px; min-width: 0; }
.link-row code { font-family: inherit; font-size: 12px; flex: 1; min-width: 0; line-height: 1.8; overflow-wrap: anywhere; word-break: break-all; color: #4d5e78; }
.link-row > button { flex-shrink: 0; }
.link-row > a { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 4px; font-size: 12px; white-space: nowrap; }
.welcome-block { display: flex; flex-direction: column; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; overflow: hidden; }
.welcome-block-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px 10px; padding: 7px 10px 7px 13px; background: #f8faf9; border-bottom: 1px solid var(--line); min-width: 0; }
.block-type { display: inline-flex; align-items: center; gap: 7px; color: #596c87; font-size: 12px; font-weight: 500; min-height: 28px; }
.block-type svg { width: 15px; height: 15px; }
.block-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-left: auto; }
.block-actions .text-button { min-height: 28px; padding: 4px 8px; }
.welcome-block-content { min-width: 0; padding: 12px; }
.welcome-block textarea { display: block; width: 100%; min-height: 92px; max-height: 480px; resize: vertical; line-height: 1.7; font-size: 13px; padding: 10px 12px; }
.welcome-block-content > p { margin: 0; font-size: 12px; line-height: 1.8; }
.welcome-block img, .welcome-block video { display: block; width: auto; max-width: 100%; max-height: 200px; border-radius: 6px; object-fit: contain; }
.welcome-block video { background: #23323b; }
.welcome-panel .form-error:empty { display: none; }
.welcome-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 16px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.welcome-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; margin-left: auto; }
.save-status { color: var(--muted); font-size: 12px; line-height: 1.5; }
.save-status.dirty { color: #9b763e; }
.save-status.saved { color: #27856a; }
.screen-error { display: grid; place-items: center; min-height: 100dvh; text-align: center; padding: 32px; }
.screen-error .brand-logo { width: 64px; height: 64px; margin-bottom: 24px; }
.screen-error h1 { font-size: 23px; }
.screen-error p { color: var(--muted); line-height: 1.8; max-width: 36em; }

/* Feedback appears where the action happened; no extra decorative motion. */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 26px; width: min(450px, calc(100% - 30px)); max-height: calc(100dvh - 30px); overflow: auto; color: var(--ink); box-shadow: 0 18px 64px #23323b1f; }
dialog::backdrop { background: #23323b4d; backdrop-filter: blur(2px); }
dialog[open] { animation: dialog-enter .18s ease-out both; }
dialog h2 { font-size: 21px; font-weight: 650; margin-bottom: 22px; }
dialog p { line-height: 1.8; }
dialog .search { width: 100%; }
dialog .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 22px; }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); padding: 11px 18px; width: max-content; max-width: calc(100% - 28px); border-radius: 8px; background: #24344e; color: #fff; font-size: 12px; line-height: 1.6; box-shadow: 0 6px 24px #23323b18; opacity: 0; pointer-events: none; z-index: 30; transition: opacity .16s; overflow-wrap: anywhere; }
#toast.show { opacity: 1; }
.button-spinner { display: inline-block; width: 13px; height: 13px; flex-shrink: 0; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .75s linear infinite; vertical-align: middle; }
.loading-error { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px 18px; color: var(--muted); font-size: 12px; line-height: 1.8; text-align: center; min-height: 120px; }
.loading-error p { margin: 0; max-width: 30em; }
.loading-error .secondary { min-height: 32px; }
.page-enter { animation: none; }
.skeleton { position: relative; overflow: hidden; background: #edf1f6; border-radius: 5px; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, #ffffff8f, transparent); transform: translateX(-100%); animation: shimmer 1.5s ease-in-out infinite; }
.skeleton-line { display: block; width: 100%; height: 12px; border-radius: 4px; }
.skeleton-line + .skeleton-line { margin-top: 10px; }
.skeleton-line.short { width: 55%; }
.skeleton-avatar { display: block; width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0; }
.skeleton-row { display: flex; align-items: center; gap: 12px; padding: 18px; border-bottom: 1px solid #eef1ef; }
.skeleton-row > div { flex: 1; min-width: 0; }
.skeleton-card { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.list-skeleton { padding: 2px 0; }
.chat-skeleton { padding: 8px 0; }
.chat-skeleton .skeleton-row { align-items: flex-start; border: 0; padding: 8px 0 22px; }
.chat-skeleton .skeleton-row:nth-child(even) { flex-direction: row-reverse; }
.chat-skeleton .skeleton-row > div { flex: 0 1 64%; max-width: 400px; }
.chat-skeleton .skeleton-line { height: 38px; border-radius: 8px; }
.chat-skeleton .skeleton-line + .skeleton-line { height: 10px; width: 46%; margin-top: 9px; }
.welcome-skeleton { display: grid; gap: 12px; }
.welcome-skeleton .skeleton-card { display: grid; gap: 12px; }
.welcome-skeleton .skeleton-line:last-child { height: 68px; margin: 0; }
.back-mobile, .mobile-only { display: none; }
.hidden { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes page-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dialog-enter { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (hover: hover) and (pointer: fine) {
  button.primary:not(:disabled):hover { background: #066997; }
  button.primary.danger:not(:disabled):hover { background: #b93940; }
  button.secondary:not(:disabled):hover { border-color: #cbd6e7; background: #f8faf9; }
  .rail-button:not(:disabled):hover { color: var(--accent); background: #f1f5f5; }
  .rail-button.active:not(:disabled):hover { background: #e1eff6; }
  .visitor:not(.active):hover { background: #f6f8f7; }
  .icon-button:not(:disabled):hover { background: #edf4f7; color: var(--accent); }
  .text-button:not(:disabled):hover { background: var(--blue); }
  .text-button.danger:not(:disabled):hover { background: #fff0f0; }
  .emoji-picker button:hover { background: var(--canvas); }
  .link-row > a:hover { text-decoration: underline; text-underline-offset: 3px; }
  .message-row > .message-actions { opacity: 0; transition: opacity .12s; }
  .message-row:hover > .message-actions, .message-row:focus-within > .message-actions { opacity: 1; }
  .table-wrap tbody tr:hover { background: #f9fbfb; }
  .latest-messages:hover { background: #f0f7fa; border-color: #a3c7d8; }
}

@media (min-width: 1500px) {
  .inbox { width: 320px; }
  .chat-messages { padding-left: 5%; padding-right: 5%; }
}

@media (max-width: 1200px) {
  .inbox { width: 280px; }
  .admin-main, .settings-main { padding: 24px; }
  .welcome-footer { align-items: flex-start; }
  .welcome-footer .settings-actions { flex-basis: 100%; padding-top: 2px; }
}

@media (max-width: 900px) {
  .nav-unread { position: absolute; top: 4px; right: 2px; height: 16px; min-width: 16px; padding: 0 4px; font-size: 9px; }
  .admin-workspace .inbox { width: 292px; }
  .rail { width: 68px; padding: 20px 7px 12px; align-items: center; gap: 20px; }
  .rail-brand { padding: 0; justify-content: center; }
  .brand-copy, .profile-copy, .rail-button .nav-label { display: none; }
  .rail-button .nav-short { display: inline; font-size: 11px; line-height: 1.2; white-space: nowrap; }
  .rail-button { min-height: 56px; padding: 9px 4px; gap: 6px; flex-direction: column; justify-content: center; text-align: center; border-radius: 9px; }
  .rail-button svg { width: 21px; height: 21px; }
  .rail-nav { gap: 7px; }
  .rail-bottom { padding-top: 8px; }
  .rail-profile { justify-content: center; padding: 12px 0 2px; }
  .inbox { width: 272px; }
  .chat-header { padding: 0 20px; }
  .chat-messages { padding: 22px 18px; }
  .composer { padding-left: 18px; padding-right: 18px; }
  .admin-main, .settings-main { padding: 24px 20px; }
  .page-heading h1 { font-size: 23px; }
  .page-heading { align-items: flex-start; gap: 12px; }
  th, td { padding-left: 15px; padding-right: 15px; }
}

@media (max-width: 650px) {
  .profile-preview { gap: 12px; }
  .avatar-options { gap: 5px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .avatar-options button { font-size: 18px; }
  .chat-person .visitor-origin { max-width: 42vw; }
  .admin-workspace .inbox { width: calc(100% - 68px); }
  .admin-workspace .conversation-context { padding: 9px 16px; font-size: 11px; }
  .login { grid-template-columns: minmax(0, 380px); padding: 24px 20px; gap: 0; }
  .login-story { display: none; }
  .login-form { min-height: 0; padding: 28px 24px; border: 0; background: transparent; }
  .login-mobile-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
  .login-mobile-brand strong { font-size: 26px; font-weight: 650; }
  .login-mobile-brand .brand-logo { width: 52px; height: 52px; border-radius: 13px; }
  .login-form form { width: min(100%, 360px); }
  .field input, .field textarea, .field select, .search { font-size: 16px; }
  .rail { padding-top: 18px; gap: 18px; }
  .rail .brand-logo { width: 38px; height: 38px; border-radius: 10px; }
  .inbox { width: calc(100% - 68px); border: 0; }
  .inbox-head { padding: 22px 18px 16px; }
  .inbox-head .search { font-size: 14px; }
  .inbox-head .inbox-search { min-height: 42px; }
  .inbox-search .search-clear { width: 36px; height: 36px; }
  .workspace.chat-open .rail, .workspace.chat-open .inbox { display: none; }
  .workspace:not(.chat-open) > .conversation { display: none; }
  .back-mobile { display: inline-flex; }
  .chat-header { height: 74px; padding: 0 16px; gap: 9px; }
  .chat-header .header-actions { gap: 5px; }
  .chat-header .header-actions .small { display: none; }
  .chat-header .status-line { font-size: 11px; }
  .chat-header h3 { max-width: 48vw; }
  .message-body { max-width: 80%; }
  .message-bubble { padding: 10px 13px; }
  .latest-messages { right: 12px; bottom: 10px; min-height: 42px; padding: 9px 13px; }
  .workspace .composer, .desk-dialog-workspace .composer, .visitor-shell .composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 10px; padding: 6px 12px max(6px, env(safe-area-inset-bottom)); }
  .composer-tools { grid-column: 1 / -1; grid-row: 1; margin: 0; }
  .composer-tools .icon-button { width: 32px; height: 32px; }
  .composer .pending-media { grid-column: 1 / -1; grid-row: 2; max-height: 140px; padding: 2px 0; }
  .composer textarea { grid-column: 1; grid-row: 3; min-height: 44px; height: 44px; max-height: 100px; border: 1px solid var(--line); border-radius: 8px; background: var(--canvas); padding: 8px 10px; font-size: 16px; }
  .composer-bottom { grid-column: 2; grid-row: 3; align-items: center; justify-content: flex-end; }
  .composer-bottom .hint { display: none; }
  .composer .primary { min-height: 44px; padding: 10px 15px; }
  .visitor-shell { max-width: 100%; box-shadow: none; }
  .visitor-shell .chat-header h3 { max-width: 42vw; }
  .visitor-brand { padding-left: 8px; }
  .visitor-brand > span { font-size: 10px; }
  .visitor-brand .brand-logo { width: 28px; height: 28px; }
  .chat-mobile-brand { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; color: var(--muted); font-size: 10px; }
  .chat-mobile-brand .brand-logo { width: 24px; height: 24px; border-radius: 6px; }
  .visitor-shell { border: 0; }
  .admin-main, .settings-main { padding: 22px 14px; }
  .page-heading { flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 18px; }
  .page-heading h1 { font-size: 22px; }
  .page-heading p { font-size: 12px; }
  .page-heading > button { min-height: 38px; }
  .panel { padding: 15px; margin-bottom: 14px; }
  .panel-heading { margin-bottom: 12px; }
  .link-row { flex-wrap: wrap; gap: 8px 12px; padding: 10px; }
  .link-row code { flex-basis: 100%; }
  .welcome-block-head { padding: 6px 8px 6px 10px; gap: 4px; }
  .block-actions .text-button { min-height: 36px; padding: 7px 8px; }
  .welcome-block-content { padding: 10px; }
  .welcome-block textarea { min-height: 96px; padding: 9px 10px; font-size: 16px; }
  .welcome-block img, .welcome-block video { max-width: 100%; max-height: 180px; }
  .welcome-footer { margin-top: 14px; padding-top: 14px; gap: 14px; }
  .welcome-buttons { gap: 7px; }
  .welcome-buttons .secondary { padding: 8px 10px; font-size: 12px; min-height: 40px; }
  .settings-actions { width: 100%; justify-content: space-between; gap: 10px; }
  .settings-actions .primary { min-height: 40px; }
  .save-status { font-size: 11px; }
  .table-wrap { border-radius: 8px; }
  .table-toolbar { padding: 11px 13px; border-radius: 8px 8px 0 0; }
  .table-toolbar + .table-wrap { border-radius: 0 0 8px 8px; }
  .admin-main .table-wrap table { display: block; min-width: 0; width: 100%; white-space: normal; }
  .admin-main .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .admin-main .table-wrap tbody { display: block; width: 100%; }
  .admin-main .table-wrap tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 7px 8px; padding: 14px 14px 10px; border-top: 1px solid var(--line); }
  .admin-main .table-wrap td { min-width: 0; padding: 0; border: 0; }
  .admin-main .table-wrap td:first-child { grid-column: 1 / -1; }
  .admin-main .table-wrap td:nth-child(3) { justify-self: end; }
  .admin-main .table-wrap td:last-child { grid-column: 1 / -1; margin-top: 3px; padding-top: 7px; border-top: 1px solid #f0f3f8; }
  .admin-main .account-meta { min-width: 0; overflow-wrap: anywhere; }
  .admin-main .account-username { overflow-wrap: anywhere; line-height: 1.6; }
  .admin-main .account-username::before { content: "账号 "; color: #8b979e; font-size: 11px; }
  .admin-main .table-wrap td:nth-child(3) .text-button { background: var(--blue); min-height: 36px; padding: 7px 10px; }
  .admin-main .row-actions { flex-wrap: wrap; gap: 4px; }
  .admin-main .row-actions .text-button { min-height: 36px; }
  .admin-main .row-actions .text-button:first-child { margin-right: auto; }
  .mobile-only { display: block; }
  dialog { padding: 22px; }
  .emoji-picker { left: 12px; grid-template-columns: repeat(8, 28px); }
}

@media (max-width: 360px) {
  .admin-main, .settings-main { padding: 20px 12px; }
  .panel { padding: 12px; }
  .page-heading h1 { font-size: 21px; }
  .block-actions { gap: 0; }
  .block-actions .text-button { padding-left: 7px; padding-right: 7px; }
  .welcome-buttons .secondary { padding-left: 9px; padding-right: 9px; }
  .settings-actions { align-items: flex-start; flex-direction: column; }
  .settings-actions .primary { align-self: flex-end; }
  .visitor { padding-left: 14px; padding-right: 14px; gap: 8px; }
  .visitor-time { font-size: 9px; }
  .inbox-head { padding-left: 16px; padding-right: 16px; }
}

/* Landscape keyboards leave little space; keep identity and send on screen. */
.visitor-shell.compact-viewport .chat-header { height: 44px; padding: 0 16px; gap: 8px; }
.visitor-shell.compact-viewport .chat-header h3 { font-size: 14px; margin-bottom: 2px; }
.visitor-shell.compact-viewport .chat-header .avatar { width: 28px; height: 28px; border-radius: 9px; }
.visitor-shell.compact-viewport .visitor-brand .brand-logo { width: 24px; height: 24px; }
.visitor-shell.compact-viewport .chat-messages { padding: 6px 16px; }
.visitor-shell.compact-viewport .composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 6px 12px max(6px, env(safe-area-inset-bottom)); }
.visitor-shell.compact-viewport .composer-tools { grid-column: 1 / -1; grid-row: 1; margin: 0; }
.visitor-shell.compact-viewport .composer-tools .icon-button { height: 32px; width: 36px; }
.visitor-shell.compact-viewport .composer textarea { grid-column: 1; grid-row: 3; min-height: 42px; height: 42px; max-height: 42px; }
.visitor-shell.compact-viewport .composer-bottom { grid-column: 2; grid-row: 3; justify-content: flex-end; }
.visitor-shell.compact-viewport .composer-bottom .hint { display: none; }
.visitor-shell.compact-viewport .composer .primary { min-height: 42px; padding: 8px 16px; }
.visitor-shell.compact-viewport .pending-media { grid-column: 1 / -1; grid-row: 2; max-height: 40px; padding: 2px 0; }
.visitor-shell.compact-viewport .media-preview { width: 44px; flex-basis: 44px; padding: 2px; border-radius: 6px; }
.visitor-shell.compact-viewport .media-preview img, .visitor-shell.compact-viewport .media-preview video { width: 38px; height: 30px; border-radius: 4px; }
.visitor-shell.compact-viewport .media-preview-name { display: none; }
.visitor-shell.compact-viewport .pending-media:empty { display: none; }

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

/* Admin records keep filters, ownership, and destructive actions easy to scan. */
.visitor-management > .visitor-search-form, .visitor-management > .visitor-table-content { max-width: 1240px; }
.visitor-search-form { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(200px, 260px) auto; align-items: end; gap: 18px; padding: 20px; }
.visitor-search-form .field { margin: 0; }
.visitor-search-form .agent-selector { margin: 0; }
.visitor-search-form .search { min-height: 46px; margin: 0; }
.visitor-search-actions { display: flex; align-items: center; gap: 8px; padding-bottom: 1px; }
.visitor-search-actions > button { min-height: 44px; }
.visitor-table-content { min-width: 0; }
.visitor-table-wrap .table-toolbar { border: 0; }
.visitor-table-message { display: block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.visitor-table-owner .avatar { width: 28px; height: 28px; border-radius: 8px; }
.table-pagination, .pagination-controls { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.table-pagination { flex-wrap: wrap; padding: 16px 0; }
.pagination-controls button { min-width: 70px; }
.agent-avatar-dialog { width: min(500px, calc(100vw - 32px)); }
.agent-avatar-dialog .actions { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.system-settings .settings-form { max-width: 720px; }
.retention-panel .field { max-width: 220px; }
.retention-panel > .small { line-height: 1.8; max-width: 560px; }
.retention-panel .settings-actions { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; }
.retention-panel .form-error:empty, .profile-panel .form-error:empty { display: none; }
@media (max-width: 1100px) {
  .visitor-search-form { grid-template-columns: minmax(0, 1fr) minmax(180px, 1fr); }
  .visitor-search-actions { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .visitor-search-form { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .visitor-search-actions { grid-column: 1; }
  .visitor-management .table-wrap tbody tr { grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
  .visitor-management .table-wrap td:nth-child(2) { grid-column: 1; }
  .visitor-management .table-wrap td:nth-child(3) { grid-column: 1 / -1; justify-self: stretch; }
  .visitor-management .table-wrap td:nth-child(4) { grid-column: 1; }
  .visitor-management .table-wrap td:nth-child(5) { grid-column: 2; grid-row: 2; }
  .visitor-management .table-wrap td:nth-child(3) .visitor-table-message { max-width: none; white-space: nowrap; }
  .visitor-management .table-wrap td:last-child { margin-top: 0; }
  .table-pagination { gap: 10px; }
  .pagination-controls { width: 100%; gap: 8px; }
}
