:root {
  --primary: #6d28d9;
  --primary-dark: #5b21b6;
  --bg: #faf9fc;
  --card: #ffffff;
  --border: #e7e3ef;
  --text: #1c1530;
  --muted: #6b6480;
  --deal: #16a34a;
  --danger: #dc2626;
  --radius: 16px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem; max-width: 960px; margin: 0 auto;
}
.brand { font-weight: 800; font-size: 1.25rem; color: var(--text); }
.brand span { color: var(--primary); }
.nav-right { display: flex; gap: 1rem; align-items: center; }

.container { max-width: 960px; margin: 0 auto; padding: 1rem 1.5rem 4rem; }

/* Buttons */
.btn, .btn-outline {
  display: inline-block; padding: 0.75rem 1.4rem; border-radius: 12px;
  font-weight: 600; cursor: pointer; border: 1px solid transparent; font-size: 1rem;
}
.btn { background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--border); }
.btn-outline:hover { background: #f3f0fb; text-decoration: none; }
.btn.full, button.full { width: 100%; }
.btn.small, .btn-outline.small { padding: 0.45rem 0.9rem; font-size: 0.85rem; }
button { font-family: inherit; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }

/* Hero */
.hero { text-align: center; padding: 2.5rem 0; }
.hero-badge {
  width: 84px; height: 84px; border-radius: 24px; background: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 2.4rem;
  margin: 0 auto 1.5rem; box-shadow: 0 12px 30px rgba(109,40,217,.25);
}
.hero h1 { font-size: 3rem; margin: 0 0 1rem; line-height: 1.1; }
.hero h1 span { color: var(--primary); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 560px; margin: 0 auto 2rem; }
.cta-row { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem; margin-top: 3rem; text-align: left;
}
.feature h3 { margin: 0.5rem 0 0.25rem; font-size: 1rem; }
.feature p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.feature-icon {
  width: 42px; height: 42px; border-radius: 12px; background: #f3f0fb;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}

/* Forms */
.auth-card, .form-card { max-width: 460px; margin: 2rem auto; }
.form-card { max-width: 620px; }
label { display: block; margin: 1rem 0 0; font-weight: 600; font-size: 0.9rem; }
input, select, textarea {
  width: 100%; margin-top: 0.4rem; padding: 0.7rem 0.85rem; border-radius: 10px;
  border: 1px solid var(--border); font-size: 1rem; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
form button { margin-top: 1.5rem; }

/* Flash */
.flash { padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash.error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.flash:not(.error) { background: #f0fdf4; color: var(--deal); border: 1px solid #bbf7d0; }

/* Results */
.results-head { margin-bottom: 1.5rem; }
.results-head h2 { margin: 0; }
.prefs-card { padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.chip { font-size: 0.78rem; padding: 0.25rem 0.6rem; border-radius: 999px; font-weight: 600; }
.chip.outsole { background: #ede9fe; color: var(--primary-dark); }
.chip.material { background: #e0f2fe; color: #0369a1; }
.chip.attr { background: #fef3c7; color: #92400e; }

.shoe-list { display: flex; flex-direction: column; gap: 1rem; }
.shoe { display: flex; gap: 1.25rem; padding: 1rem; }
.shoe.deal { border-color: var(--deal); box-shadow: 0 0 0 1px var(--deal); }
.shoe-img { flex-shrink: 0; width: 110px; height: 110px; border-radius: 12px; overflow: hidden; background: #f3f0fb; display: flex; align-items: center; justify-content: center; }
.shoe-img img { width: 100%; height: 100%; object-fit: contain; }
.img-placeholder { font-size: 2.5rem; }
.shoe-body { flex: 1; min-width: 0; }
.shoe-top { display: flex; justify-content: space-between; gap: 1rem; }
.shoe-top h3 { margin: 0; font-size: 1.05rem; }
.score-badge {
  flex-shrink: 0; text-align: center; background: var(--primary); color: #fff;
  border-radius: 12px; padding: 0.4rem 0.7rem; font-weight: 800; font-size: 1.2rem; line-height: 1;
}
.score-badge span { display: block; font-size: 0.6rem; font-weight: 600; opacity: 0.85; margin-top: 2px; }
.shoe-meta { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 0.6rem 0; }
.price { font-weight: 800; font-size: 1.15rem; }
.deal-flag { color: var(--deal); font-weight: 700; font-size: 0.85rem; }
.ok-flag { color: var(--deal); font-size: 0.8rem; }
.reasons { margin: 0.5rem 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.85rem; }
.reasons li { margin: 0.15rem 0; }

.savings { color: var(--deal); font-weight: 700; font-size: 0.9rem; margin: 0.25rem 0; }
.offers { margin-top: 0.5rem; }
.offers summary { cursor: pointer; color: var(--primary); font-size: 0.85rem; font-weight: 600; }
.offers ul { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.offers li {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0;
  border-top: 1px solid var(--border); font-size: 0.85rem;
}
.offer-seller { flex: 1; font-weight: 600; }
.offer-price { font-weight: 800; }

/* Utility */
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
code { background: #f3f0fb; padding: 0.1rem 0.35rem; border-radius: 5px; font-size: 0.85em; }

/* Foot-scan upload (questionnaire) */
.foot-scan {
  margin-top: 1.5rem; border: 1px dashed var(--border); border-radius: 12px;
  padding: 1rem 1.25rem 1.25rem;
}
.foot-scan legend { font-weight: 700; font-size: 0.95rem; padding: 0 0.4rem; }
.foot-scan p { margin: 0.25rem 0 0.75rem; }
.file-label input[type="file"] {
  padding: 0.5rem; font-size: 0.85rem; background: #faf9fc;
}

/* Foot-profile card (results) */
.foot-card { padding: 1rem 1.25rem; margin-bottom: 1.5rem; }
.foot-traits { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.6rem 0; }
.foot-trait {
  background: #f3f0fb; border-radius: 10px; padding: 0.45rem 0.75rem;
  font-weight: 700; font-size: 0.95rem; display: flex; flex-direction: column;
}
.foot-trait em { font-style: normal; font-weight: 600; font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

/* Chat widget */
.chat-launcher {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 60;
  width: 56px; height: 56px; border-radius: 50%; background: var(--primary);
  border: none; padding: 0; color: #fff; font-size: 1.6rem; font-family: inherit;
  display: flex; align-items: center; justify-content: center; line-height: 1;
  cursor: pointer; box-shadow: 0 10px 26px rgba(109,40,217,.4); user-select: none;
}
.chat-launcher:hover { background: var(--primary-dark); }
.chat-launcher.open { font-size: 1.4rem; }
.chat-panel {
  position: fixed; right: 1.25rem; bottom: 5.5rem; z-index: 50;
  width: min(360px, calc(100vw - 2.5rem)); height: min(520px, calc(100vh - 8rem));
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 48px rgba(28,21,48,.22);
}
/* The [hidden] attribute must win over display:flex above, or the panel can't close. */
.chat-panel[hidden] { display: none; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1rem; background: var(--primary); color: #fff; font-weight: 700;
}
.chat-close { background: none; border: none; color: #fff; font-size: 1.4rem; cursor: pointer; line-height: 1; padding: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.chat-msg {
  max-width: 85%; padding: 0.6rem 0.85rem; border-radius: 14px; font-size: 0.9rem;
  white-space: pre-wrap; word-wrap: break-word;
}
.chat-msg.bot { align-self: flex-start; background: #f3f0fb; color: var(--text); border-bottom-left-radius: 4px; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-form { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--border); }
.chat-form input { margin-top: 0; }
.chat-form .btn { padding: 0.7rem 1rem; }

@media (max-width: 560px) {
  .hero h1 { font-size: 2.2rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .shoe { flex-direction: column; }
  .shoe-img { width: 100%; height: 160px; }
}
