/* ============================================================
 * Golova Widget — refined business style
 * Warm ivory canvas, deep ink, restrained typography.
 * ============================================================ */

:root {
  /* Surfaces — clean white canvas to match avatar's studio backdrop */
  --bg:           #FFFFFF;          /* primary canvas */
  --bg-stage:     #EEF1FF;          /* surrounding stage (around phone) */
  --surface:      #FFFFFF;          /* hero/cards */
  --surface-2:    #F8F9FF;          /* secondary surface (sheets) */
  --surface-3:    #F0F2FF;          /* hovered surface */

  /* Type */
  --ink:          #161A2D;          /* primary text */
  --ink-soft:     #262B40;          /* hovers / strong body */
  --ink-mute:     #6D7391;          /* secondary text */
  --ink-dim:      #98A0BE;          /* tertiary text */

  /* Accent */
  --accent:       #1F2937;          /* deep graphite — primary action */
  --accent-2:     #0E1116;          /* hover */
  --accent-warm:  #B7855A;          /* warm clay — subtle highlights only */

  /* States */
  --positive:     #2E7D5B;
  --negative:     #B53D2E;

  /* Hairlines */
  --rule:         rgba(20, 22, 29, 0.08);
  --rule-strong:  rgba(20, 22, 29, 0.16);

  /* Legacy compat (consumed elsewhere) */
  --screen-bg:    var(--bg);
  --sheet-bg:     var(--surface-2);
  --chip-bg:      var(--accent);
  --chip-border-color: var(--accent);
  --chip-voice-border-color: var(--rule-strong);
  --chip-chat-border-color: var(--accent);
  --chip-text:    #FFFFFF;
  --input-border: var(--rule-strong);
  --accent-secondary: var(--accent-warm);

  /* Typography */
  --font-display: "Fraunces", "Georgia", "Times New Roman", serif;
  --font-body:    "Instrument Sans", -apple-system, "SF Pro Text", system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;

  /* Radius — keep restrained */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button {
  cursor: pointer;
  font-family: inherit;
  transition: transform 200ms cubic-bezier(.2,.8,.2,1),
              background 180ms ease,
              color 180ms ease,
              border-color 180ms ease,
              box-shadow 180ms ease;
}

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

/* ===== Loading State ===== */

.loading-state {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.loading-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--rule-strong);
  border-top-color: var(--ink);
  animation: spin 0.9s linear infinite;
}

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

/* ===== Error State ===== */

.error-state {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
  padding: 28px;
}

.error-state-content {
  text-align: center;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 28px 24px 30px;
  box-shadow: 0 1px 2px rgba(20, 22, 29, 0.04), 0 8px 24px rgba(20, 22, 29, 0.04);
}

.error-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(181, 61, 46, 0.10);
  color: var(--negative);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  margin-bottom: 14px;
}

.error-state-content p {
  font-size: 14.5px;
  color: var(--ink-mute);
  line-height: 1.55;
  margin: 0;
}

/* ===== Stage & Phone ===== */

.stage {
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 24px 0;
  background: var(--bg-stage);
}

.phone {
  position: relative;
  width: 375px;
  height: 760px;
  background: var(--bg);
  border-radius: 0;
  overflow: hidden;
  transform-origin: top center;
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
}

.phone.iframe-mode {
  width: 100vw;
  height: 100dvh;
  transform: none !important;
  border: none;
}

.phone.iframe-mode .stage { background: var(--bg); }

.screen { position: absolute; inset: 0; }
.screen.is-active { background: transparent; }

#screen-home.is-active {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 98px 16px 14px;
}

.phone:not(.iframe-mode) #screen-home.is-active { padding-bottom: 14px; }

#screen-home.is-active .hero {
  flex: 0 0 auto;
  height: 336px;
  min-height: 336px;
  width: 100%;
  max-width: 100%;
}

/* ===== Shared Widget Header ===== */

