/* ═══════════════════════════════════════════════════════════════
   Al-Khalily Book Catalog — Main Stylesheet
   ═══════════════════════════════════════════════════════════════ */

/* ─── Font Faces ──────────────────────────────────────────────── */

/* Latin — Body */
@font-face {
    font-family: 'Rethink Sans';
    src: url('/fonts/Rethink_Sans/RethinkSans-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}
/* Rethink Sans italic intentionally excluded — was causing mobile rendering issues */

/* Latin — Headings */
@font-face {
    font-family: 'DM Serif Display';
    src: url('/fonts/DM_Serif_Display/DMSerifDisplay-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

/* Arabic — Body (Rubik) */
@font-face {
    font-family: 'Rubik';
    src: url('/fonts/Rubik/Rubik-VariableFont_wght.ttf') format('truetype');
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
}
/* Rubik italic intentionally excluded — preventing mobile italic rendering issues */

/* Arabic — Navigation + Titles (Cairo) */
@font-face {
    font-family: 'Cairo';
    src: url('/fonts/Cairo/Cairo-VariableFont_slnt,wght.ttf') format('truetype');
    font-weight: 200 1000;
    font-style: normal;
    font-display: swap;
}

/* Arabic — Fallbacks */
@font-face {
    font-family: 'Amiri';
    src: url('/fonts/Amiri/Amiri-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Amiri';
    src: url('/fonts/Amiri/Amiri-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Noto Naskh Arabic';
    src: url('/fonts/Noto_Naskh_Arabic/NotoNaskhArabic-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* Arabic — Display (book titles) */
@font-face {
    font-family: 'Aref Ruqaa';
    src: url('/fonts/Aref_Ruqaa/ArefRuqaa-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Aref Ruqaa';
    src: url('/fonts/Aref_Ruqaa/ArefRuqaa-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Icons — Material Symbols Outlined */
@font-face {
    font-family: 'Material Symbols Outlined';
    src: url('/fonts/MaterialSymbolsOutlined-Regular.woff2') format('woff2'),
         url('/fonts/MaterialSymbolsOutlined-Regular.ttf') format('truetype');
    font-weight: 100 700;
    font-style: normal;
    font-display: block;
}

.material-icon {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 1.1em;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    vertical-align: -0.15em;
    margin-inline-end: 4px;
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

.material-icon:only-child {
    margin-inline-end: 0;
}

/* ─── Root font-size (makes rem relative to body text) ───────── */

html { font-size: 19px; }
html[lang="ar"] { font-size: 21px; }

/* ─── Custom Properties ───────────────────────────────────────── */

:root {
    /* Colors — warm earth tones */
    --color-bg: #FAF6EF;
    --color-bg-alt: #F5F0E8;
    --color-shade: #E8DFD0;
    --color-shade-dark: #D4C9B5;
    --color-text: #3D3D3D;
    --color-text-muted: #7A7167;
    --color-heading: #444444;
    --color-accent: #C17A2F;
    --color-accent-dark: #A0621A;
    --color-accent-light: #D4943F;
    --color-success: #4A8C5C;
    --color-success-bg: #EDF5F0;
    --color-danger: #B83A2A;
    --color-danger-bg: #FCEEED;
    --color-warning: #C17A2F;
    --color-warning-bg: #FFF6EB;
    --color-info: #4A6B8C;
    --color-info-bg: #EDF2F7;
    --color-reserved: #8B7355;
    --color-white: #FFFFFF;

    /* Typography */
    --font-body: 'Rethink Sans', 'Inter', 'Source Sans 3', system-ui, sans-serif;
    --font-heading: 'Rethink Sans', 'Inter', system-ui, sans-serif;
    --font-arabic: 'Rubik', 'Amiri', 'Noto Naskh Arabic', sans-serif;
    --font-arabic-nav: 'Cairo', 'Rubik', sans-serif;
    --font-arabic-heading: 'Cairo', 'Rubik', sans-serif;

    /* Spacing (px so they don't scale with root font-size) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Borders & Shadows */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* Layout */
    --container-max: 1100px;
    --header-height: 64px;
}

/* ─── Reset & Base ────────────────────────────────────────────── */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--color-text);
    background-color: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    max-width: 100vw;
    overflow-x: clip;
}

/* Arabic language body font */
[lang="ar"] body {
    font-family: var(--font-arabic);
    font-size: 1rem;
    line-height: 1.8;
}

a {
    color: var(--color-accent-dark);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover {
    color: var(--color-accent);
}
a:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

img { max-width: 100%; height: auto; }

/* ─── Typography ──────────────────────────────────────────────── */

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--color-heading);
    line-height: 1.25;
    margin-bottom: var(--space-md);
}

[lang="ar"] h1, [lang="ar"] h2, [lang="ar"] h3, [lang="ar"] h4 {
    font-family: var(--font-arabic-heading);
    font-weight: 800;
    font-style: normal;
    font-variation-settings: 'slnt' 0;
}

h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin-bottom: var(--space-md); }

/* ─── Container ───────────────────────────────────────────────── */

.container {
    max-width: var(--container-max);
    margin-inline: auto;
    padding-inline: var(--space-md);
}

/* ─── Scroll Sentinel (invisible, triggers sticky detection) ── */
.scroll-sentinel {
    position: absolute;
    top: 0;
    height: 1px;
    width: 1px;
    pointer-events: none;
}

/* ─── Site Header ─────────────────────────────────────────────── */

.site-header {
    background: var(--color-white);
    border-bottom: 1px solid var(--color-shade);
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    /* iOS Sticky-Stabilisierung (Finding 7): translateZ zwingt das Element auf
       einen eigenen Compositor-Layer, dadurch verhält sich sticky bei der iOS
       URL-Bar-Animation berechenbarer. will-change als zusätzlicher Hint. */
    transform: translateZ(0);
    will-change: transform;
    /* z-index 110: muss über der admin-nav (101) liegen, damit Tooltips der
       Top-Nav-Items (Katalog/Meine Bücher/Verwaltung) nach unten in den
       admin-nav-Bereich ragen dürfen ohne von der admin-nav überdeckt zu
       werden. Stacking-Context-Hierarchie: Header > Sub-Nav > Content.
       Bleibt unter Toasts (9000) und Modals (9999+). */
    z-index: 110;
    height: var(--header-height);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.site-header.is-stuck {
    background: rgba(221, 212, 197, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid color-mix(in srgb, var(--color-shade) 60%, transparent);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .site-header.is-stuck {
    background: rgba(67, 56, 43, 0.85);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    gap: var(--space-md);
}

.site-logo {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 720;
    color: var(--color-accent-dark);
    white-space: nowrap;
    text-decoration: none;
    transition: opacity 0.2s;
}
.site-logo:hover {
    opacity: 0.75;
}

[lang="ar"] .site-logo {
    font-family: var(--font-arabic-heading);
    font-style: normal;
    font-variation-settings: 'slnt' 0;
}

.nav-greeting {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-accent-dark);
    white-space: nowrap;
}
.nav-greeting--mobile {
    display: none;
}

.nav-tip {
    display: none;
}

/* ─── Navigation ──────────────────────────────────────────────── */

.site-nav {
    display: flex;
    align-items: center;
    gap: 45px;
}

.nav-link {
    font-size: 1.1rem;
    font-weight: 720;
    font-style: normal;
    color: var(--color-text-muted);
    padding: var(--space-xs) 0;
    transition: color 0.15s;
    white-space: nowrap;
}
.nav-link:hover {
    color: var(--color-text);
}
.nav-link.active {
    color: var(--color-accent-dark);
}

.nav-logout {
    font-size: 1.1rem;
    font-weight: 720;
    font-style: normal;
    color: var(--color-text-muted);
    white-space: nowrap;
}
.nav-logout:hover {
    color: var(--color-text);
}

.nav-logout-form {
    display: inline;
    margin: 0;
    padding: 0;
}
button.nav-logout {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding-inline-start: var(--space-md);
    border-inline-start: 1px solid var(--color-shade);
}

.user-name {
    font-size: 1.1rem;
    font-weight: 720;
    color: var(--color-text);
}

/* ─── Mobile Nav Toggle ───────────────────────────────────────── */

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-sm);
    flex-direction: column;
    gap: 5px;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    transition: transform 0.2s, opacity 0.2s;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }
    .site-nav {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        /* 100dvh = dynamic viewport height — auf iOS Safari korrekt wenn URL-Bar
           ein/ausfährt. Fallback auf 100vh für alte Browser. */
        max-height: calc(100vh - var(--header-height));
        max-height: calc(100dvh - var(--header-height));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        z-index: 9999;
        background: rgba(221, 212, 197, 0.85);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-bottom: 1px solid color-mix(in srgb, var(--color-shade) 60%, transparent);
        flex-direction: column;
        align-items: flex-start;
        padding: var(--space-md);
        /* Extra Bottom-Padding für iPhone Home-Indicator + komfortable Lücke
           damit der letzte Menüpunkt (Logout) gut anklickbar bleibt. */
        padding-bottom: max(var(--space-xl), calc(env(safe-area-inset-bottom) + var(--space-md)));
        gap: var(--space-sm);
        box-shadow: var(--shadow-md);
    }
    /* Body-scroll lock via position:fixed (iOS-robust). JS speichert scrollY auf
       open + restored on close — sonst springt iOS bei overflow:hidden zurück. */
    body.nav-open {
        position: fixed;
        width: 100%;
        overflow: hidden;
    }

    [data-theme="dark"] .site-nav {
        background: rgba(67, 56, 43, 0.85);
    }
    .site-nav.is-open {
        display: flex;
    }

    /* Remove header backdrop-filter when nav is open so fixed nav can blur properly */
    .site-header.nav-open.is-stuck {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--color-white);
    }
    [data-theme="dark"] .site-header.nav-open.is-stuck {
        background: var(--color-bg);
    }
    /* Force normal font-style in mobile nav to prevent italic rendering bug */
    .site-nav,
    .site-nav * {
        font-style: normal !important;
        font-variation-settings: 'slnt' 0, 'ital' 0 !important;
    }
    /* Greeting always visible in header bar on mobile */
    .nav-link {
        display: flex;
        flex-direction: column;
        gap: 2px;
        font-style: normal !important;
        -webkit-font-smoothing: antialiased;
    }
    .nav-tip {
        display: block;
        font-size: 0.75rem;
        font-weight: 400;
        color: var(--color-text-muted);
        line-height: 1.3;
    }
    .user-info {
        border-inline-start: none;
        padding-inline-start: 0;
        padding-top: var(--space-sm);
        border-top: 1px solid var(--color-shade);
    }

    /* Admin sub-nav: hide the bar, show links in burger menu */
    .admin-nav {
        display: none;
    }
    .admin-mobile-links {
        display: flex;
        flex-direction: column;
        gap: var(--space-xs);
        padding-inline-start: var(--space-md);
        padding-top: var(--space-xs);
        width: 100%;
    }
    .admin-mobile-links .admin-nav-link {
        font-size: 0.95rem;
        font-weight: 500;
        padding: var(--space-xs) var(--space-sm);
    }
}

/* Hide mobile admin links on desktop */
@media (min-width: 769px) {
    .admin-mobile-links {
        display: none;
    }
}

/* ─── Theme + Language Group (docked together) ───────────────── */

.lang-theme-group {
    display: inline-flex;
    align-items: center;
    background: var(--color-bg-alt);
    border-radius: var(--radius-md);
    padding: 2px;
    gap: 2px;
}

.lang-theme-group .theme-toggle {
    background: transparent;
    border-radius: calc(var(--radius-md) - 2px);
    height: auto;
    width: auto;
    padding: 4px 6px;
}

.lang-theme-group .lang-switcher {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

/* ─── Language Switcher ───────────────────────────────────────── */

.lang-switcher {
    position: relative;
    background: var(--color-bg-alt);
    border-radius: var(--radius-md);
    padding: 2px;
}

.lang-link {
    font-family: 'Rubik', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: calc(var(--radius-md) - 2px);
    color: var(--color-text-muted);
    transition: all 0.15s;
    display: block;
    text-align: center;
    white-space: nowrap;
    line-height: 1.4;
    box-sizing: border-box;
}
.lang-link:hover {
    color: var(--color-text);
    background: var(--color-shade);
}
.lang-link.active {
    background: var(--color-white);
    color: var(--color-accent-dark);
    box-shadow: var(--shadow-sm);
}

/* Desktop: dropdown on hover, opens ONLY downward */
@media (min-width: 769px) {
    .lang-switcher {
        display: inline-flex;
        flex-direction: column;
        z-index: 200;
    }
    .lang-dropdown {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 2px;
        background: var(--color-bg-alt);
        padding: 2px;
        padding-top: 0;
        border-radius: 0 0 var(--radius-md) var(--radius-md);
        box-shadow: var(--shadow-md);
    }
    .lang-switcher:hover {
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }
    .lang-switcher:hover .lang-dropdown {
        display: flex;
    }

    /* Inside the docked group: dropdown pops from the whole group */
    .lang-theme-group .lang-switcher {
        position: relative;
    }
    .lang-theme-group .lang-dropdown {
        min-width: 100%;
    }
}

/* Mobile: horizontal row, all links visible */
@media (max-width: 768px) {
    .lang-switcher {
        display: inline-flex;
        flex-direction: row;
        gap: 2px;
    }
    .lang-dropdown {
        display: contents;
    }
}

/* ─── Admin Sub-Nav ───────────────────────────────────────────── */

.admin-nav {
    background: var(--color-bg-alt);
    border-bottom: 1px solid var(--color-shade);
    padding: var(--space-sm) 0;
    /* overflow: visible — icons fit easily and Tooltip darf nach unten rausragen. */
    overflow: visible;
    position: -webkit-sticky;
    position: sticky;
    top: var(--header-height);
    /* iOS Sticky-Stabilisierung (Finding 7): siehe .site-header. */
    transform: translateZ(0);
    will-change: transform;
    /* z-index 101: über dem Seiteninhalt, damit Sub-Nav-Tooltips aus dem
       eigenen Stacking-Context heraus sichtbar bleiben. UNTER dem Header (110)
       — sonst überdeckt die Sub-Nav die Top-Nav-Tooltips (Katalog/Meine Bücher/
       Verwaltung), die nach unten in den Sub-Nav-Bereich ragen.
       Bleibt unter Toasts (9000) und Modals (9999+). */
    z-index: 101;
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.admin-nav .container {
    flex-wrap: wrap;
}

/* Admin nav also goes translucent when header is stuck */
.has-stuck-header .admin-nav {
    background: rgba(221, 212, 197, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom-color: color-mix(in srgb, var(--color-shade) 60%, transparent);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .has-stuck-header .admin-nav {
    background: rgba(67, 56, 43, 0.8);
}

.admin-nav .container {
    display: flex;
    gap: var(--space-xs);
}

.admin-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--color-text-muted);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-md);
    white-space: nowrap;
    transition: all 0.15s;
}
.admin-nav-link:hover {
    background: var(--color-shade);
    color: var(--color-text);
}
.admin-nav-link.active {
    background: var(--color-accent);
    color: var(--color-white);
}

/* Icon-only desktop sub-nav (Super-Admin — kompakt für viele Items) */
.admin-nav--icons .admin-nav-link {
    padding: var(--space-xs) var(--space-sm);
    min-width: 2.4em;
    justify-content: center;
}
.admin-nav--icons .admin-nav-link .material-icon {
    font-size: 1.35em;
    margin: 0;
    vertical-align: middle;
}
/* Badge auf Errors-Icon — kompakt über die rechte obere Ecke des Icons positioniert */
.admin-nav--icons .admin-nav-link .nav-badge {
    margin-inline-start: 4px;
}
/* Text-Labels in Icon-Mode versteckt (Tooltips übernehmen die Beschriftung) */
.admin-nav--icons .admin-nav-label {
    display: none;
}

/* Text-Mode desktop sub-nav (Admin-Light — Bibi, A11y-friendly mit Icon + Wort) */
.admin-nav--text .admin-nav-link .material-icon {
    font-size: 1.2em;
}
.admin-nav--text .admin-nav-label {
    font-size: 0.95rem;
}
/* Tooltips im Text-Mode unterdrücken — wären redundant zum Text-Label, plus
   Touch-Devices (Bibis iPad) zeigen Hover eh nicht. */
.admin-nav--text .admin-nav-link[data-tooltip]::after {
    display: none;
}

/* ─── Main Content ────────────────────────────────────────────── */

.main-content {
    flex: 1;
    /* body is display:flex column. Default align-items:stretch should give us
       100% cross-axis, but in this layout it resolves to content-width — so
       we force the width explicitly. `min-width: 0` then lets flex-children
       respect .container's max-width instead of being forced wider by long
       inner text/buttons. */
    width: 100%;
    min-width: 0;
    padding-top: var(--space-xl);
    padding-bottom: var(--space-2xl);
}

.page-title {
    margin-bottom: var(--space-xl);
}

.page-title h1 {
    color: var(--color-accent-dark);
    margin-bottom: var(--space-xs);
}

/* K7 Phase B subtitle (my-books) — dezente Status-Zeile unter dem Titel.
   Bewusst kein Alert-Style — soll wie Design wirken, nicht wie ein Hinweis.
   margin-top: in AR klebt der Untertitel sonst sehr nah am großen Cairo-Titel
   (Walid 2026-05-31). var(--space-sm) gibt etwas Luft ohne aufgeräumt zu wirken. */
.page-title .page-subtitle {
    color: var(--color-text-muted);
    font-size: 1rem;
    line-height: 1.5;
    margin: var(--space-md) 0 0;
}

/* ─── Alerts / Flash Messages ─────────────────────────────────── */

.alert {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    font-size: 1rem;
}

.alert-success {
    background: var(--color-success-bg);
    color: #2D5A3A;
}
.alert-error {
    background: var(--color-danger-bg);
    color: #8B2E22;
}
.alert-warning {
    background: var(--color-warning-bg);
    color: #7A5A20;
}
.alert-info {
    background: var(--color-info-bg);
    color: #2E4A66;
}

/* ─── Catalog Toolbar (stats + search + sort) ────────────────── */

.catalog-toolbar {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Stats Bar */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin: 0;
}

.stat-item {
    background: var(--color-bg-alt);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    color: var(--color-text-muted);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
    user-select: none;
    text-align: center;
    min-width: 80px;
}
.stat-item:hover {
    background: var(--color-shade);
}
.stat-item.active {
    border-color: var(--color-accent);
    background: var(--color-warning-bg);
    color: var(--color-accent-dark);
    font-weight: 600;
}
.stat-item strong {
    color: var(--color-accent-dark);
    font-size: 1.15rem;
    font-weight: 700;
    display: block;
    line-height: 1.2;
    margin-bottom: 2px;
}
.stat-item.active strong {
    color: var(--color-accent-dark);
}
.stat-item--disabled {
    opacity: 0.4;
    cursor: default;
}
.stat-item--disabled:hover {
    background: var(--color-bg-alt);
}

/* Search + Sort row */
.toolbar-row {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    flex-wrap: wrap;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 180px;
    max-width: 400px;
}

.input-search {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    padding-inline-end: 36px;
    border: 2px solid var(--color-shade);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background: var(--color-bg);
    transition: border-color 0.15s;
}
.input-search:focus {
    outline: none;
    border-color: var(--color-accent);
}

[lang="ar"] .input-search {
    font-family: var(--font-arabic);
}

.search-clear {
    position: absolute;
    top: 50%;
    inset-inline-end: 8px;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: 18px;
    line-height: 1;
    padding: 4px;
    border-radius: 50%;
    display: none;
    transition: color 0.15s, background 0.15s;
    font-family: 'Material Symbols Outlined';
}
.search-clear:hover {
    color: var(--color-text);
    background: var(--color-shade);
}
.search-wrapper.has-text .search-clear {
    display: block;
}

.sort-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}
.sort-controls label {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    font-weight: 500;
    margin-inline-end: 4px;
    white-space: nowrap;
}

/* Admin-only shelf filter dropdown — sits next to sort-controls in toolbar */
.shelf-filter-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}
.shelf-filter-controls label {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    font-weight: 500;
    margin-inline-end: 4px;
    white-space: nowrap;
}
.shelf-filter-select {
    min-width: 8em;
    max-width: 14em;
    font-size: 0.82rem;
    padding: 4px 8px;
    /* Ligaturen aus: sonst macht die Schrift aus "(9)" ein Kringel-Glyph ⑨ */
    font-variant-ligatures: none;
}
.shelf-filter-select.is-active {
    background: var(--color-accent);
    color: var(--color-white);
    border-color: var(--color-accent);
    font-weight: 600;
}
.sort-btn {
    background: none;
    border: 1px solid var(--color-shade);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.sort-btn:hover {
    background: var(--color-shade);
    color: var(--color-text);
}
.sort-btn.active {
    background: var(--color-accent);
    color: var(--color-white);
    border-color: var(--color-accent);
}

.search-count {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

@media (max-width: 600px) {
    .catalog-toolbar {
        padding: var(--space-md);
    }
    .stats-bar {
        flex-direction: column;
    }
    .toolbar-row {
        flex-direction: column;
        align-items: stretch;
    }
    .input-search {
        max-width: 100%;
    }
    .sort-controls {
        justify-content: flex-start;
    }
}

/* ─── Search Highlight ───────────────────────────────────────── */

mark.search-highlight {
    background: var(--color-accent);
    color: var(--color-bg);
    border-radius: 3px;
    padding: 1px 3px;
    font-weight: inherit;
}

/* ─── Subtle cancel link (unreserve) ─────────────────────────── */

.btn-cancel-subtle {
    background: none;
    border: none;
    color: var(--color-danger);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    padding: var(--space-xs) 0;
    text-decoration: underline;
    text-underline-offset: 2px;
    opacity: 0.8;
    transition: opacity 0.15s;
}
.btn-cancel-subtle:hover {
    opacity: 1;
}

/* ─── Confirm Modal ───────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: var(--space-md);
}
.modal-overlay[hidden] { display: none; }

.modal-box {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-xl);
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.modal-box[dir="rtl"] {
    font-family: var(--font-arabic);
}

.modal-msg {
    font-size: 1.05rem;
    line-height: 1.65;
    margin-bottom: var(--space-lg);
    color: var(--color-text);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 var(--space-md);
    color: var(--color-accent);
}
.modal-title:empty { display: none; }

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: var(--space-md);
}

/* ─── Cover-Lightbox ─────────────────────────────────────────── */

.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    /* Finding 8: `inset: 0` interpretiert iOS Chrome dynamisch mit der animierten
       Toolbar-Höhe → Lightbox „atmet" mit der URL-Bar. Stattdessen explizite
       Large-Viewport-Units (max-mögliche Größe, stabil) mit vh/vw als Fallback. */
    width: 100vw;
    width: 100lvw;
    height: 100vh;
    height: 100lvh;
    z-index: 600;
    background: rgba(20, 15, 10, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    overflow: auto;
    overscroll-behavior: contain;
    contain: layout style paint;
    will-change: opacity;
}
.lightbox-overlay[hidden] { display: none; }

.lightbox-box {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
}

.lightbox-cover-area {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
}

/* Pfeil-Buttons (sichtbare Alternative zu Klick-Zonen) — dezent */
.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.lightbox-arrow:hover,
.lightbox-arrow:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.95);
    outline: none;
}
.lightbox-arrow[disabled] {
    opacity: 0.25;
    cursor: default;
    color: rgba(255, 255, 255, 0.3);
}
.lightbox-arrow[disabled]:hover {
    background: transparent;
}
.lightbox-arrow .material-icon {
    font-size: 1.5rem;
}
.lightbox-arrow-prev { left: var(--space-md); }
.lightbox-arrow-next { right: var(--space-md); }

/* RTL: Pfeil-Buttons gespiegelt — prev rechts (Richtung des "vorherigen" in RTL),
   next links (Richtung des "nächsten" in RTL-Lese-Flow) */
[dir="rtl"] .lightbox-arrow-prev {
    left: auto;
    right: var(--space-md);
}
[dir="rtl"] .lightbox-arrow-next {
    right: auto;
    left: var(--space-md);
}

/* Klick-Zonen — links 30% / Mitte 40% / rechts 30%, transparent overlay.
   Absolut positioniert mit expliziten left/right damit RTL-Spiegelung kontrollierbar bleibt
   (statt vom Grid-Auto-Placement abzuhängen das im RTL-Container reversed). */
.lightbox-zones {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}
.lightbox-zone {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30%;
    pointer-events: auto;
    cursor: pointer;
}
.lightbox-zone.is-disabled { cursor: default; }

/* LTR: prev links, next rechts */
.lightbox-zone-prev { left: 0; }
.lightbox-zone-next { right: 0; }

/* RTL: spiegeln — prev rechts (= Richtung des "vorherigen"), next links (= Lese-Flow vorwärts) */
[dir="rtl"] .lightbox-zone-prev { left: auto; right: 0; }
[dir="rtl"] .lightbox-zone-next { right: auto; left: 0; }

/* Hover-Effekt nur auf Geräten mit echtem Hover (Q10) */
@media (hover: hover) {
    .lightbox-zone-prev:hover:not(.is-disabled),
    .lightbox-zone-next:hover:not(.is-disabled) {
        background: linear-gradient(to right, rgba(255,255,255,0.06), transparent 60%);
    }
    .lightbox-zone-next:hover:not(.is-disabled) {
        background: linear-gradient(to left, rgba(255,255,255,0.06), transparent 60%);
    }
}

/* Reduced Motion: Übergänge aus */
@media (prefers-reduced-motion: reduce) {
    .lightbox-arrow { transition: none; }
}

/* ── Lightbox Info-Panel ─────────────────────────────────── */

.lightbox-info-toggle {
    position: absolute;
    top: var(--space-md);
    right: calc(var(--space-md) + 48px); /* Close = 44 + 4 Lücke */
    z-index: 4;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.lightbox-info-toggle:hover,
.lightbox-info-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.95);
    outline: none;
}
.lightbox-info-toggle[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.95);
}
.lightbox-info-toggle .material-icon {
    font-size: 1.25rem;
}
[dir="rtl"] .lightbox-info-toggle {
    right: auto;
    left: calc(var(--space-md) + 56px);
}

/* Info-Panel: semi-transparente Overlay-Tafel über dem Cover.
   Cover bleibt voller Größe, Panel überlappt nur (Walid-Wunsch 2026-05-10). */
.lightbox-info {
    position: absolute;
    z-index: 5;
    background: rgba(20, 15, 10, 0.78);
    -webkit-backdrop-filter: blur(10px) saturate(110%);
    backdrop-filter: blur(10px) saturate(110%);
    color: rgba(255, 245, 230, 0.95);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    overflow-y: auto;
    overscroll-behavior: contain;
    direction: rtl;
    text-align: right;
    font-family: var(--font-arabic);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}
.lightbox-info[hidden] { display: none; }

.lightbox-info-title {
    font-family: 'Cairo', var(--font-arabic);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.45;
    color: var(--color-accent);
    margin: 0 0 var(--space-md);
}

.lightbox-info-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.lightbox-info-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 245, 230, 0.92);
}

/* Action-Bereich nutzt existing .btn-reserve-unified Styles (gleiche Optik wie Karten).
   Hier nur Loading-State und Hidden-Reset spezifisch für Lightbox. */
.lightbox-action[hidden] { display: none; }
.lightbox-action .btn-reserve-unified.is-loading {
    opacity: 0.7;
    cursor: progress;
}
.lightbox-action .btn-reserve-unified[disabled] {
    opacity: 0.55;
    cursor: default;
}

/* Inline-Confirm-Strip (Q14) — erscheint im Info-Panel statt stacked Modal */
.lightbox-confirm {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.lightbox-confirm[hidden] { display: none; }

.lightbox-confirm-msg {
    margin: 0 0 var(--space-md);
    color: rgba(255, 245, 230, 0.95);
    font-size: 0.95rem;
    line-height: 1.4;
}

.lightbox-confirm-buttons {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-start;
    flex-wrap: wrap;
}

.lightbox-confirm-buttons .btn {
    min-height: 40px;
    font-family: var(--font-arabic);
}

/* Error-Toast im Lightbox-Footer */
.lightbox-error {
    margin-top: var(--space-md);
    padding: 8px 14px;
    background: rgba(220, 70, 70, 0.18);
    border: 1px solid rgba(220, 70, 70, 0.4);
    border-radius: var(--radius-md);
    color: rgba(255, 230, 220, 0.98);
    font-size: 0.88rem;
}
.lightbox-error[hidden] { display: none; }

.lightbox-info-meta {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.lightbox-info-row {
    display: flex;
    flex-direction: column;
}
.lightbox-info-row[hidden] { display: none; }

.lightbox-info-label {
    font-size: 0.78rem;
    font-style: italic;
    font-weight: 500;
    color: rgba(255, 245, 230, 0.55);
    line-height: 1.1;
    margin-bottom: 2px;
    direction: ltr;
    text-align: right;
}

.lightbox-info-value {
    font-size: 1rem;
    line-height: 1.5;
    color: rgba(255, 245, 230, 0.95);
    word-break: break-word;
}

/* Bottom-Sheet auf ALLEN Größen (Walid 2026-05-10: nie seitlich).
   Mobile: edge-to-edge. Desktop: max 720px, zentriert. */
.lightbox-info {
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 45vh;
    max-height: 45dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

@media (min-width: 768px) {
    .lightbox-info {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: calc(100% - var(--space-md) * 2);
        max-width: 720px;
    }
}

/* iOS-Synthetic-Italic-Bug umgehen auf Mobile.
   Gleiche Strategie wie `.site-nav` (siehe CLAUDE.md #9 + bestehender Workaround). */
@media (max-width: 768px) {
    .lightbox-info-title,
    .lightbox-info-status,
    .lightbox-info-value {
        font-style: normal !important;
        font-variation-settings: 'slnt' 0 !important;
    }
}

.lightbox-cover-img {
    display: block;
    max-width: min(100%, 900px);
    max-height: 80vh;
    max-height: 80dvh;
    object-fit: contain;
    contain: layout style;
}
.lightbox-cover-img[hidden] { display: none; }

.lightbox-cover--missing {
    width: min(60vw, 320px);
    aspect-ratio: 2 / 3;
    max-height: 60vh;
    max-height: 60dvh;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-shade) 0%, var(--color-bg-alt) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-cover--missing[hidden] { display: none; }
.lightbox-cover--missing .material-icon {
    font-size: 5rem;
    color: var(--color-text-muted);
    opacity: 0.45;
}

/* Header-Button: dezent — transparent default, nur Hover/Focus zeigt Hintergrund.
   Touch-Target bleibt 44px für a11y. */
.lightbox-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    z-index: 4;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.lightbox-counter {
    position: absolute;
    top: var(--space-md);
    left: var(--space-md);
    z-index: 1;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    background: rgba(0, 0, 0, 0.35);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    pointer-events: none;
    user-select: none;
    min-height: 44px;
    display: flex;
    align-items: center;
}

/* RTL: Counter wandert auf die andere Seite (gegenüber von Close) */
[dir="rtl"] .lightbox-counter {
    left: auto;
    right: var(--space-md);
}
.lightbox-close:hover,
.lightbox-close:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.95);
    outline: none;
}
.lightbox-close .material-icon {
    font-size: 1.25rem;
}

/* RTL: Close-Button auf der anderen Seite */
[dir="rtl"] .lightbox-close {
    right: auto;
    left: var(--space-md);
}

/* Cover-Image: kein sichtbarer Focus-Ring (das Bild ist tabindex="-1"
   und nur für programmatic Reader-Focus erreichbar; aria-label sagt was es ist). */
.lightbox-cover-img:focus,
.lightbox-cover-img:focus-visible {
    outline: none;
}

/* Body-Scroll-Lock wenn Lightbox offen.
   Layout-Shift-Kompensation entfernt — auf Mobile (Overlay-Scrollbars) eh unnötig
   und auf Desktop kaum sichtbar. */
/* iOS-robust scroll-lock (analog body.nav-open): position:fixed + JS-managed
   top:-scrollY. Verhindert dass iOS Safari die URL-Bar-Animation triggert während
   die Lightbox offen ist — sonst verschiebt sich der Viewport und die Lightbox
   scheint zu „wandern" (Finding 8). */
body.lightbox-open {
    position: fixed;
    width: 100%;
    overflow: hidden;
    overscroll-behavior: contain;
}

/* Reduced Motion: keine Transition */
@media (prefers-reduced-motion: reduce) {
    .lightbox-close { transition: none; }
}

/* Print: Lightbox nie sichtbar */
@media print {
    .lightbox-overlay { display: none !important; }
}

/* Visually-hidden utility (accessibility — Reader-only Text) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Cover im Catalog/my-books wird klickbar */
.book-cover {
    cursor: zoom-in;
}
.book-cover--missing {
    cursor: zoom-in;
}

/* ─── Book Grid ───────────────────────────────────────────────── */

.book-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
}

@media (max-width: 1100px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 600px) {
    .book-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Admin form container ────────────────────────────────────── */

.admin-form {
    max-width: 600px;
    background: var(--color-white);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-lg);
}

/* ─── Admin responsive ───────────────────────────────────────── */

@media (max-width: 768px) {
    .admin-form,
    form[style*="max-width"] {
        max-width: 100% !important;
    }

    /* Stack admin stat cards 2-col */
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Details/summary in admin */
    details summary {
        padding: var(--space-sm) 0;
    }
}

/* Medium screens: table scrolls horizontally */
@media (max-width: 768px) and (min-width: 601px) {
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table {
        min-width: 600px;
    }
}

/* Small screens: card layout for tables */
@media (max-width: 600px) {
    .data-table thead {
        display: none;
    }
    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }
    .data-table tr {
        background: var(--color-white);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        padding: var(--space-md);
        margin-bottom: var(--space-md);
        border-bottom: none;
    }
    .data-table td {
        border-bottom: 1px solid var(--color-bg-alt);
        padding: var(--space-sm) 0;
    }
    .data-table td:last-child {
        border-bottom: none;
    }
    .data-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.75rem;
        font-weight: 600;
        color: var(--color-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-bottom: 2px;
    }

    /* Action buttons: allow wrapping */
    .actions-cell {
        white-space: normal;
    }
    .data-table td[data-label] .btn {
        margin-bottom: var(--space-xs);
    }

    .stat-cards {
        grid-template-columns: 1fr;
    }
    .stats-bar {
        flex-direction: column;
    }
}

