:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --ink: #0e0e10;
  --ink-2: #3a3a3f;
  --muted: #74747a;
  --faint: #b4b4b8;
  --line: rgba(14, 14, 16, 0.08);
  --line-2: rgba(14, 14, 16, 0.14);
  --track: rgba(14, 14, 16, 0.07);
  --veil: rgba(246, 246, 244, 0.86);
  --shadow: 0 1px 2px rgba(14, 14, 16, 0.04), 0 24px 60px -24px rgba(14, 14, 16, 0.18);
  --ambient: 0.32;
  --radius: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0c;
    --surface: #151517;
    --ink: #f1f1ee;
    --ink-2: #c9c9c6;
    --muted: #8d8d93;
    --faint: #4c4c52;
    --line: rgba(255, 255, 255, 0.07);
    --line-2: rgba(255, 255, 255, 0.13);
    --track: rgba(255, 255, 255, 0.08);
    --veil: rgba(11, 11, 12, 0.86);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 30px 70px -30px rgba(0, 0, 0, 0.7);
    --ambient: 0.28;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0b0c;
  --surface: #151517;
  --ink: #f1f1ee;
  --ink-2: #c9c9c6;
  --muted: #8d8d93;
  --faint: #4c4c52;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --track: rgba(255, 255, 255, 0.08);
  --veil: rgba(11, 11, 12, 0.86);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 30px 70px -30px rgba(0, 0, 0, 0.7);
  --ambient: 0.28;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 10px; }
[hidden] { display: none !important; }

/* Ambient colour lifted from the current image */
.ambient {
  position: fixed;
  inset: -25%;
  z-index: -1;
  background-size: cover;
  background-position: center;
  filter: blur(110px) saturate(1.5);
  opacity: 0;
  transition: opacity 1.2s var(--ease);
  pointer-events: none;
}
.ambient.on { opacity: var(--ambient); }

/* Bar */
.bar {
  height: 68px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.mark svg { width: 22px; height: 22px; stroke-width: 3; }
.mark .dot { fill: currentColor; stroke: none; }
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 8px 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--muted);
  font-size: 14px;
  transition: border-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.search-trigger:hover { color: var(--ink); border-color: var(--faint); }
.search-trigger:active { transform: scale(0.97); }
.search-trigger svg { width: 16px; height: 16px; }
kbd {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--track);
}

/* Stage */
.stage {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 28px 40px;
  display: flex;
  flex-direction: column;
}

/* Empty state */
.empty { flex: 1; display: flex; }
.drop {
  position: relative;
  flex: 1;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
  border-radius: 32px;
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.6s var(--ease), border-color 0.3s, background-color 0.3s;
}
.drop:hover { border-color: var(--line-2); }
.drop-title {
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-wrap: balance;
}
.drop-sub { margin-top: 14px; color: var(--muted); font-size: 14px; text-wrap: balance; }
.drop-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }

.btn {
  height: 46px;
  padding: 0 20px 0 17px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: transform 0.25s var(--ease), background-color 0.2s, border-color 0.2s, opacity 0.2s;
}
.btn svg { width: 18px; height: 18px; stroke-width: 1.8; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { opacity: 0.88; }
.btn.ghost { border: 1px solid var(--line-2); color: var(--ink); }
.btn.ghost:hover { border-color: var(--faint); background: var(--track); }
.coarse { display: none; }
@media (pointer: coarse) {
  .fine { display: none; }
  .coarse { display: inline; }
}
.model {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--track);
}
.model i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width 0.3s linear;
}

/* Result */
.result {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: start;
}
.shot {
  position: sticky;
  top: 16px;
  margin: 0;
  justify-self: end;
  width: fit-content;
  max-width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.shot img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  min-width: min(320px, 100%);
  max-height: calc(100dvh - 140px);
}
.scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 60%, transparent 100%);
  background-size: 100% 220%;
  mix-blend-mode: overlay;
}
.shot-actions {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  gap: 8px;
}
.replace {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(14, 14, 16, 0.72);
  color: #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s, transform 0.4s var(--ease);
}
.replace svg { width: 18px; height: 18px; }
.replace:hover { background: rgba(14, 14, 16, 0.88); }
.replace:active { transform: scale(0.94); }
.shot:hover .replace, .shot-actions:focus-within .replace { opacity: 1; transform: none; }
.shot:hover .replace + .replace { transition-delay: 0.04s; }

