/* ============================================================
   dein Nagelstudio · Bilder-Studio
   Gleiche Design-Sprache wie die Website (src/app/globals.css):
   warmes Porzellan, Aubergine-Tinte, Blush-Rosé, Champagner-Gold,
   Fraunces + Manrope, Nagel-Mandelform als Signatur.
   ============================================================ */

@font-face { font-family: "Fraunces"; font-weight: 400; font-style: normal; font-display: swap; src: url("/cms/fonts/fraunces-400.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 400; font-style: italic; font-display: swap; src: url("/cms/fonts/fraunces-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Fraunces"; font-weight: 500; font-style: normal; font-display: swap; src: url("/cms/fonts/fraunces-500.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 400; font-display: swap; src: url("/cms/fonts/manrope-400.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 500; font-display: swap; src: url("/cms/fonts/manrope-500.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 600; font-display: swap; src: url("/cms/fonts/manrope-600.woff2") format("woff2"); }
@font-face { font-family: "Manrope"; font-weight: 700; font-display: swap; src: url("/cms/fonts/manrope-700.woff2") format("woff2"); }

:root {
  --porcelain: #fbf6f2;
  --porcelain-2: #f4e9e3;
  --porcelain-3: #efdcd6;
  --ink: #211018;
  --ink-soft: #6e5560;
  --ink-faint: #a58f97;
  --line: #e7d6cf;
  --line-2: #dcc4bb;
  --plum: #7c2b4e;
  --plum-deep: #571d38;
  --rose: #dda0a6;
  --rose-soft: #f0d3d2;
  --gold: #c29b5b;
  --gold-soft: #e7cfa0;
  --danger: #a3313f;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --nail-radius: 46% 46% 44% 44% / 62% 62% 38% 38%;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 24px 60px -32px rgba(87, 29, 56, 0.45);
  --topbar: 4.25rem;
}

*, *::before, *::after { box-sizing: border-box; }
* { border-color: var(--line); }

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--porcelain);
  color: var(--ink);
  font: 500 15px/1.55 var(--font-body);
}
::selection { background: var(--plum); color: #fff; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--plum); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.grain::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 200; opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Typografie ---------- */
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.015em; line-height: 1.06; margin: 0; }
.display em { font-style: italic; color: var(--plum); }
.eyebrow { font-size: 0.66rem; letter-spacing: 0.3em; text-transform: uppercase; font-weight: 700; color: var(--plum); }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 0.85rem; }
.hairline {
  height: 1px; border: 0; margin: 0;
  background: linear-gradient(90deg, transparent, var(--line-2) 20%, var(--gold-soft) 50%, var(--line-2) 80%, transparent);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px; padding: 0.7rem 1.3rem; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 0.9rem; line-height: 1; white-space: nowrap;
  background: transparent;
  transition: transform 0.35s var(--ease), background-color 0.25s, color 0.25s, border-color 0.25s, box-shadow 0.35s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }
.btn-primary { background: var(--ink); color: var(--porcelain); box-shadow: 0 12px 30px -12px rgba(33, 16, 24, 0.55); }
.btn-primary:not(:disabled):hover { background: var(--plum); box-shadow: 0 18px 40px -12px rgba(124, 43, 78, 0.6); }
.btn-ghost { border-color: var(--line-2); color: var(--ink); background: rgba(251, 246, 242, 0.6); }
.btn-ghost:not(:disabled):hover { border-color: var(--plum); color: var(--plum); }
.btn-soft { background: var(--porcelain-2); color: var(--ink); }
.btn-soft:not(:disabled):hover { background: var(--rose-soft); color: var(--plum-deep); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: transparent; }
.btn-danger:not(:disabled):hover { background: var(--danger); color: #fff; }
.btn-danger.confirm { background: var(--danger); color: #fff; }
.btn-sm { min-height: 36px; padding: 0.5rem 0.9rem; font-size: 0.82rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(251, 246, 242, 0.92); color: var(--ink);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.3s var(--ease);
}
.icon-btn:hover { border-color: var(--plum); color: var(--plum); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.link { color: var(--plum); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; font-weight: 600; }

/* ---------- Formulare ---------- */
.field { display: grid; gap: 0.4rem; }
.field > span { font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); }
.input {
  width: 100%; min-height: 46px; padding: 0.7rem 1rem; border-radius: 14px;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input::placeholder { color: var(--ink-faint); }
.input:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 4px color-mix(in srgb, var(--plum) 14%, transparent); }
.input-sm { min-height: 38px; padding: 0.45rem 0.8rem; border-radius: 11px; font-size: 0.88rem; }
/* iOS Safari zoomt beim Antippen von Feldern unter 16 px hinein und bleibt
   danach gezoomt (Dialoge wirken dann eingeengt/abgeschnitten). */
input, select, textarea, .input, .input-sm { font-size: max(16px, 1rem); }
.form-error { color: var(--danger); font-size: 0.85rem; font-weight: 600; min-height: 1.2em; margin: 0; }

/* ---------- Ladeanzeige ---------- */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner {
  width: 1.1rem; height: 1.1rem; border-radius: 50%; display: inline-block; flex: none;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
}
.boot .spinner { width: 2rem; height: 2rem; color: var(--plum); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Anmeldung / Ersteinrichtung
   ============================================================ */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 2rem 1.25rem;
  background:
    radial-gradient(900px 560px at 12% 8%, var(--rose-soft) 0%, transparent 60%),
    radial-gradient(800px 560px at 92% 95%, color-mix(in srgb, var(--gold-soft) 75%, transparent) 0%, transparent 60%),
    var(--porcelain);
}
.auth-card {
  width: min(100%, 26rem); padding: 2.5rem 2rem 2rem; border-radius: 28px;
  background: rgba(255, 255, 255, 0.72); border: 1px solid var(--line);
  box-shadow: var(--shadow); backdrop-filter: blur(16px);
  animation: rise 0.7s var(--ease) both;
}
.auth-card .display { font-size: clamp(2rem, 6vw, 2.5rem); margin-top: 0.85rem; }
.auth-card form { display: grid; gap: 1rem; margin-top: 1.75rem; }
.auth-brand { display: flex; align-items: center; gap: 0.75rem; }
.auth-or { display: flex; align-items: center; gap: 0.8rem; color: var(--ink-faint); font-size: 0.75rem; letter-spacing: 0.2em; text-transform: uppercase; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-foot { margin-top: 1.75rem; text-align: center; font-size: 0.72rem; color: var(--ink-faint); letter-spacing: 0.04em; }
.strength { height: 4px; border-radius: 99px; background: var(--porcelain-3); overflow: hidden; }
.strength > i { display: block; height: 100%; width: 0; background: var(--rose); transition: width 0.35s var(--ease), background-color 0.3s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.mark {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border-radius: 14px; background: var(--ink); overflow: hidden;
}
.mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text .name { font-family: var(--font-display); font-size: 1.15rem; }
.brand-text .sub { font-size: 0.58rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; }

/* ============================================================
   App-Rahmen
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1.25rem; padding-top: env(safe-area-inset-top, 0px);
  background: rgba(251, 246, 242, 0.85); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar .left, .topbar .right { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.topbar .mark { width: 38px; height: 38px; border-radius: 50%; box-shadow: 0 0 0 1px var(--line-2); }

.status {
  display: inline-flex; align-items: center; gap: 0.55rem; padding: 0.45rem 0.9rem;
  border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap;
  background: var(--porcelain-2); color: var(--ink-soft); border: 1px solid transparent;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.status.live { color: var(--plum); background: color-mix(in srgb, var(--rose-soft) 55%, transparent); }
.status.dirty { color: #8a6526; background: color-mix(in srgb, var(--gold-soft) 45%, transparent); }
.status.dirty .dot { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 25%, transparent); }
.status.running { color: var(--plum); background: #fff; border-color: var(--line); }
.status.failed { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.status button { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.save-hint { font-size: 0.75rem; color: var(--ink-faint); white-space: nowrap; }

.layout { display: grid; grid-template-columns: minmax(22rem, 30rem) 1fr; height: calc(100dvh - var(--topbar)); }
.editor { overflow-y: auto; padding: 1.75rem 1.5rem 6rem; border-right: 1px solid var(--line); scroll-behavior: smooth; }
.editor-head { margin-bottom: 1.5rem; }
.editor-head .display { font-size: 2.1rem; margin-top: 0.5rem; }
.editor-head p { margin: 0.6rem 0 0; }

.preview { position: relative; display: flex; flex-direction: column; background: var(--porcelain-2); min-width: 0; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.75rem 1.25rem; }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--porcelain-3); }
.segmented button {
  border: 0; background: transparent; padding: 0.45rem 0.95rem; border-radius: 999px; min-height: 34px;
  display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; font-weight: 600; color: var(--ink-soft);
}
.segmented button svg { width: 15px; height: 15px; }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 4px 14px -8px rgba(33, 16, 24, 0.5); }
.stage { position: relative; flex: 1; overflow: hidden; padding: 0 1.25rem 1.25rem; }
.screen {
  position: relative; width: 100%; height: 100%; margin: 0 auto; overflow: hidden;
  border-radius: 20px; background: var(--porcelain); box-shadow: var(--shadow), 0 0 0 1px var(--line-2);
  transition: width 0.5s var(--ease), border-radius 0.5s var(--ease);
}
.screen.mobile { width: min(100%, 390px); border-radius: 38px; box-shadow: var(--shadow), 0 0 0 8px var(--ink), 0 0 0 9px var(--line-2); }
.stage:has(.screen.mobile) { padding-top: 0.75rem; padding-bottom: 1.75rem; }
.screen iframe {
  position: absolute; top: 0; left: 0; border: 0; background: var(--porcelain);
  transform-origin: 0 0; transition: opacity 0.35s ease;
}
.screen iframe.back { opacity: 0; pointer-events: none; }
.preview-loading {
  position: absolute; right: 1rem; bottom: 1rem; z-index: 3; display: inline-flex; gap: 0.5rem; align-items: center;
  padding: 0.45rem 0.8rem; border-radius: 999px; background: rgba(33, 16, 24, 0.82); color: var(--porcelain);
  font-size: 0.75rem; font-weight: 600; opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.3s var(--ease); pointer-events: none;
}
.preview-loading.on { opacity: 1; transform: none; }

/* ---------- Karten / Abschnitte ---------- */
.section {
  padding: 1.35rem; border-radius: 24px; background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line); margin-bottom: 1rem;
  transition: border-color 0.3s, box-shadow 0.4s var(--ease);
}
.section.focus { border-color: var(--rose); box-shadow: 0 18px 40px -30px rgba(124, 43, 78, 0.6); }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-head h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; margin: 0.3rem 0 0; letter-spacing: -0.01em; }
.section-head p { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--ink-soft); }
.count { font-family: var(--font-display); font-style: italic; color: var(--ink-faint); font-size: 1.1rem; }

/* Einzelbild-Slot */
.slot { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; }
.thumb {
  position: relative; overflow: hidden; background: var(--porcelain-3);
  border: 0; padding: 0; display: block; flex: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
button.thumb:hover img { transform: scale(1.05); }
.thumb.nail { width: 6.25rem; aspect-ratio: 4 / 5; border-radius: var(--nail-radius); box-shadow: 0 0 0 1px var(--line-2); }
.thumb.round { width: 5rem; aspect-ratio: 1; border-radius: 50%; box-shadow: 0 0 0 1px var(--line-2); }
.thumb.missing { display: grid; place-items: center; color: var(--ink-faint); font-size: 0.7rem; text-align: center; padding: 0.5rem; }
.thumb.missing::after { content: "Bild fehlt"; }
.slot-info { min-width: 0; display: grid; gap: 0.6rem; }
.slot-info .file { font-size: 0.78rem; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.drop-target { position: relative; }
.drop-target.dragover::after {
  content: "Bild hier ablegen"; position: absolute; inset: -6px; border-radius: 22px; z-index: 5;
  display: grid; place-items: center; font-weight: 700; color: var(--plum); font-size: 0.85rem;
  background: color-mix(in srgb, var(--rose-soft) 80%, transparent); border: 2px dashed var(--plum);
}

/* Vorher / Nachher */
.pairs { display: grid; gap: 0.85rem; }
.pair { padding: 0.85rem; border-radius: 18px; background: var(--porcelain); border: 1px solid var(--line); display: grid; gap: 0.75rem; }
.pair-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.pair-imgs .thumb { width: 100%; aspect-ratio: 4 / 3; border-radius: 14px; box-shadow: 0 0 0 1px var(--line-2); }
.pair-imgs .tag {
  position: absolute; left: 0.45rem; top: 0.45rem; z-index: 2; padding: 0.2rem 0.55rem; border-radius: 99px;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; pointer-events: none;
  background: rgba(33, 16, 24, 0.72); color: var(--porcelain);
}
.pair-imgs .tag.after { background: rgba(251, 246, 242, 0.88); color: var(--plum); }
.pair-row { display: flex; gap: 0.5rem; align-items: center; }
.pair-row .input { flex: 1; }

/* Galerie */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.tile { position: relative; border-radius: 16px; overflow: hidden; aspect-ratio: 1; background: var(--porcelain-3); box-shadow: 0 0 0 1px var(--line); transition: transform 0.3s var(--ease), box-shadow 0.2s, opacity 0.2s; }
.tile > button.thumb { width: 100%; height: 100%; }
.tile .num {
  position: absolute; left: 0.4rem; top: 0.4rem; z-index: 2; min-width: 1.5rem; height: 1.5rem; padding: 0 0.4rem;
  display: grid; place-items: center; border-radius: 99px; background: rgba(251, 246, 242, 0.9);
  font-size: 0.68rem; font-weight: 700; color: var(--ink); pointer-events: none;
}
.tile.selected { box-shadow: 0 0 0 3px var(--plum); }
.tile.dragging { opacity: 0.35; }
.tile.drop-before { box-shadow: -4px 0 0 0 var(--plum); }
.tile.drop-after { box-shadow: 4px 0 0 0 var(--plum); }
.tile.add {
  display: grid; place-items: center; border: 1.5px dashed var(--line-2); background: transparent; box-shadow: none;
  color: var(--ink-soft); font-size: 0.78rem; font-weight: 600; text-align: center; padding: 0.5rem;
}
.tile.add:hover { border-color: var(--plum); color: var(--plum); background: color-mix(in srgb, var(--rose-soft) 35%, transparent); }
.tile.add svg { width: 22px; height: 22px; margin: 0 auto 0.3rem; }
.tile-detail {
  margin-top: 0.85rem; padding: 0.85rem; border-radius: 18px; background: var(--porcelain); border: 1px solid var(--line);
  display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.85rem; align-items: start; animation: rise 0.35s var(--ease) both;
}
.tile-detail .thumb { width: 4.5rem; aspect-ratio: 1; border-radius: 12px; }
.tile-detail .tools { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.55rem; }

.empty {
  padding: 1.5rem; border-radius: 18px; text-align: center; color: var(--ink-soft); font-size: 0.88rem;
  border: 1.5px dashed var(--line-2); background: rgba(251, 246, 242, 0.6);
}

/* ============================================================
   Dialoge
   ============================================================ */
dialog {
  border: 0; padding: 0; color: var(--ink); background: var(--porcelain);
  border-radius: 28px; box-shadow: 0 40px 120px -40px rgba(33, 16, 24, 0.6);
  width: min(100vw - 2rem, 44rem); max-width: none;
  max-height: calc(100vh - 2rem); max-height: min(100dvh - 2rem, 52rem);
}
dialog.wide {
  width: min(100vw - 2rem, 64rem);
  /* Feste Höhe: ältere iOS-Versionen lassen den Inhalt sonst auf 0 schrumpfen. */
  height: calc(100vh - 2rem);
  height: min(100dvh - 2rem, 52rem);
}
dialog[open] { display: flex; flex-direction: column; animation: pop 0.4s var(--ease) both; }
dialog::backdrop { background: rgba(33, 16, 24, 0.42); backdrop-filter: blur(4px); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.5rem 1.5rem 1rem; }
.dlg-head .display { font-size: 1.75rem; margin-top: 0.35rem; }
.dlg-body { padding: 0 1.5rem 1.25rem; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; min-height: 0; }
.dlg-head, .dlg-foot { flex: none; }
.dlg-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding: 1rem 1.5rem calc(1rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: rgba(244, 233, 227, 0.5);
}
.dlg-foot .right { display: flex; gap: 0.5rem; margin-left: auto; }

/* Mediathek */
.lib-tools { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: 0.4rem 0.85rem;
  font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); min-height: 34px;
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--porcelain); }
.dropzone {
  display: grid; place-items: center; gap: 0.35rem; text-align: center; padding: 1.25rem; margin-bottom: 1rem;
  border-radius: 20px; border: 1.5px dashed var(--line-2); color: var(--ink-soft); font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.5); transition: border-color 0.2s, background-color 0.2s;
}
.dropzone.dragover { border-color: var(--plum); background: color-mix(in srgb, var(--rose-soft) 60%, transparent); color: var(--plum); }
.dropzone strong { color: var(--ink); }
.dropzone .btn { margin-top: 0.35rem; }
@media (hover: none) and (pointer: coarse) {
  .dropzone .drag-hint { display: none; }
  .dropzone .btn { width: 100%; }
}
.library { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 0.75rem; }
.lib-item { position: relative; display: grid; gap: 0.35rem; }
.lib-item > button.thumb {
  width: 100%; aspect-ratio: 1; border-radius: 16px; box-shadow: 0 0 0 1px var(--line);
  transition: box-shadow 0.2s, transform 0.3s var(--ease);
}
.lib-item.selected > button.thumb { box-shadow: 0 0 0 3px var(--plum); transform: scale(0.97); }
.lib-item .pick {
  position: absolute; right: 0.45rem; top: 0.45rem; z-index: 2; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; pointer-events: none;
  background: rgba(251, 246, 242, 0.85); border: 1.5px solid var(--line-2); color: transparent;
}
.lib-item.selected .pick { background: var(--plum); border-color: var(--plum); color: #fff; }
.lib-item .meta { font-size: 0.7rem; color: var(--ink-faint); line-height: 1.3; overflow: hidden; }
.lib-item .meta b { display: block; color: var(--ink-soft); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-item .badge {
  position: absolute; left: 0.45rem; top: 0.45rem; z-index: 2; padding: 0.15rem 0.5rem; border-radius: 99px;
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; pointer-events: none;
  background: rgba(33, 16, 24, 0.72); color: var(--porcelain);
}
.lib-item .del { position: absolute; right: 0.4rem; bottom: 3.1rem; z-index: 3; width: 32px; height: 32px; opacity: 0; transition: opacity 0.2s; }
.lib-item:hover .del, .lib-item:focus-within .del, .lib-item .del.confirm { opacity: 1; }
.lib-item .del.confirm { width: auto; padding: 0 0.7rem; border-radius: 99px; background: var(--danger); color: #fff; border-color: var(--danger); font-size: 0.72rem; font-weight: 700; }
.uploading { display: flex; align-items: center; gap: 0.6rem; font-size: 0.82rem; color: var(--plum); font-weight: 600; }

/* Listen (Passkeys, Versionen) */
.list { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.list li {
  display: flex; align-items: center; gap: 0.85rem; padding: 0.85rem 1rem; border-radius: 16px;
  background: #fff; border: 1px solid var(--line);
}
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { font-size: 0.76rem; color: var(--ink-faint); }
.list .ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--rose-soft); color: var(--plum); }
.list .ico svg { width: 18px; height: 18px; }
.block + .block { margin-top: 1.75rem; }
.block h3 { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; margin: 0 0 0.35rem; }
.block > p { margin: 0 0 1rem; font-size: 0.86rem; color: var(--ink-soft); }
.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.85rem; }
.inline-form .input { flex: 1 1 12rem; }
.note {
  padding: 0.85rem 1rem; border-radius: 14px; font-size: 0.84rem; line-height: 1.5;
  background: color-mix(in srgb, var(--gold-soft) 35%, transparent); color: #6d4f1c; border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
}
.stack { display: grid; gap: 0.85rem; }
pre.log {
  margin: 0; padding: 1rem; border-radius: 16px; background: var(--ink); color: #f1e4e8;
  font: 0.75rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; max-height: 50dvh; overflow: auto;
}

/* Menü */
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 0.5rem); z-index: 60; min-width: 15rem; padding: 0.4rem;
  border-radius: 18px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: pop 0.25s var(--ease) both;
}
.menu-pop button, .menu-pop a {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; padding: 0.7rem 0.85rem; border-radius: 12px;
  border: 0; background: transparent; text-align: left; font-size: 0.88rem; font-weight: 600; color: var(--ink); text-decoration: none;
}
.menu-pop button:hover, .menu-pop a:hover { background: var(--porcelain-2); color: var(--plum); }
.menu-pop svg { width: 17px; height: 17px; color: var(--ink-soft); }
.menu-pop hr { border: 0; height: 1px; background: var(--line); margin: 0.35rem 0.4rem; }

