:root {
  --navy: #0f1b2d;
  --navy-2: #1a2a44;
  --ivory: #faf7f0;
  --paper: #ffffff;
  --sage: #a8be78;
  --sage-dark: #5f7a35;
  --sage-soft: #eef3e1;
  --ink: #1b2432;
  --grey: #6b7280;
  --line: #e4e0d6;
  --warn: #b45309;
  --warn-soft: #fbf0dd;
  --bad: #b42318;
  --bad-soft: #fbe9e7;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 2px 8px rgba(15, 27, 45, .05);
  --radius: 10px;
  --nav-h: 62px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ivory); color: var(--ink); font-size: 16px; line-height: 1.45; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
a { color: var(--navy); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--sage-dark); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* splash */
.splash { position: fixed; inset: 0; background: var(--navy); color: var(--ivory); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; z-index: 50; transition: opacity .3s; }
.splash.done { opacity: 0; pointer-events: none; }
.splash-logo { border-radius: 20px; margin-bottom: 10px; }
.splash-name { font-size: 28px; font-weight: 700; }
.splash-tag { margin: 0 0 18px; color: #c8d0dc; font-size: 15px; }
.splash-ver { position: absolute; bottom: 24px; margin: 0; font-size: 12px; color: #8f9bb0; }
.spinner { width: 22px; height: 22px; border: 2px solid #34445f; border-top-color: var(--sage); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } * { transition: none !important; } }

/* shell */
.hdr { position: sticky; top: 0; z-index: 10; background: var(--navy); color: var(--ivory); padding-top: env(safe-area-inset-top); }
.hdr-in { max-width: 980px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ivory); font-weight: 700; font-size: 18px; margin-right: auto; }
.brand img { border-radius: 7px; }
.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: transparent; border: 0; color: var(--ivory); text-decoration: none; }
.icon-btn:hover { background: var(--navy-2); }
.icon-btn svg { width: 22px; height: 22px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--sage); color: var(--navy); font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.dot { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--sage); border: 2px solid var(--navy); }

main { max-width: 980px; margin: 0 auto; padding: 18px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--paper); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.nav-in { max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--nav-h); text-decoration: none; color: var(--grey); font-size: 11.5px; font-weight: 500; }
.nav a svg { width: 22px; height: 22px; }
.nav a[aria-current="page"] { color: var(--navy); font-weight: 700; }
.nav a[aria-current="page"] svg { color: var(--sage-dark); }

/* type + layout */
.page-title { font-size: 24px; margin-bottom: 4px; }
.sub { color: var(--grey); margin: 0 0 16px; font-size: 15px; }
.section { margin-top: 26px; }
.section-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.section-h h2 { font-size: 17px; }
.section-h a { font-size: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, 1fr); } .grid.two { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid.deals { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px; }
.muted { color: var(--grey); }
.small { font-size: 13px; }

/* discovery cards */
.engine { display: block; text-decoration: none; color: inherit; padding: 18px; min-height: 124px; }
.engine.dark { background: var(--navy); color: var(--ivory); border-color: var(--navy); }
.engine h3 { font-size: 18px; margin-bottom: 4px; }
.engine p { margin: 0; font-size: 14px; opacity: .85; }
.engine .count { display: inline-block; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--sage-dark); }
.engine.dark .count { color: var(--sage); }

