:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d1a16;
  --muted: #8a8378;
  --accent: #5b4bff;
  --accent-soft: #efedff;
  --jev: #0e9f6e;
  --jev-soft: #e6f7ef;
  --line: #e8e2d8;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 22px; background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 42px; height: 42px; border-radius: 12px; color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), #9d8cff);
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.tagline { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.controls { display: flex; gap: 14px; align-items: center; }
.jev-toggle { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.toggle-label { font-weight: 700; }
.switch {
  width: 46px; height: 26px; border-radius: 999px; border: none; cursor: pointer;
  background: #cfc9bd; position: relative; transition: background .2s;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch.on { background: var(--jev); }
.switch.on .knob { left: 23px; }
.mode-label { color: var(--muted); min-width: 64px; }
.credit { font-size: 12px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.credit:hover { color: var(--ink); text-decoration: underline; }
.ghost-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

.layout { display: flex; gap: 20px; max-width: 1400px; margin: 0 auto; padding: 20px 22px 80px; }
.sidebar { width: 290px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 82px; align-self: flex-start; max-height: calc(100vh - 100px); overflow: auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2 { margin: 0 0 4px; font-size: 14px; }
.hint { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.empty { font-size: 13px; color: var(--muted); }
.ghost-bars { display: flex; flex-direction: column; gap: 8px; }
.ghost-row { font-size: 12px; }
.ghost-row .lbl { display: flex; justify-content: space-between; margin-bottom: 3px; }
.ghost-row .bar { height: 8px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; }
.ghost-row .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #9d8cff); transition: width .5s; }
.ghost-row.jev .fill { background: linear-gradient(90deg, var(--jev), #34d399); }
.metrics { display: flex; gap: 10px; }
.metric-col { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.metric-col.active { border-color: var(--jev); box-shadow: 0 0 0 1px var(--jev); }
.metric-col h3 { margin: 0 0 8px; font-size: 12px; }
.metric-col dl { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.metric-col dl div { display: flex; justify-content: space-between; font-size: 12px; }
.metric-col dt { color: var(--muted); }
.metric-col dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.how ol { margin: 0; padding-left: 18px; font-size: 12.5px; color: #4c463c; display: flex; flex-direction: column; gap: 6px; }

.feed-wrap { flex: 1; min-width: 0; }
.feed-banner {
  display: flex; gap: 8px; align-items: center; font-size: 13px;
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px;
  border: 1px solid var(--line); background: #fff;
}
.feed-banner .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--jev); animation: pulse 1.6s infinite; }
.feed-banner.off .dot { background: #cfc9bd; animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.grid { display: flex; flex-direction: column; gap: 18px; }
.row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.row.jev-row { position: relative; }
.row-label {
  grid-column: 1 / -1; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--jev); display: flex; align-items: center; gap: 8px;
}
.row-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.row-label.pop { color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.10); }
.card .img-wrap { position: relative; aspect-ratio: 1; background: linear-gradient(135deg, #efe9dc, #e2d9c8); overflow: hidden; }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-fallback {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 64px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), #9d8cff);
}
.badge {
  position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 800;
  padding: 4px 9px; border-radius: 999px; color: #fff; background: var(--jev);
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.badge.explore { background: var(--accent); }
.badge.cat { background: rgba(29,26,22,.72); font-weight: 600; }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .title { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .variant { font-size: 11.5px; color: var(--muted); }
.card .meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }
.card .price { font-weight: 800; font-size: 15px; }
.card .rating { font-size: 12px; color: var(--muted); }
.cart-btn {
  margin-top: 8px; border: none; border-radius: 9px; padding: 8px;
  background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.cart-btn:hover { background: var(--accent); }
.card.shimmer .img-wrap, .card.shimmer .body { position: relative; overflow: hidden; }
.card.shimmer .img-wrap::after, .card.shimmer .body::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.7) 50%, transparent 70%);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.sentinel { display: grid; place-items: center; padding: 26px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.end-msg { text-align: center; color: var(--muted); font-size: 14px; }
.hidden { display: none !important; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 13px; padding: 10px 18px;
  border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 50;
}

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; flex-shrink: 0;
  border: 1px solid var(--line); background: #fff; border-radius: 50%;
  cursor: pointer; color: var(--ink);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
/* Jev strip: sticky live tracker for narrow screens (replaces sidebar) */
.jev-strip { display: none; }
.strip-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 10px 8px 14px; cursor: pointer; font-size: 13px; color: var(--ink);
}
.strip-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--jev); flex-shrink: 0; animation: pulse 1.6s infinite; }
.strip-chips { display: flex; gap: 8px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.strip-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; font-weight: 700; font-size: 12px; padding: 4px 10px;
  border-radius: 999px; font-variant-numeric: tabular-nums;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.chip.jev { background: var(--jev-soft); color: #0b6e4e; }
.strip-empty { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.strip-chev { color: var(--muted); flex-shrink: 0; }
/* bottom sheet: full ghost panel + proof metrics */
.sheet-back { position: fixed; inset: 0; background: rgba(29,26,22,.45); z-index: 60; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: var(--card); border: 1px solid var(--line); border-bottom: none;
  border-radius: 20px 20px 0 0; max-height: 78vh; overflow: auto;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
}
.sheet-handle { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 4px auto 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 15px; }
.sheet-metrics { display: flex; gap: 10px; margin: 14px 0 8px; }
.sheet-metrics .metric-col { flex: 1; }
body.noscroll { overflow: hidden; }
[hidden] { display: none !important; }
@media (max-width: 1080px) {
  .topbar { flex-wrap: wrap; }
  .jev-strip { display: block; flex-basis: 100%; }
  .layout { flex-direction: column; }
  .sidebar { display: none; }
  .row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .brand h1 { font-size: 17px; }
  .layout { padding: 14px 14px 64px; gap: 14px; }
  .row { gap: 10px; }
  .card .body { padding: 8px 10px 10px; }
  .card .title { font-size: 12.5px; }
  .cart-btn { padding: 12px; font-size: 13px; }
  .toast { max-width: 92vw; text-align: center; }
  .feed-banner { font-size: 12px; }
}
/* touch input, regardless of screen size */
@media (pointer: coarse) {
  .cart-btn { padding: 12px; min-height: 44px; }
  .switch { width: 56px; height: 32px; }
  .switch .knob { width: 26px; height: 26px; top: 3px; left: 3px; }
  .switch.on .knob { left: 27px; }
  .ghost-btn { padding: 10px 16px; }
}
@media (hover: none) {
  .card:hover { transform: none; box-shadow: none; }
  .card:active { border-color: var(--accent); }
}
