/* ═══════════════════════════════════════════
   Physiksammlung - Design System
   ═══════════════════════════════════════════ */

:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1a202c;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    padding-bottom: 72px; /* space for bottom nav */
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ─── Top Bar ─── */
.topbar {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}
.topbar-brand {
    color: white;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-username { font-size: 14px; opacity: 0.9; }
.topbar-logout { color: white; opacity: 0.8; display: flex; }
.topbar-logout:hover { opacity: 1; color: white; }

/* ─── Bottom Navigation ─── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card);
    display: flex;
    border-top: 1px solid var(--border);
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    font-size: 11px;
    color: var(--text-secondary);
    gap: 2px;
    min-height: 56px;
    justify-content: center;
    transition: color 0.2s;
}
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:hover { color: var(--primary); }
.bottom-nav-item svg { width: 22px; height: 22px; }

/* ─── Main Content ─── */
.main-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

/* ─── Messages ─── */
.messages {
    position: fixed; top: 16px; right: 16px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
    max-width: 400px; width: calc(100% - 32px);
    pointer-events: none;
}
.message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastIn 0.3s ease, toastOut 0.4s ease 3.6s forwards;
}
.message-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.message-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.message-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.message-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ─── Cards ─── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 12px;
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card-link { display: block; color: inherit; }
.card-link:hover { color: inherit; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.card-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}
.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.card-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ─── Kennung Badge ─── */
.kennung {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    background: #eef2ff;
    color: var(--primary-dark);
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

/* ─── Condition Badge ─── */
.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-gut { background: #ecfdf5; color: #065f46; }
.badge-beschaedigt { background: #fffbeb; color: #92400e; }
.badge-defekt { background: #fef2f2; color: #991b1b; }
.badge-unbekannt { background: #f1f5f9; color: #475569; }

/* Topic Badge */
.badge-topic { background: #f0f2f5; color: #475569; }

/* ─── Location Breadcrumb ─── */
.location {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.location a { color: var(--text-secondary); }
.location a:hover { color: var(--primary); }
.location-sep { color: #cbd5e1; }

/* ─── Search ─── */
.search-hero {
    text-align: center;
    padding: 32px 0 24px;
}
.search-hero h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.search-input-wrap {
    position: relative;
    max-width: 560px;
    margin: 0 auto;
}
.search-input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    outline: none;
    font-family: var(--font);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}
.search-input-wrap svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}
.search-results { margin-top: 16px; text-align: left; }
.search-section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin: 20px 0 8px;
}
.search-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 32px 0;
    font-size: 15px;
}

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}
.form-group .helptext {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 16px;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.form-group .errorlist {
    list-style: none;
    color: var(--danger);
    font-size: 13px;
    margin-top: 4px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-section {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 24px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

/* ─── Multi-Select Dropdown ─── */
.multi-select { position: relative; user-select: none; }
.filters .multi-select { min-width: 0; }
.multi-select-header {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 40px; padding: 6px 12px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--card); cursor: pointer; transition: border-color 0.2s;
    font-size: 14px;
}
.multi-select-header:hover { border-color: var(--text-secondary); }
.multi-select.open .multi-select-header {
    border-color: var(--primary); border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.multi-select-tags { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
.multi-select-placeholder { color: var(--text); line-height: 28px; }
.multi-select-tag {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; background: #e8f0fe; color: var(--primary);
    border-radius: 4px; font-size: 13px; line-height: 1.6;
}
.multi-select-tag-remove {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border: none; background: transparent;
    color: var(--primary); font-size: 14px; cursor: pointer; border-radius: 50%; padding: 0;
}
.multi-select-tag-remove:hover { background: #c5d8f8; }
.multi-select-arrow { flex-shrink: 0; margin-left: 8px; color: var(--text-secondary); transition: transform 0.2s; }
.multi-select.open .multi-select-arrow { transform: rotate(180deg); }
.multi-select-dropdown {
    display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
    background: var(--card); border: 1px solid var(--primary); border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); max-height: 260px; overflow-y: auto;
}
.multi-select.open .multi-select-dropdown { display: block; }
.multi-select-options { list-style: none; margin: 0; padding: 4px 0; }
.multi-select-options li { padding: 0; }
.multi-select-options label {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; cursor: pointer; transition: background 0.15s; font-size: 14px;
}
.multi-select-options label:hover { background: var(--bg); }
.multi-select-options input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    min-height: 44px;
    transition: all 0.2s;
    text-align: center;
    justify-content: center;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 36px; }
.btn-block { display: flex; width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ─── Page Headers ─── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}
.page-title { font-size: 20px; font-weight: 700; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); }

/* ─── Breadcrumb ─── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { color: #cbd5e1; }

/* ─── Filters ─── */
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filters select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-family: var(--font);
    min-height: 40px;
}

/* ─── Detail Page ─── */
.detail-header { margin-bottom: 20px; }
.detail-kennung { margin-bottom: 8px; }
.detail-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.detail-section {
    margin-top: 24px;
}
.detail-section-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.detail-description {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
}
.detail-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    font-size: 14px;
}
.detail-meta dt { color: var(--text-secondary); font-weight: 500; }
.detail-meta dd { color: var(--text); }

/* ─── Image Gallery ─── */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.gallery-item {
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    background: #f8fafc;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: fadeIn 0.2s ease;
}
.lightbox img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 300px;
    object-fit: contain;
}
.gallery-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}
.gallery-item:hover .gallery-delete { display: flex; }

/* ─── File Upload ─── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-top: 8px;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: #eef2ff;
}
.upload-zone input { display: none; }
.upload-zone svg { margin-bottom: 8px; }
.upload-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.upload-preview-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}
/* ─── Video Player ─── */
.video-player { margin: 12px 0; }
.video-player video { width: 100%; max-height: 500px; border-radius: var(--radius); background: #000; }
.video-caption { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* Responsive video embed (YouTube/Vimeo) */
.video-embed { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: var(--radius); }
.video-embed iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* ─── Upload Preview: Video ─── */
/* ─── Link List (dynamic add/remove) ─── */
.link-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 14px;
}
.link-list-item .link-type-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}
.link-list-item .link-type-badge.video { background: #eff6ff; color: var(--primary); }
.link-list-item .link-type-badge.link { background: #f0f2f5; color: #475569; }
.link-list-item .link-url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-list-item .remove-link {
    margin-left: auto;
    color: var(--danger);
    cursor: pointer;
    background: none;
    border: none;
    font-size: 18px;
    padding: 4px;
    flex-shrink: 0;
}
.link-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}
.link-add-row input[type="url"] {
    flex: 1;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    outline: none;
}
.link-add-row input[type="url"]:focus { border-color: var(--primary); }
.link-add-row select {
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    background: var(--card);
}

/* ─── Detail: Link section ─── */
.detail-links { display: flex; flex-direction: column; gap: 6px; }
.detail-link-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}
.detail-link-item svg { flex-shrink: 0; color: var(--text-secondary); }

.upload-preview-video {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #eff6ff;
    color: var(--primary);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    border: 1px solid var(--border);
}

/* ─── Gallery: Video item in edit form ─── */
.gallery-video {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #000;
}
.gallery-video video { width: 100%; max-height: 200px; display: block; }

/* ─── Gallery: PDF item in edit form ─── */
.gallery-pdf {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #fef2f2;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    padding: 12px;
}
.gallery-pdf-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--danger);
    text-align: center;
    word-break: break-all;
}

