/* ===========================================================================
   WishWatch — "Sand & Teal" light theme
   ========================================================================= */

:root {
  --bg-0: #e9d8a6;   /* sand background */
  --bg-1: #f0e3bd;   /* warmer wash */

  --ink: #001219;       /* headings / primary text */
  --ink-soft: #34534b;  /* secondary text */
  --ink-faint: #6e7a66; /* faint / hints */

  --line: rgba(0, 18, 25, 0.12);
  --line-2: rgba(0, 18, 25, 0.22);
  --glass: #fbf4da;     /* warm near-white surface */
  --glass-2: #f3e8c4;   /* slightly deeper surface */

  --brand: #0a9396;       /* teal */
  --brand-deep: #005f73;  /* deep teal */
  --teal-tint: #94d2bd;   /* light teal */
  --mint-soft: #dcefe5;   /* pale light-teal tint (hovers/selection) */
  --navy: #001219;        /* deepest ink */

  --cyan: #0a9396;        /* accent / borders / hovers (legacy name) */
  --indigo: #0a9396;      /* focus border (legacy name) */
  --accent: #0a9396;
  --accent-grad: linear-gradient(120deg, #0a9396 0%, #ee9b00 100%);

  --badge-grad: linear-gradient(120deg, #ee9b00, #ca6702);
  --sale: #bb3e03;        /* deal text */
  --sale-2: #ca6702;
  --sale-ink: #2b1400;    /* dark text on amber badge */
  --danger: #ae2012;

  --r-lg: 18px;
  --r: 14px;
  --r-sm: 10px;

  --shadow: 0 18px 44px -26px rgba(0, 18, 25, 0.32);
  --shadow-glow: 0 10px 30px -16px rgba(10, 147, 150, 0.35);

  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-display: "Space Grotesk", var(--font-ui);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1100px 700px at 8% -8%, rgba(10, 147, 150, 0.12), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(238, 155, 0, 0.12), transparent 55%),
    var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- soft drifting wash backdrop ------------------------------------------ */
.aurora {
  position: fixed; inset: -25%; z-index: -1; pointer-events: none;
  filter: blur(80px); opacity: 0.4;
}
.aurora::before, .aurora::after {
  content: ""; position: absolute; width: 55vw; height: 55vw;
  border-radius: 50%; will-change: transform;
}
.aurora::before {
  top: -6%; left: -8%;
  background: radial-gradient(circle, rgba(10, 147, 150, 0.45), transparent 62%);
  animation: drift1 26s ease-in-out infinite alternate;
}
.aurora::after {
  bottom: -12%; right: -6%;
  background: radial-gradient(circle, rgba(238, 155, 0, 0.4), transparent 62%);
  animation: drift2 32s ease-in-out infinite alternate;
}

@keyframes drift1 {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(14vw, 10vh, 0) scale(1.18); }
}
@keyframes drift2 {
  from { transform: translate3d(0, 0, 0) scale(1.05); }
  to   { transform: translate3d(-12vw, -8vh, 0) scale(1.25); }
}

/* ---- layout --------------------------------------------------------------- */
.wrap {
  max-width: 1140px; margin: 0 auto; padding: 18px 22px 96px; position: relative;
  transition: margin-right 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; position: relative; z-index: 40;
  animation: fadeUp 0.6s 0.02s both;
}
.brand { display: flex; align-items: center; gap: 14px; }

/* ---- logo (icon + wordmark) ----------------------------------------------- */
.ww-icon { display: block; flex: none; }
.brand .ww-icon { width: 42px; height: 42px; }

.wordmark {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.5px;
  line-height: 1.05; color: var(--brand-deep); margin: 0;
}
.brand .wordmark { font-size: 1.5rem; }
.wm-watch, h1 .tag {
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

h1 {
  font-family: var(--font-display);
  font-size: 1.55rem; font-weight: 700; margin: 0; letter-spacing: -0.4px;
  line-height: 1.05;
}
.subtle { color: var(--ink-soft); font-size: 0.9rem; margin-top: 3px; }

/* ---- buttons -------------------------------------------------------------- */
.btn {
  position: relative; border: 0; cursor: pointer;
  font-family: var(--font-ui); font-size: 0.95rem; font-weight: 600;
  color: #fff; padding: 12px 20px; border-radius: var(--r);
  background: var(--brand-deep);
  box-shadow: var(--shadow-glow);
  transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
  isolation: isolate;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.12); }
.btn:active { transform: translateY(0) scale(0.985); }
.btn:disabled { opacity: 0.7; cursor: default; transform: none; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

.btn.ghost {
  background: var(--glass); color: var(--brand-deep);
  border: 1px solid var(--line-2); box-shadow: none;
}
.btn.ghost:hover { color: var(--brand-deep); border-color: var(--brand); filter: none; background: var(--mint-soft); }

.btn .spinner { display: none; align-items: center; gap: 8px; }
.btn.loading .label { display: none; }
.btn.loading .spinner { display: inline-flex; }
.spinner::before {
  content: ""; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4); border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}

/* ---- search controls ------------------------------------------------------ */
.controls {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.6s 0.08s both;
}
.input-wrap { position: relative; flex: 1 1 340px; display: flex; }
.input-wrap svg {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--ink-faint); pointer-events: none;
}
.input-wrap input { padding-left: 44px !important; width: 100%; }

