@font-face {
  font-family: "Magnolia 1786";
  src: url("1786.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #231f20;
  --muted: #6e6a66;
  --line: #ddd8cf;
  --paper: #f1f0eb;
  --surface: #fffefa;
  --charcoal: #231f20;
  --moss: #546c5a;
  --rose: #c95cbb;
  --accent: #d45bc8;
  --gold: #a98f61;
  --glass: rgba(255, 254, 250, 0.7);
  --glass-strong: rgba(255, 254, 250, 0.84);
  --glass-line: rgba(255, 255, 255, 0.62);
  --shadow: 0 24px 70px rgba(35, 31, 32, 0.14);
  --inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(241, 240, 235, 0.52) 38%, rgba(231, 226, 216, 0.68)),
    repeating-linear-gradient(90deg, rgba(35, 31, 32, 0.025) 0 1px, transparent 1px 92px),
    var(--paper);
  color: var(--ink);
  font-family: "Magnolia 1786", Georgia, "Times New Roman", serif;
}

body::before {
  content: "";
  display: block;
  height: 10px;
  background: var(--charcoal);
}

button,
input {
  font: inherit;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.48), transparent 55%),
    linear-gradient(180deg, rgba(35, 31, 32, 0.06), transparent 190px),
    var(--paper);
  padding: 20px;
}

.login-box {
  width: min(100%, 380px);
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  background: var(--glass-strong);
  box-shadow: var(--shadow), var(--inner-glow);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  padding: 22px;
  text-align: center;
}

.login-box label {
  display: block;
  margin-top: 22px;
  font-weight: 800;
  text-align: left;
}

.login-box input {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.74);
  padding: 0 12px;
}

.login-box button {
  width: 100%;
  margin-top: 14px;
}

.login-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--rose);
  font-weight: 700;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 18px 0 26px;
}

.topbar > div:first-child {
  grid-column: 2;
  text-align: center;
}

.brand-logo {
  display: block;
  width: clamp(180px, 24vw, 300px);
  height: auto;
  margin: 0 auto 8px;
}

.login-logo {
  width: min(260px, 82%);
  margin: 0 auto 12px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2.3rem;
  line-height: 1.08;
}

h2 {
  font-size: 1.1rem;
}

.status {
  grid-column: 3;
  justify-self: end;
  min-width: 160px;
  max-width: 48%;
  border: 1px solid var(--glass-line);
  border-radius: 6px;
  background: rgba(255, 254, 250, 0.68);
  color: var(--muted);
  padding: 10px 12px;
  text-align: center;
  box-shadow: 0 12px 34px rgba(35, 31, 32, 0.08), var(--inner-glow);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.status.ready {
  color: var(--moss);
  border-color: rgba(84, 108, 90, 0.38);
}

.status.warn {
  color: var(--rose);
  border-color: rgba(201, 92, 187, 0.35);
}

.workbench {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.submit-panel,
.results-panel {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  box-shadow: var(--shadow), var(--inner-glow);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
}

.submit-panel {
  padding: 16px;
}

.upload-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 210px;
  border: 1px dashed #aaa39a;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

.upload-zone.dragging {
  border-color: var(--moss);
  background: rgba(255, 255, 255, 0.62);
}

.upload-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-title,
.upload-action {
  display: block;
}

.upload-title {
  font-size: 1rem;
  font-weight: 700;
}

.upload-action {
  margin-top: 6px;
  color: var(--accent);
  font-weight: 700;
}

.preview-wrap {
  margin-top: 14px;
  border: 1px solid var(--glass-line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.48);
  overflow: hidden;
  aspect-ratio: 4 / 5;
  box-shadow: var(--inner-glow);
}

.preview-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-note {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 22px;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(35, 31, 32, 0.08), var(--inner-glow);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:focus-visible,
.upload-zone:focus-within,
.login-box input:focus-visible {
  outline: 3px solid rgba(212, 91, 200, 0.28);
  outline-offset: 2px;
}

.primary {
  background: linear-gradient(180deg, rgba(55, 50, 51, 0.98), var(--charcoal));
  color: white;
  border-color: rgba(255, 255, 255, 0.15);
}

.secondary {
  background: rgba(255, 254, 250, 0.56);
  color: var(--charcoal);
  border-color: var(--glass-line);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}

.meter {
  height: 8px;
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.52);
  border-radius: 999px;
  overflow: hidden;
}

.meter-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width 120ms ease;
}

.results-panel {
  min-height: 520px;
  padding: 16px;
}

.results-heading {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

#resultCount {
  color: var(--muted);
  font-size: 0.9rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  padding-top: 16px;
}

.match-card {
  border: 1px solid var(--glass-line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.72);
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(35, 31, 32, 0.08), var(--inner-glow);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.match-card:first-child {
  border-color: rgba(84, 108, 90, 0.7);
  box-shadow: 0 0 0 2px rgba(84, 108, 90, 0.12);
}

.match-card img,
.match-image-link {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1.15;
}

.match-image-link {
  color: inherit;
  text-decoration: none;
}

.match-card img {
  object-fit: contain;
  background: rgba(245, 242, 235, 0.68);
}

.match-details {
  display: grid;
  gap: 5px;
  min-height: 96px;
  padding: 10px 12px 12px;
  overflow-wrap: anywhere;
}

.meta-line {
  color: var(--ink);
  line-height: 1.25;
}

.meta-line strong {
  font-weight: 850;
}

.meta-line a,
.design-links a {
  color: var(--accent);
  font-weight: 850;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.plm-image-line a {
  display: inline-block;
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(170, 163, 154, 0.8);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.32);
  color: var(--muted);
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 640px);
    padding-top: 12px;
  }

  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
    padding-bottom: 16px;
  }

  .topbar > div:first-child,
  .status {
    grid-column: 1;
  }

  h1 {
    font-size: 1.8rem;
    text-align: center;
  }

  .status {
    max-width: none;
    justify-self: stretch;
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .results-panel {
    min-height: 360px;
  }
}