.widget-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(255,255,255,0.92) 72%, rgba(255,255,255,0) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.widget-head-row {
  position: relative;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.widget-head-row h1 {
  margin: 0;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 96;
  font-weight: 460;
  font-size: 22px;
  letter-spacing: -0.012em;
  color: var(--ink);
  text-align: center;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.mode-tab {
  min-height: 42px;
  padding: 0 10px;
  border-radius: 12px;
  border: 1px solid var(--rule);
  background: rgba(255,255,255,0.88);
  color: var(--ink-mute);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 10px rgba(20,22,29,0.04);
}

.mode-tab:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--rule-strong);
  background: #fff;
}

.mode-tab.is-active {
  background: linear-gradient(180deg, #1F2532 0%, #14161D 100%);
  color: #fff;
  border-color: #0D0F14;
  box-shadow: 0 8px 18px rgba(20,22,29,0.16);
}

.mode-tab.is-live {
  background: linear-gradient(180deg, #C8493A 0%, #A33223 100%);
  border-color: #8A2A1D;
  color: #fff;
}

.mode-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.mode-tab-icon svg { display: block; }

/* ===== Legacy Top Header ===== */

.top {
  position: relative;
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.top h1 {
  margin: 0;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 96;
  font-weight: 460;
  font-size: 24px;
  letter-spacing: -0.012em;
  color: var(--ink);
  text-align: center;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-chat {
  height: 64px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rule);
}

.top-chat h2 {
  margin: 0;
  font-family: var(--font-display);
  font-variation-settings: "opsz" 72;
  font-weight: 460;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.back {
  position: absolute;
  left: 12px;
  top: 50%;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  padding: 0;
  transform: translateY(-50%);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-mute);
}

.back:hover { background: var(--surface-3); color: var(--ink); }

.back span {
  display: block;
  width: 9px;
  height: 9px;
  border-left: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  margin: 0 0 0 4px;
}

.top-chat .back { left: 12px; }

/* ===== Hero / Avatar ===== */

.hero {
  position: relative;
  width: 100%;
  height: 388px;
  margin: 0 auto;
  background: transparent;
  flex-shrink: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-lg);
  isolation: isolate;
}


.avatar-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  position: absolute;
  inset: 0;
  background: transparent;
  visibility: hidden;
  z-index: 1;
  border-radius: var(--r-lg);
}

.avatar-video.ready { visibility: visible; }
.avatar-video.hidden { opacity: 0; pointer-events: none; }

/* ===== Action Buttons ===== */

.switcher {
  display: none !important;
}

.mic-level-bar {
  width: 100%;
  height: 3px;
  background: var(--rule);
  border-radius: 999px;
  margin-top: 10px;
  flex-shrink: 0;
  overflow: hidden;
}

.mic-level-fill {
  height: 100%;
  width: 0%;
  background: var(--ink);
  border-radius: 999px;
  transition: width 50ms linear, background 200ms ease;
}

.chip {
  position: relative;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 550;
  letter-spacing: -0.003em;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  isolation: isolate;
  transition:
    transform 240ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 240ms cubic-bezier(0.16, 1, 0.3, 1),
    background 200ms ease,
    border-color 200ms ease,
    color 200ms ease;
  -webkit-tap-highlight-color: transparent;
}

.chip:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.chip:disabled,
.chip.chip-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.chip-content {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: currentColor;
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.chip-icon svg { display: block; width: 100%; height: 100%; }
.chip-icon-voice { width: 14px; height: 18px; }
.chip-icon-chat  { width: 17px; height: 16px; }

/* ==== Voice = secondary (refined ghost) ==== */
.chip-voice {
  background: var(--surface);
  color: var(--ink);
  border-color: rgba(20, 22, 29, 0.14);
  box-shadow:
    0 1px 1px rgba(20, 22, 29, 0.025),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.chip-voice:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: rgba(20, 22, 29, 0.28);
  transform: translateY(-1px);
  box-shadow:
    0 4px 12px -4px rgba(20, 22, 29, 0.10),
    0 1px 2px rgba(20, 22, 29, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.chip-voice:hover:not(:disabled) .chip-icon {
  transform: scale(1.06);
}

.chip-voice:active:not(:disabled) {
  transform: translateY(0);
  box-shadow:
    0 1px 1px rgba(20, 22, 29, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* ==== Chat = primary (filled, with dimensional depth) ==== */
.chip-chat {
  background: linear-gradient(180deg, #1F2532 0%, #14161D 100%);
  color: #FFFFFF;
  border-color: #0D0F14;
  box-shadow:
    0 1px 2px rgba(20, 22, 29, 0.18),
    0 4px 10px -2px rgba(20, 22, 29, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.20);
}

.chip-chat::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 50%);
  opacity: 0;
  transition: opacity 240ms ease;
  pointer-events: none;
  z-index: 0;
}

.chip-chat .chip-content { position: relative; z-index: 1; }

.chip-chat:hover:not(:disabled) {
  background: linear-gradient(180deg, #262C3A 0%, #181B24 100%);
  transform: translateY(-1px);
  box-shadow:
    0 2px 4px rgba(20, 22, 29, 0.22),
    0 8px 20px -4px rgba(20, 22, 29, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.20);
}

.chip-chat:hover:not(:disabled)::before { opacity: 1; }
.chip-chat:hover:not(:disabled) .chip-icon { transform: scale(1.06); }

.chip-chat:active:not(:disabled) {
  transform: translateY(0);
  box-shadow:
    0 1px 1px rgba(20, 22, 29, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 -1px 0 rgba(0, 0, 0, 0.20);
}

/* ==== Live state (active voice call) ==== */
.chip-live {
  background: linear-gradient(180deg, #C8493A 0%, #A33223 100%) !important;
  border-color: #8A2A1D !important;
  color: #FFFFFF !important;
  box-shadow:
    0 1px 2px rgba(165, 50, 35, 0.30),
    0 4px 14px -2px rgba(165, 50, 35, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18) !important;
}

.chip-live .chip-icon-voice {
  animation: mic-pulse 1.4s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.15); opacity: 0.85; }
}

.chip-soon {
  font-size: 11px;
  margin-left: 6px;
  opacity: 0.55;
  letter-spacing: 0.02em;
}

/* ===== Composer ===== */

.composer {
  position: absolute;
  left: 20px;
  width: calc(100% - 40px);
  height: 48px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  display: flex;
  align-items: center;
  padding: 4px 4px 4px 6px;
  gap: 6px;
  box-shadow: 0 1px 2px rgba(20, 22, 29, 0.03);
}

.composer:focus-within { border-color: var(--ink); }

.composer-home { top: 506px; display: none; }
.composer-chat { bottom: 18px; }

.phone.iframe-mode .composer {
  left: 16px;
  width: calc(100% - 32px);
}

.composer input {
  border: 0;
  outline: none;
  flex: 1;
  padding: 0 12px;
  font-family: var(--font-body);
  font-size: 15px;
  background: transparent;
  color: var(--ink);
}

.composer input::placeholder { color: var(--ink-dim); }

.mini {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  font-size: 15px;
  color: var(--ink-mute);
}

.send {
  width: 44px;
  height: 38px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: #FFFFFF;
  font-size: 16px;
  display: grid;
  place-items: center;
}

.send:hover:not(:disabled) { background: var(--accent-2); }
.send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Bottom Sheet / Suggestions ===== */

.bottom-sheet {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  background: var(--surface-2);
  border-top: 1px solid var(--rule);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 12px 14px 14px;
  overflow-y: auto;
  margin-top: 8px;
}

.phone.iframe-mode .bottom-sheet {
  width: 100%;
  padding: 14px 16px 14px;
}

.grabber {
  width: 36px;
  height: 3px;
  border-radius: 999px;
  background: var(--rule-strong);
  margin: 0 auto 14px;
}

.suggestion {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  min-height: 36px;
  margin: 0 auto 8px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 13.5px;
  letter-spacing: 0.005em;
  padding: 8px 14px;
  text-align: left;
  position: relative;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.suggestion:hover {
  background: var(--surface-3);
  border-color: var(--rule-strong);
  color: var(--ink);
}

/* ===== Chat Canvas ===== */

.chat-canvas {
  position: absolute;
  inset: 102px 16px 82px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
}

.chat-canvas::-webkit-scrollbar { width: 6px; }
.chat-canvas::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  border-radius: 999px;
}

/* ===== Message Bubbles ===== */

.message-wrapper { margin-bottom: 12px; }

.message-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message-assistant {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.bubble {
  border-radius: var(--r-lg);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.55;
  max-inline-size: min(82%, 44ch);
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  text-wrap: pretty;
  hyphens: auto;
  letter-spacing: 0.003em;
}

.message-user .bubble-out {
  max-inline-size: min(78%, 38ch);
  background: var(--accent);
  color: #FFFFFF;
}

.message-assistant .bubble-in {
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-size: 14.5px;
  letter-spacing: 0.005em;
  max-inline-size: min(84%, 46ch);
  white-space: normal;
}

.assistant-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.assistant-paragraph { margin: 0; }

.assistant-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.assistant-list li { margin: 0; }

.bubble-out { background: var(--accent); color: #FFFFFF; }
.bubble-in  { background: var(--surface); color: var(--ink); }

/* ===== Source Citation ===== */

.source-citation {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-dim);
  line-height: 1.4;
  padding-left: 4px;
  letter-spacing: 0.005em;
}

/* ===== Typing Indicator ===== */

.typing-indicator {
  position: absolute;
  left: 18px;
  bottom: 76px;
  display: flex;
  gap: 5px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  width: fit-content;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-dim);
  animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* ===== Feedback Buttons ===== */

.feedback-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-left: 4px;
}

.feedback-btn {
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink-mute);
  cursor: pointer;
  line-height: 1;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.feedback-btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--ink-mute);
  color: var(--ink);
}

.feedback-btn.feedback-active {
  border-color: var(--accent);
  background: rgba(31, 41, 55, 0.06);
  color: var(--ink);
}

.feedback-btn.feedback-disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* ===== Feedback Comment Form ===== */

.feedback-comment-form {
  width: 100%;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feedback-textarea {
  width: 100%;
  max-width: 280px;
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 13.5px;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
  outline: none;
  transition: border-color 180ms ease;
}

.feedback-textarea:focus { border-color: var(--ink); }

.feedback-error {
  font-size: 11.5px;
  color: var(--negative);
  min-height: 14px;
}

.feedback-submit-btn {
  align-self: flex-start;
  padding: 7px 16px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: #FFFFFF;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.feedback-submit-btn:hover { background: var(--accent-2); }

.feedback-confirm {
  font-size: 12px;
  color: var(--positive);
  margin-left: 6px;
}

/* ===== Debug Panel ===== */

.debug-panel { display: none; }
.debug-panel.active {
  display: block;
  background: rgba(31, 41, 55, 0.06);
  border-top: 1px solid var(--rule);
  padding: 6px 12px;
}
.debug-panel p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 1.3;
  text-align: center;
  color: var(--ink-mute);
}

/* ===== Iframe / Embed Mode ===== */

.phone.iframe-mode .debug-panel { display: none !important; }

.phone.iframe-mode #screen-home {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow-y: auto;
  background: var(--bg);
  padding: 92px 16px 12px;
}

.phone.iframe-mode .top { display: none; }

.phone.iframe-mode .hero {
  width: 100%;
  max-width: 100%;
  height: auto;
  flex: 0 0 auto;
  min-height: 160px;
  margin: 0;
}

.phone.iframe-mode .switcher { display: none !important; }

.phone.iframe-mode .composer-home { display: none !important; }

.phone.iframe-mode .bottom-sheet {
  width: 100%;
  min-height: 40px;
  flex: 0 0 auto;
  padding: 12px 14px;
}

.phone.iframe-mode .suggestion {
  width: 100%;
  max-width: 100%;
  font-size: 13px;
  min-height: 32px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 7px 14px;
}

.phone.iframe-mode .chat-canvas {
  position: absolute;
  inset: 102px 16px 70px;
}

.phone.iframe-mode .composer-chat {
  bottom: 14px;
  width: calc(100% - 32px);
}

/* Mobile avatar scale */
@media (max-width: 768px) {
  .hero {
    transform: scale(var(--mobile-avatar-scale, 1));
    transform-origin: center top;
  }

  .message-assistant .bubble-in {
    max-inline-size: min(92%, 40ch);
    font-size: 14.5px;
  }
}

.phone.iframe-mode .back { display: none; }

.phone.iframe-mode .widget-head {
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.05s !important;
  }
}
.locale-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  min-width: 66px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 18px rgba(20, 22, 29, 0.06);
}

.locale-toggle:hover {
  background: #fff;
  color: var(--ink);
}

.manager-canvas {
  display: flex;
  align-items: center;
  justify-content: center;
}

.manager-empty-state {
  width: 100%;
  max-width: 260px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: rgba(255,255,255,0.92);
  padding: 22px 18px;
  text-align: center;
}

.manager-empty-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--ink);
  margin-bottom: 8px;
}