input[type="text"], select {
  font-family: var(--font-ui); font-size: 0.95rem; color: var(--ink);
  background: #fffdf3; border: 1px solid var(--line-2);
  border-radius: var(--r); padding: 13px 15px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
input[type="text"]::placeholder { color: var(--ink-faint); }
input[type="text"]:focus, select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(10, 147, 150, 0.18);
  background: #fff;
}
select {
  flex: 0 0 auto; cursor: pointer; padding-right: 38px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23005f73' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
select option { background: #fbf4da; color: var(--ink); }

/* ---- status line ---------------------------------------------------------- */
.status {
  margin: 10px 4px; color: var(--ink-soft); font-size: 0.92rem;
  min-height: 1.3em; display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap;
  justify-content: space-between;
  transition: color 0.2s ease;
}
.status-l { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-r { color: var(--ink-faint); font-size: 0.85rem; white-space: nowrap; }
.status.error { color: var(--danger); }
.status .pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(120deg, rgba(238, 155, 0, 0.22), rgba(202, 103, 2, 0.14));
  color: var(--sale); border: 1px solid rgba(202, 103, 2, 0.4);
  border-radius: 999px; padding: 3px 12px; font-weight: 700; white-space: nowrap;
  animation: popIn 0.4s both;
}

/* ---- sort toolbar --------------------------------------------------------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; margin: 2px 2px 18px;
  animation: fadeUp 0.4s both;
}
.toolbar[hidden] { display: none; }
.sortlabel { color: var(--ink-faint); font-size: 0.88rem; }
.control-right select { padding: 9px 36px 9px 13px; font-size: 0.9rem; }

/* ---- results grid --------------------------------------------------------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.card {
  position: relative; display: flex; flex-direction: column; overflow: hidden;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  animation: cardIn 0.5s var(--d, 0ms) both;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.22s ease, box-shadow 0.22s ease;
}
.card:hover {
  transform: translateY(-6px);
  border-color: var(--line-2);
  box-shadow: 0 30px 60px -30px rgba(0, 18, 25, 0.45), var(--shadow-glow);
}
.card.sale { border-color: rgba(238, 155, 0, 0.55); }
.card.sale:hover { box-shadow: 0 30px 60px -30px rgba(0,18,25,.45), 0 10px 36px -14px rgba(238,155,0,.5); }

.thumb-wrap { position: relative; overflow: hidden; aspect-ratio: 460 / 215; background: #e7dcb4; }
.card .thumb {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.card:hover .thumb { transform: scale(1.07); }
.thumb-wrap::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0, 18, 25, 0.3), transparent 45%);
}

.thumb-wrap .trailer {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  z-index: 1; opacity: 0; transition: opacity 0.25s ease;
}
.thumb-wrap .trailer.show { opacity: 1; }

/* trailer audio controls (speaker + volume) — fade in/out with the trailer */
.trailer-ctrls {
  position: absolute; left: 8px; bottom: 8px; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  background: rgba(0, 18, 25, 0.62); border-radius: 999px; padding: 4px 11px 4px 5px;
  opacity: 0; transition: opacity 0.2s ease;
}
.trailer-ctrls.show { opacity: 1; }
.tr-mute {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  background: none; border: 0; color: #fff; padding: 0; flex: none;
  transition: color 0.18s ease;
}
.tr-mute svg { width: 17px; height: 17px; }
.tr-mute:hover { color: var(--teal-tint); }
.tr-vol {
  -webkit-appearance: none; appearance: none; width: 62px; height: 4px;
  background: rgba(255, 255, 255, 0.4); border-radius: 999px; cursor: pointer; outline: none;
}
.tr-vol::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 13px; height: 13px;
  border-radius: 50%; background: #fff; cursor: pointer;
}
.tr-vol::-moz-range-thumb { width: 13px; height: 13px; border: 0; border-radius: 50%; background: #fff; cursor: pointer; }
.thumb-wrap.noimg { background: linear-gradient(135deg, #f3e8c4, #e2d49e); }
.thumb-wrap.noimg img { display: none; }
.thumb-wrap.noimg::before {
  content: "No preview image"; position: absolute; inset: 0; z-index: 1;
  display: grid; place-items: center; color: var(--ink-faint); font-size: 0.82rem;
}

.card .body { padding: 15px 16px 17px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card .title {
  font-family: var(--font-display); font-weight: 600; font-size: 1.02rem;
  line-height: 1.25; letter-spacing: -0.2px;
}

.badge {
  position: absolute; top: 12px; left: 12px; z-index: 2;
  background: var(--badge-grad);
  color: var(--sale-ink); font-weight: 800; font-size: 0.95rem;
  padding: 5px 11px; border-radius: 10px; overflow: hidden;
  box-shadow: 0 8px 20px -8px rgba(202, 103, 2, 0.7);
}
.badge::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55), transparent 70%);
  transform: translateX(-130%); animation: sheen 3.4s ease-in-out infinite;
}

.price-row { display: flex; align-items: baseline; gap: 10px; margin-top: auto; flex-wrap: wrap; }
.price-now { font-family: var(--font-display); font-size: 1.32rem; font-weight: 700; letter-spacing: -0.5px; }
.price-now.free { color: var(--sale); }
.price-was { color: var(--ink-faint); text-decoration: line-through; font-size: 0.9rem; }
.shop { color: var(--ink-soft); font-size: 0.85rem; }
.shop b { color: var(--ink); font-weight: 600; }

.buy {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  text-decoration: none; margin-top: 3px;
  background: var(--glass-2); color: var(--ink); font-weight: 600; font-size: 0.9rem;
  padding: 10px 13px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.buy:hover { text-decoration: none; transform: translateY(-1px);
  background: rgba(10, 147, 150, 0.12); border-color: var(--brand); }
.untracked { color: var(--ink-faint); font-size: 0.85rem; font-style: italic; margin-top: auto; }

/* ---- skeleton loaders ----------------------------------------------------- */
.card.skeleton { animation: cardIn 0.4s both; pointer-events: none; }
.sk { position: relative; overflow: hidden; background: rgba(0, 18, 25, 0.07); border-radius: 8px; }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  animation: shimmer 1.4s infinite;
}
.sk-line { height: 14px; margin: 2px 0; }

/* ---- setup wizard --------------------------------------------------------- */
.setup-card {
  position: relative;
  max-width: 620px; margin: 7vh auto 0;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 22px; padding: 34px 34px 30px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.6s both;
}
.setup-card .ww-icon { width: 42px; height: 42px; }
.setup-close {
  position: absolute; top: 16px; right: 16px;
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  background: var(--glass); border: 1px solid var(--line-2);
  color: var(--ink-soft); font-size: 1rem; line-height: 1;
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.setup-close:hover { color: var(--danger); border-color: var(--danger); transform: rotate(90deg); }
.setup-close:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
body.is-settings .setup-close { display: inline-flex; }

.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn.secondary {
  background: var(--glass); color: var(--ink-soft);
  border: 1px solid var(--line-2); box-shadow: none; display: none;
}
.btn.secondary:hover { color: var(--ink); border-color: var(--line-2); filter: none; }
body.is-settings .btn.secondary { display: inline-block; }

.steps { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }
.steps li { line-height: 1.5; }

.locked-note {
  display: none; margin: 6px 0 0; padding: 13px 15px; border-radius: 12px;
  background: var(--glass-2); border: 1px solid var(--line-2);
  color: var(--ink-soft); font-size: 0.9rem; line-height: 1.5;
}
body.is-locked .locked-note { display: block; }
body.is-locked #setup-form { display: none; }
.setup-card .brand { margin-bottom: 18px; }
.setup-card h1 { font-size: 1.7rem; }
.setup-card p.lead { color: var(--ink-soft); margin: 0 0 6px; line-height: 1.6; }
.field { margin: 22px 0; display: flex; flex-direction: column; gap: 8px; }
.field label { font-weight: 600; font-family: var(--font-display); letter-spacing: -0.2px; }
.field .hint { color: var(--ink-soft); font-size: 0.85rem; line-height: 1.5; }
.field .hint code {
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; font-size: 0.82em;
}
.field input { width: 100%; }
.field.err input { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(174, 32, 18, 0.16); }
.field .msg { color: var(--danger); font-size: 0.85rem; min-height: 1em; }

/* ---- login page ---------------------------------------------------------- */
.login-card {
  max-width: 460px; margin: 12vh auto 0; text-align: center;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 22px; padding: 40px 34px 30px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.6s both;
}
.login-card .ww-icon { width: 104px; height: 104px; margin: 0 auto 18px; }
.login-card .wordmark { font-size: 2.1rem; margin-bottom: 4px; }
.login-card h1 { font-size: 1.7rem; }
.login-card .lead { color: var(--ink-soft); line-height: 1.6; margin: 8px 0 24px; }
.btn.steam {
  display: inline-flex; align-items: center; gap: 10px;
  background: linear-gradient(120deg, #1b9fff, #2a5fff); color: #fff;
  font-size: 1rem; padding: 14px 26px;
}
.login-card .fineprint { color: var(--ink-faint); font-size: 0.8rem; margin: 18px 0 0; }

/* ---- signed-in chip ------------------------------------------------------ */
.userchip {
  display: flex; align-items: center; gap: 10px;
  background: var(--glass); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 5px 8px 5px 5px;
}
.userchip[hidden] { display: none; }
.userchip img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.userchip #user-name { font-size: 0.9rem; font-weight: 600; }
.userchip .logout {
  font-size: 0.82rem; color: var(--ink-soft); text-decoration: none;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-2);
  transition: color 0.18s ease, border-color 0.18s ease;
}
.userchip .logout:hover { color: var(--danger); border-color: var(--danger); }

/* ---- public-wishlist caveat ---------------------------------------------- */
.caveat {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin: 14px 2px 0; color: var(--ink-soft); font-size: 0.88rem;
}
.linklike {
  background: none; border: 0; color: var(--brand-deep); cursor: pointer;
  font: inherit; padding: 0; text-decoration: underline;
}
.howto {
  margin: 10px 2px 0; padding: 12px 14px; border-radius: 12px;
  background: var(--glass-2); border: 1px solid var(--line);
  color: var(--ink-soft); font-size: 0.86rem; line-height: 1.55;
}
.howto[hidden] { display: none; }

/* ---- private-wishlist notice card ---------------------------------------- */
.notice {
  grid-column: 1 / -1; max-width: 560px;
  background: var(--glass); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); padding: 22px 24px;
  animation: cardIn 0.4s both;
}
.notice h3 { font-family: var(--font-display); margin: 0 0 8px; font-size: 1.15rem; }
.notice p { color: var(--ink-soft); line-height: 1.6; margin: 0 0 10px; }
.notice ol { margin: 0 0 10px; padding-left: 20px; color: var(--ink); line-height: 1.7; }
.notice .fineprint { color: var(--ink-faint); font-size: 0.82rem; margin: 0; }

/* ---- friends bar + discovery --------------------------------------------- */
.friendsbar { display: flex; align-items: center; gap: 12px; margin: 16px 2px 0; flex-wrap: wrap; }
.friendsbar[hidden] { display: none; }
.friends-strip { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.friends-empty { color: var(--ink-faint); font-size: 0.88rem; align-self: center; }
.friend-chip {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  background: var(--glass); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 4px 12px 4px 4px; color: var(--ink); font-size: 0.88rem;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.friend-chip:hover { text-decoration: none; border-color: var(--brand); background: var(--mint-soft); transform: translateY(-1px); }
.friend-chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.btn.small { padding: 8px 14px; font-size: 0.85rem; box-shadow: none; }

.discovery {
  margin: 12px 2px 0; background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 14px 16px;
  animation: fadeUp 0.3s both;
}
.discovery[hidden] { display: none; }
.disc-title { font-family: var(--font-display); font-weight: 600; margin-bottom: 10px; }
.disc-loading, .disc-msg { color: var(--ink-soft); font-size: 0.9rem; line-height: 1.5; }
.disc-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.disc-row:first-of-type { border-top: 0; }
.disc-user { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); flex: 1; min-width: 0; }
.disc-user:hover { text-decoration: none; color: var(--brand-deep); }
.disc-user img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }

/* ---- tabs + sort control row ---------------------------------------------- */
.control-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin: 12px 2px 0;
}
.control-row[hidden] { display: none; }
.control-row .tabs, .control-row .toolbar { margin: 0; }
.control-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.filter-group { display: flex; align-items: center; gap: 10px; }

/* hover tooltip (used by the store filter) */
.tip { position: relative; }
.tip:hover::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 70;
  width: max-content; max-width: 260px; white-space: normal; text-align: left;
  background: var(--ink); color: #fbf4da;
  font-size: 0.8rem; font-weight: 500; line-height: 1.45;
  padding: 9px 12px; border-radius: 10px; box-shadow: var(--shadow);
  pointer-events: none;
}
.tabs { display: flex; gap: 6px; margin: 18px 2px 0; }
.tabs[hidden] { display: none; }
.tab {
  background: transparent; border: 1px solid var(--line-2); color: var(--ink-soft);
  border-radius: 999px; padding: 8px 16px; font: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.tab:hover { color: var(--ink); background: var(--mint-soft); border-color: var(--teal-tint); }
.tab.active { background: var(--brand-deep); color: #fff; border-color: transparent; }

/* ---- "wanted by" tag on feed cards --------------------------------------- */
.card .wanted { font-size: 0.8rem; color: var(--brand-deep); font-weight: 600; }

/* ---- profile page header -------------------------------------------------- */
.profile-head {
  display: flex; align-items: center; gap: 16px; margin: 8px 2px 18px;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px 20px;
}
.phead-av { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; }
.phead-info { flex: 1; min-width: 0; }
.phead-info h1 { font-size: 1.4rem; margin: 0; }
.phead-sub { color: var(--ink-soft); font-size: 0.9rem; margin-top: 2px; }

/* ---- taste-match overlap -------------------------------------------------- */
.overlap {
  margin: 0 2px 16px; background: var(--glass); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); padding: 16px 18px; animation: fadeUp 0.3s both;
}
.overlap[hidden] { display: none; }
.ov-title { font-family: var(--font-display); font-weight: 600; margin-bottom: 10px; }
.ov-item { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 6px 0; font-size: 0.9rem; }
.ov-item:hover { text-decoration: none; color: var(--brand-deep); }
.ov-item img { width: 46px; height: 22px; object-fit: cover; border-radius: 4px; }

/* ---- search reveal + header link ----------------------------------------- */
.search-toggle { margin: 16px 2px 0; }
.search-area[hidden] { display: none; }
.search-area { animation: fadeUp 0.3s both; }
.user-link { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: inherit; }
.user-link:hover { text-decoration: none; }
#user-name { display: none; }
#user-avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none;
  border: 1px solid var(--line-2); transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.user-link:hover #user-avatar { border-color: var(--brand); box-shadow: 0 0 0 3px var(--mint-soft); }

.hdr-divider { width: 1px; height: 24px; background: var(--line-2); margin: 0 3px; flex: none; }

.header-actions .logout {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: 1px solid var(--line-2); border-radius: 11px;
  color: var(--ink-soft); text-decoration: none;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.header-actions .logout:hover { color: var(--danger); border-color: var(--danger); background: #fbe9e7; }
.logout-text { display: none; }
.logout-ic { display: inline-flex; }

/* ---- "friends also want this" -------------------------------------------- */
.also-wanted { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--ink-soft); }
.aw-av { display: inline-flex; margin-left: -6px; }
.aw-av:first-child { margin-left: 0; }
.aw-av img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; border: 2px solid var(--glass); }

/* ---- profile: self panels + edit ----------------------------------------- */
.self-panels[hidden] { display: none; }
.panel {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 18px; margin: 0 2px 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel h2 { font-family: var(--font-display); font-size: 1.05rem; margin: 0; }
.fr-list { display: flex; flex-direction: column; gap: 2px; }
.fr-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; transition: background 0.15s ease; }
.fr-row:hover { background: var(--mint-soft); }
.fr-user { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); flex: 1; min-width: 0; }
.fr-user:hover { text-decoration: none; color: var(--brand-deep); }
.fr-user img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.edit-panel { display: flex; flex-direction: column; gap: 6px; }
.edit-panel label { font-size: 0.85rem; color: var(--ink-soft); margin-top: 6px; }
.edit-panel .muted { color: var(--ink-faint); }
.edit-panel input, .edit-panel textarea {
  width: 100%; background: #fffdf3; border: 1px solid var(--line-2);
  color: var(--ink); border-radius: var(--r); padding: 10px 12px; font: inherit; resize: vertical;
}
.edit-panel input:focus, .edit-panel textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(10, 147, 150, 0.18);
}
.edit-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.phead-bio { color: var(--ink-soft); font-size: 0.9rem; margin-top: 6px; line-height: 1.5; }
.signout-row { margin: 4px 2px 0; }