/* deal card */
.deal { display: flex; flex-direction: column; overflow: hidden; }
.deal-img { aspect-ratio: 16 / 9; background: var(--sage-soft); display: grid; place-items: center; color: var(--sage-dark); position: relative; overflow: hidden; }
.deal-img img { width: 100%; height: 100%; object-fit: cover; }
.deal-img svg { width: 44px; height: 44px; opacity: .6; }
.deal-flag { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.deal-body { padding: 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.retailer { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--grey); font-weight: 600; }
.deal h3 { font-size: 16px; font-weight: 600; letter-spacing: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.4em; }
.price-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price { font-size: 22px; font-weight: 700; }
.was { color: var(--grey); text-decoration: line-through; font-size: 14px; }
.off { font-size: 13px; font-weight: 700; color: var(--sage-dark); background: var(--sage-soft); padding: 2px 7px; border-radius: 5px; }
.off.big { background: var(--navy); color: var(--sage); }
.meta { font-size: 12.5px; color: var(--grey); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.deal-foot { display: flex; gap: 8px; margin-top: auto; padding-top: 10px; }

.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); white-space: nowrap; }
.badge.demo { background: var(--warn-soft); border-color: #ecd6a8; color: var(--warn); }
.badge.verified { background: var(--sage-soft); border-color: #cfdcae; color: var(--sage-dark); }
.badge.retailer { background: #e9eef7; border-color: #cdd8ec; color: #2d4670; }
.badge.neutral { color: var(--grey); }
.badge.upcoming { background: #e9eef7; color: #2d4670; border-color: #cdd8ec; }
.badge.expired { background: #f0eee8; color: var(--grey); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #f1c7c1; }
.deal.is-expired { opacity: .72; }

/* buttons + forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: var(--ivory); font-weight: 600; font-size: 15px; text-decoration: none; }
.btn:hover { background: var(--navy-2); }
.btn.secondary { background: var(--paper); color: var(--navy); border-color: var(--line); }
.btn.secondary:hover { background: var(--sage-soft); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn.grow { flex: 1; }
.btn svg { width: 18px; height: 18px; }
.save-btn[aria-pressed="true"] { background: var(--sage-soft); border-color: var(--sage); color: var(--sage-dark); }

label.field { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
label.field > span { display: block; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid #cfcabd; border-radius: 8px; background: var(--paper); font-weight: 400; }
input:focus, select:focus { border-color: var(--sage-dark); }
.hint { font-size: 13px; color: var(--grey); font-weight: 400; margin-top: 4px; }
.error { background: var(--bad-soft); color: var(--bad); border: 1px solid #f1c7c1; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.notice { background: var(--warn-soft); color: #7a4a0a; border: 1px solid #ecd6a8; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.info { background: var(--sage-soft); border: 1px solid #d5e0b8; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 7px 13px; font-size: 14px; min-height: 38px; }
.chip[aria-pressed="true"] { background: var(--navy); color: var(--ivory); border-color: var(--navy); }
.seg { display: flex; background: #efebe0; padding: 3px; border-radius: 10px; gap: 2px; margin-bottom: 16px; overflow-x: auto; }
.seg a, .seg button { flex: 1; text-align: center; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--grey); font-weight: 600; font-size: 14px; border: 0; background: transparent; white-space: nowrap; }
.seg [aria-current="true"], .seg [aria-current="page"] { background: var(--paper); color: var(--navy); box-shadow: var(--shadow); }

/* toggles + sliders */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switch:last-child { border-bottom: 0; }
.switch small { display: block; color: var(--grey); font-size: 13px; }
.tg { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: #cfcabd; position: relative; flex: none; border: 0; transition: background .15s; }
.tg::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.tg:checked { background: var(--sage-dark); }
.tg:checked::after { transform: translateX(18px); }
input[type=range] { width: 100%; accent-color: var(--sage-dark); height: 28px; }
.range-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* lists */
.list-item { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-weight: 600; text-align: right; }
.empty { text-align: center; padding: 34px 20px; color: var(--grey); }
.empty h3 { color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.empty p { margin: 0 auto; max-width: 380px; font-size: 15px; }
.skeleton { background: linear-gradient(90deg, #efebe0, #f7f4ea, #efebe0); background-size: 200% 100%; animation: sh 1.4s infinite; border-radius: var(--radius); height: 260px; }
@keyframes sh { to { background-position: -200% 0; } }

.health { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; }
.health > div { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.health > div:nth-child(odd) { border-right: 1px solid var(--line); }
.health > div:nth-last-child(-n+2) { border-bottom: 0; }
.health span { display: block; font-size: 12px; color: var(--grey); text-transform: uppercase; letter-spacing: .05em; }
.health b { font-size: 15px; }

.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; max-width: 420px; margin: 0 auto; padding: 24px 16px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head img { border-radius: 16px; }
.auth-head h1 { font-size: 26px; margin-top: 10px; }
.auth-head p { margin: 4px 0 0; color: var(--grey); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); background: var(--navy); color: var(--ivory); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 60; max-width: 90vw; box-shadow: var(--shadow); }
.legal h2 { font-size: 17px; margin: 20px 0 6px; }
.legal p, .legal li { font-size: 15px; }
.noscript { padding: 20px; }
.dual { position: relative; }