.manager-empty-copy {
  font-size: 13px;
  color: var(--ink-mute);
  line-height: 1.5;
}

.composer-disabled {
  opacity: 0.72;
}

/* ===== Compact 2026 Widget Refresh ===== */

:root {
  --bg-stage: #EEF1FF;
  --surface-2: #F8F9FF;
  --surface-3: #F0F2FF;
  --ink: #161A2D;
  --ink-soft: #262B40;
  --ink-mute: #6D7391;
  --ink-dim: #98A0BE;
  --accent: #5A49F8;
  --accent-2: #7A2BFF;
  --accent-warm: #9F66FF;
  --positive: #29B36B;
  --negative: #D45252;
  --rule: rgba(69, 79, 126, 0.12);
  --rule-strong: rgba(69, 79, 126, 0.22);
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
}

.phone {
  width: 390px;
  height: 540px;
  border-radius: 28px;
  box-shadow: 0 24px 70px rgba(58, 66, 126, 0.16);
}

#screen-home.is-active {
  padding: 78px 12px 6px;
}

.phone:not(.iframe-mode) #screen-home.is-active {
  padding-bottom: 6px;
}

.widget-head {
  gap: 10px;
  padding: 10px 12px 8px;
  background: linear-gradient(135deg, #4D77FF 0%, #6B47FF 42%, #A11BFF 100%);
  box-shadow: 0 10px 34px rgba(80, 72, 255, 0.26);
}

.widget-head-row h1 {
  color: #FFFFFF;
  font-size: 16px;
  letter-spacing: -0.01em;
  max-width: 200px;
}

.widget-controls {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.widget-control {
  position: relative;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.widget-control:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.28);
}

.widget-control.is-active {
  background: rgba(255, 255, 255, 0.28);
}

.widget-control-compact {
  display: none !important;
}

.widget-control span {
  position: absolute;
  inset: 0;
  display: block;
}

.widget-control span::before,
.widget-control span::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: currentColor;
}

