:root {
  --red: #ef233c;
  --red-dark: #cf1830;
  --ink: #101114;
  --muted: #6e7179;
  --line: #e7e8ec;
  --soft: #f6f7f9;
  --surface: #ffffff;
  color-scheme: light;
}

* { box-sizing: border-box; }

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

html { background: #eef0f4; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 2%, rgba(239, 35, 60, .10), transparent 32rem),
    linear-gradient(180deg, #fff 0, #f4f5f7 34rem, #eef0f4 100%);
  font-family: "Alexandria", system-ui, sans-serif;
}

button, textarea, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }

.assistant-container {
  width: min(100% - 28px, 980px);
  margin-inline: auto;
}

.assistant-header {
  position: sticky;
  z-index: 20;
  top: 0;
  padding-top: env(safe-area-inset-top);
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid rgba(16,17,20,.08);
  box-shadow: 0 6px 24px rgba(16,17,20,.05);
  backdrop-filter: blur(16px);
}

.header-inner {
  min-height: 76px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
}

.back-button, .restart-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
}

.back-button svg, .restart-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.assistant-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.assistant-brand img {
  width: 58px;
  height: 46px;
  object-fit: contain;
}

.assistant-brand span { display: grid; gap: 4px; }
.assistant-brand strong { font-size: 15px; line-height: 1.25; }
.assistant-brand small { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 5px; }
.assistant-brand small i { width: 7px; height: 7px; background: #16a163; border-radius: 50%; box-shadow: 0 0 0 3px rgba(22,161,99,.12); }

.assistant-main { padding-block: 24px 30px; }

.assistant-intro {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.expert-mark {
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  display: grid;
  place-items: center;
  border-radius: 21px;
  color: #fff;
  background: linear-gradient(145deg, var(--red), #a80f24);
  box-shadow: 0 16px 34px rgba(239,35,60,.24);
}

.expert-mark svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.assistant-intro span { color: var(--red); font-weight: 800; font-size: 13px; }
.assistant-intro h1 { margin: 5px 0 7px; font-size: clamp(22px, 4vw, 34px); line-height: 1.35; letter-spacing: -.04em; }
.assistant-intro p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }

.chat-card {
  min-height: min(690px, calc(100dvh - 170px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(16,17,20,.08);
  border-radius: 26px;
  box-shadow: 0 24px 70px rgba(22,25,35,.10);
}

.messages {
  flex: 1 1 auto;
  min-height: 340px;
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin-bottom: 18px;
  animation: message-in .28s ease both;
}

.message-row.user { justify-content: flex-start; }
.message-row.assistant { justify-content: flex-end; }

.assistant-avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--ink);
  color: #fff;
}

.assistant-avatar svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.message-bubble {
  max-width: min(78%, 610px);
  padding: 13px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-line;
}

.assistant .message-bubble {
  background: var(--soft);
  border: 1px solid #eceef1;
  border-bottom-right-radius: 5px;
}

.user .message-bubble {
  color: #fff;
  background: linear-gradient(145deg, var(--red), #d71931);
  border-bottom-left-radius: 5px;
  box-shadow: 0 9px 22px rgba(239,35,60,.18);
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -7px 41px 19px 0;
}

.quick-replies button {
  min-height: 39px;
  padding: 8px 13px;
  color: #26282d;
  background: #fff;
  border: 1px solid #dadce1;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.quick-replies button:disabled { opacity: .5; cursor: default; }

.quick-replies button:hover { border-color: var(--red); color: var(--red); }

.owner-contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -7px 41px 19px 0;
}

.owner-contact-actions a {
  min-height: 42px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #159957;
  border: 1px solid #128049;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(21,153,87,.18);
}

.owner-contact-actions a:last-child {
  color: #24262b;
  background: #fff;
  border-color: #dadce1;
  box-shadow: none;
}

.owner-contact-actions a:hover,
.owner-contact-actions a:focus-visible {
  transform: translateY(-1px);
  outline: 2px solid rgba(239,35,60,.28);
  outline-offset: 2px;
}

.typing {
  width: 62px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--soft);
  border-radius: 16px 16px 5px 16px;
}

.typing i { width: 6px; height: 6px; background: #8a8d94; border-radius: 50%; animation: typing 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }

.recommendations {
  display: grid;
  gap: 11px;
  margin: -6px 41px 20px 0;
}

.assistant-product {
  display: grid;
  grid-template-columns: 108px 1fr;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(19,22,31,.07);
}

.product-photo { min-height: 150px; padding: 10px; background: #f4f5f7; }
.product-photo img { width: 100%; height: 100%; max-height: 155px; display: block; object-fit: contain; }
.product-info { min-width: 0; padding: 13px 13px 12px; }
.product-badge { display: inline-block; margin-bottom: 5px; color: var(--red); font-size: 10px; font-weight: 800; }
.product-info h3 { margin: 0 0 5px; font-size: 14px; line-height: 1.55; }
.product-info > p { margin: 0 0 7px; color: var(--muted); font-size: 11px; line-height: 1.65; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-info ul { margin: 0 0 9px; padding: 0 16px 0 0; color: #45484e; font-size: 10px; line-height: 1.7; }
.product-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.product-bottom strong { font-size: 13px; }
.product-bottom a { padding: 7px 10px; color: #fff; background: var(--ink); border-radius: 9px; font-size: 10px; font-weight: 700; }

.starter-prompts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  padding: 0 24px 16px;
}

.starter-prompts[hidden] { display: none; }

.starter-prompts button {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  color: #2a2c31;
  background: #fff;
  border: 1px solid #dfe1e5;
  border-radius: 15px;
  font-size: 12px;
  font-weight: 700;
}

.starter-prompts button:hover { border-color: rgba(239,35,60,.55); background: #fff8f9; }
.starter-prompts span { font-size: 19px; }

.composer {
  display: grid;
  grid-template-columns: 1fr 52px;
  align-items: end;
  gap: 10px;
  padding: 15px 20px;
  background: #fff;
  border-top: 1px solid var(--line);
}

.message-input-wrap {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 4px 16px;
  background: #f4f5f7;
  border: 1px solid transparent;
  border-radius: 17px;
}

.message-input-wrap:focus-within { border-color: rgba(239,35,60,.45); box-shadow: 0 0 0 4px rgba(239,35,60,.07); background: #fff; }

.message-input-wrap textarea {
  width: 100%;
  max-height: 120px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.7;
}

.message-input-wrap textarea::placeholder { color: #999ca3; }

.send-button {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(145deg, var(--red), var(--red-dark));
  box-shadow: 0 12px 25px rgba(239,35,60,.25);
}

.send-button:disabled { opacity: .45; box-shadow: none; cursor: wait; }
.send-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; transform: scaleX(-1); }

.assistant-note { margin: 0; padding: 0 20px calc(13px + env(safe-area-inset-bottom)); color: #999ca3; background: #fff; text-align: center; font-size: 10px; line-height: 1.6; }
.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 message-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

@media (max-width: 700px) {
  body { background: #fff; }
  .assistant-container { width: 100%; }
  .header-inner { padding-inline: 14px; min-height: 69px; }
  .assistant-main { padding: 0; }
  .assistant-intro { display: none; }
  .chat-card { min-height: calc(100dvh - 70px - env(safe-area-inset-top)); border: 0; border-radius: 0; box-shadow: none; }
  .messages { min-height: 0; padding: 19px 14px; }
  .message-bubble { max-width: 85%; font-size: 14px; }
  .starter-prompts { grid-template-columns: repeat(2, 1fr); padding: 0 14px 13px; }
  .starter-prompts button { justify-content: flex-start; min-height: 52px; }
  .composer { padding: 11px 12px; grid-template-columns: 1fr 50px; position: sticky; bottom: 0; }
  .message-input-wrap, .send-button { min-height: 50px; height: 50px; }
  .assistant-note { padding-inline: 12px; }
  .quick-replies, .recommendations { margin-right: 41px; margin-left: 0; }
  .assistant-product { grid-template-columns: 96px 1fr; }
  .product-info ul { display: none; }
  .product-photo { min-height: 132px; }
}

@media (max-width: 390px) {
  .assistant-brand img { width: 50px; }
  .assistant-brand strong { font-size: 13px; }
  .message-bubble { max-width: 88%; }
  .starter-prompts button { font-size: 11px; }
  .assistant-product { grid-template-columns: 86px 1fr; }
}

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