/* Local Support MVP — shared visual system for the visitor page and agent workspace. */

:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf9;
  --surface-2: #f7f4ee;
  --surface-3: #efebe2;
  --ink: #1d2a25;
  --ink-soft: #34443d;
  --muted: #67736d;
  --faint: #8b958f;
  --line: #e3ded4;
  --line-strong: #d4cec2;
  --brand: #1f6f5c;
  --brand-strong: #175848;
  --brand-soft: #e6f1ec;
  --brand-tint: #f1f8f5;
  --accent: #c46a3f;
  --accent-soft: #fbf0e8;
  --amber: #92651c;
  --amber-soft: #fbf3df;
  --danger: #a5413a;
  --danger-soft: #fbece9;
  --shadow-lg: 0 34px 80px -38px rgba(29, 42, 37, 0.38), 0 10px 30px -18px rgba(29, 42, 37, 0.18);
  --shadow-sm: 0 2px 8px rgba(29, 42, 37, 0.05);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 15px;
  --radius-sm: 11px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

svg {
  display: block;
}

::selection {
  background: rgba(31, 111, 92, 0.2);
}

:focus-visible {
  outline: 3px solid rgba(31, 111, 92, 0.45);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  transform: translateY(-160%);
  transition: transform 0.16s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- Shared shell ---------- */

.page {
  min-height: 100dvh;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  width: 100%;
  max-width: 1440px;
  min-height: 72px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 12px;
  flex: 0 0 auto;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-sub {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  margin-top: 2px;
}

.topbar-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
}

.topbar-link {
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 9px;
  white-space: nowrap;
}

.topbar-link:hover {
  background: rgba(29, 42, 37, 0.05);
  color: var(--brand);
}

.connection-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.7);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.connection-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--faint);
}

.connection-chip[data-state="online"] {
  color: var(--brand-strong);
  border-color: #cfe6dc;
  background: var(--brand-tint);
}

.connection-chip[data-state="online"] .connection-dot {
  background: #2b8a6c;
  box-shadow: 0 0 0 3px rgba(43, 138, 108, 0.12);
}

.connection-chip[data-state="offline"] {
  color: var(--amber);
  border-color: #eedcb5;
  background: var(--amber-soft);
}

.connection-chip[data-state="offline"] .connection-dot {
  background: #c58a27;
}

.connection-chip[data-state="connecting"] .connection-dot {
  background: #b3a894;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}

.site-footer {
  flex: 0 0 auto;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button--primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 6px 16px -8px rgba(31, 111, 92, 0.7);
}

.button--primary:hover:not(:disabled) {
  background: var(--brand-strong);
}

.button--primary:disabled {
  background: #9db8ae;
  box-shadow: none;
}

.button--secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-soft);
}

.button--secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: #c3bba9;
}

.button--quiet {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.button--quiet:hover:not(:disabled) {
  background: rgba(29, 42, 37, 0.06);
  color: var(--ink);
}

.button--danger {
  background: var(--danger);
  color: #fff;
}

.button--danger:hover:not(:disabled) {
  background: #8e342e;
}

.button--danger-quiet {
  min-height: 36px;
  padding: 6px 12px;
  border-color: #eccfc9;
  background: #fffaf8;
  color: var(--danger);
  font-size: 13px;
}

.button--danger-quiet:hover:not(:disabled) {
  background: var(--danger-soft);
}

.button-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.inline-error {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid #f0d3ce;
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.55;
}

/* ---------- Visitor page ---------- */

.page--visitor {
  background:
    radial-gradient(1000px 620px at -5% -8%, rgba(238, 198, 137, 0.3), transparent 62%),
    radial-gradient(900px 620px at 105% 4%, rgba(31, 111, 92, 0.13), transparent 58%),
    var(--bg);
}

.visitor-topbar {
  border-bottom: 1px solid transparent;
}

.visitor-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 28px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(390px, 550px);
  align-items: center;
  gap: clamp(32px, 5vw, 76px);
}

.visitor-intro {
  max-width: 540px;
  padding: 12px 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(31, 111, 92, 0.1);
}

.visitor-title {
  margin-top: 20px;
  font-size: clamp(44px, 5.2vw, 68px);
  line-height: 1.08;
  letter-spacing: -0.045em;
  font-weight: 800;
}

.visitor-title em {
  position: relative;
  display: inline-block;
  color: var(--brand);
  font-style: normal;
}

.visitor-title em::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 2px;
  bottom: 3px;
  height: 9px;
  border-radius: 99px;
  background: rgba(240, 201, 135, 0.62);
  z-index: -1;
}

.intro-lead {
  margin-top: 22px;
  max-width: 460px;
  color: #52605a;
  font-size: 16px;
  line-height: 1.9;
}

.feature-list {
  margin-top: 30px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 14px;
}

.feature-check {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
}

.intro-note {
  margin-top: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 12px;
}

.intro-note::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--line-strong);
}

