/* Handy-Ansicht (Prototyp 09.10.2026): greift nur unter 768 px Breite, die Desktop-Ansicht bleibt unverändert.
   Seitenleiste = Schublade (Menü-Knopf), unten eine feste Leiste, Board = eine Spalte pro Bildschirm zum Wischen. */
#mob-menu, #mob-nav, #sb-backdrop { display: none; }
.stb-live, .stb-manuell-btn, .mv-btn { display: none; } /* Start/Stopp-Karte des Stundenbuchs und „Verschieben nach“: nur am Handy */

@media (max-width: 768px) {
  html, body { overscroll-behavior: none; }
  #app { grid-template-columns: minmax(0, 1fr); height: 100dvh; }
  #main { height: 100dvh; }

  /* Seitenleiste als Schublade */
  #sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: min(86vw, 330px); z-index: 60;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: none; padding-bottom: env(safe-area-inset-bottom); }
  body.sb-open #sidebar { transform: none; box-shadow: 8px 0 30px rgba(0,0,0,.35); }
  #sb-backdrop { position: fixed; inset: 0; z-index: 55; background: rgba(8,20,12,.5); }
  body.sb-open #sb-backdrop { display: block; }
  .sb-resize { display: none; }
  #sb-top .brandcard { margin: 12px 12px 6px; }
  .sb-item { min-height: 44px; }

  /* Kopfzeile */
  #topbar { height: 52px; padding: 0 10px; gap: 8px; }
  #mob-menu { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px;
    border: 0; background: none; border-radius: 8px; color: var(--text); cursor: pointer; }
  #mob-menu:active { background: var(--bg-subtle); }
  .search-wrap { flex: 1; width: auto; max-width: none; min-width: 0; }
  #topbar .spacer { display: none; }
  #search { width: 100%; }

  /* Seiteninhalt */
  #page { padding-bottom: calc(64px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
  .pagewrap { padding: 12px 12px 24px; }
  .phead { flex-wrap: wrap; gap: 4px 10px; }
  .ptitle { font-size: 20px; min-width: 0; overflow-wrap: anywhere; } /* lange Projektnamen umbrechen statt über den Rand zu laufen */
  .phead .muted { flex: 1 1 100%; order: 3; }
  .phead .spacer { display: none; }
  .dayhint { display: none; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; padding: 10px 12px; }

  /* Board: eine Spalte pro Bildschirm, seitlich wischen */
  .board { gap: 10px; scroll-snap-type: x mandatory; scroll-padding: 0 12px; margin: 0 -12px; padding: 0 12px 16px; }
  .bcol { width: calc(100vw - 40px); scroll-snap-align: start; }
  .card { padding: 12px; }
  .card .check { width: 24px; height: 24px; }

  /* Aufgabenfenster wird zum Vollbild */
  #panel { position: fixed; top: 0; right: 0; bottom: 0; left: 0; width: 100vw; max-width: 100vw; z-index: 70; border-left: 0; }

  /* Bedienelemente mit dem Daumen treffbar */
  .btn, .iconbtn, select, input[type="date"], input[type="time"] { min-height: 40px; }
  input, select, textarea { font-size: 16px; } /* verhindert das Hineinzoomen auf dem iPhone */

  /* Untere Leiste */
  #mob-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: #fff; border-top: 1px solid var(--border-strong);
    padding-bottom: env(safe-area-inset-bottom); }
  body.loggedout #mob-nav, body.loggedout #mob-menu { display: none; }
  #mob-nav a, #mob-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 56px; border: 0; background: none; color: var(--text-2); font: inherit; font-size: 11px; text-decoration: none; position: relative; cursor: pointer; }
  #mob-nav a.active { color: var(--accent-strong, var(--accent)); font-weight: 600; }
  #mob-nav a.active svg { stroke-width: 2.4; }
  #mob-nav .mob-badge { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 16px; padding: 0 4px; height: 16px; border-radius: 8px;
    background: #d64545; color: #fff; font-size: 10px; line-height: 16px; text-align: center; }
  body.sb-open #mob-nav { display: none; }

  /* Kalender passt auf die Breite, Tabellen (Admin, Projektübersicht …) wischen für sich statt die ganze Seite zu verschieben */
  .calwrap { min-width: 0; }
  .cal-toolbar { flex-wrap: wrap; }
  .ptable { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Menüs (Filter, Ansichten, Ich …) als Fläche über der unteren Leiste statt am Knopf, der Platz am Rand reicht dort nie; Dialoge und Hinweise passend */
  .menu { left: 8px !important; right: 8px !important; top: auto !important; bottom: calc(64px + env(safe-area-inset-bottom)); width: auto;
    min-width: 0; max-width: none; max-height: min(70dvh, calc(100dvh - 140px)); }
  body.sb-open .menu { bottom: calc(12px + env(safe-area-inset-bottom)); }
  .menu-item { min-height: 44px; }
  .filterpanel { min-width: 0; max-width: none; max-height: none; }
  .fopt { min-height: 42px; }
  .fopt input[type="checkbox"] { width: 20px; height: 20px; }
  .modal-overlay { padding-top: 8px; }
  .modal { max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); max-width: 90vw; text-align: center; }

  /* „Verschieben nach …“ statt Ziehen (Karte im Board, Zeile in der Liste) */
  .mv-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; margin-left: 4px; color: var(--text-2); }
  .tname .mv-btn { margin-left: auto; }

  /* Liste: statt Tabelle mit seitlichem Wischen je Aufgabe eine Karte – Name oben, die übrigen Felder (Projekt, Frist …) darunter */
  .glist { min-width: 0; width: 100%; }
  .glist-head { display: none; }
  .trow { display: flex; flex-wrap: wrap; align-items: center; padding: 4px 0 8px 36px; } /* 36 px = Häkchen, darunter beginnen die Felder */
  .trow .tname { flex: 1 1 calc(100% + 36px); margin-left: -36px; min-width: 0; min-height: 40px; }
  .trow .tcell { flex: 0 1 auto; max-width: 100%; width: auto; min-height: 0; padding: 2px 10px 2px 0; }
  .trow .tcell:empty { display: none; }

  /* Stundenbuch: große Start/Stopp-Karte statt kleinem Uhr-Knopf, Formular nur auf Wunsch */
  .stb-live { display: flex; flex-direction: column; gap: 10px; padding: 18px 16px; margin-bottom: 12px; border: 1px solid var(--border-strong);
    border-radius: 16px; background: var(--bg-subtle); }
  .stb-live.running { border-color: var(--brand); background: var(--accent-soft); }
  .stb-live-time { font-size: 44px; line-height: 1.1; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
  .stb-live-sub { text-align: center; }
  .stb-live input { width: 100%; }
  .stb-live .stb-chips { margin: 0; }
  .stb-live-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; border: 0; border-radius: 14px;
    font: inherit; font-size: 20px; font-weight: 700; background: var(--brand); color: var(--brand-ink); cursor: pointer; }
  .stb-live-btn.stop { background: var(--danger); color: #fff; }
  .stb-live-btn:active { filter: brightness(.92); }
  .stb-manuell-btn { display: block; width: 100%; }
  .stb .stb-form:not(.open) { display: none; }
  .stb .stb-timer { display: none; } /* der kleine Uhr-Knopf im Formular: am Handy gibt es die Karte */
  .stb .zhint { display: none; }
}
