/*
 * carwiki – dunkles Grundschema.
 * Farb- und Schriftwerte an BookStack angelehnt (docs/ui-ux.md, U-002).
 * Ausschließlich dunkel, kein Umschalter (U-001) – Ausnahme ist @media print.
 */

:root {
    --font-body: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-size-base: 15px;
    --line-height-base: 1.6;

    --color-bg: #222328;
    --color-bg-raised: #2b2d33;
    --color-bg-sunken: #1b1c20;
    --color-border: #3a3c44;
    --color-text: #e6e6e6;
    --color-text-muted: #9a9ca3;
    --color-link: #6cb2eb;
    --color-accent: #0288d1;
    --color-accent-text: #ffffff;

    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;

    --nav-width: 260px;
    --context-width: 300px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
}

a {
    color: var(--color-link);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--color-bg-sunken);
    border-bottom: 1px solid var(--color-border);
}

.site-header__logo {
    font-weight: bold;
    color: var(--color-text);
    text-decoration: none;
}

.language-switch {
    display: flex;
    gap: var(--spacing-sm);
}

.language-switch button {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
}

.language-switch button[aria-current="true"] {
    color: var(--color-accent-text);
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.header-auth {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-left: var(--spacing-lg);
    color: var(--color-text-muted);
}

.header-auth a,
.header-auth button {
    color: var(--color-link);
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.layout {
    display: grid;
    grid-template-columns: var(--nav-width) 1fr var(--context-width);
    min-height: calc(100vh - 3.5rem);
}

/* U-003: same column, two modes - editing widens it, never overlays the
   content (docs/ui-ux.md). The content column is 1fr, so it reflows to
   make room instead of being covered. */
.layout--editing-context {
    grid-template-columns: var(--nav-width) 1fr var(--context-width-editing, 480px);
}

.layout__nav,
.layout__context {
    background: var(--color-bg-raised);
    padding: var(--spacing-md);
    overflow-y: auto;
}

/* M5.5, "klebende Abschnittsnavigation" - the nav column only: a grid
   item stretches to the row's full height by default, which would make
   it exactly as tall as the main content column and defeat sticky
   positioning entirely. align-self: start lets it size to its own
   content instead, so it can actually be shorter than the page and stay
   in view while the reader scrolls a long document. Not applied to
   .layout__context - there's no equivalent "always wants to stay
   visible while scrolling" case for the details panel. */
.layout__nav {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
}

.layout__nav {
    border-right: 1px solid var(--color-border);
}

.layout__context {
    border-left: 1px solid var(--color-border);
}

.layout__content {
    padding: var(--spacing-lg);
    min-width: 0;
}

/* M5.5: nav/context become collapsible below 900px (see base.html) - a
   checkbox+label toggle, not <details>: Chromium/Firefox hide a closed
   <details>'s body through an internal ::details-content box with its own
   content-visibility that author CSS cannot reliably force back open
   above the breakpoint (verified - "display: block !important" alone
   does not undo it). A checkbox has no such native hiding to fight, so
   "always open above 900px" is just "the toggle and its label don't
   render there". */
.layout__collapsible-toggle,
.layout__collapsible-summary {
    display: none;
}

.layout__collapsible-content {
    display: block;
}

.section-banner {
    background: var(--color-bg-raised);
    border-left: 3px solid var(--color-accent);
    padding: var(--spacing-sm) var(--spacing-md);
    margin: var(--spacing-md) 0;
    color: var(--color-text-muted);
}

.section-banner--error {
    border-left-color: #e05a5a;
}

.section-diff {
    background: var(--color-bg-sunken);
    border: 1px solid var(--color-border);
    padding: var(--spacing-md);
    overflow-x: auto;
    white-space: pre-wrap;
}

/* M5.5, "schrittorientierte Ansicht": numbered steps stay Markdown `<ol>`
   lists (decision 017, kein Step-Modell) - this is presentation only.
   Scoped to top-level lists in rendered content (the `>` combinator) so
   a nested sub-list inside a step doesn't also get a big circled number. */
.section-fragment > ol {
    list-style: none;
    counter-reset: step;
    padding-left: 0;
}

.section-fragment > ol > li {
    position: relative;
    counter-increment: step;
    padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-sm) 2.75rem;
    margin-bottom: var(--spacing-sm);
    border-left: 2px solid var(--color-border);
}

.section-fragment > ol > li::before {
    content: counter(step);
    position: absolute;
    left: -1rem;
    top: var(--spacing-sm);
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-accent-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
}

.section-fragment__actions,
.section-form__actions,
.document-status {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    margin-top: var(--spacing-sm);
}

.revision-list {
    list-style: none;
    padding: 0;
}

.inline-form {
    display: inline;
}

.revision-list li {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border);
}

