:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --line: #e6e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #6366f1;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --danger: #dc2626;
  --today: #6366f1;
  --shadow: 0 1px 2px rgb(15 23 42 / .04), 0 8px 24px rgb(15 23 42 / .06);
  --radius: 14px;
  --hour: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d14;
    --surface: #141722;
    --surface-2: #1b1f2d;
    --line: #262b3b;
    --text: #e8eaf2;
    --muted: #8b93a8;
    --accent: #818cf8;
    --accent-ink: #0b0d14;
    --accent-soft: #1f2340;
    --danger: #f87171;
    --today: #818cf8;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 8px 14px; font-weight: 550; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.block { width: 100%; }
.btn.danger-text { border-color: transparent; background: none; color: var(--danger); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 0; background: none; font-size: 20px; line-height: 1;
  display: inline-grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0; }

input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.error { color: var(--danger); font-size: 14px; min-height: 0; margin: 6px 0 0; }
.error:empty { display: none; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 8px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
.logo {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: conic-gradient(from 210deg, #6366f1, #ec4899, #f59e0b, #10b981, #6366f1);
  box-shadow: inset 0 0 0 5px var(--surface);
  outline: 1px solid var(--line);
}

/* ---------- auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 26px; margin-top: 28px; }
.auth-card p.muted { margin: 6px 0 22px; }
.auth-card label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.auth-card label input { margin-top: 6px; color: var(--text); font-weight: 400; font-size: 15px; }
.auth-card .btn { padding: 11px; margin-top: 6px; }
.switch { text-align: center; margin: 18px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 264px 1fr; height: 100vh; height: 100dvh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line); padding: 18px 16px; display: flex; flex-direction: column; gap: 18px; overflow: auto;
}
.new-btn { padding: 11px; border-radius: 12px; box-shadow: 0 6px 16px -6px var(--accent); }
.plus { font-size: 18px; margin-right: 4px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: -8px; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.people li label { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
.people li label:hover { background: var(--surface-2); }
.people input { appearance: none; width: 18px; height: 18px; border-radius: 6px; border: 2px solid var(--c); margin: 0; padding: 0; flex: none; display: grid; place-items: center; }
.people input:checked { background: var(--c); }
.people input:checked::after { content: ""; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.people input:focus { box-shadow: none; }
.sidebar-foot { margin-top: auto; }
.me { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 8px; border-radius: 12px; text-align: left; }
.me:hover { background: var(--surface-2); }
.me small { display: block; color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.toolbar h2 { font-size: 20px; font-weight: 650; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; }
.menu-btn { display: none; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-weight: 550; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.view { flex: 1; min-height: 0; overflow: auto; touch-action: pan-y; overscroll-behavior: contain; }
.view.is-month { scroll-snap-type: y proximity; scroll-padding-top: 34px; }

/* ---------- mini month ---------- */
.mini-head { display: flex; align-items: center; justify-content: space-between; font-weight: 650; margin-bottom: 6px; padding-left: 4px; }
.mini-head .icon-btn { width: 28px; height: 28px; font-size: 16px; }
.mini-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; gap: 2px; }
.mini-grid .dow { color: var(--muted); font-weight: 600; padding: 4px 0; }
.mini-grid button { border: 0; background: none; aspect-ratio: 1; border-radius: 50%; padding: 0; font-size: 12px; position: relative; }
.mini-grid button:hover { background: var(--surface-2); }
.mini-grid button.out { color: var(--muted); opacity: .55; }
.mini-grid button.sel { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.mini-grid button.today { background: var(--today); color: #fff; font-weight: 700; }
.mini-grid button.has::after { content: ""; position: absolute; bottom: 3px; left: 50%; width: 3px; height: 3px; margin-left: -1.5px; border-radius: 50%; background: currentColor; opacity: .6; }

/* ---------- month view ---------- */
.month { display: block; }
.month-dow { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 3; }
.month-dow div { padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: var(--row, 100px); }
.month-grid .day:nth-child(7n+1) { scroll-snap-align: start; }
.day { transition: background-color .25s; }
.day.first .num { width: auto; padding: 0 8px; border-radius: 13px; background: var(--surface-2); color: var(--text); white-space: nowrap; }
.day.first.out .num { color: var(--muted); }
.day.today.first .num { background: var(--today); color: #fff; }
.day {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 3px; cursor: pointer; overflow: hidden; background: var(--surface);
}
.day:nth-child(7n) { border-right: 0; }
.day:hover { background: var(--surface-2); }
.day.out { background: var(--bg); }
.day.out .num { color: var(--muted); }
.day .num { font-size: 13px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; flex: none; }
.day.today .num { background: var(--today); color: #fff; }
.chip {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 2px 6px; border-radius: 6px; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 0; background: none; text-align: left; width: 100%;
}
.chip:hover { background: color-mix(in srgb, var(--c) 14%, transparent); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.chip .t { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.chip .n { overflow: hidden; text-overflow: ellipsis; }
.chip.allday { background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--text); font-weight: 550; }
.chip.allday .dot { display: none; }
.more { font-size: 12px; color: var(--muted); font-weight: 600; border: 0; background: none; text-align: left; padding: 2px 6px; }
.more:hover { color: var(--accent); }

/* ---------- week / day view ---------- */
.week-top { position: sticky; top: 0; z-index: 3; background: var(--surface); display: grid; grid-template-columns: 56px minmax(0, 1fr); border-bottom: 1px solid var(--line); overflow: hidden; }
.week-body { display: grid; grid-template-columns: 56px minmax(0, 1fr); padding-top: 8px; overflow: hidden; }
/* while swiping, days slide underneath the time labels */
.wh-corner, .ad-label { position: relative; z-index: 2; background: var(--surface); }
.wh-days, .ad-row, .cols { will-change: transform; width: 300%; margin-left: -100%; }
.wh-days { display: grid; grid-template-columns: repeat(var(--n), 1fr); border-bottom: 1px solid var(--line); }
.wh-corner { border-bottom: 1px solid var(--line); }
.wh-days button { border: 0; background: none; padding: 10px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; border-left: 1px solid var(--line); }
.wh-days .dname { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.wh-days .dnum { font-size: 20px; font-weight: 650; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; }
.wh-days .today .dnum { background: var(--today); color: #fff; }
.wh-days .today .dname { color: var(--today); }
.ad-label { font-size: 11px; color: var(--muted); padding: 12px 6px; text-align: right; }
.ad-row { display: grid; grid-template-columns: repeat(var(--n), 1fr); min-height: 46px; }
.ad-row .ad-cell { border-left: 1px solid var(--line); padding: 5px 4px; display: flex; flex-direction: column; gap: 4px; min-width: 0; cursor: pointer; }
.ad-row .chip { font-size: 13.5px; padding: 6px 8px; border-radius: 8px; min-height: 32px; }
.hours { position: relative; z-index: 2; background: var(--bg); }
.hours div { height: var(--hour); font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.hours div:first-child { visibility: hidden; }
.cols { display: grid; grid-template-columns: repeat(var(--n), 1fr); position: relative;
  background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% var(--hour); }
.col { position: relative; border-left: 1px solid var(--line); height: calc(var(--hour) * 24); cursor: pointer; }
.col.today { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.ev {
  position: absolute; border: 0; text-align: left; border-radius: 8px; padding: 4px 7px; overflow: hidden; font-size: 12.5px; line-height: 1.3;
  background: color-mix(in srgb, var(--c) 20%, var(--surface)); color: var(--text);
  border-left: 3px solid var(--c); box-shadow: 0 0 0 1px var(--surface);
}
.ev:hover { background: color-mix(in srgb, var(--c) 30%, var(--surface)); z-index: 2; }
.ev strong { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev span { color: var(--muted); font-size: 11.5px; }
.now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 1; pointer-events: none; }
.now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

/* ---------- dialogs ---------- */
dialog.sheet {
  border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgb(0 0 0 / .25);
}
dialog.sheet::backdrop { background: rgb(15 23 42 / .35); backdrop-filter: blur(3px); }
dialog.sheet[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.sheet form { padding: 18px 22px 20px; display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-head h3 { flex: 1; font-size: 20px; }
.title-input { font-size: 22px; font-weight: 650; border: 0; border-bottom: 2px solid var(--line); border-radius: 0; padding: 6px 0; letter-spacing: -0.01em; }
.title-input:focus { box-shadow: none; border-bottom-color: var(--accent); }
.field { display: grid; gap: 6px; }
.lbl { font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.when { display: grid; gap: 8px; }
.when-row { display: grid; grid-template-columns: 56px 1fr 120px; gap: 8px; align-items: center; }
.when-row input[type=time]:disabled { opacity: .35; }
.chips, .swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px 5px 6px; display: inline-flex; align-items: center; gap: 7px; font-size: 14px; }
.chips button .avatar { width: 22px; height: 22px; font-size: 11px; opacity: .45; }
.chips button.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); font-weight: 600; }
.chips button.on .avatar { opacity: 1; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--surface); outline: 2px solid transparent; background: var(--c); }
.swatches button.on { outline-color: var(--c); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.toggle { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 550; cursor: pointer; }
.toggle input { display: none; }
.toggle span { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgb(0 0 0 / .2); }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(16px); }
.sheet-foot { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; width: 100%; }
.invite { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite code { font-size: 18px; font-weight: 700; letter-spacing: .12em; background: var(--surface-2); padding: 6px 12px; border-radius: 8px; }
details summary { cursor: pointer; font-weight: 600; color: var(--muted); }
details[open] summary { margin-bottom: 12px; }
details .field { margin-bottom: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 550; font-size: 14px;
  transition: opacity .2s, transform .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.fab { display: none; }
.scrim { display: none; }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgb(0 0 0 / .3); z-index: 40; }
  .menu-btn { display: inline-grid; }
  .toolbar { padding: 10px 12px; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "menu title nav" "today seg seg"; gap: 8px 6px; }
  .menu-btn { grid-area: menu; }
  .toolbar h2 { grid-area: title; font-size: 18px; }
  .nav { grid-area: nav; }
  #today { grid-area: today; padding: 6px 12px; }
  .toolbar .seg { grid-area: seg; justify-self: end; }
  .ad-label { padding: 8px 2px; font-size: 10px; }
  .seg button { padding: 6px 9px; }
  .day { padding: 3px; }
  .day .num { width: 22px; height: 22px; font-size: 12px; }
  .month .chip { font-size: 11px; padding: 1px 3px; gap: 3px; }
  .month .chip .t { display: none; }
  .ad-row { min-height: 50px; }
  .ad-row .ad-cell { padding: 5px 2px; }
  .ad-row .chip { font-size: 13px; padding: 7px 6px; min-height: 36px; }
  /* 7 narrow columns: let titles wrap instead of shrinking to "Sc…" */
  .week-top.n7 .ad-row .chip { font-size: 11px; padding: 4px 3px; line-height: 1.2; white-space: normal; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
  .week-top.n7 .ad-row .chip .n { overflow: visible; }
  .week-top.n7 .chip.s-ooo .n::before { content: none; }
  .week-top, .week-body { grid-template-columns: 44px minmax(0, 1fr); }
  .wh-days .dnum { font-size: 16px; width: 30px; height: 30px; }
  .fab {
    display: grid; place-items: center; position: absolute; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
    width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-ink);
    font-size: 28px; box-shadow: 0 10px 24px -6px var(--accent); z-index: 10;
  }
  .when-row { grid-template-columns: 1fr 110px; }
  .when-row .lbl { grid-column: 1 / -1; }
}

/* ---------- "show as" status: busy / tentative / out of office / free ---------- */
:root { --ooo: #a855f7; }
/* Busy is the default solid tint (see .ev / .chip.allday). */
.s-tentative.ev, .s-tentative.chip.allday {
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--c) 30%, var(--surface)) 0 5px,
    color-mix(in srgb, var(--c) 8%, var(--surface)) 5px 10px);
}
.s-tentative.ev { border-left-style: dashed; }
.s-ooo.ev, .s-ooo.chip.allday {
  background-color: color-mix(in srgb, var(--ooo) 12%, var(--surface));
  background-image:
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--ooo) 24%, transparent) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--ooo) 24%, transparent) 0 1px, transparent 1px 7px);
  border-left-color: var(--ooo);
}
.s-ooo.chip.allday { box-shadow: inset 3px 0 0 var(--ooo); }
.s-free.ev, .s-free.chip.allday {
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 55%, transparent);
  border-left-style: dotted;
}
.s-free.ev strong, .s-free.chip.allday .n { font-weight: 500; color: var(--muted); }
.s-free.chip.allday { border: 1.5px dashed color-mix(in srgb, var(--c) 60%, transparent); box-shadow: none; padding: 1px 5px; }
.ev:hover, .chip.allday:hover { filter: brightness(0.97); }

/* status markers for timed chips in month view */
.chip.s-tentative .dot { background: linear-gradient(90deg, var(--c) 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px var(--c); }
.chip.s-free .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
.chip.s-ooo .dot { border-radius: 2px; background: var(--ooo); }
.chip.s-ooo .n::before { content: "Away · "; color: var(--ooo); font-weight: 700; }

.badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 0 5px; border-radius: 4px; margin-right: 4px; vertical-align: 1px; }
.badge.ooo { background: var(--ooo); color: #fff; }
.badge.tentative { background: color-mix(in srgb, var(--c) 25%, var(--surface)); color: var(--text); }
.badge.free { border: 1px solid var(--line); color: var(--muted); }

/* picker in the event dialog + legend in the sidebar */
.showas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.showas button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 13px; font-weight: 550; }
.showas button.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.swatch { width: 100%; height: 14px; border-radius: 4px; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 20%, var(--surface)); }
.swatch.s-tentative { border-left-style: dashed; background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 30%, var(--surface)) 0 4px, color-mix(in srgb, var(--c) 8%, var(--surface)) 4px 8px); }
.swatch.s-ooo { border-left-color: var(--ooo); background-color: color-mix(in srgb, var(--ooo) 12%, var(--surface));
  background-image: repeating-linear-gradient(45deg, color-mix(in srgb, var(--ooo) 35%, transparent) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--ooo) 35%, transparent) 0 1px, transparent 1px 5px); }
