:root {
  color-scheme: light;
  --ink: #18231f;
  --muted: #68746f;
  --line: #dfe5e1;
  --paper: #ffffff;
  --canvas: #f4f6f2;
  --green: #165f4a;
  --green-deep: #0e4536;
  --mint: #dff1e8;
  --blue: #254f75;
  --danger: #a4362c;
  --shadow: 0 24px 70px rgba(29, 47, 40, 0.12);
}

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

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 6%, rgba(173, 215, 195, .42), transparent 28rem),
    radial-gradient(circle at 92% 88%, rgba(182, 206, 224, .34), transparent 30rem),
    var(--canvas);
  font: 15px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.shell {
  min-height: 100vh;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 22px 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.topbar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -.025em;
  text-decoration: none;
}

.brand-mark, .login-mark {
  display: grid;
  place-items: center;
  color: white;
  background: var(--green);
  font-family: Georgia, serif;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
}

.brand-mark { width: 31px; height: 31px; border-radius: 10px; }

.step-label {
  color: var(--muted);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(209,219,213,.9);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 650;
  backdrop-filter: blur(12px);
}

.step-label span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #34a574;
  box-shadow: 0 0 0 4px rgba(52,165,116,.13);
}

.chat-card {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(250px, 1fr) auto auto;
  background: rgba(255,255,255,.9);
  border: 1px solid rgba(205,215,209,.92);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.chat-head {
  min-height: 82px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 13px;
  border-bottom: 1px solid var(--line);
}

.agent-avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, #244f43, #0f392f);
  border-radius: 15px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  box-shadow: 0 8px 18px rgba(16,69,53,.2);
}

.agent-copy { min-width: 0; }
.agent-copy h1 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.agent-copy p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.online-dot { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: #31a673; }

.head-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.voice-menu { position: relative; }
.voice-menu summary {
  min-height: 38px;
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green-deep);
  background: #f1f6f3;
  border: 1px solid #d6e3dc;
  border-radius: 10px;
  font-size: 11px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.voice-menu summary::-webkit-details-marker { display: none; }
.voice-menu summary:hover, .voice-menu[open] summary { background: var(--mint); }
.voice-menu summary svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.voice-menu summary b { display: inline-block; max-width: 95px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; white-space: nowrap; }
.voice-menu-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  right: 0;
  width: min(300px, calc(100vw - 30px));
  padding: 15px;
  color: var(--ink);
  background: white;
  border: 1px solid #d7e0db;
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(21,48,38,.18);
}