/* Camera viewfinder (laptops; phones use the native camera) */
.cam {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px;
  border: 0;
  background: transparent;
  color: #fff;
}
.cam[open] { display: grid; place-items: center; }
.cam-panel {
  width: min(960px, 100%);
  padding: 10px;
  border-radius: 30px;
  background: #0b0b0c;
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, 0.6);
}
.cam::backdrop { background: rgba(10, 10, 12, 0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cam-frame {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background: #151517;
  aspect-ratio: 16 / 10;
  max-height: calc(100dvh - 150px);
}
.cam-frame video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s var(--ease);
}
.cam-frame video.live { opacity: 1; }
.cam-frame video.mirror { transform: scaleX(-1); }
.cam-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.cam-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 10px 6px;
}
.cam-btn {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transition: background-color 0.2s, transform 0.25s var(--ease);
}
.cam-btn:hover { background: rgba(255, 255, 255, 0.16); }
.cam-btn:active { transform: scale(0.94); }
.cam-btn svg { width: 20px; height: 20px; }
#camClose { justify-self: start; }
#camFlip { justify-self: end; }
.shutter {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid #fff;
  transition: transform 0.25s var(--ease);
}
.shutter i {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s var(--ease);
}
.shutter:hover i { transform: scale(0.94); }
.shutter:active i { transform: scale(0.84); }
.shutter:focus-visible { outline-color: #fff; border-radius: 50%; }

.read { padding-top: clamp(4px, 2vh, 24px); min-width: 0; }

.skeleton { display: grid; gap: 14px; padding-top: 6px; }
.skeleton i {
  display: block;
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--track) 0%, var(--line-2) 50%, var(--track) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton i:first-child { height: 44px; border-radius: 12px; margin-bottom: 8px; }
.status { margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--muted); min-height: 18px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.head h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4.4vw, 4rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  text-wrap: balance;
}
.pct {
  flex-shrink: 0;
  margin-top: 0.35em;
  font-family: var(--mono);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
}
.meta {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--muted);
}
.desc {
  margin: 22px 0 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 54ch;
  text-wrap: pretty;
}

.group { margin-top: 40px; }
.group h2 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.group ul { list-style: none; margin: 0; padding: 0; }

.signals li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  align-items: center;
  gap: 20px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.signals.plain li { grid-template-columns: 1fr; }
.bar-track { height: 3px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 3px; background: var(--ink); transform-origin: left; }

.alts li { border-bottom: 1px solid var(--line); }
.alts button {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  transition: padding 0.4s var(--ease), color 0.2s;
}
.alts button:hover { padding-left: 6px; }
.alts .num { font-family: var(--mono); font-size: 13px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.alts svg { width: 16px; height: 16px; color: var(--faint); transition: transform 0.4s var(--ease), color 0.2s; }
.alts button:hover svg { transform: translateX(3px); color: var(--ink); }
.alts .cat { display: block; font-size: 13px; font-weight: 400; color: var(--muted); }

/* Style-only view (opened from search with no image) */
.result.solo { grid-template-columns: minmax(0, 1fr); max-width: 720px; margin: 0 auto; width: 100%; }
.result.solo .shot { display: none; }

/* Search */
.search {
  width: min(620px, calc(100vw - 32px));
  max-height: min(560px, calc(100dvh - 120px));
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  flex-direction: column;
}
.search[open] { display: flex; }
.search::backdrop { background: rgba(10, 10, 12, 0.32); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.search-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 18px;
  height: 58px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.search-box svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.search-box input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.search-box input::placeholder { color: var(--faint); }
.list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; overscroll-behavior: contain; }
.list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.list li[aria-selected="true"] { background: var(--track); }
.list .n { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .c { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .p { font-family: var(--mono); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.list .none { cursor: default; color: var(--muted); font-size: 15px; display: block; }

/* Window-wide drop veil */
.dropveil {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--veil);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.dropveil span {
  font-size: clamp(1.4rem, 2.6vw, 2rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  padding: 26px 40px;
  border: 1.5px dashed var(--ink);
  border-radius: 24px;
}
body.dragging .dropveil { opacity: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.5s var(--ease);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .bar { padding: 0 16px; height: 60px; }
  .stage { padding: 4px 16px 32px; }
  .search-trigger { padding: 0; width: 38px; justify-content: center; }
  .search-trigger .label, .search-trigger kbd { display: none; }
  .drop { border-radius: 26px; min-height: 0; }
  .result { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .shot { position: relative; top: 0; justify-self: center; }
  .shot img { max-height: 46dvh; }
  .replace { opacity: 1; transform: none; }
  .drop-actions { flex-direction: column; align-items: stretch; width: 100%; max-width: 280px; }
  .btn { justify-content: center; }
  .group { margin-top: 32px; }
  .search { margin-top: 10px; max-height: calc(100dvh - 20px); }
}

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