.partnumber-table {
    display: grid;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow-x: auto;
}

.partnumber-table__rows {
    display: contents;
}

.partnumber-table__row {
    display: grid;
    grid-template-columns: 10rem minmax(0, 1fr) 5rem minmax(0, 1fr) auto;
    gap: var(--spacing-sm);
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

/* The entity-editor panel (U-003) is narrower than the main content column -
   a 5-column table needs tighter proportions there, not just a horizontal
   scrollbar nobody notices. */
.layout__context .partnumber-table__row {
    grid-template-columns: 6rem minmax(0, 1fr) 3rem minmax(0, 1fr) auto;
    font-size: 0.9em;
}

.partnumber-table__row--header {
    background: var(--color-bg-sunken);
    color: var(--color-text-muted);
    font-weight: bold;
}

.partnumber-table__row input[type="text"],
.partnumber-table__row select {
    width: 100%;
    min-width: 0;
}

.partnumber-table__actions {
    display: flex;
    gap: var(--spacing-sm);
    white-space: nowrap;
}

.partnumber-table__errors {
    grid-column: 1 / -1;
    color: #e05a5a;
}

/* Pinout: unlike partnumber-table, the column COUNT varies per pinout
   (implementation plan: only columns with any value render) - flexbox
   handles a variable child count naturally, a CSS Grid track list can't. */
.pinout-table {
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow-x: auto;
}

.pinout-table__rows {
    display: contents;
}

.pinout-table__row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

/* The edit/add form rows carry more fields (colour_base + colour_stripe +
   colour_raw individually) than a display row's single merged column -
   narrower so 7-8 of them still wrap into a readable block instead of one
   unbroken line. */
.pinout-table__row--form > [role="cell"] {
    flex-basis: 5rem;
}

.pinout-table__row > [role="cell"],
.pinout-table__row > [role="columnheader"] {
    flex: 1 1 6rem;
    min-width: 0;
}

.pinout-table__row--header {
    background: var(--color-bg-sunken);
    color: var(--color-text-muted);
    font-weight: bold;
}

.pinout-table__row input[type="text"],
.pinout-table__row input[type="number"],
.pinout-table__row select {
    width: 100%;
    min-width: 0;
}

.pinout-table__actions {
    flex: 0 0 auto;
    display: flex;
    gap: var(--spacing-sm);
    white-space: nowrap;
}

.entity-editor__tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.entity-editor__tabs a {
    display: inline-block;
    padding: var(--spacing-sm) 0;
    color: var(--color-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
}

.entity-editor__tabs a[aria-current="true"] {
    color: var(--color-text);
    border-bottom-color: var(--color-accent);
}

.entity-editor__field {
    margin-bottom: var(--spacing-sm);
}

.entity-editor__field label {
    display: block;
    color: var(--color-text-muted);
    margin-bottom: 0.2rem;
}

.entity-editor__field input,
.entity-editor__field select,
.entity-editor__field textarea {
    width: 100%;
}

.context-summary dt {
    color: var(--color-text-muted);
    font-size: 0.9em;
    margin-top: var(--spacing-sm);
}

.context-summary dd {
    margin: 0;
}

/* Vorsortierer (M4b): Massenaktionen oben, darunter das nach Aufnahmezeit
   geclusterte Raster - siehe carwiki/media/clustering.py. */
.media-triage__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-md);
    background: var(--color-bg-raised);
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.media-triage__count {
    margin: 0;
    color: var(--color-text-muted);
    align-self: center;
}

.media-triage__action {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.media-triage__part-results {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.media-triage__part-result button {
    width: 100%;
    text-align: left;
}

.media-triage__part-empty {
    margin: 0;
    color: var(--color-text-muted);
}

.media-triage__cluster {
    border: 1px solid var(--color-border);
    border-radius: 4px;
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-md);
}

.media-triage__cluster-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--color-text-muted);
}

.media-triage__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.media-triage__card {
    position: relative;
    display: block;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}

.media-triage__card img {
    display: block;
    width: 100%;
    height: 9rem;
    object-fit: cover;
    background: var(--color-bg-sunken);
}