.speak-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.speak-toggle input { accent-color: var(--green); }
.voice-select-label { display: block; margin: 14px 0 6px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.voice-menu-panel select { width: 100%; min-height: 40px; padding: 0 10px; color: var(--ink); background: white; border: 1px solid #ccd8d1; border-radius: 9px; outline: none; }
.voice-menu-panel select:focus { border-color: #6d9d8a; box-shadow: 0 0 0 3px rgba(54,137,105,.11); }
.voice-menu-panel button { width: 100%; min-height: 39px; margin-top: 9px; color: var(--green-deep); background: var(--mint); border: 0; border-radius: 9px; font-size: 12px; font-weight: 750; cursor: pointer; }
.voice-menu-panel small { display: block; margin-top: 10px; color: var(--muted); font-size: 10px; line-height: 1.4; }

.quiet-button {
  color: var(--green-deep);
  background: var(--mint);
  border: 0;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.messages {
  min-height: 0;
  padding: 25px clamp(18px, 5vw, 62px);
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message { max-width: min(78%, 720px); margin-bottom: 22px; }
.message.user { margin-left: auto; }
.message-label { margin: 0 8px 6px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; }
.message.user .message-label { text-align: right; }
.bubble { padding: 13px 16px; border-radius: 6px 18px 18px 18px; background: #eef2ef; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user .bubble { color: white; background: var(--green); border-radius: 18px 6px 18px 18px; }
.message-meta { margin: 6px 8px 0; color: #89938f; font-size: 10px; }
.replay-button { margin: 6px 8px 0; padding: 0; color: var(--green); background: none; border: 0; font-size: 10px; font-weight: 750; cursor: pointer; }
.replay-button:hover { color: var(--green-deep); text-decoration: underline; }

.thinking {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 clamp(18px, 5vw, 62px) 13px;
  color: var(--muted);
  font-size: 11px;
}

.thinking[hidden] { display: none; }
.thinking span { width: 5px; height: 5px; border-radius: 50%; background: var(--green); animation: blink 1.1s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: .16s; }
.thinking span:nth-child(3) { animation-delay: .32s; }
.thinking b { margin-left: 4px; font-weight: 600; }
@keyframes blink { 0%, 70%, 100% { opacity: .25; transform: translateY(0); } 35% { opacity: 1; transform: translateY(-2px); } }

.composer-wrap { border-top: 1px solid var(--line); padding: 14px clamp(14px, 3vw, 30px) 12px; background: rgba(250,251,249,.94); }

.composer {
  min-height: 56px;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 42px;
  align-items: end;
  gap: 8px;
  padding: 7px;
  background: white;
  border: 1px solid #d8dfda;
  border-radius: 18px;
  box-shadow: 0 8px 26px rgba(28,49,40,.06);
}

.composer:focus-within { border-color: #7cac99; box-shadow: 0 0 0 3px rgba(54,137,105,.11); }
.message-input-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

textarea {
  width: 100%;
  min-height: 40px;
  max-height: 132px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 9px 5px 7px;
  line-height: 1.45;
}

textarea::placeholder { color: #98a29d; }

.mic-button, .send-button {
  height: 44px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
}

.mic-button { min-width: 76px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: var(--green); background: var(--mint); font-size: 12px; font-weight: 800; }
.mic-button:hover { background: #d2ebdf; }
.mic-button.listening { color: white; background: #b54238; animation: micGlow 1.25s infinite; }
.mic-symbol { display: block; flex: 0 0 auto; width: 19px; height: 19px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mic-label { line-height: 1; }
.send-button { width: 42px; }
.send-button { color: white; background: var(--green); font-size: 22px; font-weight: 500; }
.send-button:hover { background: var(--green-deep); }
.send-button:disabled, .mic-button:disabled { opacity: .45; cursor: not-allowed; }
@keyframes micGlow { 50% { box-shadow: 0 0 0 7px rgba(181,66,56,.12); } }

.voice-state { display: flex; align-items: center; gap: 11px; min-height: 48px; margin: 0 1px 9px; padding: 8px 10px; color: var(--danger); background: #fff3f1; border: 1px solid #f0c9c4; border-radius: 12px; font-size: 12px; }
.voice-state[hidden] { display: none; }
.voice-pulse { height: 18px; display: flex; align-items: center; gap: 2px; }
.voice-pulse i { width: 2px; height: 6px; background: currentColor; border-radius: 2px; animation: wave .72s infinite alternate; }
.voice-pulse i:nth-child(2), .voice-pulse i:nth-child(4) { animation-delay: .18s; }
.voice-pulse i:nth-child(3) { animation-delay: .36s; }
.voice-state-copy { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.voice-state-copy strong { font-size: 12px; }
.voice-state-copy span { max-width: min(58vw, 620px); overflow: hidden; color: var(--muted); font-size: 10px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.voice-state button { min-height: 32px; margin-left: auto; padding: 0 11px; flex: 0 0 auto; color: currentColor; background: rgba(255,255,255,.75); border: 1px solid currentColor; border-radius: 8px; font-size: 11px; font-weight: 800; cursor: pointer; }
.voice-state[data-state="permission"], .voice-state[data-state="processing"] { color: var(--blue); background: #f1f6fa; border-color: #cadbe8; }
.voice-state[data-state="speaking"] { color: var(--green); background: #eff8f3; border-color: #cbe4d7; }
.voice-state[data-state="error"] { color: var(--danger); }
.voice-state[data-state="error"] .voice-pulse i { animation: none; height: 4px; }
@keyframes wave { to { height: 18px; } }

.composer-foot { min-height: 21px; padding: 7px 4px 0; display: flex; justify-content: space-between; gap: 12px; color: #8a948f; font-size: 10px; }

.login-card {
  width: min(100%, 520px);
  align-self: center;
  justify-self: center;
  padding: 42px;
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(205,215,209,.92);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-mark { width: 52px; height: 52px; margin-bottom: 30px; border-radius: 16px; font-size: 24px; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.login-card h1 { margin: 8px 0 10px; font: 700 clamp(27px, 5vw, 37px)/1.1 Georgia, serif; letter-spacing: -.035em; }
.login-card > p { margin: 0 0 28px; color: var(--muted); }
.login-card label { display: block; margin: 0 0 7px; font-size: 12px; font-weight: 750; }
.login-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.login-row input { min-width: 0; padding: 12px 13px; border: 1px solid #cfd8d2; border-radius: 11px; outline: none; }
.login-row input:focus { border-color: #6d9d8a; box-shadow: 0 0 0 3px rgba(54,137,105,.11); }
.login-row button { padding: 0 18px; color: white; background: var(--green); border: 0; border-radius: 11px; font-weight: 750; cursor: pointer; }
.form-error { min-height: 20px; margin-top: 8px; color: var(--danger); font-size: 12px; }

footer { text-align: center; color: #85908b; font-size: 10px; letter-spacing: .015em; }

@media (max-width: 700px) {
  .shell { padding: 10px 10px 8px; gap: 9px; }
  .topbar { min-height: 43px; padding: 0 3px; }
  .step-label { font-size: 10px; }
  .chat-card { border-radius: 19px; }
  .chat-head { min-height: 70px; padding: 12px; }
  .agent-avatar { width: 40px; height: 40px; border-radius: 12px; }
  .agent-copy p { max-width: 33vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .voice-menu summary { padding: 0 9px; }
  .voice-menu summary > span { max-width: 115px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .voice-menu-panel { position: fixed; top: auto; right: 10px; bottom: 12px; left: 10px; width: auto; }
  .quiet-button { padding: 7px 8px; }
  .messages { padding: 18px 12px; }
  .message { max-width: 91%; }
  .composer-wrap { padding: 10px 9px 8px; }
  .voice-state-copy span { max-width: 52vw; }
  .login-card { padding: 30px 23px; border-radius: 20px; }
  .login-row { grid-template-columns: 1fr; }
  .login-row button { min-height: 45px; }
}

@media (max-width: 410px) {
  .voice-menu summary > span { max-width: 82px; }
  .mic-button { min-width: 46px; width: 46px; padding: 0; }
  .mic-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .composer { grid-template-columns: 46px minmax(0, 1fr) 42px; }
  .composer-foot span:last-child { display: none; }
}

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