:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --ink: #222018;
    --muted: #657175;
    --line: #d9e0e3;
    --accent: #1f6f68;
    --accent-strong: #15524d;
    --ok: #16803c;
    --warning: #a26212;
    --bar: #17201f;
    --bar-muted: #b8c4c2;
    --shadow: 0 16px 38px rgba(23, 32, 31, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px 24px;
    padding: 12px 24px;
    background: var(--bar);
    color: #fff;
    box-shadow: 0 6px 20px rgba(23, 32, 31, 0.2);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    font-weight: 800;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    margin-top: 3px;
    color: var(--bar-muted);
    font-size: 13px;
}

.menu {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--bar-muted);
    text-decoration: none;
    font-weight: 700;
}

.menu-item.active,
.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.menu-icon {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    border: 2px solid currentColor;
    border-radius: 5px;
    font-size: 0;
}

.content {
    min-width: 0;
    padding: 32px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent-strong);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.12;
}

.stats {
    min-width: 116px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    text-align: right;
}

.stats strong,
.stats span {
    display: block;
}

.stats strong {
    font-size: 24px;
}

.stats span {
    color: var(--muted);
    font-size: 13px;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.notice strong {
    font-size: 14px;
}

.notice span {
    color: var(--muted);
    font-size: 13px;
}

.notice.success {
    border-color: rgba(22, 128, 60, 0.25);
}

.notice.success strong {
    color: var(--ok);
}

.notice.warning {
    border-color: rgba(162, 98, 18, 0.3);
}

.notice.warning strong {
    color: var(--warning);
}

.image-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.image-link {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    background: #e6ecee;
}

.image-link img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-meta {
    display: grid;
    gap: 4px;
    padding: 10px 12px 12px;
}

.image-meta strong {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.image-meta span {
    color: var(--muted);
    font-size: 12px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 28px;
}

.pagination a,
.pagination span {
    min-height: 40px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    text-decoration: none;
    font-weight: 700;
}

.pagination span {
    color: var(--muted);
    font-weight: 600;
}

.pagination a:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.pagination a.disabled {
    pointer-events: none;
    opacity: 0.45;
}

.empty-state {
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.empty-state h2 {
    margin: 0 0 8px;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

code {
    padding: 2px 5px;
    border-radius: 5px;
    background: #e8eef0;
}

/* Import-Button und Fortschritt in der Kopfzeile */
.import-trigger {
    border: 0;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.import-trigger:disabled {
    cursor: default;
    opacity: 0.55;
}

.import-trigger .menu-label {
    flex: 1;
}

.menu-icon.import {
    position: relative;
    border: 0;
}

.menu-icon.import::before {
    position: absolute;
    top: 2px;
    left: 50%;
    width: 2px;
    height: 12px;
    background: currentColor;
    content: "";
    transform: translateX(-50%);
}

.menu-icon.import::after {
    position: absolute;
    top: 6px;
    left: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    content: "";
    transform: translateX(-50%) rotate(45deg);
}

.import-count {
    min-width: 36px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.import-panel {
    padding: 12px 24px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.import-bar {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e3e9eb;
}

.import-bar-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.2s ease;
}

.import-status {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

/* --- Benutzer und Anmeldung in der Kopfzeile --- */

.topbar-user {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-left: auto;
}

.topbar-title {
    margin: 0;
    color: var(--bar-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 7px 11px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 14px;
}

.role-badge {
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.auth-form {
    display: grid;
    gap: 10px;
}

.auth-form label {
    display: grid;
    gap: 5px;
    color: var(--bar-muted);
    font-size: 12px;
    font-weight: 700;
}

/* Anmeldung und Ersteinrichtung sitzen kompakt in der Kopfzeile. */
.topbar-auth {
    align-items: flex-end;
}

.topbar-auth .topbar-title {
    align-self: center;
}

.topbar-auth .auth-form {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar-auth .auth-form label {
    gap: 3px;
    font-size: 11px;
}

.topbar-auth .auth-form input {
    width: 170px;
}

.auth-form input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 400;
}

.auth-form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.form-error {
    color: #f0a1a1;
    font-size: 12px;
}

/* --- Formulare und Tabellen im Inhaltsbereich --- */

.panel {
    margin-bottom: 28px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.panel-title {
    margin: 0 0 18px;
    font-size: 18px;
}

.form-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.field {
    display: grid;
    flex: 1 1 180px;
    gap: 6px;
    min-width: 160px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.field input,
.field select {
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg);
    color: var(--ink);
    font: inherit;
    font-size: 15px;
    font-weight: 400;
}

.field input:focus,
.field select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.form-hint {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.btn {
    padding: 10px 18px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.btn:hover {
    background: var(--accent-strong);
}

.btn-small {
    padding: 7px 13px;
    font-size: 13px;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0;
}

.inline-form select {
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.table-wrapper table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table-wrapper th,
.table-wrapper td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.table-wrapper th {
    background: var(--bg);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    white-space: nowrap;
    text-transform: uppercase;
}

.table-wrapper tbody tr:last-child td {
    border-bottom: 0;
}

.tag {
    margin-left: 6px;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

/* --- Vollbildansicht --- */

.viewer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: start;
}

.viewer-stage {
    display: grid;
    min-height: 320px;
    margin: 0;
    padding: 16px;
    place-items: center;
    border-radius: 12px;
    background: #101716;
    box-shadow: var(--shadow);
}

.viewer-stage img {
    max-width: 100%;
    max-height: 74vh;
    border-radius: 6px;
    object-fit: contain;
}

.viewer-title {
    margin: 0;
    font-size: 22px;
    word-break: break-word;
}

.viewer-side {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.viewer-side .panel-title:not(:first-child) {
    margin-top: 24px;
}

.facts {
    display: grid;
    gap: 12px;
    margin: 0;
}

.facts div {
    display: grid;
    gap: 2px;
}

.facts dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.facts dd {
    margin: 0;
    font-size: 14px;
    word-break: break-word;
}

.viewer-nav {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
}

.viewer-nav-link {
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.viewer-nav-link:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.viewer-nav-link.disabled {
    opacity: 0.45;
}

/* --- Tags --- */

.face-canvas { position: relative; max-width: 100%; line-height: 0; }
.face-canvas > img { display: block; width: auto; height: auto; }
.face-box { position: absolute; border: 2px solid #ffd166; line-height: 1; }
.face-box.assigned { border-color: #46d58b; }
.face-box span { display: inline-block; padding: 3px; background: #101716; color: white; font-size: 12px; }
.face-box:focus-visible { outline: 3px solid white; outline-offset: 3px; }
.recognition { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.recognition-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px; }
.recognition-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.recognition-controls input:not([type="hidden"]):not([type="checkbox"]), .recognition-controls select {
    min-width: 0; max-width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--panel); color: var(--ink); font: inherit;
}
.recognition-controls input[type="checkbox"] { width: 18px; height: 18px; vertical-align: middle; accent-color: var(--accent); }
.recognition .btn { max-width: 100%; white-space: normal; }
.recognition .btn:disabled { opacity: .5; cursor: not-allowed; }
.recognition .secondary { background: #e5e7eb; color: #252a30; }
.recognition-faces { margin: 24px 0; }
.recognition-faces summary { cursor: pointer; font-weight: 700; }
.face-assignment { padding: 10px 0; border-bottom: 1px solid var(--line); }
.face-assignment:target { outline: 2px solid var(--accent); outline-offset: 5px; }
.recognition-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 16px; }
.recognition-candidate { min-width: 0; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--panel); }
.recognition-candidate label { display: block; cursor: pointer; }
.recognition-candidate img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #edf0f2; }
.candidate-choice { display: block; padding: 10px; font-size: 13px; overflow-wrap: anywhere; }
.candidate-time { margin: 0; padding: 0 10px 8px; color: var(--muted); font-size: 12px; }
.candidate-meta { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 0 10px 12px; font-size: 12px; }

/* Tooltip mit den zugewiesenen Tags: erscheint beim Ueberfahren der Kachel. */
.candidate-image { position: relative; display: block; }

/* Personensuche: markiert das gefundene Gesicht in der Vorschlagskachel. */
.candidate-face {
    position: absolute;
    z-index: 1;
    border: 2px solid #ffd166;
    box-shadow: 0 0 0 1px rgba(16, 23, 22, 0.5);
    pointer-events: none;
}

.candidate-tags {
    position: absolute;
    z-index: 2;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 100%;
    padding: 7px 9px;
    overflow: hidden;
    background: rgba(23, 32, 31, 0.88);
    opacity: 0;
    transition: opacity 0.12s ease;
    pointer-events: none;
}

.recognition-candidate:hover .candidate-tags,
.recognition-candidate:focus-within .candidate-tags {
    opacity: 1;
}

.candidate-tag {
    max-width: 100%;
    overflow: hidden;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.candidate-tags-empty {
    color: #cfd8d6;
    font-size: 11px;
    font-style: italic;
}
.recognition .notice { overflow-wrap: anywhere; }
.recognition h3 { overflow-wrap: anywhere; }

.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 4px 4px 11px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}

.tag-chip-name {
    max-width: 170px;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-chip-form {
    display: inline-flex;
    margin: 0;
}

.tag-chip-remove {
    display: grid;
    width: 20px;
    height: 20px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    font: inherit;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.tag-chip-remove:hover {
    background: #b93030;
}

.tag-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin: 0 0 4px;
}

.tag-form .btn {
    flex: 0 0 auto;
}

/* Tag-Galerie: Auswahl der Tags */

/* Tag-Auswahl links, Bilder rechts daneben. */
.tag-galerie {
    display: grid;
    grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

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

.tag-picker-titel {
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    font-weight: 700;
}

.tag-picker-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 14px 16px;
    list-style: none;
}

.tag-picker-hint {
    padding: 0 16px 14px;
}

.tag-picker-link {
    /* Alle Knopfe sind gleich breit; die Ebene rueckt den Namen im Knopf ein. */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
    width: 100%;
    padding: 5px 11px;
    padding-left: calc(11px + var(--tiefe, 0) * 16px);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: inherit;
    font-size: 13px;
    text-decoration: none;
}

.tag-picker-link:hover {
    border-color: var(--accent);
}

.tag-picker-link.is-active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.tag-picker-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-picker-count {
    flex: none;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(23, 32, 31, 0.08);
    font-size: 11px;
    font-weight: 700;
}

.tag-picker-link.is-active .tag-picker-count {
    background: rgba(255, 255, 255, 0.25);
}

/* Modul "Tags bearbeiten" */
.tag-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
    margin: 0 0 20px;
}

.tag-table-wrap {
    overflow-x: auto;
}

.tag-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.tag-table th,
.tag-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.tag-table thead th {
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tag-table tbody tr:hover {
    background: rgba(31, 111, 104, 0.05);
}

/* Baumordnung: Unterbegriffe ruecken unter ihrem Oberbegriff ein. Der Selektor
   muss `.tag-table th` (Klassen- plus Typselektor) schlagen, sonst gewinnt dort
   das kuerzere `padding: 8px 10px`. */
.tag-table th.tag-tree {
    padding-left: calc(10px + var(--tiefe, 0) * 32px);
    white-space: nowrap;
}

.tag-branch {
    margin-right: 9px;
    color: var(--muted);
    font-size: 15px;
}

.tag-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
}

/* Anzahl hinter dem Namen, verlinkt in die Tag-Galerie. */
.tag-count {
    margin-left: 7px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    text-decoration: none;
}

.tag-count:hover,
.tag-count:focus-visible {
    color: var(--accent);
    text-decoration: underline;
}

.tag-detail .panel-title {
    margin-top: 26px;
}

.tag-create {
    margin: 0 0 22px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.tag-create .panel-title {
    margin-top: 0;
}

.tag-create .form-hint {
    margin-bottom: 0;
}

.btn.danger {
    background: #b93030;
    color: #fff;
}

.combo {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.combo-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.combo-input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--bg);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
}

.combo-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.combo-list {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    max-height: 230px;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    list-style: none;
}

.combo-option {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.combo-option.aktiv,
.combo-option:hover {
    background: var(--accent);
    color: #fff;
}

.combo-empty {
    padding: 8px 10px;
    color: var(--muted);
    font-size: 13px;
}

/* --- Auswahl und Massenbearbeitung --- */

.btn-quiet {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
}

.btn-quiet:hover {
    border-color: var(--accent);
    background: var(--panel);
    color: var(--accent-strong);
}

.selection-bar {
    position: sticky;
    z-index: 30;
    top: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.selection-count {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 0 auto 0 0;
    color: var(--muted);
    font-size: 13px;
}

.selection-count strong {
    color: var(--accent-strong);
    font-size: 20px;
}

.selection-note {
    display: block;
    color: var(--accent-strong);
    font-size: 12px;
}

.selection-actions {
    display: flex;
    gap: 8px;
}

.selection-all {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.subsection-title {
    margin: 26px 0 12px;
    font-size: 15px;
}

.image-card.pick {
    position: relative;
    /* Haelt Abstand zur klebenden Auswahlleiste, wenn hierher gescrollt wird. */
    scroll-margin-top: 96px;
}

/* Anklickbare Flaeche der Kachel; der Link ins Vollbild liegt daneben. */
.pick-surface {
    display: block;
    cursor: pointer;
}

.image-card.pick .pick-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.image-card.pick img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #e6ecee;
    object-fit: cover;
}

.pick-box {
    position: absolute;
    z-index: 2;
    top: 10px;
    left: 10px;
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    background: rgba(23, 32, 31, 0.5);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
}

/* Ausgewaehlt: die Klasse setzt das Skript, :has() wirkt auch ohne JavaScript. */
.image-card.pick.is-selected .pick-box {
    background: var(--accent);
}

.image-card.pick.is-selected .pick-box::after {
    content: "\2713";
}

.image-card.pick:has(.pick-input:checked) .pick-box {
    background: var(--accent);
}

.image-card.pick:has(.pick-input:checked) .pick-box::after {
    content: "\2713";
}

.image-card.pick:has(.pick-input:focus-visible) .pick-box {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.image-card.pick.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 104, 0.35);
}

.image-card.pick:has(.pick-input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(31, 111, 104, 0.35);
}

/* Kleiner Link in die Vollbildansicht. */
.pick-open {
    position: absolute;
    z-index: 3;
    top: 10px;
    right: 10px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    background: rgba(23, 32, 31, 0.55);
    color: #fff;
    text-decoration: none;
}

/* Pfeil nach Nordost: Bild gross oeffnen. */
.pick-open::after {
    content: "\2197";
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.pick-open:hover,
.pick-open:focus-visible {
    background: var(--accent);
    outline: none;
}

.pick-tags {
    display: block;
    overflow: hidden;
    color: var(--accent-strong);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pagination button:disabled {
    opacity: 0.45;
    cursor: default;
}

@media (max-width: 760px) {
    .topbar {
        position: static;
        padding: 14px 16px;
    }

    .topbar-user {
        margin-left: 0;
    }

    .import-panel {
        padding: 12px 16px 14px;
    }

    .content {
        padding: 20px 16px 28px;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .stats {
        text-align: left;
    }

    .tag-galerie {
        grid-template-columns: minmax(0, 1fr);
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .notice {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-auth {
        width: 100%;
    }

    .topbar-auth .auth-form {
        width: 100%;
    }

    .topbar-auth .auth-form label {
        flex: 1 1 140px;
    }

    .topbar-auth .auth-form input {
        width: 100%;
    }

    .panel {
        padding: 18px;
    }

    .form-grid {
        align-items: stretch;
        flex-direction: column;
    }

    .form-grid .btn {
        width: 100%;
    }

    .viewer {
        grid-template-columns: minmax(0, 1fr);
    }

    .viewer-stage img {
        max-height: 50vh;
    }

    .viewer-nav {
        flex-wrap: wrap;
    }

    .viewer-nav-link {
        flex: 1 1 100%;
        text-align: center;
    }

    .tag-form {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .tag-form .btn {
        width: 100%;
    }

    .selection-bar {
        position: static;
        align-items: stretch;
    }

    .selection-count {
        margin-right: 0;
    }

    .selection-actions {
        flex: 1 1 100%;
        flex-wrap: wrap;
    }

    .selection-actions .btn {
        flex: 1 1 45%;
    }
}
