/* ============================================================================
   Betreuungskalender — responsive-first UI
   Warm & friendly: Varela Round (display) + Nunito Sans (body), warm off-white,
   soft rounded pill controls. Identity colours come from server config at runtime
   and are injected as CSS variables (--c-<id> / --band-<id>) by app.js.
   Mobile-first: base styles target phones; wider layouts are added with min-width.
   ========================================================================== */

:root {
  /* Warm neutral surface palette */
  --bg:        #fbf8f3;
  --surface:   #ffffff;
  --surface-2: #f4eee4;
  --ink:       #2e2a24;
  --ink-soft:  #6f675b;
  --ink-faint: #9b9388;
  --line:      #e7ded0;
  --line-soft: #f0e9dc;
  --danger:    #c0492f;
  --ok:        #2f8a6d;

  --accent:      #e0911f;   /* warm amber as the neutral app accent */
  --accent-ink:  #5e3c08;
  --accent-soft: #fbf0db;

  --shadow-sm: 0 1px 2px rgba(75, 60, 35, .06), 0 2px 6px rgba(75, 60, 35, .05);
  --shadow-md: 0 4px 14px rgba(75, 60, 35, .10), 0 2px 4px rgba(75, 60, 35, .06);
  --shadow-lg: 0 14px 40px rgba(60, 45, 25, .18);

  --r-sm: 9px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --tap: 44px;
  --maxw: 1280px;

  --ease: cubic-bezier(.2, .7, .3, 1);
  --t-fast: 140ms;
  --t-mid: 220ms;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Nunito Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, .brand-name, .login-title, .seg, .btn-pill, .month-sep {
  font-family: 'Varela Round', 'Nunito Sans', system-ui, sans-serif;
  font-weight: 400;
  letter-spacing: .01em;
}

[hidden] { display: none !important; }
button { font-family: inherit; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 65%, white);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------------------------------------------------------------- Buttons -- */
.btn {
  --bg-btn: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: var(--bg-btn);
  color: var(--ink);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  --bg-btn: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }

.btn-ghost {
  --bg-btn: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-pill {
  --bg-btn: var(--surface);
  border-color: var(--line);
  padding: 0 18px;
  box-shadow: var(--shadow-sm);
}
.btn-pill:hover { background: var(--surface-2); }

.btn-icon {
  --bg-btn: var(--surface);
  width: var(--tap);
  min-width: var(--tap);
  padding: 0;
  border-color: var(--line);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }

.btn-block { width: 100%; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); background: var(--surface); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, white); }

.btn .spinner { display: none; }
.btn.is-busy .btn-label { visibility: hidden; }
.btn.is-busy .spinner { display: inline-block; position: absolute; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* edit mode active */
.btn-edit.is-on {
  --bg-btn: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ---------------------------------------------------------------- Spinner -- */
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-lg { width: 30px; height: 30px; border-width: 3px; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================ LOGIN ===== */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px max(16px, env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 80% at 50% -10%, #fff 0%, transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 30px 26px 26px;
  text-align: center;
}
.login-mark {
  width: 60px; height: 60px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  color: #fff;
  background: var(--accent);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}
.login-title { margin: 0 0 4px; font-size: 1.55rem; }
.login-sub { margin: 0 0 22px; color: var(--ink-soft); font-size: .92rem; }

.field { display: block; text-align: left; margin-bottom: 14px; }
.field-label { display: block; font-size: .82rem; font-weight: 700; color: var(--ink-soft); margin: 0 2px 6px; }
.pw-wrap { position: relative; display: block; }
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 46px 0 16px;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--r-pill);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.input:focus { outline: none; border-color: var(--accent); background: #fff; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--ink-faint); cursor: pointer; border-radius: 50%;
}
.pw-toggle:hover { color: var(--ink-soft); }
.pw-toggle.is-on { color: var(--accent); }

.login-msg {
  margin: 0 0 14px;
  padding: 10px 14px;
  font-size: .88rem;
  font-weight: 700;
  border-radius: var(--r-md);
  text-align: left;
}
.login-msg.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, white); border: 1px solid color-mix(in srgb, var(--danger) 25%, white); }
.login-msg.warn { color: var(--accent-ink); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, white); }

/* ============================================================ APP SHELL = */
.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
  padding: 8px max(12px, env(safe-area-inset-left)) 8px max(12px, env(safe-area-inset-right));
  padding-top: max(8px, env(safe-area-inset-top));
}
.topbar-row {
  display: flex; align-items: center; gap: 10px;
  max-width: var(--maxw); margin: 0 auto;
}
.topbar-row + .topbar-row { margin-top: 8px; }

