:root {
  --bg: #f6f1ea;
  --surface: #fffdf9;
  --ink: #2b2320;
  --muted: #7a6c64;
  --line: #e6ddd2;
  --red: #b3261e;
  --red-dark: #8e1d17;
  --green: #1e5a3a;
  --gold: #c99a2e;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; line-height: 1.15; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--red);
  color: #fff;
  font-family: 'Great Vibes', cursive;
  font-size: 30px;
  line-height: 1;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
}
.logo { color: var(--gold); font-family: system-ui, sans-serif; font-size: 22px; }
/* Abzeichen "Admin" in der Kopfzeile (Admin-Bereich und Admin-Anmeldeseiten) */
.topbar-sub { font-family: 'Nunito', system-ui, sans-serif; font-size: 14px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .18); }

/* ---------- Layout ---------- */
.editor {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 28px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 60px;
  align-items: start;
}

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.preview {
  position: sticky;
  top: 20px;
  order: 2;
  padding: 18px;
  --page-bg: #1c2630;
  --page-bg2: #3a4b5c;
  /* gleicher Hintergrund wie auf der Empfängerseite, Farben setzt editor.js je nach Design */
  background: radial-gradient(ellipse at 50% 25%, var(--page-bg2), var(--page-bg) 75%);
  background-color: var(--page-bg);
  border: none;
  color: #fff;
  overflow: hidden;
  isolation: isolate;
}
.preview > :not(.preview-snow) { position: relative; z-index: 1; }
.preview-snow { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.preview-head { display: flex; align-items: center; justify-content: space-between; }
.preview-head h2 { margin: 0; font-size: 24px; }
.preview-stage { height: min(calc(100vh - 170px), 760px); min-height: 380px; margin-top: 8px; }
.preview-tip { margin: 6px 0 0; font-size: 13px; opacity: .7; text-align: center; }
.preview .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .4); }
.preview .btn-ghost:hover { background: rgba(255, 255, 255, .12); }

.form-panel { order: 1; padding: 28px 30px; }
.form-panel h1 { margin: 0 0 6px; font-size: 36px; color: var(--red-dark); }

fieldset { border: none; padding: 0; margin: 26px 0 0; min-width: 0; }
legend {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  margin-bottom: 12px;
  font-weight: 800;
  font-size: 18px;
}
.step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 14px;
}