.swatch.s-free { background: var(--surface); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 55%, transparent); border-left-style: dotted; }
.legend { list-style: none; margin: 0; padding: 0 8px; display: grid; gap: 7px; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 10px; }
.legend .swatch { width: 26px; height: 12px; flex: none; }
@media (max-width: 820px) { .showas button { font-size: 12px; padding: 6px 4px; } }

/* ---------- brand ---------- */
.zeit { color: var(--accent); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text #family-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-text small { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }

/* ---------- all-day events colour the whole day ---------- */
.dayfill { position: absolute; top: 0; bottom: 0; pointer-events: none; z-index: 0;
  background: color-mix(in srgb, var(--c) 13%, transparent); }
.dayfill.s-tentative { background: repeating-linear-gradient(135deg,
  color-mix(in srgb, var(--c) 16%, transparent) 0 8px, color-mix(in srgb, var(--c) 4%, transparent) 8px 16px); }
.dayfill.s-ooo { background-color: color-mix(in srgb, var(--ooo) 10%, transparent);
  background-image:
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--ooo) 20%, transparent) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--ooo) 20%, transparent) 0 1px, transparent 1px 9px); }
.dayfill.s-free { background: none; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c) 30%, transparent); }
.col .ev, .col .now { z-index: 1; }

/* month view: tint the whole day cell */
.day.tinted { background: color-mix(in srgb, var(--c) 11%, var(--surface)); }
.day.tinted:hover { background: color-mix(in srgb, var(--c) 17%, var(--surface)); }
.day.tinted.s-tentative { background: repeating-linear-gradient(135deg,
  color-mix(in srgb, var(--c) 13%, var(--surface)) 0 8px, var(--surface) 8px 16px); }