/* ---- header actions: region + search + chip ------------------------------ */
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-actions[hidden] { display: none; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--line-2); color: var(--ink-soft);
  transition: color 0.18s ease, border-color 0.18s ease;
}
.icon-btn:hover { color: var(--brand-deep); border-color: var(--brand); background: var(--mint-soft); }

.region-dd { position: relative; }
.region-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--glass); border: 1px solid var(--line-2); color: var(--ink);
  border-radius: 11px; padding: 8px 11px; font: inherit; font-size: 0.9rem; font-weight: 600;
  transition: border-color 0.18s ease;
}
.region-btn:hover { border-color: var(--brand); background: var(--mint-soft); }
.region-btn .region-globe { color: var(--brand-deep); flex: none; }
.region-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  width: 210px; max-height: 320px; overflow-y: auto;
  background: var(--glass); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 6px; box-shadow: var(--shadow);
}
.region-menu[hidden] { display: none; }
.region-item {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; color: var(--ink-soft); font: inherit; font-size: 0.88rem;
  padding: 8px 10px; border-radius: 8px;
}
.region-item:hover { background: var(--mint-soft); color: var(--ink); }
.region-item.sel { color: var(--brand-deep); font-weight: 600; }

/* ---- search popover ------------------------------------------------------- */
.search-pop {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%);
  width: min(560px, 92vw); z-index: 55;
  background: var(--glass); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 16px;
  box-shadow: var(--shadow); animation: fadeUp 0.25s both;
}
.search-pop[hidden] { display: none; }
.caveat-mini { color: var(--ink-faint); font-size: 0.82rem; margin: 10px 2px 0; }

