:root {
  --bg: #0b0a09;
  --ink: #f6f1e8;
  --muted: #b5ada0;
  --gold: #d8b07a;
  --card: #161310;
  --line: rgba(246, 241, 232, 0.1);
  --like: #ff4d6d;
  --nope: #8a8278;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body {
  font-family: Outfit, "PingFang TC", "Noto Sans TC", sans-serif;
  overflow-x: hidden;
}
h1, h2, h3, em {
  font-family: "Instrument Serif", "Songti TC", serif;
  font-weight: 400;
}
button { font: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.top, .intro, .lab, .picks, .lightbox { position: relative; z-index: 1; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-t)) 18px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.04em;
}
.brand-kicker { margin: 0; font-size: 10px; letter-spacing: 0.18em; color: var(--gold); }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 0.02em; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
}
.chip-btn[aria-pressed="true"] {
  color: var(--bg);
  background: var(--ink);
  border-color: var(--ink);
}
.heart-count {
  display: flex; align-items: center; gap: 6px;
  background: #221c18;
  color: var(--like);
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
}
.heart-count b { color: var(--ink); font-weight: 600; }

.hidden { display: none !important; }

.intro { padding: 8px 18px 28px; }
.intro-card {
  display: grid;
  gap: 18px;
  max-width: 920px;
  margin: 0 auto;
  background: linear-gradient(180deg, #171310, #100e0c);
  border: 1px solid var(--line);
  border-radius: 28px;
  overflow: hidden;
}
.intro-card .pic {
  display: flex;
  justify-content: center;
  background: #100e0c;
}
.intro-card img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 56vh;
  object-fit: contain;
}
.intro-copy { padding: 4px 22px 26px; }
.eyebrow { margin: 0 0 6px; color: var(--gold); letter-spacing: 0.16em; font-size: 12px; }
.intro h2 { margin: 0 0 10px; font-size: clamp(32px, 7vw, 56px); line-height: 1.05; }
.intro h2 em { color: var(--gold); font-style: italic; }
.intro-copy p { margin: 0 0 18px; color: var(--muted); line-height: 1.6; }
.intro-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  font-weight: 600;
}
.btn.primary { background: var(--gold); color: #1a140e; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.lab { min-height: calc(100dvh - 72px); padding-bottom: calc(16px + var(--safe-b)); }
.progress { height: 3px; background: #221c18; margin: 0 18px 14px; border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--gold); transition: width 0.25s ease; }

.lab-swipe {
  display: grid;
  gap: 16px;
  padding: 0 18px;
}
.deck {
  position: relative;
  width: min(100%, 340px, calc(58dvh * 3 / 4));
  aspect-ratio: 3 / 4;
  height: auto;
  margin: 0 auto;
}
.card {
  position: absolute;
  inset: 0;
  border-radius: 26px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
  touch-action: none;
  user-select: none;
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  background: #111;
}
.card .orig {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  background: #111;
}
.card.peeking .orig { opacity: 1; }
.stamp {
  position: absolute;
  top: 28px;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 6px 14px;
  border: 4px solid;
  border-radius: 8px;
  opacity: 0;
  transform: rotate(-12deg);
}
.stamp.yes { left: 18px; color: #3dd68c; border-color: #3dd68c; }
.stamp.no { right: 18px; color: var(--like); border-color: var(--like); transform: rotate(12deg); }

.meta { padding: 0 4px 8px; }
.meta-index { margin: 0; color: var(--gold); letter-spacing: 0.14em; font-size: 12px; }
.meta h2 { margin: 4px 0 0; font-size: 34px; }
.meta-en { margin: 2px 0 10px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
}
.vibe { margin: 12px 0 0; color: var(--gold); }
.why { margin: 6px 0 0; color: var(--muted); line-height: 1.55; }
blockquote {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-left: 2px solid var(--gold);
  background: #14110f;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}
.hold-hint, .keys-hint { color: var(--muted); font-size: 12px; text-align: center; }
.keys-hint { display: none; }

.actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin: 14px 0 8px;
}
.round {
  width: 64px; height: 64px; border-radius: 50%;
  border: 1px solid var(--line);
  background: #161310;
  color: var(--ink);
  font-size: 22px;
}
.round.like { color: var(--like); width: 74px; height: 74px; font-size: 28px; }
.round.nope { color: var(--nope); }
.round.peek { width: 58px; height: 58px; font-size: 13px; letter-spacing: 0.04em; }
.round:active { transform: scale(0.94); }

.wall { padding: 0 18px 24px; }
.wall-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.wall-tools input {
  flex: 1;
  min-width: 160px;
  background: #14110f;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
}
.grid-count { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-items: start;
}
.tile {
  position: relative;
  border: 0;
  padding: 0;
  background: #111;
  border-radius: 18px;
  overflow: hidden;
  text-align: left;
  color: inherit;
}
.tile img {
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  background: #111;
}
.tile figcaption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 28px 10px 10px;
  background: linear-gradient(transparent, rgba(0,0,0,0.78));
  font-size: 13px;
}
.tile.liked::after {
  content: "♥";
  position: absolute;
  top: 8px; right: 10px;
  color: var(--like);
}

.picks { padding: 8px 18px calc(40px + var(--safe-b)); max-width: 880px; margin: 0 auto; }
.picks h2 { margin: 4px 0 8px; font-size: 40px; }
.picks-sub { color: var(--muted); }
.back { background: none; border: 0; color: var(--gold); padding: 0 0 10px; }
.podium, .picks-list { display: grid; gap: 12px; margin: 18px 0; }
.pick-card {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  background: #14110f;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.pick-card img { width: 92px; height: auto; object-fit: contain; object-position: top; background: #111; }
.pick-card h3 { margin: 12px 12px 4px; font-size: 24px; }
.pick-card p { margin: 0 12px 12px; color: var(--muted); font-size: 14px; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8,7,6,0.92);
  padding: calc(18px + var(--safe-t)) 16px calc(18px + var(--safe-b));
  overflow: auto;
}
.lb-close {
  position: absolute; top: calc(12px + var(--safe-t)); right: 14px;
  background: #221c18; color: var(--ink); border: 0; border-radius: 50%;
  width: 40px; height: 40px;
}
.lb-stage { max-width: 980px; margin: 48px auto 0; display: grid; gap: 16px; }
.compare {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  width: min(100%, 340px, calc(60dvh * 3 / 4));
  aspect-ratio: 3 / 4;
  height: auto;
  margin: 0 auto;
  background: #111;
}
.compare img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.compare .orig-layer { clip-path: inset(0 0 0 100%); }
.compare input[type="range"] {
  position: absolute;
  left: 8%; right: 8%; bottom: 16px;
  width: 84%;
  accent-color: var(--gold);
}
.cmp-label {
  position: absolute; bottom: 40px; font-size: 11px; letter-spacing: 0.1em;
  background: rgba(0,0,0,0.45); padding: 3px 8px; border-radius: 99px;
}
.cmp-label.left { left: 10px; }
.cmp-label.right { right: 10px; }
.cmp-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--gold);
  left: 0;
  box-shadow: 0 0 0 3px rgba(216, 176, 122, 0.25);
  pointer-events: none;
}
.lb-info { max-width: 560px; margin: 0 auto; }
.lb-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.lb-nav .meta-index { margin: 0; }
.lb-info h3 { margin: 0 0 8px; font-size: 32px; }
.price-line { color: var(--gold); font-weight: 600; }
.coarse { color: var(--muted); line-height: 1.55; }
.how { margin: 10px 0 0; padding-left: 18px; color: var(--ink); }
.how li { margin: 0 0 6px; }
.ref-block { margin-top: 16px; }
.ref-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 12px; }
.ref-row img { width: 100%; height: auto; object-fit: contain; border-radius: 12px; background: #111; }
.ref-row a { color: inherit; }
.shop-mini { display: grid; gap: 8px; margin: 14px 0; }
.shop-card {
  background: #14110f;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
}
.shop-card b { display: block; margin-bottom: 4px; }
.shop-card a { color: var(--gold); }
.shop-card.best { border-color: var(--gold); }
.lb-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.dye-lab { padding: 8px 18px 32px; max-width: 980px; margin: 0 auto; }
.dye-lab h2 { margin: 4px 0 8px; font-size: 36px; }
.dye-lead { color: var(--muted); }
.dye-stage { display: grid; gap: 16px; margin-top: 14px; }
#dye-canvas {
  width: min(100%, 340px);
  height: auto;
  border-radius: 22px;
  background: #111;
  justify-self: center;
}
.dye-panel { display: grid; gap: 12px; }
.dye-src-lab, .pick-row, .slide-row { color: var(--muted); font-size: 14px; display: grid; gap: 6px; }
.dye-panel select, .dye-panel input[type="color"] {
  background: #14110f;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
}
.swatch.on { border-color: var(--ink); transform: scale(1.08); }
.dye-price, .dye-shop { margin: 0; color: var(--muted); font-size: 14px; }
.dye-shop a { color: var(--gold); }

#confetti {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
}

@media (max-width: 899px) {
  .meta .why, .meta blockquote, .meta .hold-hint { display: none; }
  .meta h2 { font-size: 26px; }
  .round { width: 58px; height: 58px; }
  .round.like { width: 68px; height: 68px; }
}

@media (min-width: 900px) {
  .intro-card { grid-template-columns: 0.9fr 1.1fr; align-items: center; }
  .intro-card img { max-height: 72vh; }
  .intro-copy { padding: 28px 36px 28px 8px; }
  .lab-swipe {
    grid-template-columns: minmax(320px, 420px) 1fr;
    align-items: center;
    max-width: 980px;
    margin: 0 auto;
  }
  .deck { margin: 0; width: min(360px, calc(70dvh * 3 / 4)); }
  .keys-hint { display: block; }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .tile:hover { transform: translateY(-3px); transition: transform 0.2s ease; }
  .lb-stage { grid-template-columns: 380px 1fr; align-items: start; }
  .compare { margin: 0; }
  .dye-stage { grid-template-columns: 380px 1fr; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .progress-bar, .tile { transition: none !important; }
}
