:root {
  --bg: #f0f0f4;
  --card: #ffffff;
  --ink: #16142b;
  --sub: #5c5a72;
  --line: #e4e3ee;
  --muted: #f4f3f9;
  --primary: #7c3aed;
  --sale: #7c3aed;
  --on-primary: #ffffff;
  --accent: #e11d48;
  --buy: #047857;
  --good: #f59e0b;
  --neutral: #3f3d56;
  --shadow: 0 1px 2px rgba(22, 20, 43, 0.04), 0 4px 12px rgba(22, 20, 43, 0.06);
  --radius: 24px;
  --heading: "Russo One", "Arial Black", system-ui, sans-serif;
  --body: "Chakra Petch", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f0f1c;
  --card: #1b1a2e;
  --ink: #ececf4;
  --sub: #a4a2bd;
  --line: #2e2c48;
  --muted: #252439;
  --primary: #a37bff;
  --sale: #6d3fd6;
  --on-primary: #12101f;
  --accent: #fb5277;
  --buy: #10a36b;
  --good: #fbbf24;
  --neutral: #47456a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 500 16px/1.5 var(--body); }
button, input, select { font: inherit; color: inherit; }
button, select, a { cursor: pointer; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { max-width: 1480px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }

.topbar { position: sticky; top: 0; z-index: 8; background: var(--card); box-shadow: 0 1px 0 var(--line); padding-top: env(safe-area-inset-top, 0px); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; padding-block: 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--heading); font-size: 20px; white-space: nowrap; color: inherit; text-decoration: none; }
.brand .mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); }
.search { flex: 1; min-width: 0; max-width: 520px; position: relative; }
.search input { width: 100%; height: 44px; border-radius: 14px; border: 2px solid transparent; background: var(--muted); padding: 0 44px 0 44px; font-weight: 500; }
.search input:focus { border-color: var(--primary); background: var(--card); outline: none; }
.search > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--sub); pointer-events: none; }
.search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font: 600 12px var(--body); color: var(--sub); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; }
.spacer { flex: 1; }
.pick { display: flex; flex-direction: column; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--sub); }
.pick select { height: 32px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 0 8px; font-size: 14px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.icon-btn { height: 44px; min-width: 44px; padding: 0 12px; border-radius: 14px; border: 0; background: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; white-space: nowrap; }
.icon-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }
.profile-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.profile-name:empty { display: none; }
.pill { font-family: var(--heading); font-size: 12px; background: var(--accent); color: #fff; border-radius: 8px; padding: 1px 7px; }
.icon-btn[aria-pressed="true"] .pill { background: #fff; color: var(--accent); }

.page { display: grid; gap: 16px; padding-block: 16px 0; }

.bento { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: minmax(132px, auto); gap: 16px; }
.featured { --tint: var(--primary); grid-column: span 2; grid-row: span 2; position: relative; overflow: hidden; border-radius: var(--radius); color: #fff; display: flex; flex-direction: column; justify-content: flex-end; padding: 22px; min-height: 280px; background: var(--tint); box-shadow: var(--shadow); isolation: isolate; }
.featured img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.featured::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, transparent 15%, rgba(10, 8, 24, 0.88) 80%); }
.featured .eyebrow { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; background: var(--buy); border-radius: 10px; padding: 4px 10px; font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.featured h2 { font-family: var(--heading); font-weight: 400; font-size: clamp(24px, 2.4vw, 34px); line-height: 1.05; margin: 0 0 8px; text-wrap: balance; }
.featured .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.featured .big { font-family: var(--heading); font-size: 30px; }
.featured s { opacity: .75; }
.featured .off { background: var(--accent); border-radius: 8px; padding: 2px 8px; font-weight: 700; }
.featured .go { margin-left: auto; height: 44px; border: 0; border-radius: 14px; background: #fff; color: #16142b; padding: 0 18px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }

.mood { --c: #7c3aed; --on: #fff; position: relative; border: 0; border-radius: var(--radius); background: var(--c); color: var(--on); text-align: left; padding: 16px 16px 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; box-shadow: var(--shadow); overflow: hidden; }
.mood .mark { position: absolute; right: -18px; bottom: -22px; width: 120px; height: 120px; opacity: .16; stroke-width: 1.6; transform: rotate(-12deg); pointer-events: none; }
.mood > span { position: relative; }
.bento.has-active .mood:not([aria-pressed="true"]), .mood.is-empty:not([aria-pressed="true"]) { opacity: .55; }
.mood .top { display: flex; align-items: center; justify-content: space-between; }
.mood .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, currentColor 16%, transparent); }
.mood .check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; opacity: .55; }
.mood .check svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; }
.mood[aria-pressed="true"] .check { background: var(--on); color: var(--c); border-color: var(--on); opacity: 1; }
.mood[aria-pressed="true"] .check svg { opacity: 1; }
.mood .mood-label { display: block; font-weight: 700; font-size: 16px; line-height: 1.2; }
.mood .n { font-family: var(--heading); font-size: 28px; line-height: 1; }
.mood .n small { font-family: var(--body); font-size: 13px; font-weight: 600; opacity: .85; margin-left: 4px; }