/* ---- profile stats row ---------------------------------------------------- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 2px 18px; }
.stats-row[hidden] { display: none; }
.stat {
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 12px; text-align: center;
}
.stat-num { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; letter-spacing: -0.5px; color: var(--brand-deep); }
.stat-label { color: var(--ink-soft); font-size: 0.8rem; margin-top: 2px; }
.stat.sale { border-color: rgba(238, 155, 0, 0.45); background: linear-gradient(180deg, rgba(238,155,0,.07), var(--glass)); }
.stat.sale .stat-num { color: var(--sale-2); }
.stat.deal { border-color: rgba(187, 62, 3, 0.35); background: linear-gradient(180deg, rgba(187,62,3,.06), var(--glass)); }
.stat.deal .stat-num { color: var(--sale); }

/* ---- friends slide-in drawer --------------------------------------------- */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 75; display: none;
  background: rgba(0, 18, 25, 0.28); animation: fadeUp 0.2s both;
}

.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 300px; max-width: 86vw; z-index: 80;
  background: var(--glass); border-left: 1px solid var(--line-2);
  box-shadow: -22px 0 60px -34px rgba(0, 18, 25, 0.5);
  transform: translateX(100%); transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex; flex-direction: column;
}
body.drawer-open .drawer { transform: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 12px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-family: var(--font-display); font-size: 1.1rem; margin: 0; }
.drawer-close {
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--line-2); color: var(--ink-soft); font-size: 1rem; line-height: 1;
  transition: color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.drawer-close:hover { color: var(--danger); border-color: var(--danger); transform: rotate(90deg); }
