/* V3.207.152: Optimierung für faltbare Handys – iPhone Duo (iOS 27)
   Außendisplay 5,4" · 1398×2034 px · 460 ppi  → ca. 466×678 CSS-Pixel (hochkant)
   Innendisplay 7,6" · 1878×2670 px · 430 ppi  → ca. 626×890 CSS-Pixel hochkant bzw. 890×626 aufgeklappt quer
   Gilt für Bürosa und fibusa. Nur Darstellung – Daten und Abläufe bleiben unverändert. */

/* ---------- Touch allgemein (alle Displays des Geräts) ---------- */
@media (pointer:coarse){
 /* iOS vergrößert die Seite beim Tippen in Felder unter 16 px – das verhindert diese Regel */
 input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px}
 /* Bildschirmhöhe ohne die Safari-Leisten (dvh), damit Dialoge nicht unter die Leiste rutschen */
 #modal .modal-card{max-height:calc(100dvh - 24px);overflow:auto;-webkit-overflow-scrolling:touch}
 .fb-modal-card{max-height:calc(100dvh - 24px)}
 /* Tabellen seitlich wischen statt die Seite zu verbreitern */
 .table-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}
 /* Aktionssymbole ohne Maus erreichbar (Schloss-Leiste, Belegliste) */
 .fibu-acts{visibility:visible!important;position:static!important;transform:none!important;box-shadow:none!important;border:0!important;background:transparent!important;padding:0!important}
 .fibu-acts-float{display:none!important}
 html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
}

/* ---------- Außendisplay zugeklappt: ca. 466×678 ---------- */
@media (max-width:520px) and (pointer:coarse){
 header .brand small{display:none}
 #modal{padding:0!important}
 #modal .modal-card{width:100%!important;max-width:100%!important;border-radius:16px 16px 0 0;margin:auto 0 0 0;max-height:calc(100dvh - 8px)}
 #modal .modal-card .actions,.fb-modal-card .actions{position:sticky;bottom:0;background:inherit;padding-top:8px;padding-bottom:calc(8px + env(safe-area-inset-bottom,0px));z-index:2}
 .form-grid{grid-template-columns:minmax(0,1fr)!important}
 .toolbar{gap:8px}
 .toolbar label{flex:1 1 100%;min-width:0}
 .stats{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 .fg-bar .fg-drop{flex-wrap:wrap}
 .ai-kpis{grid-template-columns:minmax(0,1fr)!important}
 .xl-dlg .xl-x,.fa-x{min-width:40px;min-height:40px}
}

/* ---------- Innendisplay hochkant: ca. 626×890 ---------- */
@media (min-width:600px) and (max-width:700px) and (pointer:coarse){
 .form-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 .stats{grid-template-columns:repeat(3,minmax(0,1fr))!important}
 .ai-kpis{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 #modal .modal-card{max-width:600px!important;width:calc(100% - 24px)!important}
 .fb-main{padding-left:18px;padding-right:18px}
}

/* ---------- Innendisplay aufgeklappt quer: ca. 890×626 (breit, aber wenig Höhe) ---------- */
@media (min-width:701px) and (max-width:1024px) and (max-height:720px) and (pointer:coarse){
 /* Kopfbereich schlanker – mehr Platz für Listen und die Buchungsmaske */
 header{padding-top:6px!important;padding-bottom:6px!important;min-height:0!important}
 header .brand small{display:none}
 header .logo svg{width:34px;height:34px}
 #nav{overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch}
 #nav::-webkit-scrollbar{display:none}
 main#main>h1,main#main .page-head h1{font-size:1.45rem;margin-top:.2em;margin-bottom:.2em}
 /* Dialoge: volle Höhe nutzen, Schaltflächen bleiben sichtbar */
 #modal{padding:8px!important;align-items:flex-start!important}
 #modal .modal-card{max-height:calc(100dvh - 16px);width:calc(100% - 16px)!important;max-width:980px!important}
 #modal .modal-card .actions{position:sticky;bottom:0;background:inherit;padding-top:8px;z-index:2}
 .fibu-wide-modal .modal-card{max-width:calc(100vw - 16px)!important}
 /* Formulare zwei- bis dreispaltig */
 .form-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
 /* Buchungsmaske: Zeile umbrechen statt seitlich abzuschneiden */
 .fibu-mask-row{flex-wrap:wrap}
 /* Belegansicht und Viewer: Höhe des Displays ausnutzen */
 .dv-body,.dms-vdoc{max-height:calc(100dvh - 120px)}
 /* fibusa: schlanke Kopfzeile */
 .fb-top-in{height:52px}
 .fb-main{padding-top:14px}
 .fb-modal-card{max-height:calc(100dvh - 16px)}
}

/* ---------- Falz: meldet der Browser zwei Bildschirmhälften, Dialoge nicht über die Faltung legen ---------- */
@media (horizontal-viewport-segments:2){
 #modal .modal-card{max-width:calc(env(viewport-segment-width 1 0, 50vw) - 24px)!important;margin-left:auto!important;margin-right:12px!important}
 .fb-modal-card{max-width:calc(env(viewport-segment-width 1 0, 50vw) - 24px);margin-left:auto}
}
