/* ============================================================
   IDUNN DESIGN SYSTEM v2 — komplett neu, modern, professional
   ============================================================ */

:root {
  /* Brand-Palette: warm + professionell, gold-rot Akzent */
  --color-bg: #faf7f2;
  --color-surface: #ffffff;
  --color-surface-2: #fdf6e3;
  --color-surface-3: #f5ecdc;
  --color-border: #e6dcc4;
  --color-border-strong: #c8b894;
  --color-text: #2a1f14;
  --color-text-soft: #5a4a3a;
  --color-text-muted: #8a7a68;
  --color-primary: #b54d3a;          /* warm-rot Akzent */
  --color-primary-hover: #9a3f2f;
  --color-primary-soft: #fce4dc;
  --color-accent: #c89a3a;            /* gold */
  --color-accent-soft: #f8efd0;
  --color-success: #4a7a4a;
  --color-error: #b54d3a;

  /* Typo */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  --font-serif: "Georgia", "Cambria", "Times New Roman", serif;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(42, 31, 20, 0.06), 0 1px 3px rgba(42, 31, 20, 0.04);
  --shadow-md: 0 4px 12px rgba(42, 31, 20, 0.08), 0 2px 4px rgba(42, 31, 20, 0.04);
  --shadow-lg: 0 12px 32px rgba(42, 31, 20, 0.12), 0 4px 12px rgba(42, 31, 20, 0.06);
  --shadow-xl: 0 24px 64px rgba(42, 31, 20, 0.18);
  --shadow-glow: 0 0 0 4px rgba(181, 77, 58, 0.15);

  /* Transitions */
  --t-fast: 120ms cubic-bezier(.4,0,.2,1);
  --t-base: 200ms cubic-bezier(.4,0,.2,1);
  --t-slow: 400ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(12px);
  background: rgba(255, 255, 255, 0.85);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
  font-weight: 700;
  font-size: 1.15rem;
}
.brand-icon { font-size: 1.4rem; }
.topnav {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.topnav a {
  color: var(--color-text-soft);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--t-fast);
}
.topnav a:hover { color: var(--color-primary); }
.user-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--color-text-soft);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.6rem 1.2rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
  user-select: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
}
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover {
  background: var(--color-surface-2);
  border-color: var(--color-primary);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-soft);
}
.btn-ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.btn-block { width: 100%; }
.btn-lg { padding: 0.85rem 1.6rem; font-size: 1.05rem; }

/* ============================================================
   LOGIN PAGE — komplett neuer Look
   ============================================================ */
.auth-shell {
  min-height: calc(100vh - 65px);
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0;
  background: var(--color-bg);
}
@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
}
.auth-hero {
  position: relative;
  background:
    linear-gradient(135deg, #2a1810 0%, #5a3a28 50%, #8b4a32 100%);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
  overflow: hidden;
}
.auth-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(200, 154, 58, 0.25) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(181, 77, 58, 0.3) 0%, transparent 50%);
  pointer-events: none;
}
.auth-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(45deg, transparent 0 20px, rgba(255,255,255,0.02) 20px 21px);
  pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero h1 {
  font-family: var(--font-serif);
  font-size: 3.5rem;
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-4);
  line-height: 1.1;
}
.auth-hero p.lede {
  font-size: 1.15rem;
  color: rgba(255, 255, 255, 0.8);
  max-width: 480px;
  line-height: 1.6;
  margin: 0 0 var(--space-6);
}
.auth-hero .feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-3);
  max-width: 480px;
}
.auth-hero .feature-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.95rem;
}
.auth-hero .feature-list .icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.auth-form-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-8) var(--space-6);
  max-width: 480px;
  width: 100%;
  justify-self: center;
}
.auth-form-wrap h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
  margin: 0 0 var(--space-2);
  letter-spacing: -0.01em;
}
.auth-form-wrap .subtitle {
  color: var(--color-text-muted);
  margin: 0 0 var(--space-6);
}
.auth-form {
  display: grid;
  gap: var(--space-4);
}
.auth-form label {
  display: grid;
  gap: var(--space-2);
}
.auth-form label > span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-soft);
}
.auth-form input {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.85rem 1rem;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  transition: all var(--t-fast);
  outline: none;
}
.auth-form input:hover { border-color: var(--color-text-muted); }
.auth-form input:focus {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}
.auth-meta {
  margin-top: var(--space-5);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}
.auth-flash {
  background: var(--color-primary-soft);
  border: 1px solid var(--color-primary);
  color: var(--color-primary-hover);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

/* ============================================================
   PAGE
   ============================================================ */
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-6);
}
.flashes { margin-bottom: var(--space-4); }
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
}
.flash-error { background: var(--color-primary-soft); color: var(--color-primary-hover); }

