/* Layout: ein karierter Notizblock mit Spiralbindung, darauf die Tabelle Tage × Familie wie auf Papier, mit Kuli-Blau geschrieben.
   Bewusst nur ein Look (Papier), deshalb kein Dark Mode. */
:root {
  --desk: #2f3437;
  --paper: #fbfbf8;
  --grid: #d9e1ea;
  --ink: #1f3a8a;
  --ink-soft: #4b5f9e;
  --pencil: #6b7280;
  --mark: #fff3a8;
  --danger: #b42318;
  --hand: "Kalam", "Comic Sans MS", "Segoe Print", cursive;
  --ui: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--desk); }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 14px/1.4 var(--ui);
  padding: calc(20px + env(safe-area-inset-top, 0px)) 16px calc(40px + env(safe-area-inset-bottom, 0px));
}
[hidden] { display: none !important; }
.pad {
  max-width: 1100px;
  margin: 0 auto;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 18px 18px;
  border-radius: 4px 4px 6px 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  position: relative;
  padding: 34px 18px 22px;
}
.spiral {
  position: absolute; top: -10px; left: 14px; right: 14px; height: 22px;
  background: radial-gradient(circle at 50% 70%, #9aa3ab 0 4px, transparent 5px) 0 0 / 18px 22px repeat-x;
  pointer-events: none;
}
.spiral::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse 3px 9px at 50% 30%, #c9ced3 0 70%, transparent 75%) 0 0 / 18px 22px repeat-x;
}
header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; margin-bottom: 14px; }
h1 {
  font-family: var(--hand); font-weight: 700; font-size: 2.4rem; line-height: 1; margin: 0;
  text-wrap: balance;
}
h1 { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.role {
  display: inline-block; vertical-align: middle; font: 700 .75rem var(--ui); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink); border: 1.5px solid var(--ink); border-radius: 999px; padding: 3px 10px; margin-left: 8px;
  transform: rotate(-3deg);
}
.range { font-family: var(--hand); font-size: 1.15rem; color: var(--ink-soft); margin-top: 8px; }
button { font-family: var(--ui); }
.admin-box { display: flex; flex-wrap: wrap; gap: 8px; }
button.link {
  font: 600 .9rem var(--ui); color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--ink); border-radius: 999px; padding: 6px 14px; cursor: pointer;
}

