:root {
  color-scheme: light;
  --ink: #102822;
  --muted: #64706b;
  --paper: #f6f1e8;
  --surface: #fffaf1;
  --line: #ddd2c1;
  --accent: #d4563c;
  --accent-dark: #9f3426;
  --gold: #f7d37b;
  --green: #285b4f;
  --shadow: 0 18px 45px rgba(16, 40, 34, 0.14);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
textarea {
  font: inherit;
}

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

.app-shell {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(247, 211, 123, 0.22), transparent 36%),
    linear-gradient(180deg, #fffaf1 0%, var(--paper) 55%, #e8efe9 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid rgba(16, 40, 34, 0.1);
  background: rgba(255, 250, 241, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 850;
  letter-spacing: 0;
  font-size: 1.08rem;
}

.nav {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
}

.nav-button,
.icon-button,
.small {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 700;
}

.nav-button.active {
  background: var(--ink);
  color: var(--surface);
}

.view {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 18px 16px 48px;
}

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

h1 {
  font-size: clamp(2.2rem, 12vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: 0;
  margin-bottom: 18px;
}

h2 {
  font-size: 1.25rem;
  letter-spacing: 0;
}

h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  font-size: 0.9rem;
}

.eyebrow {
  color: var(--accent-dark);
  text-transform: uppercase;
  font-weight: 850;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.auth-layout,
.home,
.crop-layout,
.results-layout,
.account-layout,
.admin-layout {
  display: grid;
  gap: 18px;
}

.intro,
.hero {
  min-height: 46vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.panel,
.auth-panel,
.context-panel {
  background: rgba(255, 250, 241, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-panel {
  display: grid;
  gap: 10px;
}

.field-label {
  font-weight: 760;
  color: var(--ink);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 13px 14px;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

.primary,
.secondary {
  border: 0;
  border-radius: 8px;
  min-height: 48px;
  padding: 0 18px;
  font-weight: 850;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary.active {
  background: var(--ink);
  color: var(--surface);
}

.full {
  width: 100%;
}

.upload-target {
  display: grid;
  gap: 4px;
  place-items: center;
  margin-top: 14px;
  min-height: 178px;
  border: 2px dashed rgba(16, 40, 34, 0.32);
  border-radius: 8px;
  background: #fffdf7;
  cursor: pointer;
  text-align: center;
  padding: 24px;
}

.upload-target input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-title {
  font-size: 1.3rem;
  font-weight: 900;
}

.upload-subtitle {
  color: var(--muted);
}

.quota-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  display: grid;
  gap: 2px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric-value {
  font-size: 1.35rem;
  font-weight: 900;
}

.metric-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.crop-host {
  width: 100%;
  min-height: 300px;
}

.crop-canvas {
  display: block;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  border-radius: 8px;
  box-shadow: var(--shadow);
  touch-action: none;
  background: #111;
}

.actions,
.search-actions,
.segmented {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.selected-item {
  display: grid;
  gap: 14px;
}

.selected-item img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 8px;
  background: #111;
}

.loading-panel {
  min-height: 62vh;
  display: grid;
  place-items: center;
  text-align: center;
  align-content: center;
}

.loader {
  width: 54px;
  height: 54px;
  border: 5px solid rgba(16, 40, 34, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.section-title {
  margin: 18px 0 4px;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.product-card {
  display: grid;
  gap: 8px;
  background: #fffdf7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.product-image-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(16, 40, 34, 0.1);
  background: #111;
}

.product-image-frame.loading::before {
  content: "";
  width: 34px;
  height: 34px;
  border: 4px solid rgba(255, 255, 255, 0.34);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.product-image-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image-placeholder {
  display: grid;
  place-items: center;
  gap: 10px;
  width: 100%;
  height: 100%;
  color: var(--ink);
  background: linear-gradient(180deg, #fff8e8 0%, #e8efe9 100%);
}

.placeholder-shirt {
  width: 74px;
  height: 88px;
  border-radius: 20px 20px 10px 10px;
  background: var(--green);
  clip-path: polygon(28% 0, 72% 0, 93% 22%, 78% 42%, 78% 100%, 22% 100%, 22% 42%, 7% 22%);
}

.placeholder-text {
  font-weight: 900;
}

.product-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  width: fit-content;
  border-radius: 999px;
  background: #e8efe9;
  color: var(--green);
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 850;
}

.badge.pending {
  background: #fff0cf;
  color: #76540c;
}

.badge.demo {
  background: #edf1f4;
  color: #50606a;
}

.demo-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.score {
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 0.9rem;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 100%;
}

.link-button.disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.notice,
.error,
.success {
  border-radius: 8px;
  padding: 12px;
}

.notice {
  background: #fff8df;
  border: 1px solid #ecd58f;
}

.error {
  background: #fff0ec;
  border: 1px solid #e0a094;
  color: #812417;
}

.success {
  background: #edf7ee;
  border: 1px solid #b4d8ba;
  color: #285b32;
}

.disabled-panel {
  display: grid;
  gap: 12px;
  min-height: 44vh;
  align-content: center;
}

.request-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.request-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.admin-email {
  font-weight: 850;
}

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

@media (min-width: 760px) {
  .auth-layout {
    grid-template-columns: 1.15fr 0.85fr;
    align-items: center;
    min-height: calc(100vh - 90px);
  }

  .selected-item {
    grid-template-columns: minmax(280px, 0.8fr) minmax(320px, 1fr);
    align-items: start;
  }
}

@media (max-width: 620px) {
  .quota-grid,
  .product-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
  }

  .nav-button,
  .icon-button {
    flex: 1;
  }

  .admin-row {
    grid-template-columns: 1fr;
  }
}