.day.tinted.s-ooo { background-color: color-mix(in srgb, var(--ooo) 8%, var(--surface));
  background-image:
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--ooo) 18%, transparent) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--ooo) 18%, transparent) 0 1px, transparent 1px 9px); }

/* month view: part-day "Out of office" shown as a mesh band at its time of day */
.month-grid .day { position: relative; }
.month-grid .day > :not(.ooo-band) { position: relative; z-index: 1; }
.ooo-band { position: absolute; left: 0; right: 0; z-index: 0; pointer-events: none;
  background-color: color-mix(in srgb, var(--ooo) 12%, transparent);
  background-image:
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--ooo) 30%, transparent) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--ooo) 30%, transparent) 0 1px, transparent 1px 7px);
  box-shadow: inset 3px 0 0 var(--ooo); }

/* month cells: never squash event labels; overflow is summarised by "+N more" */
.month-grid .day > .chip, .month-grid .day > .more { flex-shrink: 0; }
.more { white-space: nowrap; }

/* ---------- small helpers ---------- */
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.link.small, .small { font-size: 13px; }
.lbl-row { display: flex; align-items: center; justify-content: space-between; }
a.btn { display: inline-block; text-align: center; text-decoration: none; color: inherit; }
a.btn.primary { color: var(--accent-ink); }

