:root {
    --bg: #0b0c0f;
    --panel: #111318;
    --panel-2: #171a20;
    --text: #f7f7f4;
    --muted: #979ca8;
    --line: rgba(255,255,255,.09);
    --accent: #d8ff61;
    --accent-ink: #11140a;
    --danger: #ff6b73;
    --radius: 22px;
    --shadow: 0 24px 80px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 10% -10%, rgba(151,92,255,.14), transparent 28rem),
        radial-gradient(circle at 90% 5%, rgba(216,255,97,.08), transparent 24rem),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

/* Volle verfügbare Breite statt festem 1660px-Deckel. */
.app-shell { width: calc(100% - 32px); min-height: 100vh; margin: 0 auto; padding: 30px 0 24px; display: flex; flex-direction: column; }
main { flex: 1 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-mark { width: 46px; height: 46px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; transform: rotate(6deg); }
.brand-mark span { border-radius: 8px; background: var(--accent); }
.brand-mark span:nth-child(2), .brand-mark span:nth-child(3) { opacity: .34; }
h1 { font-size: clamp(24px, 2.4vw, 36px); margin: 0; letter-spacing: -.045em; line-height: 1; }
.brand p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.btn { border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 750; transition: .18s ease; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px rgba(216,255,97,.10); }
.btn-ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
.plus { font-size: 20px; line-height: 0; margin-right: 5px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.searchbox { flex: 1; min-width: 220px; max-width: min(620px, 42vw); display: flex; align-items: center; gap: 10px; background: rgba(17,19,24,.88); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; }
.searchbox span { color: var(--muted); font-size: 22px; transform: translateY(-1px); }
.searchbox input { width: 100%; background: transparent; color: var(--text); border: 0; outline: 0; padding: 12px 0; }
.toolbar-actions { display: flex; gap: 10px; }
select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 11px 36px 11px 12px; outline: 0; }

/* Echtes row-first Grid: keine Multi-Column-Balancierung mehr. */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    align-items: start;
}
.gallery.few-items {
    grid-template-columns: repeat(auto-fit, minmax(240px, 390px));
    justify-content: start;
}
.card {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 15px;
    background: var(--panel);
    border: 1px solid rgba(255,255,255,.065);
    box-shadow: 0 3px 12px rgba(0,0,0,.16);
    cursor: zoom-in;
}
.card img { display: block; width: 100%; height: 100%; object-fit: cover; background: #15171c; transition: transform .35s cubic-bezier(.2,.75,.2,1), filter .25s ease; }
.card:hover img { transform: scale(1.025); filter: brightness(.84); }
.card-overlay { position: absolute; inset: auto 0 0; padding: 48px 12px 12px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; background: linear-gradient(transparent, rgba(0,0,0,.74)); opacity: 0; transform: translateY(6px); transition: .2s ease; }
.card:hover .card-overlay, .card:focus-within .card-overlay { opacity: 1; transform: none; }
.card-prompt { margin: 0; color: white; font-size: 12px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-shadow: 0 1px 10px #000; }
.card-meta { flex: 0 0 auto; font-size: 10px; color: rgba(255,255,255,.8); background: rgba(0,0,0,.44); border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 5px 7px; backdrop-filter: blur(8px); }
.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 30px; }
.page-btn { min-width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); background: var(--panel); }
.page-btn.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 800; }
.page-btn:disabled { opacity: .35; cursor: default; }
.empty-state { max-width: 620px; margin: 13vh auto; text-align: center; color: var(--muted); }
.empty-state h2 { color: var(--text); margin: 14px 0 7px; font-size: 26px; }
.empty-state p { line-height: 1.6; margin: 0 auto 22px; }
.empty-orb { width: 76px; height: 76px; margin: 0 auto; display: grid; place-items: center; border-radius: 24px; background: linear-gradient(135deg, rgba(216,255,97,.17), rgba(151,92,255,.16)); color: var(--accent); font-size: 34px; border: 1px solid var(--line); }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.72); backdrop-filter: blur(16px); }
.modal { position: relative; width: min(650px, 100%); border: 1px solid var(--line); border-radius: 24px; background: #121419; box-shadow: var(--shadow); padding: 28px; }
.modal-kicker { color: var(--accent); letter-spacing: .17em; font-size: 10px; font-weight: 900; }
.modal h2 { font-size: 29px; letter-spacing: -.035em; margin: 5px 0 7px; }
.modal-copy { margin: 0 42px 24px 0; color: var(--muted); line-height: 1.5; font-size: 14px; }
.icon-btn { position: absolute; top: 18px; right: 18px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); font-size: 22px; }
.field { display: block; margin: 18px 0; }
.field > span { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 800; }
.field em { color: var(--muted); font-style: normal; font-weight: 500; margin-left: 5px; }
.field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 13px; background: #0d0f13; color: var(--text); padding: 13px 14px; outline: 0; transition: border .15s ease, box-shadow .15s ease; }
.field textarea { resize: vertical; min-height: 130px; line-height: 1.45; }
.field input:focus, .field textarea:focus { border-color: rgba(216,255,97,.6); box-shadow: 0 0 0 3px rgba(216,255,97,.07); }
.field small { display: block; margin-top: 7px; color: #777d89; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.form-error { border: 1px solid rgba(255,107,115,.28); background: rgba(255,107,115,.08); color: #ff9ba1; border-radius: 12px; padding: 11px 12px; font-size: 13px; }
.import-success { padding-top: 4px; }
.success-head { display: flex; align-items: flex-start; gap: 14px; margin: 10px 0 22px; padding-right: 34px; }
.success-icon { flex: 0 0 auto; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 15px; background: rgba(216,255,97,.12); border: 1px solid rgba(216,255,97,.24); color: var(--accent); font-size: 22px; font-weight: 900; }
.success-head h3 { margin: 3px 0 4px; font-size: 24px; letter-spacing: -.03em; }
.success-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.import-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.import-stat { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 15px; background: #0d0f13; }
.import-stat span { display: block; margin-bottom: 7px; color: #7f8490; font-size: 9px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.import-stat strong { display: block; overflow: hidden; color: var(--text); font-size: 16px; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.import-stat small { display: block; margin-top: 3px; color: var(--accent); font-size: 10px; }
.success-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.lightbox { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-columns: minmax(0, 1fr) 340px; background: rgba(5,6,8,.96); }
.lightbox-stage { min-width: 0; display: grid; place-items: center; padding: 28px; overflow: hidden; }
.lightbox-stage img { max-width: 100%; max-height: calc(100vh - 56px); object-fit: contain; border-radius: 8px; box-shadow: 0 20px 80px rgba(0,0,0,.34); }
.lightbox-info { border-left: 1px solid var(--line); background: #0e1014; padding: 70px 22px 24px; display: flex; flex-direction: column; overflow-y: auto; }
.lightbox-close { position: fixed; z-index: 61; top: 16px; right: 16px; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: #171a20; color: white; font-size: 24px; }
.lightbox-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 24px; }
.lightbox-keyhint { margin: -13px 0 22px; color: #676d78; font-size: 10px; letter-spacing: .01em; }
.lightbox-stage img.is-switching { opacity: .62; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 6px 8px; font-size: 11px; color: #ccd0d7; }
.muted { color: var(--muted); font-size: 11px; }
.prompt-block { padding: 0 0 24px; border-bottom: 1px solid var(--line); }
.prompt-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.prompt-heading span, .source-block > span { color: #7f8490; letter-spacing: .13em; font-size: 9px; font-weight: 900; }
.prompt-block p { margin: 0; white-space: pre-wrap; line-height: 1.55; color: #e1e3e7; font-size: 13px; }
.text-btn { border: 0; background: transparent; color: var(--accent); padding: 3px 0; font-size: 11px; }
.source-block { padding: 21px 0; display: grid; gap: 7px; }
.source-block a { color: #c9ced8; font-size: 12px; word-break: break-word; text-decoration-color: #4e5562; }
.danger-btn { margin-top: auto; border: 1px solid rgba(255,107,115,.24); border-radius: 13px; padding: 11px 12px; background: rgba(255,107,115,.07); color: #ff8d94; }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 8px; }
.toast { max-width: 360px; border-radius: 13px; border: 1px solid var(--line); background: #181b21; color: white; padding: 11px 14px; box-shadow: var(--shadow); font-size: 13px; animation: toastIn .18s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.skeleton { aspect-ratio: 1 / 1; border-radius: 15px; background: linear-gradient(100deg, #13161b 20%, #1b1f26 36%, #13161b 52%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position-x: -200%; } }

/* Diagnose */
.diag-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 38px 0 70px; }
.diag-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.diag-header h1 { margin: 7px 0 8px; font-size: clamp(30px, 4vw, 46px); }
.diag-header p { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.55; }
.diag-back { flex: 0 0 auto; }
.diag-message { margin: 0 0 18px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); }
.diag-message.ok { border-color: rgba(216,255,97,.22); }
.diag-message.warn { border-color: rgba(255,203,107,.28); }
.diag-message.error { border-color: rgba(255,107,115,.34); color: #ffb0b5; }
.diag-message ul { margin: 8px 0 0 18px; color: var(--muted); font-size: 12px; }
.diag-section { margin-top: 18px; padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: rgba(17,19,24,.82); }
.diag-section.compact { padding-bottom: 14px; }
.diag-section-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.diag-section h2 { margin: 0 0 5px; font-size: 21px; letter-spacing: -.025em; }
.diag-section-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 9px; }
.check-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: #0d0f13; }
.check-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px rgba(216,255,97,.07); }
.check-card.fail .check-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(255,107,115,.07); }
.check-card strong { display: block; font-size: 13px; }
.check-card small { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.check-card b { font-size: 10px; color: var(--accent); }
.check-card.fail b { color: var(--danger); }
.diag-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; margin-bottom: 16px; }
.diag-stats > div, .config-list > div { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #0d0f13; }
.diag-stats span, .config-list span { display: block; margin-bottom: 7px; color: #7f8490; font-size: 9px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.diag-stats strong { font-size: 18px; }
.maintenance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.maintenance-card { display: flex; min-height: 225px; flex-direction: column; justify-content: space-between; gap: 20px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: #0d0f13; }
.maintenance-card h3 { margin: 6px 0 7px; font-size: 17px; }
.maintenance-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.maintenance-card form { display: flex; }
.maintenance-card form button { width: 100%; }
.maintenance-label { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.maintenance-card.danger-zone .maintenance-label { color: var(--danger); }
.config-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.config-list strong { font-size: 13px; }
code { color: var(--accent); }


/* Dezenter, optionaler Projekt-Footer. */
.mini-footer {
    margin-top: 38px;
    padding: 16px 0 2px;
    border-top: 1px solid rgba(255,255,255,.045);
    color: rgba(151,157,169,.58);
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
    letter-spacing: .015em;
    user-select: none;
}

@media (min-width: 2200px) {
    .app-shell { width: calc(100% - 48px); }
    .gallery { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
}
@media (max-width: 1100px) {
    .gallery { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
    .diag-stats { grid-template-columns: repeat(3, 1fr); }
    .maintenance-grid { grid-template-columns: 1fr; }
    .maintenance-card { min-height: 0; }
    .config-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
    .lightbox { grid-template-columns: 1fr; overflow-y: auto; }
    .lightbox-stage { min-height: 70vh; padding: 16px; }
    .lightbox-stage img { max-height: 70vh; }
    .lightbox-info { border-left: 0; border-top: 1px solid var(--line); padding: 22px; min-height: 260px; }
    .danger-btn { margin-top: 20px; }
}
@media (max-width: 680px) {
    .app-shell { width: calc(100% - 24px); padding-top: 20px; }
    .topbar { align-items: flex-start; }
    .brand p { display: none; }
    .topbar .btn { padding: 10px 12px; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .searchbox { max-width: none; }
    .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .gallery { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
    .gallery.few-items { grid-template-columns: repeat(auto-fit, minmax(140px, 260px)); }
    .card { border-radius: 12px; }
    .card-overlay { opacity: 1; transform: none; padding: 35px 8px 8px; }
    .card-prompt { display: none; }
    .modal { padding: 22px 18px; border-radius: 20px; }
    .modal-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .import-stats { grid-template-columns: 1fr 1fr; }
    .success-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .diag-shell { width: calc(100% - 24px); padding-top: 24px; }
    .diag-header { flex-direction: column; }
    .diag-back { width: 100%; }
    .diag-stats { grid-template-columns: 1fr 1fr; }
    .config-list { grid-template-columns: 1fr; }
    .check-grid { grid-template-columns: 1fr; }
}

/* Ergebnis der Thumbnail-Erzeugung nach einem Import. */
.thumbnail-result {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    align-items: center;
    gap: 11px;
    margin-top: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(216,255,97,.22);
    border-radius: 14px;
    background: rgba(216,255,97,.055);
}
.thumbnail-result-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: rgba(216,255,97,.13);
    color: var(--accent);
    font-size: 17px;
    font-weight: 900;
}
.thumbnail-result strong { display: block; margin-bottom: 3px; font-size: 13px; }
.thumbnail-result span { display: block; color: var(--muted); font-size: 11px; line-height: 1.4; }
.thumbnail-result.is-error { border-color: rgba(255,203,107,.25); background: rgba(255,203,107,.055); }
.thumbnail-result.is-error .thumbnail-result-icon { background: rgba(255,203,107,.12); color: #ffcb6b; }
