/* =========================================================================
   Pension Belegungsbuch — Oberfläche
   Mobile First. Alle Maße in rem, damit A- / A / A+ das Layout skaliert.
   ========================================================================= */

/* ---------- Skalierung / Tokens ---------- */
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
html[data-scale="0"] { font-size: 15px; }
html[data-scale="1"] { font-size: 17px; }
html[data-scale="2"] { font-size: 19px; }
html[data-scale="3"] { font-size: 21.5px; }
html[data-scale="4"] { font-size: 24.5px; }

:root {
  --primary:      #2f5d50;
  --primary-dark: #234639;
  --primary-soft: #e4ede9;
  --secondary:    #b8862f;
  --secondary-soft:#fbf1dc;
  --ink:          #23201c;
  --ink-soft:     #5d574e;
  --line:         #ddd6c9;
  --line-strong:  #c3b9a6;
  --paper:        #faf7f1;
  --card:         #ffffff;
  --free:         #ffffff;
  --free-alt:     #f6f2e9;
  --danger:       #a3372c;
  --alert:        #8a4b00;
  --alert-soft:   #fdf0d8;
  --radius:       .7rem;
  --touch:        3rem;      /* ~48px bei Basisgröße */
  --unit-w:       11.5rem;
  --day-w:        7.6rem;    /* Wochenansicht: Breite eines ganzen Tages */
  --row-h:        3.3rem;
  --shadow:       0 .15rem .8rem rgba(35,32,28,.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1,h2,h3 { margin: 0 0 .4rem; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.icon { width: 1.35em; height: 1.35em; fill: currentColor; flex: none; }
.sr { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }

/* ---------- Grundlegende Bedienelemente ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--touch); padding: .55rem 1rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--card); color: var(--ink); font-weight: 600;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-quiet   { background: transparent; border-color: transparent; }
.btn-danger  { color: var(--danger); border-color: #e2c4c0; background: #fff; }
.btn-big     { min-height: 3.6rem; font-size: 1.05rem; width: 100%; }
.btn[disabled] { opacity: .45; }

.field { margin-bottom: 1.1rem; }
.field > label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field .hint { color: var(--ink-soft); font-size: .85rem; margin-top: .3rem; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--touch); padding: .6rem .75rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff;
}
input[type="date"].input { min-height: 3.4rem; font-size: 1.05rem; }
textarea.input { min-height: 5rem; }
.input:focus, .btn:focus-visible { outline: 3px solid var(--secondary); outline-offset: 1px; }

.row2 { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
@media (min-width: 700px) { .row2 { grid-template-columns: 1fr 1fr; } }

.stepper { display: flex; align-items: center; gap: .6rem; }
.stepper button { width: var(--touch); height: var(--touch); border-radius: 50%;
  border: 1px solid var(--line-strong); background: #fff; font-size: 1.3rem; font-weight: 700; }
.stepper output { min-width: 4.5rem; text-align: center; font-size: 1.15rem; font-weight: 700; }

.quickdays { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .45rem; }
.quickdays button { min-height: 2.6rem; padding: .3rem .7rem; border-radius: .5rem;
  border: 1px solid var(--line-strong); background: #fff; font-weight: 600; }

.checkline { display: flex; align-items: flex-start; gap: .7rem; padding: .7rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.checkline input { width: 1.4rem; height: 1.4rem; margin-top: .1rem; flex: none; }
/* Beschriftung und Erklärungstext stehen untereinander; der Erklärungstext beginnt
   auf Höhe des Textes, nicht unter der Checkbox. Bleibt auf jeder Breite zweizeilig. */
.checkline > span { display: block; min-width: 0; }
.checkline strong { display: block; }
.checkline .hint { display: block; margin-top: .15rem; line-height: 1.35;
  color: var(--ink-soft); font-size: .85rem; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .5rem .7rem; background: var(--primary); color: #fff;
}
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.tb {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: var(--touch); min-width: var(--touch); padding: .4rem .8rem;
  border-radius: var(--radius); border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.10); color: #fff; font-weight: 600;
}
.tb-strong { background: #fff; color: var(--primary-dark); border-color: #fff; }
.badge { background: var(--secondary); color: #241a05; border-radius: 999px;
  padding: .05rem .5rem; font-weight: 800; font-size: .85rem; }
.badge-alert { background: #fff3cf; color: #6d3b00; border: 1px solid #d9a441; }
.fontsize { display: flex; border: 1px solid rgba(255,255,255,.35); border-radius: var(--radius); overflow: hidden; }
.fontsize button { min-width: 2.9rem; min-height: var(--touch); border: 0; background: rgba(255,255,255,.10);
  color: #fff; font-weight: 700; }
.fontsize button + button { border-left: 1px solid rgba(255,255,255,.25); }
.fontsize button[aria-pressed="true"] { background: #fff; color: var(--primary-dark); }

/* ---------- Plan-Navigation ---------- */
.plannav {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .55rem .7rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.plannav .range { font-weight: 700; padding: 0 .3rem; }
.viewswitch { margin-left: auto; display: flex; border: 1px solid var(--line-strong);
  border-radius: var(--radius); overflow: hidden; }
.viewswitch button { min-height: var(--touch); min-width: 5rem; border: 0; background: #fff; font-weight: 700; }
.viewswitch button[aria-pressed="true"] { background: var(--primary); color: #fff; }

/* ---------- Streifen "Offene Anfragen" (Variante B) ---------- */
.reqstrip { background: var(--secondary-soft); border-bottom: 1px solid var(--line); }
.reqstrip[hidden] { display: none; }
.reqstrip-head { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; font-weight: 700; }
.reqstrip-head .btn { min-height: 2.5rem; padding: .25rem .7rem; }
.reqstrip-cards { display: flex; gap: .6rem; overflow-x: auto; padding: 0 .7rem .7rem; }
.reqcard { flex: 0 0 15rem; text-align: left; background: #fff; border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: .6rem .7rem; min-height: 5rem; }
.reqcard .kind { font-size: .8rem; font-weight: 800; letter-spacing: .03em; color: var(--ink-soft); }
.reqcard .who { font-weight: 700; font-size: 1.05rem; }
.reqcard.alert { border: 2px solid var(--alert); background: var(--alert-soft); }
.reqcard.alert .kind { color: var(--alert); }

/* ---------- Belegungsplan ----------
   Bewusst KEIN CSS-Grid mit sticky Grid-Items: sticky wird dort auf die Grid-Area
   beschränkt. Stattdessen Zeilen aus Flex-Boxen — die zuverlässige Variante für
   eine feststehende Unterkunftsspalte plus feststehende Datumszeile.            */
.plan-wrap { flex: 1; min-height: 0; overflow: auto; background: var(--paper); }
.plan { display: block; width: max-content; min-width: 100%; position: relative; }
.plan.month { --day-w: 2.7rem; }

.phead { position: sticky; top: 0; z-index: 5; display: flex; background: #fff; }
.prow  { display: flex; min-height: var(--row-h); flex: none; }   /* wächst bei langen Namen mit */
.pgroup{ display: flex; flex: none; }

.pname {
  position: sticky; left: 0; z-index: 3; flex: none; width: var(--unit-w);
  background: #fff; border-right: 2px solid var(--line-strong); border-bottom: 1px solid var(--line);
  padding: .25rem .6rem; display: flex; flex-direction: column; justify-content: center;
  /* nichts darf aus der feststehenden Spalte in das Datumsraster laufen */
  overflow: hidden;
}
.phead .pname { z-index: 6; border-bottom: 2px solid var(--line-strong);
  justify-content: center; font-weight: 700; font-size: .85rem; }

/* Gruppenkopf: eigene Zeile, gleicher linker Innenabstand wie die Unterkunftszeilen.
   Der Titel darf umbrechen bzw. trennen, die Anzahl bleibt rechts und erzwingt
   keinen Überlauf. */
.pgroup .pname {
  background: var(--primary-soft); color: var(--primary-dark);
  font-weight: 800; font-size: .95rem; line-height: 1.15;
  flex-direction: row; align-items: center; gap: .4rem;
  padding: .4rem .6rem; min-height: 2.3rem;
  border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
}
.pgroup .g-label {
  min-width: 0;                 /* erlaubt das Schrumpfen im Flex-Kontext        */
  -webkit-hyphens: auto;        /* iPadOS-Safari braucht das Präfix              */
  hyphens: auto;                /* trennt „Monteurs-/unterkünfte“ nach dt. Regel */
  overflow-wrap: break-word;    /* nur als letzte Rückfallebene, nicht „anywhere“*/
}
.pgroup .g-count { flex: none; margin-left: auto; font-weight: 700;
  font-size: .82em; color: var(--primary-dark); opacity: .8; }

.pname .u-label { font-weight: 800; min-width: 0; line-height: 1.15;
  -webkit-hyphens: auto; hyphens: auto; overflow-wrap: break-word; }
.pname .u-meta  { font-size: .78rem; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pname.inactive { opacity: .55; }

.ptrack { position: relative; display: flex; flex: none; }
.pgroup .ptrack { background: var(--primary-soft);
  border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }

.pday { flex: none; width: var(--day-w); border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line); background: var(--free); }
.pday.we { background: #f3efe4; }
.phead .pday { text-align: center; padding: .3rem .1rem; font-size: .82rem; line-height: 1.15;
  border-bottom: 2px solid var(--line-strong); background: #fff; }
.phead .pday.we { background: #f3efe4; }
.phead .pday.today { background: var(--secondary); color: #241a05; }
.phead .pday .dow  { font-weight: 700; }
.phead .pday .dnum { font-size: 1.05rem; font-weight: 800; }
.phead .pday .mon  { font-size: .7rem; }

.free { border: 0; padding: 0; background: transparent; width: 100%; height: 100%; display: block; }
.free:active { background: var(--primary-soft); }

.todaycol { position: absolute; top: 0; bottom: 0; z-index: 0; pointer-events: none;
  background: rgba(184,134,47,.16);
  border-left: .18rem solid var(--secondary); border-right: .18rem solid var(--secondary); }

/* Balken */
.bar {
  position: absolute; top: .22rem; bottom: .22rem; z-index: 2;
  border-radius: .45rem; padding: .1rem .45rem; overflow: hidden; text-align: left;
  display: flex; align-items: center; gap: .35rem; border: 1px solid transparent;
  font-size: .85rem; line-height: 1.15; min-width: 0;
}
.bar .bar-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.bar .bar-sub { font-weight: 400; opacity: .9; }
.bar-booking { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.bar-booking.legacy { background: #4a6f63; }
.bar-block {
  color: #33302b; border-color: var(--line-strong);
  background-color: #ded8cb;
  background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.16) 0 .35rem, transparent .35rem .7rem);
}
.bar .halfstart { position: absolute; left: 0; top: 0; bottom: 0; width: .22rem; background: rgba(255,255,255,.55); }

/* Legende */
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; padding: .55rem .7rem;
  background: var(--card); border-top: 1px solid var(--line); font-size: .85rem; }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend .swatch { display: inline-block; width: 1.5rem; height: 1rem; border-radius: .25rem; border: 1px solid var(--line-strong); }
.legend .sw-book { background: var(--primary); }
.legend .sw-block { background-color: #ded8cb;
  background-image: repeating-linear-gradient(45deg, rgba(0,0,0,.16) 0 .3rem, transparent .3rem .6rem); }
.legend .sw-free { background: #fff; }
.legend .sw-today { background: rgba(184,134,47,.35); border-color: var(--secondary); }

/* ---------- Smartphone-Liste ---------- */
.mobilelist { display: none; padding: .7rem; }
.daycard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: .8rem; overflow: hidden; }
.daycard > h3 { background: var(--primary-soft); color: var(--primary-dark);
  padding: .5rem .7rem; margin: 0; font-size: .95rem; }
.daycard.today > h3 { background: var(--secondary); color: #241a05; }
.dayrow { display: flex; flex-wrap: wrap; gap: .3rem .6rem; align-items: center; width: 100%;
  text-align: left; padding: .6rem .7rem; border: 0; border-top: 1px solid var(--line);
  background: #fff; min-height: var(--touch); }
.dayrow .u { font-weight: 800; min-width: 5.5rem; overflow-wrap: anywhere; }
.dayrow .g { min-width: 0; overflow-wrap: anywhere; }
.dayrow .st { margin-left: auto; font-size: .8rem; font-weight: 700; padding: .1rem .5rem;
  border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); }
.dayrow .st.block { background: #e3ded2; color: #3c382f; }
.dayrow .st.free { background: #eef6f2; color: #2f5d50; }

/* ---------- Sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(30,26,20,.45); z-index: 40; }
.sheet {
  position: fixed; z-index: 41; background: var(--card); box-shadow: var(--shadow);
  left: 0; right: 0; bottom: 0; top: 0; display: flex; flex-direction: column;
}
@media (min-width: 700px) {
  .sheet { top: 3vh; bottom: 3vh; left: 50%; transform: translateX(-50%);
           width: min(46rem, 94vw); border-radius: 1rem; overflow: hidden; }
  .sheet.wide { width: min(60rem, 96vw); }
}
.sheet-head { display: flex; align-items: center; gap: .6rem; padding: .7rem;
  border-bottom: 1px solid var(--line); background: #fff; }
.sheet-head h2 { flex: 1; margin: 0; }
.sheet-body { flex: 1; overflow: auto; padding: 1rem; }
.sheet-foot { display: flex; gap: .6rem; flex-wrap: wrap; padding: .8rem;
  border-top: 1px solid var(--line); background: var(--card); }
.sheet-foot .btn { flex: 1 1 12rem; min-height: 3.4rem; }

/* Informations-/Statusblöcke */
.note { border-radius: var(--radius); padding: .7rem .8rem; margin-bottom: 1rem; border: 1px solid var(--line-strong); background: #fff; }
.note-ok    { background: var(--primary-soft); border-color: #a9c9bd; }
.note-warn  { background: var(--alert-soft); border-color: #e0b263; }
.note-info  { background: #eef2f6; border-color: #c3cfd9; }
.note strong { display: block; }

.deflist { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .9rem; margin: 0 0 1rem; }
.deflist dt { color: var(--ink-soft); }
.deflist dd { margin: 0; font-weight: 600; }

.optionlist { display: flex; flex-direction: column; gap: .5rem; }
.optionlist .opt {
  display: flex; align-items: center; gap: .7rem; width: 100%; text-align: left;
  padding: .7rem; min-height: 3.6rem; background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
}
.optionlist .opt[aria-pressed="true"] { border: 2px solid var(--primary); background: var(--primary-soft); }
.optionlist .opt .o-main { font-weight: 700; }
.optionlist .opt .o-meta { font-size: .85rem; color: var(--ink-soft); }
.optionlist .opt .o-right { margin-left: auto; text-align: right; font-weight: 700; }
.opt-flag { font-size: .75rem; font-weight: 800; background: var(--secondary-soft);
  border: 1px solid var(--secondary); color: #6d3b00; border-radius: 999px; padding: .05rem .5rem; }
.groupcap { font-weight: 800; color: var(--ink-soft); font-size: .85rem; margin: .9rem 0 .35rem; }

/* Autocomplete */
.ac-wrap { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + .2rem); z-index: 5;
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; }
.ac-list button { display: block; width: 100%; text-align: left; border: 0; background: #fff;
  padding: .7rem .8rem; min-height: 3.4rem; border-bottom: 1px solid var(--line); }
.ac-list button:last-child { border-bottom: 0; }
.ac-list .ac-name { font-weight: 700; }
.ac-list .ac-meta { font-size: .85rem; color: var(--ink-soft); }

/* Mikrofon */
.with-mic { display: flex; gap: .5rem; align-items: stretch; }
.with-mic .input { flex: 1; }
.mic { width: var(--touch); min-height: var(--touch); border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: #fff; display: inline-flex; align-items: center; justify-content: center; }
.mic.rec { background: var(--danger); border-color: var(--danger); color: #fff; }
.reclamp { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--danger); }
.recdot { width: .8rem; height: .8rem; border-radius: 50%; background: var(--danger); }
.recdot.on { animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.voice-step { font-size: 1.25rem; font-weight: 700; margin-bottom: .8rem; }
.voice-progress { color: var(--ink-soft); font-weight: 600; margin-bottom: .3rem; }

/* Einstellungen */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: .6rem; }
@media (min-width: 640px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.settings-grid .card {
  display: flex; flex-direction: column; gap: .2rem; text-align: left; padding: .8rem;
  min-height: 4.6rem; border: 1px solid var(--line-strong); border-radius: var(--radius); background: #fff; }
.settings-grid .card b { font-size: 1rem; }
.settings-grid .card span { font-size: .85rem; color: var(--ink-soft); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; }
.toast { background: #23201c; color: #fff; padding: .7rem 1rem; border-radius: var(--radius);
  box-shadow: var(--shadow); max-width: 90vw; }
.toast small { display: block; opacity: .75; }

/* ---------- App-Rahmen ---------- */
.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------- Smartphone ---------- */
@media (max-width: 700px) { .hide-xs { display: none; } }

@media (max-width: 599px) {
  .plan-wrap { display: none; }
  .mobilelist { display: block; flex: 1; min-height: 0; overflow: auto; }
  .topbar { padding: .4rem .5rem; }
  .tb { padding: .4rem .6rem; }
  .legend { display: none; }
  .brand .name { display: none; }
  .plannav .range { width: 100%; order: 5; text-align: center; }
}

/* ---------- Desktop ---------- */
@media (min-width: 1280px) {
  :root { --day-w: 8.4rem; }
}

/* ---------- Ergänzungen der Anwendung (nicht im Mockup enthalten) ---------- */
.plainwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.plainbox  { width: min(30rem, 100%); background: #fff; border: 1px solid var(--line);
             border-radius: 1rem; box-shadow: var(--shadow); padding: 1.4rem; }
.plainbox h1 { text-align: center; }
.plainbox .sub { text-align: center; color: var(--ink-soft); margin: 0 0 1.4rem; }

.banner { padding: .7rem 1rem; font-weight: 600; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.banner strong { display: block; width: 100%; }
.banner-success { background: var(--primary-soft); color: var(--primary-dark); }
.banner-info    { background: #eef2f6; }
.banner-error, .banner-danger { background: #fdf1ef; color: var(--danger); }
.banner .btn { min-height: 2.4rem; padding: .2rem .7rem; }

.page { padding: 1rem; max-width: 60rem; margin: 0 auto; width: 100%; }
.page.wide { max-width: none; }
.page h1 { margin-bottom: .8rem; }
.page-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; }
.page-actions .btn { flex: 1 1 12rem; min-height: 3.4rem; }
.scroll { flex: 1; min-height: 0; overflow: auto; }
.backlink { display: inline-flex; align-items: center; gap: .4rem; min-height: var(--touch); font-weight: 600; }
.errorlist { background: #fdf1ef; border: 1px solid #e2c4c0; border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: 1rem; }
.errorlist ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.field .err { color: var(--danger); font-weight: 600; margin-top: .25rem; }
.input.has-error { border-color: var(--danger); border-width: 2px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); }
table.list th { font-size: .85rem; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.nowrap { white-space: nowrap; }
