/* ============================================================
   Volleyball-Portal — base styles (mobile-first)
   ============================================================ */

:root {
    --color-primary: #1d4ed8;
    --color-primary-dark: #1e40af;
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-text: #1f2937;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-border-strong: #d3d9e2;
    --color-zebra: #f6f8fc; /* Listen: leicht blaustichiges Grau (gewählt, kein neutrales) */
    --color-hover: #eef2fb;
    --color-success-bg: #dcfce7;
    --color-success-text: #166534;
    --color-error-bg: #fee2e2;
    --color-error-text: #991b1b;
    --radius: 8px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family:
        system-ui,
        -apple-system,
        'Segoe UI',
        Roboto,
        sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 1rem;
}

main.container {
    flex: 1;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

/* --- Header / Navigation --- */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    min-height: 56px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    color: var(--color-text);
    padding: 0.5rem 0;
}
.brand-logo {
    height: 34px;
    width: auto;
}
.main-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.main-nav a {
    color: var(--color-text);
    text-decoration: none;
    padding: 0.6rem 0.5rem; /* comfortable touch target */
}
.main-nav a:hover {
    color: var(--color-primary);
}
.nav-user {
    color: var(--color-muted);
    font-size: 0.9rem;
}

/* --- Internal sub navigation (second header row, logged-in only) --- */
.sub-nav {
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
}
.sub-nav-inner {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.sub-nav a {
    color: var(--color-text);
    text-decoration: none;
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
}
.sub-nav a:hover {
    color: var(--color-primary);
}
.sub-nav a.active {
    color: var(--color-primary);
    font-weight: 600;
    border-bottom-color: var(--color-primary);
}

/* --- Footer --- */
.site-footer {
    border-top: 1px solid var(--color-border);
    color: var(--color-muted);
    font-size: 0.85rem;
    padding: 1rem 0;
    margin-top: 2rem;
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.footer-nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}
.footer-nav a {
    color: var(--color-muted);
    text-decoration: none;
}
.footer-nav a:hover {
    color: var(--color-primary);
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0.6rem 1rem; /* ≥44px touch height with line-height */
    border-radius: var(--radius);
    font-size: 0.95rem;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--color-primary-dark);
    color: #fff;
}
.btn-ghost {
    background: transparent;
    border-color: transparent;
}
.btn-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
}
.btn-danger {
    color: #991b1b;
    border-color: #fca5a5;
}
.btn-danger:hover {
    background: var(--color-error-bg);
    color: #991b1b;
    border-color: #991b1b;
}
.btn-block {
    width: 100%;
}
.inline-form {
    display: inline;
}

/* --- Cards / Hero --- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.card-narrow {
    max-width: 420px;
    margin: 2rem auto;
}
.center {
    text-align: center;
}
.hero {
    text-align: center;
    padding: 3rem 1rem;
}

/* --- Dashboard tiles --- */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.tile {
    display: block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--color-text);
}
.tile h2 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
}
.tile p {
    margin: 0;
    color: var(--color-muted);
    font-size: 0.9rem;
}
a.tile:hover {
    border-color: var(--color-primary);
}
.tile-disabled {
    opacity: 0.55;
}

/* --- Filter bar (search/filter above lists) --- */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}
.filter-bar input[type='search'] {
    flex: 1 1 220px;
}
/* Forces the following controls onto a new row inside a wrapping filter bar. */
.filter-bar .filter-break {
    flex-basis: 100%;
    height: 0;
    margin: 0;
}
.filter-bar input[type='text'] {
    flex: 1 1 160px;
    width: auto;
}
.filter-bar select,
.filter-bar input[type='date'] {
    width: auto;
}
.check-label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-weight: 400;
    font-size: 0.9rem;
    white-space: nowrap;
}
.empty-note {
    color: var(--color-muted);
}
.optional {
    font-weight: 400;
    color: var(--color-muted);
}
.plain-list {
    list-style: none;
    padding: 0;
}
.plain-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--color-border);
}
.plain-list li:last-child {
    border-bottom: none;
}

/* --- Forms --- */
label {
    display: block;
    margin: 1rem 0 0.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}
