@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-hover: #f0f1f7;
  --border: #e6e8f0;
  --border-strong: #d7dae6;
  --text: #171a26;
  --text-muted: #5c6079;
  --text-faint: #8d90a6;
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(99, 102, 241, 0.08);
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7ecc8;
  --warning: #b45309;
  --warning-bg: #fffbeb;
  --warning-border: #fbe3a1;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --error-border: #fbcaca;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 16px 40px rgba(23, 26, 38, 0.08);
  --shadow-sm: 0 1px 2px rgba(23, 26, 38, 0.04), 0 2px 8px rgba(23, 26, 38, 0.04);
}

* {
  box-sizing: border-box;
}

/* [hidden] muss IMMER gewinnen, egal welche display-Regel eine Klasse sonst setzt (z.B.
   display:flex fuer .status/.error) -- sonst bleiben Elemente trotz hidden-Attribut sichtbar. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(99, 102, 241, 0.06), transparent),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(5, 150, 105, 0.05), transparent),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  background: rgba(244, 245, 250, 0.8);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
  color: white;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

h1 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-hint {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Disclaimer ---------- */

.disclaimer {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: var(--warning-bg);
  color: var(--warning);
  border-bottom: 1px solid var(--warning-border);
  padding: 0.7rem 1.75rem;
  margin: 0;
  font-size: 0.85rem;
}

.disclaimer::before {
  content: "ⓘ";
  font-size: 1rem;
  line-height: 1.3;
  flex-shrink: 0;
  opacity: 0.85;
}

/* ---------- Layout ---------- */

main {
  max-width: 620px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.auth-page {
  max-width: 380px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  gap: 1.75rem;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.auth-brand .brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 1.2rem;
}

.auth-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Step indicator ---------- */

.steps {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-faint);
  font-size: 0.82rem;
  font-weight: 600;
}

.step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.25s ease;
  flex-shrink: 0;
  background: var(--surface);
}

.step.is-active .step-dot {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.step.is-done .step-dot {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.step.is-active,
.step.is-done {
  color: var(--text);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border-strong);
  border-radius: 2px;
  transition: background 0.3s ease;
}

.step-line.is-done {
  background: var(--success);
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  animation: card-in 0.35s ease;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Upload / dropzone ---------- */

.dropzone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 2.25rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  background: var(--bg);
  display: block;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 0.85rem;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 1.3rem;
}

.dropzone-text {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0 0 0.25rem;
}

.dropzone-subtext {
  color: var(--text-faint);
  font-size: 0.8rem;
  margin: 0;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.image-preview-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-top: 1rem;
}

.image-preview-wrap[hidden] {
  display: none;
}

.image-preview-wrap img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.image-preview-info {
  min-width: 0;
  flex: 1;
}

.image-preview-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-preview-size {
  font-size: 0.78rem;
  color: var(--text-faint);
}

.image-preview-clear {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem 0.5rem;
  margin: 0;
  border-radius: var(--radius-sm);
  line-height: 1;
  box-shadow: none;
}

.image-preview-clear:hover {
  color: var(--error);
  background: var(--error-bg);
  transform: none;
  box-shadow: none;
}

/* ---------- Forms ---------- */

label {
  display: block;
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  margin-bottom: 1rem;
}

input[type="email"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1.35rem;
}

fieldset:last-of-type {
  margin-bottom: 0.5rem;
}

legend {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  padding: 0;
  margin-bottom: 0.6rem;
  line-height: 1.4;
}

/* Toggle-button radios */
.toggle-group {
  display: flex;
  gap: 0.5rem;
}

.toggle-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.toggle-label {
  flex: 1;
  text-align: center;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease;
  margin: 0;
  user-select: none;
}

.toggle-label:hover {
  border-color: var(--accent);
  color: var(--text);
}

.toggle-input:checked + .toggle-label {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.toggle-input:focus-visible + .toggle-label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Buttons ---------- */

button {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.3rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.25);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.32);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

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

button.btn-block {
  width: 100%;
}

button.btn-ghost {
  background: none;
  color: var(--text-muted);
  box-shadow: none;
  border: 1px solid var(--border-strong);
}

button.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: none;
}

