/* Familienkalender – Gestaltung
   Ruhige, kühle Flächen; Farbe kommt von den Kalendern. Die Periodenüberschrift ist die einzige Serifenschrift. */

:root {
  color-scheme: light dark;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eceff3;
  --ink: #18202b;
  --muted: #5b6776;
  --line: #dde1e8;
  --line-2: #e9ecf1;
  --accent: #2459d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefc;
  --today: #e8f0ff;
  --danger: #bf2f25;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 30px rgba(16, 24, 40, .14);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, serif;
  --side-w: 272px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1217;
    --surface: #161b22;
    --surface-2: #1d242d;
    --ink: #e8ecf1;
    --muted: #9ba7b6;
    --line: #29313c;
    --line-2: #212832;
    --accent: #7aa5ff;
    --accent-ink: #0b1220;
    --accent-soft: #1c2a47;
    --today: #1b2b4a;
    --danger: #ff7b70;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .5);
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
ul { list-style: none; margin: 0; padding: 0; }
small, .meta { color: var(--muted); }
.meta { font-size: .86rem; margin: 6px 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.spacer { flex: 1; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Buttons & Eingaben ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 8px;
  border: 0; background: transparent; color: inherit; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.input {
  width: 100%; min-height: 38px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.input.big { font-size: 1.25rem; font-weight: 600; border: 0; border-bottom: 2px solid var(--line); border-radius: 0; padding-left: 0; background: transparent; }
.input.big:focus-visible { outline: 0; border-bottom-color: var(--accent); }
.input.narrow { width: 76px; }
.input.small { min-height: 32px; padding: 3px 8px; width: auto; }
textarea.input { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check.small { font-size: .85rem; color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 17px; height: 17px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.field-hint { font-size: .8rem; color: var(--muted); }
.row { margin-top: 14px; display: grid; gap: 6px; }
.row.inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.wrap { gap: 8px; }

/* ---------- Gerüst ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100dvh; }
.side {
  background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  padding: calc(14px + var(--safe-t)) 14px calc(14px + var(--safe-b)); gap: 14px; overflow-y: auto; min-height: 0;
}
.brand { font-family: var(--font-serif); font-size: 1.3rem; letter-spacing: .01em; padding: 2px 4px; display: flex; align-items: center; gap: 8px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 700 .8rem var(--font); }
.cal-group h3 { font-size: .75rem; font-weight: 600; color: var(--muted); padding: 0 6px 4px; letter-spacing: .02em; }
.cal-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; background: transparent; border-radius: 8px; text-align: left; }
.cal-item:hover { background: var(--surface-2); }
.cal-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.off .name { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.cal-box {
  width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--c); background: var(--c); flex: none;
  display: grid; place-items: center; color: var(--fg, #fff);
}
.cal-item.off .cal-box { background: transparent; }
.cal-box svg { width: 12px; height: 12px; stroke-width: 3; }
.cal-item.off .cal-box svg { display: none; }
.cal-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.cal-dot.lg { width: 16px; height: 16px; }
.side-foot { margin-top: auto; display: grid; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; border: 0; background: transparent; width: 100%; text-align: left; }
.side-link:hover { background: var(--surface-2); }
.side-link svg { color: var(--muted); }
.side-user { padding: 8px; font-size: .85rem; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.bar {
  display: flex; align-items: center; gap: 6px; padding: calc(10px + var(--safe-t)) 14px 10px;
  border-bottom: 1px solid var(--line); background: var(--surface); min-height: 60px;
}
.bar h1 { font-family: var(--font-serif); font-weight: 500; font-size: 1.5rem; letter-spacing: .005em; margin-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .sub { color: var(--muted); font-size: .85rem; margin-left: 4px; white-space: nowrap; }
.bar .menu-btn { display: none; }
.view-tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 10px; margin-left: auto; }
.view-tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; }
.view-tabs button[aria-current=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px; background: transparent; white-space: nowrap;
}
.status.warn { color: var(--ink); border-color: #e0a100; background: color-mix(in srgb, #e0a100 16%, transparent); }
.status.busy svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#view { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px; }
#view.fill { overflow: hidden; }
.tabs { display: none; }
.fab {
  position: fixed; right: 18px; bottom: 18px; width: 56px; height: 56px; border-radius: 18px; border: 0;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow); display: none; place-items: center; z-index: 5;
}
.scrim { display: none; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- Terminübersicht ---------- */
.agenda { max-width: 860px; margin: 0 auto; }
.agenda-day { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.agenda-day:first-child { border-top: 0; }
.agenda-day-head { display: flex; align-items: center; gap: 12px; align-self: start; }
.agenda-daynum { font-family: var(--font-serif); font-size: 2rem; line-height: 1; width: 2.3rem; height: 2.3rem; display: grid; place-items: center; border-radius: 50%; }
.agenda-day.today .agenda-daynum { background: var(--accent); color: var(--accent-ink); }
.agenda-dayname { font-weight: 600; display: grid; line-height: 1.2; }
.agenda-dayname small { font-weight: 400; }
.agenda-list { display: grid; gap: 2px; min-width: 0; }
.agenda-item {
  display: grid; grid-template-columns: 112px 4px minmax(0, 1fr); gap: 12px; align-items: stretch; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left;
}
.agenda-item:hover { background: var(--surface-2); }
.agenda-when { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .88rem; padding-top: 1px; display: grid; align-content: start; }
.agenda-bar { background: var(--c); border-radius: 2px; }
.agenda-what { display: grid; gap: 1px; min-width: 0; }
.agenda-title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.ico-inline { color: var(--muted); display: inline-flex; }
.agenda-meta { color: var(--muted); font-size: .86rem; display: flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.agenda-cal { color: var(--muted); font-size: .78rem; }
.agenda-more { min-height: 40px; }

/* ---------- Suche ---------- */
.search { max-width: 860px; margin: 0 auto; }
.search-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.search-bar svg { color: var(--muted); }
.search-input { flex: 1; min-width: 160px; border: 0; background: transparent; font-size: 1.05rem; padding: 6px 0; }
.search-input:focus-visible { outline: 0; }
.search-section h3 { margin: 22px 4px 6px; font-size: .9rem; color: var(--muted); }
.search-item .agenda-when small { font-size: .78rem; }

/* ---------- Woche ---------- */
.week { height: 100%; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.wk-head, .wk-allday { display: grid; grid-template-columns: 52px repeat(7, minmax(0, 1fr)); }
.wk-head { border-bottom: 1px solid var(--line); }
.wk-gutter { font-size: .7rem; color: var(--muted); display: grid; place-items: center; }
.wk-gutter.small { font-size: .6rem; overflow: hidden; align-self: start; padding-top: 4px; grid-row: 1; }
.wk-dayhead { border: 0; background: transparent; padding: 8px 4px; display: grid; justify-items: center; gap: 2px; border-left: 1px solid var(--line-2); }
.wk-dow { font-size: .78rem; color: var(--muted); font-weight: 600; }
.wk-dom { font-family: var(--font-serif); font-size: 1.35rem; width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 50%; }
.wk-dayhead.today .wk-dom { background: var(--accent); color: var(--accent-ink); }
.wk-dayhead.today .wk-dow { color: var(--accent); }
.wk-allday { grid-template-rows: repeat(var(--lanes, 1), 22px); row-gap: 2px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.wk-allday.empty-row { display: none; }
.wk-scroll { flex: 1; overflow: auto; min-height: 0; position: relative; }
.wk-grid { display: grid; grid-template-columns: 52px repeat(7, minmax(0, 1fr)); }
.wk-hour { height: var(--hour); font-size: .68rem; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.wk-col {
  position: relative; border-left: 1px solid var(--line-2); height: calc(var(--hour) * 24); cursor: cell;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hour) - 1px), var(--line-2) calc(var(--hour) - 1px), var(--line-2) var(--hour));
}
.wk-col.today { background-color: var(--today); }
.wk-ev {
  position: absolute; border: 0; border-left: 3px solid var(--c); border-radius: 5px; padding: 2px 5px; text-align: left; overflow: hidden;
  background: color-mix(in srgb, var(--c) 20%, var(--surface)); color: var(--ink); display: flex; flex-direction: column; gap: 0; font-size: .78rem; line-height: 1.25; cursor: pointer;
}
.wk-ev:hover { background: color-mix(in srgb, var(--c) 32%, var(--surface)); z-index: 2; }
.wk-ev.tiny { flex-direction: row; gap: 5px; align-items: baseline; }
.wk-ev.cont-top { border-top-left-radius: 0; border-top-right-radius: 0; }
.wk-ev.cont-bottom { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.wk-ev-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.wk-ev-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.wk-ev-loc { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* Balken (ganztägig / mehrtägig) – gemeinsam für Woche und Monat */
.seg { font-size: .78rem; text-align: left; border: 0; min-width: 0; overflow: hidden; }
.seg.seg-bar {
  background: var(--c); color: var(--fg, #fff); border-radius: 5px; margin: 0 2px; padding: 0 7px; height: 20px; line-height: 20px; font-weight: 500;
  white-space: nowrap; text-overflow: ellipsis;
}
.seg.seg-bar:hover { filter: brightness(1.1); }
.seg.seg-bar.cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.seg.seg-bar.cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.seg.chip { display: flex; align-items: center; gap: 5px; margin: 0 2px; padding: 0 4px; height: 20px; border-radius: 5px; background: transparent; }
.seg.chip:hover { background: var(--surface-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.chip-time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* ---------- Monat ---------- */
.month { height: 100%; display: grid; grid-template-rows: auto repeat(var(--weeks), minmax(84px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mo-dows { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.mo-dows div { padding: 7px 10px; font-size: .78rem; color: var(--muted); font-weight: 600; }
.mo-week { position: relative; border-bottom: 1px solid var(--line-2); min-height: 0; overflow: hidden; }
.mo-week:last-child { border-bottom: 0; }
.mo-bg { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mo-cell { border-right: 1px solid var(--line-2); cursor: pointer; }
.mo-cell:last-child { border-right: 0; }
.mo-cell.weekend { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.mo-cell.other { background: color-mix(in srgb, var(--surface-2) 80%, transparent); }
.mo-cell.today { background: var(--today); }
.mo-grid {
  position: relative; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); pointer-events: none; padding-top: 2px;
  grid-template-rows: 26px repeat(var(--lanes), 20px) 18px; row-gap: 1px;
}
.mo-grid > * { pointer-events: auto; }
.mo-num { justify-self: start; margin: 0 0 0 5px; border: 0; background: transparent; font-size: .85rem; min-width: 24px; height: 24px; border-radius: 12px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.mo-num:hover { background: var(--surface-2); }
.mo-num.today { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.mo-more { justify-self: start; border: 0; background: transparent; color: var(--muted); font-size: .76rem; font-weight: 600; padding: 0 6px; margin-left: 2px; }
.mo-more:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Dialoge ---------- */
dialog.modal {
  border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  width: min(520px, calc(100vw - 20px)); max-height: calc(100dvh - 24px); overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal.wide { width: min(640px, calc(100vw - 20px)); }
dialog.modal.small { width: min(420px, calc(100vw - 20px)); }
dialog.modal::backdrop { background: rgba(8, 12, 18, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px 20px; gap: 8px; }
.modal-head h2 { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; min-height: 0; }
.modal-foot { display: flex; gap: 8px; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); align-items: center; }
.choice-list { display: grid; gap: 8px; margin-top: 10px; }
.btn.choice { justify-content: flex-start; min-height: 44px; }
.btn.choice.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.choice.danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.ev-modal { border-top: 5px solid var(--c, var(--accent)); }
.ev-form .row { margin-top: 12px; }
.dt { grid-template-columns: 1fr; gap: 10px; }
.dt-pair { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; }
.dt-pair:has(input[type=time][hidden]) { grid-template-columns: 1fr; }
.series-note { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); margin: 0; }
.wd-box { display: flex; gap: 4px; flex-wrap: wrap; }
.wd { width: 38px; height: 34px; border-radius: 17px; border: 1px solid var(--line); background: transparent; font-size: .82rem; }
.wd[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; background: var(--c); padding: 0; box-shadow: inset 0 0 0 2px var(--surface); }
.swatch[aria-pressed=true] { border-color: var(--ink); }
.swatch-custom { width: 32px; height: 32px; padding: 0; border: 0; background: transparent; border-radius: 50%; }
.cal-rows { display: grid; gap: 2px; }
.cal-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.cal-row-main { flex: 1; display: grid; min-width: 0; }
.cal-row-main small { overflow: hidden; text-overflow: ellipsis; }
.members { display: grid; gap: 6px; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.feed-url { display: flex; gap: 6px; align-items: center; }
.user-rows { display: grid; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.user-row.disabled .user-main strong { text-decoration: line-through; }
.user-main { flex: 1; display: grid; min-width: 160px; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.user-new { display: grid; gap: 8px; margin: 8px 0; }
.users-admin h3 { margin: 18px 0 6px; font-size: .95rem; }
.secret { background: var(--accent-soft); border-radius: 10px; padding: 12px; margin-bottom: 12px; display: grid; gap: 6px; }
.import-preview { margin-top: 14px; }
.import-samples { margin: 8px 0; padding-left: 18px; list-style: disc; font-size: .88rem; color: var(--muted); }
.import-warn { font-size: .85rem; margin-top: 8px; }
.import-warn ul { padding-left: 18px; list-style: disc; max-height: 140px; overflow: auto; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { background: #202833; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: .92rem; transition: opacity .4s; pointer-events: auto; }
.toast.error { background: #a12a21; }
.toast.warn { background: #8a5a00; }
.toast.out { opacity: 0; }

/* ---------- Anmeldung ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { font-family: var(--font-serif); font-weight: 500; font-size: 1.7rem; margin-bottom: 4px; }
.auth-card p { margin: 0 0 14px; color: var(--muted); }
.auth-card form { display: grid; gap: 12px; }
.auth-error { color: var(--danger); font-size: .9rem; min-height: 1.2em; }
.auth-card .btn { width: 100%; min-height: 44px; }

/* ---------- Mobil ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); z-index: 20; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(8, 12, 18, .5); z-index: 15; }
  .scrim.show { display: block; }
  .bar { padding-left: 6px; padding-right: 8px; gap: 2px; }
  .bar .menu-btn { display: inline-grid; }
  .bar h1 { font-size: 1.2rem; margin-left: 2px; flex: 1; }
  .bar .sub, .view-tabs, .bar .today-btn { display: none; }
  .status { font-size: 0; padding: 6px; gap: 0; }
  .mo-num { white-space: nowrap; padding: 0 4px; margin-left: 2px; font-size: .8rem; }
  .tabs {
    display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: var(--safe-b);
  }
  .tabs button { border: 0; background: transparent; padding: 8px 0 6px; display: grid; justify-items: center; gap: 2px; font-size: .72rem; color: var(--muted); }
  .tabs button[aria-current=true] { color: var(--accent); font-weight: 600; }
  #view { padding: 8px; }
  .fab { display: grid; bottom: calc(76px + var(--safe-b)); }
  #toasts { bottom: calc(80px + var(--safe-b)); }
  .agenda-day { grid-template-columns: 1fr; gap: 2px; }
  .agenda-day-head { gap: 10px; }
  .agenda-item { grid-template-columns: 84px 4px minmax(0, 1fr); gap: 10px; }
  .mo-dows div { padding: 6px 4px; text-align: center; }
  .seg.chip .chip-time { display: none; }
  .seg { font-size: .72rem; }
  .wk-head, .wk-allday, .wk-grid { grid-template-columns: 38px repeat(7, minmax(0, 1fr)); }
  .wk-hour { padding-right: 4px; font-size: .62rem; }
  .wk-dom { font-size: 1.05rem; width: 1.7rem; height: 1.7rem; }
  .wk-ev { font-size: .7rem; padding: 1px 3px; }
  .wk-ev-time { display: none; }
  .wk-ev:not(.tiny) .wk-ev-time { display: block; }
  .dt-pair { grid-template-columns: 1fr 1fr; }
  dialog.modal { width: calc(100vw - 12px) !important; max-height: calc(100dvh - 12px); }
}
@media (min-width: 861px) {
  .user-new { grid-template-columns: 1fr 1fr; }
  .user-new .input:nth-child(3) { grid-column: 1 / -1; }
}
@media print {
  .side, .bar, .tabs, .fab { display: none !important; }
  .shell { display: block; height: auto; }
  #view { overflow: visible; }
}

/* ---------- Labels ---------- */
.lbl { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; line-height: 1; padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 6px; white-space: nowrap; }
.agenda-cal .lbl:first-child { margin-left: 8px; }
.lbl.edit { margin: 0; font-size: .82rem; padding: 5px 6px 5px 10px; background: var(--accent-soft); color: var(--ink); }
.lbl.edit button { border: 0; background: transparent; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 3px; border-radius: 50%; }
.lbl.edit button:hover { color: var(--ink); }
.lbl-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-height: 40px; }
.lbl-input { flex: 1; min-width: 120px; border: 0; background: transparent; padding: 4px 2px; }
.lbl-input:focus-visible { outline: 0; }
.lbl-edit:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.lbl-filter { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 6px; }
.lbl-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; font-size: .84rem; }
.lbl-chip small { font-size: .72rem; }
.lbl-chip:hover { background: var(--surface-2); }
.lbl-chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.lbl-chip[aria-pressed=true] small { color: inherit; opacity: .8; }
.filter-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--ink); border-radius: 999px; padding: 4px 10px; font-size: .82rem; margin-left: 6px; white-space: nowrap; max-width: 28vw; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Kalender: nur / alle ---------- */
.cal-li { display: flex; align-items: center; }
.cal-li .cal-item { flex: 1; min-width: 0; }
.only-btn { border: 0; background: transparent; color: var(--muted); font-size: .76rem; padding: 4px 8px; border-radius: 6px; opacity: 0; }
.cal-li:hover .only-btn, .only-btn:focus-visible { opacity: 1; }
.only-btn:hover { background: var(--surface-2); color: var(--ink); }
@media (hover: none) { .only-btn { opacity: 1; } }
.show-all { justify-content: flex-start; }

/* ---------- Erinnerungen ---------- */
.rem-edit { display: grid; gap: 6px; justify-items: start; }
.rem-row { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.rem-row .icon-btn { width: 32px; height: 32px; }
#reminders {
  position: fixed; top: calc(70px + var(--safe-t)); right: 16px; width: min(380px, calc(100vw - 24px)); z-index: 30;
  display: grid; gap: 8px; max-height: calc(100dvh - 100px); overflow-y: auto; padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.rem-head { display: flex; align-items: center; gap: 8px; padding: 2px 2px 4px; }
.rem-head .btn { margin-left: auto; }
.rem-card { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 10px; padding: 8px 8px 8px 10px; background: var(--surface); }
.rem-main { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 0; display: grid; gap: 1px; }
.rem-main span, .rem-main small { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) { #reminders { top: calc(64px + var(--safe-t)); right: 8px; left: 8px; width: auto; } .filter-pill { max-width: 40vw; } }

/* ---------- Blocker ("Belegt") ---------- */
.seg.seg-bar.blocked { background: repeating-linear-gradient(135deg, var(--c) 0 7px, color-mix(in srgb, var(--c) 65%, #fff) 7px 14px); }
.seg.chip.blocked .chip-title { font-style: italic; color: var(--muted); font-weight: 400; }
.wk-ev.blocked { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 22%, var(--surface)) 0 7px, color-mix(in srgb, var(--c) 8%, var(--surface)) 7px 14px); }
.wk-ev.blocked .wk-ev-title { font-style: italic; color: var(--muted); }
.agenda-item.blocked .agenda-title { font-style: italic; color: var(--muted); font-weight: 500; }

/* ---------- Markierung Privat / Blocker ---------- */
.vis-mark { display: inline-flex; vertical-align: -2px; margin: 0 4px; opacity: .8; flex: none; }
.vis-mark.private { opacity: .9; }
.seg.seg-bar .vis-mark { margin: 0 4px 0 0; }
.seg.chip .vis-mark { margin: 0 0 0 auto; color: var(--muted); }
.wk-ev-title { display: flex; align-items: center; gap: 3px; }
.wk-ev-title .vis-mark { margin: 0; }
.vis-pill { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 500; line-height: 1; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 4px; }
.vis-pill.private { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.vis-pill.busy { background: color-mix(in srgb, #e0a100 18%, var(--surface)); color: var(--ink); }

/* ---------- Freigaben in der Kalenderliste ---------- */
.shares { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.shares.none { color: var(--muted); font-size: .8rem; align-items: center; gap: 5px; }
.share-chip { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink); }
.share-chip svg { color: var(--muted); }
.share-chip em { font-style: normal; color: var(--muted); }
.share-chip.write { background: var(--accent-soft); }
.share-chip.feed { background: color-mix(in srgb, #e0a100 16%, var(--surface)); }
.cal-row { align-items: flex-start; }
.cal-row .btn { margin-top: 2px; }
.cal-dot.lg { margin-top: 3px; }

/* Titelzeile auf mittleren Breiten entlasten: Status nur als Icon */
@media (max-width: 1320px) and (min-width: 861px) {
  .status { font-size: 0; padding: 6px; gap: 0; }
  .bar .sub { display: none; }
}

/* ---------- Schnell-Import ---------- */
.qi-info { margin: 4px 0 10px; font-weight: 500; }
.qi-list { display: grid; gap: 8px; margin-bottom: 12px; }
.qi-card { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; background: var(--surface-2); }
.qi-card span { color: var(--muted); font-size: .88rem; }
.qi-card .ico-inline { margin-left: 6px; vertical-align: -2px; }
.qi-loc { display: flex; align-items: center; gap: 4px; }
#dropzone {
  position: fixed; inset: 10px; z-index: 300; display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center;
  border: 3px dashed var(--accent); border-radius: 20px; background: color-mix(in srgb, var(--accent-soft) 88%, transparent); color: var(--ink); pointer-events: none;
}
#dropzone span { color: var(--muted); }
@media (max-width: 860px) { .import-btn { display: none; } }

/* ---------- Tagesarten: Feiertag · Brückentag · Urlaub ----------
   Farbe kommt immer vom Kalender (--dc, gesetzt aus der persönlichen Kalenderfarbe).
   Unterscheidung der Art ohne Label:  Feiertag = kräftige Fläche, Brückentag = Schraffur, Urlaub = zarte Fläche. */
.dm { --dm-ink: color-mix(in srgb, var(--dc) 62%, var(--ink)); }
.dm.dm-holiday { background: color-mix(in srgb, var(--dc) 20%, var(--surface)); }
.dm.dm-bridge { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--dc) 24%, var(--surface)) 0 6px, color-mix(in srgb, var(--dc) 8%, var(--surface)) 6px 12px); }
.dm.dm-vacation { background: color-mix(in srgb, var(--dc) 11%, var(--surface)); }
.mo-grid .dm, .mo-grid .dm:hover { background: transparent; }  /* Zahl/Name liegen über der getönten Zelle */

/* Monat */
.mo-num.dm:not(.today) { color: var(--dm-ink); font-weight: 700; }
.mo-hol { justify-self: end; align-self: center; max-width: calc(100% - 40px); margin-right: 6px; border: 0; background: transparent; padding: 0; font-size: .72rem; font-weight: 600; color: var(--dm-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.mo-hol[data-dm=bridge] { font-style: italic; }
.mo-hol[data-dm=vacation] { font-weight: 500; }
.mo-hol:hover { text-decoration: underline; }

/* Woche */
.wk-dayhead.dm:not(.today) .wk-dom { color: var(--dm-ink); }
.wk-hol { display: block; max-width: 100%; font-size: .68rem; font-weight: 600; color: var(--dm-ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wk-hol[data-dm=bridge] { font-style: italic; }
.wk-hol[data-dm=vacation] { font-weight: 500; }
.wk-col.dm { background-blend-mode: normal; }

/* Übersicht */
.agenda-day-head { display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); gap: 0 12px; align-items: start; }
.agenda-dayname { display: grid; line-height: 1.25; min-width: 0; }
.agenda-holname { border: 0; background: transparent; padding: 0; margin-top: 3px; text-align: left; justify-self: start; font-weight: 700; font-size: .9rem; line-height: 1.25; color: var(--dm-ink, var(--ink)); text-wrap: balance; }
.agenda-holname[data-dm=bridge] { font-style: italic; }
.agenda-holname[data-dm=vacation] { font-weight: 500; }
.agenda-holname small { font-weight: 400; color: var(--muted); font-style: normal; }
.agenda-holname:hover { text-decoration: underline; }
.agenda-day.dm { border-top-color: transparent; border-radius: 12px; padding-left: 14px; padding-right: 14px; margin: 0 -14px; }
.agenda-day.dm + .agenda-day { border-top-color: transparent; }
.agenda-day.dm + .agenda-day.dm { margin-top: 6px; }
.agenda-day.dm:not(.today) .agenda-daynum { color: var(--dm-ink); }
.agenda-day.dm .agenda-item:hover { background: color-mix(in srgb, var(--dc) 14%, var(--surface)); }
@media (max-width: 860px) { .agenda-day.dm { margin: 0 -2px; padding-left: 12px; padding-right: 12px; } }

/* Tagesdialog */
.hol-banner { display: grid; gap: 2px; border-radius: 10px; padding: 8px 12px; margin: 2px 0 10px; }

@media (max-width: 860px) {
  .mo-hol { display: none; }
  .mo-num.dm::after { content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--dm-ink); margin-left: 3px; vertical-align: middle; }
  .wk-hol { font-size: 0; }
}

/* Wochenansicht: Kopf und ganztägige Zeile um die Scrollbar-Breite des Zeitrasters einrücken (--sbw per JS gemessen) */
.wk-head { padding-right: var(--sbw, 0px); }
.wk-allday { padding-right: var(--sbw, 0px); }

/* ---------- Sprungauswahl (Titel anklicken) ---------- */
.bar h1 { overflow: visible; }
.title-btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; letter-spacing: inherit; color: inherit; background: transparent; border: 0; border-radius: 10px; padding: 2px 8px; white-space: nowrap; }
.title-btn:not(:disabled):hover { background: var(--surface-2); }
.title-btn .caret { display: inline-flex; color: var(--muted); }
.title-btn:disabled { cursor: default; }
.title-btn:disabled .caret { display: none; }
.title-text { overflow: hidden; text-overflow: ellipsis; }
#jump { position: fixed; z-index: 60; width: 320px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); display: grid; gap: 10px; }
.jump-head { display: grid; grid-template-columns: 38px 1fr 38px; gap: 6px; align-items: center; }
.jump-head select { width: 100%; text-align: center; font-weight: 600; min-height: 38px; }
.jump-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.jump-month { min-height: 42px; border: 1px solid var(--line); background: transparent; border-radius: 10px; font-weight: 500; position: relative; }
.jump-month:hover { background: var(--surface-2); }
.jump-month[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.jump-month.now:not([aria-pressed=true])::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--accent); }
.jump-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.jump-date { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); min-width: 0; }
.jump-date .input { width: auto; min-width: 0; }
@media (max-width: 860px) { .bar h1 { min-width: 0; } #jump { width: calc(100vw - 16px); left: 8px !important; } }

/* Titel hat Vorrang: Ansichts-Tabs zeigen bei mittleren Breiten nur Icons (Tooltip bleibt) */
.bar h1 { flex: 0 1 auto; min-width: 0; }
@media (max-width: 1480px) and (min-width: 861px) {
  .view-tabs button { font-size: 0; gap: 0; padding: 8px 11px; }
}

.bar h1 { margin-left: 2px; }
@media (max-width: 860px) { .title-btn { max-width: 100%; } }

/* ---------- Serien: Bearbeitungsumfang ---------- */
.mode-tabs { display: flex; gap: 2px; background: var(--surface-2); padding: 3px; border-radius: 10px; margin: 12px 0 6px; flex-wrap: wrap; }
.mode-tab { flex: 1 1 auto; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.mode-tab:hover { color: var(--ink); }
.mode-tab[aria-selected=true] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .14); }
.mode-hint { margin: 0 0 4px; }
.rec-wrap { display: contents; }
.rec-wrap[hidden] { display: none !important; }

/* ---------- Fehlerhinweise ---------- */
#toasts.in-dialog { position: fixed; top: 14px; bottom: auto; left: 50%; transform: translateX(-50%); z-index: 1000; }
.toast.warn { background: #8a5a00; }
[aria-invalid=true] { border-color: var(--danger) !important; outline: 2px solid var(--danger); outline-offset: 1px; }

/* Schnellauswahl (häufige Titel/Orte) */
.pick-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.pick-row > .input { flex: 1 1 auto; min-width: 0; }
.pick-btn { border: 1px solid var(--line); color: var(--muted); }
.pick-btn:disabled { opacity: .4; cursor: not-allowed; }
.pick-row > .input.big + .pick-btn { border-color: transparent; }
.pick-list { display: grid; gap: 2px; margin-top: 8px; }
.pick-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; width: 100%; min-height: 42px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; }
.pick-item:hover, .pick-item:focus-visible { background: var(--accent-soft); }
.pick-text { min-width: 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; padding-top: 2px; }
.pick-count { flex: none; padding-top: 3px; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }

/* ---------- Übersicht: schmale Datumsleiste, Tagesarten als eigene Zeile ---------- */
/* Monatsgruppe: Überschrift klebt oben, bis die nächste Gruppe sie verdrängt */
.agenda-mg + .agenda-mg { margin-top: 10px; }
.agenda-month { position: sticky; top: 0; z-index: 3; background: var(--bg); font-family: var(--font-serif); font-size: 1.15rem; font-weight: 600; padding: 12px 2px 8px; box-shadow: 0 0 0 100vmax var(--bg); clip-path: inset(0 -100vmax); }   /* deckt beim Kleben die volle Breite ab (auch die überstehenden Tagesart-Flächen), nach oben/unten nur den eigenen Kasten */
.agenda-month + .agenda-day { border-top: 0; padding-top: 8px; }
.agenda-end { text-align: center; color: var(--muted); font-size: .85rem; padding: 4px 0 8px; }
.agenda-end[hidden] { display: none; }
.agenda-day { position: relative; }
.agenda-add { position: absolute; top: 10px; right: 4px; width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--muted); opacity: 0; transition: opacity .12s; z-index: 1; }
.agenda-day:hover .agenda-add, .agenda-add:focus-visible { opacity: 1; }
.agenda-add:hover { color: var(--accent); border-color: var(--accent); }
@media (hover: none) { .agenda-add { display: none; } }   /* Touch: „+“ in der Kopfzeile nutzt den oben sichtbaren Tag */
.agenda-hols { display: flex; flex-wrap: wrap; gap: 2px 14px; min-width: 0; }
.agenda-hols .agenda-holname { margin-top: 0; }
.agenda-dayname .dn-short { display: none; }
@media (min-width: 861px) {
  .agenda-day { grid-template-columns: 64px minmax(0, 1fr); gap: 0 10px; }
  .agenda-day-head { grid-column: 1; grid-row: 1 / span 2; display: flex; flex-direction: column-reverse; align-items: center; justify-content: flex-end; gap: 3px; padding-top: 2px; }
  .agenda-dayname { display: block; text-align: center; font-weight: 600; }
  .agenda-dayname .dn-long, .agenda-dayname .dn-month { display: none; }
  .agenda-dayname .dn-short { display: block; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .agenda-day.today .dn-short { color: var(--accent); }
  .agenda-day.dm .dn-short { color: var(--dm-ink, var(--muted)); }
  .agenda-hols { grid-column: 2; grid-row: 1; padding: 2px 10px 4px 10px; }
  .agenda-list { grid-column: 2; grid-row: 2; }
  .agenda-item { grid-template-columns: 96px 4px minmax(0, 1fr); }
  .agenda-month { padding-left: 74px; }
}
@media (max-width: 860px) {
  .agenda-hols { padding: 0 0 4px calc(2.6rem + 12px); }
  .agenda-month { padding-left: 4px; }
}
.agenda-meta { align-items: flex-start; }
.agenda-meta > svg { margin-top: 3px; flex: none; }

/* Ganztägige Zeile der Woche: einklappbar, eingeklappt mit „+N“ je Tag */
.wk-allday-toggle { grid-column: 1; grid-row: 1 / span var(--lanes, 1); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 1px; padding: 3px 0 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.wk-allday-toggle:hover { background: var(--surface-2); color: var(--ink); }
.wk-allday-toggle svg { flex: none; }
.seg.more { margin: 0 2px; height: 20px; line-height: 18px; padding: 0 6px; text-align: center; font-weight: 700; color: var(--ink); background: var(--surface-2); border: 1px dashed var(--muted); border-radius: 5px; cursor: pointer; }
.seg.more:hover { background: var(--accent-soft); border-color: var(--accent); }
@media (max-width: 860px) { .wk-allday-toggle .lbl { display: none; } }

/* ---------- Aktion läuft: Dialog gesperrt, Fortschritt sichtbar ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.modal-head { position: relative; }
dialog.is-busy, dialog.is-busy * { cursor: progress; }
dialog.is-busy .modal-body { opacity: .55; transition: opacity .15s; }
dialog.is-busy .modal-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent) no-repeat; background-size: 40% 100%; animation: slide 1s linear infinite; }
.btn.loading, .btn.loading:disabled { opacity: 1; }
.btn.loading::before { content: ""; width: 14px; height: 14px; margin-right: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; flex: none; }

/* Fußleiste im Termin-Dialog darf nie aus dem Bildschirm laufen: Speichern bleibt erreichbar */
.modal-foot { min-width: 0; }
.modal-foot .btn { flex: 0 0 auto; }
.btn.compact .lbl { margin-left: 6px; }
@media (max-width: 560px) {
  .modal-foot { gap: 6px; padding-left: 12px; padding-right: 12px; }
  .modal-foot .btn.compact .lbl, .modal-foot .btn.hide-narrow { display: none; }
  .modal-foot .btn.compact { padding-left: 12px; padding-right: 12px; }
  .modal-foot .btn.primary { min-width: 120px; }
}