input[type='text'],
input[type='email'],
input[type='password'],
input[type='search'],
input[type='date'],
textarea,
select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--color-surface);
}
select {
    max-width: 100%;
}
input[type='color'] {
    width: 48px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    cursor: pointer;
}
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
    border-color: var(--color-primary);
}
form .btn-block {
    margin-top: 1.5rem;
}
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Grouped form section: everything that belongs to one logical input sits
   on a tinted panel (e.g. Verein/Gruppe incl. the inline-create fields). */
fieldset.feldgruppe {
    margin: 1.25rem 0 0;
    padding: 0 1rem 1rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-zebra);
}
fieldset.feldgruppe legend {
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0 0.4rem;
}
.feldgruppe-hinweis {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin: 0.25rem 0 0;
}
/* Inset panel for the inline-create fields inside a feldgruppe. */
.feldgruppe-einschub {
    margin-top: 1rem;
    padding: 0.25rem 0.85rem 0.85rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius);
}
.feldgruppe-einschub .btn {
    margin-top: 0.85rem;
}

/* --- Turnier context navigation (same look as .sub-nav, inside the page) --- */
.turnier-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}
.turnier-nav a {
    color: var(--color-text);
    text-decoration: none;
    padding: 0.55rem 0.7rem;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.turnier-nav a:hover {
    color: var(--color-primary);
}
.turnier-nav a.active {
    color: var(--color-primary);
    font-weight: 600;
    border-bottom-color: var(--color-primary);
}
.turnier-nav-zurueck {
    color: var(--color-muted) !important;
    margin-right: 0.5rem;
}

/* Quick entry band above the tournament list ("today / next tournament") */
.naechstes-turnier h2 {
    margin: 0;
}
.naechstes-turnier p {
    margin: 0.25rem 0 0;
}

/* "Next step" hint on the tournament overview */
.naechster-schritt {
    border-left: 3px solid var(--color-primary);
}
.naechster-schritt h2 {
    margin: 0;
    font-size: 1.05rem;
}
.naechster-schritt p {
    margin: 0.25rem 0 0;
    color: var(--color-muted);
}

/* --- Tables --- */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
th,
td {
    text-align: left;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
th {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--color-muted);
}
tr:last-child td {
    border-bottom: none;
}
.row-inactive td {
    color: var(--color-muted);
}
.col-actions {
    text-align: right;
}

/* --- Badges & flash messages --- */
.badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
}
.badge-green {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}
.badge-gray {
    background: var(--color-border);
    color: var(--color-muted);
}
.badge-blue {
    background: #dbeafe;
    color: #1e40af;
}
.badge-red {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

/* ============================================================
   Listen — einheitliches Tabellen-/Karten-Muster.
   Aufbau & Vorlage: docs/listen-muster.md
   • Zebra + Hover, damit die Zeile im Blick bleibt.
   • Nebenfelder als Unterzeile (.sub) unter dem Hauptfeld (.haupt)
     → weniger Spalten, kurze Zeilen, kein Querscrollen.
   • Auf schmalen Screens wird jede Zeile eine beschriftete Karte
     (data-label je <td>): normale Listen ab 680 px, dichte Listen
     (Klasse .liste--breit, z. B. mit Kommentar + vielen Aktionen)
     schon ab 940 px — so wird nie ein Button abgeschnitten.
   ============================================================ */
.liste-karte {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.liste {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
    border: none;
    border-radius: 0;
    font-size: 0.92rem;
}
.liste th,
.liste td {
    text-align: left;
    padding: 0.7rem 0.85rem;
    vertical-align: middle;
    white-space: normal;
    border-bottom: none;
}
.liste thead th {
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--color-border-strong);
    white-space: nowrap;
}
.liste tbody td {
    border-top: 1px solid var(--color-border);
}
.liste tbody tr:first-child td {
    border-top: none;
}
.liste tbody tr:nth-child(even) {
    background: var(--color-zebra);
}
.liste tbody tr:hover {
    background: var(--color-hover);
}
.liste .row-inactive td {
    color: var(--color-muted);
}
.liste .haupt {
    font-weight: 600;
    color: var(--color-text);
}
.liste .haupt a {
    color: inherit;
    text-decoration: none;
}
.liste .haupt a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}
.liste .sub {
    display: block;
    font-weight: 400;
    font-size: 0.82rem;
    color: var(--color-muted);
    margin-top: 0.15rem;
}
.liste .num-spalte {
    font-variant-numeric: tabular-nums;
}
.liste .col-actions {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}
.liste .col-check {
    width: 1%;
    white-space: nowrap;
    text-align: center;
}
.liste .aktionen {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: nowrap;
}
.liste .aktionen .inline-form {
    display: inline-flex;
    margin: 0;
}
.liste .kommentar-form {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.liste .kommentar-form input[type='text'] {
    flex: 1 1 6rem;
    min-width: 4rem;
    width: auto;
}

/* Karten-Umschaltung. Regeln je Umschaltpunkt dupliziert und per :has()
   auf die passenden Listen begrenzt (dichte .liste--breit früh bei 940 px,
   normale Listen erst bei 680 px). */
@media (max-width: 940px) {
    .liste-karte:has(.liste--breit) {
        border: none;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }
    .liste-karte:has(.liste--breit) .liste,
    .liste-karte:has(.liste--breit) .liste tbody,
    .liste-karte:has(.liste--breit) .liste tr,
    .liste-karte:has(.liste--breit) .liste td {
        display: block;
        width: 100%;
    }
    .liste-karte:has(.liste--breit) .liste thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }
    .liste-karte:has(.liste--breit) .liste tbody tr,
    .liste-karte:has(.liste--breit) .liste tbody tr:nth-child(even) {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        box-shadow: var(--shadow-card);
        margin-bottom: 0.85rem;
        padding: 0.4rem 0.25rem;
    }
    .liste-karte:has(.liste--breit) .liste tbody td {
        border-top: none;
        display: flex;
        align-items: baseline;
        gap: 0.75rem;
        padding: 0.35rem 0.9rem;
    }
    .liste-karte:has(.liste--breit) .liste tbody td::before {
        content: attr(data-label);
        flex: 0 0 7rem;
        white-space: nowrap;
        font-size: 0.72rem;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--color-muted);
        font-weight: 600;
        line-height: 1.5;
    }
    .liste-karte:has(.liste--breit) .liste td.zelle-haupt,
    .liste-karte:has(.liste--breit) .liste td.col-actions {
        gap: 0;
    }
    .liste-karte:has(.liste--breit) .liste td.zelle-haupt::before,
    .liste-karte:has(.liste--breit) .liste td.col-actions::before {
        display: none;
    }
    .liste-karte:has(.liste--breit) .liste .zelle-haupt {
        border-bottom: 1px solid var(--color-border);
        margin-bottom: 0.25rem;
        padding-bottom: 0.6rem;
    }
    .liste-karte:has(.liste--breit) .liste .zelle-stand .sub {
        display: inline;
        margin-top: 0;
    }
    .liste-karte:has(.liste--breit) .liste .zelle-stand .sub::before {
        content: '· ';
    }
    .liste-karte:has(.liste--breit) .liste td.zelle-kommentar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.3rem;
    }
    .liste-karte:has(.liste--breit) .liste td.zelle-kommentar::before {
        flex: none;
    }
    .liste-karte:has(.liste--breit) .liste .kommentar-form {
        width: 100%;
    }
    .liste-karte:has(.liste--breit) .liste .aktionen {
        justify-content: flex-start;
        flex-wrap: wrap;
        width: 100%;
        padding-top: 0.15rem;
    }
}
@media (max-width: 680px) {
    .liste-karte:not(:has(.liste--breit)) {
        border: none;
        background: transparent;
        box-shadow: none;
        overflow: visible;
    }
    .liste-karte:not(:has(.liste--breit)) .liste,
    .liste-karte:not(:has(.liste--breit)) .liste tbody,
    .liste-karte:not(:has(.liste--breit)) .liste tr,
    .liste-karte:not(:has(.liste--breit)) .liste td {
        display: block;
        width: 100%;
    }
    .liste-karte:not(:has(.liste--breit)) .liste thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }
    .liste-karte:not(:has(.liste--breit)) .liste tbody tr,
    .liste-karte:not(:has(.liste--breit)) .liste tbody tr:nth-child(even) {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        box-shadow: var(--shadow-card);
        margin-bottom: 0.85rem;
        padding: 0.4rem 0.25rem;
    }
    .liste-karte:not(:has(.liste--breit)) .liste tbody td {
        border-top: none;
        display: flex;
        align-items: baseline;
        gap: 0.75rem;
        padding: 0.35rem 0.9rem;
    }
    .liste-karte:not(:has(.liste--breit)) .liste tbody td::before {
        content: attr(data-label);
        flex: 0 0 7rem;
        white-space: nowrap;
        font-size: 0.72rem;
        letter-spacing: 0.05em;
        text-transform: uppercase;
        color: var(--color-muted);
        font-weight: 600;
        line-height: 1.5;
    }
    .liste-karte:not(:has(.liste--breit)) .liste td.zelle-haupt,
    .liste-karte:not(:has(.liste--breit)) .liste td.col-actions {
        gap: 0;
    }
    .liste-karte:not(:has(.liste--breit)) .liste td.zelle-haupt::before,
    .liste-karte:not(:has(.liste--breit)) .liste td.col-actions::before {
        display: none;
    }
    .liste-karte:not(:has(.liste--breit)) .liste .zelle-haupt {
        border-bottom: 1px solid var(--color-border);
        margin-bottom: 0.25rem;
        padding-bottom: 0.6rem;
    }
    .liste-karte:not(:has(.liste--breit)) .liste td.zelle-kommentar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.3rem;
    }
    .liste-karte:not(:has(.liste--breit)) .liste td.zelle-kommentar::before {
        flex: none;
    }
    .liste-karte:not(:has(.liste--breit)) .liste .kommentar-form {
        width: 100%;
    }
    .liste-karte:not(:has(.liste--breit)) .liste .aktionen {
        justify-content: flex-start;
        flex-wrap: wrap;
        width: 100%;
        padding-top: 0.15rem;
    }
}

