/* ==========================================================================
   Diecast Vault — styles
   1. Tokens   2. Base   3. Layout & header   4. Hero & stats
   5. Controls & chips   6. Cards   7. Modals & forms   8. Feedback   9. Responsive
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  --bg: #0D0F12;
  --bg-deep: #090B0D;
  --surface: #161920;
  --surface-2: #1B1F28;
  --surface-3: #222734;
  --field: #0F1216;
  --border: #262B36;
  --border-strong: #343A48;

  --text: #F5F7FA;
  --text-2: #C9CFDA;
  --muted: #8A93A6;
  --faint: #5B6376;

  --accent: #00E5FF;
  --accent-soft: rgba(0, 229, 255, 0.12);
  --accent-glow: rgba(0, 229, 255, 0.28);
  --crimson: #FF3B30;
  --crimson-soft: rgba(255, 59, 48, 0.13);
  --gold: #FFC94D;
  --gold-soft: rgba(255, 201, 77, 0.13);
  --rose: #FF7AB6;
  --rose-soft: rgba(255, 122, 182, 0.13);

  --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --ease: cubic-bezier(0.2, 0.75, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.02);
  color-scheme: dark;
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
body.has-modal { overflow: hidden; }

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

/* Ambient background: drifting glow orbs + tech grid that lights up around the cursor */
.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -20%, #0B1A22 0%, transparent 60%),
    linear-gradient(180deg, #0B1016 0%, var(--bg) 45%, var(--bg-deep) 100%);
}
.orb {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
  animation: drift 26s ease-in-out infinite alternate;
}
.orb--1 {
  top: -22vmax; right: -14vmax;
  width: 62vmax; height: 62vmax;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.24) 0%, rgba(0, 229, 255, 0.08) 38%, transparent 68%);
}
.orb--2 {
  top: 28vh; left: -24vmax;
  width: 58vmax; height: 58vmax;
  background: radial-gradient(circle, rgba(0, 110, 255, 0.20) 0%, rgba(0, 110, 255, 0.06) 40%, transparent 68%);
  animation-duration: 32s;
  animation-delay: -8s;
}
.orb--3 {
  bottom: -30vmax; right: 8vw;
  width: 54vmax; height: 54vmax;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.14) 0%, rgba(0, 229, 255, 0.04) 42%, transparent 68%);
  animation-duration: 38s;
  animation-delay: -16s;
}
.orb--4 {
  top: 8vh; left: 30vw;
  width: 30vmax; height: 30vmax;
  background: radial-gradient(circle, rgba(255, 59, 48, 0.07) 0%, transparent 65%);
  animation-duration: 30s;
  animation-direction: alternate-reverse;
}

.ambient__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.05) 1px, transparent 1px);
  background-size: 64px 64px;
  background-position: center top;
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 60% 0%, #000 0%, transparent 75%);
  mask-image: radial-gradient(ellipse 90% 70% at 60% 0%, #000 0%, transparent 75%);
}
.ambient__grid--lit {
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.28) 1px, transparent 1px);
  -webkit-mask-image: radial-gradient(260px circle at var(--px, -999px) var(--py, -999px), #000 0%, transparent 100%);
  mask-image: radial-gradient(260px circle at var(--px, -999px) var(--py, -999px), #000 0%, transparent 100%);
  opacity: var(--spot, 0);
  transition: opacity 0.5s var(--ease);
}
.ambient__grid--lit::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(420px circle at var(--px, -999px) var(--py, -999px), rgba(0, 229, 255, 0.10), transparent 70%);
}