.upload-preview-pdf {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: #fef2f2;
    color: var(--danger);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid var(--border);
}

/* ─── Device Picker ─── */
.device-picker-search {
    position: relative;
    margin-bottom: 8px;
}
.device-picker-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 240px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}
.device-picker-results.show { display: block; }
.device-picker-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.device-picker-item:hover { background: var(--bg); }
.device-picker-item:last-child { border-bottom: none; }

.selected-devices { margin-top: 8px; }
.selected-device {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 14px;
}
.selected-device .kennung { font-size: 12px; }
.selected-device input[type="number"] {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    text-align: center;
}
.selected-device .remove-device {
    margin-left: auto;
    color: var(--danger);
    cursor: pointer;
    background: none;
    border: none;
    font-size: 18px;
    padding: 4px;
}

/* ─── Tree View (Admin) ─── */
.tree { list-style: none; }
.tree-item { margin-bottom: 4px; }
.tree-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid var(--border);
}
.tree-header:hover { background: var(--bg); }
.tree-toggle { transition: transform 0.2s; font-size: 12px; color: var(--text-secondary); }
.tree-header.open .tree-toggle { transform: rotate(90deg); }
.tree-name { flex: 1; font-weight: 500; }
.tree-count { font-size: 13px; color: var(--text-secondary); }
.tree-actions { display: flex; gap: 4px; }
.tree-actions a {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    color: var(--text-secondary);
}
.tree-actions a:hover { background: var(--bg); color: var(--primary); }
.tree-children {
    margin-left: 20px;
    margin-top: 4px;
    display: none;
}
.tree-children.open { display: block; }

