:root {
  color-scheme: light dark;
  font-family: "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  background-color: #f7f5f3;
  color: #2e2522;
  --accent-primary: #d8a657;
  --accent-secondary: #a9702c;
  --accent-muted: rgba(216, 166, 87, 0.6);
}

body {
  margin: 0;
  background: linear-gradient(180deg, #faf7f2 0%, #f3eae4 100%);
}

.container {
  width: min(960px, 92vw);
  margin: 0 auto;
  padding: 1.5rem 0;
}

.site-header,
.site-footer {
  text-align: center;
  padding: 1.25rem 0;
}

.site-header {
  background: rgba(255, 255, 255, 0.66);
  border-bottom: 1px solid rgba(46, 37, 34, 0.1);
}

.site-footer {
  font-size: 0.875rem;
  color: rgba(46, 37, 34, 0.7);
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
}

.tagline {
  margin: 0.25rem 0 0;
  color: rgba(46, 37, 34, 0.75);
}

.flow h2 {
  margin-top: 2.5rem;
  font-size: 1.5rem;
  color: #3e302b;
}

.tryon-form {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.brand-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.25rem 1.35rem;
  border-radius: 20px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  min-height: 160px;
  justify-content: center;
}

.brand-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.brand-card input[type="radio"] {
  position: absolute;
  inset: 12px 12px auto auto;
  width: 1.1rem;
  height: 1.1rem;
}

.brand-card .brand-name {
  font-size: 1.2rem;
  font-weight: 600;
  margin-right: 2rem;
}

.brand-card .brand-tagline {
  margin: 0;
  font-size: 0.95rem;
  color: rgba(46, 37, 34, 0.7);
}

.brand-card.is-active {
  border-color: var(--card-accent, var(--accent-primary));
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.12);
}

.brand-card.is-active::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.brand-card.is-active .brand-name {
  color: var(--card-accent, var(--accent-primary));
}

.style-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.style-card {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid transparent;
  border-radius: 18px;
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.style-card input[type="radio"] {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 1.1rem;
  height: 1.1rem;
}

.style-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  margin-bottom: 0.75rem;
}

.style-card:hover,
.style-card:has(input[type="radio"]:checked) {
  border-color: var(--accent-primary);
  box-shadow: 0 12px 28px rgba(78, 60, 44, 0.15);
}

.card-copy h3 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
}

.card-copy p {
  margin: 0;
  color: rgba(46, 37, 34, 0.75);
}

.category-heading {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--accent-secondary);
  text-transform: uppercase;
}

.category-heading:first-of-type {
  margin-top: 0.5rem;
}

.upload-block {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  padding: 1.5rem;
  border: 2px dashed var(--accent-muted);
  text-align: center;
}

.file-input {
  display: block;
  margin: 0 auto 0.75rem;
}

.camera-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.camera-inline .secondary {
  width: fit-content;
}

#camera-status {
  margin: 0;
  color: #236045;
  font-weight: 500;
}

.hint,
.helptext {
  font-size: 0.95rem;
  color: rgba(46, 37, 34, 0.6);
}

.primary,
.secondary {
  display: inline-block;
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

.primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  font-weight: 600;
}

.primary:hover {
  opacity: 0.9;
}

.secondary {
  background: transparent;
  color: var(--accent-secondary);
  border: 1px solid var(--accent-muted);
}

.flash-container {
  margin-bottom: 1.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  margin: 0.5rem 0;
}

.flash-error {
  background: rgba(214, 40, 40, 0.1);
  color: #852424;
  border: 1px solid rgba(214, 40, 40, 0.2);
}

.flash-success {
  background: rgba(61, 178, 116, 0.12);
  color: #236045;
  border: 1px solid rgba(61, 178, 116, 0.2);
}

.result-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  background: rgba(255, 255, 255, 0.95);
  padding: 1.5rem;
  border-radius: 18px;
  box-shadow: 0 18px 28px rgba(78, 60, 44, 0.1);
}

.result-image {
  width: 100%;
  border-radius: 12px;
  object-fit: cover;
}

.result-meta h3 {
  margin-top: 0;
  color: #3e302b;
}

.result-meta dl {
  margin: 1rem 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  font-size: 0.9rem;
  color: rgba(46, 37, 34, 0.7);
}

dt {
  font-weight: 600;
}

dd {
  margin: 0;
}

.actions {
  margin-top: 2rem;
  text-align: center;
}

@media (max-width: 600px) {
  .style-card input[type="radio"] {
    position: static;
    margin-bottom: 0.5rem;
  }

  .brand-card {
    min-height: auto;
    padding: 1.1rem 1.2rem;
  }

  .brand-card input[type="radio"] {
    position: static;
    margin-bottom: 0.75rem;
  }
}

[hidden] {
  display: none !important;
}

.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 26, 24, 0.35);
  display: grid;
  place-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.loader-card {
  background: rgba(255, 255, 255, 0.95);
  padding: 1.75rem 2.25rem;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  color: #3e302b;
  max-width: 320px;
}

.loader-card p {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.loader-spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 6px solid rgba(0, 0, 0, 0.08);
  border-top-color: var(--accent-primary);
  animation: loader-spin 0.9s linear infinite;
}

@keyframes loader-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.primary.is-loading {
  position: relative;
  cursor: wait;
  opacity: 0.8;
}

.camera-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  padding: 1.5rem;
}

.camera-dialog {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 20px;
  padding: 1.5rem;
  max-width: min(540px, 92vw);
  max-height: min(92vh, 720px);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: #2e2522;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.camera-frame {
  position: relative;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  width: min(100%, calc(65vh * 0.75), 480px);
  max-height: 65vh;
  margin: 0 auto;
}

#camera-preview,
#camera-still {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-still[hidden] {
  display: none;
}

.camera-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.camera-actions .primary,
.camera-actions .secondary {
  min-width: 140px;
}

.camera-hint {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(46, 37, 34, 0.7);
  text-align: center;
}

@media (max-height: 720px) {
  .camera-modal {
    padding: 1rem;
  }

  .camera-dialog {
    padding: 1.25rem;
    gap: 0.75rem;
  }

  .camera-frame {
    width: min(100%, calc(55vh * 0.75), 420px);
    max-height: 55vh;
  }
}

.unlock {
  max-width: 420px;
  margin: 3rem auto;
  background: rgba(255, 255, 255, 0.94);
  padding: 2rem;
  border-radius: 18px;
  box-shadow: 0 16px 28px rgba(78, 60, 44, 0.12);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  color: #3e302b;
}

.unlock h2 {
  margin: 0;
  font-size: 1.6rem;
}

.unlock-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.unlock-form input[type="password"] {
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(46, 37, 34, 0.2);
  background: rgba(255, 255, 255, 0.95);
  color: #2e2522;
}

.unlock-form input[type="password"]:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.unlock-form input[type="password"]::placeholder {
  color: rgba(46, 37, 34, 0.55);
}

.unlock-label {
  font-weight: 600;
}