.widget-control span::before {
  width: 10px;
  height: 1.7px;
  border-radius: 999px;
}

.widget-control-compact span::before {
  width: 11px;
  height: 8px;
  background: transparent;
  border: 1.6px solid currentColor;
  border-radius: 3px;
}

.widget-control-close span::before,
.widget-control-close span::after {
  width: 11px;
  height: 1.7px;
  border-radius: 999px;
}

.widget-control-close span::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.widget-control-close span::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.mode-switcher {
  gap: 8px;
}

.mode-tab {
  min-height: 38px;
  border-radius: 14px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.mode-tab:hover:not(:disabled) {
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.22);
}

.mode-tab.is-active {
  background: #FFFFFF;
  color: #3156F7;
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 24px rgba(35, 22, 111, 0.16);
}

.mode-tab.is-live {
  background: linear-gradient(180deg, #FF7D6A 0%, #FF5B76 100%);
  border-color: rgba(255, 255, 255, 0.32);
}

.hero {
  height: 336px;
}

.composer {
  left: 14px;
  width: calc(100% - 28px);
  height: 52px;
  border-radius: 18px;
  padding: 5px 5px 5px 8px;
  gap: 8px;
  box-shadow: 0 10px 28px rgba(52, 60, 103, 0.08);
}

.composer-home {
  top: 446px;
}

.composer-chat {
  bottom: 14px;
}

.send {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
}

.send:hover:not(:disabled) {
  background: linear-gradient(135deg, #6658FF 0%, #8C3BFF 100%);
}

.bottom-sheet {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(118, 125, 177, 0.16);
  border-radius: 18px;
  padding: 10px 10px 12px;
  margin-top: 2px;
  box-shadow: 0 -2px 0 rgba(255, 255, 255, 0.22), 0 12px 32px rgba(52, 60, 103, 0.08);
}

.grabber {
  width: 34px;
  height: 4px;
  margin: 0 auto 10px;
}

.suggestion {
  max-width: none;
  min-height: 42px;
  border-radius: 14px;
  font-size: 13px;
  letter-spacing: 0;
  padding: 10px 14px;
}

.chat-canvas {
  inset: 108px 14px 76px;
}

.bubble {
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.5;
}

.typing-indicator {
  left: 14px;
  bottom: 72px;
}

.phone.iframe-mode #screen-home {
  position: absolute;
  inset: 0;
  overflow: hidden;
  padding: 0;
}

.phone.iframe-mode .hero {
  position: absolute;
  left: 0;
  right: 0;
  top: 118px;
  bottom: 0;
  width: auto;
  max-width: none;
  height: auto;
  min-height: 0;
  margin: 0;
}

.phone.iframe-mode .avatar-video {
  object-position: 50% top;
  transform: none;
}

.phone.iframe-mode .bottom-sheet {
  padding: 10px;
}

.phone.iframe-mode .chat-canvas {
  inset: 108px 14px 74px;
}

.phone.iframe-mode .composer-chat {
  width: calc(100% - 28px);
}

.phone.iframe-mode .widget-head {
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.locale-toggle {
  display: none !important;
}

.manager-canvas {
  padding: 18px;
}

.manager-empty-state {
  max-width: 250px;
  border-radius: 18px;
}

.manager-empty-title {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.manager-empty-copy {
  font-size: 13px;
}

.phone.widget-compact {
  height: 470px;
}

.phone.widget-compact #screen-home.is-active {
  padding: 70px 10px 4px;
}

.phone.widget-compact #screen-home.is-active .hero,
.phone.widget-compact .hero,
.phone.widget-compact.phone.iframe-mode .hero {
  height: 286px;
  min-height: 286px;
}

.phone.widget-compact .widget-head {
  padding: 8px 10px 6px;
}

.phone.widget-compact .widget-head-row h1 {
  font-size: 14px;
}

.phone.widget-compact .mode-tab {
  min-height: 34px;
  font-size: 10.5px;
}

.phone.widget-compact.phone.iframe-mode #screen-home {
  position: absolute;
  inset: 0;
  overflow: hidden;
  padding: 0;
}

.phone.widget-compact.phone.iframe-mode .hero {
  position: absolute;
  left: 0;
  right: 0;
  top: 102px;
  bottom: 4px;
  width: auto;
  max-width: none;
  height: auto;
  min-height: 0;
  margin: 0;
}

.phone.widget-minimized {
  height: 104px !important;
}

.phone.widget-minimized .screen,
.phone.widget-minimized .debug-panel {
  display: none !important;
}

.phone.widget-minimized .widget-head {
  position: relative;
  inset: auto;
  height: 100%;
  justify-content: center;
  border-radius: inherit;
  padding: 12px;
}

.phone.widget-minimized .widget-head-row {
  min-height: 24px;
}

.phone.widget-minimized .mode-switcher {
  margin-top: 2px;
}
