:root {
  color-scheme: light;
  --ground: #f1f4f2;
  --surface: #fff;
  --soft: #f5f7f5;
  --ink: #1d2823;
  --muted: #5e6a63;
  --line: #e4e9e5;
  --control: #c5cec8;
  --accent: #206047;
  --accent-soft: #eaf3ed;
  --danger: #a13730;
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--ground); font-size: 16px; line-height: 1.6; }
button, input, textarea { font: inherit; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-underline-offset: 3px; }
button:disabled { cursor: default; }
::selection { background: #d0e7d8; color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
textarea { caret-color: var(--accent); }
svg { display: block; flex-shrink: 0; }
.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; }

.app-header { position: sticky; top: 0; z-index: 10; background: var(--ground); height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; max-width: 1264px; padding: 0 32px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--accent); }
.brand-word { font-size: 27px; line-height: 1; font-weight: 750; letter-spacing: -0.035em; }
.brand-note { font-size: 13px; color: var(--muted); padding-left: 14px; border-left: 1px solid var(--control); }
.new-chat { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid var(--control); border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 550; background: transparent; min-height: 44px; }
.app-sheet { min-height: calc(100dvh - 84px); margin: 0 12px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.chat { display: flex; flex-direction: column; min-height: calc(100dvh - 86px); max-width: 860px; margin: 0 auto; padding: 0 32px; }
.chat-main { flex: 1; padding-top: 40px; }
.chat-title { font-size: 15px; font-weight: 550; margin: 0 0 30px; color: var(--muted); }
.empty-state { max-width: 680px; margin: min(11vh, 100px) auto 44px; }
.empty-state h1 { font-size: 32px; line-height: 1.2; letter-spacing: -0.025em; font-weight: 600; margin: 0 0 16px; text-wrap: balance; }
.empty-state p { max-width: 520px; color: var(--muted); margin: 0; }
.examples { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; margin-top: 32px; }
.example { display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 16px; width: 100%; padding: 15px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; font-size: 14px; color: var(--ink); min-height: 56px; }
.example svg { color: var(--muted); }

.message { margin: 0 0 36px; scroll-margin-top: 24px; }
.message--user { display: flex; justify-content: flex-end; }
.user-bubble { max-width: 85%; padding: 13px 18px; border-radius: 16px 16px 4px 16px; background: var(--soft); overflow-wrap: anywhere; white-space: pre-wrap; }
.message-heading { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; font-size: 13px; font-weight: 650; color: var(--accent); }
.message-heading svg { width: 18px; height: 18px; }
.message-text { max-width: 68ch; font-size: 17px; line-height: 1.75; overflow-wrap: anywhere; }
.message-text p { margin: 0 0 12px; }
.message-text > :last-child { margin-bottom: 0; }
.message-text ul, .message-text ol { margin: 0 0 12px; padding-left: 1.5em; }
.message-text li + li { margin-top: 6px; }
.message-text li > p { margin-bottom: 6px; }
.message-text h1, .message-text h2, .message-text h3, .message-text h4, .message-text h5, .message-text h6 { font-size: 1.1em; line-height: 1.4; margin: 20px 0 8px; }
.message-text > :first-child { margin-top: 0; }
.message-text pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; margin: 0; }
.answer-status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 6px 0; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.answer-error { margin-top: 12px; color: var(--muted); font-size: 14px; }
.answer-error p { margin: 0 0 8px; }
.text-action { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; border: 0; padding: 0; background: none; color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.recommendations { margin: 28px 0 4px; max-width: 68ch; }
.recommendations-heading { margin: 0 0 10px; color: var(--muted); font-size: 13px; font-weight: 500; }
.product-list { display: grid; gap: 0; padding: 0 18px; border-radius: 12px; background: var(--soft); }
.product-card { padding: 16px 0; min-width: 0; }
.product-card + .product-card { border-top: 1px solid var(--line); }
.product-mainline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.product-card h3 { font-size: 14px; font-weight: 600; line-height: 1.5; margin: 0; overflow-wrap: anywhere; }
.product-price { flex: none; font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.product-reason { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 5px 0 0; overflow-wrap: anywhere; }
.product-attributes { margin: 7px 0 0; display: flex; flex-wrap: wrap; gap: 3px 14px; padding: 0; font-size: 12px; line-height: 1.5; color: var(--muted); list-style: none; }
.product-attributes li { overflow-wrap: anywhere; }
.product-topline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; line-height: 1.5; color: var(--muted); margin-top: 9px; }
.ad-label { color: var(--ink); border: 1px solid var(--control); padding: 0 5px; border-radius: 3px; font-weight: 500; }

.composer-region { position: sticky; bottom: 0; background: var(--surface); padding: 20px 0 18px; }
.composer { position: relative; border: 1px solid var(--control); border-radius: var(--radius); background: var(--surface); }
.composer:focus-within { border-color: var(--accent); }
.composer textarea { display: block; width: 100%; min-height: 114px; max-height: 240px; padding: 17px 20px 58px; border: 0; resize: vertical; outline: none; border-radius: var(--radius); background: transparent; color: var(--ink); line-height: 1.5; }
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.composer-footer { position: absolute; left: 20px; right: 12px; bottom: 11px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-hint { color: var(--muted); font-size: 12px; }
.send-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--ink); color: var(--surface); border: 0; border-radius: 9px; padding: 8px 13px; min-height: 40px; font-size: 13px; font-weight: 550; }
.send-button:disabled { color: var(--muted); background: var(--line); }
.demo-notice { color: var(--muted); text-align: center; font-size: 12px; margin: 11px 0 0; line-height: 1.5; }
.form-error { padding: 12px 0; color: var(--danger); font-size: 14px; }
.configuration-note { color: var(--muted); font-size: 14px; background: var(--soft); padding: 14px 18px; border-radius: 12px; margin-bottom: 24px; }
.configuration-note strong { display: block; color: var(--ink); margin-bottom: 2px; }

