/* Design-System der Sensorverwaltung.
   Seiten, die auf layout.html umgestellt sind, nutzen nur dieses Stylesheet.
   Farben/Abstände ausschließlich über die Variablen unten — Dark Mode
   überschreibt nur die Variablen. */

:root {
    /* Inhaltsbreite — wächst automatisch auf breiten Bildschirmen (siehe unten) */
    --page-width: 1240px;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --primary-text: #1e40af;

    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;

    --success: #16a34a;
    --success-soft: #dcfce7;
    --success-text: #166534;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-soft: #fee2e2;
    --danger-text: #991b1b;
    --warning-soft: #fef3c7;
    --warning-text: #92400e;
    --info-soft: #e0f2fe;
    --info-text: #075985;

    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.18);
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.dark-mode {
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-soft: #172554;
    --primary-text: #bfdbfe;

    --bg: #0b1120;
    --surface: #111827;
    --surface-muted: #1e293b;
    --border: #1f2937;
    --border-strong: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;

    --success-soft: #14532d;
    --success-text: #bbf7d0;
    --danger-soft: #450a0a;
    --danger-text: #fecaca;
    --warning-soft: #451a03;
    --warning-text: #fde68a;
    --info-soft: #082f49;
    --info-text: #bae6fd;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* ---------- Grundlagen ---------- */

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

.icon { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }

/* ---------- Kopfleiste ---------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-header-inner {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
}

.main-nav {
    display: flex;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
}
.main-nav a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}
.main-nav a:hover { background: var(--surface-muted); color: var(--text); text-decoration: none; }
.main-nav a.active { background: var(--primary-soft); color: var(--primary-text); }

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.header-user-name {
    text-align: right;
    line-height: 1.2;
    font-size: 0.875rem;
}
.header-user-name .muted { font-size: 0.75rem; }

.app-header .nav-toggle { display: none; }

/* ---------- Seitenrahmen ---------- */

.page {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 28px 20px 48px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-header p { margin: 4px 0 0; color: var(--text-muted); }

.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 28px 0 12px;
}

/* ---------- Karten ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-body { padding: 20px; }
.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.grid { display: grid; gap: 16px; }
.grid-tiles { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

/* Kachel für Funktionen auf dem Dashboard */
.tile {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 18px;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.tile:hover {
    text-decoration: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.tile-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.tile-title { font-weight: 600; margin-bottom: 2px; }
.tile-text { font-size: 0.85rem; color: var(--text-muted); }

/* Schlüssel/Wert-Liste */
.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin: 0;
}
.facts dt { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 500; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible, .input:focus-visible, .select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger-text); }
.btn-danger-soft:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-muted); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-lg { padding: 11px 18px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; }

.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.btn-row.nowrap { flex-wrap: nowrap; }
.btn-icon-sm { padding: 5px 7px; }

/* ---------- Formulare ---------- */

.field { margin-bottom: 14px; }
.field label, .label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
}
.input, .select {
    width: 100%;
    padding: 8px 11px;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}
.input::placeholder { color: var(--text-muted); }

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}
.toolbar .search { position: relative; flex: 1 1 240px; max-width: 360px; }
.toolbar .search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.toolbar .search .input { padding-left: 34px; }
.toolbar .select { width: auto; min-width: 130px; }

/* ---------- Tabellen ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    background: var(--surface-muted);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-muted); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: " ↕"; opacity: 0.4; }
th.sortable.asc::after { content: " ↑"; opacity: 1; }
th.sortable.desc::after { content: " ↓"; opacity: 1; }

tr.clickable { cursor: pointer; }
tr.hash-highlight { animation: hashFlash 2.5s ease; }
@keyframes hashFlash { 0%, 40% { background: var(--primary-soft); } 100% { background: transparent; } }

.empty-state { padding: 40px 20px; text-align: center; color: var(--text-muted); }

/* ---------- Badges & Chips ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--surface-muted);
    color: var(--text-muted);
}
.badge-success { background: var(--success-soft); color: var(--success-text); }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.badge-primary { background: var(--primary-soft); color: var(--primary-text); }

/* ---------- Meldungen ---------- */

