:root {
  color-scheme: light;
  --ink: #1c2922;
  --muted: #68736c;
  --forest: #243b2f;
  --forest-soft: #3d5849;
  --cream: #f4f1ea;
  --paper: #fffefa;
  --gold: #c29a61;
  --line: rgba(35, 57, 46, 0.14);
  font-family: "DM Sans", system-ui, sans-serif;
}

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

html, body { min-width: 320px; min-height: 100%; margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 5%, rgba(194,154,97,.18), transparent 24rem),
    radial-gradient(circle at 90% 90%, rgba(61,88,73,.12), transparent 30rem),
    var(--cream);
}

.site-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) max(18px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(18px, env(safe-area-inset-left));
}

.site-header {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(190px, 1fr);
  align-items: center;
  gap: clamp(16px, 3vw, 42px);
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 0 16px;
}

.brand {
  display: grid;
  justify-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50% 50% 46% 54%;
  color: #fff;
  background: linear-gradient(145deg, var(--forest-soft), var(--forest));
  box-shadow: 0 8px 20px rgba(36,59,47,.2);
  font: 800 20px/1 "Manrope", sans-serif;
}

.brand-name { margin-top: 5px; font: 800 19px/1 "Manrope", sans-serif; letter-spacing: -.035em; }
.brand-tagline { margin-top: 4px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }

.store-button {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 11px;
  min-height: 56px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255,254,250,.74);
  box-shadow: 0 8px 25px rgba(40,54,47,.07);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.store-button:hover { transform: translateY(-2px); border-color: rgba(194,154,97,.6); box-shadow: 0 12px 30px rgba(40,54,47,.12); }
.store-button small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.general-button { justify-self: end; }
.button-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; background: var(--forest); font: 800 13px/1 "Manrope", sans-serif; }
.general-button .button-icon { color: var(--forest); background: #e8d3b3; }

.main-content {
  display: grid;
  min-height: 0;
  place-items: stretch center;
  padding: 0 0 14px;
}

.chat-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1000px, 100%);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 22px 65px rgba(36,59,47,.14);
}

.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.86);
}