.media-triage__card input[type="checkbox"] {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
}

.media-triage__meta {
    display: block;
    padding: 0.2rem var(--spacing-sm);
    font-size: 0.8em;
    color: var(--color-text-muted);
    background: var(--color-bg-raised);
}

/* aspect=bild embeds (carwiki/media/aspects.py) - a photo placed inline in
   prose via ::: embed teil:x aspect=bild. */
.media-embed {
    margin: var(--spacing-md) 0;
}

.media-embed img {
    display: block;
    max-width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.media-embed figcaption {
    margin-top: 0.3rem;
    font-size: 0.9em;
    color: var(--color-text-muted);
}

.media-embed__flag {
    cursor: help;
}

/* MediaAnnotationLayer overlay (M4d) - normalised 0..1 coordinates sit
   inside a wrapper the same box as the <img>, so the same markup works at
   any CSS size without a server-rendered derivative per size. `arrow`/
   `frame` are true SVG (need actual line/rect geometry); `num`/`badge`
   markers are plain HTML positioned by percentage so their badge shape
   stays a circle regardless of the photo's aspect ratio - an SVG circle
   drawn in a non-square viewBox would come out as an ellipse. */
.media-annotate {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.media-annotate img {
    display: block;
    max-width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.media-annotate__lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.media-annotate__arrow {
    stroke: var(--color-accent);
    stroke-width: 2;
    fill: none;
}

.media-annotate__arrowhead {
    fill: var(--color-accent);
}

.media-annotate__frame {
    stroke: var(--color-accent);
    stroke-width: 2;
    fill: none;
}

.media-annotate__marker {
    position: absolute;
    transform: translate(-50%, -50%);
    font-size: 0.85em;
    line-height: 1;
    white-space: nowrap;
}

.media-annotate__marker--num,
.media-annotate__marker--badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6em;
    height: 1.6em;
    padding: 0 0.3em;
    border-radius: 999px;
    background: var(--color-accent);
    color: var(--color-accent-text);
    font-weight: 600;
    box-shadow: 0 0 0 2px var(--color-bg-sunken);
}

.media-annotate__marker--frame-label {
    padding: 0.1em 0.4em;
    border-radius: 4px;
    background: var(--color-bg-sunken);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

/* The overlay editor (M4d, static/js/media_annotate.js) - markers/handles
   become pointer targets and get a grab cursor only in editing mode; a
   read-only embed elsewhere on the site never shows a hand cursor over a
   photo it can't interact with. */
.media-annotate--editing .media-annotate__marker,
.media-annotate--editing .media-annotate__handle {
    cursor: grab;
    touch-action: none;
}

.media-annotate--editing img {
    cursor: crosshair;
}

.media-annotate__handle {
    position: absolute;
    width: 0.9em;
    height: 0.9em;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--color-bg);
    border: 2px solid var(--color-accent);
}

.media-annotate__marker.is-selected,
.media-annotate__handle.is-selected {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

.media-annotate-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.media-annotate-toolbar button[aria-pressed="true"] {
    background: var(--color-accent);
    color: var(--color-accent-text);
}

.media-annotate-toolbar__status {
    color: var(--color-text-muted);
    font-size: 0.9em;
}

.media-annotate-toolbar__status.is-error {
    color: #e57373;
}

.media-annotate-props {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.media-annotate-props__group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

/* Kabelbaum-Detailseite (M4c) - schreibgeschütztes Erst-Layout, gleiche
   Grid-/Zeilenstruktur wie partnumber-table. */
.harness-wire-table {
    display: grid;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow-x: auto;
}

.harness-wire-table__row {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr) 5rem 6rem minmax(0, 1fr);
    gap: var(--spacing-sm);
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

/* Same narrower-column-set adjustment partnumber-table already makes when
   an open context panel halves the main content's width. */
.layout--editing-context .harness-wire-table__row {
    font-size: 0.9em;
}

.harness-wire-table__row--header {
    background: var(--color-bg-sunken);
    color: var(--color-text-muted);
    font-weight: bold;
}

/* The Adern-Panel in the right context area (kabelbaum-Editor) - flexbox
   like pinout-table, not a fixed grid: HarnessWireForm has more fields
   than fit one fixed column set once inputs replace plain text. */
.harness-wire-panel {
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow-x: auto;
}

.harness-wire-panel__rows {
    display: contents;
}

.harness-wire-panel__row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.harness-wire-panel__row--header {
    background: var(--color-bg-sunken);
    color: var(--color-text-muted);
    font-weight: bold;
}

.harness-wire-panel__row--form > [role="cell"] {
    flex-basis: 6rem;
}

.harness-wire-panel__row > [role="cell"],
.harness-wire-panel__row > [role="columnheader"] {
    flex: 1 1 6rem;
    min-width: 0;
}

.harness-wire-panel__row input[type="text"],
.harness-wire-panel__row input[type="number"],
.harness-wire-panel__row select {
    width: 100%;
    min-width: 0;
}

.harness-wire-panel__actions {
    flex: 0 0 auto;
    display: flex;
    gap: var(--spacing-sm);
    white-space: nowrap;
}

/* Galerie auf der Part-Detailseite (M4b, "Galerien auf Part"). */
.part-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.part-gallery__item {
    display: block;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}

.part-gallery__item > a {
    display: block;
    color: inherit;
    text-decoration: none;
}

.part-gallery__item img {
    display: block;
    width: 100%;
    height: 8rem;
    object-fit: cover;
    background: var(--color-bg-sunken);
}

.part-gallery__item span {
    display: block;
    padding: 0.2rem var(--spacing-sm);
    font-size: 0.8em;
    color: var(--color-text-muted);
}

.part-gallery__annotate {
    display: block;
    padding: 0.2rem var(--spacing-sm);
    font-size: 0.8em;
    text-align: center;
    color: var(--color-link);
    border-top: 1px solid var(--color-border);
}

.part-gallery__edit-form {
    margin: 0;
}

.part-gallery__edit {
    display: block;
    width: 100%;
    padding: 0.2rem var(--spacing-sm);
    font-size: 0.8em;
    text-align: center;
    color: var(--color-link);
    background: none;
    border: 0;
    border-top: 1px solid var(--color-border);
    cursor: pointer;
}

/* Regler-Editor (M4f) - media_edit.html. */
.media-edit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
    gap: var(--spacing-lg);
    align-items: start;
}

.media-edit__preview img {
    max-width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.media-edit__hint {
    color: var(--color-text-muted);
    font-size: 0.9em;
}

.media-edit__form input {
    width: 100%;
}

/* Platzierungs-Picker in _section_form.html - "Foto einfügen" fold-out. */
.media-picker {
    margin: var(--spacing-sm) 0;
    padding: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-bg-raised);
}

.media-picker__search {
    width: 100%;
    margin-top: var(--spacing-sm);
}

.media-picker__results {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.media-picker__part {
    text-align: left;
}

.media-picker__variant {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 6rem;
    padding: 0.3rem;
}

.media-picker__variant img {
    width: 100%;
    height: 4.5rem;
    object-fit: cover;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

.media-picker__variant span {
    margin-top: 0.2rem;
    font-size: 0.8em;
    color: var(--color-text-muted);
}

.media-picker__empty {
    margin: 0;
    color: var(--color-text-muted);
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .layout__nav,
    .layout__context {
        border: none;
        border-bottom: 1px solid var(--color-border);
        padding: 0 var(--spacing-md);
    }

    /* M5.5: nav and context collapse behind a checkbox+label toggle
       instead of vanishing entirely (the old fallback made both
       unreachable below 900px) - einklappbare Seitenbereiche. */
    .layout__collapsible-toggle {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

    .layout__collapsible-summary {
        display: block;
        padding: var(--spacing-sm) 0;
        font-weight: bold;
        cursor: pointer;
    }

    .layout__collapsible-summary::before {
        content: "▸ ";
    }

    .layout__collapsible-toggle:checked ~ .layout__collapsible-summary::before {
        content: "▾ ";
    }

    .layout__collapsible-content {
        display: none;
        padding-bottom: var(--spacing-md);
    }

    .layout__collapsible-toggle:checked ~ .layout__collapsible-content {
        display: block;
    }

    .layout__collapsible-toggle:focus-visible ~ .layout__collapsible-summary {
        outline: 2px solid var(--color-accent);
    }

    /* U-003 says bottom-sheet; this is a simpler stacked fallback (content
       above, editor below) - honest degradation, not the full sheet yet. */
    .layout--editing-context {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
    }

    .layout--editing-context .layout__context {
        border-left: none;
        border-top: 1px solid var(--color-border);
    }

    /* M5.5, "Breite Tabellen als Karten": any [role="table"] container
       with this class turns into stacked cards below 900px, CSS-only.
       Works generically across every div-based fake-table in the project
       (they all already share the [role="row"]/[role="cell"]/
       [role="columnheader"] structure) - a table only needs to opt in by
       adding the class to its container. Cells with a `data-label`
       attribute get an inline column name; cells without one just stack
       silently (an honest, still-readable degradation for tables that
       haven't been given labels yet). */
    .responsive-rows [role="row"]:has(> [role="columnheader"]) {
        display: none;
    }

    .responsive-rows [role="row"] {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .responsive-rows [role="cell"] {
        display: flex;
        justify-content: space-between;
        gap: var(--spacing-md);
    }

    .responsive-rows [role="cell"][data-label]::before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--color-text-muted);
        flex-shrink: 0;
    }
}

/* Garage/Vorhaben (M5.2) - same grid-row pattern as .partnumber-table. */
.owned-vehicle-table {
    display: grid;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    overflow-x: auto;
}

.owned-vehicle-table__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 8rem auto;
    gap: var(--spacing-sm);
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--color-border);
}

.owned-vehicle-table__row--header {
    background: var(--color-bg-sunken);
    color: var(--color-text-muted);
    font-weight: bold;
}

.owned-vehicle-table__row input[type="text"],
.owned-vehicle-table__row input[type="date"],
.owned-vehicle-table__row select {
    width: 100%;
    min-width: 0;
}

.owned-vehicle-table__other-scope {
    color: var(--color-text-muted);
    font-size: 0.9em;
}

/* "Passt zu deinem Fahrzeug" (M5.2). */
.applicability-banner {
    background: var(--color-bg-raised);
    border-left: 3px solid var(--color-accent);
    padding: var(--spacing-sm) var(--spacing-md);
    margin: var(--spacing-md) 0;
}

.applicability-banner--mismatch {
    border-left-color: #e05a5a;
}

/* Honeypot (M5.3, Registrierungsformular) - visually hidden but present in
   the DOM/tab order for anything that doesn't render CSS, e.g. simple bots.
   Not display:none/visibility:hidden, which some scrapers explicitly skip. */
.registration-honeypot {
    position: absolute;
    left: -9999px;
    top: -9999px;
}

.site-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.9em;
}

.video-embed {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-bg-sunken);
}

.video-embed__load-button {
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-accent);
    border-radius: 4px;
    background: var(--color-accent);
    color: var(--color-accent-text);
    font-size: 1em;
    cursor: pointer;
}