/* --- Tournament detail --- */
.fact-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}
.muted {
    color: var(--color-muted);
    font-weight: 400;
}
.card + .card {
    margin-top: 1.5rem;
}
/* Tile row (e.g. tournament overview) needs a bit more air than card-to-card */
.tile-grid + .card {
    margin-top: 2rem;
}
.card h2 {
    margin-top: 0;
}
.card h3 {
    margin-top: 1.5rem;
}
.row-form {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.row-form input[type='date'],
.row-form select {
    width: auto;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
}
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.4rem;
    margin: 0.75rem 0 1rem;
}
/* --- Schieberegler (Ein/Aus-Schalter) ---
   Eine Checkbox mit sichtbarer Bahn: derselbe Baustein im Turnierformular
   (speichert mit dem Formular) und auf der Durchfuehrungsseite (schickt sich
   per data-autosubmit selbst ab). Die Checkbox bleibt fokussierbar, nur
   optisch ersetzt — Tastatur und Screenreader arbeiten damit unveraendert. */
.schalter {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 44px;
    cursor: pointer;
    user-select: none;
}
.schalter input[type='checkbox'] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}
.schalter-bahn {
    position: relative;
    flex: none;
    width: 44px;
    height: 24px;
    border-radius: 12px;
    background: var(--color-border-strong);
    transition: background 0.15s ease;
}
.schalter-bahn::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.25);
    transition: transform 0.15s ease;
}
.schalter input[type='checkbox']:checked + .schalter-bahn {
    background: var(--color-primary);
}
.schalter input[type='checkbox']:checked + .schalter-bahn::after {
    transform: translateX(20px);
}
.schalter input[type='checkbox']:focus-visible + .schalter-bahn {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}
.schalter input[type='checkbox']:disabled + .schalter-bahn {
    opacity: 0.5;
}
.schalter-text {
    font-size: 0.9rem;
}
.schalter-form {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 0;
}
.bcc-box {
    width: 100%;
    font-family: monospace;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}
