/* ShopPal v2 - FinTech design system (Nov 2026).
   Direction: clean, high-trust, Stripe/Linear/PayPal-modern.
   Palette: soft background #F8FAFC, white surfaces, slate borders
   #E2E8F0, PayPal navy #003087 + blue #0070BA accents.
   Type: Inter/system-ui for UI; tabular-nums + monospace for money,
   Order IDs and JSON payloads, like a financial dashboard.
   Accessibility: WCAG 2.1 AA - text contrast >= 4.5:1, touch targets
   44px, visible focus, prefers-reduced-motion support. */

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ink: #0f172a;
  --muted: #475569;
  --faint: #64748b;
  --navy: #003087;
  --navy-dark: #00205f;
  --gold: #ffc439;
  --blue: #0070ba;
  --blue-dark: #005ea6;
  --amber-bg: #fffbeb;
  --amber-border: #f59e0b;
  --amber-text: #92400e;
  --emerald-bg: #ecfdf5;
  --emerald-border: #10b981;
  --emerald-text: #065f46;
  --red-bg: #fef2f2;
  --red-text: #991b1b;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.1);
  --radius: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

.ext-link { font-size: 0.85rem; color: var(--blue); }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

/* Money, Order IDs and JSON read like a financial dashboard: monospace
   with tabular figures, so digits line up. */