/* ─── Book Card ───────────────────────────────────────────────── */

.book-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    direction: rtl;
    text-align: right;
    position: relative;  /* Anker für das Shelf-Eck-Badge */
}

.book-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Book cover — 2:3 portrait, top of card, max 220px.
   No background/shadow on real covers — Alpha-PNG/WebP lets the book "float" on the card. */
.book-cover {
    display: block;
    width: 100%;
    max-width: 220px;
    aspect-ratio: 2 / 3;
    object-fit: contain;
    margin: 0 auto var(--space-md);
}

/* Placeholder for books without a cover photo */
.book-cover--missing {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-shade) 0%, var(--color-bg-alt) 100%);
}

.book-cover__icon {
    font-size: 3.5rem;
    color: var(--color-text-muted);
    opacity: 0.45;
}

/* Compact view — covers sichtbar, kleiner */
.book-grid--compact .book-cover {
    max-width: 140px;
    margin-bottom: var(--space-sm);
}
.book-grid--compact .book-cover__icon {
    font-size: 2.4rem;
}

/* List view — info-dichter Modus, Cover ausgeblendet */
.book-grid--list .book-cover {
    display: none;
}

/* Book title — Cairo, always RTL */
.book-title {
    font-family: 'Cairo', var(--font-arabic);
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.45;
    color: var(--color-accent-dark);
    margin-bottom: var(--space-md);
    font-style: normal;
    font-variation-settings: 'slnt' 0;
}