/* --- CMS: WYSIWYG editor --- */
.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    padding: 0.4rem;
    border: 1px solid var(--color-border);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--color-bg);
}
.editor-toolbar .editor-select {
    width: auto;
    padding: 0.3rem 0.4rem;
    font-size: 0.85rem;
}
.editor-btn {
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    border-radius: 6px;
    padding: 0.3rem 0.55rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.editor-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
.editor-btn-active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.editor-area {
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: var(--color-surface);
    min-height: 320px;
    padding: 1rem;
    overflow: auto;
}
.editor-area:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}
.editor-source {
    border-radius: 0 0 var(--radius) var(--radius) !important;
}
.editor-sep {
    width: 1px;
    align-self: stretch;
    background: var(--color-border);
    margin: 0 0.2rem;
}
.editor-toolbar .editor-color {
    width: 34px;
    height: 30px;
}

/* --- Media management grid --- */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.media-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.media-item img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
    background: var(--color-bg);
}
.media-meta {
    padding: 0.5rem 0.6rem;
}
.media-meta small {
    word-break: break-all;
}
.media-actions {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}

/* --- Reports overview cards --- */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}
.report-card {
    display: flex;
    flex-direction: column;
}
.report-card .report-icon {
    font-size: 1.8rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}
.report-card h2 {
    margin: 0 0 0.25rem;
    font-size: 1.1rem;
}
.report-card p {
    margin-top: 0;
    flex: 1;
}
.report-card select {
    width: 100%;
    margin-bottom: 0.75rem;
}