/* Hinweise */
#toasts {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); z-index: 300;
  transform: translateX(-50%); display: grid; gap: 0.5rem; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 2rem);
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 1.1rem; border-radius: 999px;
  background: var(--ink); color: var(--porcelain); font-size: 0.86rem; font-weight: 600;
  box-shadow: 0 20px 40px -20px rgba(33, 16, 24, 0.7); animation: rise 0.4s var(--ease) both;
}
.toast.error { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); transition: opacity 0.3s, transform 0.3s; }

/* Mobile Tab-Leiste (Bearbeiten / Vorschau) */
.tabs {
  display: none; position: fixed; left: 50%; bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px)); z-index: 45;
  transform: translateX(-50%); padding: 4px; border-radius: 999px; background: var(--ink); box-shadow: 0 20px 40px -18px rgba(33, 16, 24, 0.8);
}
.tabs button { border: 0; background: transparent; color: rgba(251, 246, 242, 0.65); padding: 0.65rem 1.25rem; border-radius: 999px; font-weight: 700; font-size: 0.85rem; min-height: 44px; display: inline-flex; gap: 0.45rem; align-items: center; }
.tabs button svg { width: 16px; height: 16px; }
.tabs button[aria-pressed="true"] { background: var(--porcelain); color: var(--ink); }