.brand { display: flex; align-items: center; gap: 9px; margin-right: auto; min-width: 0; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 11px; flex: none; }
.brand-name { font-size: 1.12rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }
.me {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 13px 0 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm);
}
.me-dot { width: 13px; height: 13px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px #fff inset; }
.me-name { font-weight: 800; font-size: .9rem; white-space: nowrap; }
.btn-edit .btn-label { display: none; }

.nav-row { justify-content: space-between; flex-wrap: wrap; }
.nav-window { display: flex; align-items: center; gap: 7px; min-width: 0; }
.range { font-size: .9rem; font-weight: 700; color: var(--ink-soft); margin-left: 4px; white-space: nowrap; }

.view-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: var(--r-pill); border: 1px solid var(--line-soft);
}
.seg {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 16px;
  border: 0; background: transparent; color: var(--ink-soft);
  border-radius: var(--r-pill); cursor: pointer; font-size: .92rem;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg-badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center;
  font-size: .72rem; font-weight: 800; font-family: 'Nunito Sans', sans-serif;
  color: #fff; background: var(--accent); border-radius: var(--r-pill);
}

/* ------------------------------------------------------------- Legend ---- */
.legend {
  display: flex; flex-wrap: wrap; gap: 8px;
  max-width: var(--maxw); margin: 0 auto; width: 100%;
  padding: 12px max(12px, env(safe-area-inset-left));
}
.legend-group { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.legend-sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.legend-hint { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--ink-soft); padding: 4px 4px; }
.legend-band { width: 22px; height: 14px; border-radius: 5px; border: 1px solid var(--line); }
.legend-dash { width: 16px; height: 0; border-top: 2px dashed var(--ink-faint); }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 36px; padding: 0 13px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-pill);
  font-weight: 700; font-size: .85rem; color: var(--ink); cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.chip .swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.chip .band-sw { width: 20px; height: 13px; border-radius: 4px; border: 1.5px solid; flex: none; }
.chip.child { border-color: color-mix(in srgb, var(--chip-c) 45%, var(--line)); }
.chip.is-off { opacity: .42; background: var(--surface-2); }
.chip.is-off .swatch { background: var(--ink-faint) !important; }
.chip .chip-strike { text-decoration: none; }
.chip.is-off .chip-name { text-decoration: line-through; }

/* ============================================================ LAYOUT ==== */
.layout {
  flex: 1; width: 100%;
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 max(12px, env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom));
  display: block;
}
.cal-pane { min-width: 0; }
.weekday-head { display: none; }

/* ----- mobile view switching: one pane visible at a time ----- */
.app[data-view="cal"]   .notes-pane { display: none; }
.app[data-view="notes"] .cal-pane   { display: none; }

/* =========================================================== CALENDAR === */
.calendar { display: flex; flex-direction: column; gap: 10px; }

.month-sep {
  position: sticky; top: 0; z-index: 5;
  margin: 8px 0 2px;
  padding: 7px 14px;
  font-size: .95rem; color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, white);
  border-radius: var(--r-pill);
  align-self: flex-start;
}

.week {
  display: grid;
  grid-template-columns: 1fr;   /* phone: one day per row (legible timelines) */
  gap: 8px;
}

/* ------------------------------------------------------------- Day cell -- */
.day {
  position: relative;
  display: flex;               /* phone: date column + timeline */
  gap: 12px;
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.day:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: var(--shadow-md); }
.day:active { transform: scale(.995); }
.day.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm); }
.day.is-out { opacity: .55; }
/* hidden by the parent filter — keep the slot (grid + bar alignment) but blank it out */
.day.is-filtered { opacity: .34; box-shadow: none; background: var(--surface-2); }
.day.is-filtered .tl, .day.is-filtered .dots { visibility: hidden; }
.day.is-filtered:hover { border-color: var(--line); box-shadow: none; }

.day-head {
  display: flex; align-items: baseline; gap: 8px;
  flex: none; width: 92px;
}
.day-wd { font-size: .78rem; font-weight: 800; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; }
.day-num { font-family: 'Varela Round', sans-serif; font-size: 1.45rem; line-height: 1; color: var(--ink); }
.day.is-today .day-num { color: var(--accent); }
.day-mtag { font-size: .72rem; font-weight: 800; color: var(--accent-ink); }

