:root {
  color-scheme: light;
  --ink: #111c17;
  --muted: #64736b;
  --paper: #f6f7f2;
  --surface: rgba(255, 255, 255, 0.92);
  --line: #dce2d9;
  --soft: #edf2eb;
  --accent: #0c6b58;
  --accent-dark: #074b40;
  --ring: rgba(12, 107, 88, 0.18);
  --shadow: 0 24px 80px rgba(18, 30, 24, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(12, 107, 88, 0.12), transparent 30%),
    radial-gradient(circle at 82% 14%, rgba(184, 139, 58, 0.12), transparent 28%),
    linear-gradient(180deg, #fbfcf8 0%, var(--paper) 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button,
label {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

.workspace {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr;
}

h1,
h2,
p {
  margin-top: 0;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 24% 20%, rgba(12, 107, 88, 0.14), transparent 32%),
    radial-gradient(circle at 76% 18%, rgba(184, 139, 58, 0.12), transparent 30%),
    linear-gradient(180deg, #fbfcf8 0%, var(--paper) 100%);
  z-index: 30;
}

.login-screen::before {
  content: "";
  position: absolute;
  inset: 12% -10%;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0)),
    url("https://images.unsplash.com/photo-1555041469-a586c61ea9bc?auto=format&fit=crop&w=900&q=80") 0 20% / 24rem 15rem repeat-x;
  opacity: 0.16;
  filter: saturate(0.8);
  mask-image: linear-gradient(180deg, transparent, black 28%, black 72%, transparent);
}

.login-card {
  position: relative;
  width: min(420px, 100%);
  padding: 28px;
  display: grid;
  gap: 12px;
  border: 1px solid rgba(12, 107, 88, 0.14);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.login-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: white;
  background: var(--accent);
  box-shadow: 0 12px 30px rgba(12, 107, 88, 0.24);
}

.login-mark svg {
  width: 22px;
  height: 22px;
}

.login-card h1 {
  margin: 4px 0 0;
  font-size: 1.75rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.login-card p {
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 750;
}

.login-card label {
  color: #405047;
  font-size: 0.85rem;
  font-weight: 900;
}

.login-card input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(12, 107, 88, 0.16);
  border-radius: 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  outline: 0;
}

.login-card input:focus {
  border-color: rgba(12, 107, 88, 0.42);
  box-shadow: 0 0 0 5px var(--ring);
}

.login-button {
  min-height: 50px;
  margin-top: 6px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: white;
  background: var(--accent);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 16px 36px rgba(12, 107, 88, 0.24);
}

.login-button svg {
  width: 18px;
  height: 18px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: #9f3d32;
  font-size: 0.9rem;
}

.is-authenticated .login-screen {
  display: none;
}

.is-locked .workspace {
  pointer-events: none;
  user-select: none;
  filter: blur(10px);
}

.is-authenticated .workspace {
  pointer-events: auto;
  user-select: auto;
  filter: none;
}

.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;
}

.small-button,
.search-button,
.reference-button,
.upload-button {
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 850;
  transition:
    transform 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.small-button:hover,
.search-button:hover,
.reference-button:hover,
.upload-button:hover {
  transform: translateY(-1px);
}

.small-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 36px rgba(18, 30, 24, 0.12);
  backdrop-filter: blur(16px);
}

.reset-fab {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 8;
}

.small-button svg,
.search-button svg,
.reference-button svg,
.upload-button svg {
  width: 18px;
  height: 18px;
}

.stage {
  position: relative;
  min-height: 0;
  display: grid;
  overflow: hidden;
}

.domain-marquee {
  position: absolute;
  inset: 70px 0 auto;
  height: min(34vh, 280px);
  display: flex;
  gap: 18px;
  opacity: 0.42;
  filter: saturate(0.86);
  mask-image: linear-gradient(90deg, transparent 0%, black 10%, black 90%, transparent 100%);
  pointer-events: none;
  transition:
    opacity 260ms ease,
    transform 260ms ease,
    filter 260ms ease;
  z-index: 0;
}

.domain-marquee::after {
  content: "";
  position: absolute;
  inset: -20px 0;
  background: linear-gradient(180deg, rgba(246, 247, 242, 0) 0%, rgba(246, 247, 242, 0.54) 70%, rgba(246, 247, 242, 0.98) 100%);
}

.marquee-track {
  min-width: max-content;
  display: flex;
  align-items: center;
  gap: 18px;
  animation: marquee 46s linear infinite;
}

.marquee-track:nth-child(2) {
  animation-name: marqueeDuplicate;
}

.domain-marquee figure {
  position: relative;
  width: clamp(180px, 20vw, 292px);
  height: clamp(126px, 14vw, 204px);
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  background: white;
  box-shadow: 0 26px 70px rgba(18, 30, 24, 0.14);
}

.domain-marquee img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.domain-marquee figcaption {
  position: absolute;
  left: 12px;
  bottom: 12px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: #0e1915;
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
  font-weight: 900;
  backdrop-filter: blur(12px);
}

