:root {
  --bg: #101012;
  --surface: #1B1B1F;
  --surface-2: #242429;
  --text: #F4F2EE;
  --muted: #9A968E;
  --border: #303036;
  --accent: #FF5A36;
  --accent-2: #FF8355;
  --accent-contrast: #FFFFFF;
  --coral-bg: rgba(255, 90, 54, 0.16);
  --coral-text: #FF9166;
  --danger: #FF6B5E;
  --header-gradient: linear-gradient(150deg, #202024 0%, #17171A 100%);
  --header-glow: radial-gradient(circle, rgba(255, 90, 54, 0.30), transparent 70%);
}

:root[data-theme="light"] {
  --bg: #FAF7F2;
  --surface: #FFFFFF;
  --surface-2: #F3ECE1;
  --text: #211D1A;
  --muted: #8A8078;
  --border: #E7E1D8;
  --coral-bg: #FCE4DC;
  --coral-text: #C1441C;
  --danger: #C1441C;
  --header-gradient: linear-gradient(150deg, #FFFFFF 0%, #F3ECE1 100%);
  --header-glow: radial-gradient(circle, rgba(255, 90, 54, 0.16), transparent 70%);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Work Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body, .card, .entry-card, .gallery-item, .modal, .back-btn,
.topbar, .detail-header, .form-header, .field input, .field textarea {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 48px;
}

a { color: inherit; text-decoration: none; }

/* Header-Flächen (Topbar / Kundendetail / Formular) – gemeinsamer moderner Look
   mit dezentem Verlauf und einem weichen Akzent-Glow oben rechts. */
.topbar, .detail-header, .form-header {
  position: sticky;
  top: 0;
  z-index: 10;
  overflow: hidden;
  background: var(--header-gradient);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.topbar::before, .detail-header::before, .form-header::before {
  content: "";
  position: absolute;
  top: -70px; right: -50px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: var(--header-glow);
  pointer-events: none;
}

/* Topbar (Kundenliste) */
.topbar {
  padding: 16px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  font-family: 'Oswald', sans-serif;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex-grow: 1; justify-content: flex-end; }
.search {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 16px;
  color: var(--text);
  font-family: 'Work Sans', sans-serif;
  font-size: 14px;
  flex: 1 1 140px;
  min-width: 0;
  max-width: 260px;
}
.search::placeholder { color: var(--muted); }

/* Buttons */
.btn-primary, .btn-outline, .btn-danger {
  border-radius: 999px;
  padding: 11px 20px;
  font-family: 'Work Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-block;
  text-align: center;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-contrast);
  box-shadow: 0 6px 16px -6px rgba(255, 90, 54, 0.55);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-outline, .btn-outline-invert {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover, .btn-outline-invert:hover { background: var(--surface-2); border-color: rgba(255, 255, 255, 0.2); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(255, 107, 94, 0.45); margin-right: auto; }
.btn-danger:hover { background: rgba(255, 107, 94, 0.1); }

/* Listen */
.subtitle {
  padding: 12px 16px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.list { padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.card:hover { background: var(--surface-2); border-color: rgba(255, 255, 255, 0.16); }
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--coral-bg); color: var(--coral-text);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Oswald', sans-serif; font-size: 15px; font-weight: 600;
  flex-shrink: 0;
}
.card-info { flex-grow: 1; min-width: 0; }
.name { font-family: 'Oswald', sans-serif; font-size: 19px; font-weight: 600; }
.card .name { font-size: 16px; }
.contact { font-size: 13px; color: var(--muted); margin-top: 2px; }
.meta { text-align: right; flex-shrink: 0; }
.meta-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.meta-value { font-size: 14px; margin-top: 2px; color: var(--accent-2); font-weight: 600; }

/* Kundendetail */
.detail-header {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.back-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
  font-size: 19px;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.back-btn:hover { background: #2C2C32; }
.detail-info { flex-grow: 1; min-width: 160px; }
.detail-info .name { color: var(--text); }
.detail-info .contact { color: var(--muted); }

.section-row {
  padding: 20px 20px 8px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.section-title { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0.4px; text-transform: uppercase; }
.section-row .btn-primary { margin-left: auto; }

.entry-card {
  display: flex; gap: 16px;
  padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.entry-card:hover { background: var(--surface-2); border-color: rgba(255, 255, 255, 0.16); }
.entry-photo { position: relative; width: 96px; height: 96px; border-radius: 14px; overflow: hidden; flex-shrink: 0; background: var(--surface-2); }
.entry-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-placeholder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; text-align: center; padding: 4px; }
.entry-info { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.entry-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.motiv { font-family: 'Oswald', sans-serif; font-size: 17px; font-weight: 600; }
.preis { font-family: 'Oswald', sans-serif; font-size: 16px; font-weight: 600; color: var(--accent-2); flex-shrink: 0; }
.details { font-size: 14px; color: var(--muted); }
.tags { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pill { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.date { font-size: 13px; color: var(--muted); }

/* Formular (Neuer Eintrag) */
.form-header {
  padding: 22px 20px; display: flex; align-items: center; gap: 14px;
}
.form-title { font-family: 'Oswald', sans-serif; font-size: 18px; font-weight: 600; }
.form-subtitle { font-size: 13px; color: var(--muted); }

.form-body { padding: 24px 20px; display: flex; flex-direction: column; gap: 24px; }
@media (min-width: 560px) {
  .form-body { flex-direction: row; }
  .photo-upload { width: 260px; flex-shrink: 0; }
}

.photo-upload { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--muted); }

.foto-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.foto-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-remove {
  position: absolute;
  top: 2px; right: 2px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #FFFFFF;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.foto-add-bar {
  display: flex;
  border: 2px dashed var(--accent);
  border-radius: 14px;
  background: var(--coral-bg);
  overflow: hidden;
}
.foto-add-segment {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  position: relative;
}
.foto-add-segment input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
}
.foto-add-divider {
  width: 1px;
  background: rgba(255, 90, 54, 0.35);
  align-self: stretch;
  margin: 10px 0;
}
.foto-count {
  position: absolute;
  bottom: 4px; right: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
}
.upload-hint { font-size: 13px; color: var(--muted); }
.upload-error { font-size: 13px; color: var(--danger); }

.form-fields { flex-grow: 1; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 500; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field input, .field textarea {
  font-family: 'Work Sans', sans-serif; font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  width: 100%;
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.field textarea { resize: vertical; }

.form-actions { padding: 0 20px 32px; display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }

/* Modal (Neuer Kunde / Kontakt bearbeiten) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 24px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
}
.modal h2 { font-family: 'Oswald', sans-serif; font-size: 19px; margin: 0 0 4px; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.footer-info {
    margin-top: 24px;
    padding: 14px 0 6px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
}
.footer-info a {
    color: inherit;
    text-decoration: none;
}

/* Galerie */
.gallery-grid {
  padding: 16px 20px 20px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 560px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}
.gallery-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.gallery-item:hover { background: var(--surface-2); border-color: rgba(255, 255, 255, 0.16); }
.gallery-item img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--surface-2); }
.gallery-caption { padding: 8px 10px; }
.gallery-name { font-size: 13px; font-weight: 600; }
.gallery-motiv { font-size: 12px; color: var(--muted); margin-top: 1px; }
.gallery-date { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Sicherung (Export/Import) */
.backup-row {
  padding: 14px 20px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.link-btn {
  background: none;
  border: none;
  padding: 2px 0;
  margin: 0;
  font-family: 'Work Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  display: inline-block;
}
.link-btn:hover { color: var(--text); }
.backup-sep { font-size: 12px; color: var(--muted); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer;
  width: 100%; height: 100%;
}
.backup-meldung {
  margin: -8px 20px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* Foto-Lightbox (vergrößerte Ansicht) */
.lightbox-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 100;
  cursor: zoom-out;
}
.lightbox-backdrop img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  object-fit: contain;
  cursor: default;
}
.entry-photo img, .foto-thumb img { cursor: zoom-in; }
