:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1d3038;
  background: #edf2f4;
  font-synthesis: none;
  --ink: #1d3038;
  --muted: #64777e;
  --line: #d8e1e4;
  --surface: #ffffff;
  --surface-soft: #f5f8f9;
  --brand: #356b7c;
  --brand-dark: #284f5d;
  --accent: #ad7835;
  --danger: #a64040;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100dvh;
  margin: 0;
  background: #edf2f4;
}

button,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(216, 155, 53, 0.38);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  background: var(--surface);
}

.app-header {
  padding: max(10px, env(safe-area-inset-top)) 12px 9px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  color: #fff;
  background: var(--brand-dark);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 12px rgba(40, 79, 93, 0.16);
}

.brand-copy {
  min-width: 0;
}

.assistant-role {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  line-height: 1.2;
}

h1 {
  overflow: hidden;
  font-size: 17px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  font-size: 20px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.language-picker {
  padding: 3px;
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.language-button,
.view-tab {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 750;
}

.language-button {
  min-width: 34px;
  min-height: 32px;
  padding: 0 6px;
  border-radius: 7px;
  font-size: 11px;
}

.language-button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 8px rgba(21, 52, 50, 0.1);
}

.secondary-button,
.inline-action {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #bdd0cb;
  border-radius: 10px;
  color: var(--brand-dark);
  background: #fff;
  cursor: pointer;
  font-weight: 750;
}

.secondary-button:hover,
.inline-action:hover {
  background: var(--surface-soft);
}

.secondary-button.compact {
  min-height: 36px;
}

.app-state {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3c9a75;
  box-shadow: 0 0 0 3px rgba(60, 154, 117, 0.13);
}

.app-state.thinking .state-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 155, 53, 0.16);
  animation: pulse 1.2s ease-in-out infinite;
}

.app-state.error .state-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(166, 64, 64, 0.12);
}

.app-state.completed .state-dot {
  background: #52706a;
  box-shadow: none;
}

.context-bar {
  position: relative;
  min-height: 36px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 11px;
}

.demo-badge {
  font-weight: 650;
}

.information-disclosure {
  margin-left: auto;
}

.information-disclosure summary {
  min-height: 30px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--brand-dark);
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}

.information-disclosure summary::-webkit-details-marker {
  display: none;
}

.information-disclosure summary:focus-visible {
  outline: 2px solid rgba(53, 107, 124, 0.35);
  outline-offset: 2px;
  border-radius: 6px;
}

.information-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + 5px);
  right: 10px;
  width: min(360px, calc(100vw - 20px));
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(29, 48, 56, 0.14);
  font-size: 12px;
  line-height: 1.48;
}

.information-panel p {
  margin: 0;
}

.information-panel p + p {
  margin-top: 9px;
}

.view-tabs {
  padding: 0 14px;
  display: flex;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.view-tab {
  min-height: 42px;
  padding: 0 1px;
  border-bottom: 2px solid transparent;
  font-size: 13px;
}

.view-tab.active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
}

.view[hidden] {
  display: none;
}

.conversation-view {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
}

.messages {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 12px 22px;
  scroll-behavior: smooth;
}

.message {
  max-width: 91%;
  margin-bottom: 14px;
}

.message.customer {
  margin-left: auto;
}

