:root {
  --jbl: #FF6A00;
  --jbl-dark: #E65F00;
  --jbl-soft: #FFF1E8;
  --ink: #141414;
  --muted: #6B6B6B;
  --line: #ECECEC;
  --bg: #FAFAFA;
  --card: #FFFFFF;
  --user: #141414;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
.app { display: flex; flex-direction: column; height: 100dvh; max-width: 720px; margin: 0 auto; background: var(--bg); position: relative; }

/* ------------------------------------------------------------ cabecera */
.top { display: flex; align-items: center; justify-content: space-between; padding: max(10px, env(safe-area-inset-top)) 14px 8px; background: #fff; border-bottom: 1px solid var(--line); position: relative; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .jbl { height: 26px; width: auto; }
.titles .title { font-weight: 700; font-size: 16px; letter-spacing: .01em; }
.titles .subtitle { font-size: 12px; color: var(--muted); }
.icon-btn { border: 0; background: transparent; color: var(--ink); font-size: 22px; line-height: 1; padding: 6px 8px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: #f2f2f2; }
.menu { position: absolute; right: 12px; top: 52px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(0,0,0,.12); padding: 6px; z-index: 20; min-width: 230px; }
.menu button { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 14px; cursor: pointer; }
.menu button:hover { background: var(--jbl-soft); }

/* ------------------------------------------------------------ etapas */
.stages { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.stage { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.stage .dot { width: 10px; height: 10px; border-radius: 50%; background: #D9D9D9; transition: background .3s, box-shadow .3s; }
.stage.done .dot { background: var(--jbl); }
.stage.active { color: var(--ink); }
.stage.active .dot { background: var(--jbl); box-shadow: 0 0 0 4px rgba(255,106,0,.18); }
.stages .line { flex: 1; height: 2px; background: var(--line); border-radius: 2px; }

/* ------------------------------------------------------------ mensajes */
.messages { flex: 1; overflow-y: auto; padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.msg { max-width: 86%; display: flex; flex-direction: column; gap: 6px; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg.system { align-self: center; max-width: 100%; }
.bubble { padding: 10px 14px; border-radius: var(--radius); line-height: 1.42; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user .bubble { background: var(--user); color: #fff; border-bottom-right-radius: 6px; }
.msg.assistant .bubble { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.bubble a { color: var(--jbl-dark); font-weight: 600; text-decoration: none; }
.bubble b { font-weight: 700; }
.bubble ol, .bubble ul { margin: 6px 0 0 18px; padding: 0; }
.bubble li { margin: 3px 0; }
.msg.user .photo-thumb { max-width: 200px; border-radius: 14px; border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.divider { font-size: 12px; color: var(--muted); background: #EFEFEF; padding: 4px 12px; border-radius: 999px; margin: 6px 0; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 6px 12px; }
.status .spin { width: 14px; height: 14px; border: 2px solid #ddd; border-top-color: var(--jbl); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 7px; height: 7px; background: #C9C9C9; border-radius: 50%; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* ------------------------------------------------------------ tarjetas */
.cards { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; max-width: 100%; scroll-snap-type: x mandatory; }
.cards::-webkit-scrollbar { display: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.card.product { flex: 0 0 250px; scroll-snap-align: start; }
.card.product .thumb { background: #F4F4F4; height: 160px; display: flex; align-items: center; justify-content: center; }
.card.product .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: 10px 12px 12px; }
.card .badge { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; background: var(--jbl); padding: 3px 8px; border-radius: 999px; margin-bottom: 6px; }
.card .badge:empty { display: none; }
.card h3 { margin: 0; font-size: 16px; }
.card .cat { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.card .specs { margin: 0 0 10px 16px; padding: 0; font-size: 13px; color: #333; }
.card .specs li { margin: 2px 0; }
.card .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; padding: 7px 10px; border-radius: 999px; cursor: pointer; }
.btn.primary { background: var(--jbl); border-color: var(--jbl); color: #fff; }
.btn:hover { filter: brightness(.97); }
.stores { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.stores a { font-size: 12px; font-weight: 600; color: var(--jbl-dark); background: var(--jbl-soft); padding: 5px 10px; border-radius: 999px; text-decoration: none; }

.card.image { max-width: 320px; }
.card.image img { width: 100%; display: block; }
.card.image .caption { padding: 8px 12px; font-size: 12px; color: var(--muted); }
.card.image .caption b { color: var(--ink); }

.card.reward { max-width: 320px; border: 0; background: linear-gradient(135deg, #FF6A00, #FF8F3F); color: #fff; }
.card.reward .body { padding: 14px 16px 16px; }
.card.reward .eyebrow { font-size: 12px; opacity: .9; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.card.reward .code { font-size: 24px; font-weight: 800; letter-spacing: .06em; margin: 6px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.card.reward .desc { font-size: 13px; opacity: .95; }
.card.reward .meta { font-size: 12px; opacity: .85; margin-top: 8px; }

.card.guide { max-width: 340px; }
.card.guide h3 { font-size: 15px; margin: 0 0 8px; }
.card.guide ol { margin: 0 0 0 18px; padding: 0; font-size: 14px; }
.card.guide li { margin: 6px 0; }
.card.guide li label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.card.guide li input { margin-top: 3px; accent-color: var(--jbl); }
.card.guide li.done label { color: var(--muted); text-decoration: line-through; }

/* ------------------------------------------------------------ chips y composer */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 12px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 13px; padding: 7px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.chip:hover { background: var(--jbl-soft); border-color: #FFD1B3; }
.composer { display: flex; align-items: center; gap: 8px; padding: 8px 12px max(10px, env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid var(--line); }
.composer .photo { color: var(--muted); }
.composer input[type=text] { flex: 1; border: 1px solid var(--line); background: #F6F6F6; border-radius: 999px; padding: 11px 14px; font: inherit; font-size: 15px; outline: none; }
.composer input[type=text]:focus { border-color: #FFC49A; background: #fff; }
.composer .send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--jbl); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.composer .send:disabled { opacity: .5; cursor: default; }

.toast { position: absolute; left: 50%; bottom: 90px; transform: translateX(-50%); background: #222; color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 13px; z-index: 30; box-shadow: 0 6px 18px rgba(0,0,0,.2); }

@media (min-width: 720px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .msg { max-width: 78%; }
}
