:root {
  color-scheme: light dark;
  --bg: #e9ecea; --surface: #f9faf8; --ink: #1b2225; --muted: #586468; --line: #c9d0cd;
  --accent: #1f62a8; --accent-ink: #fff; --accent-soft: #dce7f3;
  --warn: #8a5e08; --warn-soft: #f5ead2; --warn-rand: #d9931a;
  --crit: #a8372b; --crit-soft: #f4dcd8;
  --wochenende: #e2e6e3;
  --dienst: #d11a1a;
  --art-x: #dfe3e0; --art-u: #d3ecd9;
  --f-titel: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-text: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111517; --surface: #1a2023; --ink: #e4e9e7; --muted: #98a4a7; --line: #2d3639;
    --accent: #6ea8e6; --accent-ink: #0d1a28; --accent-soft: #1d2d40;
    --warn: #e0b251; --warn-soft: #3a2f16; --warn-rand: #e0b251;
    --crit: #ec8476; --crit-soft: #3d1f1b;
    --wochenende: #20272a;
    --dienst: #ff6b60;
    --art-x: #2a3235; --art-u: #1e4430;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--f-text); }
main { padding: 16px; }
.schmal { max-width: 640px; margin: 0 auto; display: grid; gap: 16px; padding-top: 32px; }
h1 { font: 600 38px/1 var(--f-titel); margin: 0; letter-spacing: .01em; }
h2 { font: 600 21px/1.1 var(--f-titel); margin: 0 0 8px; }
p { margin: 0; }
code { font-size: .92em; }
.leise { color: var(--muted); font-size: 14px; }
.stapel { display: grid; gap: 10px; }
.karte { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 16px; }
.fehler { color: var(--crit); }

button, input { font: inherit; color: inherit; }
button { border-radius: 5px; padding: 8px 14px; cursor: pointer; border: 1px solid transparent; min-height: 40px; }
button:disabled { opacity: .45; cursor: default; }
.primaer { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.flach { background: var(--surface); border-color: var(--line); }
.flach:hover:not(:disabled) { border-color: var(--accent); }
.klein { padding: 2px 10px; min-height: 32px; }
.gefahr { color: var(--crit); }
:where(input[type=text], input[type=password], input[type=date], input[type=time]) {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 8px; width: 100%; min-width: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.meldung { padding: 10px 14px; border-radius: 6px; }
.meldung.warn { background: var(--warn-soft); }
.meldung.krit { background: var(--crit-soft); color: var(--crit); }

.ablage {
  display: grid; gap: 4px; justify-items: center; text-align: center; padding: 44px 16px; cursor: pointer;
  background: var(--surface); border: 2px dashed var(--accent); border-radius: 8px;
}
.ablage strong { font: 600 25px/1.1 var(--f-titel); color: var(--accent); }
.ablage input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ablage:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.ablage.ziehen { background: var(--accent-soft); }
.ablage.aus { opacity: .5; pointer-events: none; }

.lesen { display: flex; gap: 14px; align-items: center; }
.lesen img { width: 84px; height: 84px; object-fit: cover; border-radius: 4px; }

.liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.liste li { display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.liste .oeffnen { flex: 1; min-width: 0; text-align: left; background: none; display: grid; gap: 0; padding: 4px 8px; }
.liste .oeffnen strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Editor */
.leiste { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.titel.titel { flex: 1 1 220px; font: 600 25px/1.1 var(--f-titel); background: transparent; border-color: transparent; }
.titel.titel:hover, .titel.titel:focus { background: var(--surface); border-color: var(--line); }
.stand { min-width: 96px; }
.stand.krit { color: var(--crit); }
.aktionen { display: flex; gap: 8px; align-items: center; }
.aktionen.umbruch { flex-wrap: wrap; margin-top: 8px; }

.hinweise { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.hinweise ul { margin: 0; padding-left: 18px; }

.pruefen {
  display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn-rand);
  border-radius: 6px; padding: 8px 12px; margin-bottom: 10px;
}
.pruefen.fertig { border-left-color: var(--line); }

.arbeit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 36%); gap: 14px; align-items: start; }
.arbeit.ohne-foto { grid-template-columns: minmax(0, 1fr); }
.arbeit.ohne-foto .foto-feld { display: none; }
.plan-spalte { display: grid; gap: 10px; justify-items: start; min-width: 0; container-type: inline-size; }

.tabelle-rahmen { overflow: auto; max-width: 100%; max-height: 72vh; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; justify-self: stretch; }
.tabelle-rahmen:has(.kal) { overflow: visible; max-height: none; background: none; border: 0; }
table { border-collapse: separate; border-spacing: 0; }
th, td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; }
thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; }
.kopf-name, .zelle-name { position: sticky; left: 0; background: var(--surface); z-index: 1; }
thead .kopf-name { z-index: 3; text-align: left; padding: 6px 10px; font-weight: 600; }
.spalte-knopf { display: block; width: 100%; min-width: 46px; background: none; padding: 4px 2px; border-radius: 0; line-height: 1.15; font-size: 13px; }
.spalte-knopf b { display: block; font: 600 16px/1.1 var(--f-titel); }
.spalte-knopf:hover { color: var(--accent); }
.wochenende, thead th.wochenende { background: var(--wochenende); }
.zelle-name > div { display: flex; align-items: center; }
.name { border: 0 !important; border-radius: 0 !important; background: transparent !important; width: 150px !important; font-weight: 500; padding: 8px 6px 8px 10px !important; }
.zeile-weg { background: none; color: var(--muted); padding: 0 8px; min-height: 32px; }
.zeile-weg:hover { color: var(--crit); }
.zelle { display: block; width: 46px; height: 38px; border: 0; background: transparent; text-align: center; font-weight: 600; padding: 0 2px; }
.zelle:focus, .name:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.art-x { background: var(--art-x); color: var(--muted); }
.art-u { background: var(--art-u); }
.unsicher { box-shadow: inset 0 0 0 2px var(--warn-rand); color: var(--warn); }
.druck { display: none; }
.zelle.dienst24 { box-shadow: inset 0 0 0 2px var(--dienst); }
.zelle.dienst24.unsicher { box-shadow: inset 0 0 0 2px var(--dienst), inset 0 0 0 4px var(--warn-rand); }

.rahmen-legende { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); }
.rahmen-legende span { display: inline-flex; align-items: center; gap: 6px; }
.muster { width: 18px; height: 12px; border: 2px solid; border-radius: 2px; }
.muster-dienst { border-color: var(--dienst); }
.muster-unsicher { border-color: var(--warn-rand); }

