/* Zusätzlich durch das media-Attribut isoliert. Keine Wirkung auf Desktop/Druck. */
@media screen and (max-width: 768px) {
    :root {
        --grund: var(--ui-white); --karte: var(--ui-ivory); --aktion: var(--ui-deep-blue);
        --aktion-hell: #e4eff5; --linie: #b4cad5; --linie-stark: var(--ui-dust-denim);
        --text: var(--ui-text); --text-leise: var(--ui-text);
        --schrift: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    }
    html { scroll-padding-bottom: 110px; }
    body { padding-bottom: calc(88px + env(safe-area-inset-bottom)); line-height: 1.5; }
    header.kopf {
        position: relative; padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
        gap: 8px; background: var(--grund); border: 0; box-shadow: none;
    }
    .marke { flex: 1; min-width: 0; font-size: 17px; white-space: normal; color: var(--aktion); }
    .marke .person { display: block; margin: 2px 0 0; font-size: 13px; color: var(--text); }
    .navi-rollbereich { display: none; }
    .sprachwahl { display: flex; gap: 2px; }
    .sprachwahl button { min-width: 44px; min-height: 44px; padding: 6px; border-radius: 12px; }
    .kopfzahlen { padding: 6px 16px 12px; gap: 12px; flex-wrap: wrap; background: transparent; }
    .kopfsaldo { flex: 1; min-width: 85px; text-align: left; }
    .kopfsaldo .beschriftung { font-size: 11px; white-space: normal; letter-spacing: 0; }
    .kopfsaldo .wert { font-size: 23px; font-variant-numeric: tabular-nums; }
    main { padding: 4px 14px 20px; min-width: 0; }
    .karte { padding: 18px 16px; border-radius: 20px; border: 1px solid var(--linie); box-shadow: none; margin-bottom: 14px; min-width: 0; }
    h2 { font-size: 18px; color: var(--aktion); overflow-wrap: anywhere; }
    .spalten { flex-direction: column; gap: 0; }
    .spalten > * { min-width: 0; width: 100%; max-width: 100%; flex-basis: auto; }
    .feldraster { grid-template-columns: 1fr; }
    button, .knopf, button.winzig, button.alslink, .meldungsliste .knopf.winzig {
        min-height: 44px; padding: 10px 14px; border-radius: 12px; touch-action: manipulation;
    }
    button.haupt, .knopf.haupt { background: var(--ui-deep-blue); border-color: var(--ui-deep-blue); color: var(--ui-white); }
    button:active, .knopf:active { opacity: .8; }
    button:disabled { opacity: .55; }
    :focus-visible { outline: 3px solid var(--ui-deep-blue); outline-offset: 3px; }
    input[type="text"], input[type="number"], input[type="date"], input[type="email"], select, textarea {
        font-size: 16px; min-height: 44px; max-width: 100%; border-radius: 10px;
    }
    input.zeit { width: 82px; padding: 10px 6px; }
    .segmente li { flex-wrap: wrap; gap: 8px; padding: 12px 0; }
    .segmente li .dauer { margin-left: 0; }
    .seite-heute .zeitliste { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
    .seite-heute .zeitliste > button.haupt { order: -1; min-height: 72px; width: 100%; font-size: 21px; font-weight: 700; border-radius: 18px; }
    .stempelmeldung { flex-wrap: wrap; margin: 0 0 14px; border-radius: 18px; }
    .stempelmeldung .text { font-size: 20px; }
    .stempelmeldung .korrektur { flex-wrap: wrap; }
    .karte table:not(.tagesliste):not(.matrix) { display: block; max-width: 100%; overflow-x: auto; }
    .rollbar { max-width: 100%; overflow-x: auto; }
    .spiegel-personalien { grid-template-columns: 1fr; }
    .spiegel-personalien .feldname { min-width: 0; }
    .dialog-hintergrund { padding: 12px; align-items: flex-end; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .dialog { border-radius: 22px; max-height: 85dvh; overflow-y: auto; padding: 22px 18px; }
    .dialog-knoepfe { flex-direction: column-reverse; }
    .dialog-knoepfe button { width: 100%; }
    #quittung { bottom: calc(92px + env(safe-area-inset-bottom)); left: 14px; right: 14px; }
    /* Bisherige erzwungene Drehung vollständig aufheben. */
    html:has(body.seite-meldungen), body.seite-meldungen { overflow: auto; }
    body.seite-meldungen .rahmen-inhalt { position: static; width: auto; height: auto; transform: none; overflow: visible; }
    body.seite-meldungen .dialog-hintergrund { inset: 0; width: auto; height: auto; transform: none; }
    .mobile-tabs {
        display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
        position: fixed; inset: auto 0 0; z-index: 80;
        padding: 8px max(6px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
        background: var(--ui-white); border-top: 1px solid #b4cad5; box-shadow: 0 -4px 22px #18314f0d;
    }
    .mobile-tabs > a, .mobile-mehr > summary {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 4px; min-height: 56px; padding: 6px 2px; border-radius: 14px;
        font-size: 11px; font-weight: 600; text-decoration: none; color: var(--ui-text); cursor: pointer;
        text-align: center; overflow-wrap: anywhere; touch-action: manipulation;
    }
    .mobile-tabs [aria-current="page"], .mobile-mehr > summary.aktiv, .mobile-mehr[open] > summary { background: var(--ui-deep-blue); color: var(--ui-white); }
    .mobile-mehr > summary { list-style: none; }
    .mobile-mehr > summary::-webkit-details-marker { display: none; }
    .mobile-menue { position: absolute; bottom: calc(100% + 10px); right: 14px; left: 14px; padding: 8px; background: var(--ui-ivory); border: 1px solid var(--ui-dust-denim); border-radius: 20px; box-shadow: 0 8px 32px #18314f26; }
    .mobile-menue a { display: flex; align-items: center; gap: 10px; padding: 14px; min-height: 48px; color: var(--ui-deep-blue); text-decoration: none; border-radius: 12px; }
    .mobile-punkt { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ui-dust-denim); margin-left: 3px; }
}

@media screen and (max-width: 768px) {
    .mobile-hidden { display: none !important; }
    .monatsstart, .hauptschalter { background: var(--ui-pale-sky); }
    .karte table:not(.matrix) thead th { background: var(--ui-pale-sky); color: var(--ui-text); }
    .mobile-exports { display: flex; justify-content: flex-end; gap: 4px; margin: -6px -4px 6px 0; }
    .mobile-exports button, .mobile-exports a.knopf { font-size: 12px; min-width: 40px; min-height: 40px; padding: 6px 8px; border-radius: 8px; }
    .mobile-exports button:last-child { font-size: 23px; line-height: 1; }
    .seite-monat main > .karte > .zeitliste:has(> #export-excel) { margin: 0 !important; }
    .mobile-month-title { display: grid; grid-template-columns: 36px minmax(0, 1fr) 76px 36px; align-items: center; gap: 4px; margin-bottom: 12px; }
    .mobile-month-title select#monat-wahl, .mobile-month-title input#jahr-wahl { width: 100%; max-width: none !important; padding: 6px 2px; font-size: 17px; font-weight: 700; color: var(--ui-deep-blue); border: 0; background: transparent; }
    .mobile-month-title a.knopf { min-height: 44px; padding: 4px; text-align: center; font-size: 26px; border: 0; background: transparent; }
    .mobile-absence-time { display: flex; align-items: center; gap: 5px; width: 100%; flex-wrap: wrap; }
    .mobile-absence-time button { padding: 6px; min-width: 36px; font-size: 19px; }
    .mobile-absence-time .absenzpaar { gap: 4px; }
    .mobile-absence-caption { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
    .mobile-absence-pair { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; }
    .mobile-absence-pair .merker { white-space: normal; }
    .mobile-absence-pair button { flex: none; min-width: 36px; padding: 6px; }
    table.tagesliste, table.tagesliste tbody, table.tagesliste tfoot, table.tagesliste tr, table.tagesliste td { display: block; width: auto; }
    table.tagesliste thead { display: none; }
    table.tagesliste tr { background: var(--ui-ivory); border: 1px solid var(--linie); border-radius: 12px; margin: 0 0 8px; padding: 10px; }
    table.tagesliste tr.wochenende { background: #eceef1; }
    table.tagesliste tr.feiertag { background: #e4e4e4; }
    table.tagesliste tr.heute { border-left: 4px solid var(--ui-deep-blue); }
    table.tagesliste td { border: 0; padding: 2px 0; background: none !important; text-align: left; }
    table.tagesliste td:empty { display: none; }
    table.tagesliste td[data-spalte] { display: inline-block; margin-right: 8px; }
    table.tagesliste td[data-spalte]::before { content: attr(data-spalte) ' '; font-size: 10px; color: var(--ui-text); }
    table.tagesliste tr[data-tag] > td:nth-child(-n+2)::before { content: none; }
    table.tagesliste tr[data-tag] > td:first-child { font-weight: 700; }
    table.tagesliste td.mobile-note-cell { display: flex; align-items: center; gap: 6px; }
    .mobile-note-cell input { flex: 1; min-width: 0; width: 0; font-size: 16px !important; }
    .mobile-note-cell a { flex: none; min-width: 36px; padding: 6px; }
    table.tagesliste tr.wochensumme, table.tagesliste tr.monatstotal { background: var(--ui-text); border-color: var(--ui-text); color: var(--ui-white); }
    table.tagesliste tr:is(.wochensumme, .monatstotal) td,
    table.tagesliste tr:is(.wochensumme, .monatstotal) td::before,
    table.tagesliste tr:is(.wochensumme, .monatstotal) .leise { color: var(--ui-white); }
    .mobile-warning { position: fixed; right: 0; top: 155px; z-index: 90; }
    .mobile-warning > summary { display: flex; width: 42px; height: 46px; align-items: center; justify-content: center; list-style: none; cursor: pointer; border-radius: 12px 0 0 12px; background: var(--ui-white); border: 1px solid #e5c04b; box-shadow: 0 2px 10px #18314f18; }
    .mobile-warning > summary::-webkit-details-marker { display: none; }
    .mobile-warning svg { width: 30px; height: 30px; }
    .mobile-warning-content { position: absolute; right: 44px; top: 0; width: min(310px, calc(100vw - 60px)); max-height: 60dvh; overflow-y: auto; padding: 12px; border: 1px solid #e5c04b; border-radius: 14px; background: #FFF8D9; box-shadow: 0 4px 24px #18314f20; }
    .mobile-warning-content .warnung, .mobile-warning-content .meldungsleiste, .mobile-warning-content .meldungsleiste-grund { padding: 0; margin: 0; max-width: 100%; border: 0; background: transparent; color: var(--ui-text); }
    .mobile-warning-content .meldungsleiste { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
    .mobile-warning-content .warnung + .warnung { margin-top: 14px; }
    .mobile-warning-content .warnung strong { color: var(--ui-text); }
    .mobile-warning-icon { display: inline-block; width: 22px; height: 22px; vertical-align: middle; }
    .mobile-warning-icon svg { width: 100%; height: 100%; }
    .seite-meldungen .jahrwahl { position: sticky; top: 0; z-index: 60; padding: 8px 0; background: var(--ui-white); display: flex; flex-wrap: wrap; gap: 6px; }
    .seite-meldungen .jahrwahl > .leise { display: none; }
    .seite-meldungen .jahrstepper a, .seite-meldungen .jahrstepper .pfeil, .seite-meldungen .jahrstepper .jahrzahl { padding: 8px; }
    .mobile-case-jumps { display: grid; grid-template-columns: repeat(3, 1fr); flex: 0 1 auto; margin-left: auto; gap: 4px; }
    .mobile-case-jumps a { justify-content: center; text-align: center; min-width: 0; overflow-wrap: anywhere; padding: 10px 6px; min-height: 44px; font-size: 12px; color: var(--ui-deep-blue); text-decoration: none; background: var(--ui-pale-sky); border-radius: 8px; display: flex; align-items: center; }
    .mobile-case-list { display: grid; gap: 8px; }
    .mobile-case-card { display: grid; width: 100%; grid-template-columns: 1fr auto; gap: 4px 8px; text-align: left; padding: 14px; background: var(--ui-white); border: 1px solid #b4cad5; border-radius: 12px; color: var(--ui-text); }
    .mobile-case-card strong { color: var(--ui-deep-blue); font-size: 16px; }
    .mobile-case-date { grid-column: 1 / -1; font-size: 13px; white-space: normal; }
    .mobile-case-type { grid-column: 1 / -1; font-size: 14px; font-weight: 600; }
    .mobile-case-warning { display: flex; align-items: center; gap: 5px; font-size: 12px; }
    .mobile-case-warning svg { width: 18px; height: 18px; }
    body.mobile-case-open { overflow: hidden; }
    .mobile-case-panel { position: fixed; inset: 0; z-index: 150; overflow-y: auto; overscroll-behavior: contain; background: var(--ui-white); padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
    .mobile-case-header { position: sticky; top: 0; padding: calc(8px + env(safe-area-inset-top)) 0 12px; background: var(--ui-white); border-bottom: 1px solid #b4cad5; z-index: 1; }
    .mobile-case-header button { background: transparent; border: 0; color: var(--ui-deep-blue); padding-left: 0; }
    .mobile-case-header h2 { margin: 4px 0; }
    .mobile-case-field { padding: 14px; background: var(--ui-ivory); border-radius: 12px; margin-top: 10px; }
    .mobile-case-field h3 { margin: 0 0 5px; font-size: 12px; font-weight: 600; color: var(--ui-text); }
    .mobile-case-value { font-size: 16px; overflow-wrap: anywhere; white-space: normal; }
    .mobile-case-value .merker { white-space: normal; }
    .mobile-case-value button, .mobile-case-value .knopf { margin: 4px 4px 4px 0; }
}
@media screen and (max-width: 768px) {
    .mobile-warning { top: calc(50dvh - 24px); }
    .mobile-warning > summary { width: 30px; }
    .mobile-warning > summary svg { width: 24px; }
    .mobile-warning-content { right: 32px; }
    .mobile-exports { margin-right: 0; }
    .seite-meldungen main > .karte { background: var(--ui-white); border: 0; padding: 8px 0; }
    .mobile-case-card { background: var(--ui-ivory); }
    .mobile-case-jumps { max-width: 100%; }
}

/* Präzisierungen nach den Handy-Referenzen 29–36. */
@media screen and (max-width: 768px) {
    :root { --grund: var(--ui-ivory); --karte: var(--ui-white); --linie: var(--ui-deep-blue); --linie-stark: var(--ui-deep-blue); }
    header.kopf, .kopfzahlen, .mobile-tabs, .mobile-menue { background: var(--ui-ivory); }
    .karte, .dialog, .mobile-case-card, .mobile-case-field, .jahreswahl {
        background: var(--ui-white); border: 1px solid var(--ui-deep-blue);
    }
    table.tagesliste tr { background: var(--ui-white); border-color: var(--ui-deep-blue); }
    table.tagesliste tr.wochenende { background: #eceef1; }
    table.tagesliste tr.feiertag { background: #e4e4e4; }
    table.tagesliste tr.wochensumme, table.tagesliste tr.monatstotal { background: var(--ui-text); }
    .mobile-tabs, .mobile-case-header { border-color: var(--ui-deep-blue); }
    .mobile-case-panel, .mobile-case-header { background: var(--ui-ivory); }
    .seite-meldungen main > .karte { background: transparent; }
    .seite-meldungen .jahrwahl { background: var(--ui-ivory); }
    .seite-meldungen .segmentwahl a:not(.aktiv), .seite-meldungen .jahrstepper a,
    .seite-meldungen .jahrstepper .pfeil { background: var(--ui-pale-sky); }
    .mobile-case-jumps a { background: var(--ui-deep-blue); color: var(--ui-white); }
    .mobile-absence-pair { align-items: stretch; }
    .mobile-absence-pair button.winzig {
        min-height: 0; min-width: 24px; padding: 0 5px; border-radius: 4px;
        font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
    }
    .mobile-absence-pair .merker { display: inline-flex; align-items: center; }
    .mobile-note-cell a.knopf {
        display: inline-flex; align-items: center; justify-content: center;
        height: 44px; min-height: 44px; padding: 0 10px; line-height: 1; font-size: 16px;
    }
    .mobile-absence-time { flex-wrap: nowrap; gap: 6px; }
    .mobile-absence-time .absenzpaar { flex: 1; min-width: 0; gap: 4px; }
    .mobile-absence-time .absenzpaar input.zeit { flex: 1; width: 0; min-width: 0; }
    .mobile-absence-time > .dauer { flex: none; margin-left: 0; }
    .mobile-absence-time > button { margin-left: auto; flex: none; padding: 8px; font-size: 12px; }
    .seite-heute .zeitliste > button.segment-neu { font-size: 18px; font-weight: 600; min-height: 54px; }
    .seite-ueberzeit table tfoot td, .seite-jahr table:not(.matrix) tfoot td { background: var(--ui-pale-sky); }
    .seite-jahr table:not(.matrix) tbody td { background: var(--ui-white); }
    .mobile-year-heading { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
    .mobile-year-heading h2 { margin: 0; font-size: clamp(14px, 4vw, 18px); }
    .mobile-year-heading .mobile-exports { flex: none; margin: 0; }
    .mobile-year-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 8px 0 14px; }
    .mobile-year-meta > span:first-child { min-width: 0; overflow-wrap: anywhere; }
    .mobile-year-meta > span:last-child { flex: none; font-size: 11px; }
    .spiegel-personalien { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 8px; font-size: 13px; }
    .spiegel-personalien > div { min-width: 0; overflow-wrap: anywhere; }
    .spiegel-personalien .feldname { display: block; font-size: 11px; margin-bottom: 2px; }
    .mobile-year-picker { display: inline-flex; align-items: center; gap: 6px; }
    .mobile-year-picker a { min-width: 36px; text-align: center; font-size: 24px; padding: 4px; background: var(--ui-pale-sky); }
    .mobile-year-picker select { font-size: 18px; font-weight: 600; text-align: center; }
    table.tagesliste tr.heute { background: var(--ui-white); }
    table.tagesliste tr.wochensumme, table.tagesliste tr.monatstotal { background: var(--ui-pale-sky); border-color: var(--ui-deep-blue); }
    table.tagesliste tr:is(.wochensumme, .monatstotal) td,
    table.tagesliste tr:is(.wochensumme, .monatstotal) td::before,
    table.tagesliste tr:is(.wochensumme, .monatstotal) .leise { color: var(--ui-text); }
    .mobile-absence-time .absenzpaar input.zeit { padding-left: 2px; padding-right: 2px; }
    .mobile-absence-time > .zeit { flex: 1; width: 70px; min-width: 0; padding: 9px 2px; }
}

@media screen and (max-width: 768px) {
    :root { --grund: var(--ui-background); }
    header.kopf, .kopfzahlen, .mobile-tabs, .mobile-menue { background: var(--ui-ivory); }
    .seite-meldungen .jahrwahl { background: var(--ui-background); }
    .mobile-punkt { background: var(--ui-negative); }
    table.tagesliste tr.monatstotal td.plus { color: var(--plus); }
    table.tagesliste tr.monatstotal td.minus { color: var(--minus); }
    table.tagesliste tr.aufteilung { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px; background: #e4eff5; }
    table.tagesliste tr.aufteilung td:first-child { grid-column: 1 / -1; text-align: left; line-height: 1.5; }
    table.tagesliste tr.aufteilung td { margin: 0; padding: 0; }
    table.tagesliste tr.aufteilung td > br:first-child { display: none; }
    table.tagesliste tr.aufteilung td:has(a) { align-self: center; text-align: right; }
    table.tagesliste tr.aufteilung td a { display: inline-block; padding: 6px 10px; border: 1px solid var(--ui-deep-blue); border-radius: 8px; text-decoration: none; color: var(--ui-deep-blue); font-family: var(--schrift); }
    .mobile-month-title { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: start; margin: 0 0 12px; }
    .mobile-month-group { display: flex; grid-column: 1; grid-row: 1; min-width: 0; align-items: stretch; }
    .mobile-month-group a.knopf { min-width: 24px; padding: 2px; flex: none; }
    .mobile-month-group select#monat-wahl { min-width: 0; width: 100%; font-size: 15px; padding: 0 2px; }
    .mobile-month-title > .mobile-exports { grid-column: 2; grid-row: 1 / 3; margin: 0; gap: 3px; align-self: start; }
    .mobile-month-title .mobile-exports button { min-width: 32px; padding: 6px; }
    .mobile-month-title > .mobile-year-picker { grid-column: 1; grid-row: 2; justify-self: start; }
    .mobile-year-picker, .seite-meldungen .jahrstepper { display: inline-flex; gap: 0; align-items: stretch; border: 1px solid var(--ui-deep-blue); border-radius: 9px; overflow: hidden; }
    .mobile-year-picker a.knopf, .seite-meldungen .jahrstepper a, .seite-meldungen .jahrstepper .pfeil {
        display: inline-flex; align-items: center; justify-content: center; align-self: stretch;
        border: 0; border-radius: 0; padding: 0 8px; min-width: 32px; min-height: 42px; margin: 0; background: var(--ui-pale-sky); line-height: 1;
    }
    .mobile-year-picker select, .seite-meldungen select.mobile-message-year {
        width: auto; max-width: 100px !important; min-height: 42px; height: 42px; margin: 0;
        border: 0; border-left: 1px solid var(--ui-deep-blue); border-right: 1px solid var(--ui-deep-blue);
        border-radius: 0; background: var(--ui-white); font-size: 16px; padding: 0 5px;
    }
    .mobile-warning > summary { width: 36px; }
    .mobile-warning-content { right: 38px; width: max-content; max-width: min(310px, calc(100vw - 54px)); padding: 9px; }
    .mobile-warning-content .meldungsleiste-grund { display: block; }
    .mobile-warning-content .meldungsleiste { width: auto; min-width: 0; text-align: left; gap: 6px; }
    .mobile-warning-content .meldungsleiste > span { flex: none; }
    .mobile-warning-content .knopf { display: inline-flex; justify-content: center; align-items: center; min-height: 35px; padding: 6px 11px; font-size: 12px; line-height: 1; }
    /* Gleiche Spaltenbreiten für gestempelte und abwesende Zeitpaare. */
    .seite-heute .segmente li:not(.absenzzeile):has(> input.zeit), .mobile-absence-time {
        display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto auto; align-items: center; column-gap: 6px;
    }
    .mobile-absence-time .absenzpaar { grid-column: 1 / 4; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; }
    .seite-heute .segmente input.zeit, .mobile-absence-time .absenzpaar input.zeit, .mobile-absence-time > .zeit { width: 100%; min-width: 0; padding: 9px 2px; }
    .seite-heute .segmente li > button, .mobile-absence-time > button { padding: 8px; font-size: 12px; margin: 0; }
    .seite-heute .segmente li > .dauer, .mobile-absence-time > .dauer { margin: 0; }
    .seite-heute .segmente li > .merker { grid-column: 1 / -1; }
    .seite-heute .segmente li > button { grid-column: 5; grid-row: 1; }
    .seite-heute .segmente li > .dauer { grid-column: 4; grid-row: 1; }
    .matrix-wrap[role="button"] { cursor: zoom-in; }
}
/* Nur die ausdrücklich geöffnete Vergrösserung, auch bei gedrehtem Gerät. */
@media screen {
    body.mobile-matrix-open { overflow: hidden; }
    .mobile-matrix-view { position: fixed; inset: 0; z-index: 210; background: var(--ui-background); }
    .mobile-matrix-sheet { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 8px; background: var(--ui-background); }
    .mobile-matrix-controls { display: flex; flex: none; gap: 8px; margin-bottom: 8px; }
    .mobile-matrix-controls button { min-height: 40px; min-width: 44px; padding: 8px 12px; }
    .mobile-matrix-controls button:first-child { margin-right: auto; }
    .mobile-matrix-scroll { flex: 1; min-height: 0; overflow: auto; padding: 8px; touch-action: pan-x pan-y; }
    .mobile-matrix-stage { position: relative; margin: auto; }
}
@media screen and (orientation: portrait) {
    .mobile-matrix-sheet { inset: auto; left: 50%; top: 50%; width: 100dvh; height: 100dvw; transform: translate(-50%, -50%) rotate(90deg); }
}

@media screen and (max-width: 768px) {
    .seite-meldungen .jahrstepper.mobile-simple-year {
        display: block; width: 100%; border: 0; border-radius: 0; overflow: visible; margin: 0 0 10px;
    }
    .mobile-simple-year > label { display: block; margin-bottom: 5px; }
    .seite-meldungen .mobile-simple-year select.mobile-message-year {
        display: block; width: 100%; max-width: none !important; height: 44px; margin-top: 5px;
        border: 1px solid var(--ui-deep-blue); border-radius: 10px; padding: 8px 12px; font-size: 16px; font-weight: 400; text-align: left;
    }
    /* Jahresansicht: Jahr-Auswahl und «Tagesnummern» auf einer Zeile, das
       Auswahlfeld nur so breit wie noetig. Das spart die Zeile, die das
       vollbreite Feld sonst fuer sich beanspruchte. */
    .seite-jahr .mobile-simple-year {
        display: inline-flex; align-items: center; gap: 8px; width: auto; margin: 0 0 10px;
    }
    .seite-jahr .mobile-simple-year select#jahr-wahl {
        width: auto; max-width: 120px; height: 44px; margin: 0;
        border: 1px solid var(--ui-deep-blue); border-radius: 10px; padding: 8px 10px;
        font-size: 16px; font-weight: 400; text-align: left;
    }
    .seite-meldungen .jahrwahl { flex-wrap: wrap; }
    .mobile-input-active .mobile-tabs, .mobile-input-active .mobile-menue { display: none !important; }
    .seite-ueberzeit button[data-zurueckziehen] { display: block; margin-left: 0; padding-left: 0; text-align: left; }
    .seite-jahr table.matrix td.leer { border-color: var(--ui-deep-blue); }
}
@media screen {
    .mobile-matrix-view table.matrix th, .mobile-matrix-view table.matrix td { border-color: var(--ui-deep-blue); }
    .mobile-matrix-scroll { touch-action: none; overscroll-behavior: contain; }
}

@media screen and (max-width: 768px) {
    .mobile-month-group { gap: 3px; }
    .mobile-month-group a.knopf { min-width: 40px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
    .mobile-month-group select#monat-wahl { flex: 1; width: 106px; max-width: 120px !important; font-size: 14px; }
    .mobile-month-title > .mobile-year-picker { border: 0; overflow: visible; }
    .mobile-month-title .mobile-year-picker select { width: 112px; max-width: none !important; border: 1px solid var(--ui-deep-blue); border-radius: 10px; padding: 8px 12px; height: 44px; font-weight: 400; }
    .seite-meldungen .jahrwahl { flex-wrap: nowrap; align-items: center; }
    .seite-meldungen .jahrwahl > label { display: none; }
    .seite-meldungen .meldungen-jahrauswahl { width: 90px !important; min-width: 80px; flex: 0 0 90px; height: 44px; padding: 6px; margin: 0; }
    .mobile-case-jumps { min-width: 0; gap: 3px; }
    .mobile-case-jumps a { padding: 8px 4px; font-size: 11px; }
    .mobile-warning > summary { width: 43.2px; height: 55.2px; background: var(--ui-attention-bg); border-color: var(--ui-attention-border); box-shadow: 0 2px 12px #a5202033; }
    .mobile-warning > summary svg { width: 28.8px; }
    .mobile-warning-content { right: 46px; max-width: min(310px, calc(100vw - 62px)); }
}
@media screen and (max-width: 370px) {
    .mobile-month-title > .mobile-exports { grid-row: 2; align-self: center; }
    .mobile-month-group { grid-column: 1 / -1; }
}

@media screen and (max-width: 768px) {
    .mobile-month-title .mobile-exports #monat-drucken { border: 1px solid var(--ui-deep-blue); border-radius: 8px; background: #fff; }
}

/* Einheitliche Exportbuttons in Monats- und Jahresansicht. */
@media screen and (max-width: 768px) {
    .mobile-exports > button,
    .mobile-exports > a.knopf,
    .mobile-month-title .mobile-exports > button {
        display: inline-flex; align-items: center; justify-content: center;
        flex: 0 0 40px; width: 40px; min-width: 40px; max-width: 40px;
        height: 40px; min-height: 40px; padding: 0;
        font-size: 12px; line-height: 1; border: 1px solid var(--ui-deep-blue);
        border-radius: 8px; margin: 0;
    }
    .mobile-exports svg { display: block; width: 20px; height: 20px; flex: none; }
}

@media screen and (max-width: 768px) {
    table.tagesliste tr.heute { background: var(--heute); border-left: 1px solid var(--ui-deep-blue); }
    table.tagesliste tr.heute td:first-child { border-left: 0; }
    table.tagesliste .zeitpaar, table.tagesliste .mobile-time-entry {
        display: inline-flex; align-items: center; gap: 8px; vertical-align: middle;
    }
    table.tagesliste .zeitpaar > button, table.tagesliste .mobile-time-entry > button {
        box-sizing: border-box; width: 36px; min-width: 36px; height: 44px;
        padding: 0; margin: 0; flex: none; text-align: center;
    }
    .mobile-month-group select#monat-wahl {
        background: var(--ui-white); border: 1px solid var(--ui-deep-blue); border-radius: 10px;
        color: var(--ui-text); min-height: 44px; padding: 6px; font-size: 14px; font-weight: 400;
    }
}

@media screen and (max-width: 768px) {
    /* 40px Monats-Pfeil plus 3px Abstand: beide Auswahlfelder bündig. */
    .mobile-month-title > .mobile-year-picker { margin-left: 43px; }
    .mobile-month-group select#monat-wahl,
    .mobile-month-title .mobile-year-picker select {
        flex: 0 0 112px; width: 112px; min-width: 112px; max-width: 112px !important;
    }
}
@media screen and (max-width: 370px) {
    .mobile-month-title > .mobile-exports { grid-row: 3; }
}

@media screen and (max-width: 768px) {
    .mobile-month-title { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 6px; }
    .mobile-month-heading { grid-column: 1; grid-row: 1; margin: 0; align-self: center; color: #000000; font-size: 17px; }
    .mobile-month-title > .mobile-exports { grid-column: 2; grid-row: 1; align-self: center; }
    .mobile-month-controls { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
    .mobile-month-controls .mobile-year-picker { margin: 0; border: 0; overflow: visible; flex: none; }
    .mobile-month-controls .mobile-year-picker select { width: 112px; height: 44px; border: 1px solid var(--ui-deep-blue); border-radius: 10px; padding: 8px 12px; font-weight: 400; background: #fff; }
}
@media screen and (max-width: 370px) {
    .mobile-month-heading { font-size: 16px; }
    .mobile-month-controls .mobile-month-group a.knopf { min-width: 28px; width: 28px; }
    .mobile-month-controls .mobile-month-group select#monat-wahl { flex-basis: 102px; width: 102px; min-width: 102px; max-width: 102px !important; }
    .mobile-month-controls .mobile-year-picker select { flex-basis: 82px; width: 82px; min-width: 82px; max-width: 82px !important; padding: 6px; }
}

@media screen and (max-width: 768px) {
    .mobile-month-controls { justify-content: flex-start; gap: 8px; }
    .mobile-month-controls .mobile-year-picker { order: -1; }
    .mobile-month-controls .mobile-year-picker select,
    .mobile-month-controls .mobile-month-group select#monat-wahl {
        font-family: var(--schrift); font-size: 16px; font-weight: 400;
        line-height: normal; color: var(--ui-text); text-align: left;
    }
}

/* Server-eigene Anmeldung/Einrichtung, ohne Tab-Bar und ohne Funktionsänderung. */
@media screen and (max-width: 768px) {
 body.mobile-standalone { padding-bottom: 0; }
 .mobile-standalone main { margin: 20px auto; max-width: 100%; }
 .mobile-standalone input[type="password"] { font-family: var(--schrift); font-size: 16px; min-height: 44px; border-radius: 10px; }
 .kopf .abmelden { margin: 0; }
 .kopf .abmelden button { white-space: nowrap; }
}

@media screen and (max-width: 768px) {
    .karte, .mobile-case-card, .mobile-case-field, .jahreswahl, table.tagesliste tr, table.tagesliste tr.heute { border-color: var(--ui-dust-denim); }
    .dialog.gefahr { border: 0; }
    button.gefahr.haupt, button.gefahr.haupt:hover { background: var(--ui-terracotta); border-color: var(--ui-terracotta); }
    .seite-heute .segmente li:not(.absenzzeile):has(> input.zeit), .mobile-absence-time {
        grid-template-columns: minmax(0, 82px) auto minmax(0, 82px) auto auto; justify-content: space-between;
    }
    .mobile-time-status { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; justify-self: start; }
    .mobile-time-status .merker { flex: none; width: auto; }
    .mobile-warning { top: 30dvh; }
    .mobile-warning-content { top: 50%; transform: translateY(-50%); min-height: 76px; max-height: 50dvh; padding: 14px 12px; background: var(--ui-warning-bg); border-color: var(--ui-warning-border); color: var(--ui-warning-text); }
    .mobile-warning-content .warnung, .mobile-warning-content .warnung strong, .mobile-warning-content .meldungsleiste, .mobile-warning-content .meldungsleiste-grund { color: var(--ui-warning-text); }
    .mobile-warning-content .meldungsleiste { flex-direction: row; align-items: center; gap: 10px; }
    .mobile-warning-content .meldungsleiste > span { flex: 1; min-width: 0; }
    .mobile-warning-content .knopf { min-height: 32px; padding: 6px 9px; flex: none; color: var(--ui-warning-text); border-color: var(--ui-warning-border); }
    .mobile-warning-content .meldungsleiste-grund + .warnung { margin-top: 10px; }
}
@media screen and (min-width: 520px) and (max-width: 768px) {
    .seite-heute .segmente li:not(.absenzzeile):has(> input.zeit) { grid-template-columns: 82px auto 82px max-content auto auto; }
    .seite-heute .segmente li > .mobile-time-status { grid-column: 4; grid-row: 1; }
    .seite-heute .segmente li > .dauer { grid-column: 5; }
    .seite-heute .segmente li > button { grid-column: 6; }
}

@media screen and (max-width: 768px) {
    .mobile-case-card.hervorgehoben { background: var(--ui-danger-bg); }
}

/* Ungültige Kalendertage auch im vergrösserten Präsenzspiegel klar absetzen. */
@media screen {
    .mobile-matrix-view table.matrix { background: var(--ui-white); }
    .mobile-matrix-view table.matrix td.leer { background: var(--ui-calendar-empty); }
}
@media screen and (max-width: 768px) {
    .seite-jahr table.matrix td.leer { background: var(--ui-calendar-empty); }
}
