/* Seller1 agent widget */
.agent {
  --agent-gap: max(18px, env(safe-area-inset-right));
  --agent-bottom: calc(18px + env(safe-area-inset-bottom));
  --agent-dot-ring: var(--card);
  --call-level: 0;
}
html.agent-lock, html.agent-lock body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}

.agent-fabs {
  position: fixed; z-index: 40;
  inset-inline-end: var(--agent-gap);
  bottom: var(--agent-bottom);
  display: flex; align-items: center; gap: 10px;
}
.agent-fab {
  position: relative;
  display: grid; place-items: center;
  width: 56px; height: 56px;
  border: 0; border-radius: var(--r-full);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-med) var(--ease-out), background-color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.agent-fab:active { transform: scale(0.94); }
.agent-fab:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; }
.agent-fab-chat { background: var(--accent); color: var(--on-accent); box-shadow: var(--sh-accent), inset 0 1px 0 rgba(255,255,255,.18); }
.agent-fab-chat .agent-mark { width: 30px; height: 30px; --agent-dot-ring: var(--accent); }
.agent-fab-call { width: 48px; height: 48px; background: var(--glass); color: var(--ink); border: 1px solid var(--line-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--sh-2); }
.agent-fab-call .ph { width: 21px; height: 21px; }
.agent-call-slot { position: relative; }
.call-badge {
  position: absolute; top: -4px; inset-inline-start: -6px;
  min-width: 28px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: #16a34a; color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  box-shadow: 0 4px 10px rgba(22, 163, 74, .35);
  pointer-events: none;
}
.call-note {
  position: fixed; z-index: 46;
  inset-inline-end: var(--agent-gap);
  bottom: calc(var(--agent-bottom) + 72px);
  width: min(260px, calc(100vw - 28px));
  display: grid; gap: 0.2rem;
  padding: 0.8rem 0.9rem 0.85rem;
  background: var(--card); color: var(--ink);
  border: 1px solid #22c55e; border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,.4), 0 0 0 3px rgba(34,197,94,.22);
  text-align: right;
}
.call-note b { font-size: 0.9rem; line-height: 1.75; padding-inline-end: 1.2rem; }
.call-note-tip { display: block; margin-top: 0.15rem; font-size: 0.75rem; line-height: 1.6; color: var(--ink-2); }
.call-note-kicker { font-size: 0.72rem; font-weight: 700; color: #4ade80; }
.call-note::after {
  content: ""; position: absolute; inset-inline-end: 18px; bottom: -6px;
  width: 12px; height: 12px; background: var(--card);
  border-inline-end: 1px solid #22c55e; border-bottom: 1px solid #22c55e;
  transform: rotate(45deg);
}
.call-note-x {
  position: absolute; inset-inline-end: 4px; top: 4px;
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--ink-3);
  border-radius: 999px; cursor: pointer;
}
.call-note-x .ph { width: 14px; height: 14px; }
.call-sheet {
  position: fixed; z-index: 62;
  inset-inline-end: var(--agent-gap);
  bottom: calc(var(--agent-bottom) + 70px);
  width: min(360px, calc(100vw - 24px));
  display: grid; gap: 0.65rem;
  padding: 1.1rem 1rem 1rem;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 22px;
  box-shadow: var(--sh-3);
}
.call-sheet[hidden] { display: none; }
.call-sheet > b { font-size: 1rem; line-height: 1.7; padding-inline-end: 1.4rem; }
.call-sheet > p { margin: 0; font-size: 0.82rem; line-height: 1.8; color: var(--ink-2); }
.call-note[hidden] { display: none; }
.agent-fab-close { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transform: rotate(-60deg) scale(.6); transition: opacity var(--t-fast), transform var(--t-med) var(--ease-out); }
.agent-fab-close .ph { width: 24px; height: 24px; }
.agent-fab-chat .agent-mark { transition: opacity var(--t-fast), transform var(--t-med) var(--ease-out); }
.agent.is-open .agent-fab-chat .agent-mark { opacity: 0; transform: rotate(60deg) scale(.6); }
.agent.is-open .agent-fab-close { opacity: 1; transform: none; }
.agent-mark circle:last-child { stroke: var(--agent-dot-ring); }

