*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #ffffff;
  --color-bg-secondary: #f7f6f3;
  --color-bg-tertiary: #f0ede8;
  --color-text: #1a1a1a;
  --color-text-secondary: #6b6b6b;
  --color-text-tertiary: #9a9a9a;
  --color-border: rgba(0,0,0,0.10);
  --color-border-medium: rgba(0,0,0,0.18);
  --color-border-strong: rgba(0,0,0,0.28);
  --color-accent: #8b1a1a;
  --color-success-bg: #eaf3de;
  --color-success-text: #3b6d11;
  --color-warning-bg: #faeeda;
  --color-warning-text: #854f0b;
  --color-danger-bg: #fcebeb;
  --color-danger-text: #a32d2d;
  --color-info-bg: #e6f1fb;
  --color-info-text: #185fa5;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1a1a1a;
    --color-bg-secondary: #242424;
    --color-bg-tertiary: #2e2e2e;
    --color-text: #f0ede8;
    --color-text-secondary: #a8a8a8;
    --color-text-tertiary: #6e6e6e;
    --color-border: rgba(255,255,255,0.10);
    --color-border-medium: rgba(255,255,255,0.18);
    --color-border-strong: rgba(255,255,255,0.28);
    --color-accent: #c94040;
    --color-success-bg: #173404;
    --color-success-text: #97c459;
    --color-warning-bg: #412402;
    --color-warning-text: #FAC775;
    --color-danger-bg: #501313;
    --color-danger-text: #F09595;
    --color-info-bg: #042c53;
    --color-info-text: #85b7eb;
  }
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  background: var(--color-bg-secondary);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-bg);
  min-height: 100vh;
  padding: 1.25rem 1.25rem 3rem;
}

.header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 0.5px solid var(--color-border);
}

.header svg { color: var(--color-text-tertiary); }

.logo {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--color-text-secondary);
}
.logo span { color: var(--color-accent); }

.step { display: none; }
.step.active { display: block; }

.step-label {
  font-size: 11px;
  color: var(--color-text-tertiary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.step-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1.5rem;
  line-height: 1.25;
}

.sub-label {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: 0.75rem;
}

/* Upload zone */
.upload-zone {
  border: 1.5px dashed var(--color-border-medium);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: var(--color-bg-secondary);
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.upload-zone:active { background: var(--color-bg-tertiary); }
.upload-zone svg { color: var(--color-text-tertiary); display: block; margin: 0 auto 0.75rem; }
.upload-zone p { font-size: 15px; color: var(--color-text-secondary); margin-bottom: 4px; }
.upload-zone small { font-size: 12px; color: var(--color-text-tertiary); }

#label-preview {
  max-width: 100%;
  max-height: 260px;
  border-radius: var(--radius-md);
  display: block;
  margin: 0 auto 0.75rem;
  object-fit: contain;
}

#image-status {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  margin-bottom: 4px;
}

/* Option cards */
.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.drink-store-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.option-card {
  background: var(--color-bg);
  border: 0.5px solid var(--color-border-medium);
  border-radius: var(--radius-lg);
  padding: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.option-card:active { background: var(--color-bg-secondary); }
.option-card.selected {
  border-color: var(--color-accent);
  background: var(--color-danger-bg);
}
.option-card svg { color: var(--color-text-tertiary); display: block; margin-bottom: 8px; }
.option-card.selected svg { color: var(--color-accent); }
.option-card strong { font-size: 14px; font-weight: 600; display: block; color: var(--color-text); margin-bottom: 2px; }
.option-card small { font-size: 12px; color: var(--color-text-secondary); }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
  font-size: 13px;
  color: var(--color-text-secondary);
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 15px;
  border: 0.5px solid var(--color-border-medium);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--color-border-strong); }

.price-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.price-input-wrap span { font-size: 15px; color: var(--color-text-secondary); }
.price-input-wrap input { width: 100px; }

/* Buttons */
.btn-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.btn-primary:active { opacity: 0.8; }

.btn-secondary {
  background: transparent;
  border: 0.5px solid var(--color-border-medium);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 15px;
  color: var(--color-text-secondary);
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.btn-secondary:active { background: var(--color-bg-secondary); }

/* Analyzing */
.analyzing { text-align: center; padding: 3rem 0; }
.spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.analyzing p { font-size: 14px; color: var(--color-text-secondary); }

/* Notes / info boxes */
.info-note, .warn-note, .error-note {
  font-size: 13px;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.5;
}
.info-note { background: var(--color-info-bg); color: var(--color-info-text); }
.warn-note { background: var(--color-warning-bg); color: var(--color-warning-text); }
.error-note { background: var(--color-danger-bg); color: var(--color-danger-text); }
.info-note svg, .warn-note svg, .error-note svg { flex-shrink: 0; margin-top: 1px; }

/* Result card */
.result-card {
  background: var(--color-bg);
  border: 0.5px solid var(--color-border-medium);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.result-header {
  padding: 1rem 1.25rem;
  border-bottom: 0.5px solid var(--color-border);
  background: var(--color-bg-secondary);
}
.result-header .winery {
  font-size: 11px;
  color: var(--color-text-tertiary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.result-header .wine-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}
.result-header .vintage-line {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.result-body { padding: 0.5rem 1.25rem 1rem; }

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--color-border);
  gap: 1rem;
}
.field-row:last-child { border-bottom: none; }
.field-label { font-size: 12px; color: var(--color-text-tertiary); min-width: 120px; flex-shrink: 0; }
.field-value { font-size: 13px; color: var(--color-text); text-align: right; }

.notes-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 0.5px solid var(--color-border);
}
.notes-label { font-size: 12px; color: var(--color-text-tertiary); margin-bottom: 6px; }
.notes-text { font-size: 13px; color: var(--color-text-secondary); line-height: 1.6; font-style: italic; }

textarea.personal-notes {
  width: 100%;
  border: 0.5px solid var(--color-border-medium);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  resize: vertical;
  min-height: 80px;
  margin-top: 6px;
  outline: none;
  -webkit-appearance: none;
}
textarea.personal-notes:focus { border-color: var(--color-border-strong); }

.star-rating { display: flex; gap: 6px; margin-top: 8px; }
.star-rating span {
  font-size: 28px;
  cursor: pointer;
  color: var(--color-border-medium);
  transition: color 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.star-rating span.lit { color: #BA7517; }

/* Badge */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 100px;
  margin-left: 6px;
  vertical-align: middle;
}
.badge-cellar { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-drink { background: var(--color-warning-bg); color: var(--color-warning-text); }

/* Success screen */
.success-msg { text-align: center; padding: 2rem 0; }
.success-icon {
  display: block;
  margin: 0 auto 1.25rem;
  color: var(--color-success-text);
}
.success-msg h2 { font-size: 22px; font-weight: 600; margin-bottom: 0.5rem; }
.success-msg p { font-size: 14px; color: var(--color-text-secondary); margin-bottom: 2rem; line-height: 1.6; }