/* ---------- Auswahl: Motive ---------- */
.motif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 12px; }
.motif-option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  transition: border-color .2s, transform .2s;
}
.motif-option img { width: 100%; aspect-ratio: 5 / 7; border-radius: 6px; box-shadow: 0 3px 10px rgba(0, 0, 0, .18); background: var(--line); display: block; }
.motif-option.landscape img { aspect-ratio: 7 / 5; }
/* Lange Wörter (z. B. „Christbaumkugeln“) mit Silbentrennung umbrechen statt aus der Spalte zu ragen */
.motif-option { min-width: 0; }
.motif-option span { display: block; min-width: 0; text-align: center; line-height: 1.25; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }
.motif-grid.landscape { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.motif-option:hover { transform: translateY(-2px); }

.format-switch label { display: inline-flex; align-items: center; gap: 8px; }
.format-icon { display: inline-block; border: 2px solid currentColor; border-radius: 3px; }
.format-icon.portrait { width: 12px; height: 17px; }
.format-icon.landscape { width: 17px; height: 12px; }
.motif-option[aria-pressed="true"] { border-color: var(--red); background: #fbecea; font-weight: 700; }

/* ---------- Auswahl: Farben ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.swatch-color { position: relative; width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.swatch-color::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; background: var(--dot); border: 2px solid #fff; }
.swatch[aria-pressed="true"] { border-color: var(--red); background: #fbecea; font-weight: 700; }

/* ---------- Felder ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; position: relative; }
.field > span:first-child { font-weight: 700; font-size: 14px; }
.field em { font-weight: 400; font-style: normal; color: var(--muted); }
input:not([type="radio"]):not([type="checkbox"]), textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; min-height: 54px; }
input:focus, textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(30, 90, 58, .15); }
.counter { position: absolute; right: 10px; bottom: 8px; font-size: 12px; color: var(--muted); pointer-events: none; }

.suggestions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -6px 0 18px; font-size: 13px; color: var(--muted); }
.chip {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.chip:hover { border-color: var(--green); color: var(--green); }

.font-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.font-option {
  padding: 10px 8px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.2;
}
.font-option[aria-pressed="true"] { border-color: var(--red); background: #fbecea; }

.segmented { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); margin-bottom: 16px; }
.segmented label { position: relative; padding: 8px 16px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 14px; color: var(--muted); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--green); }

.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 18px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--green); width: 17px; height: 17px; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.error { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: #fdecea; color: var(--red-dark); font-weight: 700; font-size: 14px; }
.privacy { margin: 12px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-large { width: 100%; padding: 15px 22px; font-size: 17px; }

/* ---------- Ergebnis ---------- */
.result { text-align: center; padding: 20px 0; }
.result-icon { font-size: 44px; color: var(--gold); line-height: 1; }
.result h2 { font-size: 34px; margin: 10px 0; color: var(--green); }
.result p { color: var(--muted); }
.result p.warn { color: var(--red-dark); font-weight: 700; }
.linkbox { display: flex; gap: 8px; }
.linkbox input { font-family: ui-monospace, monospace; font-size: 13px; min-width: 0; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.result-list { list-style: none; padding: 0; margin: 18px 0 0; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.result-list li { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.rl-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 14px; }
.rl-who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-status { flex: none; font-weight: 700; }
.rl-status.ok { color: var(--green); }
.rl-status.fail { color: var(--red-dark); }

/* ---------- Empfängerliste ---------- */
.recipients { display: flex; flex-direction: column; gap: 8px; }
.recipient-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 8px; align-items: center; }
.r-remove {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer;
}
.r-remove:hover { color: var(--red); border-color: var(--red); }
.btn-small { padding: 7px 14px; font-size: 14px; align-self: flex-start; margin-top: 4px; }
.field-hint { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
@media (max-width: 560px) {
  .recipient-row { grid-template-columns: minmax(0, 1fr) 36px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
  .recipient-row .r-greeting { grid-row: 2; grid-column: 1; }
  .recipient-row .r-remove { grid-row: 1 / span 2; grid-column: 2; }
}

/* ---------- 404 ---------- */
body.plain { min-height: 100vh; display: grid; place-items: center; }
.notfound { text-align: center; max-width: 440px; padding: 24px; }
.notfound-star { font-size: 56px; color: var(--gold); }
.notfound h1 { font-size: 38px; margin: 8px 0; color: var(--red-dark); }
.notfound p { color: var(--muted); margin-bottom: 24px; }

/* ---------- Mobil ---------- */
@media (max-width: 900px) {
  .editor { grid-template-columns: 1fr; padding: 16px 16px 48px; gap: 16px; }
  .preview { position: relative; top: 0; order: 0; padding: 14px; }
  .preview-stage { height: 52svh; min-height: 320px; }
  .form-panel { padding: 22px 18px; }
  .form-panel h1 { font-size: 30px; }
  .topbar { padding: 12px 16px; font-size: 26px; }
}

/* ---------- Anmeldung ---------- */
/* Hintergrund: aufgeklappte Beispielkarte (login-bg.js), leicht unscharf hinter einem Milchglas-Fenster */
.login-page {
  --page-bg: #3f0d0d;
  --page-bg2: #b91c1c;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 50% 30%, var(--page-bg2), var(--page-bg) 75%) fixed;
  background-color: var(--page-bg);
}
.login-page .topbar { position: relative; z-index: 2; }
.login-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.login-snow { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-bg-stage {
  position: absolute;
  inset: 9% 6%;
  width: auto;
  height: auto;
  filter: blur(5px) saturate(1.05);
  opacity: .9;
}
.login-wrap { position: relative; z-index: 1; flex: 1; display: grid; place-items: center; padding: 60px 16px; }
.login-panel {
  width: 100%;
  max-width: 420px;
  padding: 28px;
  background: rgba(255, 253, 249, .74);
  border: 1px solid rgba(255, 255, 255, .55);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .6);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}
.login-panel p { color: #5e5049; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .login-panel { background: rgba(255, 253, 249, .93); }
}
.login-panel h1 { margin: 0 0 10px; font-size: 32px; color: var(--red-dark); }
.login-sent { text-align: center; }
.login-sent h2 { font-size: 28px; margin: 8px 0; color: var(--green); }
/* Versandstatus des Anmeldelinks: verschickt gerade / ist raus / fehlgeschlagen */
.send-status {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 4px 0 12px; padding: 7px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 700; background: rgba(255, 255, 255, .6);
}
.login-panel .send-status { color: var(--muted); }
.send-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--gold); animation: send-pulse 1.1s ease-in-out infinite; }
@keyframes send-pulse { 50% { opacity: .25; transform: scale(.7); } }
.login-panel [data-state="sent"] .send-status { color: var(--green); background: #e6f1ea; }
.login-panel [data-state="failed"] .send-status { color: var(--red-dark); background: #fdecea; }
[data-state="sent"] .send-dot, [data-state="failed"] .send-dot { display: none; }
.login-panel .send-note { font-size: 13px; color: var(--muted); margin-bottom: 0; }
[data-state="failed"] .send-note { display: none; }
#loginRetry { margin-top: 12px; }
@media (prefers-reduced-motion: reduce) { .send-dot { animation: none; } }
.topbar .spacer { flex: 1; }
.user-box { display: flex; align-items: center; gap: 10px; font-family: 'Nunito', system-ui, sans-serif; font-size: 14px; }
.user-box button { font: inherit; font-weight: 700; color: #fff; background: none; border: 1px solid rgba(255, 255, 255, .4); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.user-box button:hover { background: rgba(255, 255, 255, .12); }
@media (max-width: 600px) { .user-box .user-mail { display: none; } }

/* ---------- Impressum & Datenschutz ---------- */
/* Unauffällige Links am Seitenende */
.legal-links {
  padding: 4px 16px 18px;
  text-align: center;
  font-family: 'Nunito', system-ui, sans-serif;
  font-size: 12px;
  color: var(--muted);
  opacity: .8;
}
.legal-links a { color: inherit; text-decoration: none; }
.legal-links a:hover, .legal-links a:focus-visible { text-decoration: underline; }
.login-page .legal-links { position: relative; z-index: 1; color: rgba(255, 255, 255, .6); }

.legal-page { min-height: 100vh; display: flex; flex-direction: column; }
.topbar .app-home { color: inherit; text-decoration: none; }
.legal-wrap { flex: 1; padding: 32px 16px 24px; }
.legal-panel { max-width: 760px; margin: 0 auto; padding: 32px 36px; line-height: 1.6; overflow-wrap: break-word; }
.legal-panel h1 { margin: 0 0 18px; font-size: 38px; color: var(--red-dark); }
.legal-panel h2 { margin: 28px 0 8px; font-size: 26px; }
.legal-panel h3 { margin: 20px 0 6px; font-size: 20px; }
.legal-panel p, .legal-panel ul { margin: 0 0 12px; }
.legal-panel ul { padding-left: 22px; }
.legal-panel li { margin-bottom: 6px; }
.legal-panel a { color: var(--green); }
@media (max-width: 600px) {
  .legal-panel { padding: 22px 18px; }
  .legal-panel h1 { font-size: 32px; }
}

/* ---------- Admin-Anmeldung: wie die Mitarbeiter-Anmeldung, aber blau und ohne Karte ---------- */
.login-admin {
  --page-bg: #050c1f;
  --page-bg2: #24447e;
  --admin-blue: #24447e;
  --admin-blue-dark: #1b2c55;
}
.login-admin .topbar { background: var(--admin-blue-dark); }
.login-admin .login-panel h1 { color: var(--admin-blue-dark); }
.login-admin .btn-primary { background: var(--admin-blue); }
.login-admin .btn-primary:hover { background: var(--admin-blue-dark); }
.login-admin .login-sent h2 { color: var(--admin-blue); }
.login-admin .result-icon { color: var(--admin-blue); }
.login-admin input:focus { border-color: var(--admin-blue); box-shadow: 0 0 0 3px rgba(36, 68, 126, .18); }
.login-admin .login-panel a:not(.btn) { color: var(--admin-blue); }
/* admin.html: Hintergrund nur, solange die Anmeldung zu sehen ist */
body:not(.login-page) > .login-bg { display: none; }
.login-page .admin-login { position: relative; z-index: 1; flex: 1; }
.login-page .admin-disabled { position: relative; z-index: 1; flex: 1; color: rgba(255, 255, 255, .85); }
.login-page .admin-disabled code { color: #fff; }
.login-admin .login-panel { background: rgba(255, 253, 249, .94); }