/* ─── Confirm Delete ─── */
.confirm-delete {
    max-width: 480px;
    margin: 40px auto;
    text-align: center;
}
.confirm-delete h2 { margin-bottom: 16px; }
.confirm-delete p { color: var(--text-secondary); margin-bottom: 24px; }

/* ─── Login ─── */
body:has(.login-page) { padding: 0 !important; }
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    padding: 20px;
}
.login-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 32px;
    width: 100%;
    max-width: 400px;
}
.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
}
.login-card p {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}
.login-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 15px; margin-bottom: 16px; }

/* ─── Tables (Experiment Device List) ─── */
.device-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.device-table th {
    text-align: left;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    font-size: 13px;
}
.device-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.device-table tr:hover td { background: #f8fafc; }

/* ─── Responsive ─── */
@media (min-width: 768px) {
    .main-content { padding: 24px; }
    .search-hero { padding: 48px 0 32px; }
    .search-hero h1 { font-size: 28px; }
    .form-row { grid-template-columns: 1fr 1fr 1fr; }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (min-width: 1024px) {
    body { padding-bottom: 0; padding-top: 104px; }
    .topbar { position: fixed; top: 0; left: 0; right: 0; }
    .bottom-nav {
        position: fixed;
        top: 48px;
        bottom: auto;
        left: 0;
        right: 0;
        border-top: none;
        border-bottom: 1px solid var(--border);
        background: var(--card);
        justify-content: center;
        gap: 4px;
        padding: 0 16px;
        z-index: 99;
    }
    .bottom-nav-item {
        flex: 0 0 auto;
        flex-direction: row;
        padding: 12px 20px;
        font-size: 14px;
        gap: 8px;
        min-height: 48px;
        border-bottom: 3px solid transparent;
        border-radius: 0;
    }
    .bottom-nav-item.active {
        border-bottom-color: var(--primary);
        background: rgba(102, 126, 234, 0.06);
    }
    .bottom-nav-item:hover {
        background: rgba(102, 126, 234, 0.06);
    }
    .bottom-nav-item svg { width: 18px; height: 18px; }
    .main-content { max-width: 960px; }
}

/* ─── Pagination ─── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 0;
    font-size: 14px;
}
.pagination-link {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--primary);
    font-weight: 500;
}
.pagination-link:hover { background: var(--bg); color: var(--primary-dark); }
.pagination-info { color: var(--text-secondary); }

/* ─── Admin Stats ─── */
.admin-stats {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.stat-item {
    flex: 1;
    min-width: 80px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
}
.stat-value { display: block; font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-label { display: block; font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.admin-stats-compact { gap: 4px; flex-wrap: nowrap !important; }
.admin-stats-compact .stat-item { min-width: 0 !important; padding: 8px 4px; }
.admin-stats-compact .stat-label { white-space: nowrap; }
.stat-label-short { display: none; }
@media (max-width: 480px) {
    .stat-label-full { display: none; }
    .stat-label-short { display: inline; }
    .admin-stats-compact .stat-value { font-size: 20px; }
    .admin-stats-compact .stat-label { font-size: 11px; }
}

/* ─── Admin Toolbar ─── */
.admin-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.tree-search {
    flex: 1;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    outline: none;
}
.tree-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); }

/* ─── Danger Zone ─── */
.danger-zone {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.danger-zone[open] {
    border-color: #fecaca;
}
.danger-zone-toggle {
    display: block;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    list-style: none;
}
.danger-zone-toggle::-webkit-details-marker { display: none; }
.danger-zone-toggle::before { content: ""; }
.danger-zone[open] .danger-zone-toggle {
    color: var(--danger);
    border-bottom: 1px solid #fecaca;
}
.danger-zone-content {
    padding: 16px;
    background: #fef2f2;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.danger-zone-content p {
    font-size: 13px;
    color: #991b1b;
    margin-bottom: 12px;
}

/* ─── Condition Bar ─── */
.condition-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}
.condition-segment { min-width: 2px; }
.condition-gut { background: var(--success); }
.condition-beschaedigt { background: var(--warning); }
.condition-defekt { background: var(--danger); }
.condition-unbekannt { background: #94a3b8; }

/* ─── Spinner ─── */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Risk Box (Gefährdungsbeurteilung) ─── */
.risk-box {
    margin-top: 24px;
    border-left: 4px solid var(--danger);
    background: #fef2f2;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 16px;
}
.risk-box-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    color: #991b1b;
    margin-bottom: 8px;
}
.risk-box-header svg { color: var(--danger); flex-shrink: 0; }
.risk-box-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
}
.risk-box-ack {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 8px 12px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #065f46;
    font-weight: 500;
}
.risk-box-ack svg { color: var(--success); flex-shrink: 0; }
.risk-box-warning {
    margin-top: 12px;
    padding: 8px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #92400e;
    font-weight: 500;
}
.risk-box-log-link {
    display: inline-block;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}
.risk-box-log-link:hover { color: var(--primary); }

/* ─── Utilities ─── */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.hidden { display: none; }

/* Guide pages */
.guide-table { width: 100%; border-collapse: collapse; margin: 12px 0 20px; font-size: 14px; }
.guide-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.guide-table tr:last-child td { border-bottom: none; }
.guide-table code { background: var(--bg); padding: 2px 6px; border-radius: var(--radius-sm); font-size: 13px; word-break: break-all; }
.guide-path { background: var(--bg); padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; margin: 8px 0 16px; border-left: 3px solid var(--primary); }
.guide-hint { display: flex; align-items: flex-start; gap: 10px; background: #fef9c3; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin: 16px 0; color: #854d0e; }
.guide-code { background: var(--bg); padding: 14px 16px; border-radius: var(--radius-sm); font-size: 13px; overflow-x: auto; margin: 8px 0 16px; line-height: 1.6; white-space: pre; font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace; }

/* ── Block Editor ─────────────────────────── */
.block-list { min-height: 40px; }
.block-item { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; margin-bottom: 6px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: box-shadow .15s; }
.block-item.dragging { opacity: 0.4; }
.block-handle { cursor: grab; color: var(--text-secondary); font-size: 18px; user-select: none; padding: 0 4px; }
.block-type-badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.block-content { flex: 1 1 100%; min-height: 60px; resize: vertical; font-size: 14px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; }
.block-heading-input { flex: 1; font-size: 16px; font-weight: 600; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.block-embed-wrap { display: flex; align-items: center; gap: 8px; flex: 1; }
.block-embed-input { flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.embed-platform-badge { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; background: #ede9fe; color: #6d28d9; white-space: nowrap; }
.embed-platform-badge:empty { display: none; }
.block-file-input { font-size: 13px; }
.block-file-name { font-size: 13px; color: var(--text-secondary); }
.block-caption-input { flex: 1 1 100%; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; margin-top: 4px; }
.block-actions { display: flex; gap: 2px; margin-left: auto; }
.block-actions button { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); width: 28px; height: 28px; cursor: pointer; font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.block-actions button:hover { background: var(--bg); color: var(--text); }
.block-remove:hover { color: var(--danger) !important; border-color: var(--danger) !important; }
.block-add-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 20px; }
.block-add-btn { background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--text-secondary); transition: all .15s; }
.block-add-btn:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }

/* ── Content Block Rendering (Detail) ──── */
.content-block-heading { font-size: 1.25rem; font-weight: 600; margin: 24px 0 8px; color: var(--text); }
.block-caption { font-size: 13px; color: var(--text-secondary); text-align: center; margin: -8px 0 16px; }
.embed-container { margin: 16px 0; }
.embed-badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 4px; background: #ede9fe; color: #6d28d9; margin-bottom: 8px; }

/* ── New Badge Variants ──────────────── */
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-difficulty { background: #fef3c7; color: #92400e; }
.badge-social { background: #ede9fe; color: #6d28d9; }

/* ── 3-column form row ───────────────── */
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 768px) {
    .form-row-3 { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   LMS – Kurssystem
   ═══════════════════════════════════════════ */

/* Course grid */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.course-card {
    display: block;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}
.course-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.course-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.course-icon { font-size: 24px; }
.course-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px;
}
.course-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Status badges */
.badge-entwurf { background: #f3f4f6; color: #6b7280; }
.badge-aktiv { background: #d1fae5; color: #065f46; }
.badge-archiviert { background: #fef3c7; color: #92400e; }
.badge-muted { background: #f3f4f6; color: #9ca3af; }

/* Course info bar */
.course-info-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}

/* Unit list */
.unit-list { display: flex; flex-direction: column; gap: 8px; }
.unit-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border-radius: 10px;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}
.unit-card:hover { box-shadow: var(--shadow-md); }
.unit-card-left { display: flex; align-items: center; gap: 12px; }
.unit-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}
.unit-card h3 { font-size: 15px; font-weight: 600; margin: 0; }
.unit-desc { font-size: 13px; color: var(--text-secondary); margin: 2px 0 0; }
.unit-card-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.unit-due { white-space: nowrap; }
.unit-points { font-weight: 600; }

/* Button group */
.btn-group { display: flex; gap: 8px; }

/* Import list */
.experiment-import-list { display: flex; flex-direction: column; gap: 8px; }
.import-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}
.import-card-info { flex: 1; }
.import-card-info h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.import-card-info p { font-size: 13px; color: var(--text-secondary); margin: 0; }
.import-card-meta { display: flex; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); }

/* Danger button */
.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}
.btn-danger:hover { background: #dc2626; }

/* Form container spacing */
.form-container { max-width: 600px; }
.form-actions { display: flex; gap: 8px; margin-top: 1.5rem; }

/* Submission status badges */
.badge-eingereicht { background: #dbeafe; color: #1e40af; }
.badge-zurueckgegeben { background: #fef3c7; color: #92400e; }
.badge-bewertet { background: #d1fae5; color: #065f46; }

/* Submission editor */
.submission-block { display: flex; gap: 8px; margin-bottom: 8px; }
.submission-block select { width: 120px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.submission-block textarea { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; resize: vertical; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.data-table tr:hover td { background: #f8fafc; }

@media (max-width: 768px) {
    .course-grid { grid-template-columns: 1fr; }
    .unit-card { flex-direction: column; align-items: flex-start; gap: 8px; }
    .unit-card-right { align-self: flex-end; }
    .btn-group { flex-wrap: wrap; }
    .submission-block { flex-direction: column; }
    .submission-block select { width: 100%; }
}