/* Book metadata — label on top italic, value below in Arabic font */
.book-meta {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.meta-label {
    font-size: 0.78rem;
    font-style: italic;
    font-weight: 500;
    color: var(--color-text-muted);
    line-height: 1.1;
    margin-bottom: 1px;
}

.meta-value {
    font-family: var(--font-arabic);
    font-size: 1rem;
    color: var(--color-text);
    line-height: 1.35;
}

/* Year value: keep Western numerals readable */
.meta-value-year {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--color-text-muted);
}

/* Shelf-Indikator (admin-only).
   Karten- + Kompaktansicht: angepinnter Eck-Sticker (siehe scoped Regeln unten).
   Listenansicht behält vorerst die In-Flow-Zeile — eigene Überarbeitung folgt. */
.book-shelf-line {
    margin-bottom: var(--space-sm);
    line-height: 1.6;
}

/* Heller Sticker: cremefarben, Akzent-Text + -Rand, leichter Schatten zum Abheben.
   Gilt für alle Ansichten — nur die Positionierung unten ist ansichts-spezifisch. */
.book-shelf-line .shelf-badge {
    font-size: 13px;
    background: var(--color-bg);
    color: var(--color-accent);
    border-color: color-mix(in srgb, var(--color-accent) 55%, transparent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    padding: 3px 8px;
}

/* Karten- + Kompaktansicht (nicht Liste): Eck-Sticker oben links. */
.book-grid:not(.book-grid--list) .book-shelf-line {
    position: absolute;
    top: var(--space-md);
    left: var(--space-md);
    margin: 0;
    line-height: 1;
    z-index: 2;
}
/* "(in beiden Regalen!)" passt nicht in die Ecke — entfällt dort, bleibt im Lightbox. */
.book-grid:not(.book-grid--list) .book-shelf-line .shelf-warning {
    display: none;
}

/* Kompaktansicht: kleinere Karte (Padding 10–12px) → engerer Eck-Abstand
   und ein leicht kleineres Badge, damit es proportional bleibt. */
.book-grid--compact .book-shelf-line {
    top: var(--space-sm);
    left: var(--space-sm);
}
.book-grid--compact .book-shelf-line .shelf-badge {
    font-size: 12px;
    padding: 2px 6px;
}

.shelf-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--color-accent);
    background: color-mix(in srgb, var(--color-accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-accent) 30%, transparent);
    border-radius: 4px;
    padding: 2px 7px;
    font-family: var(--font-mono, monospace);
}

.shelf-multi {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 6px;
}

.shelf-plus {
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 12px;
}

.shelf-warning {
    font-size: 11px;
    font-style: italic;
    color: var(--color-accent);
    font-weight: 600;
}

.book-actions {
    margin-top: auto;
    padding-top: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-sm);
}

/* Card states */
.book-card--mine {
    background: var(--color-success-bg);
}

/* ── Animations: card state changes after reserve / unreserve ── */

/* Reserve: dark solid green → settles to the normal light success bg */
@keyframes book-just-reserved {
    0%   { background-color: var(--color-success); }
    100% { background-color: var(--color-success-bg); }
}
/* Unreserve: brief danger-tinted flash → fades back to normal card bg */
@keyframes book-just-unreserved {
    0%   { background-color: var(--color-danger-bg); }
    100% { background-color: var(--color-bg); }
}
/* My-books cancel: card dissolves before page reloads */
@keyframes book-dissolve {
    0%   { opacity: 1;   transform: scale(1);    }
    100% { opacity: 0;   transform: scale(0.92) translateY(-6px); }
}

.book-card--just-reserved  { animation: book-just-reserved  1.6s ease-out forwards; }
.book-card--just-unreserved{ animation: book-just-unreserved 1.6s ease-out forwards; }
.book-card--dissolving {
    animation: book-dissolve 0.45s ease-in forwards;
    pointer-events: none;
}

.book-card--reserved {
    opacity: 0.45;
    filter: grayscale(1);
}
.book-card--reserved:hover {
    opacity: 0.45;
    filter: grayscale(1);
    box-shadow: var(--shadow-sm);
    transform: none;
}

/* ─── Badges ──────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.5;
    vertical-align: baseline;
}

.badge-mine {
    background: var(--color-success);
    color: var(--color-white);
}

.badge-reserved {
    background: var(--color-shade-dark);
    color: var(--color-text);
}

/* Admin sees reserved cards in green with username */
.badge-reserved-admin {
    background: var(--color-success);
    color: var(--color-white);
    font-size: 0.82rem;
    line-height: 1.6;
}
/* When badge has a Latin username in Arabic UI, lift Arabic text for baseline alignment */
[lang="ar"] .badge-reserved-admin .badge-ar {
    position: relative;
    top: -3px;
}
.badge-reserved-admin .badge-name {
    font-family: var(--font-body);
}
.book-card--reserved-admin {
    background: var(--color-success-bg);
    opacity: 1;
}
.book-card--reserved-admin:hover {
    opacity: 1;
}

.badge-available {
    background: var(--color-bg-alt);
    color: var(--color-text-muted);
}

/* ─── Unified Reserve/Unreserve Button ────────────────────────── */

.btn-reserve-unified {
    display: inline-block;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.5;
    text-align: center;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: background-color 0.2s, color 0.2s;
}
[lang="ar"] .btn-reserve-unified {
    font-family: var(--font-arabic);
}

/* Available: beige default → green on hover */
.btn-reserve-unified--available {
    background: var(--color-shade-dark);
    color: var(--color-text);
    min-width: 110px;
}
.btn-reserve-unified--available:hover {
    background: var(--color-success);
    color: var(--color-white);
}

/* Mine: solid green, hover → red with "Cancel?" text */
.btn-reserve-unified--mine {
    background: var(--color-success);
    color: var(--color-white);
    min-width: 140px;
}
[lang="ar"] .btn-reserve-unified--mine {
    min-width: 110px;
}
.btn-reserve-unified--hover-cancel {
    background: var(--color-danger) !important;
    color: var(--color-white) !important;
}

/* Reserved (other users): gray, no action */
.btn-reserve-unified--reserved {
    background: var(--color-shade-dark);
    color: var(--color-text);
    cursor: default;
    min-width: 110px;
}

/* Disabled state (deadline passed) */
.btn-reserve-unified--disabled {
    cursor: default;
    opacity: 0.8;
}

/* ─── Handed-Over State (D.12) ────────────────────────────────────
   Reservierungen, die bereits übergeben wurden. Eigene Karte wird beige
   gedämpft (kein Storno mehr möglich), fremde Karte wirkt „nicht mehr
   verfügbar". Animationen für reservieren/stornieren werden hier nicht
   ausgelöst – Übergabe ist ein Admin-Workflow. */

.book-card--mine.book-card--handed-over {
    background: var(--color-bg-alt);
}

.btn-reserve-unified--handed-over {
    background: var(--color-bg-alt);
    color: var(--color-text-muted);
    border: 1px solid var(--color-shade-dark);
    cursor: default;
    min-width: 140px;
}

.btn-reserve-unified--not-available {
    background: var(--color-shade-dark);
    color: var(--color-text-muted);
    cursor: default;
    min-width: 110px;
}

.badge-reserved-admin--handed-over {
    background: var(--color-text-muted);
    color: var(--color-white);
    font-size: 0.78rem;
}

@media (prefers-reduced-motion: reduce) {
    .book-card--just-reserved,
    .book-card--just-unreserved,
    .book-card--dissolving {
        animation: none;
    }
}

/* ─── Sort Direction Arrows ──────────────────────────────────── */

.sort-btn.sort-asc::after {
    content: ' ↑';
    font-size: 0.75em;
}
.sort-btn.sort-desc::after {
    content: ' ↓';
    font-size: 0.75em;
}

/* ─── Custom Tooltips ────────────────────────────────────────── */

[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: var(--color-text);
    color: var(--color-white);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 100;
    line-height: 1.4;
}
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
/* RTL tooltip positioning */
[dir="rtl"] [data-tooltip]::after {
    font-family: var(--font-arabic);
}
/* Hide CSS tooltips on mobile (nav-tips shown instead) */
@media (max-width: 768px) {
    [data-tooltip]::after { display: none; }
}

/* ─── Buttons ─────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, transform 0.1s, box-shadow 0.15s;
    line-height: 1.4;
}

[lang="ar"] .btn {
    font-family: var(--font-arabic);
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--color-accent);
    color: var(--color-white);
}
.btn-primary:hover {
    background: var(--color-accent-dark);
    color: var(--color-white);
    box-shadow: var(--shadow-sm);
}

.btn-success {
    background: var(--color-success);
    color: var(--color-white);
}

.btn-danger {
    background: var(--color-danger);
    color: var(--color-white);
}
.btn-danger:hover {
    background: #9E3022;
    color: var(--color-white);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--color-accent);
    color: var(--color-accent);
}
.btn-outline:hover {
    background: var(--color-accent);
    color: var(--color-white);
}

.btn-sm {
    padding: 6px var(--space-md);
    font-size: 0.92rem;
}

.btn:disabled, .btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── Forms ───────────────────────────────────────────────────── */

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: var(--space-xs);
    color: var(--color-text);
}

.form-input,
.form-select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--color-shade);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background: var(--color-white);
    color: var(--color-text);
    transition: border-color 0.15s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-accent);
}

.form-hint {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    margin-top: var(--space-xs);
}

.form-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.inline-form {
    display: inline;
}

/* ─── Tables (Admin) ──────────────────────────────────────────── */

/* overflow-x: auto bewusst NICHT im Default — CSS-Spec schaltet sonst
   overflow-y automatisch von visible auf auto, sobald die horizontale
   Scrollbar erscheint (lange Email-Strings). Folge: vertikaler Schlitz
   der bei 18+ Usern in admin/emails.php nur ~3 Zeilen zeigt.
   Horizontal-Scroll für schmale Viewports kommt aus mobile @media unten. */
.table-wrapper {
    margin-bottom: var(--space-lg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: start;
    border-bottom: 1px solid var(--color-shade);
}

.data-table th {
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-bg-alt);
}

.data-table tr:hover td {
    background: var(--color-bg-alt);
}
@media (max-width: 600px) {
    .data-table tr:hover td {
        background: transparent;
    }
}

/* ─── Cards (Admin stat cards) ────────────────────────────────── */

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--color-white);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.stat-card__value {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    color: var(--color-accent-dark);
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.stat-card__label {
    font-size: 0.92rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

/* ─── Edit User Box ───────────────────────────────────────────── */

.edit-user-box {
    background: var(--color-bg-alt);
    border: 2px solid var(--color-shade);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}
.edit-user-box h3 {
    margin-bottom: var(--space-md);
    color: var(--color-accent-dark);
}

/* ─── Magic Link Display ──────────────────────────────────────── */

.magic-link-box {
    background: var(--color-warning-bg);
    border: 2px solid var(--color-accent);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin: var(--space-lg) 0;
    text-align: center;
}

.magic-link-code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-accent-dark);
    letter-spacing: 0.1em;
    margin: var(--space-md) 0;
    user-select: all;
}

.magic-link-url {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.92rem;
    background: var(--color-white);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    display: inline-block;
    word-break: break-all;
    user-select: all;
    margin: var(--space-sm) 0;
}

/* ─── Welcome / Login Page ────────────────────────────────────── */

.welcome-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height) - 100px);
}

.welcome-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2xl);
    max-width: min(500px, calc(100vw - 2rem));
    width: 100%;
    text-align: center;
    overflow: hidden;
    box-sizing: border-box;
}

.welcome-card h1 {
    color: var(--color-accent-dark);
    margin-bottom: var(--space-sm);
}

.welcome-card p {
    color: var(--color-text-muted);
}

/* ─── 404-Seite (sprach-neutral, 3 Sprachen parallel) ──────────── */

.error-404 .error-404-block {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.error-404 .error-404-block:last-of-type {
    border-bottom: none;
}
.error-404 .error-404-block h2 {
    font-size: 1.15rem;
    color: var(--color-accent-dark);
    margin: 0 0 0.3rem;
    font-weight: 600;
}
.error-404 .error-404-block p {
    margin: 0;
    font-size: 0.95rem;
}
.error-404 .error-404-block[lang="ar"] h2,
.error-404 .error-404-block[lang="ar"] p {
    font-family: 'Cairo', var(--font-arabic);
}
.error-404-action {
    margin-top: 1.4rem;
}
.error-404-action .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
}
.error-404-action .material-icon {
    font-size: 1.6rem;
}

/* ─── Code Login Form ────────────────────────────────────────── */

.code-login-form {
    text-align: center;
}

.code-login-label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text);
    margin-bottom: var(--space-sm);
}