.drawer-body { padding: 8px 16px 20px; overflow-y: auto; flex: 1; }
.drawer-body .fr-row { padding: 9px 8px; border-bottom: 1px solid var(--line); border-radius: 0; }
.drawer-body .fr-row:last-child { border-bottom: 0; }
.drawer-body .fr-row:hover { background: var(--mint-soft); }
.drawer-foot { padding: 12px 16px 18px; border-top: 1px solid var(--line); }
.drawer-foot a {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.9rem;
}

/* ---- alerts: notification bell + panel + toasts --------------------------- */
.bell-wrap { position: relative; display: inline-flex; }
.bell-badge {
  position: absolute; top: -4px; right: -4px; z-index: 1;
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 0.68rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-0);
}
.bell-badge[hidden] { display: none; }
.bell-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 65;
  width: 340px; max-width: 92vw; max-height: 72vh; overflow-y: auto;
  background: var(--glass); border: 1px solid var(--line-2); border-radius: 14px;
  box-shadow: var(--shadow); animation: fadeUp 0.2s both;
}
.bell-panel[hidden] { display: none; }
.bell-head {
  font-family: var(--font-display); font-weight: 600; font-size: 1rem;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--glass);
}
.bell-body { padding: 6px; }
.alert-empty { color: var(--ink-soft); font-size: 0.88rem; line-height: 1.5; padding: 14px 12px 18px; }
.alert-row {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  text-decoration: none; color: var(--ink); transition: background 0.15s ease;
}
.alert-row:hover { text-decoration: none; background: var(--mint-soft); }
.alert-av { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; }
.alert-img { width: 64px; height: 30px; border-radius: 6px; object-fit: cover; flex: none; }
.alert-txt { font-size: 0.86rem; line-height: 1.4; min-width: 0; }
.alert-txt b { font-weight: 600; }
.alert-time, .alert-sub { display: block; color: var(--ink-faint); font-size: 0.78rem; margin-top: 2px; }
.alert-cut { color: var(--sale); font-weight: 700; }
.alert-was { color: var(--ink-faint); text-decoration: line-through; font-size: 0.8rem; }