.alerts { padding: 16px 18px; border: 2px solid var(--buy); }
.alerts-head { display: flex; align-items: center; gap: 10px; color: var(--buy); }
.alerts-head h2 { flex: 1; margin: 0; font-family: var(--heading); font-weight: 400; font-size: 20px; color: var(--ink); }
.alerts ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.drop { width: 100%; min-height: 44px; border: 0; border-radius: 12px; background: var(--muted); padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; text-align: left; }
.drop-name { font-weight: 700; }
.drop s { color: var(--sub); }
.drop-off { color: var(--buy); font-weight: 700; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.results { padding: 18px 18px 22px; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; }
.summary { flex: 1; min-width: 200px; color: var(--sub); font-weight: 500; }
.summary b { font-family: var(--heading); font-weight: 400; color: var(--ink); font-size: 20px; margin-right: 4px; }
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 14px; background: var(--muted); border: 0; font-weight: 600; font-size: 14px; }
.switch .knob { width: 34px; height: 20px; border-radius: 10px; background: var(--line); position: relative; }
.switch .knob::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch[aria-pressed="true"] .knob { background: var(--primary); }
.switch[aria-pressed="true"] .knob::after { left: 17px; }
.sort { display: flex; gap: 4px; background: var(--muted); border-radius: 14px; padding: 4px; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.sort button { border: 0; background: none; border-radius: 10px; min-height: 36px; padding: 0 12px; font-weight: 600; font-size: 14px; color: var(--sub); white-space: nowrap; }
.sort button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.linkish { border: 0; background: none; padding: 0; color: var(--primary); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(182px, 1fr)); gap: 16px; }
.card { --tint: var(--primary); position: relative; min-width: 0; border-radius: 20px; background: var(--card); border: 1px solid var(--line); }
.card[aria-current="true"] { background: color-mix(in srgb, var(--primary) 9%, var(--card)); border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.card .open { all: unset; box-sizing: border-box; display: grid; gap: 4px; width: 100%; padding: 8px 8px 14px; border-radius: 20px; cursor: pointer; }
.card .open:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.art { position: relative; aspect-ratio: 2 / 3; width: 100%; border-radius: 14px; overflow: hidden; background: var(--muted); margin-bottom: 6px; }
.art img { position: relative; width: 100%; height: 100%; object-fit: cover; display: block; }
.art-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; font-family: var(--heading); font-size: 18px; line-height: 1.15; color: var(--sub); }
img.fade { opacity: 0; transition: opacity .3s ease; }
img.fade.is-loaded { opacity: 1; }
img.is-missing { visibility: hidden; }
.art:has(> img.fade:not(.is-loaded, .is-missing)), .shot:has(> img.fade:not(.is-loaded, .is-missing)), .featured:has(> img.fade:not(.is-loaded, .is-missing)), .skeleton { animation: pulse 1.4s ease-in-out infinite; }
.art:has(> img.fade:not(.is-loaded, .is-missing)) .art-fallback { visibility: hidden; }
@keyframes pulse { 50% { opacity: .6; } }
.skeleton { background: var(--muted); border-radius: 12px; }
.skeleton-chart { height: 130px; }
.skeleton-lines { display: grid; gap: 8px; }
.skeleton-lines .skeleton { height: 14px; }
.skeleton-lines .skeleton:last-child { width: 60%; }
.card.is-placeholder { pointer-events: none; padding: 8px 8px 14px; display: grid; gap: 8px; }
.card.is-placeholder .art { margin: 0; }
.card.is-placeholder .skeleton { height: 14px; }
.badge { position: absolute; left: 8px; top: 8px; z-index: 1; border-radius: 9px; padding: 3px 8px; font-size: 12px; font-weight: 700; color: #fff; display: inline-flex; align-items: center; gap: 4px; max-width: calc(100% - 16px); }
.badge svg.i { width: 14px; height: 14px; }
.v-buy { background: var(--buy); color: #fff; }
.v-good { background: var(--good); color: #2b1900; }
.v-sale { background: var(--sale); color: #fff; }
.v-wait, .v-steady, .v-full { background: var(--neutral); color: #fff; }
.off-flag { position: absolute; right: 8px; bottom: 8px; z-index: 1; font-family: var(--heading); font-size: 15px; background: var(--accent); color: #fff; border-radius: 10px; padding: 2px 8px; }
.title { font-weight: 700; font-size: 16px; line-height: 1.2; padding: 0 4px; overflow-wrap: anywhere; }
.tags { color: var(--sub); font-size: 13px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 2px 4px 0; }
.price .now { font-family: var(--heading); font-size: 18px; }
.price s { color: var(--sub); font-size: 13px; }
.alt { color: var(--sub); font-size: 13px; padding: 0 4px; }
.meta { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--sub); font-size: 13px; padding: 2px 4px 0; }
.meta span { display: inline-flex; align-items: center; gap: 3px; }
.meta svg.i { width: 14px; height: 14px; }
.empty, .status { grid-column: 1 / -1; text-align: center; padding: 56px 16px; color: var(--sub); }
.empty b, .status b { display: block; font-family: var(--heading); font-weight: 400; font-size: 22px; color: var(--ink); margin-bottom: 6px; }
.more { display: flex; justify-content: center; margin-top: 18px; }
.more button { min-height: 44px; border: 0; border-radius: 14px; background: var(--muted); padding: 0 22px; font-weight: 700; }

.preview { --tint: var(--primary); --tint-ink: #fff; position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: thin; }
.p-hero { position: relative; padding: 14px; border-radius: var(--radius) var(--radius) 0 0; background: linear-gradient(160deg, var(--tint), color-mix(in srgb, var(--tint) 25%, var(--card)) 85%); }
.shot { aspect-ratio: 460 / 215; border-radius: 16px; overflow: hidden; background: var(--muted); }
.p-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.close { display: none; position: absolute; right: 22px; top: 22px; width: 44px; height: 44px; border-radius: 14px; border: 0; background: rgba(0, 0, 0, .65); color: #fff; place-items: center; }
.p-body { padding: 18px 20px 22px; display: grid; gap: 16px; }
.p-body h2 { font-family: var(--heading); font-weight: 400; font-size: 28px; line-height: 1.05; margin: 0; text-wrap: balance; }
.byline { color: var(--sub); font-size: 14px; margin-top: 4px; }
.verdict { border-radius: 18px; padding: 16px 18px; display: grid; gap: 4px; }
.verdict .word { display: flex; align-items: center; gap: 8px; font-family: var(--heading); font-size: 22px; }
.verdict .prices { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 6px; }
.verdict .now { font-family: var(--heading); font-size: 32px; }
.verdict s { opacity: .75; }
.verdict .off { background: rgba(255, 255, 255, .22); border-radius: 8px; padding: 1px 8px; font-weight: 700; }
.verdict .alt-big { opacity: .9; font-weight: 600; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--sub); margin: 0 0 6px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .note { font-size: 13px; color: var(--sub); margin-top: 4px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.facts div { background: var(--muted); border-radius: 14px; padding: 10px 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: center; }
.facts svg.i { grid-row: span 2; color: var(--tint); }
.facts dt { font-size: 12px; color: var(--sub); font-weight: 600; }
.facts dd { margin: 0; font-weight: 700; font-size: 15px; }
.blurb { margin: 0; font-weight: 400; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips span { border-radius: 10px; padding: 3px 10px; font-size: 13px; font-weight: 600; background: var(--muted); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn { min-height: 48px; border-radius: 14px; border: 0; background: var(--muted); color: var(--ink); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; padding: 0 12px; text-align: center; }
.btn.primary { grid-column: 1 / -1; background: var(--tint); color: var(--tint-ink); font-size: 17px; min-height: 54px; }
.btn[aria-pressed="true"] { background: var(--accent); color: #fff; }

.owned { position: absolute; left: 8px; bottom: 8px; z-index: 1; font-size: 12px; font-weight: 700; color: #fff; background: rgba(22, 20, 43, .78); border-radius: 8px; padding: 1px 8px; }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(460px, calc(100% - 32px)); background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15, 15, 28, .55); }
.dialog-body { padding: 22px; display: grid; gap: 10px; }
.dialog-body h2 { font-family: var(--heading); font-weight: 400; font-size: 24px; margin: 0; }
.dialog-body p { margin: 0; color: var(--sub); font-weight: 400; }
.field { font-size: 13px; font-weight: 700; margin-top: 6px; }
.dialog-body input { height: 48px; border-radius: 14px; border: 2px solid var(--line); background: var(--muted); padding: 0 14px; }
.dialog-body input:focus { border-color: var(--primary); outline: none; }
.dialog-body select { height: 48px; border-radius: 14px; border: 2px solid var(--line); background: var(--muted); color: var(--ink); padding: 0 12px; font-weight: 600; }
#regionBtn { display: none; }
.dialog-status { min-height: 1.5em; }
.dialog-status.error { color: var(--accent); font-weight: 600; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.dialog-actions .btn.primary { grid-column: auto; min-height: 48px; font-size: 16px; background: var(--primary); color: var(--on-primary); }

footer { margin-top: 16px; background: var(--card); box-shadow: 0 -1px 0 var(--line); }
footer .wrap { padding-block: 22px calc(30px + env(safe-area-inset-bottom, 0px)); display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between; align-items: flex-start; }
footer .notes { max-width: 72ch; display: grid; gap: 4px; color: var(--sub); font-size: 13px; font-weight: 400; }
footer .controls { display: flex; flex-wrap: wrap; gap: 12px 18px; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 40; background: var(--ink); color: var(--card); border-radius: 16px; padding: 8px 8px 8px 16px; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); font-weight: 600; }
.toast button { min-height: 36px; border: 0; border-radius: 10px; background: var(--primary); color: var(--on-primary); padding: 0 14px; font-weight: 700; }
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(15, 15, 28, .55); }

@media (max-width: 1200px) {
  .bento { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .featured { grid-column: span 4; grid-row: auto; min-height: 260px; }
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .preview { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); max-height: none; z-index: 21; border-radius: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .preview { overscroll-behavior: contain; }
  .preview:not(.open) { display: none; }
  .p-hero { border-radius: 0; }
  .close { display: grid; }
}
@media (max-width: 720px) {
  .topbar .wrap { flex-wrap: wrap; gap: 8px; }
  .brand .name { display: none; }
  .brand { flex: 1; }
  .topbar .pick { display: none; }
  #regionBtn { display: inline-flex; }
  .search { order: 9; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .profile-name { display: none; }
  .spacer { display: none; }
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; grid-auto-rows: minmax(116px, auto); }
  .featured { grid-column: span 2; min-height: 240px; padding: 16px; }
  .featured .go { margin-left: 0; }
  .mood { padding: 12px; }
  .mood .n { font-size: 24px; }
  .results { padding: 14px 10px 16px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .preview { top: auto; height: 94%; width: 100%; border-radius: 24px 24px 0 0; }
  .p-hero { border-radius: 24px 24px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