.link-btn {
  background: none;
  color: var(--accent);
  padding: 0;
  text-decoration: none;
  font-size: 0.85rem;
  box-shadow: none;
  font-weight: 600;
}

.link-btn:hover {
  text-decoration: underline;
  transform: none;
  box-shadow: none;
}

/* ---------- Status / feedback ---------- */

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
  margin-right: 0.5rem;
}

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

.status {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 0.9rem;
}

.status[hidden] {
  display: none;
}

.error {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  margin-top: 1rem;
  font-size: 0.88rem;
}

.error[hidden] {
  display: none;
}

.warning {
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  margin: 0.5rem 0 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------- Confidence gauge ---------- */

.confidence {
  margin-bottom: 1.5rem;
}

.confidence-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.5rem;
}

.confidence-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.confidence-value {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.confidence-track {
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Result ---------- */

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.result-badge.badge-none {
  background: var(--success-bg);
  color: var(--success);
}

.result-badge.badge-prominent {
  background: var(--accent-soft);
  color: var(--accent);
}

#result-preview {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  box-shadow: var(--shadow);
}

/* ---------- Badge-Positions-Vorschau (Drag) ---------- */

#badge-position-block {
  margin: 0.5rem 0 1.25rem;
}

#badge-position-preview {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  line-height: 0;
}

#badge-position-image {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Der eigentliche Drag-Griff ist dieser Wrapper (groesser als das sichtbare Icon, per Padding --
   siehe BADGE_DRAG_HIT_PADDING in app.js), damit er auf einem Touchscreen auch bei einem sehr
   kleinen Icon noch zuverlaessig treffbar ist. Das Icon-Bild selbst behaelt exakt seine vom
   Server berechnete Groesse (siehe app.js) -- nur die Klickflaeche ringsum ist groesser. */
#badge-drag-handle {
  position: absolute;
  padding: 12px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#badge-drag-handle:active {
  cursor: grabbing;
}

#badge-position-icon {
  display: block;
  -webkit-user-drag: none;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
}

#badge-position-reset {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  padding: 0.45rem 0.9rem;
}

/* ---------- Footer / Rechtsseiten ---------- */

.site-footer {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.5rem 1.5rem 2.5rem;
  font-size: 0.82rem;
}

.site-footer a {
  color: var(--text-faint);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

.legal-page main {
  max-width: 720px;
}

.legal-page h2 {
  margin-top: 1.75rem;
}

.legal-page h2:first-of-type {
  margin-top: 0;
}

.legal-page p {
  color: var(--text-muted);
}

.legal-page .placeholder {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.4rem;
  font-weight: 600;
}

.faq-item {
  margin-bottom: 1.5rem;
}

.faq-item h3 {
  font-size: 1rem;
  margin: 0 0 0.4rem;
}

.faq-item p {
  margin: 0;
  color: var(--text-muted);
}

.anchor-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}

.anchor-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.anchor-nav a:hover {
  text-decoration: underline;
}

/* ---------- Admin ---------- */

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.admin-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.admin-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
}

/* ---------- Auth ---------- */

.auth-form-card {
  width: 100%;
}

.auth-toggle-row {
  text-align: center;
  margin-top: 1rem;
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .topbar {
    padding: 1rem;
  }

  main {
    padding: 1.5rem 1rem 3rem;
  }

  .card {
    padding: 1.35rem;
  }

  .toggle-group {
    flex-direction: column;
  }

  /* Groesseres Touch-Ziel auf dem Handy (>= 44px Richtwert) fuer die Ja/Nein-Umschalter. */
  .toggle-label {
    padding: 0.8rem 1rem;
  }
}