.video-embed__provider {
    font-weight: normal;
    opacity: 0.85;
}

.video-embed__hint {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.9em;
}

.video-embed iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
}

/* Kept at the very end of the file on purpose (M5.5): every component
   rule above declares its own `display` unconditionally, so a print-only
   override needs to win a same-specificity, later-source-wins tie
   against all of them - true regardless of which came first, only if
   this block comes last. An earlier position (this used to sit further
   up, before Garage/Vorhaben and friends existed) silently stopped
   working for every component added after it - verified by a browser
   test that actually checks computed style under page.emulate_media. */
@media print {
    :root {
        --color-bg: #ffffff;
        --color-bg-raised: #ffffff;
        --color-text: #000000;
    }

    .site-header,
    .layout__nav,
    .layout__context {
        display: none;
    }

    .layout {
        display: block;
    }

    /* Editing and other interactive/personalised chrome is never part of
       the reference document a printed page exists for. */
    .section-fragment__actions,
    .section-form__actions,
    .document-status,
    .section-banner,
    .section-fragment--editing,
    .section-fragment--conflict,
    .section-add-form,
    .partnumber-table__actions,
    .partnumber-table__row--form,
    .pinout-table__actions,
    .pinout-table__row--form,
    .harness-wire-panel__actions,
    .harness-wire-panel__row--form,
    .media-triage__actions,
    #media-upload,
    .media-picker,
    .site-footer,
    .checklist-actions,
    .applicability-banner,
    .translation-badge form,
    .owned-vehicle-table__actions,
    .owned-vehicle-table__row--form,
    .project-item-table__actions,
    .project-item-table__row--form,
    .project-step-list form,
    .project-step-add-form {
        display: none;
    }

    h1,
    h2 {
        break-after: avoid;
    }

    table,
    figure,
    img {
        break-inside: avoid;
    }
}