.dots { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; }
.dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 1.5px #fff; }
.dot-more { font-size: .68rem; font-weight: 800; color: var(--ink-faint); margin-left: 1px; }

/* ----------------------------------------------------------- Timeline ---- */
.tl { flex: 1; min-width: 0; }
/* Fixed height (room for 2 stacked label rows) so every day's body starts at the
   same y and the bars line up across the grid, regardless of handover labels. */
.tl-times { position: relative; height: 2rem; margin-bottom: 2px; }
.tl-time {
  position: absolute; top: 0;
  font-size: .62rem; font-weight: 800; line-height: 1;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  padding: 1px 2px; border-radius: 3px;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tl-body {
  position: relative;
  height: 58px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.tl-band { position: absolute; left: 0; right: 0; height: 50%; }
.tl-band.top { top: 0; }
.tl-band.bot { bottom: 0; }
.tl-mid { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: color-mix(in srgb, var(--ink) 8%, transparent); }

.tl-pname {
  position: absolute; left: 6px;
  font-size: .58rem; font-weight: 800; letter-spacing: .03em;
  color: color-mix(in srgb, var(--pn-c) 75%, var(--ink));
  opacity: .65; text-transform: uppercase; pointer-events: none;
}
.tl-pname.top { top: 3px; }
.tl-pname.bot { bottom: 3px; }

.tl-handover {
  position: absolute; top: 0; bottom: 0; width: 0;
  border-left: 1.5px dashed color-mix(in srgb, var(--ink) 45%, transparent);
  pointer-events: none;
}
.tl-seg { position: absolute; height: 4px; border-radius: 3px; }
.tl-step { position: absolute; width: 4px; border-radius: 3px; }
.tl-badge {
  position: absolute;
  width: 17px; height: 17px; margin: -8.5px 0 0 -2px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff; font-size: .62rem; font-weight: 800;
  box-shadow: 0 0 0 2px #fff;
  font-family: 'Nunito Sans', sans-serif;
}

/* edit mode: flippable badges */
.app.is-editing .day { cursor: default; }
.app.is-editing .day .tl-body { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 40%, transparent); }
.tl-badge.editable { cursor: pointer; box-shadow: 0 0 0 2px #fff, 0 0 0 4px color-mix(in srgb, var(--accent) 55%, transparent); }
.tl-badge.editable:hover { transform: scale(1.12); }
.tl-badge.editable:active { transform: scale(.95); }

/* ============================================================ NOTES ===== */
.notes-pane { min-width: 0; }
.notes-head { display: none; }
.feed { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }

.feed-day {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.feed-day:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: var(--shadow-md); }
.feed-day.in-window { border-left: 4px solid var(--accent); }
.feed-date { font-size: .82rem; font-weight: 800; color: var(--ink-soft); margin-bottom: 8px; }
.note { display: flex; gap: 9px; padding: 5px 0; }
.note + .note { border-top: 1px solid var(--line-soft); }
.note-av { width: 24px; height: 24px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: .72rem; font-weight: 800; box-shadow: 0 0 0 2px #fff; }
.note-main { min-width: 0; flex: 1; }
.note-meta { display: flex; align-items: baseline; gap: 8px; }
.note-author { font-weight: 800; font-size: .86rem; }
.note-time { font-size: .72rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.note-text { font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 1px; }
.note-del {
  flex: none; align-self: flex-start; margin-left: 4px;
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--ink-faint);
  border-radius: 50%; cursor: pointer;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.note-del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

.empty { text-align: center; color: var(--ink-faint); padding: 48px 20px; }
.empty svg { color: var(--line); margin-bottom: 10px; }
.empty-title { font-weight: 800; color: var(--ink-soft); }

/* ============================================================ SHEET ===== */
.sheet-root { position: fixed; inset: 0; z-index: 100; display: flex; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(40, 30, 15, .45); animation: fade var(--t-mid) var(--ease); }
.sheet {
  position: relative; margin-top: auto;
  width: 100%; max-height: 92dvh;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slide-up var(--t-mid) var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-grab { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 9px auto 2px; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 6px 16px 10px; border-bottom: 1px solid var(--line-soft); }
.sheet-title { margin: 0; margin-right: auto; font-size: 1.12rem; }
.sheet-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }

/* ----- custody block in sheet ----- */
.cust { margin-bottom: 18px; }
.cust-child { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.cust-av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .78rem; flex: none; }
.cust-name { font-weight: 800; }
.cust-tag { font-size: .72rem; font-weight: 800; color: var(--accent-ink); background: var(--accent-soft); padding: 2px 8px; border-radius: var(--r-pill); }
.cust-summary { font-size: .95rem; color: var(--ink); padding: 8px 12px; background: var(--surface-2); border-radius: var(--r-md); }
.cust-summary .seg-parent { font-weight: 800; }

/* editor */
.edit-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.edit-label { font-size: .82rem; font-weight: 700; color: var(--ink-soft); }
.sel, .time-in {
  min-height: var(--tap); padding: 0 12px; font-size: 1rem; font-family: inherit;
  color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--r-md);
}
.time-in { width: 116px; }
.ho-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.ho-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px; background: var(--surface-2); border-radius: var(--r-md); }
.ho-item .arrow { color: var(--ink-faint); }
.edit-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* ----- comments in sheet ----- */
.thread { margin-top: 6px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.thread-title { font-size: .82rem; font-weight: 800; color: var(--ink-soft); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .03em; }
.thread-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.add-note { display: flex; gap: 8px; align-items: flex-end; }
.add-note textarea {
  flex: 1; min-height: 44px; max-height: 140px; padding: 11px 14px;
  font-family: inherit; font-size: 1rem; color: var(--ink);
  background: var(--bg); border: 1.5px solid var(--line); border-radius: var(--r-md); resize: vertical;
}
.add-note textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.send-btn { width: var(--tap); min-width: var(--tap); height: var(--tap); flex: none; border-radius: 50%; background: var(--accent); color: #fff; border: 0; display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow-sm); }
.send-btn:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.send-btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ============================================================ MISC ====== */
.loading { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; gap: 12px; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(2px); grid-auto-flow: row; }
.loading-text { font-weight: 700; color: var(--ink-soft); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 120; max-width: min(92vw, 440px);
  padding: 12px 18px; border-radius: var(--r-pill);
  background: var(--ink); color: #fff; font-weight: 700; font-size: .9rem;
  box-shadow: var(--shadow-lg); animation: pop var(--t-mid) var(--ease);
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ====================================================== RESPONSIVE ===== */

/* Tablet+ : show both nav and a roomier legend */
@media (min-width: 600px) {
  .btn-edit .btn-label { display: inline; }
  .brand-name { font-size: 1.25rem; }
}

/* Calendar grid kicks in: 7 columns, classic month view.
   The Kalender/Notizen toggle stays available here (single column) until the
   side-by-side layout takes over at >=1000px. */
@media (min-width: 760px) {
  .weekday-head {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px;
    padding: 4px 2px 6px; position: sticky; top: 0; z-index: 6;
  }
  .weekday-head span { text-align: center; font-size: .78rem; font-weight: 800; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }

  .week { grid-template-columns: repeat(7, 1fr); gap: 8px; }
  .month-sep { position: static; }

  .day {
    flex-direction: column;
    gap: 7px;
    padding: 9px;
    aspect-ratio: auto;
    min-height: 124px;
  }
  .day-head { width: auto; flex-wrap: wrap; align-items: center; }
  .day-wd { display: none; }                 /* weekday shown in header row */
  .day-num { font-size: 1.15rem; }
  .tl-time { font-size: .58rem; }
  .tl-body { height: 52px; }
  .tl-pname { display: none; }
}

/* Desktop: calendar + notes side by side (both panes always visible) */
@media (min-width: 1000px) {
  .view-switch { display: none; }
  .app[data-view] .cal-pane { display: block; }     /* overrides the mobile pane-hiding */
  .app[data-view] .notes-pane { display: flex; }

  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
  .notes-pane {
    position: sticky; top: 132px;
    max-height: calc(100dvh - 150px);
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm); overflow: hidden;
  }
  .notes-head { display: block; padding: 14px 16px 6px; }
  .notes-title { margin: 0; font-size: 1.05rem; }
  .feed { overflow-y: auto; padding: 8px 14px 16px; }
  .feed-day { box-shadow: none; }
  .sheet-root { place-items: center; padding: 24px; }
  .sheet {
    margin: auto; max-width: 540px; max-height: 86dvh;
    border-radius: var(--r-lg);
    animation: pop var(--t-mid) var(--ease);
  }
  .sheet-grab { display: none; }
}

/* ====================================================== A11Y / MOTION = */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .btn:active, .day:active, .tl-badge.editable:active { transform: none; }
}