h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img { display: block; max-width: 100%; }
::selection { background: var(--accent); color: #031519; }

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

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 2; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font: 500 11px/1 var(--font-display);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font: 600 11.5px/1 var(--font-display);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease),
    transform 0.25s var(--ease), box-shadow 0.3s var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn--primary {
  background: var(--accent);
  color: #031519;
  font-weight: 600;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn--primary:hover { background: #5CF0FF; box-shadow: 0 8px 32px -6px var(--accent-glow); }
.btn--ghost {
  background: rgba(22, 25, 32, 0.7);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.btn--ghost:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.btn--danger { background: var(--crimson); color: #fff; font-weight: 600; }
.btn--danger:hover { background: #FF5A50; box-shadow: 0 8px 28px -8px rgba(255, 59, 48, 0.5); }
.btn--ghost.btn--danger { background: transparent; color: #FF6B61; border-color: rgba(255, 59, 48, 0.28); font-weight: 500; }
.btn--ghost.btn--danger:hover { background: var(--crimson-soft); border-color: rgba(255, 59, 48, 0.5); box-shadow: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--text-2);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn .icon { width: 17px; height: 17px; }
.icon-btn--glass {
  background: rgba(13, 15, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.icon-btn--glass:hover { background: var(--text); color: var(--bg); }
.icon-btn--danger:hover { background: var(--crimson); color: #fff; border-color: transparent; }
.icon-btn--got:hover { background: var(--accent); color: #031519; border-color: transparent; }

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 500;
  transition: opacity 0.2s;
}
.link-btn:hover { opacity: 0.8; }
.link-btn .icon { width: 15px; height: 15px; }
.link-btn--danger { color: #FF6B61; }

/* 3. Layout & header ----------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding-inline: clamp(16px, 4vw, 40px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid transparent;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}
.topbar.is-scrolled {
  background: rgba(13, 15, 18, 0.72);
  border-color: rgba(38, 43, 54, 0.7);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}
.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 72px;
}
.topbar__actions { display: flex; align-items: center; gap: 10px; }

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand__mark {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgba(0, 229, 255, 0.25));
}
.brand__name { font: 500 18px/1 var(--font-display); letter-spacing: -0.02em; }
.brand__name b { font-weight: 700; color: var(--accent); margin-left: 1px; }

/* Dropdown menus */
.menu { position: relative; }
.menu__chev { width: 15px !important; height: 15px !important; margin-left: -2px; transition: transform 0.25s var(--ease); }
.menu.is-open .menu__chev { transform: rotate(180deg); }
.menu__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: 272px;
  padding: 6px;
  background: rgba(22, 25, 32, 0.96);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  transition: opacity 0.2s var(--ease), transform 0.25s var(--ease), visibility 0.2s;
}
.menu.is-open .menu__panel { opacity: 1; visibility: visible; transform: none; }
.menu__panel button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px;
  border-radius: 11px;
  text-align: left;
  transition: background 0.18s;
}
.menu__panel button:hover, .menu__panel button:focus-visible { background: var(--surface-3); outline: none; }
.menu__panel strong { display: block; font-size: 14px; font-weight: 600; color: var(--text); }
.menu__panel small { display: block; font-size: 12.5px; color: var(--muted); }
.menu__icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* Account / sync menu: avatar with a status dot (green synced, cyan syncing, gold waiting, red problem) */
.account__btn { gap: 9px; }
.account__avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text);
  font: 600 11px/1 var(--font-display);
}
.account__avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.account__avatar .icon { width: 18px; height: 18px; }
.account:is([data-sync='signed-out'], [data-sync='disabled']) .account__avatar { width: 18px; background: none; }
.account__avatar::after {
  content: '';
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--faint);
  opacity: 0;
  transition: background 0.3s, opacity 0.3s;
}
.account[data-sync='synced'] .account__avatar::after { opacity: 1; background: #34D399; }
.account[data-sync='syncing'] .account__avatar::after { opacity: 1; background: var(--accent); animation: account-pulse 1.2s ease-in-out infinite; }
.account[data-sync='offline'] .account__avatar::after { opacity: 1; background: var(--gold); }
.account[data-sync='error'] .account__avatar::after { opacity: 1; background: var(--crimson); }
@keyframes account-pulse { 50% { opacity: 0.35; } }
.account__panel { width: 290px; }
.account__head { margin-bottom: 6px; padding: 10px 10px 12px; border-bottom: 1px solid var(--border); }
.account__head strong, .account__head small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__status { margin-top: 8px; color: var(--text-2); font-size: 12.5px; }
.menu__section { margin: 0; padding: 10px 10px 4px; color: var(--faint); font: 600 10.5px/1 var(--font-display); letter-spacing: 0.14em; text-transform: uppercase; }
.menu__panel > .menu__section:first-child { padding-top: 6px; }
.menu__divider { height: 1px; margin: 6px 4px; background: var(--border); }
.menu__item--quiet .menu__icon { background: rgba(255, 255, 255, 0.05); color: var(--text-2); }
.account[data-sync='error'] .account__status { color: #FF6B61; }
.account[data-sync='offline'] .account__status { color: var(--gold); }

/* 4. Hero & stats -------------------------------------------------------- */
.hero {
  position: relative;
  isolation: isolate;
  padding: clamp(40px, 8vw, 96px) 0 clamp(32px, 5vw, 56px);
}

/* Hero stage: glowing horizon, moving perspective floor and light-trail streaks */
.hero__stage {
  position: absolute;
  z-index: -1;
  top: -72px;
  bottom: -120px;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 12%, #000 72%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 12%, #000 72%, transparent 100%);
}
.hero__horizon {
  position: absolute;
  left: 0;
  right: 0;
  top: 64%;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(0, 229, 255, 0.25) 25%, rgba(0, 229, 255, 0.9) 68%, rgba(0, 229, 255, 0.25) 90%, transparent 100%);
  box-shadow: 0 0 24px 2px rgba(0, 229, 255, 0.45), 0 0 90px 12px rgba(0, 229, 255, 0.12);
}
.hero__floor {
  position: absolute;
  left: -40%;
  right: -40%;
  top: 64%;
  height: 90%;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.42) 1.5px, transparent 1.5px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.30) 1.5px, transparent 1.5px);
  background-size: 80px 80px;
  background-position: center 0;
  transform: perspective(420px) rotateX(62deg);
  transform-origin: 50% 0;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 35%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 35%);
  animation: floor 2.4s linear infinite;
  opacity: 0.55;
}
.streak {
  position: absolute;
  left: 0;
  height: 2px;
  width: clamp(120px, 22vw, 360px);
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(0, 229, 255, 0.9) 85%, #E6FDFF);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
  opacity: 0;
  will-change: transform;
  animation: streak 5.5s cubic-bezier(0.55, 0, 0.35, 1) infinite;
}
.streak--1 { top: 64%; animation-delay: 0.4s; }
.streak--2 { top: 71%; animation-delay: 2.1s; animation-duration: 4.2s; width: clamp(80px, 14vw, 240px); }
.streak--3 { top: 79%; animation-delay: 3.3s; animation-duration: 6.4s; }
.streak--4 { top: 67%; animation-delay: 4.6s; animation-duration: 4.8s; height: 1px; }
.streak--5 {
  top: 75%;
  animation-delay: 1.4s;
  animation-duration: 7s;
  background: linear-gradient(90deg, transparent, rgba(255, 59, 48, 0.8) 85%, #FFD9D6);
  box-shadow: 0 0 12px rgba(255, 59, 48, 0.5);
  height: 1px;
}
.hero__title {
  margin-top: 20px;
  font: 600 clamp(46px, 9vw, 116px)/0.92 var(--font-display);
  letter-spacing: -0.045em;
}
.hero__title em {
  font-style: normal;
  background: linear-gradient(92deg, var(--accent) 0%, #8DF6FF 45%, #F5F7FA 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* Signed in: "Welcome to / your garage, Cristian." — smaller so the name fits beside "garage" on wide screens
   and drops to its own line on narrow ones (the comma stays with "garage") */
.hero__title.has-name { font-size: clamp(40px, 7.2vw, 96px); line-height: 0.96; }
.hero__line { white-space: nowrap; }
.hero__name[hidden] { display: none; }
.hero__name { display: inline-block; max-width: 100%; overflow-wrap: anywhere; animation: hero-name-in 0.7s var(--ease) both; }
@keyframes hero-name-in { from { opacity: 0; transform: translateY(0.12em); } }
.hero__lede {
  max-width: 540px;
  margin-top: 24px;
  color: var(--muted);
  font-size: clamp(15px, 1.4vw, 17px);
}
.pulse {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}
.pulse::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  animation: pulse 2.4s var(--ease) infinite;
}

.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.reveal:nth-child(2) { transition-delay: 0.08s; }
.reveal:nth-child(3) { transition-delay: 0.16s; }
body.is-ready .reveal { opacity: 1; transform: none; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: clamp(36px, 5vw, 56px);
}
.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 20px 20px 18px;
  background: linear-gradient(180deg, rgba(27, 31, 40, 0.75), rgba(22, 25, 32, 0.6));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  animation: rise 0.8s var(--ease) both;
}
.stat:nth-child(2) { animation-delay: 0.06s; }
.stat:nth-child(3) { animation-delay: 0.12s; }
.stat:nth-child(4) { animation-delay: 0.18s; }
.stat--accent {
  border-color: rgba(0, 229, 255, 0.28);
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(0, 229, 255, 0.16), transparent 55%),
    linear-gradient(180deg, rgba(27, 31, 40, 0.8), rgba(22, 25, 32, 0.6));
}
.stat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.stat__head .icon { width: 16px; height: 16px; color: var(--faint); }
.stat--accent .stat__head .icon { color: var(--accent); }
.stat__value {
  margin-top: 6px;
  font: 600 26px/1.1 var(--font-display);
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat__value.is-num { font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat--accent .stat__value { color: var(--accent); }
.stat__sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat__meter { height: 3px; margin-top: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.stat__meter span {
  display: block;
  height: 100%;
  width: var(--w);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #8DF6FF);
  box-shadow: 0 0 10px var(--accent-glow);
  animation: meter 1.2s var(--ease) 0.2s both;
}

/* Wishlist tile: links through to the wishlist */
.stat--link {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.stat--link .stat__head .icon { color: var(--rose); }
.stat--link:hover, .stat--link:focus-visible {
  border-color: rgba(255, 122, 182, 0.4);
  box-shadow: 0 18px 44px -26px rgba(255, 122, 182, 0.5);
  outline: none;
}
.stat__go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 4px;
  color: var(--rose);
  font-size: 12.5px;
  font-weight: 500;
}
.stat__go .icon { width: 14px; height: 14px; transition: transform 0.3s var(--ease); }
.stat--link:hover .stat__go .icon { transform: translateX(3px); }

/* Collection / wishlist switch */
.tabs {
  display: flex;
  gap: 4px;
  width: fit-content;
  margin-bottom: 18px;
  padding: 4px;
  background: rgba(22, 25, 32, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scroll-margin-top: 96px;
}
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 10px 0 16px;
  border-radius: 10px;
  color: var(--muted);
  font: 500 15px/1 var(--font-display);
  letter-spacing: -0.01em;
  transition: background 0.25s var(--ease), color 0.25s;
}
.tabs button .icon { width: 17px; height: 17px; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected='true'] { background: var(--surface-3); color: var(--text); }
.tabs button[data-section='collection'][aria-selected='true'] .icon { color: var(--accent); }
.tabs button[data-section='wishlist'][aria-selected='true'] .icon { color: var(--rose); }
.tabs__count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font: 600 11.5px/1 var(--font-display);
  transition: background 0.25s var(--ease), color 0.25s;
}
.tabs button[data-section='collection'][aria-selected='true'] .tabs__count { background: var(--accent); color: #031519; }
.tabs button[data-section='wishlist'][aria-selected='true'] .tabs__count { background: var(--rose); color: #2A0616; }

/* 5. Controls & chips ---------------------------------------------------- */
.controls { display: flex; flex-wrap: wrap; gap: 12px; }
.search { position: relative; flex: 1 1 340px; min-width: 0; }
.search input {
  width: 100%;
  height: 50px;
  padding: 0 48px 0 46px;
  background: rgba(22, 25, 32, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.25s var(--ease), background 0.2s;
}
.search input::placeholder { color: var(--faint); }
.search input:hover { border-color: var(--border-strong); }
.search input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input::-webkit-search-cancel-button { filter: invert(0.6); cursor: pointer; }
.search__icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search__kbd { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; transition: opacity 0.2s; }
.search input:focus ~ .search__kbd, .search input:not(:placeholder-shown) ~ .search__kbd { opacity: 0; }

.controls__row { display: flex; flex-wrap: wrap; gap: 12px; }
.select {
  position: relative;
  display: flex;
  align-items: center;
  height: 50px;
  padding-left: 14px;
  background: rgba(22, 25, 32, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s, box-shadow 0.25s var(--ease);
}
.select:hover { border-color: var(--border-strong); }
.select:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.select::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select__label {
  color: var(--faint);
  font: 600 10.5px/1 var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.select select {
  appearance: none;
  -webkit-appearance: none;
  height: 100%;
  min-width: 0;
  max-width: 220px;
  padding: 0 38px 0 10px;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-overflow: ellipsis;
}
select option, select optgroup { background: var(--surface); color: var(--text); }

.view-toggle {
  display: inline-flex;
  padding: 4px;
  height: 50px;
  background: rgba(22, 25, 32, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.view-toggle button {
  display: grid;
  place-items: center;
  width: 40px;
  border-radius: 10px;
  color: var(--muted);
  transition: background 0.25s var(--ease), color 0.25s;
}
.view-toggle button:hover { color: var(--text); }
.view-toggle button[aria-pressed='true'] { background: var(--surface-3); color: var(--accent); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 8px 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(22, 25, 32, 0.6);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), color 0.3s var(--ease), transform 0.2s var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip:active { transform: scale(0.96); }
.chip .icon { width: 14px; height: 14px; color: var(--crimson); margin-right: -2px; }
.chip__count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font: 600 11px/1 var(--font-display);
  transition: inherit;
}
.chip.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip.is-active .chip__count { background: var(--accent); color: #031519; }
.chip--diecast.is-active { border-color: var(--crimson); background: var(--crimson-soft); color: #FF6B61; }
.chip--diecast.is-active .icon { color: #FF6B61; }
.chip--diecast.is-active .chip__count { background: var(--crimson); color: #fff; }
.chip--shelf .icon { color: var(--gold); }
.chip--chase .icon { color: var(--rose); }
.chip--dupes .icon { color: var(--text-2); }
.chip--category .icon { color: var(--accent); }
.chip--category.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chip--category.is-active .chip__count { background: var(--accent); color: var(--bg); }
.chip--dupes.is-active { border-color: var(--text-2); background: rgba(255, 255, 255, 0.08); color: var(--text); }
.chip--dupes.is-active .chip__count { background: var(--text-2); color: var(--bg); }
.chip--chase.is-active { border-color: var(--rose); background: var(--rose-soft); color: var(--rose); }
.chip--chase.is-active .chip__count { background: var(--rose); color: #2A0616; }
.chip--shelf.is-active { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }
.chip--shelf.is-active .chip__count { background: var(--gold); color: #1A1300; }
.chip--all.is-active { border-color: var(--text); background: var(--text); color: var(--bg); }
.chip--all.is-active .chip__count { background: var(--bg); color: var(--text); }

.results-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
  margin: 26px 0 16px;
  color: var(--muted);
  font-size: 14px;
}
.results-meta b { color: var(--text); font-weight: 600; }
.results-meta__actions { display: flex; flex-shrink: 0; gap: 18px; }

/* 6. Cards --------------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  padding-bottom: 72px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  isolation: isolate;
  transition: transform 0.5s var(--ease), border-color 0.4s var(--ease), box-shadow 0.5s var(--ease);
}
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(0, 229, 255, 0.09), transparent 45%);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.card:hover, .card:focus-visible {
  transform: translateY(-5px);
  border-color: rgba(0, 229, 255, 0.35);
  box-shadow: 0 24px 60px -28px rgba(0, 229, 255, 0.35), 0 12px 30px -12px rgba(0, 0, 0, 0.6);
  outline: none;
}
.card:hover::after, .card:focus-visible::after { opacity: 1; }
.card.is-entering { animation: cardIn 0.55s var(--ease) both; animation-delay: calc(var(--i, 0) * 28ms); }

/* Shared media container (cards, preview, detail) */
.media { position: relative; overflow: hidden; background: #111419; }
.media img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.6s var(--ease), transform 1s var(--ease);
}
.media.is-loaded img { opacity: 1; transform: scale(1); }
.media__ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(80% 70% at 50% 110%, rgba(0, 229, 255, 0.14), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 28px),
    linear-gradient(160deg, #1A1E27, #0F1216);
}
.media__initials {
  font: 700 clamp(56px, 7vw, 88px)/1 var(--font-display);
  letter-spacing: -0.05em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.14);
  grid-area: 1 / 1;
}
.media__ph .icon { grid-area: 1 / 1; width: 30px; height: 30px; color: var(--accent); opacity: 0.8; transform: translateY(42px); }

.card__media { aspect-ratio: 4 / 3; }
.card__media::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(9, 11, 13, 0.55) 0%, transparent 32%, transparent 62%, rgba(9, 11, 13, 0.55) 100%);
}
.card:hover .media.is-loaded img { transform: scale(1.09); }

.badge, .scale-tag {
  position: absolute;
  top: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 8px;
  font: 600 10.5px/1 var(--font-display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.badge {
  left: 12px;
  max-width: calc(100% - 96px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  line-height: 26px;
  background: rgba(13, 15, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
}
.scale-tag {
  right: 12px;
  background: rgba(13, 15, 18, 0.66);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: var(--accent);
  letter-spacing: 0.06em;
}

.card__actions {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  gap: 8px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s var(--ease), transform 0.35s var(--ease);
}
.card:hover .card__actions, .card:focus-within .card__actions { opacity: 1; transform: none; }

.card__body { display: flex; flex-direction: column; gap: 12px; flex: 1; padding: 16px 18px 18px; }
.card__title {
  font: 600 18px/1.25 var(--font-display);
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__make { color: var(--muted); font-weight: 500; }
.card__year { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.card__meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; }
.card__series { min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.pill .icon { width: 13px; height: 13px; }
.pill--mint { background: var(--accent-soft); color: #5CF0FF; }
.pill--loose { background: rgba(255, 255, 255, 0.06); color: var(--text-2); }
.pill--custom { background: var(--crimson-soft); color: #FF6B61; }
.pill--shelf { background: var(--gold-soft); color: var(--gold); }
.pill--chase { background: var(--rose-soft); color: var(--rose); }
.pill--dupe { background: rgba(255, 255, 255, 0.08); color: var(--text-2); }
.card__pills { display: flex; flex-shrink: 0; gap: 6px; }
.pill--brand { max-width: 100%; background: rgba(255, 255, 255, 0.06); color: var(--text); font: 600 10px/1 var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 24px; }
.pill--scale { background: transparent; border: 1px solid rgba(0, 229, 255, 0.4); color: var(--accent); letter-spacing: 0.04em; }
/* Grid view shows brand, scale and actions over the photo; list view moves them next to the text */
.card__inline-actions, .pill--brand, .pill--scale { display: none; }
.card__btn { width: 36px; height: 36px; border-radius: 11px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); }
.card__btn .icon { width: 16px; height: 16px; }

/* List view */
.grid[data-view='list'] { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.grid[data-view='list'] .card { flex-direction: row; }
.grid[data-view='list'] .card:hover { transform: translateX(4px); }
.grid[data-view='list'] .card__media { flex: 0 0 240px; aspect-ratio: 16 / 10; }
.grid[data-view='list'] .card__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'title title' 'meta actions';
  align-content: center;
  gap: 12px 14px;
  padding: 18px 24px;
}
/* The name gets the full width; actions share the row with the tags */
.grid[data-view='list'] .card__title { grid-area: title; font-size: 21px; }
.grid[data-view='list'] .card__inline-actions { grid-area: actions; display: flex; gap: 8px; align-self: end; }
.grid[data-view='list'] .card__meta { grid-area: meta; align-self: center; margin-top: 0; justify-content: flex-start; flex-wrap: wrap; min-width: 0; }
.grid[data-view='list'] .card__pills { flex-wrap: wrap; flex-shrink: 1; min-width: 0; }
.grid[data-view='list'] .pill--scale { display: inline-flex; }
.grid[data-view='list'] .pill--brand { display: inline-block; }
/* Most of the collection is loose 1:64 — only tag the exceptions */
.grid[data-view='list'] .pill--scale.is-default,
.grid[data-view='list'] .pill--loose { display: none; }
.grid[data-view='list'] .card__media .badge,
.grid[data-view='list'] .card__media .scale-tag,
.grid[data-view='list'] .card__media .card__actions { display: none; }

/* Empty state */
.empty { padding: 56px 16px 96px; text-align: center; }
.empty__art {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 0 auto 22px;
  border-radius: 28px;
  color: var(--accent);
  background: linear-gradient(145deg, rgba(0, 229, 255, 0.16), rgba(0, 229, 255, 0.02));
  border: 1px solid rgba(0, 229, 255, 0.25);
  box-shadow: 0 0 60px -10px var(--accent-glow);
  animation: rise 0.7s var(--ease-spring) both;
}
.empty__art .icon { width: 34px; height: 34px; }
.empty__art--wish {
  color: var(--rose);
  background: linear-gradient(145deg, rgba(255, 122, 182, 0.16), rgba(255, 122, 182, 0.02));
  border-color: rgba(255, 122, 182, 0.28);
  box-shadow: 0 0 60px -10px rgba(255, 122, 182, 0.35);
}
.empty p b { color: var(--text-2); font-weight: 600; }
.empty h2 { font: 600 26px/1.2 var(--font-display); letter-spacing: -0.02em; }
.empty p { max-width: 420px; margin: 10px auto 0; color: var(--muted); }
.empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding-top: 28px;
  padding-bottom: 40px;
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 13px;
}
.footer__keys { display: inline-flex; align-items: center; gap: 6px; }
.footer__keys kbd:not(:first-child) { margin-left: 10px; }

/* 7. Modals & forms ------------------------------------------------------ */
dialog.modal {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: hidden;
  overflow: clip; /* not a scroll container, so focusing a control mid-animation can't scroll the sheet off-screen */
}
dialog.modal[open] { display: grid; place-items: center; }
#detailCard:focus { outline: none; }
dialog.modal::backdrop {
  background: rgba(5, 6, 8, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.3s var(--ease) both;
}
dialog.modal.is-closing::backdrop { animation: fadeOut 0.2s var(--ease) both; }

.modal__card {
  display: flex;
  flex-direction: column;
  width: min(760px, 100%);
  max-height: calc(100dvh - 48px);
  background: linear-gradient(180deg, #181C24, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.42s var(--ease) both;
}
.is-closing .modal__card { animation: modalOut 0.2s var(--ease) both; }

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--border);
}
.modal__head h2 { margin-top: 8px; font: 600 24px/1.2 var(--font-display); letter-spacing: -0.025em; }
.modal__head .icon-btn { margin: -4px -8px 0 0; }
.modal__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px 26px; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: rgba(13, 15, 18, 0.35);
}

/* Form */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 18px; align-content: start; }
.field { display: flex; flex-direction: column; min-width: 0; margin: 0; padding: 0; border: 0; }
.field--full { grid-column: 1 / -1; }
/* Model + year share one row: the year only needs room for 4 digits */
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) 118px; gap: 18px; }
.field > label, .field > legend, .field > .label {
  display: block;
  margin-bottom: 8px;
  padding: 0;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}
.req { color: var(--accent); }
.opt { margin-left: 4px; color: var(--faint); font-size: 12px; font-weight: 400; }

.input, .field select {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.25s var(--ease), background 0.2s;
}
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
  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='%238A93A6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.field select:invalid, .field select option[value=''] { color: var(--faint); }
.input::placeholder { color: var(--faint); }
.input:hover, .field select:hover { border-color: var(--border-strong); }
.input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background-color: #10151A; }
.custom-input { margin-top: 8px; animation: slideDown 0.3s var(--ease) both; }

.field__error { color: #FF6B61; font-size: 12.5px; margin-top: 6px; }
.field__error:empty { display: none; }
.field.has-error .input:not([hidden]), .field.has-error select { border-color: var(--crimson); box-shadow: 0 0 0 4px var(--crimson-soft); }
.field.has-error { animation: shake 0.35s var(--ease); }
.hint { margin-top: 8px; color: var(--faint); font-size: 12.5px; }

/* Condition pill selector */
.pills { display: flex; flex-wrap: wrap; gap: 10px; }
.pill-option { position: relative; }
.pill-option input { position: absolute; opacity: 0; pointer-events: none; }
.pill-option span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--field);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease);
}
.pill-option span .icon { width: 16px; height: 16px; }
.pill-option:hover span { border-color: var(--border-strong); color: var(--text); }
.pill-option input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill-option input:checked + span { transform: scale(1.02); }
.pill-option--mint input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pill-option--loose input:checked + span { border-color: var(--text-2); background: rgba(255, 255, 255, 0.08); color: var(--text); }
.pill-option--shelf input:checked + span { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }
.pill-option--chase input:checked + span { border-color: var(--rose); background: var(--rose-soft); color: var(--rose); }
.pill-option--dupe input:checked + span { border-color: var(--text-2); background: rgba(255, 255, 255, 0.08); color: var(--text); }
.pill-option--custom input:checked + span { border-color: var(--crimson); background: var(--crimson-soft); color: #FF6B61; }

/* Photo input */
.photo { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.photo__preview { aspect-ratio: 4 / 3; border-radius: var(--radius); border: 1px solid var(--border); }
.photo__preview .media__initials { font-size: 56px; }
.photo__preview .media__ph .icon { transform: translateY(32px); width: 24px; height: 24px; }
.photo__inputs { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.photo__inputs .link-btn { align-self: flex-start; }

.segmented {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.segmented button {
  height: 32px;
  padding: 0 14px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.25s var(--ease), color 0.25s;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected='true'] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 118px;
  padding: 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: rgba(15, 18, 22, 0.6);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.25s var(--ease);
}
.dropzone .icon { width: 26px; height: 26px; color: var(--accent); margin-bottom: 2px; }
.dropzone strong { font-size: 14px; font-weight: 500; }
.dropzone u { color: var(--accent); text-underline-offset: 3px; }
.dropzone small { color: var(--faint); font-size: 12.5px; }
.dropzone:hover, .dropzone.is-drag, .dropzone:focus-within { border-color: var(--accent); background: rgba(0, 229, 255, 0.05); }
.dropzone.is-drag { transform: scale(1.015); }
.dropzone.is-busy { opacity: 0.6; cursor: progress; }

/* Detail modal */
.modal--detail .modal__card { flex-direction: row; width: min(1040px, 100%); }
.detail__media { flex: 1.3 1 0; min-height: 460px; }
.detail__media .badge { top: 16px; left: 16px; }
.detail__info { display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; }
.detail__info .modal__head { border-bottom: 0; padding-bottom: 6px; }
.detail__info .modal__head h2 { font-size: 28px; }
.detail__info .modal__foot { margin-top: auto; }
.detail__nav { position: absolute; top: 50%; z-index: 3; transform: translateY(-50%); }
.detail__nav:active { transform: translateY(-50%) scale(0.92); }
.detail__nav--prev { left: 16px; }
.detail__nav--next { right: 16px; }
.detail__count {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 3;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(13, 15, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font: 600 12px/1 var(--font-display);
  letter-spacing: 0.08em;
  backdrop-filter: blur(10px);
}
.specs { margin: 0; padding: 4px 24px 22px; overflow-y: auto; }
.specs div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px dashed var(--border);
}
.specs div:last-child { border-bottom: 0; }
.specs dt { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; }
.specs dt .icon { width: 15px; height: 15px; color: var(--faint); }
.specs dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.specs__switch { display: inline-flex; align-items: center; gap: 12px; }

.switch {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform 0.3s var(--ease-spring), background 0.25s var(--ease);
}
.switch[aria-checked='true'] { background: var(--gold-soft); border-color: var(--gold); }
.switch[aria-checked='true']::after { transform: translateX(18px); background: var(--gold); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Confirm */
.modal--confirm .modal__card { width: min(440px, 100%); padding: 28px; text-align: center; align-items: center; }
.modal--confirm h2 { margin-top: 18px; font: 600 21px/1.25 var(--font-display); letter-spacing: -0.02em; }
.modal--confirm p { margin-top: 10px; color: var(--muted); font-size: 14.5px; }
.confirm__icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; }
.confirm__icon .icon { width: 24px; height: 24px; }
.confirm__icon--danger { background: var(--crimson-soft); color: #FF6B61; }
.confirm__icon--info { background: var(--accent-soft); color: var(--accent); }
.confirm__input { margin-top: 20px; text-align: center; letter-spacing: 0.12em; }
.confirm__actions .btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.confirm__actions { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; margin-top: 26px; }
.confirm__actions .btn { flex: 1 1 0; }

/* 8. Feedback ------------------------------------------------------------ */
.toasts {
  position: fixed;
  inset: auto 24px 24px auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px 12px 16px;
  background: rgba(27, 31, 40, 0.94);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 14px;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn 0.45s var(--ease-spring) both;
}
.toast.is-leaving { animation: toastOut 0.25s var(--ease) both; }
.toast > .icon { color: var(--accent); }
.toast--error > .icon { color: var(--crimson); }
.toast--info > .icon { color: var(--text-2); }
.toast p { flex: 1; }
.toast__action {
  padding: 6px 10px;
  margin: -4px -4px -4px 4px;
  border-radius: 8px;
  color: var(--accent);
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.2s;
}
.toast__action:hover { background: var(--accent-soft); }

/* Keyframes */
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(6vw, 4vh, 0) scale(1.12); }
  100% { transform: translate3d(-4vw, 8vh, 0) scale(0.94); }
}
@keyframes floor { to { background-position: center 80px; } }
@keyframes streak {
  0% { transform: translateX(-40vw); opacity: 0; }
  10% { opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translateX(130vw); opacity: 0; }
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes meter { from { width: 0; } }
@keyframes pulse { 0% { transform: scale(0.6); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes modalOut { to { opacity: 0; transform: translateY(12px) scale(0.98); } }
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetOut { to { transform: translateY(100%); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

/* 9. Responsive ---------------------------------------------------------- */
@media (max-width: 1180px) {
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .controls__row { flex: 1 1 100%; }
  .controls__row .select { flex: 1 1 0; min-width: 0; }
  .controls__row .select select { max-width: none; width: 100%; }
}

@media (max-width: 860px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .modal--detail .modal__card { flex-direction: column; overflow-y: auto; }
  .detail__media { flex: none; min-height: 0; aspect-ratio: 4 / 3; }
  .specs { overflow: visible; }
}

@media (max-width: 640px) {
  .btn--ghost .btn__label { display: none; }
  .topbar__actions .btn--ghost { width: 42px; padding: 0; }
  .topbar__actions .menu__chev { display: none; }
  .topbar__inner { height: 64px; }

  .stats { gap: 10px; }
  .stat { padding: 16px; }
  .stat__value { font-size: 20px; }
  .stat__value.is-num { font-size: 34px; }
  .stat__sub { font-size: 12px; }

  .tabs { width: 100%; }
  .tabs button { flex: 1; justify-content: center; padding: 0 10px; }

  .controls__row { display: grid; grid-template-columns: 1fr 1fr; }
  .view-toggle { grid-column: 1 / -1; justify-self: stretch; }
  .view-toggle button { flex: 1; }
  .select__label { display: none; }
  .select { padding-left: 12px; }
  .select::after { right: 12px; }
  .select select { padding: 0 24px 0 0; }

  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: calc(-1 * clamp(16px, 4vw, 40px));
    padding-inline: clamp(16px, 4vw, 40px);
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
  }
  .chips::-webkit-scrollbar { display: none; }

  .grid[data-view='list'] .card__media { flex-basis: 128px; aspect-ratio: 1; }
  .grid[data-view='list'] .card__body { padding: 12px 12px 12px 14px; gap: 8px 8px; }
  .grid[data-view='list'] .card__title { font-size: 16px; -webkit-line-clamp: 3; }
  .grid[data-view='list'] .card__series { display: none; }
  /* Phones: stack the actions in a slim column so the name and tags share the remaining width */
  .grid[data-view='list'] .card__body { grid-template-areas: 'title actions' 'meta actions'; column-gap: 10px; }
  .grid[data-view='list'] .card__inline-actions { flex-direction: column; gap: 6px; align-self: center; }
  .grid[data-view='list'] .card__btn { width: 34px; height: 34px; border-radius: 10px; }
  .grid[data-view='list'] .card__pills { gap: 5px; }
  .grid[data-view='list'] .pill { height: 22px; padding: 0 8px; font-size: 11px; }
  .grid[data-view='list'] .pill--brand { line-height: 22px; font-size: 9.5px; letter-spacing: 0.08em; }

  /* Modals become bottom sheets */
  dialog.modal { padding: 0; }
  dialog.modal[open] { place-items: end stretch; }
  .modal__card {
    width: 100%;
    max-height: 94dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-bottom: 0;
    animation-name: sheetIn;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .is-closing .modal__card { animation-name: sheetOut; }
  .modal--confirm .modal__card { width: 100%; }
  .modal--detail .modal__card { width: 100%; }
  .modal__head { padding: 20px 18px 14px; }
  .modal__body { padding: 18px 18px 22px; }
  .modal__foot { padding: 14px 18px; }
  .modal__foot .btn { flex: 1; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .photo { grid-template-columns: minmax(0, 1fr); }
  .photo__preview { aspect-ratio: 16 / 9; }

  .hero__horizon, .hero__floor { top: 73%; }
  .streak--1 { top: 77%; } .streak--2 { top: 81%; } .streak--3 { top: 86%; } .streak--4 { top: 79%; } .streak--5 { top: 84%; }
  .hero__floor { opacity: 0.4; background-size: 56px 56px; }
  .ambient__grid { background-size: 44px 44px; }

  .toasts { inset: auto 16px 16px 16px; align-items: stretch; }
  .toast { width: auto; max-width: none; }
  .footer__keys { display: none; }
}

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

@media (max-width: 480px) {
  .topbar__actions { gap: 8px; }
  .topbar__actions .btn--primary .btn__label { display: none; }
  .topbar__actions .btn--primary { width: 42px; padding: 0; }
}

@media (max-width: 340px) {
  .brand__name { display: none; }
}

/* Touch devices: no hover, so keep card actions visible */
@media (hover: none) {
  /* iOS zooms the page when focusing a field under 16px, and the zoom sticks in home-screen apps */
  .search input, .select select, .input, .field select { font-size: 16px; }
  .card__actions { opacity: 1; transform: none; }
  .card:hover { transform: none; }
  .card:hover .media.is-loaded img { transform: scale(1); }
}

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