.agent-identity { display: flex; align-items: center; gap: 12px; }
.agent-identity > span:last-child { display: grid; }
.agent-identity strong { font: 800 18px/1.2 "Manrope", sans-serif; }
.agent-identity small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.agent-identity i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #58a36d; box-shadow: 0 0 0 4px rgba(88,163,109,.12); }
.agent-avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: #fff; background: linear-gradient(145deg, var(--forest-soft), var(--forest)); font: 800 18px/1 "Manrope", sans-serif; }
.secure-label { padding: 8px 12px; border-radius: 999px; color: var(--muted); background: #f3f1eb; font-size: 10px; font-weight: 700; }

.widget-frame {
  position: relative;
  width: 100%;
  height: clamp(480px, calc(100dvh - 250px), 720px);
  min-height: 480px;
  overflow: hidden;
  background: #fff;
  isolation: isolate;
}

.inline-chat { display: grid; grid-template-rows: minmax(0, 1fr) auto auto; width: 100%; height: 100%; background: linear-gradient(180deg, #fff 0%, #fbfaf7 100%); }
.chat-messages { min-height: 0; overflow-y: auto; padding: clamp(18px, 4vw, 42px); scroll-behavior: smooth; }
.chat-welcome { display: grid; place-items: center; align-content: center; min-height: 100%; max-width: 590px; margin: auto; text-align: center; }
.chat-welcome[hidden] { display: none; }
.voice-orb { display: grid; place-items: center; width: clamp(94px, 13vw, 132px); aspect-ratio: 1; margin-bottom: 22px; border-radius: 50%; color: #fff; background: radial-gradient(circle at 30% 25%, #e7d2a7 0 13%, #6b9c85 36%, #294b3b 68%, #16291f 100%); box-shadow: 0 22px 48px rgba(36,59,47,.24), inset 0 0 30px rgba(255,255,255,.22); }
.voice-orb span { display: grid; place-items: center; width: 54%; aspect-ratio: 1; border-radius: 50%; background: rgba(255,255,255,.94); color: var(--forest); font: 800 28px/1 "Manrope", sans-serif; box-shadow: 0 7px 20px rgba(23,43,33,.2); }
.chat-welcome h1 { margin: 0; font: 800 clamp(24px, 3vw, 34px)/1.15 "Manrope", sans-serif; letter-spacing: -.04em; }
.chat-welcome p { max-width: 520px; margin: 14px 0 24px; color: var(--muted); font-size: clamp(13px, 1.7vw, 16px); line-height: 1.6; }
.chat-welcome small { margin-top: 13px; color: #879089; font-size: 10px; }
.start-conversation { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 230px; min-height: 52px; padding: 13px 24px; border: 0; border-radius: 999px; color: #fff; background: linear-gradient(135deg, #345946, #172c22); box-shadow: 0 13px 30px rgba(32,56,44,.24); font: 700 14px/1 "DM Sans", sans-serif; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.start-conversation:hover { transform: translateY(-2px); box-shadow: 0 17px 36px rgba(32,56,44,.3); }
.start-conversation span { font-size: 18px; }
.chat-messages.has-messages { display: flex; flex-direction: column; gap: 12px; }
.message-row { display: flex; width: 100%; }
.agent-message { justify-content: flex-start; }
.user-message { justify-content: flex-end; }
.message-bubble { max-width: min(76%, 650px); padding: 12px 15px; border-radius: 18px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.agent-message .message-bubble { border: 1px solid var(--line); border-bottom-left-radius: 5px; background: #fff; box-shadow: 0 5px 18px rgba(36,59,47,.06); }
.user-message .message-bubble { border-bottom-right-radius: 5px; color: #fff; background: var(--forest); }
.file-preview { display: flex; align-items: center; gap: 9px; margin: 0 16px 8px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: #fff; font-size: 11px; }
.file-preview[hidden] { display: none; }
.file-preview img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; }
.chat-composer { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 8px; margin: 0 16px 16px; padding: 7px; border: 1px solid rgba(35,57,46,.18); border-radius: 20px; background: #fff; box-shadow: 0 10px 28px rgba(36,59,47,.1); }
.chat-composer input[type="text"] { min-width: 0; height: 42px; border: 0; outline: 0; color: var(--ink); background: transparent; font: 14px/1 "DM Sans", sans-serif; }
.chat-composer input::placeholder { color: #929a95; }
.composer-button, .send-message { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; }
.composer-button { color: var(--forest); background: #f0eee8; font-size: 20px; }
.voice-control { color: #fff; background: var(--forest); font-size: 16px; }
.voice-control.active { background: #a7463d; box-shadow: 0 0 0 4px rgba(167,70,61,.12); }
.send-message { color: #fff; background: var(--gold); font-size: 17px; }
.inline-chat[data-state="connecting"] .voice-orb { animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.045); box-shadow: 0 25px 58px rgba(36,59,47,.32); } }
.chat-note { margin: 0; padding: 9px 16px; border-top: 1px solid var(--line); color: var(--muted); background: #fbfaf6; font-size: 10px; text-align: center; }

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 11px 2px 14px;
  color: var(--muted);
  font-size: 10px;
}
.site-footer p { margin: 0; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 18px; }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover { color: var(--forest); text-decoration: underline; }

@media (max-width: 760px) {
  .site-shell { padding-inline: max(10px, env(safe-area-inset-left)); }
  .site-header { grid-template-columns: 1fr 1fr; gap: 9px; padding: 10px 0; }
  .brand { grid-column: 1 / -1; grid-row: 1; }
  .brand-tagline { display: none; }
  .store-button { grid-template-columns: 30px 1fr auto; min-width: 0; min-height: 48px; padding: 7px 9px; border-radius: 13px; font-size: 11px; }
  .store-button small { font-size: 8px; }
  .button-icon { width: 30px; height: 30px; }
  .general-button { justify-self: stretch; }
  .chat-card { min-height: 0; border-radius: 20px; }
  .widget-frame { height: clamp(440px, calc(100dvh - 255px), 680px); min-height: 440px; }
  .agent-header { min-height: 62px; padding: 9px 13px; }
  .agent-avatar { width: 38px; height: 38px; }
  .secure-label { display: none; }
  .site-footer { flex-direction: column; gap: 7px; padding: 9px 0 12px; text-align: center; }
  .site-footer nav { justify-content: center; gap: 14px; }
}

@media (max-width: 410px) {
  .store-button { grid-template-columns: 27px 1fr; }
  .store-button > span:last-child { display: none; }
  .button-icon { width: 27px; height: 27px; }
  .agent-identity small { font-size: 10px; }
  .chat-note { font-size: 9px; }
  .widget-frame { height: calc(100dvh - 245px); min-height: 410px; }
}

@media (orientation: landscape) and (max-height: 580px) {
  .site-header { padding-block: 6px; }
  .brand-tagline, .store-button small, .chat-note { display: none; }
  .brand { grid-template-columns: auto auto; align-items: center; gap: 7px; }
  .brand-name { margin: 0; }
  .store-button { min-height: 42px; }
  .agent-header { min-height: 54px; }
  .widget-frame { height: calc(100dvh - 150px); min-height: 290px; }
  .site-footer { padding-block: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .store-button { transition: none; }
}