/* --- CMS: editor + public page content --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0 1rem;
}
.code-area {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}
.page-content {
    max-width: 720px;
}
.page-content h1 {
    margin-top: 0.5rem;
}
.page-content img {
    max-width: 100%;
    height: auto;
}
.page-content table {
    width: auto;
}

.check-label-block {
    align-items: flex-start;
    white-space: normal;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}
.chip {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    margin: 0.25rem 0.25rem 0.25rem 0;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    font-size: 0.8rem;
    cursor: pointer;
}
.chip:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
#team-vorschlaege {
    color: var(--color-muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.flash ul {
    margin: 0;
    padding-left: 1.2rem;
}
.flash-success {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}
.flash-error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

/* Spielplan: Pausenzeile + kompakte Ergebnis-Eingabe */
/* Entfallenes Spiel: eine der Mannschaften ist abgemeldet. Bewusst nur gedaempft
   und nicht ausgeblendet — die Zeile bleibt im Plan stehen, damit am Feld klar
   ist, dass hier nichts stattfindet (und nicht etwa etwas vergessen wurde). */
.spiel-entfaellt td {
    opacity: 0.55;
}
.spiel-entfaellt .begegnung {
    text-decoration: line-through;
}
.spielplan-pause td {
    background: var(--color-hover);
    text-align: center;
    font-weight: 600;
    color: var(--color-muted);
}
/* Pausen-Editor: eine Zeile = Runde + Dauer + Name + Entfernen. Bei schmalem
   Fenster brechen die Felder untereinander um (flex-wrap), damit die Karte
   nirgends horizontal scrollt. */
