:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --card-hover: #ffffff;
  --text: #16181d;
  --muted: #69707c;
  --line: #e5e8ef;
  --primary: #6366f1;
  --primary-strong: #4f46e5;
  --grad-a: #6366f1;
  --grad-b: #8b5cf6;
  --accent-a: #f59e0b;
  --accent-b: #f97316;
  --ok-bg: #ecfdf5;
  --ok-text: #047857;
  --hot-bg: #fff7ed;
  --hot-text: #c2410c;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 6px 18px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16);
  --r-card: 16px;
  --r-btn: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --card: #171a21;
    --card-hover: #1c2029;
    --text: #e6e8ee;
    --muted: #9aa2b1;
    --line: #272c38;
    --primary: #818cf8;
    --primary-strong: #a5b4fc;
    --ok-bg: #10251d;
    --ok-text: #34d399;
    --hot-bg: #2b1908;
    --hot-text: #fb923c;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

img { max-width: 100%; height: auto; }

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3.5vw + .8rem, 2.4rem); font-weight: 800; }
h2 { font-size: clamp(1.15rem, 1.5vw + .8rem, 1.45rem); font-weight: 700; }

p { margin: 0 0 .8em; }

::selection { background: rgba(99, 102, 241, .28); }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

.container {
  width: min(100% - 32px, 1080px);
  margin-inline: auto;
}

.muted { color: var(--muted); }

.page { padding: 20px 0 48px; }

/* ================= header ================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding-block: 10px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  white-space: nowrap;
}

.logo b {
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-search { flex: 1 1 220px; max-width: 460px; }

/* ================= search ================= */

.search-box { position: relative; }

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  translate: 0 -50%;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 44px 11px 42px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

.search-input::placeholder { color: var(--muted); }

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}

.hero-search { margin-top: 22px; }

.hero-search .search-input { padding-block: 14px; padding-right: 110px; }

.search-submit {
  position: absolute;
  right: 6px;
  top: 50%;
  translate: 0 -50%;
  padding: 9px 18px;
}

.search-suggest {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 8px);
  z-index: 60;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.suggest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.suggest-item:last-child { border-bottom: 0; }
.suggest-item:hover { background: var(--card-hover); }
.suggest-item img { width: 24px; height: 24px; object-fit: contain; border-radius: 6px; }
.suggest-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item em { font-style: normal; color: var(--muted); font-size: .85rem; }
.suggest-empty { padding: 14px; color: var(--muted); text-align: center; }

/* ================= buttons & tags ================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: var(--r-btn);
  padding: 11px 20px;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, filter .15s;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  box-shadow: 0 4px 14px rgba(99, 102, 241, .35);
}

.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 6px 20px rgba(99, 102, 241, .45); }

.btn-block { width: 100%; }

.tag {
  display: inline-flex;
  align-items: center;
  font-size: .78rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.tag-muted { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.tag-hot { background: var(--hot-bg); color: var(--hot-text); }

/* ================= hero ================= */

.hero {
  margin-top: 16px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(139, 92, 246, .55) 0%, rgba(139, 92, 246, 0) 55%),
    radial-gradient(120% 160% at 0% 100%, rgba(59, 130, 246, .4) 0%, rgba(59, 130, 246, 0) 50%),
    linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  border-radius: 22px;
  padding: clamp(26px, 6vw, 56px) clamp(18px, 5vw, 48px);
  text-align: center;
}

.hero h1 { font-size: clamp(1.55rem, 4.5vw + .6rem, 2.6rem); margin-bottom: .35em; }

.hero-sub { opacity: .88; font-size: 1rem; margin-bottom: 0; }

/* ================= sections ================= */

.section { margin-top: 34px; }

.section-tight { margin-top: 18px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h2 { margin: 0; }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  margin-inline: -2px;
  scroll-snap-type: x proximity;
}

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

.chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .12s;
}

.chip:hover { border-color: var(--primary); transform: translateY(-1px); }

/* ================= brands grid ================= */

.brands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.brand-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 18px 12px 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}

.brand-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
}

.brand-tile img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  padding: 4px;
  border: 1px solid var(--line);
}