.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.tabs { display: flex; flex: 1 1 auto; max-width: 420px; border: 1.5px solid var(--ink); border-radius: 10px; overflow: hidden; background: var(--paper); }
.tabs button {
  flex: 1 1 0; font: 700 1rem var(--ui); color: var(--ink); background: transparent; border: 0; padding: 10px 12px; cursor: pointer;
}
.tabs button + button { border-left: 1.5px solid var(--ink); }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.weeknav .arrow {
  font: 700 1.2rem var(--ui); color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--ink); border-radius: 10px; width: 42px; height: 42px; cursor: pointer; flex: none;
}
button:focus-visible, .cell:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 3px solid #f59e0b; outline-offset: 2px;
}

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.tools button {
  font: 600 .85rem var(--ui); color: var(--ink); background: var(--paper); border: 1.5px dashed var(--ink-soft);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.tools .danger-text { color: var(--danger); border-color: var(--danger); }
.confirm { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; background: var(--mark); padding: 4px 8px; border-radius: 8px; }
.confirm .danger-solid { background: var(--danger); color: #fff; border: 1.5px solid var(--danger); }

.status { font-size: .8rem; color: var(--pencil); min-height: 1.2em; margin: 0 0 8px; }

.scroller { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -6px; padding: 0 6px 6px; }
table { border-collapse: collapse; width: 100%; min-width: 760px; table-layout: fixed; font-family: var(--hand); }
col.namecol { width: 92px; }
th, td { border: 1.5px solid var(--ink); }
thead th {
  font-weight: 700; font-size: 1.35rem; padding: 6px 4px 2px; text-align: center; background: rgba(251,251,248,.6);
}
thead th small { display: block; font-size: .85rem; font-weight: 400; color: var(--ink-soft); line-height: 1.1; }
thead th.today { background: var(--mark); }
thead th.corner { border-top-color: transparent; border-left-color: transparent; background: transparent; }
tbody th {
  font-weight: 700; font-size: 1.15rem; text-align: left; padding: 6px 8px; vertical-align: top;
  position: sticky; left: 0; background: var(--paper); z-index: 1;
}
tbody th small { display: block; font-weight: 400; font-size: .8rem; color: var(--ink-soft); }
tbody tr.alle th { color: var(--ink-soft); }
td { padding: 0; vertical-align: top; height: 84px; }
td.today { background: rgba(255,243,168,.35); }
.cell {
  display: block; width: 100%; height: 100%; min-height: 84px; padding: 6px 7px; text-align: left;
  font: 400 1.02rem/1.15 var(--hand); color: var(--ink); background: transparent; border: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; position: relative; cursor: default;
}
.editing .cell { cursor: pointer; }
.editing .cell:hover { background-color: rgba(31,58,138,.06); }
.editing .cell.empty::after {
  content: "+"; position: absolute; right: 7px; bottom: 3px; font-family: var(--ui); font-size: 1rem; color: var(--grid);
}
.editing .cell.empty:hover::after { color: var(--ink-soft); }
.cell.frei {
  color: var(--ink-soft);
  background-image: linear-gradient(to top right, transparent calc(50% - 1px), var(--ink) calc(50% - .5px), var(--ink) calc(50% + .5px), transparent calc(50% + 1px));
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .82rem; color: var(--pencil); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 22px; height: 16px; border: 1.5px solid var(--ink); display: inline-block; }
.swatch.x { background-image: linear-gradient(to top right, transparent calc(50% - 1px), var(--ink) 50%, transparent calc(50% + 1px)); }
.swatch.t { background: var(--mark); }

/* Fenster (Eintrag, Login) */
.backdrop { position: fixed; inset: 0; background: rgba(20,24,28,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 10; padding: 16px; }
@media (min-width: 640px) { .backdrop { align-items: center; } }
.sheet {
  width: 100%; max-width: 440px; background: var(--paper); border-radius: 10px; padding: 18px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 20px 40px rgba(0,0,0,.4); display: grid; gap: 12px;
}
.sheet h2 { margin: 0; font: 700 1.5rem var(--hand); }
.sheet h2 small { display: block; font: 400 .9rem var(--ui); color: var(--ink-soft); }
.sheet textarea, .sheet input[type="password"] {
  width: 100%; font: 400 1.15rem/1.3 var(--hand); color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 6px; padding: 8px 10px; background-color: #fff;
}
.sheet input[type="password"] { font: 400 1rem var(--ui); }
.sheet textarea {
  min-height: 110px; resize: vertical;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px); background-size: 100% 1.5rem;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { font: 400 .95rem var(--hand); color: var(--ink); background: #fff; border: 1px dashed var(--ink-soft); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: .95rem; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--ink); }
.error { color: var(--danger); font-weight: 600; font-size: .9rem; min-height: 0; }
.error:empty { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.actions button { font: 700 .95rem var(--ui); border-radius: 8px; padding: 9px 16px; cursor: pointer; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); }
.actions .primary { background: var(--ink); color: var(--paper); }
.actions .clear { border-color: var(--danger); color: var(--danger); margin-right: auto; }
.actions button:disabled { opacity: .6; cursor: wait; }
@media (prefers-reduced-motion: no-preference) { .sheet { animation: up .18s ease-out; } @keyframes up { from { transform: translateY(16px); opacity: .6; } } }
/* ---------- Handy: Tagesansicht ---------- */
.viewswitch, .dayview { display: none; }
@media (max-width: 719px) {
  body { padding: calc(14px + env(safe-area-inset-top, 0px)) 10px calc(24px + env(safe-area-inset-bottom, 0px)); }
  .pad { padding: 26px 14px 18px; }
  .spiral { left: 8px; right: 8px; overflow: hidden; }
  header { flex-direction: column; gap: 10px; margin-bottom: 12px; }
  h1 { font-size: 2.1rem; }
  .range { font-size: 1rem; margin-top: 6px; }
  .admin-box { gap: 6px; }
  button.link { font-size: .8rem; padding: 5px 11px; }
  #btnPrint { display: none; }
  .weeknav { gap: 6px; }
  .weeknav .arrow { width: 38px; height: 38px; }
  .tabs { max-width: none; }
  .tabs button { font-size: .9rem; padding: 9px 4px; }
  .tools button { font-size: .8rem; }

  .viewswitch { display: flex; gap: 0; margin: 0 0 12px; border: 1.5px solid var(--ink-soft); border-radius: 999px; overflow: hidden; width: max-content; }
  .viewswitch button { font: 600 .82rem var(--ui); color: var(--ink-soft); background: var(--paper); border: 0; padding: 5px 14px; cursor: pointer; }
  .viewswitch button[aria-pressed="true"] { background: var(--ink-soft); color: var(--paper); }

  body:not(.view-table) .dayview { display: block; }
  body:not(.view-table) .scroller, body:not(.view-table) .legend .swatch.t { display: none; }
  body:not(.view-table) .legend { display: none; }
}
.daystrip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 14px; }
.daystrip button {
  display: grid; justify-items: center; gap: 1px; padding: 6px 0 5px; cursor: pointer;
  font-family: var(--hand); color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--ink); border-radius: 8px; position: relative;
}
.daystrip b { font-size: 1.1rem; line-height: 1.1; }
.daystrip small { font-size: .75rem; color: var(--ink-soft); line-height: 1; }
.daystrip button.today { background: var(--mark); }
.daystrip button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.daystrip button[aria-pressed="true"] small { color: var(--paper); }
.daystrip .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .7; margin-top: 2px; }
.daystrip .dot.none { opacity: 0; }
.dayhead { font: 700 1.5rem var(--hand); margin: 0 0 8px; }
.dayhead small { font: 400 .95rem var(--hand); color: var(--ink-soft); margin-left: 6px; }
.daylist { list-style: none; margin: 0; padding: 0; border: 1.5px solid var(--ink); border-radius: 4px; background: rgba(251,251,248,.85); }
.daylist li + li { border-top: 1.5px solid var(--ink); }
.dayrow {
  display: grid; grid-template-columns: 84px minmax(0, 1fr); width: 100%; min-height: 64px; padding: 0; text-align: left;
  background: transparent; border: 0; color: var(--ink); font-family: var(--hand);
}
.dayrow .who { padding: 10px 8px 10px 10px; border-right: 1.5px solid var(--ink); font-weight: 700; font-size: 1.1rem; line-height: 1.1; }
.dayrow .who small { display: block; font-weight: 400; font-size: .75rem; color: var(--ink-soft); }
.dayrow .what { padding: 10px 12px; font-size: 1.1rem; line-height: 1.25; white-space: pre-wrap; overflow-wrap: anywhere; position: relative; }
.dayrow .what.empty { color: var(--pencil); opacity: .6; }
.dayrow .what.frei {
  color: var(--ink-soft);
  background-image: linear-gradient(to top right, transparent calc(50% - 1px), var(--ink) calc(50% - .5px), var(--ink) calc(50% + .5px), transparent calc(50% + 1px));
}
.editing .dayrow { cursor: pointer; }
.editing .dayrow:active { background: rgba(31,58,138,.08); }
.editing .dayrow .what.empty::after { content: "+ eintragen"; font: 600 .8rem var(--ui); color: var(--ink-soft); }
.swipehint { text-align: center; font-size: .78rem; color: var(--pencil); margin: 8px 0 0; }

/* Drucken: nur Überschrift und Tabelle, A4 quer */
@page { size: A4 landscape; margin: 10mm; }
@media print {
  html, body { background: #fff; padding: 0; }
  .pad { box-shadow: none; padding: 0; max-width: none; background: #fff; }
  .spiral, .admin-box, .weeknav, .tools, .status, .legend, .backdrop, .role, .viewswitch, .dayview { display: none !important; }
  .scroller { display: block !important; }
  header { margin-bottom: 6mm; }
  .scroller { overflow: visible; margin: 0; padding: 0; }
  table { min-width: 0; }
  tbody th { position: static; }
  td, .cell { height: auto; min-height: 22mm; }
  td.today, thead th.today { background: none; }
  .cell { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cell.empty::after { display: none; }
}
@media (max-width: 480px) { h1 { font-size: 2rem; } .pad { padding: 30px 12px 18px; } .tabs button { font-size: .92rem; padding: 10px 6px; } }