.pausen-zeile {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.pausen-zeile label {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-muted);
}
.pausen-zeile select,
.pausen-zeile input {
    margin: 0;
}
.pausen-zeile input[type='number'] {
    width: 6rem;
}
/* Die Vorschau ist eine reine Anzeige — keine Aktionen, deshalb schmaler. */
.zeitplan-vorschau td:first-child {
    width: 6rem;
    font-variant-numeric: tabular-nums;
}
.ergebnis-form {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.ergebnis-form input[type='number'] {
    width: 4.2rem;
    min-width: 0;
}
/* Meldestatus je Spiel: Badge + Freigabe-Button unter dem Ergebnisfeld,
   darunter eine Zeile, wer gemeldet bzw. bestätigt hat. */
.meldung-aktionen {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: 0.3rem;
}
.meldung-herkunft {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.78rem;
    line-height: 1.3;
    color: var(--color-muted);
}
/* Verlauf je Spiel im Spielplan — am Turniertisch aufklappbar, klein gehalten. */
.spiel-protokoll {
    margin-top: 0.25rem;
    font-size: 0.78rem;
    text-align: left;
}
.spiel-protokoll summary {
    cursor: pointer;
    color: var(--color-muted);
}
.spiel-protokoll ol {
    margin: 0.25rem 0 0;
    padding-left: 1.1rem;
    color: var(--color-muted);
}
.spiel-protokoll li {
    margin-bottom: 0.15rem;
    line-height: 1.35;
}
.spiel-protokoll .protokoll-zeit {
    font-variant-numeric: tabular-nums;
    margin-right: 0.3rem;
}
.spiel-protokoll .protokoll-detail {
    display: block;
}
/* Begegnung: auf Desktop inline „Heim – Gast“, das Phase-/Gruppen-Tag darunter. */
.spiel-meta {
    display: block;
    margin-top: 0.3rem;
}
@media (max-width: 940px) {
    .liste-karte:has(.liste--breit) .spielplan-pause td::before {
        display: none;
    }
    .liste-karte:has(.liste--breit) .spielplan-pause td {
        justify-content: center;
    }
    /* Spielplan-Karten: bei geringer Breite Label über den Inhalt stapeln,
       damit Inhalt (v. a. das Ergebnis-Formular) die volle Kartenbreite hat. */
    .liste-karte:has(.spielplan-liste) .liste tbody td {
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
        padding: 0.5rem 0.9rem;
    }
    .liste-karte:has(.spielplan-liste) .liste tbody td::before {
        flex: none;
    }
    /* Mannschaftsnamen untereinander: Name 1 / – / Name 2. */
    .spielplan-liste .begegnung {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1rem;
        font-size: 1.02rem;
        line-height: 1.35;
    }
    .spielplan-liste .begegnung .vs {
        color: var(--color-muted);
    }
    /* Team-Seite: Namen und Strich mittig in der Karte. */
    .spielplan-liste--team .begegnung {
        align-items: center;
        text-align: center;
    }
    /* Ergebnis-Formular volle Breite, „Speichern“ bleibt in der Karte. */
    .spielplan-liste .ergebnis-form {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        width: 100%;
    }
    .spielplan-liste .ergebnis-form .btn {
        margin-left: auto;
    }
    .spielplan-liste .meldung-aktionen {
        justify-content: flex-start;
    }
}

/* --- Würfelentscheid: letzte Instanz der Tabellen-Rangfolge ------------- */
/* Sitzt unter der betroffenen Tabelle und wird nur gezeigt, wenn eine
   Gruppe ausgespielt ist und Mannschaften ueber alle Kriterien gleich sind. */
.wuerfel-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    margin: 0.75rem 0 1.25rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-zebra);
}
.wuerfel-hinweis {
    flex: 1 0 100%;
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-muted);
}
.wuerfel-feld {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.85rem;
}
.wuerfel-feld input[type='number'] {
    width: 5rem;
    min-height: 44px;
}
.wuerfel-form .btn {
    min-height: 44px;
}
@media (max-width: 640px) {
    .wuerfel-feld {
        flex: 1 0 100%;
    }
    .wuerfel-feld input[type='number'] {
        width: 100%;
    }
    .wuerfel-form .btn {
        width: 100%;
    }
}

/* --- Mannschaftsübersicht (public + intern) ----------------------------- */
.uebersicht-grafik {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: var(--radius);
}
.vorschau-label {
    margin-top: 0.75rem;
}
.team-link {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.85rem;
    word-break: break-all;
}
/* Tabs (Infos / Grafik on the internal overview). First panel shows without JS. */
.tab-nav {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}
.tab-btn {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.6rem 1rem;
    min-height: 44px;
    font: inherit;
    font-weight: 600;
    color: var(--color-muted);
    cursor: pointer;
}
.tab-btn:hover {
    color: var(--color-text);
}
.tab-btn.is-active {
    color: var(--color-text);
    border-bottom-color: var(--color-primary);
}
.tab-panel[hidden] {
    display: none;
}
/* Tournament info block rendered from trusted editor HTML on the team pages. */
.team-infos {
    margin: 1rem 0;
}
.team-infos > :first-child {
    margin-top: 0;
}
.team-infos > :last-child {
    margin-bottom: 0;
}
/* Colour accent so a team sees at a glance which games it plays vs. referees. */
.spielplan-liste tr.rolle-spielt td.zelle-haupt {
    box-shadow: inset 4px 0 0 var(--color-success-text);
}
.spielplan-liste tr.rolle-pfeift td.zelle-haupt {
    box-shadow: inset 4px 0 0 var(--color-border-strong);
}

/* --- Druckansicht Spielplan (PDF-Export) --------------------------------- */
/* Bildschirm-Vorschau der Druckseite: gleiche Struktur, damit „Als PDF drucken“
   1:1 das zeigt, was gedruckt wird. Alle Blätter drucken hochkant (A4 portrait). */