@media (min-height: 480px) {
  body { height: 100dvh; display: flex; flex-direction: column; }
  .app-header { width: 100%; flex: none; }
  .app-sheet { flex: 1; min-height: 0; overflow: hidden; }
  .chat { height: 100%; min-height: 0; }
  .chat-main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; }
  .composer-region { position: relative; flex: none; }
  .composer textarea { max-height: min(240px, 25dvh); }
}

@media (hover: hover) and (pointer: fine) {
  .new-chat:hover { background: var(--surface); }
  .example:hover { color: var(--accent); }
  .send-button:not(:disabled):hover { background: var(--accent); }
  .text-action:hover { color: var(--ink); }
}

@media (max-width: 640px) {
  .app-header { height: 64px; padding: 0 20px; gap: 12px; }
  .brand-word { font-size: 25px; }
  .brand-note { display: none; }
  .new-chat { padding: 7px 10px; font-size: 13px; }
  .app-sheet { margin: 0; border: 0; border-radius: 0; }
  .chat { padding: 0 20px; }
  .chat-main { padding-top: 24px; }
  .chat-title { margin-bottom: 24px; }
  .empty-state { margin: 44px 0 28px; }
  .empty-state h1 { font-size: 27px; }
  .empty-state p { font-size: 15px; }
  .examples { grid-template-columns: 1fr; margin-top: 24px; }
  .example { padding: 13px 0; min-height: 48px; }
  .user-bubble { max-width: 94%; }
  .message { margin-bottom: 28px; }
  .product-list { padding: 0 14px; }
  .product-card { padding: 14px 0; }
  .message-text { font-size: 16px; line-height: 1.7; }
  .composer-region { padding: 14px 0 max(16px, env(safe-area-inset-bottom)); }
  .composer textarea { padding: 14px 16px 58px; min-height: 120px; }
  .composer-footer { left: 16px; }
  .composer-hint { font-size: 11px; }
  .demo-notice { text-align: left; }
}

.skip-link { position: absolute; top: -80px; left: 20px; z-index: 20; background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.history { position: relative; font-size: 14px; }
.history summary { cursor: pointer; padding: 10px 0; min-height: 44px; }
.history-list { position: absolute; top: calc(100% + 8px); right: 0; z-index: 10; width: 280px; max-height: 360px; overflow: auto; border: 1px solid var(--line); padding: 6px; border-radius: 12px; background: var(--surface); box-shadow: 0 8px 24px rgb(29 40 35 / 8%); }
.history-list a { display: block; padding: 10px 12px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 6px; }
.history-list a[aria-current="page"] { background: var(--soft); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .history-list a:hover { background: var(--soft); } }
@media (max-width: 640px) { .header-actions { gap: 12px; } .history-list { right: -110px; width: min(280px, calc(100vw - 40px)); } }

.auth-sheet { overflow-y: auto; }
.auth-content { width: 100%; max-width: 448px; margin: 64px auto; padding: 0 24px; }
.auth-content h1 { margin: 0 0 12px; font-size: 27px; font-weight: 600; line-height: 1.2; letter-spacing: -0.025em; }
.auth-description { margin: 0 0 32px; color: var(--muted); }
.auth-notice { color: var(--accent); }
.auth-form { display: grid; gap: 20px; }
.auth-field { display: grid; gap: 6px; }
.auth-field label { font-size: 14px; font-weight: 550; }
.auth-field input { width: 100%; min-width: 0; min-height: 48px; padding: 10px 12px; border: 1px solid var(--control); border-radius: 8px; background: var(--surface); color: var(--ink); caret-color: var(--accent); }
.auth-form .send-button { min-height: 48px; font-size: 15px; }
@media (max-width: 640px) { .auth-content { margin: 40px auto; padding: 0 20px; } }
