:root {
  color-scheme: dark;
  --bg: #020617;
  --surface: #0f172a;
  --surface-soft: #172033;
  --border: #273449;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-dark: #15803d;
  --danger: #fb7185;
  --radius: 16px;
  font-family: "Fira Sans", "Microsoft YaHei UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-soft: #e9eff6;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #475569;
  --accent: #16a34a;
  --accent-dark: #15803d;
  --danger: #be123c;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body.modal-open { overflow: hidden; }
body {
  background:
    radial-gradient(circle at 80% -20%, rgb(34 197 94 / 14%), transparent 36rem),
    linear-gradient(145deg, #020617, #07101f 55%, #020617);
}
:root[data-theme="light"] body { background: radial-gradient(circle at 80% -20%, rgb(34 197 94 / 15%), transparent 36rem), linear-gradient(145deg, #f8fafc, #e9f1f8 55%, #f8fafc); }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { outline: none; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  box-shadow: 0 0 0 3px rgb(34 197 94 / 35%);
}

.shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(100%, 440px);
  padding: 34px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgb(15 23 42 / 92%);
  box-shadow: 0 24px 80px rgb(0 0 0 / 32%);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: var(--accent); color: #052e16; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .02em; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
h2 { margin: 6px 0 8px; font-size: clamp(25px, 4vw, 34px); }
.muted { color: var(--muted); line-height: 1.55; }
.stack { display: grid; gap: 18px; margin-top: 28px; }
label { display: grid; gap: 8px; color: #dbe5f1; font-size: 14px; font-weight: 600; }
input, textarea, select {
  min-height: 46px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #07101f;
  color: var(--text);
  padding: 11px 13px;
}
select { cursor: pointer; }
.button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  padding: 0 18px;
  background: var(--accent);
  color: #052e16;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}
.button:hover { background: #4ade80; transform: translateY(-1px); }
.button.secondary { border: 1px solid var(--border); background: var(--surface-soft); color: var(--text); }
.error { min-height: 20px; color: var(--danger); font-size: 14px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.login-tools, .topbar-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.language-control { display: inline-flex; }
.language-control select {
  min-height: 44px;
  width: 116px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 34px 0 11px;
  background: #07101f;
  color: var(--text);
  cursor: pointer;
}
.theme-toggle {
  width: 44px; min-width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 10px; padding: 0; background: #07101f; color: var(--muted); cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
.theme-toggle:hover { color: var(--text); border-color: #475569; }
.theme-icon-moon { display: none; }
:root[data-theme="light"] .theme-icon-sun { display: none; }
:root[data-theme="light"] .theme-icon-moon { display: block; }
.sound-toggle {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 11px;
  background: #07101f;
  color: var(--muted);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
.sound-toggle:hover { color: var(--text); border-color: #475569; }
.sound-toggle.active { color: #bbf7d0; border-color: rgb(34 197 94 / 50%); background: rgb(34 197 94 / 10%); }
.sound-toggle.ringing svg { animation: sound-ring 420ms ease-out; }
@keyframes sound-ring { 0%, 100% { transform: scale(1); } 35% { transform: scale(1.18); } 68% { transform: scale(.94); } }
.topbar-button { min-height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; background: #07101f; color: var(--text); cursor: pointer; }
.topbar-button:hover { border-color: #475569; }

.dashboard { min-height: 100vh; display: grid; grid-template-columns: 310px 1fr; }
.sidebar { border-right: 1px solid var(--border); background: rgb(7 16 31 / 94%); padding: 20px; }
.sidebar .brand { margin-bottom: 24px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 0 10px; }
.sidebar-head h2 { font-size: 15px; margin: 0; }
.count { min-width: 28px; padding: 4px 8px; border-radius: 999px; background: rgb(34 197 94 / 14%); color: #86efac; text-align: center; font-size: 12px; }
.conversation-list { display: grid; gap: 8px; }
.conversation {
  width: 100%; min-height: 70px; border: 1px solid transparent; border-radius: 12px; padding: 12px;
  background: transparent; color: inherit; text-align: left; cursor: pointer;
}
.conversation:hover, .conversation.active { border-color: var(--border); background: var(--surface-soft); }
.conversation strong, .conversation span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation span { margin-top: 5px; color: var(--muted); font-size: 13px; }
.workspace { min-width: 0; display: grid; grid-template-rows: 76px 1fr auto; height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 0 24px; background: rgb(15 23 42 / 68%); }
.presence { display: flex; align-items: center; gap: 8px; color: #bbf7d0; font-size: 13px; }
.presence::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px rgb(34 197 94 / 12%); }
.messages { overflow: auto; padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.empty { margin: auto; max-width: 420px; text-align: center; color: var(--muted); }
.message { max-width: min(72%, 680px); padding: 11px 14px; border-radius: 16px 16px 16px 4px; background: var(--surface-soft); line-height: 1.5; overflow-wrap: anywhere; }
.message.agent { align-self: flex-end; border-radius: 16px 16px 4px 16px; border: 1px dashed var(--border); background: transparent; color: var(--text); }
.message small, .message-time { display: block; margin-top: 5px; color: var(--muted); font: 11px "Fira Code", monospace; }
.ai-message-badge { width: max-content; margin-top: 7px !important; padding: 2px 7px; border-radius: 999px; background: rgb(34 197 94 / 14%); color: #bbf7d0 !important; font: 700 10px/1.4 "Fira Sans", sans-serif !important; letter-spacing: .04em; }
:root[data-theme="light"] .ai-message-badge { color: #166534 !important; background: #dcfce7; }
.composer { position: relative; display: flex; gap: 12px; border-top: 1px solid var(--border); padding: 16px 24px 22px; background: rgb(15 23 42 / 76%); }
.quick-reply-picker { align-self: end; }
.quick-reply-picker select { width: 148px; min-height: 46px; }
.composer-input { flex: 1; min-width: 0; }
.composer textarea { min-height: 50px; max-height: 150px; resize: vertical; }
.composer .button { align-self: end; }
.composer-tools { display: flex; align-items: end; gap: 8px; }
.emoji-picker { position: absolute; z-index: 8; left: 16px; bottom: calc(100% + 8px); width: min(292px, calc(100vw - 24px)); grid-template-columns: repeat(6, 1fr); gap: 5px; padding: 10px; border: 1px solid var(--border); border-radius: 14px; background: #0b1424; box-shadow: 0 18px 50px rgb(0 0 0 / 42%); }
.emoji-picker:not(.hidden) { display: grid; }
.emoji-option { width: 40px; height: 40px; border: 0; border-radius: 9px; background: transparent; font-size: 22px; cursor: pointer; }
.emoji-option:hover, .emoji-option:focus-visible { background: var(--surface-soft); }
.composer-tool {
  width: 46px; min-width: 46px; height: 46px; align-self: end; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 12px; background: #07101f; color: var(--muted); cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
.composer-tool:hover:not(:disabled) { color: var(--text); border-color: #475569; }
.composer-tool:disabled { cursor: not-allowed; opacity: .45; }
/* The image control is a <label> wrapping the hidden file input; mirror the disabled look. */
.composer-tool:has(input:disabled) { cursor: not-allowed; opacity: .45; }
.speech-button.active { color: #fecaca; border-color: rgb(248 113 113 / 65%); background: rgb(248 113 113 / 12%); }
.composer-status { min-height: 18px; padding: 3px 4px 0; color: var(--muted); font-size: 12px; }

.satisfaction-strip { display: flex; justify-content: center; padding: 7px 0 8px; border-top: 1px solid var(--border); background: rgb(15 23 42 / 62%); }
.satisfaction-open {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 50%; padding: 0;
  background: #07101f; color: #facc15; font-size: 16px; line-height: 1; cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.satisfaction-open:hover { color: #fde047; border-color: rgb(250 204 21 / 55%); transform: translateY(-1px); }
.satisfaction-dialog { width: min(360px, calc(100% - 28px)); border: 1px solid var(--border); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 24px 70px rgb(0 0 0 / 48%); }
.satisfaction-dialog::backdrop { background: rgb(2 6 23 / 68%); backdrop-filter: blur(3px); }
.satisfaction-form { display: grid; gap: 14px; padding: 18px; }
.satisfaction-form h2 { margin: 0; font-size: 16px; }
.satisfaction-stars { display: flex; justify-content: center; gap: 4px; }
.satisfaction-star { width: 38px; height: 38px; border: 0; border-radius: 10px; padding: 0; background: transparent; color: rgb(148 163 184 / 45%); font-size: 20px; line-height: 1; cursor: pointer; }
.satisfaction-star:hover, .satisfaction-star:focus-visible { background: var(--surface-soft); color: #facc15; }
.satisfaction-star.selected { color: #facc15; }
.satisfaction-comment { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.satisfaction-comment textarea { min-height: 84px; font-size: 13px; font-weight: 400; resize: vertical; }
.satisfaction-actions { display: flex; justify-content: flex-end; gap: 8px; }
.satisfaction-actions .button { min-height: 38px; padding: 0 13px; font-size: 13px; }

.staff-panel { position: fixed; inset: 0; z-index: 20; overflow: auto; padding: 24px; background: rgb(2 6 23 / 86%); backdrop-filter: blur(8px); }
.staff-panel-card { width: min(1100px, 100%); min-height: calc(100vh - 48px); margin: 0 auto; padding: 28px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: 0 24px 90px rgb(0 0 0 / 42%); }
.staff-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.staff-panel-head h2 { margin-bottom: 0; }
.feature-setting { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 16px; margin-bottom: 14px; padding: 16px 18px; border: 1px solid var(--border); border-radius: 16px; background: rgb(34 197 94 / 7%); }
.feature-setting p { margin: 4px 0 0; }
.switch-control { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 9px; }
.switch-control input { width: 20px; min-height: 20px; accent-color: var(--accent); }
.staff-create-form { display: grid; grid-template-columns: 1fr 1fr 1fr 150px auto; align-items: end; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: #07101f; }
.staff-create-form select, .staff-edit-form select { min-height: 46px; border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; background: #07101f; color: var(--text); }
.staff-feedback { min-height: 24px; margin: 12px 2px; color: #bbf7d0; }
.staff-feedback.error { color: var(--danger); }
.staff-list { display: grid; gap: 10px; }
.staff-edit-form { display: grid; grid-template-columns: 1fr 1fr 140px 130px 1fr auto; align-items: end; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-soft); }
.staff-edit-form label span { display: flex; align-items: center; gap: 6px; }
.self-badge { padding: 2px 7px; border-radius: 999px; background: rgb(34 197 94 / 14%); color: #86efac; font-size: 11px; }
.compact-panel { width: min(520px, 100%); min-height: auto; margin-top: min(12vh, 100px); }
.compact-panel select { min-height: 46px; border: 1px solid var(--border); border-radius: 12px; padding: 0 12px; background: #07101f; color: var(--text); }
.message.system-message { align-self: center; max-width: 90%; border: 1px dashed var(--border); border-radius: 999px; padding: 7px 13px; background: transparent; color: var(--muted); font-size: 13px; text-align: center; }
.staff-message-sender { display: block; margin-bottom: 3px; font-size: 12px; }
.internal-chat-card { height: calc(100vh - 48px); min-height: 560px; display: grid; grid-template-rows: auto 1fr; }
.internal-chat-layout { min-height: 0; display: grid; grid-template-columns: 250px 1fr; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.staff-peer-list { overflow: auto; padding: 12px; border-right: 1px solid var(--border); background: #07101f; }
.staff-peer { width: 100%; min-height: 58px; margin-bottom: 7px; padding: 10px 12px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.staff-peer:hover, .staff-peer.active { border-color: var(--border); background: var(--surface-soft); }
.staff-peer span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.internal-conversation { min-width: 0; min-height: 0; display: grid; grid-template-rows: 58px 1fr auto; }
.internal-conversation-head { display: flex; align-items: center; padding: 0 18px; border-bottom: 1px solid var(--border); }
.internal-conversation .messages { padding: 18px; }

.settings-card { max-width: 1180px; }
.settings-tabs { display: flex; gap: 8px; margin: -6px 0 18px; padding-bottom: 12px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.settings-tab { min-height: 40px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 10px; padding: 0 13px; background: #07101f; color: var(--muted); cursor: pointer; }
.settings-tab:hover, .settings-tab.active { border-color: rgb(34 197 94 / 55%); background: rgb(34 197 94 / 10%); color: #bbf7d0; }
.settings-section { min-height: 320px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stats-grid article { display: grid; gap: 8px; padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-soft); }
.stats-grid strong { color: #86efac; font-size: clamp(30px, 5vw, 46px); }
.stats-grid span { color: var(--muted); }
.mini-chart { height: 190px; display: flex; align-items: end; gap: 5px; margin-top: 18px; padding: 22px 16px 8px; border: 1px solid var(--border); border-radius: 16px; background: #07101f; }
.mini-chart-bar { min-width: 3px; flex: 1; border-radius: 5px 5px 2px 2px; background: linear-gradient(#4ade80, #15803d); }
.settings-form { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 16px; }
.settings-form .wide { grid-column: 1 / -1; }
.settings-form textarea { min-height: 92px; resize: vertical; }
.settings-form > .button { justify-self: start; }
.narrow-form { max-width: 720px; }
.quick-reply-form { margin: 18px 0; padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: #07101f; }
.inline-form, .copy-row { display: flex; align-items: end; gap: 10px; }
.inline-form input { max-width: 360px; }
.settings-list { display: grid; gap: 10px; margin-top: 18px; }
.settings-list-card { display: grid; grid-template-columns: minmax(140px, .45fr) minmax(240px, 1fr) auto; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-soft); }
.settings-list-card p { margin: 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.settings-list-card .danger-button { border-color: rgb(251 113 133 / 40%); color: #fecdd3; }
.reply-group { padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: #07101f; }
.reply-group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.reply-group-items { display: grid; gap: 8px; }
.access-block { display: grid; gap: 10px; margin-bottom: 22px; }
.copy-row input, .copy-row textarea { flex: 1; }
.copy-row textarea { min-height: 90px; resize: vertical; }

.visitor-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.chat-window { width: min(100%, 760px); height: min(88vh, 820px); height: min(88dvh, 820px); min-height: 0; display: grid; grid-template-rows: 76px minmax(0, 1fr) auto auto; border: 1px solid var(--border); border-radius: 22px; overflow: hidden; background: rgb(15 23 42 / 96%); box-shadow: 0 24px 90px rgb(0 0 0 / 36%); }
.chat-window .messages { background: #091222; }
.chat-window:has(.visitor-announcement:not(.hidden)) { grid-template-rows: 76px auto 1fr auto; }
.visitor-brand { min-width: 0; display: flex; align-items: center; gap: 10px; }
.visitor-brand > div { min-width: 0; }
.visitor-brand strong, .visitor-brand .muted { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visitor-brand-logo { width: 42px; height: 42px; border-radius: 12px; object-fit: cover; background: white; }
.visitor-brand-mark { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; background: linear-gradient(145deg, #4ade80, #15803d); color: #052e16; font-size: 20px; font-weight: 900; box-shadow: 0 8px 22px rgb(34 197 94 / 18%); }
.message.image-message { padding: 7px; }
.message-image { display: block; width: auto; max-width: min(320px, 100%); max-height: 360px; border-radius: 11px; object-fit: contain; background: #020617; }
.visitor-announcement { padding: 9px 18px; border-bottom: 1px solid rgb(245 158 11 / 24%); background: rgb(245 158 11 / 10%); color: #fde68a; font-size: 13px; text-align: center; }
.presence.offline { color: var(--muted); }
.presence.offline::before { background: #64748b; box-shadow: 0 0 0 5px rgb(100 116 139 / 12%); }

:root[data-theme="light"] input,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select,
:root[data-theme="light"] .sound-toggle,
:root[data-theme="light"] .theme-toggle,
:root[data-theme="light"] .composer-tool,
:root[data-theme="light"] .topbar-button { background: #ffffff; }
:root[data-theme="light"] .chat-window { background: rgb(255 255 255 / 98%); box-shadow: 0 24px 80px rgb(15 23 42 / 16%); }
:root[data-theme="light"] .chat-window .topbar,
:root[data-theme="light"] .chat-window > .composer { background: rgb(248 250 252 / 96%); }
:root[data-theme="light"] .chat-window .messages { background: #f3f6fa; }
:root[data-theme="light"] .emoji-picker { background: #ffffff; box-shadow: 0 18px 50px rgb(15 23 42 / 18%); }
:root[data-theme="light"] .visitor-announcement { color: #854d0e; background: #fef3c7; }
:root[data-theme="light"] label { color: #334155; }
:root[data-theme="light"] .sound-toggle.active { color: #166534; background: #dcfce7; }
:root[data-theme="light"] .satisfaction-strip { background: rgb(248 250 252 / 96%); }
:root[data-theme="light"] .satisfaction-open { background: #ffffff; }
:root[data-theme="light"] .satisfaction-star:hover, :root[data-theme="light"] .satisfaction-star:focus-visible { background: #e2e8f0; }
:root[data-theme="light"] .language-trigger { background: #ffffff; }
:root[data-theme="light"] .language-dialog { background: #ffffff; color: #0f172a; }
:root[data-theme="light"] .language-option { color: #0f172a; }
:root[data-theme="light"] .language-option:hover,
:root[data-theme="light"] .language-option:focus-visible { background: #f1f5f9; }
:root[data-theme="light"] .language-option.selected { color: #166534; background: #dcfce7; }

@media (max-width: 760px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .visitor-shell { width: 100%; height: 100vh; height: 100dvh; min-height: 100svh; padding: 0; place-items: stretch; overflow: hidden; }
  .chat-window { width: 100%; height: 100vh; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; grid-template-rows: auto minmax(0, 1fr) auto auto; }
  .chat-window:has(.visitor-announcement:not(.hidden)) { grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .chat-window .topbar { min-height: 64px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; }
  .visitor-brand { gap: 8px; }
  .visitor-brand-logo { width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto; }
  .visitor-brand strong { font-size: 15px; line-height: 1.3; }
  .visitor-brand .muted { margin-top: 2px; font-size: 11px; line-height: 1.3; }
  .topbar-actions { justify-content: flex-end; gap: 7px; }
  .language-control select { width: 88px; min-height: 44px; padding-left: 8px; padding-right: 25px; font-size: 13px; }
  .chat-window > .composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "input input" "tools send"; align-items: end; gap: 8px; padding: 9px 10px max(9px, env(safe-area-inset-bottom)); }
  .chat-window > .composer .composer-input { grid-area: input; }
  .chat-window > .composer .composer-tools { grid-area: tools; }
  .chat-window > .composer > .button { grid-area: send; }
  .composer textarea { min-height: 46px; max-height: 112px; padding: 11px 12px; resize: none; line-height: 1.4; }
  .composer .button { min-width: 58px; padding-inline: 12px; }
  .composer-status:empty { display: none; }
  .messages { min-height: 0; padding: 16px 12px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .message { max-width: 88%; }
  .topbar-actions .presence { display: none; }
  .sound-toggle { width: 44px; padding: 0; justify-content: center; }
  .sound-toggle [data-sound-label] { display: none; }
  .satisfaction-strip { padding: 5px 0 6px; }
  .satisfaction-open { width: 34px; height: 34px; font-size: 15px; }
  .satisfaction-form { gap: 12px; padding: 16px; }
  .satisfaction-star { width: 42px; height: 42px; }
  .topbar-actions #openStaffPanel { max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .staff-panel { padding: 10px; }
  .staff-panel-card { min-height: calc(100vh - 20px); padding: 18px 14px; border-radius: 16px; }
  .staff-create-form, .staff-edit-form { grid-template-columns: 1fr; }
  .settings-form, .stats-grid { grid-template-columns: 1fr; }
  .settings-form .wide { grid-column: auto; }
  .inline-form, .copy-row { align-items: stretch; flex-direction: column; }
  .inline-form input { max-width: none; }
  .settings-list-card { grid-template-columns: 1fr; }
  .quick-reply-picker { display: none; }
  .feature-setting { grid-template-columns: 1fr; }
  .internal-chat-card { height: calc(100vh - 20px); }
  .internal-chat-layout { grid-template-columns: 110px 1fr; }
  .staff-peer-list { padding: 7px; }
  .staff-peer { padding: 8px; }
}

@media (max-width: 390px) {
  .chat-window .topbar { gap: 7px; padding-inline: 10px; }
  .language-control select { width: 82px; }
  .visitor-brand strong { font-size: 14px; }
  .visitor-brand .muted { max-width: 118px; }
  .chat-window > .composer { gap: 6px; padding-inline: 8px; }
  .composer-tool { width: 44px; min-width: 44px; height: 46px; }
  .composer .button { min-width: 54px; padding-inline: 9px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .chat-window .topbar { min-height: 54px; padding-block: 5px; }
  .visitor-brand .muted { display: none; }
  .visitor-brand-logo { width: 36px; height: 36px; }
  .messages { padding-block: 10px; }
  .composer { padding-block: 7px max(7px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
  .sound-toggle.ringing svg { animation: none; }
}
.language-trigger {
  min-height: 44px;
  width: min(158px, 34vw);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 11px;
  background: #07101f;
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
.language-trigger [data-language-current] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.language-trigger svg { flex: 0 0 auto; color: var(--muted); }
.language-trigger:hover { border-color: #475569; }
.language-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(720px, calc(100dvh - 48px));
  margin: auto;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 90px rgb(0 0 0 / 55%);
}
.language-dialog::backdrop { background: rgb(2 6 23 / 68%); backdrop-filter: blur(3px); }
.language-dialog-head { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 10px 8px 20px; border-bottom: 1px solid var(--border); }
.language-dialog-head strong { font-size: 17px; }
.language-dialog-close { width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 30px; line-height: 1; cursor: pointer; touch-action: manipulation; }
.language-dialog-close:hover, .language-dialog-close:focus-visible { background: var(--surface-soft); color: var(--text); }
.language-options { max-height: min(560px, calc(100dvh - 128px)); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow: auto; overscroll-behavior: contain; padding: 12px; }
.language-option { min-width: 0; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 0 12px; background: transparent; color: var(--text); text-align: left; cursor: pointer; touch-action: manipulation; }
.language-option span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.language-option:hover, .language-option:focus-visible { border-color: var(--border); background: var(--surface-soft); }
.language-option.selected { border-color: rgb(34 197 94 / 45%); background: rgb(34 197 94 / 12%); color: #bbf7d0; }
.language-check { opacity: 0; color: var(--accent); font-weight: 800; }
.language-option.selected .language-check { opacity: 1; }

@media (max-width: 600px) {
  .language-trigger { width: 100px; padding-inline: 9px; font-size: 13px; }
  .language-dialog { width: 100%; max-width: none; max-height: min(72dvh, 680px); margin: auto 0 0; border-width: 1px 0 0; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .language-dialog-head { min-height: 58px; }
  .language-options { max-height: calc(72dvh - 59px - env(safe-area-inset-bottom)); gap: 6px; padding: 10px; }
  .language-option { min-height: 48px; padding-inline: 10px; font-size: 14px; }
}