.brand-name {
  font-weight: 600;
  font-size: .95rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.brand-count { font-size: .8rem; color: var(--muted); }

/* ================= coupon cards ================= */

.coupons-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 700px) {
  .coupons-list { grid-template-columns: repeat(2, 1fr); gap: 18px; }
}

.coupon-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 22px 16px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}

@media (min-width: 700px) {
  .coupon-card {
    flex-direction: row;
    align-items: stretch;
    gap: 16px;
    padding: 20px;
  }
  .coupon-main { flex: 1; }
  .coupon-action {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    min-width: 210px;
  }
}

.coupon-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
}

.coupon-badge {
  align-self: flex-start;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .02em;
  color: #fff;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border-radius: 999px;
  padding: 4px 12px;
  box-shadow: 0 3px 10px rgba(249, 115, 22, .35);
}

@media (min-width: 700px) {
  .coupon-badge {
    position: static;
    writing-mode: initial;
  }
}

.is-exclusive { border-color: color-mix(in srgb, var(--accent-b) 45%, var(--line)); }

.coupon-shop {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.coupon-shop:hover span { color: var(--primary); }
.coupon-shop img { width: 22px; height: 22px; object-fit: contain; border-radius: 6px; }

.coupon-name { font-size: 1rem; font-weight: 700; margin: 0 0 6px; }

.coupon-desc { font-size: .9rem; color: var(--muted); margin: 0 0 10px; }

.coupon-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.coupon-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ok-text);
  background: var(--ok-bg);
  border: 1px dashed currentColor;
  border-radius: 8px;
  padding: 4px 10px;
  user-select: all;
}

@media (max-width: 699px) {
  .coupon-action { margin-top: 2px; }
  .coupon-action .btn { width: 100%; }
}

/* ================= breadcrumbs / brand page ================= */

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: .85rem;
  color: var(--muted);
  margin-top: 14px;
}

.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs span[aria-hidden] { opacity: .6; }

.brand-hero {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
}

.brand-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.brand-hero h1 { font-size: clamp(1.4rem, 3vw + .6rem, 2rem); margin-bottom: 4px; }
.brand-hero p { margin: 0; font-size: .95rem; }
.brand-site { margin-top: 4px; }

.seo-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 20px;
}

.seo-text { max-width: 75ch; color: var(--muted); font-size: .95rem; }
.seo-text p:last-child { margin-bottom: 0; }

/* ================= misc blocks ================= */

.empty-state {
  text-align: center;
  border: 2px dashed var(--line);
  border-radius: var(--r-card);
  padding: 36px 20px;
  margin-top: 20px;
}

.notfound { margin-top: 30px; }
.notfound-code {
  font-size: 4rem;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.notfound .btn { margin-top: 8px; }

.how-it-works h2 { margin-bottom: 16px; }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

@media (min-width: 700px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
}

.steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 16px;
  font-size: .95rem;
  box-shadow: var(--shadow-sm);
}

.steps li span {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  font-size: .9rem;
  color: #fff;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b));
}

.related { margin-bottom: 40px; }

/* ================= footer ================= */

.site-footer {
  margin-top: auto;
  background: #12141c;
  color: #aab1bf;
  padding: 36px 0 20px;
}

.footer-grid {
  display: grid;
  gap: 26px;
}

@media (min-width: 700px) {
  .footer-grid { grid-template-columns: 2fr 1fr 1fr; }
}

.footer-about .logo { color: #fff; margin-bottom: 10px; display: inline-flex; }
.footer-about p { font-size: .88rem; max-width: 46ch; }

.footer-nav h4 {
  color: #fff;
  font-size: .9rem;
  margin-bottom: 10px;
}

.footer-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer-nav a { font-size: .9rem; }
.footer-nav a:hover { color: #fff; }

.copyright {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: .82rem;
}

/* ================= toast ================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  translate: -50% 16px;
  z-index: 100;
  max-width: min(92vw, 420px);
  background: #1f2937;
  color: #fff;
  font-size: .9rem;
  font-weight: 600;
  border-radius: 12px;
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, translate .2s;
}

.toast.show { opacity: 1; translate: -50% 0; }

/* ================= a11y / motion ================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
