:root {
  --bg: #f7f8f5;
  --fg: #1a1f1a;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e5e7eb;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --yellow: #ca8a04;
  --yellow-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero {
  text-align: center;
  padding: 32px 16px 24px;
}
.hero h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}
.hero .tagline {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.hidden { display: none !important; }

.upload-area {
  text-align: center;
  padding: 24px 8px 8px;
  transition: background 0.15s;
}
.upload-area.drag-over {
  background: var(--green-soft);
  border-radius: 10px;
  outline: 2px dashed var(--green);
}
.upload-icon { font-size: 48px; margin-bottom: 8px; }
.upload-text { margin: 0 0 16px; font-weight: 500; }
.hint { color: var(--muted); font-size: 13px; margin: 16px 0 0; }

.lang-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 16px;
  flex-wrap: wrap;
}
.lang-label {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.lang-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lang-chip {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  line-height: 1.4;
}
.lang-chip:hover { border-color: var(--green); color: var(--green); }
.lang-chip.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
  font-weight: 500;
}

.button-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 0.15s, transform 0.05s;
  user-select: none;
  min-height: 44px;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--green);
  color: #fff;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary {
  background: var(--card);
  color: var(--fg);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }
.btn-text {
  background: transparent;
  color: var(--blue);
  padding: 8px 12px;
}

.preview-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.preview-tab {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.preview-tab.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.preview-wrap {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  min-height: 80px;
}
.preview-wrap img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  display: block;
}
.preview-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  background: rgba(0,0,0,0.55);
}
.preview-spinner.hidden { display: none; }

.threshold-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 4px;
}
.threshold-label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.threshold-row input[type=range] {
  flex: 1;
  accent-color: var(--green);
  height: 4px;
  cursor: pointer;
}
.threshold-val {
  font-size: 13px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  min-width: 26px;
  text-align: right;
}

.preview-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

#preview-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.progress-label { margin: 0 0 10px; font-weight: 500; }
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #4ade80, var(--green));
  background-size: 200% 100%;
  width: 0%;
  transition: width 0.4s ease;
  animation: shimmer 1.8s linear infinite;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.progress-pct {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}

.verdict {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 28px 24px;
  border-radius: 14px;
  border: 1px solid transparent;
}
.verdict-emoji { font-size: 52px; line-height: 1; }
.verdict-text h2 { margin: 0 0 6px; font-size: 22px; }
.verdict-text p { margin: 0; font-size: 14px; opacity: 0.85; line-height: 1.5; }