/* Proactive nudge */
.agent-nudge {
  position: fixed; z-index: 40;
  inset-inline-end: var(--agent-gap);
  bottom: calc(var(--agent-bottom) + 70px);
  width: min(300px, calc(100vw - 36px));
  display: grid; gap: 0.5rem;
  padding: 0.95rem 1rem 1rem;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  opacity: 0; transform: translateY(8px) scale(.98); transform-origin: bottom left;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out);
}
.agent-nudge.is-on { opacity: 1; transform: none; }
.agent-nudge b { font-size: 0.98rem; line-height: 1.7; padding-inline-end: 1.6rem; }
.agent-kicker { font-size: 0.75rem; color: var(--accent-ink); font-weight: 600; }
.agent-nudge-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.agent-x { position: absolute; inset-inline-end: 6px; top: 6px; width: 32px; height: 32px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink-3); border-radius: var(--r-full); cursor: pointer; }
.agent-x:hover { background: var(--tint-2); color: var(--ink); }
.agent-x .ph { width: 16px; height: 16px; }

.agent-chip {
  min-height: 34px; padding: 0.3rem 0.75rem;
  border: 1px solid var(--accent-line); border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--ink);
  font: inherit; font-size: 0.82rem; cursor: pointer;
  transition: background-color var(--t-fast), transform var(--t-fast);
}
.agent-chip:hover { background: rgba(239, 68, 68, 0.2); }
.agent-chip:active { transform: scale(.97); }

/* Panel */
.agent-panel {
  position: fixed; z-index: 41;
  inset-inline-end: var(--agent-gap);
  bottom: calc(var(--agent-bottom) + 70px);
  width: min(392px, calc(100vw - 24px));
  height: min(640px, calc(100svh - var(--agent-bottom) - 100px));
  display: flex; flex-direction: column;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
  visibility: hidden; opacity: 0;
  transform: translateY(12px) scale(.97); transform-origin: bottom left;
  transition: opacity var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-out), visibility 0s linear var(--t-med);
}
.agent.is-open .agent-panel { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }

.agent-head {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.85rem 0.9rem 0.85rem 0.6rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--accent-soft), transparent);
}
.agent-avatar { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: var(--r-full); background: var(--accent); color: #fff; --agent-dot-ring: var(--card); }
.agent-avatar .agent-mark { width: 30px; height: 30px; }
.agent-id { flex: 1; min-width: 0; display: grid; }
.agent-id b { font-size: 1rem; }
.agent-id span { display: flex; align-items: center; gap: 0.35rem; font-size: 0.76rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-live { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); flex: none; }

.agent-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; padding: 1rem 0.9rem; display: grid; align-content: start; gap: 0.75rem; scroll-behavior: smooth; }
.agent-log { display: grid; gap: 0.55rem; align-content: start; }
.agent-log:empty { display: none; }

.agent-msg, .agent-bubble {
  max-width: 88%;
  padding: 0.65rem 0.9rem;
  border-radius: 18px;
  font-size: 0.92rem; line-height: 1.85;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  animation: agent-in 220ms var(--ease-out) both;
}
.agent-msg p, .agent-bubble { margin: 0; }
.agent-msg p + p, .agent-msg p + ul, .agent-msg ul + p { margin-top: 0.45rem; }
.agent-msg ul, .agent-msg ol { margin: 0.35rem 0 0.15rem; padding-inline-start: 1.15rem; }
.agent-msg li { margin: 0.15rem 0; }
.agent-msg strong { font-weight: 800; }
.agent-msg a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.agent-msg.is-bot, .agent-bubble { justify-self: start; background: var(--tint-2); border: 1px solid var(--line); border-start-start-radius: 6px; }
.agent-msg.is-wide, .call-bubble.is-wide { max-width: 100%; width: 100%; }
.agent-msg.is-user { justify-self: end; background: var(--accent); color: var(--on-accent); border-start-end-radius: 6px; white-space: pre-wrap; }
@keyframes agent-in { from { opacity: 0; transform: translateY(6px); } }