/* Kalender für einen Einzelplan */
.kal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.kal-kopf { font: 600 17px/1.2 var(--f-titel); text-align: center; color: var(--muted); padding-bottom: 2px; }
.kal-tag { position: relative; display: flex; flex-direction: column; min-height: 100px; padding-bottom: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.kal-tag:has(.art-x) { background: var(--art-x); }
.kal-tag:has(.art-u) { background: var(--art-u); }
.kal-tag.dienst24 { border: 2px solid var(--dienst); }
.kal-tag.dienst24::after { content: "24 h"; position: absolute; top: 5px; right: 7px; font-size: 12px; font-weight: 700; color: var(--dienst); pointer-events: none; }
.kal-datum { background: none; text-align: left; padding: 5px 8px 0; min-height: 0; font-size: 13px; color: var(--muted); border-radius: 0; }
.kal-datum:hover { color: var(--accent); }
.kal-wt { display: none; font-weight: 600; }
.kal .zelle { flex: 1; width: 100%; height: auto; min-height: 40px; font-size: clamp(12px, 1.9cqw, 17px); background: transparent; }
.kal .zelle.dienst24:not(.unsicher) { box-shadow: none; }
.kal .zelle.dienst24.unsicher { box-shadow: inset 0 0 0 2px var(--warn-rand); }

.notiz-knopf { background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; line-height: 1; padding: 3px 6px; min-height: 0; border-radius: 3px; }
.notiz-knopf:hover { border-color: var(--accent); }
.kal .notiz-knopf { position: absolute; left: 6px; bottom: 5px; }
th .notiz-knopf { display: block; margin: 0 auto 3px; padding: 2px 3px; font-size: 10px; }
.notiz-druck { display: none; }
.notiz-popup { position: fixed; inset: auto; margin: 0; width: min(300px, calc(100vw - 16px)); padding: 12px 14px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgb(0 0 0 / .25); }
.notiz-popup strong { display: block; font: 600 18px/1.2 var(--f-titel); margin-bottom: 4px; }
.notiz-popup p { margin-bottom: 10px; overflow-wrap: anywhere; }

@container (max-width: 560px) {
  .kal .notiz-knopf { left: auto; right: 42px; bottom: auto; top: 50%; transform: translateY(-50%); }
  .kal { grid-template-columns: minmax(0, 1fr); }
  .kal-kopf, .kal-leer { display: none; }
  .kal-tag { flex-direction: row; align-items: center; min-height: 48px; padding-bottom: 0; }
  .kal-tag.dienst24::after { top: 50%; transform: translateY(-50%); }
  .kal-wt { display: inline; }
  .kal-datum { flex: none; width: 104px; padding: 0 0 0 10px; }
  .kal .zelle { font-size: 16px; text-align: left; align-self: stretch; }
}

.foto-feld { position: sticky; top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.foto-knoepfe { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.foto-knoepfe span { flex: 1; }
.foto-rahmen { overflow: auto; max-height: 76vh; }
.foto-rahmen img { display: block; width: 100%; }

dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 18px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .4); }

@media (max-width: 1000px) {
  .arbeit { grid-template-columns: minmax(0, 1fr); }
  .foto-feld { position: static; grid-row: 1; }
  .foto-rahmen { max-height: 38vh; }
  .tabelle-rahmen { max-height: none; }
}
@media (max-width: 560px) {
  .name { width: 104px !important; }
  .stand { order: 3; }
}

@page { size: A4 landscape; margin: 10mm; }
@media print {
  :root { color-scheme: light; --surface: #fff; --ink: #000; --line: #777; --wochenende: #eee; --muted: #333; --art-x: #e4e4e4; --art-u: #d3ecd9; --dienst: #d11a1a; }
  body { background: #fff; font-size: 11px; }
  main { padding: 0; }
  * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .aktionen, #zurueck, #speicherStand, #hinweise, #pruefen, #fotoFeld, #personNeu, .zeile-weg { display: none !important; }
  .arbeit { display: block; }
  .tabelle-rahmen { overflow: visible; max-height: none; border-color: #777; border-radius: 0; }
  thead th, .kopf-name, .zelle-name { position: static; }
  table { width: 100%; table-layout: fixed; }
  .kopf-name { width: 92px; }
  .zelle { display: none; }
  .druck { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 32px; font-size: 9px; line-height: 1.1; font-weight: 600; overflow-wrap: anywhere; }
  .druck.dienst24 { border: 2px solid var(--dienst); }
  .spalte-knopf { min-width: 0; font-size: 9px; padding: 3px 0; }
  .spalte-knopf b { font-size: 12px; }
  .name { width: 100% !important; padding: 4px 6px !important; }
  input { border-color: transparent !important; }
  input::placeholder { color: transparent; }

  #rahmenUnsicher { display: none !important; }
  .notiz-knopf { display: none !important; }
  .notiz-druck { display: block; padding: 0 6px 4px; font-size: 9px; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
  .kal .name { display: none; }
  .kal-tag { min-height: 74px; padding-bottom: 0; }
  .kal-datum { font-size: 12px; }
  .kal .zelle { display: none; }
  .kal .druck { flex: 1; font-size: 16px; min-height: 44px; background: transparent; }
  .kal .druck.dienst24 { border: 0; }
}
