:root {
  color-scheme: light;
  --background: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --text: #172033;
  --muted: #64748b;
  --border: #dbe3ee;
  --primary: #1769e0;
  --primary-dark: #0d4fae;
  --success: #16784b;
  --warning: #a05a00;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(31, 45, 61, 0.12);
}

* { box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(23, 105, 224, 0.13), transparent 34rem),
    var(--background);
  color: var(--text);
}

button, textarea { font: inherit; }

.app-shell {
  width: min(980px, 100%);
  max-height: calc(100dvh - 56px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid rgba(219, 227, 238, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 28px 30px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #ffffff, #f7faff);
  flex: 0 0 auto;
}

h1 { margin: 0; font-size: clamp(26px, 4vw, 40px); line-height: 1.08; }

.examples {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  padding: 16px 30px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.examples button {
  border: 1px solid #cbd8e9;
  background: #fff;
  color: #36506f;
  border-radius: 999px;
  padding: 9px 13px;
  cursor: pointer;
  transition: 0.18s ease;
}

.examples button:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }

.conversation {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 26px 30px;
  background: #fbfcfe;
}

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.message.user-message { justify-content: flex-end; }

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #e6effd;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  flex: 0 0 36px;
}

.bubble {
  max-width: min(760px, 86%);
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bubble p { margin: 6px 0 0; }
.user-message .bubble { background: var(--primary); color: #fff; border-color: var(--primary); border-bottom-right-radius: 5px; }
.assistant-message .bubble { border-bottom-left-radius: 5px; }

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.products,
.suggestions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.product-card {
  display: flex;
  gap: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
}

.product-image {
  width: 78px;
  height: 78px;
  object-fit: contain;
  border: 1px solid #e6ebf2;
  border-radius: 10px;
  background: #fff;
}
.product-image.hidden { display: none; }
.product-content { min-width: 0; }
.product-title { margin: 0 0 6px; font-size: 14px; line-height: 1.35; }
.product-meta { color: #52647b; font-size: 13px; }
.product-link { display: inline-block; margin-top: 7px; color: var(--primary); font-size: 13px; font-weight: 700; }
.product-link.hidden { display: none; }

.suggestion-card {
  width: 100%;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  padding: 11px;
  border: 1px solid #d7e1ee;
  border-radius: 15px;
  background: linear-gradient(135deg, #fff, #f8fbff);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: 0.18s ease;
}

.suggestion-card:hover,
.suggestion-card:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgba(23, 105, 224, 0.12);
  transform: translateY(-2px);
  outline: none;
}

.suggestion-image-wrap {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border: 1px solid #e3e9f1;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.suggestion-image-wrap.is-empty {
  background: #edf4ff;
  color: var(--primary);
}

.suggestion-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.suggestion-content {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.suggestion-content strong {
  font-size: 14px;
  line-height: 1.35;
}

.suggestion-content > span:not(.suggestion-action) {
  color: #52647b;
  font-size: 12px;
}

.suggestion-action {
  color: var(--primary);
  font-size: 12px;
  font-weight: 850;
}

.composer {
  padding: 20px 30px 26px;
  border-top: 1px solid var(--border);
  background: #fff;
  flex: 0 0 auto;
}
.composer textarea {
  width: 100%;
  min-height: 94px;
  resize: vertical;
  border: 1px solid #bccadd;
  border-radius: 14px;
  padding: 14px 15px;
  color: var(--text);
  outline: none;
  transition: 0.18s ease;
}
.composer textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(23, 105, 224, 0.11); }
.composer-footer { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.composer button {
  border: 0;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  padding: 11px 22px;
  font-weight: 800;
  cursor: pointer;
  transition: 0.18s ease;
}
.composer button:hover { background: var(--primary-dark); }
.composer button.cancel-mode { background: var(--danger); }
.composer button.cancel-mode:hover { background: #8f1c14; }
.composer button:disabled { opacity: 0.55; cursor: wait; }
.cancelled-message .bubble { color: var(--muted); background: var(--surface-soft); }