/* ---------- invitations ---------- */
.chip.pending, .ev.pending { outline: 2px dashed color-mix(in srgb, var(--c) 70%, transparent); outline-offset: -2px; opacity: .85; }
.badge.invite { background: var(--accent); color: var(--accent-ink); }
.attendees { display: flex; flex-wrap: wrap; gap: 6px; }
.att { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); }
.att b { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: #fff; background: var(--muted); }
.att.accepted b { background: #10b981; }
.att.declined b { background: var(--danger); }
.att.declined { text-decoration: line-through; color: var(--muted); }
.rsvp-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 14px; font-weight: 550; }
.rsvp-bar.accepted { background: color-mix(in srgb, #10b981 14%, var(--surface)); }
.rsvp-bar.declined { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.rsvp-btns { display: inline-flex; gap: 6px; }
.invites { padding: 10px 20px; background: var(--accent-soft); border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.invites-title { font-weight: 650; font-size: 14px; }
.invite-item { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 8px 10px;
  border-left: 4px solid var(--c); flex-wrap: wrap; }
.invite-what { flex: 1; min-width: 160px; border: 0; background: none; text-align: left; padding: 0; display: flex; flex-direction: column; }
.invite-what span { color: var(--muted); font-size: 13px; }

/* ---------- accept / decline page ---------- */
.rsvp-card h1 { margin-top: 10px; }
.rsvp-from { margin: 24px 0 0 !important; }
.rsvp-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 18px 0; font-size: 15px; }
.rsvp-dl dt { color: var(--muted); font-weight: 600; }
.rsvp-dl dd { margin: 0; }
.rsvp-notes { white-space: pre-wrap; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.rsvp-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.rsvp-actions .btn { padding: 12px; }
.rsvp-done { padding: 12px; border-radius: 12px; font-weight: 600; margin: 14px 0 6px; }
.rsvp-done.accepted { background: color-mix(in srgb, #10b981 15%, var(--surface)); }
.rsvp-done.declined { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.rsvp-open { display: block; text-align: center; margin-top: 18px; text-decoration: none; color: var(--accent); font-weight: 600; }

/* ---------- schedule assistant ---------- */
.plan { padding: 16px 20px 28px; display: grid; gap: 14px; }
.plan-controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.plan-dur { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; color: var(--muted); }
.plan-dur select { width: auto; padding: 6px 10px; }
.plan-suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.plan-suggest .lbl { margin-right: 4px; }
.sugg { border: 1px solid color-mix(in srgb, #10b981 45%, var(--line)); background: color-mix(in srgb, #10b981 10%, var(--surface));
  border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; }
.sugg:hover { background: color-mix(in srgb, #10b981 20%, var(--surface)); }
.plan-grid { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px 10px; overflow: hidden; }
.plan-row { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 10px; }
.plan-name { display: flex; align-items: center; gap: 8px; font-size: 14px; min-width: 0; }
.plan-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-name .avatar { width: 26px; height: 26px; font-size: 11px; }
.plan-name.strong { font-weight: 700; }
.plan-track { position: relative; height: 40px; margin: 4px 0; border-radius: 8px; cursor: crosshair; touch-action: pan-y;
  background-color: var(--bg);
  background-image: linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: calc(100% / var(--hours)) 100%; }
.plan-track.everyone { height: 30px; margin-bottom: 10px; }
.plan-track.bare { background: none; height: 22px; cursor: default; margin: 0; }
.hlabel { position: absolute; top: 3px; font-size: 11px; color: var(--muted); transform: translateX(-2px); white-space: nowrap; }
.pseg { position: absolute; top: 0; bottom: 0; pointer-events: none; }
.pseg.free-all { background: color-mix(in srgb, #10b981 26%, transparent); }
.pseg.busy-some { background: color-mix(in srgb, #f59e0b calc(20% + var(--k) * 40%), transparent); }
.pseg.busy-all { background: color-mix(in srgb, #ef4444 45%, transparent); }
.pblock { position: absolute; top: 4px; bottom: 4px; border: 0; pointer-events: none; border-radius: 6px; padding: 0 6px; overflow: hidden; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--c) 35%, var(--surface)); border-left: 3px solid var(--c); }
.pblock span { overflow: hidden; text-overflow: ellipsis; display: block; line-height: 32px; }
.pblock.s-tentative { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c) 38%, var(--surface)) 0 5px, color-mix(in srgb, var(--c) 10%, var(--surface)) 5px 10px); border-left-style: dashed; }
.pblock.s-ooo { background-color: color-mix(in srgb, var(--ooo) 16%, var(--surface));
  background-image: repeating-linear-gradient(45deg, color-mix(in srgb, var(--ooo) 35%, transparent) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--ooo) 35%, transparent) 0 1px, transparent 1px 6px);
  border-left-color: var(--ooo); }
.pblock.s-free { background: transparent; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--c) 50%, transparent); color: var(--muted); font-weight: 500; }
.pblock.pending { outline: 2px dashed color-mix(in srgb, var(--c) 70%, transparent); outline-offset: -2px; }
.plan-sel { position: absolute; top: -2px; bottom: -2px; border: 2px solid var(--accent); border-radius: 6px; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 14%, transparent); z-index: 2; }
.plan-now { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--danger); pointer-events: none; z-index: 3; }
.plan-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; align-items: center; }
.plan-legend span { display: inline-flex; align-items: center; gap: 6px; }
.plan-legend i { width: 18px; height: 12px; border-radius: 3px; display: inline-block; }
.plan-legend .free-all { background: color-mix(in srgb, #10b981 35%, transparent); }
.plan-legend .busy-some { background: color-mix(in srgb, #f59e0b 45%, transparent); }
.plan-legend .busy-all { background: color-mix(in srgb, #ef4444 45%, transparent); }
.plan-action { position: sticky; bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid #10b981; border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.plan-action.warn { border-left-color: #f59e0b; }
.plan-action div { display: flex; flex-direction: column; }
.plan-action span { color: var(--muted); font-size: 13px; }
@media (max-width: 820px) {
  .plan { padding: 12px 10px 90px; }
  .plan-row { grid-template-columns: 62px minmax(0, 1fr); gap: 6px; }
  .plan-name { font-size: 12px; gap: 4px; }
  .plan-name .avatar { width: 22px; height: 22px; font-size: 10px; }
  .plan-name:not(.strong) span:last-child { display: none; }
  .pblock { font-size: 10px; padding: 0 3px; }
  .invites { padding: 8px 10px; }
  .seg button { padding: 6px 7px; font-size: 14px; }
  .sugg { font-size: 12px; padding: 4px 10px; }
  .plan-suggest .lbl { flex-basis: 100%; }
}

/* ---------- WhatsApp invitations ---------- */
.invite-via { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: 28px; }
.seg.mini { padding: 2px; }
.seg.mini button { padding: 4px 10px; font-size: 13px; }
.btn.wa { background: #25d366; border-color: #25d366; color: #0b3d1f; display: inline-flex; align-items: center; gap: 6px; font-weight: 650; }
.btn.wa:hover { filter: brightness(1.05); background: #25d366; }
.share { padding: 18px 22px 20px; display: grid; gap: 12px; }
.share-list { display: grid; gap: 8px; }
.share-row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.share-row .avatar { width: 32px; height: 32px; font-size: 12px; }
.share-who { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
.share-who span { color: var(--muted); font-size: 13px; }
.share-btns { display: inline-flex; gap: 6px; }
.btn.share-native { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; }
.btn.wa-outline { display: inline-flex; align-items: center; gap: 6px; border-color: #25d366; color: #128c4a; font-weight: 650; }
