:root {
  --ink: #19192f;
  --body: #4f5368;
  --muted: #777b8e;
  --line: rgba(36, 35, 77, 0.12);
  --purple: #5856d6;
  --purple-dark: #4543b8;
  --purple-soft: #eeedff;
  --green: #119875;
  --green-soft: #e8f8f3;
  --surface: #ffffff;
  --page: #f4f4fb;
  --shadow: 0 24px 70px rgba(38, 35, 88, 0.16);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(88, 86, 214, 0.13), transparent 30%),
    radial-gradient(circle at 88% 88%, rgba(17, 152, 117, 0.10), transparent 28%),
    var(--page);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.chat-production .chat-page { min-height: 100vh; }
.chat-production .chat-app { height: min(900px, calc(100vh - 40px)); }

.demo-ribbon {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  min-height: 42px;
  padding: 9px 20px;
  color: #fff;
  background: #22213d;
  font-size: 0.78rem;
}
.demo-ribbon span { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; text-transform: uppercase; letter-spacing: .055em; }
.demo-ribbon strong { color: rgba(255,255,255,.72); font-weight: 500; }

.chat-page { display: grid; place-items: center; min-height: calc(100vh - 42px); padding: 26px; }
.chat-app {
  display: grid;
  grid-template-rows: auto auto minmax(120px, 1fr) auto auto;
  width: min(790px, 100%);
  height: min(860px, calc(100vh - 94px));
  min-height: 660px;
  overflow: hidden;
  border: 1px solid rgba(36, 35, 77, 0.10);
  border-radius: 26px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #7472ee, #4846bd);
  box-shadow: 0 8px 22px rgba(88, 86, 214, .28);
  font-size: 1.15rem;
  font-weight: 800;
}
.brand > span:last-child { display: flex; flex-direction: column; gap: 4px; }
.brand strong { font-size: .98rem; }
.brand small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .75rem; }
.brand small i { width: 7px; height: 7px; border-radius: 50%; background: #20bc87; box-shadow: 0 0 0 3px rgba(32,188,135,.13); }
.chat-header-actions { display: flex; align-items: center; gap: 10px; }
.secure-label { display: inline-flex; align-items: center; gap: 7px; color: var(--green); font-size: .75rem; font-weight: 700; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; color: var(--body); background: #fff; }
.icon-button:hover { color: var(--purple); border-color: rgba(88,86,214,.28); }

.progress-wrap { padding: 10px 22px 12px; background: #fff; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: .71rem; font-weight: 700; }
.progress-track { height: 5px; overflow: hidden; border-radius: 999px; background: #ececf4; }
.progress-track i { display: block; width: 10%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple), #7d7bea); transition: width .28s ease; }

.conversation {
  overflow-y: auto;
  padding: 24px clamp(18px, 5vw, 42px) 28px;
  background:
    linear-gradient(rgba(250,250,254,.94), rgba(250,250,254,.94)),
    radial-gradient(circle, rgba(88,86,214,.14) 1px, transparent 1.2px);
  background-size: auto, 20px 20px;
  overscroll-behavior: contain;
}
.message-row { display: flex; align-items: flex-end; gap: 9px; margin: 0 0 13px; animation: message-in .22s ease both; }
.message-row.user { justify-content: flex-end; }
.avatar-mini { display: grid; place-items: center; flex: 0 0 auto; width: 29px; height: 29px; border-radius: 10px; color: #fff; background: var(--purple); font-size: .72rem; font-weight: 800; }
.bubble {
  max-width: min(560px, 82%);
  padding: 13px 16px;
  border: 1px solid rgba(36,35,77,.08);
  border-radius: 18px 18px 18px 5px;
  color: var(--body);
  background: #fff;
  box-shadow: 0 5px 18px rgba(41,39,85,.06);
  font-size: 1rem;
  line-height: 1.55;
}
.bubble strong { color: var(--ink); }
.message-row.user .bubble { border-color: transparent; border-radius: 18px 18px 5px 18px; color: #fff; background: var(--purple); box-shadow: 0 7px 20px rgba(88,86,214,.19); }
.bubble .tiny { display: block; margin-top: 7px; color: var(--muted); font-size: .72rem; }
.message-row.user .tiny { color: rgba(255,255,255,.72); }
.bubble.review { max-width: 610px; width: 100%; }
.review-list { display: grid; gap: 9px; margin: 11px 0 0; }
.review-item { display: grid; grid-template-columns: 118px 1fr; gap: 12px; padding-top: 9px; border-top: 1px solid var(--line); font-size: .82rem; }
.review-item span { color: var(--muted); }
.review-item b { color: var(--ink); font-weight: 650; }

.typing { display: flex; align-items: center; gap: 5px; width: fit-content; padding: 13px 16px; border-radius: 18px 18px 18px 5px; background: #fff; box-shadow: 0 5px 18px rgba(41,39,85,.06); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #a8a8b8; animation: typing 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.reply-panel { padding: 16px 22px 18px; border-top: 1px solid var(--line); background: #fff; }
.reply-panel.is-scrollable { max-height: min(58vh, 520px); overflow-y: auto; overscroll-behavior: contain; }
.reply-card { display: grid; gap: 12px; }
.field-label { color: var(--ink); font-size: .8rem; font-weight: 700; }
.text-field, .text-area, .select-field {
  width: 100%;
  min-height: 49px;
  padding: 13px 15px;
  border: 1px solid rgba(36,35,77,.16);
  border-radius: 14px;
  outline: 0;
  color: var(--ink);
  background: #fff;
  font-size: 1rem;
}
.text-area { min-height: 94px; resize: vertical; line-height: 1.5; }
.select-field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 19px) 21px, calc(100% - 14px) 21px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.text-field:focus, .text-area:focus, .select-field:focus { border-color: var(--purple); box-shadow: 0 0 0 4px rgba(88,86,214,.10); }
.two-fields { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }
.three-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field-stack { display: grid; gap: 7px; }
.quick-replies { display: flex; flex-wrap: wrap; gap: 9px; }
.choice-button, .primary-button, .skip-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 46px;
  padding: 11px 17px;
  border-radius: 13px;
  font-weight: 750;
}
.choice-button { border: 1px solid rgba(88,86,214,.23); color: var(--purple-dark); background: #fff; }
.choice-button:hover { background: var(--purple-soft); }
.reply-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.primary-button { border: 0; color: #fff; background: var(--purple); box-shadow: 0 8px 20px rgba(88,86,214,.20); }
.primary-button:hover { background: var(--purple-dark); }
.skip-button { margin-right: auto; border: 0; color: var(--muted); background: transparent; font-weight: 650; }
.skip-button:hover { color: var(--purple); background: var(--purple-soft); }
.primary-button:disabled, .choice-button:disabled { cursor: wait; opacity: .62; }
.reply-note { display: flex; gap: 8px; color: var(--muted); font-size: .76rem; line-height: 1.4; }
.reply-note i { margin-top: 2px; color: var(--green); }

.status-box { display: flex; align-items: flex-start; gap: 9px; padding: 11px 13px; border-radius: 12px; color: var(--body); background: #f5f5fa; font-size: .78rem; line-height: 1.45; }
.status-box i { margin-top: 2px; color: var(--purple); }
.status-box.success { color: #08785d; background: var(--green-soft); }
.status-box.success i { color: var(--green); }
.status-box.error { color: #ad2f3d; background: #fff0f2; }
.status-box.error i { color: #cc4050; }
.code-row { display: grid; grid-template-columns: minmax(150px, 1fr) auto; gap: 10px; }
.code-field { letter-spacing: .22em; text-align: center; font-size: 1.08rem; font-weight: 800; }
.section-caption { margin: 4px 0 -2px; color: var(--ink); font-size: .78rem; font-weight: 800; }
.upload-grid + .section-caption { margin-top: 8px; }
.consent-line { display: flex; align-items: flex-start; gap: 10px; color: var(--body); font-size: .75rem; line-height: 1.45; cursor: pointer; }
.consent-line input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--purple); }
.submission-status { display: grid; place-items: center; gap: 13px; min-height: 150px; text-align: center; color: var(--body); }
.submission-status i { color: var(--purple); font-size: 1.65rem; }
.submission-status strong { color: var(--ink); }
.case-number { display: inline-flex; align-items: center; gap: 9px; margin-top: 10px; padding: 10px 13px; border-radius: 12px; color: var(--purple-dark); background: var(--purple-soft); font-weight: 800; letter-spacing: .035em; }
.case-number button { border: 0; color: inherit; background: transparent; }

.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.upload-option { position: relative; display: grid; gap: 5px; min-height: 96px; padding: 13px; border: 1px dashed rgba(88,86,214,.34); border-radius: 14px; color: var(--body); background: #fafaff; cursor: pointer; }
.upload-option:hover, .upload-option.dragging { border-color: var(--purple); background: var(--purple-soft); }
.upload-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-option i { color: var(--purple); font-size: 1rem; }
.upload-option b { font-size: .79rem; }
.upload-option small { color: var(--muted); font-size: .69rem; line-height: 1.35; }
.upload-option.has-file { border-style: solid; border-color: rgba(17,152,117,.4); background: var(--green-soft); }
.upload-option.has-file i { color: var(--green); }

.chat-footer { display: flex; justify-content: center; align-items: center; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--line); color: var(--muted); background: #fbfbfd; font-size: .69rem; text-align: center; }
.chat-footer i { color: var(--green); }

@keyframes message-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes typing { 0%, 65%, 100% { opacity: .4; transform: translateY(0); } 32% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 680px) {
  .demo-ribbon { min-height: 38px; padding: 8px 14px; }
  .demo-ribbon strong { display: none; }
  .chat-page { display: block; min-height: calc(100dvh - 38px); padding: 0; }
  .chat-app { width: 100%; height: calc(100dvh - 38px); min-height: 580px; border: 0; border-radius: 0; box-shadow: none; }
  .chat-production .chat-page { min-height: 100dvh; }
  .chat-production .chat-app { height: 100dvh; }
  .chat-header { padding: 13px 15px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 13px; }
  .secure-label { display: none; }
  .progress-wrap { padding-inline: 16px; }
  .conversation { padding: 19px 14px 24px; }
  .bubble { max-width: 88%; font-size: 1rem; }
  .reply-panel { padding: 13px 14px calc(14px + env(safe-area-inset-bottom)); }
  .two-fields { grid-template-columns: 1fr; }
  .three-fields { grid-template-columns: 1fr; }
  .code-row { grid-template-columns: 1fr; }
  .upload-grid { grid-template-columns: repeat(2, 1fr); max-height: 240px; overflow-y: auto; }
  .review-item { grid-template-columns: 92px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