.toast-wrap {
  position: fixed; right: 18px; bottom: 18px; z-index: 90;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer; max-width: 320px;
  background: var(--ink); color: #fbf4da; font-size: 0.88rem; line-height: 1.4;
  padding: 12px 15px; border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); transition: opacity 0.28s ease, transform 0.28s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast b { font-weight: 700; color: #fff; }

@media (min-width: 980px) {
  body.drawer-open .wrap { margin-right: 320px; }
}
@media (max-width: 979px) {
  body.drawer-open .drawer-scrim { display: block; }
}

/* ---- phones --------------------------------------------------------------- */
@media (max-width: 640px) {
  .wrap { padding: 16px 14px 80px; }
  .grid { gap: 14px; }

  /* One balanced header row: brand left, control cluster right (mirrors desktop). */
  header.top { margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
  .brand { flex: 0 1 auto; min-width: 0; gap: 8px; }
  .brand .ww-icon { width: 32px; height: 32px; }
  .brand .wordmark { font-size: 1.15rem; white-space: nowrap; }
  .subtle { display: none; }
  .header-actions { margin-left: auto; gap: 5px; }
  .region-btn { padding: 8px 8px; }
  .region-btn .region-globe { display: none; }   /* tighten the region pill */
  .icon-btn { width: 32px; height: 32px; }
  #user-avatar { width: 30px; height: 30px; }
  .hdr-divider { display: none; }
  .header-actions .logout { display: none; }      /* logout moves to the profile page on phones */
  .bell-panel { width: min(340px, calc(100vw - 76px)); max-width: none; max-height: 70vh; }
  .toast-wrap { right: 12px; left: 12px; bottom: 12px; align-items: stretch; }
  .toast { max-width: none; }

  /* Controls: tabs span the row, then toggle + sort share one tidy row. */
  .control-row { margin-top: 12px; row-gap: 10px; }
  .control-row .tabs { flex: 1 1 100%; }
  .control-row .tabs .tab { flex: 1; }
  .control-right { flex: 1 1 100%; justify-content: space-between; gap: 8px; }
  .control-right .toolbar, .control-right .filter-group { flex: 0 1 auto; }
  .toolbar .sortlabel, .filter-group .sortlabel { display: none; }   /* selects already read their value */
  .control-right select { font-size: 0.8rem; padding: 7px 26px 7px 9px; background-position: right 10px center; }

  /* Search popover floats as a top sheet, independent of header height. */
  .search-pop { position: fixed; top: 12px; left: 12px; right: 12px; transform: none; width: auto; }
}

@media (max-width: 520px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ---- keyframes ------------------------------------------------------------ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes sheen { 0%, 60% { transform: translateX(-130%); } 100% { transform: translateX(130%); } }

/* ---- respect reduced-motion ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
  .card:hover { transform: none; }
  .card:hover .thumb { transform: none; }
}