.nur-druck {
    display: none;
}
.druck-blatt {
    margin-bottom: 2.5rem;
}
.druck-titel {
    margin: 0 0 0.4rem;
}
.druck-untertitel {
    margin: 0 0 0.4rem;
    font-size: 1rem;
}
.druck-meta {
    margin: 0 0 0.7rem;
    font-size: 0.85rem;
    color: var(--color-muted);
}
/* Rahmenmodell: EIN kohärenter Ansatz statt gestapelter Kanten — border-collapse:
   collapse. Damit teilen sich zwei Nachbarzellen genau EINE Kante: nie doppelt/dreifach
   gezeichnet, gleichmäßig dünn, eckige (nicht runde) Ecken, und kein Zell-Hintergrund
   kann eine Nachbarkante übermalen (die Kanten gehören im Collapse-Modell der Tabelle,
   nicht der Einzelzelle). Jede Zelle UND das Tabellen-Element tragen denselben 1px-Rahmen;
   an den Außenkanten kollabieren beide zu einer einzigen Linie (keine Verdopplung), innen
   liegt zwischen zwei Zellen genau eine geteilte Linie. `border-radius: 0` überschreibt
   den abgerundeten Basis-`table`-Stil (der mit sichtbarem Rahmen sonst runde Ecken samt
   hineinlaufender Linie erzeugt). Der Zell-Selektor `tr th/td` hat Spezifität (0,1,2) und
   überstimmt damit den globalen `tr:last-child td { border-bottom: none }` der
   .tabelle/.liste-Basis, der sonst die Unterkante der letzten <tbody>-Zeile schluckt. */
.druck-tabelle {
    width: 100%;
    border-collapse: collapse;
    border-radius: 0;
    border: 1px solid var(--color-border-strong);
}
.druck-tabelle tr th,
.druck-tabelle tr td {
    border: 1px solid var(--color-border-strong);
    padding: 6px 8px;
    font-size: 0.85rem;
    vertical-align: top;
}
.druck-tabelle thead th {
    background: var(--color-zebra);
    text-align: left;
    font-weight: 600;
}
.druck-tabelle .col-nr {
    width: 2.5em;
    text-align: center;
}
.druck-tabelle .col-zeit {
    width: 5em;
    white-space: nowrap;
}
.druck-tabelle .col-schiri {
    width: 7em;
}
.druck-tabelle .col-ergebnis {
    width: 5.5em;
    text-align: center;
}
/* Pausenzeile in der Spielplan-Tabelle — am Bildschirm wie im Druck grau
   hinterlegt, damit die Vorschau dem Ausdruck entspricht. */
.druck-pause-zeile td {
    background: var(--color-hover);
    text-align: center;
    font-weight: 600;
}
.druck-tabelle .klein {
    font-size: 0.75rem;
    color: var(--color-muted);
}
.druck-tabelle .platzhalter {
    font-style: italic;
    color: var(--color-muted);
}
/* Pausenhinweis zwischen den beiden Spielplan-Seiten (statt einer Zeile in der
   Tabelle — so bleibt jede Tabelle in sich geschlossen und randscharf). */
.druck-pause-text {
    margin: 0.8rem 0 0;
    padding: 0.5rem 0.7rem;
    background: var(--color-hover);
    border-left: 3px solid var(--color-border-strong);
    font-size: 0.85rem;
    font-weight: 600;
}
/* Ergebnis-Eintragung: nur zentrierter Doppelpunkt, Zahlen handschriftlich davor/danach */
.spielplan-druck tbody td {
    padding-top: 9px;
    padding-bottom: 9px;
}
.doppelpunkt {
    font-size: 1.15rem;
    font-weight: 700;
}

/* Erfassungstabelle (hochkant): Mannschaften untereinander; jede Mannschaft in drei
   gleich hohen Unterzeilen (Spielnummer / Spielpunkte / +-Punkte). Gleiche
   Spaltenbreiten über <colgroup> + table-layout:fixed. */
.erfassung-wrap {
    /* Kein eigener Scroll-Kasten: die Tabelle überläuft (auf schmalen Screens per
       min-width) wie die Spielplan-Tabelle darüber, sodass beide gleich auf
       Seitenebene horizontal scrollen statt in einem schmaleren Bereich. */
    overflow-x: visible;
}
.erfassung {
    table-layout: fixed;
}
.erfassung th,
.erfassung td {
    text-align: center;
    vertical-align: middle;
    padding: 5px 3px;
}
.erfassung .team-zelle {
    text-align: left;
    white-space: normal;
    word-break: break-word;
}
.erfassung .erf-label {
    font-weight: 600;
    font-size: 0.75rem;
    line-height: 1.15;
    white-space: nowrap;
}
/* Summenzelle der Spielnummer-Zeile: nichts zu summieren -> grau gesperrt. Im
   Collapse-Modell gehören die Kanten der Tabelle (nicht der Zelle), der graue
   Hintergrund kann sie daher nicht mehr übermalen. */
