/* Galerie-Admin – responsives Design ohne Build-Schritt und ohne Inline-Styles (strikte CSP). */
:root {
    color-scheme: light;
    --fg: #1c1c1e; --muted: #6b6b70; --faint: #6a6a70;
    --bg: #f4f3f1; --card: #fff; --line: #e3e1dd; --line-strong: #cfccc6;
    --accent: #1c1c1e; --accent-fg: #fff; --soft: #efedea;
    --ok: #1f7a4d; --ok-bg: #e5f3eb; --warn: #8a5a00; --warn-bg: #fdf1d9;
    --danger: #b3261e; --danger-bg: #fbe9e7; --info-bg: #e9eef8; --focus: #2c5fd6;
    --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; color: var(--fg); background: var(--bg); }
a { color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Grundgerüst ---------- */
.shell { min-height: 100vh; }
.brand { font-weight: 650; letter-spacing: -.01em; text-decoration: none; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; letter-spacing: 0; }
.content { width: 100%; min-width: 0; padding: 1.25rem 1rem 3rem; max-width: 1240px; margin: 0 auto; }
.content.narrow { max-width: 460px; padding-top: 3rem; }

@media (min-width: 900px) {
    .content { padding: 2rem 2.25rem 4rem; }
}

/* ---------- Typografie ---------- */
h1 { font-size: 1.55rem; line-height: 1.25; margin: 0; letter-spacing: -.015em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
.hint, .meta { color: var(--muted); }
.hint, .meta { font-size: .87rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

/* ---------- Bausteine ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.25rem; }
.page-head .meta { margin: .3rem 0 0; }
.back { display: inline-block; margin-bottom: .6rem; color: var(--muted); text-decoration: none; font-size: .9rem; }
.back:hover { color: var(--fg); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card > :last-child { margin-bottom: 0; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.grow { flex: 1 1 auto; }

.button, button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 40px; padding: .5rem 1rem; font: inherit; font-weight: 550; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: var(--accent-fg); cursor: pointer; text-decoration: none; white-space: nowrap; }
.button.secondary, button.secondary { background: var(--card); color: var(--fg); border-color: var(--line-strong); }
.button.secondary:hover, button.secondary:hover { background: var(--soft); }
button.danger, .button.danger { background: var(--danger); border-color: var(--danger); }
button.ghost { background: none; border-color: transparent; color: var(--muted); min-height: 32px; padding: .25rem .5rem; }
button.ghost:hover { color: var(--fg); background: var(--soft); }
button.small, .button.small { min-height: 32px; padding: .3rem .7rem; font-size: .87rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: inherit; text-decoration: underline; font-weight: 400; }
form.inline { display: inline; }

.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--soft); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.draft { background: var(--info-bg); color: #2b4c8c; }
.badge.deactivated, .badge.hidden { background: var(--warn-bg); color: var(--warn); }
.badge.trashed, .badge.error { background: var(--danger-bg); color: var(--danger); }
.badge.plain::before { display: none; }

.flash { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--info-bg); }
.flash.error, .warning { background: var(--danger-bg); color: #6e1a14; }
.warning { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.warning ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.error { color: var(--danger); font-size: .88rem; margin: .35rem 0 0; }
.notice { background: var(--info-bg); padding: .75rem 1rem; border-radius: 8px; }

/* ---------- Formulare ---------- */
label { display: block; font-weight: 550; margin: 0 0 .3rem; }
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
input[type=email], input[type=password], input[type=text], input[type=date], input[type=number], select, textarea {
    width: 100%; min-height: 42px; padding: .55rem .7rem; font: inherit; color: inherit; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--danger); }
input[type=file] { display: block; width: 100%; padding: .4rem 0; }
label.checkbox { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; }
label.checkbox input { margin-top: .25rem; }
.input-prefix { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: #fff; }
.input-prefix span { padding: .55rem .6rem; background: var(--soft); color: var(--muted); font-size: .88rem; display: flex; align-items: center; white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.input-prefix input { border: 0; border-radius: 0; min-width: 0; }
.choices { display: grid; gap: .5rem; }
.choice { display: flex; gap: .65rem; align-items: flex-start; padding: .7rem .8rem; border: 1px solid var(--line-strong); border-radius: 8px; font-weight: 400; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--soft); }
.choice strong { display: block; font-weight: 600; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.settings-grid { display: grid; gap: 1rem; }
@media (min-width: 1000px) { .settings-grid { grid-template-columns: 1fr 1fr; align-items: start; } .settings-grid .wide { grid-column: 1 / -1; } }

/* ---------- Tabs, Filter ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 0 0 1.25rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 550; }
.tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--fg); }
.tabs a .count { color: var(--faint); margin-left: .35rem; font-weight: 400; }
.pills { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.pills a { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line-strong); text-decoration: none; font-size: .9rem; background: var(--card); }
.sort-pills { align-items: center; }
.sort-pills .meta { margin: 0; }
.pills a[aria-current] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.pills a .count { color: var(--faint); margin-left: .25rem; }
.pills a[aria-current] .count { color: #c9c9cc; }

/* ---------- Galerieliste ---------- */
/* Breite, Seitenabstand und Spalten wie .overview und .overview-grid auf der Kundenstartseite (gallery.css): Bei gleicher
   Fensterbreite steht jede Galerie an derselben Stelle. Beide nur zusammen ändern (Test in admin.spec.ts). */
.content:has(.gallery-overview) { max-width: 1400px; padding-left: clamp(1rem, 3vw, 2.5rem); padding-right: clamp(1rem, 3vw, 2.5rem); }
.gallery-section { margin-bottom: 2.5rem; }
.gallery-section > h2 { margin-bottom: .35rem; font-size: 1.15rem; }
.gallery-cards { display: grid; gap: 1.25rem clamp(1rem, 2vw, 1.75rem); grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); margin-top: .75rem; }
.gallery-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease; }
.gallery-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.gallery-card .cover { aspect-ratio: 3 / 2; background: var(--soft); display: flex; align-items: center; justify-content: center; color: var(--faint); overflow: hidden; }
.gallery-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-card .body { padding: .75rem .9rem .9rem; }
.gallery-card h3 { font-size: 1rem; margin: 0 0 .35rem; overflow-wrap: anywhere; }
.gallery-card .meta { margin: .35rem 0 0; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); background: var(--card); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ---------- Galerie-Kopf ---------- */
.gallery-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.gallery-head h1 { overflow-wrap: anywhere; }
.gallery-head .meta { margin: .4rem 0 0; display: flex; flex-wrap: wrap; gap: .35rem .75rem; align-items: center; }
.public-link { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- Fotos ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem .7rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; position: sticky; top: var(--topbar); z-index: 10; }
.toolbar select { width: auto; min-height: 36px; padding: .3rem .6rem; }
.toolbar .selection-count { font-size: .88rem; color: var(--muted); margin-right: auto; }
.photo-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (min-width: 700px) { .photo-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); } }
.photo-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem; display: flex; flex-direction: column; gap: .35rem; }
.photo-card.is-hidden .thumb img { opacity: .45; }
.photo-card.dragging { opacity: .4; }
.photo-card.drop-before { box-shadow: -4px 0 0 0 var(--focus); }
.photo-card.drop-after { box-shadow: 4px 0 0 0 var(--focus); }
.photo-card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.photo-card .thumb { aspect-ratio: 1 / 1; background: var(--soft); border-radius: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); font-size: .85rem; text-align: center; }
.photo-card .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-card .select { position: absolute; top: .7rem; left: .7rem; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.photo-card .flags { position: absolute; top: .65rem; right: .65rem; display: flex; gap: .25rem; }
.photo-card .filename { font-size: .82rem; font-weight: 550; overflow-wrap: anywhere; margin: 0; }
.photo-card .meta { font-size: .76rem; margin: 0; }
.photo-card .actions { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; margin-top: auto; }
.photo-card .actions a { font-size: .8rem; color: var(--muted); }
.move { display: none; }
.js .move { display: inline-flex; }
.js .photo-card[draggable="true"] { cursor: grab; }

.albums-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.album-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .4rem; }
.album-list li { display: flex; gap: .5rem; align-items: center; padding: .5rem .6rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.album-list li .grow { min-width: 0; }
.album-list input[type=text] { min-height: 36px; }

details.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1rem; }
details.panel > summary { cursor: pointer; padding: .8rem 1rem; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.panel > summary::after { content: "+"; color: var(--muted); }
details.panel[open] > summary::after { content: "–"; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > .panel-body { padding: 0 1rem 1rem; }

/* ---------- Cover / Fokuspunkt ---------- */
.focus-picker { position: relative; display: inline-block; max-width: 100%; border-radius: 8px; overflow: hidden; cursor: crosshair; line-height: 0; }
.focus-picker img { display: block; max-height: 360px; width: auto; max-width: 100%; }
.focus-marker { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0,0,0,.45); pointer-events: none; }
.cover-editor { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 1000px) { .cover-editor { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.hero-preview { aspect-ratio: 21 / 9; border-radius: 8px; overflow: hidden; background: var(--soft); }
.hero-preview.mobile { aspect-ratio: 3 / 4; max-width: 180px; }
.cover-previews { display: flex; gap: .75rem; align-items: flex-start; }
.cover-previews > div { flex: 1; }
.hero-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Tabellen, Sonstiges ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; }
.qr { background: #fff; display: inline-block; padding: .5rem; margin: 1rem 0; border-radius: 8px; }
.secret, .codes code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; }
.codes { columns: 2; padding-left: 1.5rem; }
.live { min-height: 1.2em; font-size: .88rem; color: var(--muted); }

/* Anmeldeseiten (ohne Navigation) */
.auth-body { background: var(--bg); }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.75rem 1.5rem; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 1rem; }
.auth-card button[type=submit] { width: 100%; margin-top: 1.25rem; }
.auth-card input { margin-bottom: .25rem; }
.auth-card label { margin-top: 1rem; }
.auth-card label.checkbox { margin-top: 1rem; }
.auth-card .codes { margin: 1rem 0; }
.auth-card .button, .auth-card button { margin-top: 1rem; }
section + section { margin-top: 1.5rem; }
.content > form.card { max-width: 640px; }
.focus-inputs { margin-top: .75rem; }
.focus-inputs label { margin: 0; font-weight: 400; color: var(--muted); }
.focus-inputs input { width: 90px; }
.is-picked { outline: 3px dashed var(--focus); outline-offset: 2px; }
.photo-card.is-picked { opacity: .85; }
textarea { resize: vertical; line-height: 1.5; }
.label { display: block; font-weight: 550; margin: 0 0 .3rem; }
.mail-preview { width: 100%; height: 560px; border: 1px solid var(--line); border-radius: 8px; background: #fbfaf8; }

/* Papierkorb */
.trash-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; background: var(--danger-bg); color: var(--danger); padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.trash-banner form { margin: 0; }
/* M6: importierte, gesperrte Galerie; Übersicht der Migration */
.trash-banner.migration-banner { background: var(--warn-bg); color: var(--warn); }
.badge.passed { background: var(--ok-bg); color: var(--ok); }
.badge.blocked { background: var(--warn-bg); color: var(--warn); }
.migration-filter { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.migration-filter input[type="search"] { flex: 1 1 16rem; }
.migration-counts { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: 0; }
.migration-counts div { display: flex; gap: .4rem; }
.migration-counts dt { color: var(--muted); }
.migration-counts dd { margin: 0; font-weight: 600; }
.trash-table td { vertical-align: top; }
.trash-table td.actions { text-align: right; white-space: nowrap; }
.trash-table td.actions .row { justify-content: flex-end; }
.danger-zone { max-width: 640px; border-color: var(--danger); }
.danger-zone ul { padding-left: 1.2rem; }

/* ---------- Besucher ---------- */
.visitor-table td { vertical-align: top; }
.visitor-thumbs { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.visitor-thumbs li { font-size: .78rem; color: var(--muted); overflow-wrap: anywhere; }
.visitor-thumbs img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 4px; background: var(--soft); margin-bottom: .25rem; }
.visitor-log { list-style: none; padding: 0; margin: .5rem 0 0; }
.visitor-log li { padding: .35rem 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.visitor-log li:first-child { border-top: 0; }
.visitor-log .meta { margin-right: .5rem; }

/* ---------- Business-Projekt: Untergalerien (Ordnerbaum, Vorbild PicDrop) ---------- */
/* Ablageziel beim Ziehen von Fotos auf ein Album */
.is-dragging-photos [data-drop-album] { outline: 1px dashed var(--line-strong); outline-offset: -1px; }
[data-drop-album].drop-target { background: var(--accent) !important; color: var(--accent-fg) !important; outline: none; }
[data-drop-album].drop-target .count { color: inherit; }

/* ---------- Bildauswahl im Admin (M3 Schritt 5) ---------- */
.badge.new { background: #fff3a8; color: #5c4b00; }
.badge.new::before { display: none; }

/* ---------- Lightroom-Zugänge (M3 Schritt 7) ---------- */
.token-once { border-color: #e0b400; background: #fffbe6; }
.token-value { font-size: 1rem; padding: .6rem .8rem; background: #fff; border: 1px dashed var(--line-strong); border-radius: 6px; overflow-wrap: anywhere; user-select: all; }