/* ============================================================
   Responsiv
   ============================================================ */
@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(20rem, 26rem) 1fr; }
  .save-hint { display: none; }
}
@media (max-width: 900px) {
  :root { --topbar: 3.75rem; }
  .topbar { padding: 0 0.85rem; }
  .topbar .brand-text .sub { display: none; }
  .topbar .status .label-long { display: none; }
  .layout { grid-template-columns: 1fr; height: auto; min-height: calc(100dvh - var(--topbar)); }
  .editor { border-right: 0; overflow: visible; padding: 1.25rem 1rem 7rem; }
  .preview { position: fixed; inset: var(--topbar) 0 0 0; z-index: 30; }
  .preview .device-toggle { display: none; }
  .stage { padding: 0 0.75rem 5.5rem; }
  .screen, .screen.mobile { width: 100%; border-radius: 18px; box-shadow: var(--shadow), 0 0 0 1px var(--line-2); }
  body[data-view="edit"] .preview { visibility: hidden; pointer-events: none; }
  body[data-view="preview"] .editor { display: none; }
  .tabs { display: inline-flex; }
  .btn-publish .label-long { display: none; }
}
@media (max-width: 520px) {
  .topbar .brand-text { display: none; }
  .btn-discard .label { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  dialog, dialog.wide { width: 100vw; max-height: 92vh; max-height: 92dvh; margin-bottom: 0; border-radius: 26px 26px 0 0; }
  dialog.wide { height: 92vh; height: 92dvh; }
  .dlg-head, .dlg-body, .dlg-foot { padding-left: 1.1rem; padding-right: 1.1rem; }
  .slot { grid-template-columns: auto 1fr; }
}
@media (hover: none) {
  .lib-item .del { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============================================================
   Stammdaten-Formular
   ============================================================ */
.section-toggle button { min-height: 38px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem 0.75rem; }
.form-grid > .wide, .form-grid > .field:has(textarea) { grid-column: 1 / -1; }
.form-grid .field > span { display: block; }
textarea.input { min-height: 6.5rem; resize: vertical; line-height: 1.5; font-family: inherit; }
.field-help { font-size: 0.74rem; color: var(--ink-faint); line-height: 1.4; }
.field-error { font-size: 0.76rem; font-weight: 600; color: var(--danger); min-height: 0; }
.field-error:empty { display: none; }
.field.invalid .input { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(163, 49, 63, 0.12); }
.derived {
  display: grid; gap: 0.2rem; padding: 0.7rem 0.9rem; border-radius: 14px; font-size: 0.8rem;
  background: var(--porcelain-2); color: var(--ink-soft); word-break: break-all;
}
.derived b { color: var(--ink); font-weight: 700; }
details.advanced { border-top: 1px solid var(--line); padding-top: 0.75rem; }
details.advanced summary { cursor: pointer; font-size: 0.82rem; font-weight: 600; color: var(--plum); min-height: 32px; display: flex; align-items: center; }
details.advanced[open] summary { margin-bottom: 0.75rem; }
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Benutzerverwaltung
   ============================================================ */
.menu-user { display: grid; padding: 0.55rem 0.85rem 0.35rem; line-height: 1.25; }
.menu-user b { font-size: 0.92rem; }
.menu-user span { font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.user-row { flex-wrap: wrap; }
.user-actions { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.role-select { width: auto; min-width: 8.5rem; padding-right: 2rem; }
.pill {
  display: inline-block; margin-left: 0.5rem; padding: 0.1rem 0.5rem; border-radius: 99px; vertical-align: middle;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--gold-soft); color: #6d4f1c;
}
.secret-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.5rem 0; flex-wrap: wrap; }
code.secret {
  font: 700 1.05rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.06em;
  padding: 0.5rem 0.8rem; border-radius: 10px; background: #fff; color: var(--ink); user-select: all;
}
.list.audit li { padding: 0.6rem 0.9rem; }
.list.audit li.bad { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.list.audit li.bad .title { color: var(--danger); }
@media (max-width: 520px) {
  .user-actions { width: 100%; }
  .inline-form .role-select { flex: 1 1 100%; }
}
