:root {
  /* Functional v4 shell: no template theme is selected here. */
  color-scheme: light;
  --red: #ef4148;
  --red-dark: #d92f38;
  --ink: #17181b;
  --muted: #74777f;
  --bg: #f5f6f8;
  --panel: #fff;
  --line: #e7e8eb;
  --soft: #fff1f2;
  --green: #138a63;
  --shadow: 0 14px 40px rgba(24, 25, 28, .08);
  font-family: "PingFang SC", "Microsoft YaHei", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #fff; color: var(--ink); }
body { height: 100dvh; }
button, textarea, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid rgba(239,65,72,.22); outline-offset: 2px; }
[hidden] { display: none !important; }

.page-shell { width: min(900px, 100%); height: 100dvh; margin: 0 auto; padding: env(safe-area-inset-top) 18px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-rows: 58px auto minmax(0,1fr); background: #fff; }
.topbar { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 12px; border-bottom: 1px solid #f0f0f1; }
.brand { justify-self: start; display: flex; align-items: center; color: inherit; text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 11px; box-shadow: 0 6px 16px rgba(239,65,72,.18); }
.topbar-copy, .dialog-brand div { display: flex; flex-direction: column; line-height: 1.05; }
.topbar-copy { justify-self: center; align-items: center; text-align: center; }
.topbar-copy strong { margin-top: 3px; font-size: 15px; letter-spacing: -.02em; }
.topbar-copy small { color: var(--red); font-size: 9px; font-weight: 800; letter-spacing: .09em; }
.dialog-brand small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.topbar-actions { justify-self: end; min-width: 0; display: flex; align-items: center; gap: 7px; }
.locale-control select { min-height: 34px; max-width: 92px; padding: 0 24px 0 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink); font: inherit; font-size: 11px; cursor: pointer; }
[dir="rtl"] .locale-control select { padding-right: 9px; padding-left: 24px; }
.account-pill { max-width: 210px; min-width: 0; min-height: 42px; padding: 5px 5px 5px 11px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); cursor: pointer; text-align: end; }
.account-pill strong { min-width: 0; overflow: hidden; font-size: 12px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.account-avatar { width: 30px; height: 30px; flex: none; display: block; border: 1px solid rgba(23,24,27,.08); border-radius: 50%; background: #fff; object-fit: cover; }
.account-pill.authorized { border-color: #ccebdc; background: #effaf5; }
.account-pill.authorized strong { color: var(--green); }

.voice-stage { width: min(620px,100%); margin: 0 auto; display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 16px; min-height: 132px; padding: 10px 4px; }
.voice-controls { justify-self: start; display: grid; gap: 7px; }
.presence-center { min-width: 0; display: grid; justify-items: center; gap: 5px; }
.live-presence { display: flex; align-items: center; gap: 9px; }
.avatar-face { position: relative; width: 76px; height: 76px; flex: none; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); transition: transform .2s ease; }
.avatar-face img { width: 100%; height: 100%; display: block; }
.eye-mask { position: absolute; left: 42%; top: 68%; width: 9%; height: 9%; border-radius: 50%; background: transparent; transform: translate(-50%,-50%) scaleY(0); transform-origin: center; }
.talk-mouth { position: absolute; left: 51.5%; top: 77%; width: 15%; height: 8%; border-radius: 50%; background: #111; opacity: 0; transform: translate(-50%,-50%) scaleY(.25); }
body[data-state="speaking"] .avatar-face, body[data-state="thinking"] .avatar-face { transform: translateY(-1px) rotate(-1deg); }
body[data-state="speaking"] .talk-mouth { opacity: 1; }
body[data-state="listening"] .eye-mask, body[data-state="hearing"] .eye-mask { animation: blink 4.8s infinite; }

.level-bars { width: 34px; height: 48px; display: flex; align-items: center; justify-content: center; gap: 3px; }
.level-bars i { width: 4px; height: 30px; border-radius: 999px; background: var(--red); transform: scaleY(.25); transition: transform 70ms linear, opacity .2s ease; opacity: .28; }
.level-bars i:nth-child(2), .level-bars i:nth-child(4) { height: 40px; }
.level-bars i:nth-child(2), .level-bars i:nth-child(4) { transform: scaleY(.45); }
.level-bars i:nth-child(3) { height: 48px; transform: scaleY(.62); }
.level-bars i:nth-child(1), .level-bars i:nth-child(5) { transform: scaleY(.25); }
body:not([data-state="idle"]) .level-bars i { opacity: .92; }
.output-bars { transform: scaleX(-1); }

.status-line { min-height: 18px; max-width: 260px; overflow: hidden; color: var(--muted); font-size: 10px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.conversation-action { justify-self: end; }
.control-button { width: 108px; height: 38px; padding: 0 10px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font-size: 9px; font-weight: 750; text-align: start; }
.control-button:disabled { cursor: not-allowed; opacity: .42; }
.control-icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mic-off-icon, .audio-off-icon { display: none; }
.control-button.muted .mic-on-icon, .control-button.muted .audio-on-icon { display: none; }
.control-button.muted .mic-off-icon, .control-button.muted .audio-off-icon { display: block; }
.start-button { width: 84px; height: 90px; padding: 0; display: grid; place-items: center; align-content: center; gap: 5px; border: 0; border-radius: 24px; background: transparent; color: var(--ink); cursor: pointer; font-size: 9px; font-weight: 800; }
.start-icon, .stop-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 20px; background: var(--red); color: #fff; box-shadow: 0 10px 24px rgba(239,65,72,.28); transition: transform .2s ease, border-radius .2s ease, background .2s ease; }
.start-icon svg, .stop-icon svg { width: 25px; height: 25px; fill: currentColor; }
.stop-icon { display: none; }
.start-button:hover .start-icon, .start-button:hover .stop-icon { transform: translateY(-2px); }
.start-button.active .start-icon { display: none; }
.start-button.active .stop-icon { display: grid; border-radius: 50%; background: var(--ink); box-shadow: 0 10px 24px rgba(20,21,24,.24); }
.start-button .button-label { font-size: 9px; white-space: normal; }
.control-button.muted { border-color: #ffd2d4; background: var(--soft); color: var(--red-dark); }

.transcript-card { min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(0,1fr); grid-template-rows: 42px minmax(0,1fr) auto; overflow: hidden; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); }
.transcript-head { min-width: 0; padding: 0 13px; display: grid; grid-template-columns: minmax(0,1fr) 36px minmax(0,1fr); align-items: center; gap: 6px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.8); }
.transcript-head > .speech-status { grid-column: 3; justify-self: end; max-width: 100%; }
.transcript-head > strong { font-size: 12px; }
.speech-status { min-width: 0; display: flex; gap: 5px; overflow: hidden; }
.speech-status span { padding: 4px 7px; border: 1px solid #ccebdc; border-radius: 999px; background: #effaf5; color: var(--green); font-size: 9px; font-weight: 700; white-space: nowrap; }
.speech-status span.unavailable { border-color: #ffd2d4; background: var(--soft); color: var(--red-dark); }
.transcript { min-width: 0; min-height: 0; padding: 13px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; display: grid; grid-template-columns: minmax(0,1fr); align-content: start; gap: 9px; scroll-behavior: smooth; }
.transcript:empty { place-content: center; }
.transcript:empty::before { content: attr(data-empty-label); color: #b2b4b9; font-size: 11px; text-align: center; }
.caption { min-width: 0; width: fit-content; max-width: 86%; padding: 9px 11px; border-radius: 13px; font-size: 13px; line-height: 1.5; text-align: start; white-space: pre-wrap; overflow-wrap: anywhere; }
.caption.assistant { justify-self: start; border: 1px solid var(--line); border-end-start-radius: 4px; background: #fff; }
.caption.user { justify-self: end; border-end-end-radius: 4px; background: var(--ink); color: #fff; }
.caption.pending { opacity: .68; }
.message-identity { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 7px; white-space: normal; font-size: 10px; }
.message-identity img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.message-identity strong { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.message-identity time { opacity: .7; margin-inline-start: auto; font-size: 9px; }
.message-body { white-space: pre-wrap; }
.message-retract { display: block; margin-inline-start: auto; margin-top: 6px; color: inherit; background: transparent; border: 0; font-size: 10px; text-decoration: underline; }
.caption[data-retracted="true"] { opacity: .6; }
.caption[data-retracted="true"] .message-retract { display: none; }
.task-count { grid-column: 2; justify-self: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 50%; font-size: 12px; font-weight: 700; background: #fff3f3; color: var(--red-dark); }
[hidden] { display: none !important; }
.transcript > .agent-activity { width: min(100%, 680px); overflow-anchor: none; }
.composer-modes, .voice-draft-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.composer-modes { padding: 2px 2px 8px; font-size: 11px; }
.composer-modes label { display: flex; align-items: center; gap: 6px; }
.composer-modes select, .composer-modes button, .voice-draft button { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 6px 8px; color: var(--ink); font-size: 11px; }
.voice-draft { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 8px; font-size: 11px; }
.voice-draft audio, .voice-draft textarea { width: 100%; margin: 8px 0; }
.voice-draft button:disabled { opacity: .45; }
.voice-draft [hidden] { display: none; }
.voice-draft p { margin: 0 0 8px; }
.caption.interrupted::after { content: " · " attr(data-interrupted-label); opacity: .58; font-size: 9px; }

.media-grid { width: min(430px,78vw); display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; margin-top: 7px; }
.media-grid.single { grid-template-columns: 1fr; }
.media-tile { position: relative; min-height: 96px; overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: #eceef1; cursor: pointer; }
.media-tile img, .media-tile video { width: 100%; height: 145px; display: block; object-fit: cover; }
.media-tile audio { width: 100%; margin: 22px 0; }
.media-file { min-height: 92px; padding: 13px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.media-file strong { overflow-wrap: anywhere; font-size: 11px; }
.media-file small { color: var(--muted); font-size: 9px; }
.media-download { position: absolute; inset-inline-end: 7px; bottom: 7px; padding: 5px 7px; border-radius: 8px; background: rgba(0,0,0,.72); color: #fff; text-decoration: none; font-size: 9px; }

.composer { min-width: 0; padding: 8px; border-top: 1px solid var(--line); background: #fff; }
.composer-row { min-width: 0; display: grid; grid-template-columns: 34px minmax(0,1fr) 34px 34px; align-items: end; gap: 7px; }
.composer textarea { min-width: 0; width: 100%; min-height: 34px; max-height: 92px; padding: 8px 4px; resize: none; border: 0; outline: 0; background: transparent; font-size: 13px; line-height: 1.4; }
.composer[data-input-mode="voice"] .composer-row { grid-template-columns: 34px minmax(0,1fr) 34px; }
.input-mode-toggle { font-size: 0 !important; }
.input-mode-toggle::before { content: "🎙"; font-size: 19px; }
.input-mode-toggle[aria-pressed="true"]::before { content: "⌨"; }
.hold-record { min-width: 0; min-height: 34px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none; font-size: 12px; }
.voice-draft:not([data-status="preview"]):not([data-status="transcribing"]):not([data-status="sending"]) > :is(audio, label, textarea, .voice-send-actions) { display: none; }
.icon-button, .send-button { width: 34px; height: 34px; border: 0; border-radius: 10px; cursor: pointer; font-size: 19px; }
.icon-button { background: var(--bg); color: var(--muted); }
.send-button { background: var(--ink); color: #fff; font-weight: 800; }
.attachment-tray { grid-template-columns: repeat(auto-fill,minmax(72px,1fr)); gap: 6px; margin-bottom: 7px; }
.attachment-tray:not([hidden]) { display: grid; }
.attachment-chip { position: relative; min-height: 58px; padding: 7px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 9px; }
.attachment-chip img { width: 100%; height: 58px; object-fit: cover; border-radius: 7px; }
.attachment-chip button { position: absolute; top: 3px; inset-inline-end: 3px; width: 20px; height: 20px; border: 0; border-radius: 50%; background: rgba(0,0,0,.7); color: #fff; cursor: pointer; }

.task-activity-list { max-height: min(270px,40dvh); padding: 0 8px 8px; display: flex; flex-direction: column; gap: 6px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.task-activity-list > details { flex: none; max-height: 170px; overflow: hidden; }
.agent-activity, .task-activity-list > details { margin: 0; border: 1px solid #ffd1d3; border-radius: 12px; background: #fff; color: var(--ink); }
.agent-activity summary, .task-activity-list > details summary { min-height: 36px; padding: 7px 10px; display: grid; grid-template-columns: 10px minmax(0,1fr) auto; align-items: center; gap: 8px; cursor: pointer; list-style: none; }
.agent-activity summary::-webkit-details-marker, .task-activity-list > details summary::-webkit-details-marker { display: none; }
.agent-activity summary strong, .task-activity-list > details summary strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.agent-activity summary small, .task-activity-list > details summary small { color: var(--muted); font-size: 9px; }
.activity-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 0 rgba(239,65,72,.38); }
.agent-activity.running .activity-pulse { animation: activityPulse 1.25s ease-out infinite; }
.agent-activity.completed { border-color: var(--line); }
.agent-activity.completed .activity-pulse { background: var(--green); box-shadow: none; }
.agent-activity.failed .activity-pulse { background: var(--red-dark); box-shadow: none; }
.agent-activity pre, .task-activity-list > details > pre, .task-activity-list > details > code { max-height: 126px; margin: 0; padding: 9px 10px; overflow: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); background: #17181b; color: #f4f5f6; font: 9px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.task-activity-list > details > code { display: block; }

.auth-dialog, .profile-dialog { width: min(430px,calc(100vw - 28px)); padding: 0; border: 0; border-radius: 22px; background: transparent; }
dialog::backdrop { background: rgba(17,18,20,.58); backdrop-filter: blur(8px); }
.dialog-card { position: relative; max-height: min(760px,calc(100dvh - 28px)); padding: 24px; display: grid; gap: 9px; overflow-y: auto; border: 1px solid var(--line); border-radius: 22px; background: #fff; box-shadow: 0 24px 80px rgba(0,0,0,.2); }
.dialog-brand { display: flex; align-items: center; gap: 10px; }
.dialog-brand img { width: 42px; height: 42px; border-radius: 13px; }
.dialog-card h2 { margin: 5px 0 0; font-size: 23px; }
.dialog-card > p { margin: 0 0 5px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.dialog-card label { margin-top: 3px; color: var(--muted); font-size: 10px; }
.dialog-card input { width: 100%; height: 44px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); font-size: 14px; }
.phone-row, .code-row { display: flex; gap: 7px; align-items: center; }
.phone-row > span { display: grid; place-items: center; height: 44px; padding: 0 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); color: var(--muted); }
.code-row button { flex: none; height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; }
.primary-button, .secondary-button, .logout-button, .danger-button { min-height: 45px; margin-top: 5px; border: 0; border-radius: 12px; font-weight: 750; cursor: pointer; }
.primary-button { background: var(--red); color: #fff; }
.secondary-button { padding: 0 10px; border: 1px solid var(--line); background: #fff; }
.logout-button { background: var(--bg); color: var(--ink); }
.danger-button { background: var(--soft); color: var(--red-dark); }
.profile-avatar-control { justify-self: center; display: grid; justify-items: center; gap: 7px; }
.profile-avatar-preview { width: 82px; height: 82px; display: block; border: 3px solid #fff; border-radius: 50%; background: var(--bg); box-shadow: 0 7px 22px rgba(24,25,28,.13); object-fit: cover; }
.avatar-change-button { margin: 0 !important; padding: 6px 10px; border-radius: 999px; background: var(--bg); color: var(--ink) !important; cursor: pointer; font-size: 10px !important; font-weight: 750; }
.profile-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.pwa-hint { margin: -1px 0 2px !important; color: var(--muted) !important; font-size: 10px !important; text-align: center; }
.dialog-close { position: absolute; top: 12px; inset-inline-end: 12px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--bg); cursor: pointer; }
.dialog-status { min-height: 18px; margin: 0 !important; color: var(--red-dark) !important; text-align: center; }

.lightbox { width: min(1000px,100vw); height: min(820px,100dvh); padding: 50px 55px 42px; overflow: hidden; border: 0; background: #0d0e10; color: #fff; }
.lightbox-content { width: 100%; height: 100%; display: grid; place-items: center; }
.lightbox-content img, .lightbox-content video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-content audio { width: min(600px,90%); }
.lightbox-close, .lightbox-nav { position: absolute; z-index: 2; border: 0; background: rgba(255,255,255,.12); color: #fff; cursor: pointer; }
.lightbox-close { top: 12px; inset-inline-end: 12px; width: 36px; height: 36px; border-radius: 50%; font-size: 22px; }
.lightbox-nav { top: 50%; width: 40px; height: 54px; border-radius: 12px; font-size: 30px; transform: translateY(-50%); }
.lightbox-nav.previous { left: 8px; }.lightbox-nav.next { right: 8px; }
[dir="rtl"] .lightbox-nav.previous { left: auto; right: 8px; }
[dir="rtl"] .lightbox-nav.next { right: auto; left: 8px; }
.lightbox-footer { position: absolute; inset-inline: 55px; bottom: 10px; display: flex; justify-content: space-between; gap: 12px; font-size: 11px; }
.lightbox-footer a { color: #fff; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 11px; opacity: 0; transform: translate(-50%,12px); transition: .18s ease; pointer-events: none; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@keyframes mouthTalk { from { transform: translate(-50%,-50%) scaleY(.3); } to { transform: translate(-50%,-50%) scaleY(1.35); } }
@keyframes blink { 0%,44%,48%,100% { background: transparent; transform: translate(-50%,-50%) scaleY(0); } 45%,47% { background: #fff; transform: translate(-50%,-50%) scaleY(1.25); } }
@keyframes activityPulse { 70% { box-shadow: 0 0 0 7px rgba(239,65,72,0); } 100% { box-shadow: 0 0 0 0 rgba(239,65,72,0); } }

@media (max-width: 640px) {
  .page-shell { padding-inline: 10px; grid-template-rows: 52px auto minmax(0,1fr); }
  .topbar { gap: 7px; }
  .topbar-copy strong { font-size: 13px; }
  .topbar-copy small { font-size: 7px; }
  .topbar-actions { gap: 4px; }
  .locale-control select { width: 44px; padding-inline: 5px; font-size: 9px; }
  .account-pill { max-width: 92px; padding: 6px 8px; }
  .account-pill strong { font-size: 10px; }
  .account-pill small { font-size: 8px; }
  .voice-stage { grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 7px; min-height: 116px; padding: 7px 2px; }
  .avatar-face { width: 62px; height: 62px; border-radius: 20px; }
  .level-bars { width: 22px; gap: 2px; }
  .level-bars i { width: 3px; }
  .status-line { max-width: 190px; font-size: 9px; }
  .control-button { width: 88px; height: 36px; padding: 0 7px; gap: 5px; font-size: 8px; }
  .control-icon { width: 16px; height: 16px; }
  .start-button { width: 70px; height: 82px; font-size: 8px; }
  .start-icon, .stop-icon { width: 52px; height: 52px; border-radius: 18px; }
  .speech-status span:nth-child(n+3) { display: none; }
  .caption { max-width: 92%; }
  .lightbox { padding: 45px 38px 38px; }
  .lightbox-footer { inset-inline: 38px; }
}

@media (max-height: 650px) {
  .page-shell { grid-template-rows: 46px auto minmax(0,1fr); }
  .brand img { width: 29px; height: 29px; }
  .voice-stage { min-height: 100px; padding: 5px 2px; }
  .avatar-face { width: 52px; height: 52px; border-radius: 17px; }
  .level-bars { height: 40px; }
  .start-button { height: 70px; }
  .start-icon, .stop-icon { width: 46px; height: 46px; }
}

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

/* iOS focus zoom is triggered by small form text. Keep pinch zoom available. */
@media (any-pointer: coarse), (max-width: 760px) {
  input, textarea, select, [contenteditable="true"] {
    font-size: 16px !important;
  }
  .locale-control select { min-width: 56px; }
}

/* Production app shell, separate from the five demo-only templates. */
body { background: #f7f7f5; }
.page-shell { width: min(1120px,100%); padding-inline: 24px; grid-template-rows: 72px 124px minmax(0,1fr); background: #fff; }
.topbar { display: flex; gap: 12px; }
.brand img { width: 40px; height: 40px; box-shadow: none; }
.topbar-copy { align-items: start; text-align: start; gap: 5px; flex: 1; }
.topbar-copy strong { font-size: 19px; }
.topbar-copy small { font-size: 12px; color: #666971; }
.topbar-actions { margin-inline-start: auto; display: flex; gap: 8px; }
.nav-button, .locale-control select, .account-pill { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 8px 12px; font-size: 14px; color: var(--ink); }
.account-pill { max-width: 220px; }
.account-pill strong { font-size: 14px; }
.account-avatar { width: 30px; height: 30px; }
.nav-button[data-unread]:not([data-unread="0"]) { background: var(--soft); border-color: #f2b8bb; color: #a92028; }
.owner-badge { color: #a92028; border: 1px solid #f2b8bb; border-radius: 8px; padding: 5px 8px; font-size: 12px; }
.voice-stage { min-height: 0; padding: 8px 4px; }
.control-button { width: 160px; min-height: 44px; height: auto; font-size: 13px; }
.status-line { max-width: 360px; font-size: 12px; min-height: 20px; }
.avatar-face { width: 62px; height: 62px; }
.start-button { width: 100px; height: 96px; }
.start-button .button-label { font-size: 12px; }
.transcript-card { grid-template-rows: 48px auto minmax(0,1fr) auto; background: #fafaf9; border-radius: 18px; box-shadow: none; }
.transcript-head { padding-inline: 18px; }
.transcript-head > strong { font-size: 15px; }
.speech-status span { font-size: 11px; border-color: var(--line); background: #fff; color: #555960; }
.speech-status span:nth-child(n+3) { display: none; }
.history-toolbar { display: flex; justify-content: center; background: #fafaf9; }
.history-toolbar button { min-height: 44px; padding: 8px 16px; border: 0; background: transparent; color: #62666e; font-size: 13px; cursor: pointer; }
.history-toolbar:has(button[hidden]) { display: none; }
.transcript { padding: 20px; gap: 16px; scroll-behavior: auto; overflow-anchor: none; scrollbar-gutter: stable; }
.caption { max-width: 85%; padding: 14px 16px; font-size: 16px; line-height: 1.55; }
.caption.user { color: var(--ink); background: #fff0f1; border: 1px solid #f7d8da; }
.caption.assistant { border-color: #e8e8e5; }
.message-identity { font-size: 12px; }
.message-identity time { font-size: 11px; }
.message-retract { min-width: 44px; min-height: 44px; font-size: 12px; margin-top: 0; padding: 4px 0; color: #686b72; }
.composer { padding: 12px; }
.composer-row { grid-template-columns: 44px minmax(0,1fr) 44px 44px; gap: 8px; }
.composer[data-input-mode="voice"] .composer-row { grid-template-columns: 44px minmax(0,1fr) 44px; }
.composer textarea { min-height: 44px; font-size: 16px; padding: 10px 8px; }
.icon-button, .send-button { width: 44px; height: 44px; border-radius: 13px; }
.send-button { background: var(--red); }
.send-button:hover { background: var(--red-dark); }
.hold-record { min-height: 44px; font-size: 16px; }
.composer-modes { justify-content: space-between; padding-bottom: 8px; }
.composer-modes select, .composer-modes button, .voice-draft button { min-height: 44px; font-size: 14px; }
.composer-modes label { font-size: 12px; }
.task-count { min-width: 44px; min-height: 44px; }
.agent-activity summary { min-height: 44px; }
.agent-activity summary strong { font-size: 13px; }
.agent-activity pre { font-size: 12px; }
.media-file strong { font-size: 14px; }
.media-file small { font-size: 12px; }
.media-download { min-height: 44px; display: grid; place-items: center; font-size: 13px; padding: 8px; }
.media-tile { min-height: 118px; }
.attachment-chip button { width: 44px; height: 44px; }
.profile-dialog { width: min(600px,calc(100vw - 24px)); }
.utility-dialog { width: min(600px,calc(100vw - 24px)); padding: 0; border: 0; border-radius: 22px; background: transparent; }
.dialog-card { max-height: calc(100dvh - 24px); gap: 12px; padding: 26px; }
.dialog-card label, .dialog-card > p, .pwa-hint { font-size: 14px !important; }
.dialog-card input, .dialog-card select, .dialog-card textarea { width: 100%; min-height: 44px; padding: 10px 12px; font-size: 16px; font-family: inherit; border: 1px solid var(--line); border-radius: 10px; background: #fafaf9; }
.dialog-card textarea { resize: vertical; }
.dialog-card button, .dialog-card summary, .avatar-change-button { min-height: 44px; font-size: 16px !important; }
.dialog-close { width: 44px; height: 44px; top: 10px; }
.profile-section { min-width: 0; margin: 8px 0 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; display: grid; gap: 10px; }
.profile-section legend { font-weight: 700; font-size: 17px; padding-inline: 6px; }
.profile-section p { margin: 0; color: #666971; line-height: 1.5; font-size: 14px; }
.profile-section summary { cursor: pointer; display: flex; align-items: center; }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: 24px; height: 24px; min-height: 24px; accent-color: var(--red-dark); flex: none; }
#inboxList { display: grid; gap: 12px; }
#inboxList article { border: 1px solid var(--line); border-radius: 12px; padding: 16px; font-size: 15px; overflow-wrap: anywhere; }
#inboxList article[data-unread="true"] { border-inline-start: 4px solid var(--red); }
#inboxList button { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
#inboxList p { white-space: pre-wrap; line-height: 1.5; }
.toast { position: fixed; inset: 16px auto auto 50%; margin: 0; width: max-content; max-width: min(560px,calc(100vw - 32px)); padding: 14px 18px; border: 1px solid #34373c; border-radius: 12px; font-size: 15px; line-height: 1.45; box-shadow: 0 8px 28px #0003; transform: translateX(-50%); }
.toast.show { transform: translateX(-50%); }
.toast[data-kind="error"] { background: #86252c; border-color: #86252c; }
.toast[data-kind="success"] { background: var(--ink); }
.toast::backdrop { background: transparent; }
select:focus-visible { outline: 3px solid #ef414866; outline-offset: 2px; }
@media (max-width: 700px) {
 .page-shell { padding-inline: 10px; grid-template-rows: 64px 124px minmax(0,1fr); }
 .topbar { gap: 8px; }
 .brand img { width: 32px; height: 32px; }
 .topbar-copy strong { font-size: 16px; }
 .topbar-copy small { display: none; }
 .topbar-actions { gap: 5px; }
 .nav-button { padding: 6px 8px; font-size: 12px; max-width: 106px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
 .account-pill { padding: 6px; min-width: 44px; }
 .account-pill strong { display: none; }
 .owner-badge { position: absolute; top: 51px; inset-inline-start: 12px; font-size: 10px; padding: 2px 5px; z-index: 1; }
 .locale-control select { width: 66px; padding-inline: 6px; }
 .voice-stage { grid-template-columns: 100px minmax(0,1fr) 66px; gap: 4px; }
 .control-button { width: 100px; font-size: 11px; padding-inline: 6px; gap: 5px; }
 .control-icon { width: 16px; height: 16px; }
 .start-button { width: 66px; height: 100px; }
 .start-button .button-label { font-size: 11px; }
 .start-icon, .stop-icon { width: 48px; height: 48px; }
 .avatar-face { width: 48px; height: 48px; border-radius: 16px; }
 .level-bars { width: 18px; }
 .status-line { max-width: 145px; font-size: 11px; }
 .transcript-head { padding-inline: 12px; grid-template-columns: minmax(0,1fr) 44px auto; }
 .speech-status span:not(:first-child) { display: none; }
 .transcript { padding: 12px; gap: 12px; }
 .caption { max-width: 94%; padding: 10px 12px; }
 .message-identity time { width: 100%; margin: 0; }
 .composer { padding: 8px; }
 .composer-row { gap: 5px; }
 .composer-modes { gap: 4px; }
 .composer-modes label > span { display: none; }
 .composer-modes select { max-width: 190px; }
 .composer-modes button { font-size: 13px; }
 .dialog-card { padding: 20px 16px; }
 .profile-section { padding: 12px; }
 .profile-actions { grid-template-columns: 1fr; }
 .lightbox-close, .lightbox-nav { min-width: 44px; min-height: 44px; }
}
@media (max-height: 640px) {
 .page-shell { grid-template-rows: 56px 100px minmax(0,1fr); }
 .presence-center .status-line { max-width: 240px; }
}
@media (prefers-reduced-motion: reduce) { .transcript { scroll-behavior: auto; } }


/* Keep explicit grid slots when the optional history toolbar is hidden. */
.transcript-card > .transcript-head { grid-row: 1; }
.transcript-card > .history-toolbar { grid-row: 2; }
.transcript-card > .transcript { grid-row: 3; min-height: 0; }
.transcript-card > .composer { grid-row: 4; }

/* Call state is shown on the persistent header action. */
#statusLine,.speech-status{display:none!important}
.auth-language{display:flex!important;align-items:center;gap:12px;justify-content:space-between;margin:16px 0}
.auth-language select{width:auto!important;max-width:65%;font-size:16px!important;border:1px solid var(--line);border-radius:12px;padding:8px;background:white}
#conversationToggle[data-call-state="ready"]{background:#e6f5ed;color:#347e57;border-color:#c6e6d2}
#conversationToggle[data-call-state="error"]{background:#ffe6ee;color:#ba456d;border-color:#efb7c9}
#conversationToggle[data-call-state="connected"]{background:#dcf6e8;color:#28734d;border-color:#ace0c2;box-shadow:0 0 0 calc(2px + var(--call-level,0)*15px) rgb(88 185 133 / 18%),0 0 0 calc(5px + var(--call-level,0)*25px) rgb(88 185 133 / 9%)}
#conversationToggle[data-call-state="ringing"],#conversationToggle[data-call-state="reconnecting"]{animation:call-pending 1.2s ease-in-out infinite;background:#fff1de;color:#99692c}
@keyframes call-pending{50%{box-shadow:0 0 0 5px rgb(224 168 82 / 16%);transform:rotate(-8deg)}}
@media(prefers-reduced-motion:reduce){#conversationToggle{animation:none!important;transform:none!important}}

.composer-quote{display:flex;gap:10px;align-items:center;border-inline-start:3px solid #ca6377;background:#faf0f3;border-radius:10px;padding:8px 12px;font-size:12px;margin:4px 0}.composer-quote span{flex:1;max-height:3em;overflow:hidden;white-space:pre-wrap}.composer-quote button{border:0;background:none;font-size:22px}

.model-controls{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin:0 0 7px}.model-controls select,.model-controls button{height:30px;max-width:180px;min-width:0;border:1px solid #e9dfe2;border-radius:10px;background:#faf7f8;color:#57464c;padding:3px 9px;font-size:12px;font-family:inherit}.model-controls button[aria-pressed=true]{background:#f7e2e9;color:#a84461;border-color:#e7b3c4}.geo-credit{display:block;text-align:center;margin-top:10px;font-size:10px}.geo-credit a{color:#8d8185}@media(max-width:480px){.model-controls select{max-width:155px;font-size:16px;transform-origin:left center}.model-controls{gap:4px}}

.message-quote{margin:6px 0;padding:7px 10px;border-inline-start:3px solid #cc8fa5;background:#f7f0f3;border-radius:7px;font-size:12px;color:#7b6270;max-height:7em;overflow:auto;white-space:pre-wrap}