.agent-typing { display: inline-flex; gap: 4px; padding: 0.85rem 1rem; }
.agent-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: agent-dot 1s infinite ease-in-out; }
.agent-typing span:nth-child(2) { animation-delay: .15s; }
.agent-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes agent-dot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* Gate & verify */
.agent-gate { display: grid; gap: 0.7rem; }
.agent-gate[hidden], .agent-verify[hidden], .agent-compose[hidden], .agent-chips[hidden], .agent-foot[hidden] { display: none; }
.agent-gate-lead { margin: 0; font-size: 0.84rem; color: var(--ink-2); line-height: 1.8; }
.agent-gate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.agent-field { display: grid; gap: 0.3rem; font-size: 0.8rem; color: var(--ink-2); }
.agent-field input, .agent-verify input {
  width: 100%; min-height: 44px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--field); color: var(--ink);
  font: inherit; font-size: 16px;
}
.agent-field input:focus, .agent-verify input:focus, .agent-compose textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.agent-error { margin: 0; font-size: 0.82rem; color: var(--bad); }
.agent-error[hidden] { display: none; }
.agent-fine { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.74rem; color: var(--ink-3); }
.agent-fine .ph { width: 14px; height: 14px; flex: none; }

.agent-verify { display: grid; gap: 0.55rem; padding: 0.85rem; border: 1px dashed var(--accent-line); border-radius: var(--r-md); background: var(--accent-soft); }
.agent-verify p { margin: 0; font-size: 0.82rem; line-height: 1.8; color: var(--ink-2); }
.agent-verify-row { display: flex; gap: 0.5rem; }
.agent-verify-row[hidden] { display: none; }
.agent-verify-row input { text-align: center; letter-spacing: 0.3em; }
.agent-verify-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }

/* Compose */
.agent-chips { display: flex; gap: 0.4rem; padding: 0 0.9rem 0.6rem; overflow-x: auto; scrollbar-width: none; }
.agent-chips .agent-chip { flex: none; }
.agent-compose { display: flex; align-items: flex-end; gap: 0.45rem; margin: 0 0.55rem 0.45rem; padding: 0.35rem 0.35rem 0.35rem 0.45rem; border: 1px solid var(--line); border-radius: 24px; background: var(--card); box-shadow: 0 8px 24px rgba(0,0,0,.06); }
.agent-compose textarea {
  flex: 1; resize: none; max-height: 132px; min-height: 44px;
  padding: 0.6rem 0.75rem;
  border: 0; border-radius: 18px;
  background: transparent; color: var(--ink);
  font: inherit; font-size: 16px; line-height: 1.6;
}
.agent-send { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: var(--r-full); background: var(--accent); color: #fff; cursor: pointer; box-shadow: 0 6px 16px rgba(0,0,0,.12); transition: transform var(--t-fast), background-color var(--t-fast); }
.agent-send:hover { background: var(--accent-strong); }
.agent-send:active { transform: scale(.94); }
.agent-send .ph { width: 20px; height: 20px; transform: scaleX(-1); }
.agent-foot { margin: 0; padding: 0 0.9rem 0.6rem; font-size: 0.72rem; color: var(--ink-3); display: flex; gap: 0.3rem; align-items: center; }
.agent-foot .link-btn { font-size: inherit; }

/* Call overlay. The page stays still; only the subtitle area scrolls. */
.agent-call {
  position: fixed; inset: 0; z-index: 80;
  box-sizing: border-box;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: #07080b;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  animation: agent-fade 220ms var(--ease-out) both;
}
.agent-call[hidden] { display: none; }
@keyframes agent-fade { from { opacity: 0; } }
.call-card {
  box-sizing: border-box;
  position: relative;
  width: min(400px, 100%);
  max-height: 100%;
  min-height: 0;
  display: flex; flex-direction: column; align-items: center;
  gap: 0.35rem;
  padding: 1.4rem 1.2rem 1.1rem;
  overflow: hidden;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 28px;
  box-shadow: var(--sh-3);
  text-align: center;
}
.call-top, .call-dock { flex: none; width: 100%; display: flex; flex-direction: column; align-items: center; }
.call-scroll {
  flex: 1 1 auto; min-height: 0; width: 100%;
  overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.call-orb { position: relative; width: 112px; height: 112px; display: grid; place-items: center; margin-bottom: 0.25rem; }
.call-core { position: relative; z-index: 1; width: 92px; height: 92px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: var(--sh-accent); --agent-dot-ring: var(--accent); transform: scale(calc(1 + var(--call-level) * 0.12)); transition: transform 90ms linear; }
.call-core .agent-mark { width: 56px; height: 56px; }
.call-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent-line); opacity: 0; }
.agent-call[data-mode="speak"] .call-ring { animation: call-ring 1.8s var(--ease-out) infinite; }
.agent-call[data-mode="speak"] .call-ring + .call-ring { animation-delay: .9s; }
.agent-call[data-mode="listen"] .call-ring:first-child { opacity: calc(0.25 + var(--call-level)); transform: scale(calc(0.8 + var(--call-level) * 0.35)); transition: transform 90ms linear, opacity 90ms linear; }
.agent-call[data-mode="think"] .call-core { animation: call-think 1.2s ease-in-out infinite; }
.agent-call[data-mode="connect"] .call-ring { animation: call-ring 1.4s var(--ease-out) infinite; }
@keyframes call-ring { from { opacity: .7; transform: scale(.72); } to { opacity: 0; transform: scale(1.12); } }
@keyframes call-think { 50% { transform: scale(.94); opacity: .85; } }
.call-name { font-size: 1.2rem; }
.call-status { font-size: 0.9rem; color: var(--ink-2); min-height: 1.6em; }
.agent-call[data-mode="error"] .call-status { color: var(--bad); }
.call-timer { font-variant-numeric: tabular-nums; font-size: 0.8rem; color: var(--ink-3); }
.call-thread { display: flex; flex-direction: column; gap: 0.45rem; width: 100%; text-align: right; padding: 0.15rem 0 0.35rem; }
.call-bubble {
  max-width: 92%; padding: 0.55rem 0.75rem; border-radius: 16px;
  font-size: 0.9rem; line-height: 1.75; overflow-wrap: anywhere;
}
.call-bubble p { margin: 0; }
.call-bubble p + p, .call-bubble p + ul, .call-bubble ul + p { margin-top: 0.4rem; }
.call-bubble ul { margin: 0.25rem 0; padding-inline-start: 1.15rem; }
.call-bubble li { margin: 0.12rem 0; }
.call-bubble strong { font-weight: 800; }
.call-bubble.is-bot { align-self: flex-start; background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.45); border-start-start-radius: 6px; }
.call-bubble.is-bot a { color: #4ade80; }
.call-bubble.is-user { align-self: flex-end; background: var(--accent); color: #fff; border-start-end-radius: 6px; white-space: pre-wrap; }
.agent-call.is-text .call-orb { width: 64px; height: 64px; opacity: .55; margin-bottom: 0; }
.agent-call.is-text .call-core { width: 46px; height: 46px; }
.agent-call.is-text .call-core .agent-mark { width: 26px; height: 26px; }
.call-heard { margin: 0.25rem 0 0; font-size: 0.84rem; line-height: 1.7; color: var(--ink-3); text-align: right; }
.call-heard:empty { display: none; }
.call-heard::before { content: "در حال شنیدن: "; font-weight: 700; }
.call-compose { width: 100%; display: flex; align-items: flex-end; gap: 0.4rem; margin-top: 0.35rem; padding: 0.25rem; border: 1px solid var(--line-2); border-radius: 22px; background: var(--field); }
.call-compose textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 84px;
  padding: 0.5rem 0.7rem; border: 0; border-radius: 16px;
  background: transparent; color: var(--ink);
  font: inherit; font-size: 16px; line-height: 1.5; text-align: right;
}
.call-compose button { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer; }
.call-compose button .ph { width: 18px; height: 18px; transform: scaleX(-1); }
.call-compose textarea:focus { outline: none; }
.call-actions { display: flex; align-items: center; justify-content: center; gap: 1.1rem; margin-top: 0.4rem; }
.call-btn { width: 56px; height: 56px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 50%; background: var(--tint-2); color: var(--ink); cursor: pointer; transition: transform var(--t-fast), background-color var(--t-fast); }
.call-btn:active { transform: scale(.93); }
.call-btn .ph { width: 24px; height: 24px; }
.call-btn:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; }
.call-hang { width: 66px; height: 66px; background: #dc2626; border-color: transparent; color: #fff; }
.call-hang .ph { width: 28px; height: 28px; }
.call-ico-off, .call-btn[aria-pressed="true"] .call-ico-on { display: none; }
.call-btn[aria-pressed="true"] .call-ico-off { display: grid; }
.call-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.call-hint { margin: 0.45rem 0 0; font-size: 0.74rem; color: var(--ink-3); line-height: 1.6; }
.call-ptt {
  width: min(100%, 280px);
  min-height: 58px;
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  margin-top: 0.2rem;
  border: 0; border-radius: 999px;
  background: #16a34a; color: #fff;
  font: inherit; font-size: 0.95rem; font-weight: 700;
  cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.call-ptt .ph { width: 22px; height: 22px; }
.call-ptt.is-down { background: #dc2626; }
.call-ptt:disabled { opacity: 0.45; cursor: default; }
.call-ptt:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.call-guide-btn {
  height: 40px; padding: 0 0.95rem;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--tint-2); color: var(--ink);
  font: inherit; font-size: 0.82rem; font-weight: 700; cursor: pointer;
}
.call-guide {
  position: absolute; inset: 0; z-index: 3;
  box-sizing: border-box;
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 1.2rem 1.15rem;
  overflow: auto; overscroll-behavior: contain;
  text-align: right;
  background: #101218; color: var(--ink);
}
.call-guide[hidden] { display: none; }
.call-guide b { font-size: 1.05rem; }
.call-guide ol { margin: 0; padding-inline-start: 1.2rem; display: grid; gap: 0.45rem; font-size: 0.92rem; line-height: 1.7; }
.call-guide-ok {
  margin-top: auto;
  height: 46px; border: 0; border-radius: 999px;
  background: var(--accent); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .agent-fab-chat:hover { background: var(--accent-strong); transform: translateY(-2px); }
  .agent-fab-call:hover { color: var(--accent-ink); border-color: var(--accent-line); transform: translateY(-2px); }
  .call-btn:hover { background: var(--tint-3); }
  .call-hang:hover { background: #b91c1c; }
}

@media (max-width: 960px) {
  .agent { --agent-bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); }
  .is-app .agent, body.auth-body .agent { --agent-bottom: calc(var(--tabbar-h) + 12px + env(safe-area-inset-bottom)); }
  .agent-fab { width: 52px; height: 52px; }
  .agent-fab-call { width: 44px; height: 44px; }
}

@media (max-width: 640px) {
  .agent-panel {
    inset: 0; width: 100%; height: 100%;
    height: 100dvh;
    border-radius: 0; border: 0;
    z-index: 60;
    transform: translateY(24px);
  }
  .agent-head { padding-top: calc(0.85rem + env(safe-area-inset-top)); }
  .agent-compose { padding-bottom: calc(0.6rem + env(safe-area-inset-bottom)); }
  .agent.is-open .agent-fabs { visibility: hidden; }
  .agent-gate-grid { grid-template-columns: 1fr; }
  .call-sheet { inset-inline: 12px; width: auto; max-height: calc(100dvh - 96px); overflow: auto; }
  .agent-call { padding: 0; background: #101218; height: 100dvh; max-height: 100dvh; }
  .call-card {
    width: 100%; height: 100%; max-height: 100%;
    border: 0; border-radius: 0; box-shadow: none;
    padding: calc(0.7rem + env(safe-area-inset-top)) 1rem calc(0.65rem + env(safe-area-inset-bottom));
  }
  .call-orb { width: 84px; height: 84px; }
  .call-core { width: 62px; height: 62px; }
  .call-core .agent-mark { width: 36px; height: 36px; }
  .call-name { font-size: 1.05rem; }
  .call-actions { gap: 0.9rem; }
  .call-btn { width: 52px; height: 52px; }
  .call-hang { width: 62px; height: 62px; }
  .call-hint { margin-top: 0.35rem; line-height: 1.5; }
  .call-ptt { min-height: 52px; font-size: 0.9rem; }
  .call-guide { padding-top: calc(1rem + env(safe-area-inset-top)); padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .agent-panel, .agent-nudge, .agent-fab, .agent-msg, .agent-call { transition: none !important; animation: none !important; }
  .agent-call .call-ring, .agent-call .call-core { animation: none !important; }
}
@media print { .agent { display: none !important; } }

/* Rich cards inside bubbles */
.agent-cards-head { margin: 0.6rem 0 0.4rem; font-size: 0.78rem; font-weight: 700; color: var(--ink-2); }
.agent-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.agent-card { display: grid; gap: 0.3rem; padding: 0.5rem; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); text-decoration: none !important; transition: transform var(--t-fast), box-shadow var(--t-fast); }
.agent-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.1); }
.agent-card img, .agent-card-noimg { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 10px; background: #fff; }
.agent-card-title { font-size: 0.78rem; line-height: 1.6; font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.agent-card-price { font-size: 0.86rem; font-weight: 800; color: var(--accent-ink); }
.agent-card-meta { font-size: 0.7rem; color: var(--ink-3); }
.agent-card-btn { margin-top: 0.1rem; padding: 0.35rem 0.5rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.74rem; font-weight: 700; text-align: center; }
.call-bubble .agent-card { background: #171a22; border-color: rgba(255,255,255,.12); color: #fff; }
.call-bubble .agent-card-price { color: #4ade80; }
.call-bubble .agent-cards-head { color: rgba(255,255,255,.7); }
.agent-vcard { display: flex; gap: 0.75rem; align-items: flex-start; margin-top: 0.6rem; padding: 0.8rem; border: 1px solid var(--accent-line); border-radius: 16px; background: linear-gradient(135deg, var(--accent-soft), var(--card)); }
.agent-vcard-photo { flex: none; width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.agent-vcard-body { min-width: 0; display: grid; gap: 0.2rem; }
.agent-vcard-body b { font-size: 1rem; }
.agent-vcard-body > span { font-size: 0.76rem; color: var(--ink-2); }
.agent-vcard-body p { margin: 0.2rem 0 0 !important; font-size: 0.8rem; line-height: 1.7; color: var(--ink-2); }
.agent-vcard-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.agent-vcard-actions a { padding: 0.35rem 0.7rem; border-radius: 999px; border: 1px solid var(--accent-line); background: var(--card); color: var(--accent-ink) !important; font-size: 0.76rem; font-weight: 700; text-decoration: none !important; }
.agent-vcard-actions a:last-child { background: var(--accent); color: #fff !important; border-color: transparent; }
.call-bubble .agent-vcard { background: #171a22; border-color: rgba(34,197,94,.45); }
.call-bubble .agent-vcard-actions a { background: #1f232d; color: #4ade80 !important; border-color: rgba(34,197,94,.4); }
.call-bubble .agent-vcard-body > span, .call-bubble .agent-vcard-body p { color: rgba(255,255,255,.75); }
.agent-msg code, .call-bubble code { font-family: inherit; padding: 0 0.25rem; border-radius: 4px; background: rgba(127,127,127,.15); }
@media (max-width: 360px) { .agent-cards { grid-template-columns: 1fr; } .agent-vcard { flex-direction: column; align-items: center; text-align: center; } .agent-vcard-actions { justify-content: center; } }