.code-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    direction: ltr;
    width: 100%;
    box-sizing: border-box;
}

.code-input-single {
    flex: 1 1 0;
    min-width: 0;
    max-width: 2.6rem;
    height: 3.2rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid var(--color-shade);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
    padding: 0;
    caret-color: var(--color-accent);
}

.code-input-single::placeholder {
    color: var(--color-shade-dark);
    font-weight: 400;
    opacity: 0.45;
}

.code-input-single:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(193, 122, 47, 0.15);
    background: var(--color-white);
}

/* Filled state */
.code-input-single.has-digit {
    border-color: var(--color-accent-light);
    background: var(--color-white);
}

.code-separator {
    flex: 0 0 auto;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-shade-dark);
    padding: 0 2px;
    line-height: 3.2rem;
}

/* Direction indicator for code input */
.code-direction-hint {
    font-size: 0.78rem;
    color: var(--color-shade-dark);
    margin-top: var(--space-sm);
    margin-bottom: 0;
}

@media (max-width: 540px) {
    .welcome-card {
        padding: var(--space-md) var(--space-sm);
        margin-inline: var(--space-xs);
    }
    .code-input-single {
        max-width: 2.1rem;
        height: 2.7rem;
        font-size: 1.05rem;
    }
    .code-input-group {
        gap: 3px;
    }
    .code-separator {
        font-size: 1rem;
        padding: 0 1px;
        line-height: 2.7rem;
    }
}
@media (max-width: 370px) {
    .code-input-single {
        max-width: 1.8rem;
        height: 2.4rem;
        font-size: 0.95rem;
    }
    .code-input-group {
        gap: 3px;
    }
    .code-separator {
        font-size: 0.9rem;
        padding: 0 1px;
        line-height: 2.4rem;
    }
}

/* ─── Empty States ────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--color-text-muted);
}

.empty-state h3 {
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

/* ─── Site Footer ─────────────────────────────────────────────── */

.site-footer {
    background: var(--color-bg-alt);
    border-top: 1px solid var(--color-shade);
    padding: var(--space-lg) 0;
    margin-top: auto;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.footer-deadline {
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

.deadline-label {
    font-weight: 600;
}

.deadline-expired {
    color: var(--color-danger);
    font-weight: 600;
}

.deadline-urgent {
    color: var(--color-warning);
    font-weight: 600;
}

.footer-brand {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--color-shade-dark);
}

[lang="ar"] .footer-brand {
    font-family: var(--font-arabic-heading);
    font-style: normal;
    font-variation-settings: 'slnt' 0;
}

/* ─── Admin details ──────────────────────────────────────────── */

.book-titles-list {
    font-family: var(--font-arabic);
    font-size: 0.85rem;
    line-height: 1.6;
    direction: rtl;
}

.code-display {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
}

.actions-cell {
    white-space: nowrap;
}
.actions-cell .inline-form {
    display: inline;
}

/* ─── Utility Classes ─────────────────────────────────────────── */

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }


/* ─── Arabic language — font-family overrides ────────────────── */
/* Font-size scaling is handled by html[lang="ar"] { font-size: 21px }
   which automatically bumps all rem values ~10% for Arabic. */

[lang="ar"] .nav-link,
[lang="ar"] .nav-logout,
[lang="ar"] .admin-nav-link,
[lang="ar"] .nav-greeting {
    font-family: var(--font-arabic-nav);
    font-weight: 800;
    font-style: normal;
    font-variation-settings: 'slnt' 0;
}
/* Correct font-sizes so Arabic nav matches Latin pixel sizes
   (arabic rem × 21px = latin rem × 19px → factor ≈ 0.905) */
[lang="ar"] .nav-link         { font-size: 1rem; }    /* 21px ≈ Latin 1.1rem×19px = 20.9px */
[lang="ar"] .nav-logout       { font-size: 1rem; }    /* 21px — now same as nav-link */
[lang="ar"] .admin-nav-link   { font-size: 0.86rem; } /* 18.1px ≈ Latin 18.1px */
/* user-name: Latin text should stay in Latin font, Arabic nav font only in Arabic UI */
[lang="ar"] .user-name { font-family: var(--font-body); font-size: 1rem; font-weight: 720; }
[lang="ar"] .badge { font-family: var(--font-arabic); }
[lang="ar"] .btn { font-family: var(--font-arabic); }
[lang="ar"] .btn-cancel-subtle { font-family: var(--font-arabic); }

/* ─── Compact Form Grid ──────────────────────────────────────── */

.admin-form--compact {
    max-width: 800px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0 var(--space-md);
}

.form-grid .form-group {
    margin-bottom: var(--space-md);
}

/* Column spans */
.form-group--sm { grid-column: span 3; }
.form-group--md { grid-column: span 4; }
.form-group--lg { grid-column: span 6; }

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .form-group--sm,
    .form-group--md,
    .form-group--lg {
        grid-column: span 1;
    }
}

/* ─── User Cards Grid ────────────────────────────────────────── */

.user-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.user-card {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease;
}

.user-card:hover {
    box-shadow: var(--shadow-md);
}

.user-card--admin {
    background: linear-gradient(135deg, var(--color-white) 0%, var(--color-bg-alt) 100%);
}

.user-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
    gap: var(--space-sm);
}

.user-card__name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-accent-dark);
}

.user-card__role {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: var(--color-bg-alt);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.user-card__details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xs) var(--space-md);
    margin-bottom: var(--space-md);
    font-size: 0.9rem;
}

.user-card__detail {
    display: flex;
    flex-direction: column;
}

.user-card__label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-shade-dark);
    line-height: 1.2;
}

.user-card__detail > span:not(.user-card__label) {
    line-height: 1.25;
}

.user-card__reservations.has-reservations {
    font-weight: 700;
    color: var(--color-accent-dark);
}

.user-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: auto;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-bg-alt);
    align-items: center;
}
/* Ensure all action buttons in user cards have equal height */
.user-card__actions .btn {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.user-card__actions .inline-form {
    display: inline-flex;
}

/* Manual-Code-Set Modal (Plan-Doc 14) — großes monospace-Input zentriert */
.set-code-modal-box {
    max-width: 460px;
}
.set-code-modal-input {
    display: block;
    width: 100%;
    margin: var(--space-md) auto var(--space-lg);
    padding: 16px 12px;
    font-family: monospace;
    font-size: 1.8rem;
    letter-spacing: 6px;
    text-align: center;
    border: 2px solid var(--color-shade);
    border-radius: var(--radius-md);
    background: var(--color-bg-alt);
    color: var(--color-accent-dark);
    box-sizing: border-box;
}
.set-code-modal-input:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-white);
}
#set-code-modal-subtitle:empty { display: none; }
.set-code-modal-suggest {
    display: flex;
    justify-content: center;
    margin: calc(-1 * var(--space-md)) 0 var(--space-md);
}
.set-code-modal-random {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px dashed var(--color-shade);
    color: var(--color-text-muted);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.set-code-modal-random:hover {
    background: var(--color-bg-alt);
    border-color: var(--color-accent);
    color: var(--color-text);
}
.set-code-modal-random .material-icon {
    font-size: 1.2em;
    margin: 0;
}
.set-code-modal-warning {
    background: #fff4e6;
    border: 1px solid #e89640;
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    margin: 0 0 var(--space-md);
    color: #6e3d1f;
    font-size: 0.95rem;
    text-align: start;
}
.set-code-modal-warning[hidden] { display: none; }
.set-code-modal-warning ul {
    margin: 0;
    padding-inline-start: 1.2em;
}
.set-code-modal-warning li + li { margin-top: 6px; }

.btn-info {
    background: var(--color-info);
    color: var(--color-white);
}

@media (max-width: 600px) {
    .user-grid {
        grid-template-columns: 1fr;
    }
    .user-card__details {
        grid-template-columns: 1fr 1fr;
    }
}

/* ─── Welcome Splash Screen ──────────────────────────────────── */

.welcome-splash {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.welcome-splash.fade-out {
    opacity: 0;
    pointer-events: none;
}

.welcome-splash__greeting {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-accent-dark);
    margin-bottom: var(--space-lg);
    opacity: 0;
    transform: translateY(10px);
    animation: splash-fade-in 0.4s ease forwards;
    text-align: center;
    width: 100%;
}

[lang="ar"] .welcome-splash__greeting {
    font-family: var(--font-arabic-heading);
    font-size: 2rem;
    font-style: normal;
    font-variation-settings: 'slnt' 0;
}

.welcome-splash__loader {
    width: 200px;
    height: 3px;
    background: var(--color-shade);
    border-radius: 2px;
    overflow: hidden;
    opacity: 0;
    animation: splash-fade-in 0.3s ease 0.2s forwards;
}

.welcome-splash__loader-bar {
    height: 100%;
    background: var(--color-accent);
    border-radius: 2px;
    width: 0%;
    animation: splash-load 2s ease-in-out forwards;
}

.welcome-splash__subtitle {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    margin-top: var(--space-md);
    opacity: 0;
    animation: splash-fade-in 0.3s ease 0.3s forwards;
}

@keyframes splash-fade-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes splash-load {
    0% { width: 0%; }
    30% { width: 45%; }
    60% { width: 75%; }
    100% { width: 100%; }
}

/* ─── Header Countdown (Top Bar) ─────────────────────────────── */

.header-countdown {
    font-family: 'Rubik', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg-alt);
    padding: 4px 10px;
    border-radius: var(--radius-md);
    white-space: nowrap;
    letter-spacing: 0.03em;
    /* Fixed width: prevents nav from dancing when seconds tick */
    min-width: 8.5em;
    text-align: center;
    box-sizing: border-box;
}

.header-countdown--urgent {
    color: var(--color-warning);
    background: var(--color-warning-bg);
}

.header-countdown--expired {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

/* ─── Mobile Nav Groups ──────────────────────────────────────── */

/* Desktop: nav-groups are real flex items with their own gap */
@media (min-width: 769px) {
    .nav-group {
        display: flex;
        align-items: center;
    }
    .nav-group--links {
        gap: var(--space-lg);
    }
    /* Mobile countdown group is empty on desktop — hide to avoid extra flex gap */
    .nav-group--countdown {
        display: none;
    }
}
/* Mobile: groups become vertical stacks */

/* Static nav-link (non-clickable, e.g. countdown in burger menu) */
.nav-link--static {
    cursor: default;
}

@media (max-width: 768px) {
    .nav-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .nav-group--links {
        gap: var(--space-sm);
    }

    /* Countdown looks like a nav item on mobile */
    .nav-group--countdown {
        /* No divider lines — consistent spacing from parent gap */
    }

    .nav-group--lang {
        width: auto;
        flex-direction: row;
    }

    .lang-theme-group {
        display: inline-flex;
        flex-direction: row;
    }

    .nav-group--logout {
        /* No divider lines */
    }

    /* Header countdown hidden on mobile (shown in burger menu instead) */
    .header-countdown {
        display: none;
    }
}

/* ─── Export Toolbar ──────────────────────────────────────────── */

.export-toolbar {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}

/* ─── Link Cards (for Lists selection) ───────────────────────── */

.book-card--link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: box-shadow var(--transition), transform var(--transition);
}
.book-card--link:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* ─── Breadcrumbs ─────────────────────────────────────────────── */

.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
    font-size: 0.88rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-md);
    padding: var(--space-sm) 0;
}

.breadcrumb-link {
    color: var(--color-accent);
    text-decoration: none;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-sep {
    color: var(--color-shade-dark);
    font-weight: 600;
}

.breadcrumb-current {
    font-weight: 600;
    color: var(--color-text);
}

/* ─── Logbook ─────────────────────────────────────────────────── */

.logbook-filters {
    background: var(--color-bg-alt);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
    flex: 1;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.form-input--sm {
    padding: 6px 10px;
    font-size: 0.88rem;
    border: 1px solid var(--color-shade);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-text);
}

.logbook-count {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.logbook-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.logbook-badge--login {
    background: #e8f5e9;
    color: #2e7d32;
}

.logbook-badge--logout {
    background: #e3f2fd;
    color: #1565c0;
}

.logbook-badge--reserve {
    background: #fff3e0;
    color: #e65100;
}

.logbook-badge--unreserve {
    background: #fce4ec;
    color: #c62828;
}

.logbook-badge--clear_logbook {
    background: #f3e5f5;
    color: #6a1b9a;
}

.logbook-badge--reservation_handed_over {
    background: #e0f2f1;
    color: #00695c;
}

.logbook-badge--reservation_handover_date_changed {
    background: #e1f5fe;
    color: #0277bd;
}

.logbook-badge--reservation_handover_undone {
    background: #fff8e1;
    color: #ef6c00;
}

.logbook-load-more {
    text-align: center;
    padding: var(--space-md) 0;
}

.logbook-empty {
    text-align: center;
    padding: var(--space-xl) 0;
}

.btn-danger {
    background: #c62828;
    color: white;
    border: none;
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.92rem;
}

.btn-danger:hover {
    background: #b71c1c;
}

@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
    }
    .filter-group {
        width: 100%;
    }
}

/* ─── Live update toasts (catalog polling) ─────────────────── */

.live-toast-container {
    position: fixed;
    top: var(--space-md);
    right: var(--space-md);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-width: min(420px, calc(100vw - 2 * var(--space-md)));
    pointer-events: none;
}
[dir="rtl"] .live-toast-container {
    right: auto;
    left: var(--space-md);
}

.live-toast {
    position: relative;
    background: var(--color-text);
    color: var(--color-bg);
    padding: 0.7rem 2.4rem 0.7rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    cursor: pointer;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.25s, transform 0.25s;
}
[dir="rtl"] .live-toast {
    padding: 0.7rem 1rem 0.7rem 2.4rem;
}
.live-toast.is-shown {
    opacity: 0.85;
}
.live-toast.is-shown:hover {
    opacity: 1;
}
.live-toast__close {
    position: absolute;
    top: 0.45rem;
    right: 0.55rem;
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.7;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
}
.live-toast__close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}
[dir="rtl"] .live-toast__close {
    right: auto;
    left: 0.55rem;
}
.live-toast__action {
    font-size: 0.82rem;
    opacity: 0.75;
    margin-bottom: 0.25rem;
}
.live-toast__title {
    font-weight: 600;
    word-break: break-word;
}
.live-toast__author {
    font-size: 0.85rem;
    opacity: 0.85;
    margin-top: 0.15rem;
    word-break: break-word;
}
[dir="rtl"] .live-toast {
    transform: translateX(-20px);
}
.live-toast.is-shown {
    transform: translateX(0);
}
.live-toast:hover {
    background: var(--color-text);
    filter: brightness(1.15);
}

@media (max-width: 768px) {
    .live-toast-container {
        top: auto;
        bottom: var(--space-md);
        right: var(--space-md);
        left: var(--space-md);
        max-width: none;
    }
    .live-toast { font-size: 0.88rem; }
}

/* iPhone Notch + iPad Home-Indicator safe-area. */
@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .live-toast-container {
            bottom: max(var(--space-md), env(safe-area-inset-bottom));
            left:   max(var(--space-md), env(safe-area-inset-left));
            right:  max(var(--space-md), env(safe-area-inset-right));
        }
    }
}

/* D.12 Phase 6.9 — Action-toasts mit Undo (höhere Opazität als Live-Toasts). */
.live-toast--action,
.live-toast--action.is-shown {
    opacity: 1;
}
/* Action-toasts haben Layout-Flex damit Text + Undo-Button sauber nebeneinander
   liegen (auch in RTL — sonst überlappen sie sich bei AR-Strings). */
.live-toast--action {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.live-toast--success {
    background: #1b5e20;
}
.live-toast--error {
    background: #b71c1c;
}

.live-toast__undo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0 1.1rem;
    min-height: 44px;
    min-width: 44px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: inherit;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    line-height: 1;
}
.live-toast__undo:hover,
.live-toast__undo:focus-visible {
    background: rgba(255, 255, 255, 0.28);
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 1px;
}
[dir="rtl"] .live-toast__undo {
    margin: 0.4rem 0 0 0.5rem;
}

/* Upgrade close-button tap-target to WCAG/Apple-HIG min 44×44 while
   keeping the visible × small. */