.num, .price, code, pre, .order-id, .mono {
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

.app {
  max-width: 1080px;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Sticky header: identity + live status, always visible. */
.chat-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  color: #fff;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--navy-dark);
  box-shadow: var(--shadow-sm);
}

.agent-id { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.avatar { width: 44px; height: 44px; flex-shrink: 0; }
.agent-name { font-weight: 700; font-size: 1.1rem; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
.agent-status { font-size: 0.85rem; opacity: 0.92; display: flex; align-items: center; gap: 0.35rem; }
.agent-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; }
.live-badge {
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.live-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; }
.sandbox-badge {
  font-size: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  white-space: nowrap;
}
.header-badges { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

/* Single-column layout: the chat takes the full width. The right
   sidebar was removed (its Live status + Guardrails cards duplicated the
   header badges), so there is no two-column grid any more. */
.layout { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-col { flex: 1; min-height: 0; display: flex; flex-direction: column; }
@media (min-width: 1024px) {
  .layout {
    padding: 1rem;
  }
  .chat-col {
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
}

/* Messages */
.chat {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.msg { max-width: 88%; padding: 0.7rem 0.9rem; border-radius: 16px; animation: msg-in 0.25s ease-out; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typing indicator: three pulsing dots, like a messaging app. */
.typing span {
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--faint);
  animation: typing-dot 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.msg.agent {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  box-shadow: var(--shadow-sm);
}

/* Best Deal verdict hero: the single most important answer in the chat
   gets a navy card with a gold total, so the eye lands on it first. */
.msg.agent.verdict-hero {
  background: var(--navy-dark) !important;
  color: #fff;
  border: 1px solid var(--navy-dark) !important;
  box-shadow: var(--shadow-md);
}
.msg.agent.verdict-hero .msg-label { color: #bfdbfe !important; }
.msg.agent.verdict-hero .hint { color: #cbd5e1; }
.msg.agent.verdict-hero .verdict-total {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--gold);
  margin-top: 0.15rem;
}
.msg.agent.verdict-hero .btn-primary {
  background: var(--gold);
  color: var(--navy-dark);
  border-color: var(--gold);
}

/* Gold "best" badge: the same gold as the Best Deal hero total, used for
   the winning entry in Compare, so "best" always looks the same. */
.best-badge {
  background: var(--gold);
  color: var(--navy-dark);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}
.msg.user {
  align-self: flex-end;
  background: var(--navy);
  color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.msg-label { font-size: 0.75rem; font-weight: 700; color: var(--ink); margin-bottom: 0.25rem; }
.msg p { margin: 0.35rem 0; }
.msg p:first-child { margin-top: 0; }
.msg p:last-child { margin-bottom: 0; }
.msg ul { margin: 0.35rem 0; padding-left: 1.2rem; }
.msg li { margin: 0.15rem 0; }

/* Suggestion chips under the greeting. */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.chip {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--navy);
  border-radius: 999px;
  padding: 0.75rem 1rem;
  min-height: 44px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.chip:hover { background: #eff6ff; }
.chip.active { background: var(--navy); color: #fff; }

/* Product cards inside a message. White surface, slate border, layered
   shadow; the risk pill on the card makes risk visible before any tap. */
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.product-card {
  text-align: left;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  cursor: pointer;
  font: inherit;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  animation: card-in 0.3s ease-out;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.product-card.selected { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue), var(--shadow-sm); }
.product-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--bg); }
.product-card .card-body { padding: 0.6rem 0.7rem; }
.product-card .card-body strong { display: block; font-size: 1rem; color: var(--ink); }
.product-card .price { font-weight: 700; font-size: 1.15rem; color: var(--ink); }
.product-card .seller { font-size: 0.85rem; color: var(--muted); }
.product-card .card-score { float: right; margin-left: 0.4rem; }

/* Inner content blocks (risk, cost, vault) inside a message. */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  margin-top: 0.5rem;
  animation: card-in 0.3s ease-out;
}
.card:first-child { margin-top: 0; }

.hint { color: var(--muted); font-size: 0.9rem; }
.hidden { display: none; }

.score { font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.score-safe { background: #dcfce7; color: #166534; }
.score-caution { background: #fef3c7; color: #92400e; }
.score-risky { background: #fee2e2; color: #991b1b; }
.score-emerald { background: var(--emerald-bg); color: var(--emerald-text); border: 1px solid var(--emerald-border); }

table { width: 100%; border-collapse: collapse; }
td { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
td:last-child { text-align: right; white-space: nowrap; }

/* Feature blocks: small-caps navy title over a rule, key number large. */
.feature-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
  border-bottom: 2px solid var(--navy); padding-bottom: 0.4rem; margin-bottom: 0.6rem;
}
.feature-title { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--navy); }
.feature-metric { font-size: 1.75rem; font-weight: 800; color: var(--ink); line-height: 1.2; margin: 0.2rem 0 0.5rem; }
.feature-metric-sub { font-size: 1rem; font-weight: 700; color: var(--muted); }
tr.total-row td { border-top: 2px solid var(--navy); font-size: 1.15rem; padding-top: 0.5rem; }

/* Guardrail callout: amber warning box with a shield, the reason it is
   held, and Approve / Reject actions. */
.callout {
  border: 1px solid var(--amber-border);
  border-left: 4px solid var(--amber-border);
  background: var(--amber-bg);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-top: 0.6rem;
  animation: card-in 0.3s ease-out;
}
.callout-head { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; color: var(--amber-text); }
.callout-head .shield { width: 18px; height: 18px; flex: none; }
.callout p { margin: 0.4rem 0; color: var(--ink); }
.callout .hint { color: var(--amber-text); }
.callout-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.callout-actions .btn-primary { flex: 1; min-width: 140px; }
.callout-actions .btn-secondary { flex: 1; min-width: 140px; }

/* Split payment link card: breakdown, status badge, actions. */
.split-card { animation: card-in 0.3s ease-out; }
.split-breakdown { margin: 0.5rem 0; }
.split-breakdown .row { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--border); }
.split-breakdown .row:last-child { border-bottom: none; }
.split-breakdown .row.total { font-weight: 700; border-top: 2px solid var(--navy); margin-top: 0.2rem; padding-top: 0.5rem; }
/* Nominal amount badge on a split-payment link row: the share stands out
   as a pill so each participant's amount is scannable at a glance. */
.badge-amount {
  display: inline-block;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--navy);
  font-weight: 700;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  white-space: nowrap;
}

.split-link-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.split-link-row:last-child { border-bottom: none; }
.split-link-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Dispute payload: status summary card above a dark code block. */
.dispute-summary {
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
  margin: 0.5rem 0; animation: card-in 0.3s ease-out;
}
.codeblock {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin: 0.5rem 0 0;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.55;
  border: 1px solid #1e293b;
}
.codeblock code { background: transparent; padding: 0; color: inherit; }

/* Vault actions: 2-column grid of secondary (outline) buttons. */
.vault-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; margin-top: 0.5rem; }
.vault-actions button { padding: 0.75rem 0.7rem; font-size: 0.9rem; min-height: 44px; }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--bg); }
.btn-secondary:disabled { background: var(--surface); color: var(--faint); border-color: var(--border); cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }

/* Dismiss button for the greeting: a quiet × at the top-right of the intro
   bubble, so the introduction can be closed and the catalog stays. */
.dismiss-btn {
  float: right; background: transparent; color: var(--muted); border: none;
  font-size: 1.3rem; line-height: 1; padding: 0.1rem 0.4rem; cursor: pointer;
  border-radius: 6px; font-family: inherit; min-height: 44px; min-width: 44px;
}
.dismiss-btn:hover { background: var(--bg); color: var(--ink); }

/* Compare: two stacked cards instead of a wide table, so nothing ever
   needs a horizontal scroll on a phone. */
.compare-list { display: flex; flex-direction: column; gap: 0.6rem; }
.compare-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.7rem; background: var(--surface); box-shadow: var(--shadow-sm); animation: card-in 0.3s ease-out; }
.compare-card.compare-safer { border-color: #16a34a; background: #f0fdf4; }
.compare-head { display: flex; gap: 0.6rem; align-items: center; }
.compare-head img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; flex: none; }
.compare-head .price { font-weight: 700; }
.compare-card ul { margin: 0.5rem 0 0; padding-left: 1.1rem; }
.compare-card li { margin: 0.15rem 0; }
.pick-badge { font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.45rem; border-radius: 999px; white-space: nowrap; }
.pick-safer { background: #dcfce7; color: #166534; }
.pick-cheaper { background: #f0f0f0; color: var(--ink); }
code { background: #e2e8f0; padding: 0.1rem 0.3rem; border-radius: 4px; }

button {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1rem;
  min-height: 44px;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
button:hover { background: var(--navy-dark); }
button:disabled { background: #94a3b8; color: #fff; cursor: not-allowed; }
button:active:not(:disabled) { transform: translateY(1px); }

/* Loading: a small spinner + label, used while the agent talks to the
   backend or PayPal Sandbox. Buttons are disabled while it runs. */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 0.4rem;
}
.spinner.dark { border-color: rgba(15, 23, 42, 0.2); border-top-color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-line { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }

/* Toast notifications: bottom-right, slide in, auto-dismiss. */
.toast-root {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(92vw, 360px);
}
.toast {
  background: var(--ink);
  color: #fff;
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease-out;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.toast.success { background: var(--emerald-text); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Accessibility: a visible keyboard-focus ring, and no motion for users
   who asked for it (prefers-reduced-motion). */
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  .msg, .product-card, .card, .compare-card, .callout, .split-card, .dispute-summary, .side-card, .toast { animation: none; }
  .typing span, .spinner { animation: none; }
  .product-card, .chip, button { transition: none; }
}

/* Quick Demo chips: one-tap scenario prompts above the composer, so a
   demo runs without typing. Always visible, unlike the greeting chips. */
.quick-demo {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 0.4rem;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.quick-demo-label { font-size: 0.8rem; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.quick-chip { padding: 0.7rem 0.9rem; min-height: 48px; font-size: 0.85rem; }


/* Featured tools row: Best Deal / Compare / Wishlist / Price Watch were
   hidden behind chat commands judges never typed, so they get one-tap
   chips of their own, next to the Demo row. */
.feature-demo {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 0.4rem;
  align-items: center;
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.feature-chip { padding: 0.7rem 0.9rem; min-height: 48px; font-size: 0.85rem; }
.quick-demo::-webkit-scrollbar, .feature-demo::-webkit-scrollbar { display: none; }
/* The Proof Vault lived behind an unlabeled shield icon; the label makes
   the headline feature findable. */
#vault-btn { width: auto; padding: 0 12px; gap: 6px; }
/* Header actions: Settings + Vault sit in one glued group, so the
   two buttons stay adjacent instead of spread apart by space-between. */
.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.vault-label { font-size: 0.85rem; font-weight: 600; }

/* Marketplace fallback photo (eBay sandbox listings have no image):
   a generic category illustration, rendered slightly muted. */
.mp-fallback-img { filter: saturate(0.6); opacity: 0.85; }
/* Composer: input + send, pinned to the bottom. */
.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.composer input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
}
.composer input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 2px rgba(0, 112, 186, 0.25); }

.fineprint {
  margin: 0;
  padding: 0.4rem 1rem 0.6rem;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}

@media (max-width: 480px) {
  .msg { max-width: 94%; }
  .cards { grid-template-columns: 1fr; }
  .sandbox-badge { display: none; }
  /* Compact horizontal product cards: thumbnail left, info right, so the
     catalog reads as a list instead of a stack of full-screen photos. */
  .product-card { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem; text-align: left; }
  .product-card img { width: 88px; height: 88px; flex: none; border-radius: 8px; aspect-ratio: 1 / 1; }
  .product-card .card-body { padding: 0; flex: 1; min-width: 0; }
  .product-card .card-score { float: none; margin-left: 0.3rem; }
  .toast-root { right: 0.5rem; left: 0.5rem; bottom: 0.5rem; max-width: none; }
}

/* ==========================================================================
   MODERN AI CHAT UI (DESKTOP + MOBILE) - SHOPPAL V2
   (Replaced the previous override 9 Nov 2026 ~08:35 WITA with the user's
   v2 CSS, adapted to the project's real selectors: the header uses
   h1.agent-name + div.agent-status (not strong/span), product cards use
   .card-body > strong / .price / .seller (not .card-title/.card-price/
   .card-meta), #ask is the input (class .chat-input), #ask-btn is the
   send button (class .send-btn), the composer is wrapped in
   <form class="composer-form" id="chat-form">.)
   ========================================================================== */

:root {
    --bg-canvas: #f8fafc;
    --surface-card: #ffffff;
    --navy-primary: #0b2545;
    --navy-hover: #133b6e;
    --border-subtle: #e2e8f0;
    --text-main: #0f172a;
    --text-secondary: #475569;
}

body {
    background-color: var(--bg-canvas);
    color: var(--text-main);
    margin: 0;
    overflow: hidden;
}

/* 1. App Shell Full-Viewport */
.app {
    max-width: 100% !important;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 2. Header Rapi & Tidak Terpotong di Mobile maupun Desktop */
.chat-header {
    min-height: 60px;
    height: auto !important;
    padding: 0.5rem 1.25rem !important;
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(12px);
    border: none !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    border-radius: 0 !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-shrink: 0;
    z-index: 30;
    /* The header was navy with white text; the new glass header is white,
       so the identity text and the pills need dark colours. */
    color: var(--text-main) !important;
    box-shadow: none !important;
}

/* Pulsing green dot on the header status pills (Online). */
@keyframes pulse-dot {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.chat-header .live-badge,
.chat-header .sandbox-badge {
    border-color: #cbd5e1 !important;
    color: var(--text-secondary) !important;
}
.chat-header .live-badge .dot,
.chat-header .agent-status .dot {
    animation: pulse-dot 2s infinite;
}

.agent-id {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

/* Real markup: h1.agent-name + div.agent-status (not strong/span). */
.agent-name {
    display: block;
    font-size: 1.05rem !important;
    line-height: 1.2;
    color: var(--text-main);
    margin: 0 !important;
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.76rem !important;
    line-height: 1.2;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* 3. Layout: single column at every width. (An unconditional
   2-column grid used to squeeze the chat on 921-1023px viewports, e.g. a
   phone in desktop mode; the sidebar that caused it is gone.) */
.layout {
    display: flex;
    flex-direction: column;
    gap: 0 !important;
    margin-top: 0 !important;
    padding: 0 !important;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chat-col {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--bg-canvas);
    position: relative;
    overflow: hidden;
    /* The desktop media query styled .chat-col as a bordered card; the
       modern shell is a flat panel. */
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.chat {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scroll-behavior: smooth;
    width: 100%;
    max-width: 840px;
    margin: 0 auto;
    padding: 1.15rem 1rem 1rem !important;
    display: flex;
    flex-direction: column;
    gap: 0.85rem !important;
}

/* 4. Bubble Chat Modern */
@keyframes msgSlideIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg {
    animation: msgSlideIn 0.2s ease-out;
    line-height: 1.5 !important;
}

.msg.user {
    background: linear-gradient(135deg, #0b2545 0%, #163e6c 100%) !important;
    color: #ffffff !important;
    align-self: flex-end !important;
    max-width: 78% !important;
    padding: 0.7rem 1.05rem !important;
    border-radius: 20px 20px 4px 20px !important;
    box-shadow: 0 3px 10px rgba(11, 37, 69, 0.14);
    font-weight: 500;
}

.msg.agent {
    background: var(--surface-card) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 16px !important;
    padding: 1rem 1.1rem !important;
    max-width: 100% !important;
    width: 100%;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}

.msg-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--navy-primary) !important;
    margin-bottom: 0.4rem !important;
}

.msg-label::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #10b981;
}

/* 5. Product Cards & WCAG Contrast Fix */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)) !important;
    gap: 0.75rem !important;
    margin-top: 0.65rem !important;
}

button.product-card,
button.product-card:hover,
button.product-card:focus,
button.product-card:active,
button.product-card.selected {
    background-color: #ffffff !important;
    color: var(--text-main) !important;
    border-radius: 14px !important;
    padding: 0.75rem !important;
    border: 1px solid var(--border-subtle) !important;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease !important;
}

button.product-card:hover {
    transform: translateY(-2px);
    border-color: #94a3b8 !important;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

button.product-card:focus-visible,
button.product-card:active,
button.product-card.selected {
    background-color: #eff6ff !important;
    border: 2px solid var(--navy-primary) !important;
    box-shadow: 0 6px 16px rgba(11, 37, 69, 0.12) !important;
}

/* Real card internals: .card-body > strong (title), .price, .seller. */
button.product-card .card-body strong {
    color: var(--text-main) !important;
    font-weight: 600;
    font-size: 0.88rem;
}

button.product-card .price {
    color: var(--navy-primary) !important;
    font-weight: 700;
    font-size: 0.95rem;
    margin: 0.15rem 0;
}

button.product-card .seller {
    color: var(--text-secondary) !important;
    font-size: 0.75rem;
}

/* One-tap buy: each card sits in a cell with a Buy button under it
   (a button cannot contain a button, so the Buy button is a sibling). */
.product-cell {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.product-cell .product-card {
    flex: 1;
}
/* Catalog toggle: the product list starts collapsed behind a button, so
   the greeting stays short and the photos only load when browsed. */
.catalog-toggle {
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  width: 100%; max-width: 840px; margin: 0.5rem auto 0;
  padding: 0.6rem 1rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer;
}
.catalog-toggle .chev { transition: transform 0.2s ease; flex: none; }
.catalog-toggle.open .chev { transform: rotate(180deg); }
.catalog-toggle:hover { background: var(--bg); }
.catalog-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.card-buy {
    width: 100%;
    min-height: 38px;
    border-radius: 10px;
    background: transparent;
    color: var(--navy);
    font-weight: 600;
    font-size: 0.85rem;
    border: 1px solid var(--border-strong);
    cursor: pointer;
}
.card-buy:hover {
    background: #e8eef7;
    border-color: var(--navy);
}
.card-buy:disabled {
    opacity: 0.55;
}

/* 6. Bottom Composer & Quick Demo Chips */
.quick-demo {
    width: 100%;
    max-width: 840px;
    margin: 0 auto;
    padding: 0.35rem 1rem !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    gap: 0.45rem !important;
    scrollbar-width: none;
    flex-shrink: 0;
    background: transparent !important;
    border-top: none !important;
}

.quick-demo::-webkit-scrollbar {
    display: none;
}
.chip {
    white-space: nowrap;
    background: #ffffff !important;
    color: var(--text-main) !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 999px !important;
    padding: 0.38rem 0.8rem !important;
    font-size: 0.8rem !important;
    font-weight: 500;
}

.composer {
    width: 100%;
    max-width: 840px;
    margin: 0 auto;
    padding: 0.25rem 1rem 0.65rem !important;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-shrink: 0;
    background: transparent !important;
    border-top: none !important;
}

.composer-form {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 28px;
    padding: 0.3rem 0.4rem 0.3rem 1rem;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
    display: flex;
    align-items: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.composer-form:focus-within {
    border-color: var(--navy-primary);
    box-shadow: 0 6px 24px rgba(11, 37, 69, 0.16);
}

.chat-input {
    flex: 1;
    min-width: 0;
    border: none !important;
    background: transparent !important;
    padding: 0.45rem 0.4rem !important;
    font-size: 0.92rem !important;
    color: var(--text-main) !important;
}

/* The old .composer input:focus ring would double with the form's
   :focus-within ring, so the input itself stays ring-free. */
#ask:focus {
    outline: none !important;
    box-shadow: none !important;
}

.send-btn {
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    background: var(--navy-primary) !important;
    color: #ffffff !important;
    flex-shrink: 0;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.send-btn:disabled {
    opacity: 0.55 !important;
}

.send-btn:hover {
    background: var(--navy-hover) !important;
    transform: scale(1.04);
}

/* The fineprint sits under the floating composer; keep it subtle and
   transparent so it reads as part of the bottom bar. */
.fineprint {
    background: transparent !important;
}

/* (The right sidebar was removed: its cards duplicated the header
   badges. The layout is one column at every width.) */

/* Demo chips stay one horizontal scroll row at every width. (An older
   rule wrapped them into rows above 921px; the user asked 10 Nov 2026
   to tidy the layout because the rows filled the screen.) */

/* Below 1100px the long header pills overflow and overlap the
   identity (seen at 980-1024px). Keep only the compact Live badge. */
@media (max-width: 1100px) {
    #health-badge,
    .header-badges .sandbox-badge:not(#live-status) {
        display: none !important;
    }
}

.side-card {
    background: #f8fafc !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 14px !important;
    padding: 1rem !important;
}

/* Vault tools drawer: the vault bubble is long, so it can collapse to a
   single toggle (collapsed by default on phones, expanded on desktop). */
.vault-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.35rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--navy-primary);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    cursor: pointer;
}

.msg.agent[data-step="vault"].vault-collapsed > :not(.msg-label):not(.vault-toggle) {
    display: none !important;
}

/* ==========================================================================
   8. KHUSUS LAYAR MOBILE (<= 920px): GAYA APLIKASI CHAT AI MOBILE
   ========================================================================== */
@media (max-width: 920px) {
    /* Pertahankan 100dvh agar input chat selalu terkunci di bawah layar HP
       (round sebelumnya pakai height:auto di sini dan composer terdorong
       ke bawah halaman sampai hilang dari layar pertama). */
    body, .app {
        height: 100dvh !important;
        max-height: 100dvh !important;
        overflow: hidden !important;
    }

    .chat-header {
        padding: 0.5rem 0.85rem !important;
        min-height: 54px;
    }

    /* Avatar lebih kecil di HP agar header muat dalam 54px. */
    .chat-header .avatar {
        width: 36px !important;
        height: 36px !important;
    }

    /* Sembunyikan badge panjang di header mobile agar tidak sempit */
    #health-badge,
    .header-badges .sandbox-badge:not(#live-status) {
        display: none !important;
    }

    .layout {
        display: flex !important;
        flex-direction: column !important;
        /* flex:1 mengisi sisa ruang di bawah header apa pun tingginya;
           calc(100dvh - 54px) rapuh bila header tumbuh di atas 54px. */
        flex: 1 !important;
        min-height: 0 !important;
        height: auto !important;
        overflow: hidden !important;
    }

    .chat-col {
        flex: 1 !important;
        height: 100% !important;
        min-width: 0;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .chat {
        flex: 1 !important;
        min-width: 0;
        overflow-y: auto !important;
        padding: 0.75rem 0.75rem 0.5rem !important;
        gap: 0.65rem !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Perkecil kartu greeting & chip di mobile */
    .msg.agent {
        padding: 0.85rem 0.95rem !important;
        border-radius: 14px !important;
        font-size: 0.88rem !important;
    }

    .chips {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 0.4rem !important;
        padding-bottom: 0.25rem;
        scrollbar-width: none;
    }

    .chips::-webkit-scrollbar {
        display: none;
    }

    /* Ubah katalog produk menjadi Horizontal Swipe Carousel di layar HP! */
    #catalog.cards {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory;
        gap: 0.65rem !important;
        padding: 0.25rem 0.1rem 0.5rem !important;
        -webkit-overflow-scrolling: touch;
    }

    #catalog.cards .product-cell {
        flex: 0 0 235px !important;
        width: 235px !important;
        scroll-snap-align: start;
    }

    #catalog.cards button.product-card {
        padding: 0.65rem !important;
    }

    /* Thumbnail kompak 56px di kiri (layout horizontal bawaan <=480px),
       agar kartu carousel tetap ramping. */
    #catalog.cards button.product-card img {
        width: 56px !important;
        height: 56px !important;
    }

    /* Kunci Quick Demo & Input Chat di bagian bawah layar HP */
    .quick-demo {
        padding: 0.3rem 0.75rem !important;
        background: rgba(248, 250, 252, 0.96);
        border-top: 1px solid rgba(226, 232, 240, 0.7);
    }

    .composer {
        padding: 0.2rem 0.75rem 0.55rem !important;
        background: rgba(248, 250, 252, 0.98);
    }

    /* Sembunyikan fineprint panjang di mobile agar input bar lebih lega */
    .fineprint {
        display: none !important;
    }
}

/* --- Skeleton loader: shimmer placeholder while the agent searches --- */
/* Shown in place of the typing dots on Ask/search flows; it previews the
   results layout (title line + product-card grid) so the wait feels shorter.
   The bubble is aria-hidden and never saved to chat history (see
   saveChatHistory, which strips .skeleton-msg). */
.skeleton-msg {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0.5rem 0 !important;
}
.skeleton-msg .cards {
    margin-top: 0.6rem;
}
.skeleton-line {
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-title {
    width: 55%;
    height: 14px;
}
.skeleton-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.skeleton-img {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 8px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-card .skeleton-line {
    width: 90%;
}
.skeleton-card .skeleton-short {
    width: 55%;
}
@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .skeleton-line,
    .skeleton-img {
        animation: none;
    }
}

/* Mobile: the skeleton previews the catalog carousel (same 235px cards,
   horizontal snap scroll), so the results do not jump in height when
   they replace it. */
@media (max-width: 920px) {
    .skeleton-msg .cards {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
    }
    .skeleton-msg .skeleton-card {
        flex: 0 0 235px;
        width: 235px;
        scroll-snap-align: start;
    }
}

/* Settings modal (gear in the header): one place for language, monthly
   budget, smart guardrails, and chat data. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.modal-overlay.hidden { display: none; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 43, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}
.modal {
  background: var(--surface);
  color: var(--ink);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.1rem 1.2rem 1.3rem;
  box-shadow: 0 12px 40px rgba(11, 19, 43, 0.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
/* Desktop: the modal is wider, so it does not sit as a narrow strip in
   the middle of a wide screen. Phones keep the full-width bottom sheet
   from the <=920px block below. */
@media (min-width: 921px) {
  .modal { max-width: 840px; }
}
.modal-head h2 { margin: 0; font-size: 1.25rem; }
.modal-body { margin-top: 0.5rem; }
.set-section { padding: 0.9rem 0; border-top: 1px solid var(--border); }
.set-section:first-child { border-top: none; padding-top: 0.4rem; }
.set-section h3 { margin: 0 0 0.6rem; font-size: 1rem; }
.set-section p { margin: 0.45rem 0; }
.modal-body input[type="number"] {
  width: 110px;
  min-height: 44px;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--surface);
  color: var(--ink);
}
.modal-body button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
/* Settings form rows: the input takes the free width so its placeholder
   never truncates, the Save button sits beside it, and the saved
   confirmation drops to its own line. */
.set-row { display: flex; gap: 0.5rem; align-items: center; }
.set-row input[type="number"] { flex: 1; min-width: 0; width: auto; }
.set-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin: 0.45rem 0 0.3rem; }
.set-status { font-size: 0.85rem; color: var(--muted); }
.set-status:empty { display: none; }
body.modal-open { overflow: hidden; }
.quick-chip { display: inline-flex; align-items: center; gap: 0.4rem; }
.chip-ico { flex: none; }
.send-btn svg { display: block; transform: translate(-1px, 1.5px); }
/* Proof Vault button + count badge (header). The vault lives in a modal
   now, not in the chat, so the button shows how many proofs are saved. */
#vault-btn { position: relative; }
/* Header declutter (mobile): the "Live · Sandbox" pill shrinks to just
   "Live", and the status line truncates instead of colliding with it. */
.agent-id > div { min-width: 0; }
.agent-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 920px) {
  .live-badge-extra { display: none; }
}
@media (max-width: 920px) {
  .agent-status-text { display: none; }
}
.vault-count {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--navy-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
@media (max-width: 920px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 85dvh; }
}

/* Bottom navigation: mobile only (<= 920px). One-tap reach for the four
   headline tools plus Chat: the same actions as the Try chips above the
   composer, placed where the thumb already rests. Desktop keeps the
   header and chips and never shows this bar. */
.bottom-nav { display: none; }
@media (max-width: 920px) {
  .bottom-nav {
    display: flex;
    flex: 0 0 auto;
    height: calc(60px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.06);
  }
  .nav-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 60px;
    padding: 6px 2px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.1;
    cursor: pointer;
  }
  .nav-btn svg { width: 22px; height: 22px; }
  .nav-btn.active { color: var(--blue); }
  /* The Try row duplicates the bottom nav, and the fineprint squeezes
     the composer away from it, so both hide while the nav shows. */
  .feature-demo { display: none; }
  .fineprint { display: none; }
}