.chat-card {
  position: relative;
  height: min(720px, calc(100dvh - 138px));
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(212, 206, 194, 0.84);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.chat-head {
  flex: 0 0 auto;
  min-height: 82px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf9 0%, #fdfbf6 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.chat-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.agent-avatar {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 17px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(31, 111, 92, 0.08);
}

.chat-heading-text {
  min-width: 0;
}

.chat-heading-text h2 {
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.chat-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}

.status-badge[data-status="pending"] {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge[data-status="active"] {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.status-badge[data-status="closed"] {
  background: var(--surface-3);
  color: var(--muted);
}

.chat-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #fcfaf6;
  background-image: radial-gradient(rgba(31, 111, 92, 0.055) 0.8px, transparent 0.8px);
  background-size: 17px 17px;
}

.chat-state {
  flex: 1 1 auto;
  min-height: 0;
  padding: 32px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.chat-state h3 {
  margin-top: 16px;
  font-size: 16px;
  letter-spacing: 0.01em;
}

.chat-state p {
  margin-top: 7px;
  max-width: 310px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.chat-state .button {
  margin-top: 18px;
}

.spinner {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 2px solid rgba(31, 111, 92, 0.16);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.chat-state[role="status"] p {
  margin-top: 12px;
}

.empty-mark {
  width: 66px;
  height: 66px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  box-shadow: 0 12px 30px -18px rgba(31, 111, 92, 0.55);
}

.empty-mark svg {
  width: 28px;
  height: 28px;
}

.chat-state--error .empty-mark {
  background: var(--danger-soft);
  color: var(--danger);
}

.message-list {
  flex: 1 1 auto;
  min-height: 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 17px;
  scrollbar-width: thin;
  scrollbar-color: #ccc4b5 transparent;
}

.message-list::-webkit-scrollbar,
.queue-groups::-webkit-scrollbar,
.composer-box textarea::-webkit-scrollbar {
  width: 8px;
}

.message-list::-webkit-scrollbar-thumb,
.queue-groups::-webkit-scrollbar-thumb,
.composer-box textarea::-webkit-scrollbar-thumb {
  background: #d5cec1;
  border-radius: 99px;
}

.message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
  animation: message-in 0.22s ease both;
}

.message--visitor {
  align-items: flex-end;
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 5px 5px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.4;
}

.message-author {
  color: var(--muted);
  font-weight: 600;
}

.message-bubble {
  max-width: min(84%, 430px);
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 17px 17px 17px 5px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.message--agent .message-bubble {
  background: #fffefa;
}

.message--visitor .message-bubble {
  border-color: transparent;
  border-radius: 17px 17px 5px 17px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 20px -14px rgba(31, 111, 92, 0.8);
}

.message-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message--visitor .message-meta {
  flex-direction: row-reverse;
}

.message--visitor .message-author {
  color: var(--brand-strong);
}

.closed-panel {
  flex: 0 0 auto;
  margin: 0 20px 18px;
  padding: 16px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #e6ddcb;
  border-radius: var(--radius-md);
  background: #fbf7ef;
}

.closed-panel h3 {
  font-size: 14px;
}

.closed-panel p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.closed-panel .button {
  flex: 0 0 auto;
  min-height: 38px;
  font-size: 13px;
}

.composer {
  flex: 0 0 auto;
  padding: 14px 20px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.composer-box {
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: #fffefa;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer-box:focus-within {
  border-color: rgba(31, 111, 92, 0.55);
  box-shadow: 0 0 0 4px rgba(31, 111, 92, 0.09);
}

.composer-box textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  max-height: 148px;
  padding: 12px 14px 2px;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 1.65;
}

.composer-box textarea::placeholder {
  color: #9ba39d;
}

.composer-toolbar {
  padding: 2px 8px 8px 13px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.char-count {
  color: var(--faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.char-count[data-over="true"] {
  color: var(--danger);
}

.composer .button {
  min-height: 36px;
  padding: 7px 16px;
  font-size: 13px;
}

.composer-hint {
  margin-top: 7px;
  padding: 0 3px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.5;
}

.composer[aria-busy="true"] {
  opacity: 0.92;
}

/* ---------- Agent page ---------- */

.page--agent {
  background:
    radial-gradient(900px 600px at 100% -10%, rgba(31, 111, 92, 0.1), transparent 60%),
    #f2f0ea;
}

.agent-topbar {
  border-bottom: 1px solid rgba(212, 206, 194, 0.62);
  background: rgba(255, 253, 249, 0.62);
  backdrop-filter: blur(12px);
}

.agent-identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 12px;
  white-space: nowrap;
}

.agent-identity-avatar {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 11px;
  font-weight: 800;
}

.agent-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1440px;
  height: calc(100dvh - 72px);
  min-height: 0;
  margin: 0 auto;
  padding: 18px 22px 22px;
  display: flex;
}

.center-state {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
}

.center-state h1 {
  margin-top: 16px;
  font-size: 23px;
  letter-spacing: -0.02em;
}

.center-state p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.center-state .spinner {
  width: 25px;
  height: 25px;
}

.center-state .button {
  margin-top: 18px;
}

.login-view {
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin-top: 14px;
  font-size: 31px;
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.login-lead {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.form {
  margin-top: 26px;
}

.field + .field {
  margin-top: 16px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: #fffefa;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: rgba(31, 111, 92, 0.58);
  box-shadow: 0 0 0 4px rgba(31, 111, 92, 0.09);
}

.field input::placeholder {
  color: #a1a8a2;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 68px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  min-height: 32px;
  padding: 4px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.password-toggle:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.login-submit {
  width: 100%;
  min-height: 47px;
  margin-top: 22px;
}

.login-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  line-height: 1.65;
}

.workspace {
  width: 100%;
  min-height: 0;
  display: flex;
}

.workspace-grid {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 356px minmax(0, 1fr);
  gap: 16px;
}

.queue-panel,
.detail-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 16px 40px -30px rgba(29, 42, 37, 0.25);
}

.panel-head {
  flex: 0 0 auto;
  padding: 18px 17px 14px 19px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  font-size: 17px;
  line-height: 1.35;
  letter-spacing: -0.01em;
  border-radius: 6px;
}

.panel-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.3s ease;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-button[aria-busy="true"] svg {
  animation: spin 0.8s linear infinite;
}

.queue-groups {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 9px 9px 16px;
  scrollbar-width: thin;
  scrollbar-color: #d5cec1 transparent;
}

.queue-group + .queue-group {
  margin-top: 8px;
}

.queue-group-heading {
  padding: 10px 9px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.count-pill {
  min-width: 21px;
  height: 19px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.queue-group[data-group="pending"] .count-pill {
  background: var(--amber-soft);
  color: var(--amber);
}

.queue-group[data-group="active"] .count-pill {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.conversation-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.conversation-row {
  width: 100%;
  min-height: 64px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background-color 0.13s ease, border-color 0.13s ease;
}

button.conversation-row:hover {
  background: var(--surface-2);
}

button.conversation-row[aria-pressed="true"] {
  border-color: #c8dfd6;
  background: var(--brand-tint);
}

button.conversation-row[aria-pressed="true"] .conversation-label {
  color: var(--brand-strong);
}

.conversation-row--pending {
  border-color: #ece2cd;
  background: #fdf9f0;
}

.conversation-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.conversation-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 650;
}

.conversation-time {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.conversation-row-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11.5px;
}

.conversation-unread {
  min-width: 20px;
  min-height: 20px;
  display: inline-grid;
  place-items: center;
  padding-inline: 5px;
  border-radius: 999px;
  color: #fff;
  background: var(--brand-strong);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.conversation-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.state-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.conversation-row--pending .conversation-state {
  color: var(--amber);
}

.conversation-row--active .conversation-state {
  color: var(--brand);
}

.conversation-row--closed .conversation-state {
  color: var(--faint);
}

.claim-button {
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid #e2cc9f;
  border-radius: 8px;
  background: #fff;
  color: var(--amber);
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}

.claim-button:hover:not(:disabled) {
  background: var(--amber-soft);
}

.claim-button:disabled {
  opacity: 0.65;
}

.queue-state {
  flex: 1 1 auto;
  min-height: 0;
  padding: 26px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.queue-state .spinner {
  width: 20px;
  height: 20px;
  margin-bottom: 10px;
}

.queue-state h3 {
  color: var(--ink-soft);
  font-size: 14px;
}

.queue-state p {
  margin-top: 4px;
  max-width: 230px;
  line-height: 1.7;
}

.queue-state .button {
  margin-top: 14px;
  min-height: 36px;
  font-size: 12.5px;
}

.queue-empty-icon {
  width: 46px;
  height: 46px;
  margin-bottom: 12px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--faint);
}

.queue-empty-icon svg {
  width: 21px;
  height: 21px;
}

.detail-panel {
  position: relative;
  background: var(--surface);
}

.detail-header {
  flex: 0 0 auto;
  padding: 19px 23px 15px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.detail-header-main {
  min-width: 0;
}

.detail-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.detail-title-row h2 {
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.detail-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.detail-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-state {
  flex: 1 1 auto;
  min-height: 0;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.detail-state h2 {
  margin-top: 16px;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.detail-state p {
  margin-top: 6px;
  max-width: 320px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.detail-state .button {
  margin-top: 16px;
}

.detail-state .spinner {
  width: 23px;
  height: 23px;
}

.detail-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #fcfaf6;
  background-image: radial-gradient(rgba(31, 111, 92, 0.045) 0.8px, transparent 0.8px);
  background-size: 17px 17px;
}

.detail-body .message-list {
  padding: 20px 23px;
}

.detail-closed {
  flex: 0 0 auto;
  margin: 0 20px 16px;
  padding: 14px 16px;
  border: 1px solid #e6ddcb;
  border-radius: 13px;
  background: #fbf7ef;
}

.detail-closed h3 {
  font-size: 13.5px;
}

.detail-closed p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.confirm-bar {
  flex: 0 0 auto;
  padding: 11px 23px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #f0d4cf;
  background: var(--danger-soft);
  animation: message-in 0.16s ease both;
}

.confirm-bar p {
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.confirm-actions .button {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12px;
}

.detail-composer {
  flex: 0 0 auto;
  padding: 13px 20px 15px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.detail-composer .composer-hint {
  margin-top: 6px;
}

.detail-composer .button {
  min-height: 36px;
}

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 24px;
  max-width: min(440px, calc(100vw - 34px));
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: #26332e;
  color: #fff;
  box-shadow: 0 18px 40px -18px rgba(18, 28, 24, 0.7);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast[data-tone="error"] {
  background: #6e2e2a;
}

.toast[data-tone="success"] {
  background: #1c5a49;
}

/* ---------- Responsive ---------- */

@media (max-width: 1040px) {
  .visitor-main {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 500px);
    gap: 36px;
  }

  .workspace-grid {
    grid-template-columns: 320px minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .visitor-main {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
    padding-top: 18px;
    align-items: start;
  }

  .visitor-intro {
    max-width: 620px;
    padding: 4px 0 0;
  }

  .visitor-title {
    margin-top: 14px;
    font-size: clamp(38px, 8vw, 52px);
  }

  .intro-lead {
    margin-top: 14px;
    font-size: 15px;
  }

  .feature-list {
    display: none;
  }

  .intro-note {
    display: none;
  }

  .chat-card {
    height: min(680px, calc(100dvh - 70px));
    min-height: 520px;
  }

  .agent-main {
    height: auto;
    min-height: calc(100dvh - 72px);
    padding: 12px;
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .queue-panel {
    max-height: 42dvh;
  }

  .detail-panel {
    min-height: 58dvh;
    max-height: none;
  }

  .detail-state {
    min-height: 300px;
  }
}

@media (max-width: 620px) {
  .topbar {
    min-height: 62px;
    padding: 0 14px;
    gap: 10px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 16px;
  }

  .brand-name {
    font-size: 13.5px;
  }

  .brand-sub {
    display: none;
  }

  .topbar-side {
    gap: 7px;
  }

  .topbar-link {
    padding: 7px 6px;
    font-size: 12px;
  }

  .connection-chip {
    min-height: 27px;
    padding: 3px 8px;
    font-size: 11px;
  }

  .visitor-main {
    padding: 10px 12px 24px;
    gap: 18px;
  }

  .visitor-intro {
    padding: 4px 3px 0;
  }

  .eyebrow {
    font-size: 11px;
  }

  .visitor-title {
    margin-top: 10px;
    font-size: clamp(34px, 10.5vw, 44px);
  }

  .intro-lead {
    margin-top: 10px;
    font-size: 13.5px;
    line-height: 1.7;
  }

  .chat-card {
    height: calc(100dvh - 176px);
    min-height: 470px;
    border-radius: 22px;
  }

  .chat-head {
    min-height: 72px;
    padding: 12px 15px;
  }

  .agent-avatar {
    width: 39px;
    height: 39px;
    border-radius: 13px;
    font-size: 15px;
  }

  .chat-heading-text h2 {
    font-size: 15px;
  }

  .chat-meta {
    max-width: 190px;
    font-size: 11px;
  }

  .message-list {
    padding: 18px 14px;
  }

  .message-bubble {
    max-width: 88%;
  }

  .message-text {
    font-size: 13.5px;
  }

  .composer {
    padding: 10px 12px 12px;
  }

  .composer-hint {
    display: none;
  }

  .closed-panel {
    margin: 0 12px 12px;
    padding: 13px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .closed-panel .button {
    width: 100%;
  }

  .site-footer {
    padding: 0 16px 16px;
    font-size: 11px;
  }

  .agent-topbar {
    padding: 0 12px;
  }

  .agent-identity {
    display: none;
  }

  .agent-main {
    min-height: calc(100dvh - 62px);
    padding: 8px;
  }

  .queue-panel {
    max-height: 40dvh;
    border-radius: 18px;
  }

  .detail-panel {
    min-height: 60dvh;
    border-radius: 18px;
  }

  .panel-head {
    padding: 14px 14px 11px 16px;
  }

  .detail-header {
    padding: 14px 16px 12px;
  }

  .detail-title-row h2 {
    font-size: 17px;
  }

  .detail-body .message-list {
    padding: 16px;
  }

  .detail-composer {
    padding: 10px 12px 12px;
  }

  .confirm-bar {
    padding: 10px 14px;
    align-items: flex-start;
    flex-direction: column;
  }

  .confirm-actions {
    width: 100%;
  }

  .confirm-actions .button {
    flex: 1;
  }

  .login-view {
    padding: 12px;
  }

  .login-card {
    padding: 28px 22px;
    border-radius: 22px;
  }

  .login-card h1 {
    font-size: 27px;
  }

  .toast {
    bottom: 14px;
    font-size: 12.5px;
  }
}

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

/* ---------- Landing page (same-origin stylesheet) ---------- */

.landing {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background:
    radial-gradient(900px 560px at 8% -10%, rgba(238, 198, 137, .32), transparent 62%),
    radial-gradient(800px 520px at 100% 5%, rgba(31, 111, 92, .12), transparent 58%),
    var(--bg);
}
.landing-card {
  width: min(840px, 100%);
  padding: clamp(28px, 5vw, 54px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.landing h1 {
  margin-top: 18px;
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.12;
  letter-spacing: -.045em;
}
.landing h1 em { color: var(--brand); font-style: normal; }
.landing-lead {
  max-width: 520px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}
.entry-grid {
  margin-top: 30px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.entry {
  min-height: 156px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.entry:hover {
  border-color: #c8dfd6;
  background: var(--brand-tint);
  transform: translateY(-2px);
}
.entry-kicker { color: var(--brand); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.entry strong { display: block; margin-top: 5px; font-size: 19px; letter-spacing: -.02em; }
.entry p { margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.entry-arrow { color: var(--brand); font-size: 13px; font-weight: 600; }
.landing-note {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 12px;
  line-height: 1.7;
}
@media (max-width: 620px) {
  .landing { padding: 14px; }
  .landing-card { padding: 26px 20px; border-radius: 22px; }
  .entry-grid { grid-template-columns: 1fr; }
  .entry { min-height: 132px; padding: 18px; }
}

.noscript-notice { padding: 18px; text-align: center; }

/* Mobile visitor: prioritize the conversation over the desktop introduction. */
@media (max-width: 620px) {
  .page--visitor .app-shell {
    height: 100dvh;
  }

  .page--visitor .visitor-intro,
  .page--visitor .site-footer {
    display: none;
  }

  .page--visitor .visitor-main {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    padding: 2px 12px max(10px, env(safe-area-inset-bottom));
  }

  .page--visitor .chat-card {
    height: 100%;
    min-height: 0;
  }

  .page--visitor .composer-box textarea {
    font-size: 16px;
  }
}

/* ---------- Rich message content (safe text / image / card) ---------- */

.message-bubble[data-content-type="image"] {
  padding: 4px;
  overflow: hidden;
}

.message-bubble[data-content-type="card"] {
  width: min(100%, 360px);
  padding: 0;
  overflow: hidden;
}

.message-image {
  margin: 0;
}

.message-image img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--surface-2);
}

.message-image.is-broken img {
  min-width: 180px;
  min-height: 72px;
  object-fit: contain;
}

.message-caption {
  padding: 7px 8px 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-bubble[data-content-type="card"] .message-caption {
  padding: 0;
}

.message-card {
  display: block;
  overflow: hidden;
  border-radius: 16px;
  background: #fffefa;
}

.message-card-cover-slot {
  aspect-ratio: 16 / 9;
  background: var(--surface-2);
}
.message-card-cover {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  visibility: hidden;
}
.message-card-cover.is-ready { visibility: visible; }

.message-card-body {
  padding: 12px 14px 14px;
}

.message-card-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.message-card-description {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 6px 11px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.message-card-link::after {
  content: "↗";
  font-size: 11px;
}

.message[data-auto] .message-author {
  color: var(--accent);
}

.message[data-auto] .message-meta::after {
  content: "自动";
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.message--visitor .message-meta::after {
  content: none;
}

/* ---------- Content editor (reply + automatic messages) ---------- */

.content-editor {
  min-width: 0;
}

.editor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 9px 10px 0;
}

.editor-tab {
  min-height: 29px;
  padding: 4px 11px;
  border: 1px solid transparent;
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.editor-tab:hover {
  background: var(--surface-2);
}

.editor-tab.is-active {
  border-color: var(--line);
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.editor-panel {
  padding: 8px 10px 10px;
}

.editor-field {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.editor-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.editor-text,
.editor-caption,
.editor-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffefa;
  padding: 9px 11px;
  outline: none;
  font-size: 13px;
  line-height: 1.6;
}

.editor-text {
  resize: vertical;
  min-height: 58px;
}

.editor-caption {
  resize: vertical;
  min-height: 48px;
}

.editor-input {
  min-height: 38px;
}

.editor-text:focus,
.editor-caption:focus,
.editor-input:focus {
  border-color: rgba(31, 111, 92, 0.55);
  box-shadow: 0 0 0 3px rgba(31, 111, 92, 0.08);
}

.editor-upload-row {
  margin-top: 8px;
}

.editor-upload {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.editor-upload:hover {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.editor-upload.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.editor-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.editor-preview {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
}

.editor-preview img {
  display: block;
  width: 112px;
  height: 78px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
}

.editor-remove {
  min-height: 29px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--danger);
  font-size: 11px;
}

.editor-error {
  margin: 0 10px 8px;
}

.reply-editor .editor-tabs {
  padding: 9px 12px 0;
}

.reply-editor .editor-panel {
  padding: 4px 12px 8px;
}

.reply-editor .editor-text,
.reply-editor .editor-caption {
  min-height: 46px;
  max-height: 148px;
  border: 0;
  border-radius: 0;
  padding: 8px 2px 2px;
  background: transparent;
  resize: none;
}

.reply-editor .editor-text:focus,
.reply-editor .editor-caption:focus {
  box-shadow: none;
}

.reply-editor .editor-preview img {
  width: 92px;
  height: 64px;
}

.reply-editor .editor-error {
  margin: 0 12px 8px;
}

/* ---------- Agent settings dialog ---------- */

.settings-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.settings-dialog::backdrop {
  background: rgba(23, 34, 29, 0.4);
  backdrop-filter: blur(2px);
}

.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.settings-head h2 {
  margin: 3px 0 0;
  font-size: 20px;
  line-height: 1.35;
}

.settings-presence {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.settings-body {
  max-height: calc(88vh - 190px);
  overflow-y: auto;
  padding: 0 22px;
}

.settings-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.settings-section:last-child {
  border-bottom: 0;
}

.settings-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 8px;
}

.settings-section-head h3 {
  margin: 0;
  font-size: 15px;
}

.settings-section-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.settings-section .content-editor {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.settings-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.settings-seconds {
  max-width: 180px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.switch:has(input:checked) {
  border-color: rgba(31, 111, 92, 0.35);
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.settings-foot {
  padding: 13px 22px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 8px;
}

.settings-saved {
  margin: 0;
  color: var(--brand-strong);
  font-size: 12px;
}

@media (max-width: 720px) {
  .settings-dialog {
    width: 100vw;
    max-height: 94dvh;
    border-radius: 18px 18px 0 0;
    margin: auto 0 0;
  }

  .settings-body {
    max-height: calc(94dvh - 190px);
    padding: 0 15px;
  }

  .settings-head,
  .settings-foot {
    padding-left: 15px;
    padding-right: 15px;
  }

  .settings-section-head {
    flex-direction: column;
    gap: 8px;
  }

  .message-card {
    max-width: 100%;
  }
}

.message-image img {
  min-width: 140px;
  min-height: 96px;
  width: auto;
}

/* ---------- Visitor appearance: presentation copy and message-area background ---------- */

.visitor-welcome {
  flex: 0 0 auto;
  margin: 0;
  padding: 7px 22px;
  border-bottom: 1px solid rgba(212, 206, 194, 0.7);
  background: var(--brand-tint, #f1f8f5);
  color: var(--brand-strong, #175848);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-body[data-bg-kind="preset"][data-bg-preset="paper"] {
  background-color: #fbf7ef;
  background-image: radial-gradient(rgba(146, 101, 28, 0.07) 0.8px, transparent 0.8px);
}

.chat-body[data-bg-kind="preset"][data-bg-preset="warm"] {
  background-color: #fbf1e5;
  background-image: radial-gradient(rgba(196, 106, 63, 0.1) 0.8px, transparent 0.8px);
}

.chat-body[data-bg-kind="preset"][data-bg-preset="mint"] {
  background-color: #edf7f1;
  background-image: radial-gradient(rgba(31, 111, 92, 0.09) 0.8px, transparent 0.8px);
}

.chat-body[data-bg-kind="preset"][data-bg-preset="sky"] {
  background-color: #eef5fb;
  background-image: radial-gradient(rgba(52, 106, 150, 0.09) 0.8px, transparent 0.8px);
}

.chat-body[data-bg-kind="color"] {
  background-color: var(--visitor-chat-color, #fcfaf6);
  background-image: linear-gradient(rgba(255, 253, 249, 0.72), rgba(255, 253, 249, 0.72));
}

.chat-body[data-bg-kind="image"] {
  background-image:
    linear-gradient(rgba(255, 253, 249, 0.8), rgba(255, 253, 249, 0.8)),
    var(--visitor-chat-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.chat-body[data-bg-kind="color"] .chat-state,
.chat-body[data-bg-kind="image"] .chat-state {
  background: rgba(255, 253, 249, 0.72);
}

@media (max-width: 620px) {
  .visitor-welcome {
    padding: 5px 14px;
    font-size: 11px;
  }
}

/* ---------- Visitor appearance editor and preview ---------- */

.appearance-dialog {
  width: min(1120px, calc(100vw - 32px));
}

.appearance-body {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.08fr);
  gap: 24px;
  padding-top: 18px;
  padding-bottom: 18px;
}

.appearance-form {
  min-width: 0;
}

.appearance-form .editor-field {
  margin-top: 10px;
}

.appearance-theme-row {
  margin-top: 12px;
}

.appearance-color-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.appearance-color-control input[type="color"] {
  width: 46px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.appearance-color-control output {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.appearance-background {
  margin: 16px 0 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.appearance-background legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.appearance-bg-option[hidden] {
  display: none !important;
}

.appearance-bg-preview {
  margin-top: 9px;
}

.appearance-bg-preview img {
  display: block;
  width: 100%;
  max-height: 130px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.appearance-preview-wrap {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.appearance-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.appearance-preview-head h3 {
  margin: 0;
  font-size: 14px;
}

.appearance-mode-tabs {
  display: flex;
  gap: 4px;
}

.appearance-preview {
  --brand: #1f6f5c;
  --brand-strong: #175848;
  --brand-soft: #e6f1ec;
  --brand-tint: #f1f8f5;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(212, 206, 194, 0.9);
  border-radius: 20px;
  background: #f4f1ea;
  box-shadow: var(--shadow-sm);
}

.appearance-preview[data-mode="mobile"] {
  width: 390px;
  max-width: 100%;
}

.appearance-preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}

.appearance-preview-connection {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.appearance-preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.2fr);
  gap: 13px;
  padding: 15px;
}

.appearance-preview[data-mode="mobile"] .appearance-preview-layout {
  grid-template-columns: 1fr;
  gap: 0;
  padding: 9px;
}

.appearance-preview-intro {
  align-self: center;
  padding: 8px;
}

.appearance-preview[data-mode="mobile"] .appearance-preview-intro {
  display: none;
}

.appearance-preview-intro h4 {
  margin: 0;
  font-size: clamp(21px, 3vw, 30px);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.appearance-preview-intro h4 em {
  display: inline-block;
  color: var(--brand);
  font-style: normal;
}

.appearance-preview-intro p {
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.appearance-preview-chat {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(212, 206, 194, 0.9);
  border-radius: 17px;
  background: var(--surface);
}

.appearance-preview-chathead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}

.appearance-preview-chathead span {
  color: var(--muted);
  font-size: 9px;
}

.appearance-preview-welcome {
  margin: 0;
  padding: 5px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--brand-tint);
  color: var(--brand-strong);
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.appearance-preview-body {
  min-height: 190px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: #fcfaf6;
  background-image: radial-gradient(rgba(31, 111, 92, 0.055) 0.8px, transparent 0.8px);
}

.appearance-preview[data-mode="mobile"] .appearance-preview-body {
  min-height: 300px;
}

.appearance-preview-body[data-bg-kind="preset"][data-bg-preset="paper"] {
  background-color: #fbf7ef;
  background-image: radial-gradient(rgba(146, 101, 28, 0.07) 0.8px, transparent 0.8px);
}

.appearance-preview-body[data-bg-kind="preset"][data-bg-preset="warm"] {
  background-color: #fbf1e5;
  background-image: radial-gradient(rgba(196, 106, 63, 0.1) 0.8px, transparent 0.8px);
}

.appearance-preview-body[data-bg-kind="preset"][data-bg-preset="mint"] {
  background-color: #edf7f1;
  background-image: radial-gradient(rgba(31, 111, 92, 0.09) 0.8px, transparent 0.8px);
}

.appearance-preview-body[data-bg-kind="preset"][data-bg-preset="sky"] {
  background-color: #eef5fb;
  background-image: radial-gradient(rgba(52, 106, 150, 0.09) 0.8px, transparent 0.8px);
}

.appearance-preview-body[data-bg-kind="color"] {
  background-color: var(--visitor-chat-color, #fcfaf6);
  background-image: linear-gradient(rgba(255, 253, 249, 0.72), rgba(255, 253, 249, 0.72));
}

.appearance-preview-body[data-bg-kind="image"] {
  background-image:
    linear-gradient(rgba(255, 253, 249, 0.8), rgba(255, 253, 249, 0.8)),
    var(--visitor-chat-image, none);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.appearance-preview-bubble {
  max-width: 82%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 12px 12px 12px 4px;
  background: var(--surface);
  font-size: 10px;
  line-height: 1.5;
}

.appearance-preview-bubble--visitor {
  align-self: flex-end;
  border-color: transparent;
  border-radius: 12px 12px 4px 12px;
  background: var(--brand);
  color: #fff;
}

.appearance-preview-composer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.appearance-preview-send {
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--brand);
  color: #fff;
  font-size: 9px;
}

.appearance-preview-note {
  margin: 9px 2px 0;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.5;
}

@media (max-width: 980px) {
  .appearance-body {
    grid-template-columns: 1fr;
  }

  .appearance-preview {
    max-width: 560px;
  }
}

@media (max-width: 620px) {
  .appearance-body {
    padding-left: 12px;
    padding-right: 12px;
  }

  .appearance-preview-wrap {
    padding: 10px;
  }
}

.page--visitor .brand-name {
  max-width: min(42vw, 360px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page--visitor .chat-heading-text h2 {
  max-width: min(44vw, 360px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-row.is-revealed,
.claim-button.is-revealed {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.conversation-row.is-revealed {
  background: var(--brand-tint);
}

/* Shared inbox and mobile agent workspace. The desktop and visitor grids are unchanged. */
.page--agent .mobile-only,
.page--agent .mobile-menu-backdrop {
  display: none;
}

.page--agent .conversation-preview {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (max-width: 760px) {
  .page--agent[data-mobile-screen] {
    --agent-page-bg: #f5f6f6;
    --agent-chat-bg: #edf0ef;
    --agent-row-border: #e9eceb;
    --agent-compact-header: #f7f8f8;
    --agent-mobile-gutter: 14px;
    background: var(--agent-page-bg);
    overscroll-behavior-y: none;
  }

  .page--agent[data-mobile-screen] > .app-shell {
    min-height: 0;
    height: min(100dvh, var(--agent-visual-height, 100dvh));
  }

  .page--agent[data-mobile-screen] .agent-main {
    height: auto;
    min-height: 0;
    padding: 0;
  }

  .page--agent[data-mobile-screen] .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
  }

  .page--agent[data-mobile-screen] :is(.queue-panel, .detail-panel) {
    min-height: 0;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .page--agent[data-mobile-screen="list"] .detail-panel,
  .page--agent[data-mobile-screen="chat"] .queue-panel,
  .page--agent[data-mobile-screen="chat"] .agent-topbar {
    display: none;
  }

  .page--agent .agent-topbar {
    min-height: calc(54px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) max(var(--agent-mobile-gutter, 14px), env(safe-area-inset-right, 0px)) 0 max(var(--agent-mobile-gutter, 14px), env(safe-area-inset-left, 0px));
    gap: 8px;
    background: var(--agent-compact-header, #f7f8f8);
    backdrop-filter: none;
  }

  .page--agent .agent-topbar .brand {
    gap: 8px;
    min-width: 0;
  }

  .page--agent .agent-topbar .brand-mark {
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 9px;
    font-size: 16px;
  }

  .page--agent .agent-topbar .brand-sub {
    display: none;
  }

  .page--agent .agent-topbar .topbar-side {
    gap: 7px;
  }

  .page--agent .agent-topbar :is(.topbar-link, .agent-identity, #agent-appearance-open, #agent-settings-open, #agent-qq-browser-open, #agent-logout),
  .page--agent .desktop-only-action {
    display: none;
  }

  .page--agent .agent-topbar .connection-chip {
    white-space: nowrap;
  }

  .page--agent .mobile-only:not([hidden]) {
    display: grid;
  }

  .page--agent[data-mobile-screen] .queue-panel {
    background: #fff;
  }

  .page--agent[data-mobile-screen] .queue-panel .panel-head {
    align-items: center;
    padding: 9px max(var(--agent-mobile-gutter), env(safe-area-inset-right, 0px)) 9px max(var(--agent-mobile-gutter), env(safe-area-inset-left, 0px));
    border-color: var(--agent-row-border);
    background: var(--agent-compact-header);
  }

  .page--agent[data-mobile-screen] .queue-panel .panel-head h2 {
    font-size: 16px;
  }

  .page--agent[data-mobile-screen] .queue-groups {
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    scrollbar-width: thin;
  }

  .page--agent[data-mobile-screen] .queue-group + .queue-group {
    margin-top: 0;
  }

  .page--agent[data-mobile-screen] .queue-group-heading {
    padding: 8px 14px;
    background: var(--agent-page-bg);
  }

  .page--agent[data-mobile-screen] .conversation-list {
    gap: 0;
  }

  .page--agent[data-mobile-screen] .conversation-row {
    min-height: 68px;
    padding: 12px 14px 12px 65px;
    gap: 2px;
    position: relative;
    border: 0;
    border-bottom: 1px solid var(--agent-row-border);
    border-radius: 0;
    background: #fff;
  }

  .page--agent[data-mobile-screen] .conversation-row:not(:has(.conversation-avatar))::before {
    content: "";
    position: absolute;
    left: 14px;
    top: 14px;
    width: 37px;
    height: 37px;
    border-radius: 10px;
    background:
      radial-gradient(circle at 50% 36%, var(--brand) 4px, transparent 4.5px),
      radial-gradient(ellipse 8px 5px at 50% 64%, var(--brand) 97%, transparent),
      var(--brand-soft);
  }

  .page--agent[data-mobile-screen] .conversation-row .conversation-avatar {
    position: absolute;
    left: 14px;
    top: 14px;
    width: 37px;
    height: 37px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 13px;
    font-weight: 700;
  }

  .page--agent[data-mobile-screen] button.conversation-row:is(:active, [aria-pressed="true"]) {
    background: var(--brand-tint);
  }

  .page--agent[data-mobile-screen] .conversation-label {
    font-size: 15px;
  }

  .page--agent[data-mobile-screen] .conversation-time {
    color: var(--muted);
    font-size: 11px;
  }

  .page--agent[data-mobile-screen] .conversation-preview {
    font-size: 12px;
  }

  .page--agent[data-mobile-screen] .conversation-unread {
    flex: 0 0 auto;
    background: #b63542;
    min-height: 19px;
    font-size: 11px;
  }

  .page--agent[data-mobile-screen] .detail-panel {
    background: var(--agent-chat-bg);
  }

  .page--agent[data-mobile-screen] .detail-header {
    padding: calc(4px + env(safe-area-inset-top, 0px)) max(9px, env(safe-area-inset-right, 0px)) 4px max(9px, env(safe-area-inset-left, 0px));
    min-height: calc(52px + env(safe-area-inset-top, 0px));
    position: relative;
    align-items: center;
    gap: 6px;
    border-color: var(--agent-row-border);
    background: var(--agent-compact-header);
  }

  .page--agent[data-mobile-screen] .detail-header-main {
    flex: 1 1 auto;
    text-align: center;
  }

  .page--agent[data-mobile-screen] .detail-title-row {
    justify-content: center;
    flex-wrap: nowrap;
  }

  .page--agent[data-mobile-screen] .detail-title-row h2 {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 16px;
  }

  .page--agent[data-mobile-screen] .detail-header :is(.detail-meta, .status-badge) {
    display: none;
  }

  .page--agent[data-mobile-screen] :is(#agent-back, #back-to-list, #agent-chat-menu-btn, #agent-list-menu-btn) {
    min-height: 44px;
    width: 44px;
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: var(--ink);
  }

  .page--agent[data-mobile-screen] :is(#agent-back, #back-to-list) {
    width: 58px;
    font-size: 13px;
  }

  .page--agent[data-mobile-screen] .detail-state {
    min-height: 0;
  }

  .page--agent[data-mobile-screen] .detail-body {
    background: transparent;
  }

  .page--agent[data-mobile-screen] .detail-body .message-list {
    gap: 13px;
    padding: 15px max(var(--agent-mobile-gutter), env(safe-area-inset-right, 0px)) 15px max(var(--agent-mobile-gutter), env(safe-area-inset-left, 0px));
    scrollbar-width: thin;
  }

  .page--agent[data-mobile-screen] .message--visitor {
    align-items: flex-start;
  }

  .page--agent[data-mobile-screen] .message--agent {
    align-items: flex-end;
  }

  .page--agent[data-mobile-screen] .message--visitor .message-meta {
    flex-direction: row;
  }

  .page--agent[data-mobile-screen] .message--agent .message-meta {
    flex-direction: row-reverse;
  }

  .page--agent[data-mobile-screen] .message-meta {
    color: var(--muted);
  }

  .page--agent[data-mobile-screen] .message-bubble {
    max-width: min(86%, 430px);
    padding: 8px 12px;
    border: 1px solid transparent;
    color: var(--ink);
    box-shadow: none;
  }

  .page--agent[data-mobile-screen] .message-bubble[data-content-type="image"] {
    padding: 4px;
  }

  .page--agent[data-mobile-screen] .message--visitor .message-bubble {
    background: #fff;
    border-radius: 11px 11px 11px 3px;
  }

  .page--agent[data-mobile-screen] .message--agent .message-bubble {
    background: #d1ebd7;
    border-radius: 11px 11px 3px 11px;
  }

  .page--agent[data-mobile-screen] .message--agent[data-auto] .message-bubble {
    background: #fff7e8;
  }

  .page--agent[data-mobile-screen] .detail-composer {
    max-height: 55%;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px max(9px, env(safe-area-inset-right, 0px)) max(7px, env(safe-area-inset-bottom, 0px)) max(9px, env(safe-area-inset-left, 0px));
    border-color: var(--agent-row-border);
    background: var(--agent-compact-header);
  }

  .page--agent[data-mobile-screen] .detail-composer .composer-box {
    border: 1px solid #dce2df;
    border-radius: 11px;
    background: #fff;
  }

  .page--agent[data-mobile-screen] .detail-composer .composer-box:has(.reply-editor[data-kind="text"]) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .page--agent[data-mobile-screen] .detail-composer .composer-box:has(.reply-editor[data-kind="text"]) .composer-toolbar {
    padding: 5px 6px;
  }

  .page--agent[data-mobile-screen] .detail-composer .editor-tabs {
    display: none;
  }

  .page--agent[data-mobile-screen] .detail-composer .editor-panel {
    padding: 4px 8px;
  }

  .page--agent[data-mobile-screen] .detail-composer :is(.editor-text, .editor-caption) {
    min-height: 38px;
    height: 40px;
    max-height: 90px;
    padding: 6px 3px;
    font-size: 16px;
  }

  .page--agent[data-mobile-screen] .detail-composer .composer-toolbar {
    padding: 0 6px 5px;
  }

  .page--agent[data-mobile-screen] .detail-composer .composer-hint {
    display: none;
  }

  .page--agent[data-mobile-screen] .detail-composer .button {
    min-height: 35px;
    padding: 4px 13px;
  }

  .page--agent .mobile-menu-backdrop:not([hidden]) {
    position: fixed;
    z-index: 75;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(16, 27, 23, 0.39);
  }

  .page--agent .mobile-menu-sheet {
    width: min(100%, 480px);
    max-height: min(80dvh, var(--agent-visual-height, 80dvh));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    box-shadow: 0 -7px 25px rgba(16, 27, 23, 0.12);
  }

  .page--agent .mobile-menu-sheet :is(.mobile-menu-item, .mobile-menu-cancel) {
    display: block;
    width: 100%;
    min-height: 45px;
    padding: 10px 18px;
    border: 0;
    border-bottom: 1px solid #edf0ee;
    background: #fff;
    color: var(--ink);
    text-align: center;
    text-decoration: none;
  }

  .page--agent .mobile-menu-sheet .mobile-menu-item--danger {
    color: var(--danger);
  }

  .page--agent .mobile-menu-divider {
    height: 5px;
    background: #f1f3f2;
  }

  .page--agent .mobile-menu-sheet .mobile-menu-cancel {
    border: 0;
    border-top: 6px solid #f1f3f2;
    font-weight: 700;
  }

  .page--agent[data-mobile-screen] .toast {
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
}

/* Stretch the existing, keyboard-accessible anchor across linked cards. */
.message-card { position: relative; }
.message-card-link::before { content: ""; position: absolute; inset: 0; cursor: pointer; }
.opening-overlay {
  position: fixed; inset: 0; margin: auto; border: 0; border-radius: 16px;
  padding: 18px 24px; color: #163c34; background: #fffefa;
  box-shadow: 0 8px 30px #142d2926; font: inherit; font-weight: 650;
}
.opening-overlay::backdrop { background: rgb(18 34 30 / 38%); }
.opening-status { display: flex; align-items: center; gap: 12px; }
.opening-spinner {
  flex: 0 0 18px; width: 18px; height: 18px; border: 2px solid #ccded9;
  border-top-color: #216752; border-radius: 50%;
  will-change: transform; animation: opening-spin .8s linear infinite;
}
@keyframes opening-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .opening-spinner { animation: none; } }

/* Compact chat composer: input, attachment, send. */
.page--visitor #composer { padding: 6px 9px max(7px, env(safe-area-inset-bottom)); }
#composer .composer-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 4px;
  padding: 3px 4px;
  border-radius: 12px;
}
#composer #message-input {
  min-width: 0;
  min-height: 44px;
  height: 44px;
  padding: 9px 7px;
  font-size: 16px;
  line-height: 24px;
}
#composer .composer-toolbar { padding: 0; gap: 4px; }
#composer .char-count { display: none; }
#composer #send-button { min-height: 44px; padding-inline: 10px; white-space: nowrap; }
.composer .button.composer-picture {
  display: inline-grid; place-items: center;
  width: 44px; min-width: 44px; min-height: 44px;
  padding: 0; border-radius: 8px; background: transparent;
  color: var(--brand-strong);
}
.composer .button.composer-picture:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
#attachment-name { overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .page--agent[data-mobile-screen] .detail-composer .reply-editor[data-kind="text"] {
    min-width: 0;
  }
  .page--agent[data-mobile-screen] .detail-composer .reply-editor [data-panel="text"] {
    padding: 3px 4px;
  }
  .page--agent[data-mobile-screen] .detail-composer .reply-editor [data-panel="text"] .editor-field {
    margin: 0;
  }
  .page--agent[data-mobile-screen] .detail-composer .reply-editor [data-panel="text"] .editor-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
  }
  .page--agent[data-mobile-screen] .detail-composer .reply-editor .editor-text {
    height: 44px; min-height: 44px; padding: 9px 6px;
    line-height: 24px; resize: none;
  }
  .page--agent[data-mobile-screen] .detail-composer .composer-box:has(.reply-editor[data-kind="text"]) .composer-toolbar {
    padding: 3px 4px 3px 0; gap: 4px;
  }
  .page--agent[data-mobile-screen] .detail-composer .composer-toolbar button[type="submit"] {
    min-height: 44px; padding-inline: 10px; white-space: nowrap;
  }
}

/* Prepending older messages preserves the first visible message position in script. */
.message-list { overflow-anchor: none; }
.message-history-control {
  flex: 0 0 auto;
  align-self: center;
  list-style: none;
}
.message-history-control .button {
  min-height: 44px;
  padding-inline: 14px;
  font-size: 13px;
}

.qq-browser-guide[hidden]{display:none!important}.show-qq-browser-guide>:not(.qq-browser-guide){display:none!important}
.qq-browser-guide{position:relative;min-height:100dvh;margin:auto;padding:clamp(72px,20vw,142px) 1rem 2rem;text-align:center;box-sizing:border-box;background:#fff;color:#18252d}
.show-qq-browser-guide{display:block;background:#fff}.qq-browser-guide h1,.qq-browser-guide>p:not(.qq-guide-hint):not([role]){font-size:clamp(1.15rem,5vw,1.7rem);line-height:1.4;font-weight:500}.qq-browser-guide h1 strong{letter-spacing:.18em}
.qq-guide-arrow{position:absolute;top:.25rem;right:10%;width:clamp(70px,23vw,145px);height:auto;pointer-events:none}
.qq-guide-phone{box-sizing:border-box;width:min(178px,64vw);height:258px;margin:2.2rem auto 1.2rem;border:2px solid #d7dde4;border-radius:24px;background:#f6f8fc;box-shadow:0 8px 18px #172e4820;display:grid;grid-template-rows:30px 1fr;align-items:center;padding:.7rem;color:#3d5268}.qq-guide-phone>span{text-align:right;letter-spacing:.16em}.qq-guide-phone>div{border:1px solid #dbe5ef;border-radius:14px;padding:1rem .25rem;background:#fff}.qq-guide-phone b{display:block;color:#2871d8;font-size:1.7rem}.qq-guide-hint{font-size:.88rem;color:#54667a;margin:1rem auto;max-width:22rem}.qq-browser-settings{padding:1rem}.qq-browser-settings label{display:flex;align-items:center;gap:.75rem;padding:.65rem 0}