.state-ready .domain-marquee,
.state-results .domain-marquee {
  opacity: 0.08;
  filter: blur(2px) saturate(0.7);
  transform: translateY(-10px);
}

@keyframes marquee {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(calc(-100% - 18px));
  }
}

@keyframes marqueeDuplicate {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(calc(-100% - 18px));
  }
}

.results-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition:
    opacity 260ms ease,
    transform 260ms ease;
  z-index: 1;
}

.state-ready .results-panel,
.state-results .results-panel,
.is-busy.state-ready .results-panel,
.is-busy.state-results .results-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.results-toolbar {
  min-height: 54px;
  padding: 0 clamp(18px, 3vw, 34px);
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 850;
}

.results-grid {
  min-height: 0;
  padding: 0 clamp(18px, 3vw, 34px) 132px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  align-content: start;
  gap: 14px;
  overflow: auto;
}

.result-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(22, 32, 27, 0.08);
}

.result-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--soft);
}

.result-body {
  padding: 16px;
}

.result-body h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  line-height: 1.24;
  letter-spacing: 0;
}

.result-body p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.result-body .match-reason {
  color: #3f5047;
  font-weight: 750;
}

.score {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(12, 107, 88, 0.1);
  font-size: 0.8rem;
  font-weight: 900;
}

.composer-wrap {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(760px, calc(100vw - 32px));
  display: grid;
  gap: 16px;
  justify-items: center;
  transform: translate(-50%, -50%);
  transition:
    top 320ms ease,
    bottom 320ms ease,
    transform 320ms ease,
    width 320ms ease;
  z-index: 4;
}

.state-ready .composer-wrap,
.state-results .composer-wrap {
  position: fixed;
  top: auto;
  bottom: 24px;
  transform: translateX(-50%);
}

.intro-copy {
  text-align: center;
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

.intro-copy p {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 900;
}

.intro-copy h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.state-ready .intro-copy,
.state-results .intro-copy {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  position: absolute;
}

.upload-button {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid rgba(12, 107, 88, 0.18);
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 16px 42px rgba(22, 32, 27, 0.08);
  backdrop-filter: blur(16px);
}

.upload-button input,
.reference-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.state-ready .upload-button,
.state-results .upload-button {
  position: absolute;
  right: 12px;
  top: -58px;
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.loading-card {
  min-height: 48px;
  padding: 0 16px;
  display: none;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(12, 107, 88, 0.14);
  border-radius: 999px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 16px 42px rgba(22, 32, 27, 0.08);
  font-weight: 850;
  backdrop-filter: blur(16px);
}

.is-busy .loading-card {
  display: flex;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(12, 107, 88, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.search-composer {
  width: 100%;
  min-height: 72px;
  padding: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px 52px;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(12, 107, 88, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.search-composer:focus-within {
  border-color: rgba(12, 107, 88, 0.42);
  box-shadow:
    var(--shadow),
    0 0 0 6px var(--ring);
}

.search-composer input[type="search"] {
  min-width: 0;
  width: 100%;
  height: 54px;
  border: 0;
  outline: 0;
  padding: 0 18px;
  color: var(--ink);
  background: transparent;
  font-size: 1.02rem;
}

.search-composer input[type="search"]::placeholder {
  color: #8a968f;
}

.reference-button,
.search-button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
}

.reference-button {
  color: var(--accent-dark);
  background: var(--soft);
}

.search-button {
  color: white;
  background: var(--accent);
  box-shadow: 0 12px 30px rgba(12, 107, 88, 0.25);
}

.search-button:disabled,
.reference-button.is-disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.reference-button.is-disabled {
  pointer-events: none;
}

.image-preview {
  max-width: 240px;
  display: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: 0 16px 42px rgba(22, 32, 27, 0.12);
}

.image-preview:not(:empty) {
  display: block;
}

.image-preview img {
  width: 240px;
  height: 150px;
  object-fit: cover;
}

.is-busy .search-button,
.is-busy .reference-button,
.is-busy .upload-button {
  pointer-events: none;
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .small-button {
    width: 42px;
    height: 42px;
  }

  .composer-wrap,
  .state-ready .composer-wrap,
  .state-results .composer-wrap {
    width: calc(100vw - 24px);
    bottom: 14px;
  }

  .state-landing .composer-wrap {
    top: 50%;
  }

  .search-composer {
    grid-template-columns: minmax(0, 1fr) 48px 48px;
    min-height: 64px;
  }

  .search-composer input[type="search"] {
    height: 48px;
    padding: 0 12px;
    font-size: 0.96rem;
  }

  .reference-button,
  .search-button {
    width: 48px;
    height: 48px;
  }

  .intro-copy h2 {
    font-size: clamp(2rem, 11vw, 3.2rem);
  }

  .results-grid {
    grid-template-columns: 1fr;
    padding-bottom: 124px;
  }
}