.erfassung .gesperrt {
    background: var(--color-zebra);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.erfassung tbody td {
    height: 2.4rem;
}
/* Die drei Unterzeilen einer Mannschaft zusammenhalten (kein Umbruch mittendrin). */
.erfassung tbody.team-block {
    break-inside: avoid;
}
/* Am Bildschirm auf schmalen Geräten nicht auf Viewport-Breite quetschen, sondern
   (wie die Spielplan-Tabelle) horizontal scrollen — so bleiben die Spalten lesbar.
   Der @media-print-Block unten setzt die Breite fürs A4-Blatt wieder auf 100 %. */
@media (max-width: 680px) {
    .erfassung {
        min-width: 40rem;
    }
}

/* Gruppentabellen + Endstand nebeneinander */
.druck-tabellen-raster {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.5rem;
}
.tabelle-druck th,
.tabelle-druck td {
    text-align: center;
}
.tabelle-druck .team-zelle {
    text-align: left;
}
.tabelle-druck tbody td {
    height: 2rem;
}
.druck-abstand {
    margin-top: 1.8rem;
}
.abschluss-wrap {
    max-width: 26rem;
}

@media print {
    .site-header,
    .sub-nav,
    .turnier-nav,
    .site-footer,
    .flash,
    .nur-bildschirm {
        display: none !important;
    }
    .nur-druck {
        display: block;
    }
    body {
        background: #fff;
        color: #000;
        font-size: 10pt;
    }
    main.container {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    @page {
        size: A4 portrait;
        margin: 18mm 12mm 12mm;
    }

    .druck-blatt {
        margin-bottom: 0;
    }
    /* Jedes Blatt beginnt auf einer neuen Seite. */
    .druck-blatt + .druck-blatt {
        break-before: page;
    }
    /* Entfallene Spiele bleiben im Ausdruck stehen, nur durchgestrichen —
       auf Papier ist Ausgrauen unzuverlaessig. */
    .spiel-entfaellt td {
        opacity: 1;
        text-decoration: line-through;
    }
    /* Pausenzeile mitten in der Spielplan-Tabelle. */
    .druck-pause-zeile td {
        background: #eaeaea;
        text-align: center;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    /* Der Pausenhinweis klebt am Ende der ersten Spielplan-Seite. */
    .druck-pause-text {
        background: #eaeaea;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Rahmenmodell (siehe Bildschirm-Block): dieselben geteilten Kanten, nur die Farbe
       auf reines Schwarz. */
    .druck-tabelle,
    .druck-tabelle tr th,
    .druck-tabelle tr td {
        border-color: #000;
    }
    .druck-tabelle tr th,
    .druck-tabelle tr td {
        padding: 5px 7px;
    }
    .druck-tabelle thead th {
        background: #eaeaea;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .druck-tabelle tr {
        break-inside: avoid;
    }
    /* Kopfzeile jeder (Teil-)Tabelle auf Folgeseiten wiederholen, falls eine
       Tabelle doch einmal länger als eine Seite wird. */
    .druck-tabelle thead {
        display: table-header-group;
    }
    .spielplan-druck tbody td {
        height: 9mm;
    }
    .erfassung {
        font-size: 9pt;
    }
    /* Spezifität beachten: `.druck-tabelle tr th/td` (0,1,2) weiter oben schlägt
       jede Regel `.erfassung th/td` (0,1,1) — die Tabelle trägt beide Klassen,
       deshalb hier ebenfalls über `tr`. Ohne das greifen dort 5px Innenabstand;
       zusammen mit der zweizeiligen Beschriftung („Spiel-/nummer“) wird jede
       Zeile 10,2mm statt 8mm hoch, das Blatt 277mm statt der verfügbaren 267mm —
       und die achte Mannschaft rutscht auf eine zweite Seite. Nur Abstände, am
       Rahmenmodell ändert das nichts. */
    .erfassung tr th,
    .erfassung tr td {
        padding: 2px 4px;
    }
    .erfassung tbody td {
        height: 8mm;
    }
    .tabelle-druck tbody td {
        height: 9mm;
    }
}