.alerts { display: grid; gap: 8px; margin-bottom: 20px; }
.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--info-soft);
    color: var(--info-text);
}
.alert-success { background: var(--success-soft); color: var(--success-text); }
.alert-error { background: var(--danger-soft); color: var(--danger-text); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); }
.alert-info { background: var(--info-soft); color: var(--info-text); }

.banner {
    background: var(--warning-soft);
    color: var(--warning-text);
    font-size: 0.875rem;
}
.banner-inner {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* ---------- Dialoge ---------- */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.5);
    padding: 20px;
    overflow-y: auto;
}
.modal.open { display: flex; align-items: flex-start; justify-content: center; }
.modal-dialog {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    margin-top: 8vh;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.detail-list { display: grid; gap: 0; margin: 0; }
.detail-list > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.detail-list > div:last-child { border-bottom: none; }
.detail-list dt { color: var(--text-muted); }
.detail-list dd { margin: 0; font-weight: 500; text-align: right; }

/* ---------- Anmeldeseite ---------- */

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card .card-body { padding: 32px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-mark { width: 48px; height: 48px; margin: 0 auto 12px; border-radius: var(--radius); }
.auth-brand p { color: var(--text-muted); margin: 6px 0 0; font-size: 0.9rem; }
.divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 22px 0 14px;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.stack { display: grid; gap: 8px; }

/* ---------- Weitere Komponenten ---------- */

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.92); }

/* Formularfelder: Eingaben in .field/.form-group automatisch gestalten */
.field input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]),
.field select, .field textarea,
.form-group input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]),
.form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 11px;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}
.form-group { margin-bottom: 14px; }
.form-group > label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
}
textarea.input { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
input[type=file] { font: inherit; font-size: 0.85rem; color: var(--text-muted); }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-inline .input, .form-inline .select { width: auto; }

/* Tabs (Umschaltung per JS über .active bzw. style.display) */
.tabs {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.tab {
    padding: 9px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    user-select: none;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Dialoge im klassischen Muster (.modal per style.display="block" öffnen) */
.modal-content {
    position: relative;
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    margin: 6vh auto;
    padding: 24px;
}
.modal-content.wide { max-width: 860px; }
.modal-content > h2:first-of-type, .modal-content > h3:first-of-type { margin-bottom: 18px; padding-right: 32px; }
.close-modal {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.close-modal:hover { background: var(--surface-muted); color: var(--text); }

.stat {
    padding: 16px 18px;
}
.stat-value { font-size: 1.6rem; font-weight: 600; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); }

.stack-lg { display: grid; gap: 20px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.danger-zone { border-color: var(--danger-soft); }
.danger-zone .card-header h2 { color: var(--danger); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; }
pre { background: var(--surface-muted); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; }

.breadcrumb { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }

/* ---------- Anleitungen ---------- */

.mb-sm { margin-bottom: 8px; }

.guide-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.guide-card { display: flex; flex-direction: column; overflow: hidden; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.guide-card:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow-lg); }
.guide-card-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-muted); }
.guide-card .card-body { display: flex; flex-direction: column; flex: 1; }
.guide-card-title { font-weight: 600; margin-bottom: 4px; }
.guide-card-text { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 10px; }
.guide-card-sensors { margin-top: auto; font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 6px; align-items: flex-start; }
.badge .icon { margin-right: 3px; }

.guide-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.guide-aside { position: sticky; top: 80px; }
.guide-cover { width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--radius); }
.guide-toc ol { margin: 0; padding: 12px 20px 16px 40px; font-size: 0.9rem; display: grid; gap: 6px; }

.guide-progress-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-muted); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: 4px; transition: width .2s; }

.guide-step { scroll-margin-top: 80px; }
.guide-step h2 { display: flex; align-items: center; gap: 10px; }
.step-number {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 0.85rem;
}
.guide-step.done .step-number { background: var(--success); }
.guide-step.done .guide-step-body { opacity: 0.6; }
.step-done { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }
.guide-step-body.has-image { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
.guide-step-image img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }
.guide-finished { overflow: hidden; }
.guide-finished .card-body { display: flex; gap: 8px; align-items: center; color: var(--success-text); background: var(--success-soft); font-weight: 500; }