.bubble {
  width: fit-content;
  padding: 11px 13px;
  border: 1px solid #e0e8e6;
  border-radius: 16px 16px 16px 5px;
  color: #253f3d;
  background: var(--surface-soft);
  line-height: 1.48;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.customer .bubble {
  margin-left: auto;
  border-color: var(--brand);
  border-radius: 16px 16px 5px 16px;
  color: #fff;
  background: var(--brand);
}

.message-label {
  margin: 0 0 5px 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.result-question .bubble {
  border-left: 3px solid var(--accent);
  background: #fffaf0;
}

.suggested-actions {
  max-width: 100%;
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.suggested-action {
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid #c8d6d3;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
  text-align: center;
  transition:
    border-color 120ms ease,
    background-color 120ms ease;
}

.suggested-action:hover {
  border-color: #8fa9a3;
  background: #f7faf9;
}

.suggested-action:active {
  background: #eef4f2;
  border-color: #789a92;
}

.suggested-action:focus-visible {
  outline: 2px solid rgba(23, 107, 91, 0.35);
  outline-offset: 2px;
}

.suggested-action:disabled {
  opacity: 0.5;
  cursor: default;
}

.result-information .bubble {
  border-left: 3px solid #478ca8;
  background: #f1f8fa;
}

.result-handoff .bubble {
  border-left: 3px solid #7b6aa8;
  background: #f7f4fb;
}

.system .bubble,
.error-state {
  border-color: #eccaca;
  color: #7e3434;
  background: #fff7f7;
}

.result-note {
  margin: 7px 3px 0;
  color: var(--muted);
  font-size: 11px;
}

.inline-action {
  min-height: 34px;
  margin-top: 8px;
  color: #7e3434;
  border-color: #dfbaba;
}

.lead-card {
  width: 100%;
  max-width: 100%;
  padding: 14px;
  border: 1px solid #bcd9cf;
  border-radius: 16px;
  background: #f3faf7;
  box-shadow: 0 8px 25px rgba(23, 107, 91, 0.08);
}

.lead-card .bubble {
  padding: 0;
  border: 0;
  background: transparent;
  font-weight: 650;
}

.lead-details {
  margin: 13px 0 0;
  display: grid;
  grid-template-columns: minmax(76px, 0.7fr) minmax(0, 1.6fr);
  gap: 7px 12px;
  font-size: 12px;
}

.lead-details dt {
  color: var(--muted);
}

.lead-details dd {
  margin: 0;
  color: var(--ink);
  font-weight: 650;
  overflow-wrap: anywhere;
}

.appointment-note {
  margin: 8px 0 0;
  padding-top: 9px;
  border-top: 1px solid #cee1db;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 700;
}

.typing-indicator {
  padding: 0 16px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-indicator[hidden] {
  display: none;
}

.typing-avatar {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--brand-dark);
  font-size: 10px;
  font-weight: 850;
}

.typing-dots {
  padding: 8px 10px;
  display: flex;
  gap: 4px;
  border-radius: 13px;
  background: var(--surface-soft);
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6f8581;
  animation: typing 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

.composer {
  margin: 0 12px;
  padding: 6px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
  border: 1px solid #bdccd2;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(29, 48, 56, 0.1);
}

textarea {
  width: 100%;
  min-height: 42px;
  max-height: 140px;
  padding: 10px 8px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.35;
}

textarea::placeholder {
  color: #8fa19e;
}

.send-button {
  min-width: 78px;
  height: 42px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 11px;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
  font-weight: 800;
}

.send-button:hover {
  background: var(--brand-dark);
}

.send-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.composer-hint {
  min-height: calc(27px + env(safe-area-inset-bottom));
  margin: 0;
  padding: 7px 16px calc(7px + env(safe-area-inset-bottom));
  color: #758985;
  font-size: 10px;
  text-align: center;
}

.leads-view {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 14px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface-soft);
}

.leads-heading,
.stored-lead-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.leads-list {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.stored-lead-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(21, 52, 50, 0.06);
}

.stored-lead-heading strong {
  color: var(--ink);
  font-size: 14px;
}

.stored-lead-heading time {
  color: var(--muted);
  font-size: 10px;
}

.empty-state {
  margin: 0;
  padding: 28px 18px;
  border: 1px dashed #c4d2cf;
  border-radius: 15px;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

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

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

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

@media (max-width: 430px) {
  .app-header {
    padding-right: 10px;
    padding-left: 10px;
  }

  .header-controls {
    gap: 6px;
  }

  .language-button {
    min-width: 30px;
    padding: 0 4px;
  }

  .secondary-button {
    width: 42px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .secondary-button span:first-child {
    font-size: 20px;
  }

  .secondary-button.compact {
    width: auto;
    padding: 0 10px;
    font-size: 11px;
  }

  .send-button {
    min-width: 44px;
    width: 44px;
    padding: 0;
    font-size: 0;
  }

  .send-button span:last-child {
    font-size: 18px;
  }

  .suggested-action {
    min-height: 44px;
  }

  .messages {
    padding-top: 12px;
  }
}

@media (min-width: 760px) {
  body {
    display: grid;
    place-items: center;
    padding: 24px;
    background: #e7edef;
  }

  .app-shell {
    width: min(100%, 780px);
    min-height: min(900px, calc(100dvh - 48px));
    height: min(900px, calc(100dvh - 48px));
    border: 1px solid #ccd8dc;
    border-radius: 20px;
    box-shadow: 0 20px 55px rgba(29, 48, 56, 0.14);
  }

  .app-header {
    grid-template-columns: minmax(0, 1fr) auto auto;
    padding: 14px 18px;
  }

  .app-state {
    grid-column: auto;
    grid-row: 1;
    justify-self: end;
  }

  .header-controls {
    grid-column: 2;
    grid-row: 1;
  }

  .messages {
    padding-inline: 22px;
  }

  .message {
    max-width: 78%;
  }

  .lead-card {
    max-width: 88%;
  }
}

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