#result-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.verdict.vegan       { background: var(--green-soft);  border-color: var(--green);  color: #14532d; }
.verdict.vegetarian  { background: var(--yellow-soft); border-color: var(--yellow); color: #713f12; }
.verdict.uncertain   { background: var(--blue-soft);   border-color: var(--blue);   color: #1e3a8a; }
.verdict.non-veg     { background: var(--red-soft);    border-color: var(--red);    color: #7f1d1d; }

#findingsCard h3 { margin: 0 0 16px; font-size: 16px; }
#findingsList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#findingsList li {
  padding: 16px;
  border-radius: 10px;
  border-left: 4px solid var(--border);
  background: var(--bg);
}
#findingsList li.non-vegetarian { border-left-color: var(--red); }
#findingsList li.vegetarian     { border-left-color: var(--yellow); }
#findingsList li.conditional    { border-left-color: var(--blue); }
#findingsList .finding-label {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#findingsList .finding-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tag-non-vegetarian { background: var(--red-soft); color: #7f1d1d; }
.tag-vegetarian     { background: var(--yellow-soft); color: #713f12; }
.tag-conditional    { background: var(--blue-soft); color: #1e3a8a; }
#findingsList .finding-reason {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}
#findingsList .finding-found {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

details.card { padding: 0; }
details.card summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 500;
  list-style: none;
  user-select: none;
}
details.card summary::-webkit-details-marker { display: none; }
details.card summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.15s;
}
details.card[open] summary::before { transform: rotate(90deg); }
details.card pre {
  margin: 0;
  padding: 0 20px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  color: var(--muted);
}

.warning-banner {
  background: var(--yellow-soft);
  border: 1px solid var(--yellow);
  color: #713f12;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
}

.disclaimer {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 0 8px;
  line-height: 1.55;
}

/* ── Vegan-Liste ── */
#veganCard { padding: 0; }
#veganCard summary { padding: 16px 20px; cursor: pointer; font-weight: 500; list-style: none; user-select: none; }
#veganCard summary::-webkit-details-marker { display: none; }
#veganCard summary::before { content: "▸ "; display: inline-block; margin-right: 6px; transition: transform 0.15s; }
#veganCard[open] summary::before { transform: rotate(90deg); }
#veganList {
  list-style: none;
  padding: 0 20px 16px;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.vegan-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 99px;
  background: var(--green-soft);
  font-size: 13px;
}
.vegan-label { font-weight: 500; color: #14532d; }
.vegan-found { color: #166534; font-style: italic; }

/* ── E-Nummer Lookup ── */
.lookup-section {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 8px;
}
.lookup-body { padding: 0 20px 20px; }
.lookup-body input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
  background: var(--bg);
  color: var(--fg);
  box-sizing: border-box;
}
.lookup-body input:focus { border-color: var(--green); }
.lookup-result {
  margin-top: 12px;
  padding: 14px;
  border-radius: 10px;
  border-left: 4px solid var(--border);
  background: var(--bg);
}
.lookup-result.vegan        { border-left-color: var(--green); }
.lookup-result.vegetarian   { border-left-color: var(--yellow); }
.lookup-result.conditional  { border-left-color: var(--blue); }
.lookup-result.non-vegetarian { border-left-color: var(--red); }
.lookup-result.not-found    { border-left-color: var(--muted); color: var(--muted); }
.lookup-name  { font-weight: 600; font-size: 15px; }
.lookup-badge {
  display: inline-block;
  margin: 4px 0;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-vegan          { background: var(--green-soft);  color: #14532d; }
.badge-vegetarian     { background: var(--yellow-soft); color: #713f12; }
.badge-conditional    { background: var(--blue-soft);   color: #1e3a8a; }
.badge-non-vegetarian { background: var(--red-soft);    color: #7f1d1d; }
.lookup-note { margin-top: 4px; font-size: 13px; color: var(--muted); }

footer {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 12px;
}
.footer-links {
  margin: 4px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  justify-content: center;
}
.footer-links a {
  color: var(--muted);
  text-decoration: none;
}
.footer-links a:hover { color: var(--green); text-decoration: underline; }

/* ── UI language toggle ── */
.ui-lang-toggle {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 10px 16px 0;
  max-width: 640px;
  margin: 0 auto;
}
.ui-lang-btn {
  padding: 4px 12px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  line-height: 1.4;
}
.ui-lang-btn:hover { border-color: var(--green); color: var(--green); }
.ui-lang-btn.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

/* ── Legal pages (datenschutz, impressum) ── */
.back-nav {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 8px;
}
.back-nav a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.back-nav a:hover { color: var(--green); }

.legal-content h3,
.legal-content h4 { margin: 0 0 12px; font-size: 18px; }
.legal-content h5 { margin: 16px 0 6px; font-size: 14px; }
.legal-content p  { margin: 0 0 10px; font-size: 14px; line-height: 1.6; color: var(--fg); }
.legal-content ul { padding-left: 20px; margin: 0 0 10px; }
.legal-content li { font-size: 14px; line-height: 1.6; }
.legal-content a  { color: var(--blue); }
.legal-content small { color: var(--muted); font-size: 12px; }

/* ── Traces card (same style as raw text) ── */
#tracesCard pre {
  margin: 0;
  padding: 0 20px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 480px) {
  .hero h1 { font-size: 24px; }
  .verdict { padding: 18px 16px; }
  .verdict-emoji { font-size: 40px; }
  .verdict-text h2 { font-size: 19px; }
}