/* Markdown-Inhalt */
.md { line-height: 1.65; overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.4em 0 0.5em; }
.md h1 { font-size: 1.35rem; }
.md h2 { font-size: 1.2rem; }
.md h3 { font-size: 1.05rem; }
.md p, .md ul, .md ol, .md pre, .md table, .md blockquote { margin: 0 0 1em; }
.md ul, .md ol { padding-left: 1.4em; }
.md li + li { margin-top: 0.25em; }
.md img { border-radius: var(--radius-sm); height: auto; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface-muted); }
.md code { background: var(--surface-muted); padding: 1px 5px; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md blockquote { border-left: 3px solid var(--border-strong); padding: 2px 0 2px 14px; color: var(--text-muted); }
.md .callout, .md blockquote.callout {
    border-left: 4px solid var(--primary); border-radius: var(--radius-sm);
    padding: 10px 14px; color: var(--text); background: var(--info-soft);
}
.md .callout.info { border-left-color: var(--info-text); background: var(--info-soft); }
.md .callout.success { border-left-color: var(--success); background: var(--success-soft); }
.md .callout.warning { border-left-color: #d97706; background: var(--warning-soft); }
.md .callout.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.md blockquote.callout p:last-child { margin-bottom: 0; }

/* Editor */
.md-editor { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.md-editor:focus-within { border-color: var(--primary); }
.md-editor textarea.input { border: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); min-height: 180px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.875rem; line-height: 1.55; box-shadow: none; }
.md-editor textarea.input:focus-visible { outline: none; }
.md-editor-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; border-bottom: 1px solid var(--border); padding: 4px 6px; background: var(--surface-muted); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.md-editor-bar button {
    font: inherit; font-size: 0.8rem; border: none; background: none; color: var(--text-muted);
    padding: 5px 8px; border-radius: 4px; cursor: pointer; min-width: 28px;
}
.md-editor-bar button:hover { background: var(--surface); color: var(--text); }
.md-editor-tabs button.active { background: var(--surface); color: var(--primary); font-weight: 600; }
.md-editor-tools { display: flex; flex-wrap: wrap; gap: 2px; }
.md-editor-preview { padding: 12px 14px; }

.segmented { display: flex; flex-wrap: wrap; gap: 8px; }
.segmented label {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.9rem;
    padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
.segmented label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.segmented input { accent-color: var(--primary); }

.step-edit-body { display: grid; gap: 16px; grid-template-columns: 200px minmax(0, 1fr); align-items: start; }
.image-field { display: grid; gap: 8px; margin-bottom: 14px; }
.image-field-preview {
    display: flex; align-items: center; justify-content: center; min-height: 110px;
    border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-muted); overflow: hidden;
}
.image-field-preview img { max-width: 100%; max-height: 200px; display: block; }
.sensor-picker { max-height: 320px; overflow-y: auto; display: grid; gap: 6px; padding-right: 4px; }
.sensor-picker label[hidden] { display: none; }
.attachment-list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.attachment-list.card-body { margin: 0; padding: 14px 20px; }
.attachment-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.9rem; }
.attachment-name { overflow-wrap: anywhere; display: inline-flex; gap: 6px; align-items: center; }

@media (max-width: 900px) {
    .guide-layout { grid-template-columns: minmax(0, 1fr); }
    .guide-aside { position: static; }
    .guide-step-body.has-image, .step-edit-body { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Breitbild ---------- */

/* Widescreen (ab ca. 1680 px, z.B. 1920×1080 oder 2560×1440) */
@media (min-width: 1680px) {
    :root { --page-width: 1600px; }
}

/* Ultra-Widescreen (21:9 / 32:9, ab ca. 2400 px) */
@media (min-width: 2400px) {
    :root { --page-width: 2200px; }
    .guide-layout { grid-template-columns: minmax(0, 1fr) 360px; }
}

/* Lange Fließtexte bleiben auch auf breiten Bildschirmen lesbar */
.guide-layout .md { max-width: 90ch; }

/* ---------- Mobil ---------- */

@media (max-width: 900px) {
    .app-header-inner { gap: 12px; }
    .app-header .nav-toggle { display: inline-flex; }
    .header-user-name { display: none; }
    .main-nav {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        flex-direction: column;
        padding: 8px 12px 12px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }
    .app-header.nav-open .main-nav { display: flex; }
    .page { padding: 20px 14px 40px; }
    .toolbar .search { max-width: none; }
}