/* ============================================================
   GALLERY — Karten-Grid mit Hover-Effekten
   ============================================================ */
.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}
.gallery-header h1 {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  font-weight: 400;
  margin: 0 0 var(--space-1);
  letter-spacing: -0.01em;
}
.gallery-header p { color: var(--color-text-muted); margin: 0; }
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}
.template-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: all var(--t-base);
  display: flex;
  flex-direction: column;
  position: relative;
}
.template-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}
.template-card .preview {
  aspect-ratio: 4/3;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.template-card .preview img,
.template-card .preview svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.template-card .info {
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.template-card .info h3 {
  margin: 0 0 var(--space-1);
  font-size: 1.05rem;
  font-weight: 600;
}
.template-card .info p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}


/* ============================================================
   EDITOR — Drag/Resize/Rotate, Auto-Stack, moderne Optik
   ============================================================ */
.editor-shell {
  display: grid;
  grid-template-columns: 300px 1fr 340px;
  gap: var(--space-4);
  max-width: 1700px;
  margin: 0 auto;
  padding: var(--space-4);
  min-height: calc(100vh - 65px);
}
@media (max-width: 1200px) {
  .editor-shell { grid-template-columns: 1fr; }
}
.editor-side {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}
.editor-side h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-3);
}
.editor-stage {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.editor-stage h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  margin: 0 0 var(--space-3);
  color: var(--color-text);
}
.editor-stage svg {
  max-width: 100%;
  max-height: 70vh;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  box-shadow: var(--shadow-md);
}
.editor-stage svg [data-layer-id].layer {
  cursor: grab;
}
.editor-stage svg [data-layer-id].layer:active {
  cursor: grabbing;
}
.editor-stage svg [data-layer-id].layer.selected text {
  paint-order: stroke;
  stroke: rgba(255,255,255,0.4);
  stroke-width: 1;
}

.add-bar {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.add-bar .btn { flex: 1; min-width: 0; }
.sticker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-top: var(--space-3);
}
.sticker-grid button {
  font-size: 1.4rem;
  padding: 0.5rem 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--t-fast);
  aspect-ratio: 1;
}
.sticker-grid button:hover {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
  transform: scale(1.08);
}
.sticker-grid button:active { transform: scale(0.95); }

.layer-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.layer-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  transition: all var(--t-fast);
}
.layer-row:hover { background: var(--color-surface-2); border-color: var(--color-border-strong); }
.layer-row.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  box-shadow: 0 0 0 1px var(--color-primary);
}
.layer-icon {
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}
.layer-row.selected .layer-icon {
  background: var(--color-primary);
  color: white;
}
.layer-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.layer-actions {
  display: flex;
  gap: 2px;
  opacity: 0.6;
  transition: opacity var(--t-fast);
}
.layer-row:hover .layer-actions,
.layer-row.selected .layer-actions { opacity: 1; }
.layer-actions button {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.layer-actions button:hover { background: var(--color-surface-2); }
.layer-actions button.danger:hover { background: var(--color-primary-soft); color: var(--color-primary); }
.layer-empty {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: var(--space-3);
  font-style: italic;
}

.prop-empty {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: var(--space-4);
  font-style: italic;
}
.prop-h {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 400;
  margin: 0 0 var(--space-3);
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.prop-h .badge {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  background: var(--color-accent-soft);
  color: var(--color-text);
  border-radius: var(--radius-sm);
}
.prop-row {
  margin-bottom: var(--space-3);
}
.prop-row label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-soft);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.prop-row label .prop-val { color: var(--color-text); font-weight: 700; }
.prop-row input[type=range] {
  width: 100%;
  accent-color: var(--color-primary);
}
.prop-row input[type=text], .prop-row textarea, .prop-row select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  transition: all var(--t-fast);
}
.prop-row input[type=text]:focus, .prop-row textarea:focus, .prop-row select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-glow);
}
.prop-row textarea { resize: vertical; min-height: 60px; }

.prop-colors {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.color-swatch {
  width: 28px;
  height: 28px;
  border: 2px solid var(--color-surface);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 1px var(--color-border);
  transition: all var(--t-fast);
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected {
  box-shadow: 0 0 0 2px var(--color-primary), 0 0 0 4px var(--color-primary-soft);
  transform: scale(1.05);
}

.save-bar {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.save-bar .btn { flex: 1; }
.save-bar .btn-lg { padding: 0.8rem 1.2rem; }

#photo-input { display: none; }

/* Inline edit textarea overlay */
.inline-edit {
  position: absolute;
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  font-family: inherit;
  font-size: 1rem;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  resize: none;
  outline: none;
  min-width: 200px;
}