.live-toast__close {
    min-width: 44px;
    min-height: 44px;
    top: 0;
    right: 0;
}
[dir="rtl"] .live-toast__close {
    left: 0;
    right: auto;
}
.live-toast__close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: -2px;
    opacity: 1;
}

/* Respect users with reduced-motion preference (a11y). */
@media (prefers-reduced-motion: reduce) {
    .live-toast {
        transition: opacity 0.01s linear;
        transform: none !important;
    }
}

/* ─── D.12 Phase 6.6.a Listen-Reservierungen mit Sub-Gruppen ───── */
.reservation-user-block {
    margin-bottom: var(--space-xl);
}
/* Konsistente Spacing: user-name → space-md → group-title → space-sm → list → space-md → next group-title. */
.reservation-user-name {
    margin: 0 0 var(--space-md);
    font-size: 1.35rem;
    font-family: 'Cairo', var(--font-arabic);
    color: var(--color-accent-dark, #6e3d1f);
    border-bottom: 2px solid var(--color-accent, #a05a2c);
    padding-bottom: 0.3rem;
}
.reservation-group-title {
    margin: 0 0 var(--space-sm);
    font-size: 1.05rem;
    font-weight: 600;
}
.rsv-list + .reservation-group-title {
    margin-top: var(--space-md);
}
.reservation-group-title--open {
    color: var(--color-accent, #a05a2c);
}
.reservation-group-title--completed {
    color: var(--color-text-muted, #6b6258);
}
.reservation-group-title .text-muted {
    font-weight: normal;
    font-size: 0.9rem;
}

/* Responsive Reservation-Liste — 3 Breakpoint-Layouts.
   Desktop (default): 7-Spalten-Grid wie eine Tabelle (jede Info eigene Spalte).
   Mid (max 900px): 4-Spalten-Grid mit Title + Meta-Zeile als Stack im "main".
   Mobile (max 640px): voll vertikal gestapelt. */
.rsv-list {
    display: flex;
    flex-direction: column;
}

/* Desktop (≥ 900px) default: 7 Spalten — wie Tabelle.
   display:contents auf den Wrapper-Divs (.rsv-main, .rsv-meta) lässt die
   inneren Elemente direkt im Top-Grid landen. */
.rsv-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1.4fr) minmax(0, 1fr) 60px minmax(0, 1fr) auto 90px;
    grid-template-areas: "num title author year publisher shelf date";
    column-gap: 18px;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    direction: rtl;
}
.rsv-row:last-child { border-bottom: none; }

.rsv-main { display: contents; }
.rsv-meta { display: contents; }

.rsv-num {
    grid-area: num;
    direction: ltr;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    padding-top: 0.15rem;
}
.rsv-title {
    grid-area: title;
    font-family: 'Cairo', var(--font-arabic);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-accent-dark, #6e3d1f);
    word-break: break-word;
}
.rsv-author {
    grid-area: author;
    direction: rtl;
    font-size: 0.9rem;
    line-height: 1.35;
    color: var(--color-text-muted);
    word-break: break-word;
}
.rsv-year {
    grid-area: year;
    direction: ltr;
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    padding-top: 0.15rem;
}
.rsv-publisher {
    grid-area: publisher;
    direction: rtl;
    font-size: 0.9rem;
    line-height: 1.35;
    color: var(--color-text-muted);
    word-break: break-word;
}
.rsv-shelf {
    grid-area: shelf;
    justify-self: start;
}
.rsv-date {
    grid-area: date;
    direction: ltr;
    text-align: start;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    padding-top: 0.15rem;
}
.rsv-sep { display: none; } /* separator dots hidden on desktop */

/* Mid breakpoint (640-900px): 4 Spalten — Title + Meta-Zeile als Stack. */
@media (max-width: 900px) {
    .rsv-row {
        grid-template-columns: 48px minmax(0, 1fr) auto 100px;
        grid-template-areas: "num main shelf date";
        column-gap: 18px;
        row-gap: 2px;
    }
    .rsv-main {
        display: flex;
        flex-direction: column;
        grid-area: main;
        gap: 2px;
        min-width: 0;
    }
    .rsv-meta {
        display: block;
        font-size: 0.85rem;
        line-height: 1.4;
        color: var(--color-text-muted);
        grid-area: auto;
    }
    .rsv-title {
        grid-area: auto;
        font-size: 1.05rem;
        line-height: 1.3;
    }
    .rsv-author,
    .rsv-year,
    .rsv-publisher {
        grid-area: auto;
        display: inline;
        font-size: 0.85rem;
        color: var(--color-text-muted);
        padding-top: 0;
    }
    .rsv-sep {
        display: inline;
        opacity: 0.5;
        margin: 0 0.15rem;
    }
}

/* Mobile (< 640px): Card-Style — Title + Meta oben (full width),
   Footer-Zeile mit num + shelf + date (horizontal, klein). */
@media (max-width: 640px) {
    .rsv-row {
        grid-template-columns: auto auto 1fr;
        grid-template-areas:
            "main  main  main"
            "num   shelf date";
        column-gap: 14px;
        row-gap: 8px;
        padding: 14px 0;
        align-items: center;
    }
    .rsv-main { grid-area: main; }
    .rsv-num {
        grid-area: num;
        text-align: start;
        padding-top: 0;
    }
    .rsv-shelf {
        grid-area: shelf;
        justify-self: start;
    }
    .rsv-date {
        grid-area: date;
        justify-self: end;
        padding-top: 0;
    }
    .rsv-date:empty { display: none; }
}

/* iOS-Rendering-Bug Workaround: Variable Fonts (Rubik/Cairo) werden auf
   iOS Safari random italic gerendert wenn 'slnt'/'ital' Axis nicht explizit
   auf 0 gesetzt. Gleiche Strategie wie `.site-nav` (siehe CLAUDE.md #9). */
.handover-section,
.handover-section *,
.handover-filter,
.handover-filter *,
.handover-btn,
.handover-btn *,
.reservation-user-block,
.reservation-user-block * {
    font-style: normal !important;
    font-variation-settings: 'slnt' 0, 'ital' 0 !important;
}

/* ─── D.12 Handovers page (Bibi's main work page) ──────────── */
/* Plan-Doc: _docs/13-D12-Handed-Over-Feature.md Sektion 2.3 (Variante B) + 2.8 Mobile.
   Own namespace `.handover-*` — does NOT inherit from .btn-reserve-unified
   (no hover-swap, no 37px height; Touch-First with 56-64px primary buttons). */

.handover-section {
    margin: var(--space-lg) 0;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    width: 100%;
    box-sizing: border-box;
}

/* Top section "Noch offen": prominent — what Bibi needs to act on. */
.handover-section--open {
    background: var(--color-accent-soft, #f4e9d8);
    border: 2px solid var(--color-accent, #a05a2c);
}
.handover-section--open .handover-section__title {
    font-size: 1.55rem;
    color: var(--color-accent, #a05a2c);
    margin: 0 0 var(--space-xs);
}

/* Bottom section "Bereits abgeholt": subdued — archive. */
.handover-section--completed {
    background: rgba(0,0,0,0.025);
    border: 1px solid rgba(0,0,0,0.08);
    opacity: 0.85;
}
.handover-section--completed .handover-section__title {
    font-size: 1.2rem;
    color: var(--color-text-muted, #6b6258);
    margin: 0 0 var(--space-xs);
}

.handover-section__hint {
    font-size: 0.92rem;
    color: var(--color-text-muted, #6b6258);
    margin: 0 0 var(--space-md);
}

.handover-empty {
    padding: var(--space-md) 0;
    color: var(--color-text-muted, #6b6258);
    font-style: italic;
}

.handover-user-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.handover-user-item {
    background: var(--color-bg, #fff);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0,0,0,0.08);
    overflow: hidden;
}
.handover-user-item:hover,
.handover-user-item:focus-within {
    border-color: var(--color-accent, #a05a2c);
}

.handover-user-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 0.9rem 1rem;
    min-height: 56px;
    background: transparent;
    border: none;
    width: 100%;
    text-align: inherit;
    font: inherit;
    color: inherit;
    cursor: pointer;
}
/* Name takes the available space, meta-group (count + chevron) sticks to the end. */
.handover-user-row .handover-user-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}
.handover-user-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    flex: 0 0 auto;
}

.handover-user-row--toggle .handover-user-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
    opacity: 0.6;
    font-size: 1.1rem;
    line-height: 1;
}
.handover-user-row--toggle[aria-expanded="true"] .handover-user-chevron {
    transform: rotate(180deg);
}

/* Detail-Bereich (ausgeklappt) */
.handover-detail {
    padding: var(--space-md);
    border-top: 1px solid rgba(0,0,0,0.08);
    background: rgba(0,0,0,0.015);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.handover-detail[hidden] {
    display: none;
}

/* Controls-Bar: Datum + Mass-Button auf einer Zeile (desktop) */
.handover-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-md);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.handover-date-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1 1 auto;
    min-width: 200px;
}
.handover-date-label {
    font-size: 0.95rem;
    font-weight: 600;
}
.handover-date-hint {
    display: inline;
    font-weight: 400;
    color: var(--color-text-muted, #6b6258);
    margin-inline-start: 0.4rem;
}
.handover-date-input {
    align-self: flex-start;
    padding: 0 0.7rem;
    height: 40px;
    min-height: 40px;
    box-sizing: border-box;
    font-size: 1rem;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    background: #fff;
    font-family: inherit;
}

/* Mass + Pro-Buch Buttons (gemeinsame Basis) */
.handover-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0 0.9rem;
    height: 40px;
    min-height: 40px;
    box-sizing: border-box;
    background: var(--color-accent, #a05a2c);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
    text-align: center;
    text-decoration: none;
}
.handover-btn:hover:not(:disabled) {
    filter: brightness(1.08);
}
.handover-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.handover-btn:focus-visible {
    outline: 2px solid var(--color-accent, #a05a2c);
    outline-offset: 2px;
}

/* Mass-Action: dezenter (dunkel + schmaler), aber präsent dank voller Breite. */
.handover-btn--mass {
    background: var(--color-text, #2c2520);
    flex: 1 1 auto;
    min-width: 200px;
}

/* Print-Button (Vorbereitungs-Liste für Bibi): outlined dezenter Stil
   damit er nicht mit dem prominenten Mass-Mark konkurriert. */
.handover-btn--print {
    background: transparent;
    color: var(--color-text-muted, #6b6258);
    border: 1px solid rgba(0,0,0,0.18);
}
.handover-btn--print:hover {
    background: rgba(0,0,0,0.04);
    color: var(--color-text);
    border-color: rgba(0,0,0,0.3);
}

/* Person-Filter-Bar oben auf der Übergaben-Page. */
.handover-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 var(--space-md);
    padding: 0 0.8rem;
    background: var(--color-bg, #fff);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: var(--radius-md);
    max-width: 360px;
}
.handover-filter .material-icon {
    color: var(--color-text-muted);
    font-size: 1.2em;
    margin: 0;
}
.handover-filter-input {
    flex: 1 1 auto;
    border: none;
    background: transparent;
    padding: 0.6rem 0;
    font-size: 0.95rem;
    font-family: inherit;
    color: inherit;
    outline: none;
    min-width: 0;
}
.handover-filter-input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.7;
}
.handover-filter-empty {
    font-style: italic;
}

/* Buch-Liste innerhalb des Detail-Bereichs.
   Aufbau analog zur Catalog-Listen-Ansicht (.book-grid--list) — CSS-Grid mit
   direction:rtl, sodass arabische Titel rechts beginnen wie gewohnt.
   Spalten (visuell von rechts nach links wegen RTL):
     1. Cover (50px)
     2. Title (1fr, ellipsis)
     3. Author (1fr, ellipsis)
     4. Year (60px)
     5. Shelf (auto)
     6. Action button (auto, ganz links visuell) */
.handover-list {
    display: flex;
    flex-direction: column;
    margin-top: 0.25rem;
}
.handover-list-row {
    display: grid;
    /* Catalog-style reading flow in RTL: cover → title → author → year → action.
       Cover is grid-column 1 = visually rightmost in RTL, action visually leftmost. */
    grid-template-columns: 60px minmax(0, 1.5fr) minmax(0, 1fr) 60px auto;
    grid-template-areas:
        "cover title author year action"
        "cover warning warning warning warning";
    align-items: center;
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    direction: rtl;
}

.handover-list-warning {
    grid-area: warning;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    background: #fff3e0;
    border: 2px solid #ef6c00;
    border-radius: 0.3rem;
    font-family: 'Cairo', var(--font-arabic);
    font-size: 0.95rem;
    font-weight: 700;
    color: #b85c1f;
    justify-self: start;
    align-self: start;
    margin-top: 4px;
}
.handover-list-warning .material-icon {
    font-size: 1.2rem;
    color: #ef6c00;
}
.handover-list-row:last-child {
    border-bottom: none;
}

/* Action-cell: button + shelf side-by-side, both same height. */
.handover-list-action {
    grid-area: action;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-self: start;
}

/* Desktop: Meta-Wrapper als display:contents — Children rendern direkt im Grid. */
.handover-list-meta { display: contents; }

.handover-list-cover {
    grid-area: cover;
    justify-self: start;
}
.handover-list-year {
    grid-area: year;
    direction: ltr;
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.handover-list-author {
    grid-area: author;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.handover-list-title {
    grid-area: title;
    font-family: 'Cairo', var(--font-arabic);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-accent-dark, #6e3d1f);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Cover-Thumb auf Desktop etwas größer als die ursprünglichen 40px. */
.handover-list-cover .handover-cover-thumb {
    width: 60px;
    height: 90px;
}

/* Mark-Button + Shelf: EXAKT gleiche Höhe via expliziter height + border-box. */
.handover-btn--single {
    height: 36px;
    min-height: 36px;
    padding: 0 0.9rem;
    box-sizing: border-box;
    line-height: 1;
}
.handover-list-shelf {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    min-height: 36px;
    padding: 0 0.7rem;
    box-sizing: border-box;
    font-size: 0.9rem;
    font-weight: 600;
    direction: ltr;
    color: var(--color-text-muted);
    background: rgba(0,0,0,0.04);
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: var(--radius-sm);
    line-height: 1;
}
/* Existing inner shelf-badge has its own styling — neutralize so the outer
   chip-wrapper looks clean and matches the button visually. */
.handover-list-shelf .shelf-badge {
    padding: 0;
    background: transparent;
    border: none;
    color: inherit;
    font-weight: inherit;
}

/* Single-Button: outlined style, nutzt .handover-btn-base (40px). */
.handover-btn--single {
    background: transparent;
    color: var(--color-accent, #a05a2c);
    border: 1px solid var(--color-accent, #a05a2c);
}
.handover-btn--single:hover:not(:disabled) {
    background: var(--color-accent, #a05a2c);
    color: #fff;
    filter: none;
}

/* Unmark-Button in Bereits-abgeholt-Sektion: outlined warning-style
   (gedämpftes Orange/Amber). Reversible Aktion → keine destruktiv-rote Optik. */
.handover-btn--unmark {
    background: transparent;
    color: #b85c00;
    border: 1px solid #b85c00;
}
.handover-btn--unmark:hover:not(:disabled) {
    background: #b85c00;
    color: #fff;
    filter: none;
}

/* Inline-Date-Input in Bereits-abgeholt-Detail-Rows.
   Höhe identisch zu den Buttons damit Action-Cell visuell aufgeräumt aussieht. */
.handover-date-input--inline {
    height: 40px;
    min-height: 40px;
    padding: 0 0.5rem;
    width: 130px;
    box-sizing: border-box;
    font-size: 0.9rem;
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: var(--radius-sm);
    background: #fff;
    font-family: inherit;
}

/* Completed-Section row: leicht gedämpft + abgeschlossener Eindruck. */
.handover-list-row--completed {
    opacity: 0.92;
}
.handover-list-row--completed .handover-list-title {
    color: var(--color-text);
}

/* Cover-Thumb in der Liste etwas kleiner als initial. */
.handover-list-cover .handover-cover-thumb {
    width: 40px;
    height: 60px;
}
.handover-list-cover .handover-cover-thumb--missing { font-size: 1.2rem; }

/* Mobile: Card-Layout pro Buch — Cover seitlich + 3 Zeilen-Stack daneben.
   Standard-Mobile-Pattern, lässt Title sauber umbrechen, Meta-Streifen
   darunter, Button als 3. Zeile. */
@media (max-width: 640px) {
    .handover-controls { flex-direction: column; align-items: stretch; }
    .handover-btn--mass { min-width: 0; }

    .handover-list-row {
        grid-template-columns: minmax(0, 1fr) 70px;
        grid-template-areas:
            "title   cover"
            "meta    cover"
            "warning cover"
            "action  cover";
        column-gap: 12px;
        row-gap: 6px;
        padding: 12px 0;
        align-items: start;
    }

    .handover-list-warning {
        font-size: 0.9rem;
        padding: 0.3rem 0.6rem;
    }

    .handover-list-cover {
        grid-area: cover;
        align-self: start;
        justify-self: start;
    }
    .handover-list-cover .handover-cover-thumb {
        width: 70px;
        height: 100px;
    }

    /* Shelf lives inside .handover-list-action on mobile too — keep its grid
       placement neutral, the parent flex handles the row layout. */
    .handover-list-shelf {
        grid-column: auto;
    }

    .handover-list-title {
        grid-area: title;
        white-space: normal;
        text-overflow: clip;
        overflow: visible;
        line-height: 1.3;
        font-size: 1.05rem;
    }

    /* Meta-Zeile: HTML-Reihenfolge ist author → year → shelf.
       Mit direction:rtl rendern sie visually right-to-left:
       author rechts, year mitte, shelf links. Items nur via gap getrennt
       (keine ::after Trennstriche — die wurden bei wrapping/empty fragil). */
    .handover-list-meta {
        display: flex;
        grid-area: meta;
        align-items: baseline;
        gap: 0.6rem;
        font-size: 0.85rem;
        flex-wrap: wrap;
        direction: rtl;
        justify-content: flex-start;
        color: var(--color-text-muted, #6b6258);
    }
    .handover-list-meta > * {
        grid-column: auto;
        font-size: 0.85rem;
        color: inherit;
    }
    .handover-list-meta .handover-list-author {
        direction: rtl;
        font-family: var(--font-arabic);
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .handover-list-meta .handover-list-year {
        direction: ltr;
        unicode-bidi: isolate;
    }

    .handover-list-action {
        grid-area: action;
        justify-self: start;
        flex-wrap: wrap;
        gap: 6px;
        max-width: 100%;
    }
    .handover-list-action .handover-btn--single {
        padding: 0 1.2rem;
    }
    /* In Bereits-abgeholt-Section auf Mobile: Date-Input kompakter,
       Action-Cell darf wrappen statt überzulaufen. */
    .handover-list-row--completed .handover-date-input--inline {
        width: 115px;
        font-size: 0.85rem;
    }
    .handover-list-row--completed .handover-btn--unmark {
        padding: 0 0.7rem;
    }
}

/* Kleine Cover-Thumb in der Buch-Karte. */
.handover-cover-thumb {
    flex: 0 0 auto;
    width: 56px;
    height: 84px;
    padding: 0;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: var(--radius-sm);
    background: #f4ede2;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.handover-cover-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.handover-cover-thumb:hover,
.handover-cover-thumb:focus-visible {
    border-color: var(--color-accent, #a05a2c);
    outline: none;
}
.handover-cover-thumb--missing {
    font-size: 1.8rem;
    opacity: 0.4;
    cursor: default;
}

/* Cover-Lightbox: schlanker eigener Overlay (nicht die Catalog-Lightbox).
   Finding 8 Fix: Large-Viewport-Units statt `inset: 0`, sonst „atmet" der
   Overlay mit der iOS-Chrome-Toolbar-Animation. */
.handover-cover-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    width: 100lvw;
    height: 100vh;
    height: 100lvh;
    background: rgba(0,0,0,0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    cursor: zoom-out;
}
.handover-cover-lightbox[hidden] {
    display: none;
}
.handover-cover-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    border-radius: var(--radius-sm);
    cursor: default;
}
.handover-cover-lightbox__close {
    position: absolute;
    top: max(var(--space-md), env(safe-area-inset-top, 0));
    right: max(var(--space-md), env(safe-area-inset-right, 0));
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.handover-cover-lightbox__close:hover,
.handover-cover-lightbox__close:focus-visible {
    background: rgba(255,255,255,0.28);
    outline: none;
}

.handover-user-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.handover-user-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    height: 2.2rem;
    padding: 0 0.6rem;
    border-radius: 9999px;
    background: var(--color-accent, #a05a2c);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
}
.handover-section--completed .handover-user-count {
    background: rgba(0,0,0,0.4);
}

/* ─── Backups page ──────────────────────────────────────────── */

.backups-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-md) 0 var(--space-lg);
    flex-wrap: wrap;
}
.backups-retention-hint {
    margin: 0;
    font-size: 0.88rem;
}

.backups-table .col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: end;
}
.backups-table .col-actions form,
.backups-table .col-actions a,
.backups-table .col-actions button {
    margin-inline-start: 0.25rem;
}
.backups-table .num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.backup-date {
    font-weight: 600;
    margin-inline-end: 0.5rem;
}
.backup-time {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.backup-reason {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--color-shade);
    color: var(--color-text);
    white-space: nowrap;
}
.backup-reason--auto {
    background: var(--color-shade);
    color: var(--color-text-muted);
}
.backup-reason--manual {
    background: var(--color-accent);
    color: white;
}
.backup-reason--pre-csv-import,
.backup-reason--pre-clear-log,
.backup-reason--pre-user-delete,
.backup-reason--pre-deadline-change {
    background: #d97a14;
    color: white;
}
.backup-reason--pre-restore {
    background: #5a7d9a;
    color: white;
}

.restore-modal-title {
    margin: 0 0 var(--space-sm);
    font-size: 1.1rem;
}
.restore-modal-msg {
    margin: 0 0 var(--space-sm);
    font-weight: 600;
}
.restore-modal-instructions {
    margin: 0 0 var(--space-sm);
    font-size: 0.88rem;
    line-height: 1.45;
}

/* Reservation-count diff block in the restore-confirm modal.
   Shows live count vs. backup count + an explicit loss/gain line. */
.restore-diff {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-shade);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    margin: 0 0 var(--space-md);
    font-size: 0.92rem;
}
.restore-diff-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
}
.restore-diff-label {
    color: var(--color-text-muted, #7A7167);
}
.restore-diff-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.restore-diff-result {
    border-top: 1px solid var(--color-shade);
    margin-top: 4px;
    padding-top: 8px;
}
.restore-diff-result--loss {
    color: #B33A2D;  /* warm red — matches existing alert tones, not jarring */
}
.restore-diff-result--loss .restore-diff-label,
.restore-diff-result--loss .restore-diff-value {
    color: inherit;
}
.restore-diff-result--gain {
    color: #4A7A2A;  /* muted green — uncommon case (restoring a wipe) */
}
.restore-diff-result--gain .restore-diff-label,
.restore-diff-result--gain .restore-diff-value {
    color: inherit;
}
.restore-diff-result--neutral .restore-diff-label,
.restore-diff-result--neutral .restore-diff-value {
    color: var(--color-text-muted, #7A7167);
}

@media (max-width: 768px) {
    .backups-table .col-actions {
        text-align: start;
    }
    .backups-table .col-actions form,
    .backups-table .col-actions a,
    .backups-table .col-actions button {
        margin-inline-start: 0;
        margin-inline-end: 0.25rem;
    }
}

/* ─── Local dev indicator (only rendered when on localhost) ─── */

.env-indicator {
    position: fixed;
    bottom: var(--space-md);
    left: var(--space-md);
    z-index: 9999;
    background: #2a7a3a;
    color: white;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    opacity: 0.7;
    pointer-events: auto;
    user-select: none;
    transition: opacity 0.15s;
}
.env-indicator:hover { opacity: 1; }

/* ─── Error log ──────────────────────────────────────────────── */

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5em;
    height: 1.5em;
    padding: 0 0.4em;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    color: white;
}
.nav-badge--alert { background: #c62828; }

.errors-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin: var(--space-md) 0;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-shade);
}
.errors-toolbar__count {
    color: var(--color-text-muted);
    font-size: 0.92rem;
}
.errors-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
}
.errors-toolbar__divider {
    width: 1px;
    height: 1.4rem;
    background: var(--color-shade);
    margin: 0 var(--space-xs);
}

.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn-xs { padding: 0.1rem 0.4rem; font-size: 0.8rem; }
.btn-link {
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-accent);
    cursor: pointer;
    border-radius: var(--radius-sm);
}
.btn-link:hover { background: var(--color-shade); }

.filter-group--grow { flex: 1 1 220px; }

.errors-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.error-entry {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: flex-start;
    gap: var(--space-sm);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
.error-entry:hover {
    border-color: var(--color-shade);
    background: var(--color-bg);
}
.error-entry.is-selected {
    background: var(--color-bg-alt);
    border-color: var(--color-shade-dark);
}
.error-entry.is-seen { color: var(--color-text-muted); }
.error-entry.is-seen .error-entry__message { color: var(--color-text-muted); }

.error-entry__select {
    display: flex;
    align-items: center;
    padding-top: 0.3rem;
    cursor: pointer;
}
.error-entry__select input { cursor: pointer; }

.error-entry__seen-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.2rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.error-entry__seen-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent);
    transition: background 0.15s;
}
.error-entry.is-seen .error-entry__seen-dot {
    background: transparent;
    border: 1.5px solid var(--color-shade-dark);
}
.error-entry__seen-toggle:hover .error-entry__seen-dot {
    transform: scale(1.2);
}

.error-entry__main { min-width: 0; }

.error-entry__top {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-sm);
    margin-bottom: 0.4rem;
}

.error-sev {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    background: var(--color-shade);
    color: var(--color-text);
    flex-shrink: 0;
    min-width: 8.5em;
    margin-inline-end: 0.6rem;
    text-align: center;
    box-sizing: border-box;
}
.error-sev--fatal,
.error-sev--parse,
.error-sev--error { background: #c62828; color: white; }
.error-sev--warning { background: #d97a14; color: white; }
.error-sev--notice,
.error-sev--strict { background: #5a7d9a; color: white; }
.error-sev--deprecated { background: #8a8278; color: white; }
.error-entry.is-seen .error-sev { opacity: 0.6; }

.error-time {
    display: inline-flex;
    gap: 0.6rem;
    align-items: baseline;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1;
    color: var(--color-text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}
.error-time__day { color: var(--color-accent); text-transform: uppercase; }
.error-time__date { color: var(--color-text-muted); }
.error-time__time { color: var(--color-text); }
.error-entry.is-seen .error-time__day { color: var(--color-text-muted); }
.error-entry.is-seen .error-time__time { color: var(--color-text-muted); }

.error-file {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    word-break: break-all;
    flex: 1 1 auto;
    min-width: 0;
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 0.15rem 0.4rem;
    font-size: 0.85rem;
}
.btn-ghost:hover { background: var(--color-shade); color: var(--color-text); }

.error-entry__message {
    margin: 0;
    padding: 0.5rem 0.7rem;
    background: var(--color-bg-alt);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-x: auto;
    color: var(--color-text);
}
.error-entry.is-unseen .error-entry__message { background: var(--color-bg-alt); }

@media (max-width: 768px) {
    /* Filters: prevent flex-basis from inflating column heights */
    .filter-group,
    .filter-group--grow { flex: 0 0 auto; }

    /* Toolbar: stack vertically with comfortable spacing, hide vertical dividers */
    .errors-toolbar { flex-direction: column; align-items: stretch; }
    .errors-toolbar__actions {
        justify-content: flex-start;
        gap: var(--space-sm);
    }
    .errors-toolbar__divider { display: none; }

    /* Entry header: explicit row layout with breathing room when wrapping */
    .error-entry__top { row-gap: var(--space-sm); column-gap: var(--space-sm); }
    .error-time { flex-basis: 100%; padding-top: 0.2rem; }
    .error-file { flex-basis: 100%; padding-top: 0.15rem; }
}

/* ─── Print ───────────────────────────────────────────────────── */

@media print {
    .site-header, .site-footer, .nav-toggle, .lang-switcher,
    .search-bar, .btn, .book-actions, .admin-nav, .export-toolbar {
        display: none !important;
    }
    body { background: white; }
    .book-card { box-shadow: none; border: 1px solid #ccc; }
}

/* ═══════════════════════════════════════════════════════════════
   View Mode Switcher
   ═══════════════════════════════════════════════════════════════ */

.view-switcher {
    display: inline-flex;
    background: var(--color-bg-alt);
    border-radius: var(--radius-md);
    padding: 2px;
    gap: 2px;
    flex-shrink: 0;
}

.view-btn {
    border: none;
    background: transparent;
    border-radius: calc(var(--radius-md) - 2px);
    padding: 5px 8px;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.view-btn:hover { color: var(--color-text); background: var(--color-shade); }

.view-btn.active {
    background: var(--color-white);
    color: var(--color-accent-dark);
    box-shadow: var(--shadow-sm);
}

.view-btn .material-icon { margin: 0; font-size: 1.1rem; }

/* ─── List View ───────────────────────────────────────────────── */

.book-grid--list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.book-grid--list .book-card {
    display: grid;
    grid-template-columns: 1fr 220px 55px 160px;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--color-shade);
    direction: rtl;
}

/* Admin: zusätzliche schmale Shelf-Spalte (Spalte 4), Aktionen rücken auf 5. */
.book-grid--list.book-grid--admin .book-card {
    grid-template-columns: 1fr 220px 55px 48px 160px;
}

.book-grid--list .book-card:hover {
    transform: none;
    box-shadow: none;
    background: var(--color-bg-alt);
}

.book-grid--list .book-title {
    grid-column: 1;
    font-size: 1rem;
    margin-bottom: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-grid--list .book-meta { display: none; }

.book-grid--list .book-meta[data-field="author"] {
    grid-column: 2;
    display: block;
    min-width: 0;
    margin-bottom: 0;
    overflow: hidden;
}

.book-grid--list .book-meta[data-field="author"] .meta-label { display: none; }
.book-grid--list .book-meta[data-field="author"] .meta-value {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.book-grid--list .book-meta[data-field="year"] {
    grid-column: 3;
    display: block;
    margin-bottom: 0;
    text-align: center;
}

.book-grid--list .book-meta[data-field="year"] .meta-label { display: none; }
.book-grid--list .book-meta[data-field="year"] .meta-value {
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

.book-grid--list .book-actions {
    grid-column: 4;
    margin-top: 0;
    padding-top: 0;
    justify-content: flex-start;
}
/* Admin: Aktionen in Spalte 5 (Shelf-Spalte 4 schiebt sich davor). */
.book-grid--list.book-grid--admin .book-actions {
    grid-column: 5;
}

/* Anti-Tanz: Button/Pille füllt die feste Aktions-Zelle komplett aus und
   bricht nie um — beim Hover-Textwechsel ändert sich weder Breite noch
   Zeilenzahl, die Tabelle bleibt ruhig. */
.book-grid--list .book-actions > * {
    width: 100%;
}
.book-grid--list .book-actions .btn-reserve-unified,
.book-grid--list .book-actions .badge {
    padding: 4px 14px;
    font-size: 0.82rem;
    line-height: 1.3;
    display: block;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Shelf-Badge in der Liste: eigene Spalte (4), direkt vor der Status-Pille. */
.book-grid--list .book-shelf-line {
    grid-column: 4;
    margin: 0;
    display: flex;
    justify-content: center;
}
.book-grid--list .book-shelf-line .shelf-multi {
    flex-wrap: wrap;          /* der eine Multi-Shelf-Eintrag darf hier umbrechen */
    justify-content: center;
}

/* List view on medium screens: narrower author column */
@media (max-width: 900px) {
    .book-grid--list .book-card {
        grid-template-columns: 1fr 160px 50px 140px;
    }
    .book-grid--list.book-grid--admin .book-card {
        grid-template-columns: 1fr 160px 50px 44px 140px;
    }
}

/* List view on mobile: lineares Stapeln — Titel + Autor volle Breite
   übereinander, letzte Zeile = Shelf-Badge links ↔ Status-Button rechts.
   Die Admin-Selektoren sind hier mit aufgeführt, damit sie die spezifischere
   5-Spalten-Regel aus der ≤900px-Media-Query (gilt auch <600px) überstimmen. */
@media (max-width: 600px) {
    .book-grid--list .book-card,
    .book-grid--list.book-grid--admin .book-card {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
        gap: 6px 10px;
        padding: 12px;
        align-items: center;
    }

    .book-grid--list .book-title {
        grid-column: 1 / -1;
        grid-row: 1;
        white-space: normal;
        font-size: 1rem;
        line-height: 1.4;
    }

    .book-grid--list .book-meta[data-field="author"] {
        grid-column: 1 / -1;
        grid-row: 2;
    }
    .book-grid--list .book-meta[data-field="author"] .meta-value {
        font-size: 0.8rem;
        color: var(--color-text-muted);
    }

    .book-grid--list .book-meta[data-field="year"] {
        display: none;
    }

    /* Letzte Zeile: Status-Button rechts (Spalte 1 = rechts bei RTL). */
    .book-grid--list .book-actions,
    .book-grid--list.book-grid--admin .book-actions {
        grid-column: 1;
        grid-row: 3;
        margin: 0;
    }

    /* Letzte Zeile: Shelf-Badge links gegenüber (Spalte 2 = links bei RTL, nur Admin). */
    .book-grid--list .book-shelf-line {
        grid-column: 2;
        grid-row: 3;
        justify-content: flex-start;
    }

    /* Mobile: Buttons in normaler, inhaltsbasierter Breite — nicht über die
       ganze Zeile gestreckt (der width:100%-Anti-Tanz-Fix gilt nur Desktop). */
    .book-grid--list .book-actions > * {
        width: auto;
    }
    .book-grid--list .book-actions .btn-reserve-unified,
    .book-grid--list .book-actions .badge {
        display: inline-block;
        width: auto;
        min-width: auto;
    }
}

/* ─── Compact View ────────────────────────────────────────────── */

.book-grid--compact {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

@media (max-width: 900px) {
    .book-grid--compact {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 600px) {
    .book-grid--compact {
        grid-template-columns: repeat(2, 1fr);
    }
}

.book-grid--compact .book-card { padding: 10px 12px; }

.book-grid--compact .book-title {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.book-grid--compact .book-meta[data-field="publisher"],
.book-grid--compact .book-meta[data-field="volumes"],
.book-grid--compact .book-meta[data-field="edition"] { display: none; }

.book-grid--compact .meta-value {
    font-size: 0.9rem;
}

.book-grid--compact .btn-reserve-unified {
    padding: 4px 12px;
    font-size: 0.8rem;
    min-width: auto;
}

/* ═══════════════════════════════════════════════════════════════
   Dark Mode — Warm Earth Tones
   ═══════════════════════════════════════════════════════════════ */

[data-theme="dark"] {
    --color-bg:          #1A1612;
    --color-bg-alt:      #241E18;
    --color-white:       #2A2218;
    --color-shade:       #342C22;
    --color-shade-dark:  #4A3E30;
    --color-text:        #EDE4D5;
    --color-text-muted:  #9A8A76;
    --color-heading:     #E0D5C5;
    --color-accent:      #D4943D;
    --color-accent-dark: #E8B060;
    --color-accent-light:#D4943F;
    --color-success:     #4E9465;
    --color-success-bg:  #1B3020;
    --color-danger:      #D45050;
    --color-danger-bg:   #2E1A18;
    --color-warning:     #D4943D;
    --color-warning-bg:  #2A1E10;
    --color-info:        #6A9BB5;
    --color-info-bg:     #162030;
    --color-reserved:    #7A6B55;
    --shadow-sm:         0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md:         0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg:         0 8px 24px rgba(0, 0, 0, 0.5);
}

/* Hardcoded colour overrides for dark mode */
[data-theme="dark"] .site-header {
    border-bottom-color: var(--color-shade);
}

[data-theme="dark"] .book-card--mine {
    background: var(--color-success-bg);
}

[data-theme="dark"] mark.search-highlight {
    background: #6B4C18;
    color: #F5DDB0;
}

[data-theme="dark"] .data-table th {
    background: var(--color-bg-alt);
}

/* Alert text — hardcoded dark colours are invisible on dark alert backgrounds */
[data-theme="dark"] .alert-success { color: var(--color-success); }
[data-theme="dark"] .alert-error   { color: var(--color-danger); }
[data-theme="dark"] .alert-warning { color: var(--color-warning); }
[data-theme="dark"] .alert-info    { color: var(--color-info); }

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

/* Fix: the class is .modal-box, not .modal */
[data-theme="dark"] .modal-box {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-shade-dark);
}

[data-theme="dark"] .user-card__label {
    color: var(--color-text-muted);
}

/* --color-white is the dark surface colour in dark mode, so all buttons/badges
   that write colour: var(--color-white) on a coloured bg need a light override */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .btn-success,
[data-theme="dark"] .btn-danger,
[data-theme="dark"] .btn-danger:hover,
[data-theme="dark"] .btn-outline:hover,
[data-theme="dark"] .btn-reserve-unified--mine,
[data-theme="dark"] .btn-reserve-unified--available:hover,
[data-theme="dark"] .btn-reserve-unified--hover-cancel,
[data-theme="dark"] .badge-reserved-admin {
    color: #F0E8DA;
}

/* ─── Theme Toggle Button ─────────────────────────────────────── */

.theme-toggle {
    background: var(--color-bg-alt);
    border: none;
    border-radius: var(--radius-md);
    padding: 5px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    transition: background 0.2s, color 0.2s;
    height: 32px;
    width: 36px;
}

.theme-toggle:hover { background: var(--color-shade); color: var(--color-text); }

.theme-toggle-track {
    position: relative;
    width: 20px;
    height: 20px;
    overflow: hidden;
}

.theme-icon {
    font-family: 'Material Symbols Outlined';
    font-size: 1.15rem;
    font-weight: normal;
    font-style: normal;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    direction: ltr;
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s;
}

/* Light mode: sun centred, moon hidden below */
.theme-icon--sun  { transform: translate(-50%, -50%); opacity: 1; }
.theme-icon--moon { transform: translate(-50%, 150%);  opacity: 0; }

/* Dark mode: moon centred, sun hidden above */
[data-theme="dark"] .theme-icon--sun  { transform: translate(-50%, -150%); opacity: 0; }
[data-theme="dark"] .theme-icon--moon { transform: translate(-50%, -50%);  opacity: 1; }

/* ─── Email Admin ─────────────────────────────────────────────── */

.email-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-shade);
    margin-bottom: var(--space-lg);
}
.email-tab {
    padding: var(--space-sm) var(--space-md);
    text-decoration: none;
    color: var(--color-text-muted);
    font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}
.email-tab:hover {
    color: var(--color-text);
}
.email-tab.active {
    color: var(--color-accent-dark);
    border-bottom-color: var(--color-accent-dark);
}

.email-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}
.email-controls__row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}
.email-controls__row > label {
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 70px;
}

/* Status badges */
.email-status {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}
.email-status--sent { color: var(--color-success, #2d7a3a); }
.email-status--pending { color: var(--color-accent-dark); }
.email-status--no-email { color: var(--color-text-muted); font-weight: 400; }
.email-status--failed { color: var(--color-danger, #c0392b); }

/* Textarea for template editor */
.form-textarea {
    min-height: 120px;
    resize: vertical;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}
.form-textarea--tall {
    min-height: 250px;
}

/* Variable reference */
.email-vars-ref {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-shade);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    font-size: 0.85rem;
    line-height: 2;
}
.email-vars-ref code {
    background: var(--color-white);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.82rem;
    margin-inline-end: 4px;
    border: 1px solid var(--color-border, #e0d8cc);
}

/* Preview modal */
.email-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.email-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}
.email-modal__content {
    position: relative;
    background: var(--color-white);
    border-radius: var(--radius-md, 8px);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    overflow: hidden;
}
.email-modal__header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-shade);
}
.email-modal__header h3 { margin: 0; font-size: 1rem; flex: 1; }
.email-modal__lang-bar {
    display: flex;
    gap: 4px;
}
.email-modal__lang {
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: background 0.15s, color 0.15s;
}
.email-modal__lang:hover { background: var(--color-shade); color: var(--color-text); }
.email-modal__lang.active {
    background: var(--color-accent-dark);
    color: #fff;
    border-color: var(--color-accent-dark);
}
.email-modal__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 0 4px;
    line-height: 1;
}
.email-modal__close:hover { color: var(--color-text); }
.email-modal__tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-shade);
}
.email-modal__case {
    padding: 2px 8px;
    margin-inline-end: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: none;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: background 0.15s, color 0.15s;
}
.email-modal__case:hover { background: var(--color-shade); color: var(--color-text); }
.email-modal__case.active {
    background: var(--color-accent-dark);
    color: #fff;
    border-color: var(--color-accent-dark);
}
.email-modal__tab {
    padding: var(--space-xs) var(--space-md);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.email-modal__tab.active {
    color: var(--color-accent-dark);
    border-bottom-color: var(--color-accent-dark);
}
.email-modal__body {
    flex: 1;
    overflow: auto;
}
.email-preview-pane {
    min-height: 300px;
}

/* Email test form inline */
.email-test-form {
    padding: var(--space-sm) 0;
}

@media (max-width: 600px) {
    .email-controls__row {
        flex-direction: column;
        align-items: stretch;
    }
    .email-controls__row > label {
        min-width: auto;
    }
    .email-modal__content {
        width: 98%;
        max-height: 90vh;
    }
}

/* ───────────────────────────────────────────────────────────
   Live-2-Dev-Sync (admin tool, dev-only)
   ─────────────────────────────────────────────────────────── */

.card {
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #E8E0D4);
    border-radius: 8px;
    padding: var(--space-md, 16px);
    margin-bottom: var(--space-md, 16px);
}
.card > h2:first-child,
.card > h3:first-child {
    margin-top: 0;
}

.text-success { color: var(--color-success, #2D7A3D); }
.text-warning { color: var(--color-warning, #B8702C); }

.live2dev-age-warn  { color: var(--color-warning, #B8702C); }
.live2dev-age-stale {
    color: var(--color-danger, #C0392B);
    font-weight: 600;
}

.card .data-table code {
    font-size: 0.85em;
}

@media (max-width: 600px) {
    /* On phones, let diff tables scroll horizontally instead of squishing */
    .card .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ─── Footer-Replay-Link ─────────────────────────────────────────
   Dezenter Link im Footer für logged-in Users zum erneuten
   Anschauen des Begrüßungsvideos. */
.footer-links {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}
.footer-link {
    font-size: 0.78rem;
    color: var(--color-shade-dark);
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.footer-link:hover {
    opacity: 1;
    text-decoration: underline;
}
[lang="ar"] .footer-link {
    font-family: var(--font-arabic-heading);
    font-style: normal;
    font-variation-settings: 'slnt' 0;
}

/* ─── Legal / imprint page ─────────────────────────────────────────
   Long-form prose page (/imprint.php). Constrained width for
   readability — legal text reads badly at full container width. */
.legal-page {
    max-width: 680px;
    margin: 0 auto;
    padding: var(--space-md) 0 var(--space-2xl);
    line-height: 1.7;
}
.legal-page h1 {
    margin-bottom: var(--space-md);
}
.legal-page h2 {
    margin-top: var(--space-2xl);
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--color-shade);
}
.legal-page h3 {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-xs);
}
.legal-page p,
.legal-page ul {
    margin-bottom: var(--space-md);
}
.legal-page ul {
    padding-inline-start: var(--space-lg);
}
.legal-page li {
    margin-bottom: var(--space-xs);
}
.legal-intro {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}
.legal-signoff {
    font-style: italic;
    color: var(--color-text-muted);
}
.legal-date {
    margin-top: var(--space-2xl);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ─── Auth-Loading-Overlay ───────────────────────────────────────
   Dezenter Vollbild-Overlay zwischen Login-Submit und der Navigation
   zu /welcome.php — damit User Feedback haben dass sie eingeloggt
   wurden und nicht in einen schwarzen Frame schießen. */
.auth-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    animation: auth-overlay-fade 0.25s ease forwards;
}
.auth-loading-text {
    color: #fff;
    font-family: var(--font-heading);
    font-size: 1.2rem;
    text-align: center;
}
[lang="ar"] .auth-loading-text {
    font-family: var(--font-arabic-heading);
}
@keyframes auth-overlay-fade {
    to { opacity: 1; }
}

/* ─── Übergaben 2 (admin/handovers2.php) ─────────────────────── */
/* Master-View: User-Tabelle mit Color-Cue links pro Zeile */
.handover2-master {
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--color-shade);
}
.handover2-master__head {
    display: grid;
    grid-template-columns: 18px 1fr 90px 90px 32px;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-alt, var(--color-shade));
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
}
.handover2-master__col--name { padding-inline-start: 4px; }
.handover2-master__col--num { text-align: end; }
.handover2-row {
    display: grid;
    grid-template-columns: 18px 1fr 90px 90px 32px;
    gap: var(--space-md);
    align-items: center;
    padding: var(--space-md);
    text-decoration: none;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-shade);
    transition: background 0.15s;
}
.handover2-row:hover {
    background: var(--color-bg-alt, rgba(0,0,0,0.03));
}
.handover2-row__cue {
    align-self: stretch;
    border-radius: 3px;
}
.handover2-row__name {
    font-family: var(--font-arabic-heading), var(--font-body);
    font-size: 1.15rem;
    font-weight: 600;
}
[lang="ar"] .handover2-row__name { font-family: var(--font-arabic-heading); }
.handover2-row__num {
    text-align: end;
    font-variant-numeric: tabular-nums;
    font-size: 1.05rem;
}
.handover2-row__num--total { font-weight: 600; }
.handover2-row__num--open  { color: var(--color-accent-dark, #b35a00); font-weight: 600; }
.handover2-row__num--done  { color: var(--color-success, #2d7a3d); }
.handover2-row__chevron {
    color: var(--color-text-muted);
    font-size: 1.5rem;
    justify-self: end;
}
/* Status-Cue-Farben */
.handover2-row--pending  .handover2-row__cue { background: #e8854a; }   /* orange */
.handover2-row--mixed    .handover2-row__cue { background: #d9b34a; }   /* gelb-amber */
.handover2-row--all_done .handover2-row__cue { background: #5fa86a; }   /* grün */
/* Header-Counts: tönt sich nach Status */
.handover2-detail__counts.handover2-row--pending  { border-inline-start: 6px solid #e8854a; }
.handover2-detail__counts.handover2-row--mixed    { border-inline-start: 6px solid #d9b34a; }
.handover2-detail__counts.handover2-row--all_done { border-inline-start: 6px solid #5fa86a; }

/* Legende unter Master-View */
.handover2-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg);
    margin-top: var(--space-lg);
    padding: var(--space-md);
    font-size: 0.9rem;
    color: var(--color-text-muted);
}
.handover2-legend__item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}
.handover2-legend__cue {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}
.handover2-legend__cue--pending  { background: #e8854a; }
.handover2-legend__cue--mixed    { background: #d9b34a; }
.handover2-legend__cue--all_done { background: #5fa86a; }

/* Detail-View */
.handover2-detail__back { margin-bottom: var(--space-md); }
.handover2-detail__topbar {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
}
.handover2-detail__head { display: flex; flex-direction: column; gap: var(--space-sm); }
/* 3 Counter-Cards mit Master-Status-Farben (Walid 2026-06-02) */
.handover2-detail__cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin: var(--space-md) 0 var(--space-lg);
}
/* Schmal: 3-Spalten zerquetscht die Open-Card mit dem internen side-by-side
   Counter+Button. Drum unter 900px alle 3 Cards untereinander stapeln —
   jede Card kriegt dann genug Breite (Walid 2026-06-03). */
@media (max-width: 900px) {
    .handover2-detail__cards {
        grid-template-columns: 1fr;
    }
}
.handover2-detail__card {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 2px solid;
    background: var(--color-white, #fff);
    text-decoration: none;
    color: inherit;
}
.handover2-detail__card--open {
    border-color: #e8854a;
    background: #fff8f0;
}
.handover2-detail__card--done {
    border-color: #5fa86a;
    background: #f3faf3;
}
.handover2-detail__card-row {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
}
.handover2-detail__card-num {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.handover2-detail__card--open  .handover2-detail__card-num,
.handover2-detail__card--open  .handover2-detail__card-of  { color: #b35a00; }
.handover2-detail__card--done  .handover2-detail__card-num,
.handover2-detail__card--done  .handover2-detail__card-of  { color: #2d7a3d; }
.handover2-detail__card-of {
    font-size: 1.4rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    opacity: 0.75;
}
.handover2-detail__card-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--color-text-muted);
    letter-spacing: 0.5px;
    font-weight: 600;
}
/* Open-Card: Counter + Mass-Button NEBENEINANDER (Walid 2026-06-03, Decision #1 v2).
   Card wird zum flex-row Container, Counter-Section + Action-Button als Geschwister. */
.handover2-detail__card--open {
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: var(--space-md);
}
.handover2-detail__card-counter {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    flex: 1 1 auto;
    min-width: 0;
}
/* Mass-Mark Action-Button — schmal mit Text-Wrap, sitzt auf der gegenüberliegenden
   Seite vom Counter (RTL: links / LTR: rechts). */
.handover2-detail__card-action {
    flex: 0 0 auto;
    max-width: 110px;
    align-self: stretch;
    white-space: normal;
    line-height: 1.2;
    text-align: center;
    font-size: 0.95rem;
    padding: var(--space-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}
.handover2-detail__card-action .material-icon {
    font-size: 1.4rem;
    margin: 0;
}
.handover2-detail__card-action.is-hidden { display: none; }
/* Print-Card: ganz andere Optik — eher ein großes interaktives Element. */
.handover2-detail__card--print {
    border-color: var(--color-shade);
    background: var(--color-white, #fff);
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.handover2-detail__card--print:hover {
    border-color: var(--color-accent-dark);
    background: var(--color-bg-alt, #f8f4ec);
    transform: translateY(-1px);
}
.handover2-detail__card-icon {
    font-size: 2rem;
    color: var(--color-accent-dark);
}
.handover2-detail__card--print .handover2-detail__card-label {
    color: var(--color-accent-dark);
    font-size: 1rem;
}

/* Bücher-Liste */
.handover2-books {
    list-style: none;
    padding: 0;
    margin: var(--space-lg) 0 0 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.handover2-book {
    display: grid;
    grid-template-columns: auto auto 1fr;
    grid-template-rows: 1fr auto;  /* row 1 = text (wachsend), row 2 = meta (natural) */
    grid-template-areas:
        "status cover text"
        "status cover meta";
    column-gap: var(--space-md);
    row-gap: var(--space-xs);
    align-items: start;
    padding: var(--space-md);
    border: 2px solid;
    border-radius: var(--radius-md);
    background: var(--color-white, #fff);
    transition: border-color 0.25s, background 0.25s;
}
.handover2-book__status-col { grid-area: status; }
/* Cover spannt beide Rows (text + meta) → Cover-Bottom = Meta-Bottom = shelf-tag-Bottom.
   Aspect-ratio fix + align-self: end damit Cover natural-size bleibt und nicht
   bei viel Text-Inhalt verzerrt wird (Walid 2026-06-02 v3). */
.handover2-book__cover {
    grid-area: cover;
    align-self: end;
    aspect-ratio: 2 / 3;
}
.handover2-book__text       { grid-area: text; }
.handover2-book__meta       { grid-area: meta; align-self: end; }
.handover2-book__cover {
    width: 70px;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius-sm, 4px);
    overflow: hidden;
    background: var(--color-shade);
    display: flex;
    align-items: center;
    justify-content: center;
}
.handover2-book__cover--btn {
    border: none;
    padding: 0;
    cursor: zoom-in;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.15s, box-shadow 0.15s;
}
.handover2-book__cover--btn:hover {
    transform: scale(1.04);
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}
.handover2-book__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.handover2-book__cover--missing {
    color: var(--color-text-muted);
    opacity: 0.5;
}
.handover2-book__cover--missing .material-icon {
    font-size: 1.8rem;
}
.handover2-book--open {
    border-color: #e8854a;
    background: #fff8f0;
}
.handover2-book--done {
    border-color: #5fa86a;
    background: #f3faf3;
}
/* Status-col enthält Tag → Datum → Action-Button als visuelles Paar (Walid 2026-06-02 v6).
   Tag = was ist (Info, subtle), Button = was kann ich tun (solid, clickable).
   Direkt untereinander damit das Hirn beides als Einheit liest.
   Tag+Datum sind im status-pair gruppiert damit Button via Grid woanders
   platziert werden kann wenn schmal (Walid 2026-06-02 v7). */
.handover2-book__status-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.handover2-book__status-pair {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.handover2-book__status-col .handover2-book__action {
    margin-top: var(--space-sm);  /* Atemraum zwischen Status-Info und Action */
}
/* Status-Tag: bewusst NICHT wie ein Button gestylt (Walid 2026-06-02).
   Kein gefüllter Solid-Background, keine Pille — nur farblicher Text +
   Icon mit zarter Tönung. So liest sich's klar als Info, nicht klickbar.
   Font-Size + line-height auf Title abgestimmt → Baseline-Match. */
.handover2-book__tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    font-weight: 700;
    font-size: 1.25rem;
    line-height: 1.3;
    letter-spacing: 0.3px;
}
.handover2-book__tag--open { color: #b35a00; }
.handover2-book__tag--done { color: #2d7a3d; }
.handover2-book__tag .material-icon {
    font-size: 1.25rem;
}
/* Datum-Zeile: Font-Size auf Author abgestimmt → Baseline-Match. */
.handover2-book__date {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95rem;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.handover2-book__date .material-icon {
    font-size: 1rem;
    opacity: 0.75;
}
/* Klickbares Datum (Done-Book) als Button — sieht aus wie das span, aber tappable.
   edit_calendar-Icon als Touch-Affordance (Walid 2026-06-03, Decision #2). */
.handover2-book__date--clickable {
    background: transparent;
    border: 1px solid transparent;
    padding: 4px 8px;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    min-height: 32px;
    transition: background 0.15s, border-color 0.15s;
}
.handover2-book__date--clickable:hover,
.handover2-book__date--clickable:focus-visible {
    background: rgba(45, 122, 61, 0.08);
    border-color: rgba(45, 122, 61, 0.3);
    outline: none;
}
.handover2-book__date--clickable:active {
    background: rgba(45, 122, 61, 0.15);
}
.handover2-book__date-edit-icon {
    font-size: 0.95rem !important;
    opacity: 0.6;
    margin-inline-start: 2px;
}
.handover2-book__text { min-width: 0; }
.handover2-book__title {
    font-family: var(--font-arabic-heading);
    font-size: 1.25rem;
    line-height: 1.3;
    margin-bottom: 4px;
}
.handover2-book__author {
    font-family: var(--font-arabic);
    font-size: 0.95rem;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}
.handover2-book__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    font-size: 0.85rem;
}
.handover2-book__shelf {
    background: var(--color-shade);
    padding: 2px 8px;
    border-radius: var(--radius-sm, 4px);
    font-weight: 600;
}
.handover2-book__vols--warn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #b35a00;
    font-weight: 600;
}
.handover2-book__vols--warn .material-icon { font-size: 1rem; }
.handover2-book__action { white-space: nowrap; }
.handover2-book__action .material-icon { font-size: 1.1rem; margin-inline-end: 4px; }
/* Unmark-Button: solid amber-Style (Walid 2026-06-02: outline schaut „durchsichtig" aus). */
.handover2-book__action--unmark {
    background: #d9b34a;
    color: #fff;
    border-color: #c19c30;
}
.handover2-book__action--unmark:hover { background: #c19c30; }

/* ─── Modals (Date-Confirm + Cover-Lightbox) ─────────────────── */
.handover2-modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 15, 10, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 700;
    padding: var(--space-md);
}
.handover2-modal[hidden] { display: none; }
.handover2-modal__panel {
    background: var(--color-white, #fff);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    max-width: 500px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.handover2-modal__title {
    margin: 0 0 var(--space-sm);
    font-size: 1.4rem;
    color: var(--color-accent-dark);
}
/* Book-Row: Cover-Thumb + Title in einer Box (Walid 2026-06-02 v8).
   Background + Padding wandern auf den Wrapper damit Cover und Titel
   gemeinsam von der hellen Hintergrund-Fläche umfasst werden. */
.handover2-modal__book-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: 0 0 var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--color-shade);
    border-radius: var(--radius-sm, 4px);
}
.handover2-modal__cover {
    width: 50px;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: var(--radius-sm, 4px);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    display: block;
}
.handover2-modal__cover[hidden] { display: none; }
.handover2-modal__book {
    flex: 1;
    margin: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    font-family: var(--font-arabic-heading);
    font-size: 1.15rem;
    direction: rtl;
    text-align: start;  /* RTL + start = rechts (war end = links) (Walid 2026-06-02 v8) */
    min-width: 0;
}
.handover2-modal__label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--space-xs);
    font-size: 1rem;
}
/* Date-Wrap = Flex-Container der Border/Background trägt; Input ist transparent
   ohne eigenen Border, flex: 1 1 0 + min-width: 0 → zuverlässiges Shrinking trotz
   iOS-Safari-Date-Input intrinsic min-width Quirk (Walid 2026-06-02 v11).
   Native ::-webkit-calendar-picker-indicator raus, Custom-Material-Symbol als
   echtes Flex-Sibling (Direction-Probleme vom .material-icon LTR-Override
   verschwinden weil Flex die Parent-Direction natürlich respektiert). */
.handover2-modal__date-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    box-sizing: border-box;
    background: #fffbed;
    border: 2px solid var(--color-shade);
    border-radius: var(--radius-sm, 6px);
    padding-inline-start: var(--space-md);
    cursor: pointer;
    transition: border-color 0.15s;
}
.handover2-modal__date-wrap:focus-within {
    border-color: #d9b34a;
}
.handover2-modal__date-icon {
    color: #b35a00;
    font-size: 1.5rem;
    flex-shrink: 0;
    pointer-events: none;  /* Klick geht durch zum Wrap-Handler */
    line-height: 1;
}
.handover2-modal__date-input {
    flex: 1 1 0;        /* nimmt verfügbaren Platz, schrinkt mit min-width: 0 */
    min-width: 0;       /* ohne das verhindert iOS-intrinsic-min-width das Shrinken */
    box-sizing: border-box;
    border: none;
    background: transparent;
    padding: var(--space-sm) var(--space-md);
    padding-inline-start: 0;
    font-size: 1.4rem;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    text-align: start;
    color: inherit;
    cursor: pointer;
    outline: none;
}
/* Native-Picker-Icon raus, Custom-Icon übernimmt */
.handover2-modal__date-input::-webkit-calendar-picker-indicator {
    display: none;
    -webkit-appearance: none;
    appearance: none;
}
.handover2-modal__hint {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin: var(--space-sm) 0 var(--space-lg);
}
.handover2-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}
/* Wenn Actions direkt nach Date-Wrap kommen (ohne Hint dazwischen), fehlt sonst
   die Trennung die der Hint normal als margin-bottom liefert (Walid 2026-06-03). */
.handover2-modal__date-wrap + .handover2-modal__actions {
    margin-top: var(--space-lg);
}

/* Anti-iOS-Synthetic-Italic-Bug: tritt auf iPhone UND iPad auf — Engine-bedingt,
   nicht viewport-abhängig. Drum universell, nicht innerhalb @media wrapped
   (Walid 2026-06-02 v12: war versehentlich nur unter 768px, iPad Pro Landscape
   ist 1366px → Fix griff dort nicht). Selber Pattern wie lightbox-info,
   siehe CLAUDE.md #9 + bestehender Workaround. */
.handover2-master, .handover2-master *,
.handover2-row, .handover2-row *,
.handover2-book, .handover2-book *,
.handover2-detail__topbar, .handover2-detail__topbar *,
.handover2-detail__head, .handover2-detail__head *,
.handover2-detail__cards, .handover2-detail__cards *,
.handover2-modal, .handover2-modal *,
.handover2-cover-modal, .handover2-cover-modal * {
    font-style: normal !important;
    font-variation-settings: 'slnt' 0 !important;
}

/* Mobile-Größen-Overrides: Date-Input kleiner + Panel-Padding reduziert,
   damit das Modal auf schmalen Viewports nicht aus den Rändern sprengt. */
@media (max-width: 768px) {
    .handover2-modal__panel       { padding: var(--space-md); }
    .handover2-modal__date-wrap   { padding-inline-start: var(--space-sm); gap: var(--space-xs); }
    .handover2-modal__date-icon   { font-size: 1.3rem; }
    .handover2-modal__date-input  {
        font-size: 1.2rem;
        padding: var(--space-xs) var(--space-sm);
        padding-inline-start: 0;
    }
    .handover2-modal__cover       { width: 44px; }
}

/* Cover-Lightbox: Fullscreen mit Backdrop */
.handover2-cover-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 10, 5, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 700;
    padding: var(--space-lg);
    gap: var(--space-md);
}
.handover2-cover-modal[hidden] { display: none; }
.handover2-cover-modal img {
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius-sm, 4px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.handover2-cover-modal__title {
    color: rgba(255, 245, 230, 0.9);
    font-family: var(--font-arabic-heading);
    font-size: 1.3rem;
    text-align: center;
    margin: 0;
    max-width: 90%;
}
.handover2-cover-modal__close {
    position: absolute;
    top: var(--space-md);
    inset-inline-end: var(--space-md);
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.handover2-cover-modal__close:hover { background: rgba(255,255,255,0.25); }
.handover2-cover-modal__close .material-icon { font-size: 1.6rem; }

/* Empty-State */
.handover2-empty {
    text-align: center;
    padding: var(--space-2xl) var(--space-md);
    color: var(--color-text-muted);
}
.handover2-empty .material-icon {
    font-size: 3rem;
    opacity: 0.4;
    margin-bottom: var(--space-sm);
}

@media (max-width: 900px) {
    .handover2-book__cover { width: 90px; }
}

/* ≤750px: Layout-Switch (Walid 2026-06-02 v7).
   Paired-Layout (Tag direkt über Button) bricht hier weil DE-Button breit ist
   („Als übergeben markieren" ≈ 220px) → status-col zu fett, Title gequetscht.
   Stattdessen: Status-Info (Tag+Datum) als Top-Zeile horizontal, Cover/Text/Meta
   in der Mitte, Button voll-breit unten als klare CTA. Wir nutzen
   `display: contents` auf status-col damit Tag-Pair und Button in verschiedene
   Grid-Areas wandern können ohne DOM-Restructure. */
@media (max-width: 750px) {
    .handover2-book {
        grid-template-columns: 90px 1fr;
        grid-template-rows: auto 1fr auto auto;
        grid-template-areas:
            "status status"
            "cover  text"
            "cover  meta"
            "btn    btn";
        column-gap: var(--space-md);
        row-gap: var(--space-xs);
    }
    .handover2-book__status-col { display: contents; }
    .handover2-book__status-pair {
        grid-area: status;
        flex-direction: row;
        align-items: center;
        gap: var(--space-md);
        margin-bottom: var(--space-sm);
    }
    .handover2-book__cover      { grid-area: cover; align-self: end; }
    .handover2-book__text       { grid-area: text; }
    .handover2-book__meta       { grid-area: meta; align-self: end; }
    .handover2-book__status-col .handover2-book__action {
        grid-area: btn;
        margin-top: var(--space-sm);
        width: 100%;
    }
}

@media (max-width: 700px) {
    .handover2-master__head { display: none; }
    .handover2-row {
        grid-template-columns: 18px 1fr auto auto 24px;
        gap: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
    }
    .handover2-row__name { font-size: 1rem; }
    .handover2-row__num { font-size: 0.95rem; min-width: 32px; }
    .handover2-book                  { grid-template-columns: 75px 1fr; }
    .handover2-book__cover           { width: 75px; }
    .handover2-detail__cards         { gap: var(--space-sm); }
    .handover2-detail__card          { padding: var(--space-sm); }
    .handover2-detail__card-num      { font-size: 1.4rem; }
    .handover2-detail__card-of       { font-size: 1rem; }
    .handover2-detail__card-label    { font-size: 0.7rem; }
}
