/* The calendar in the "Spike" admin's look (owner's pick, 2026-10-24): one card, the toolbar (today, arrows, the period,
   month / week / day), the kinds as chips, then the month grid or the hours. Own entries are solid pills in their
   colour; what the system knows is a soft pill with a coloured edge. Plus Jakarta Sans for figures, like the dashboard. */

.cal, #calEntryModal, #calInfoModal, #sdAgenda, #sdCal {
  --cal-accent: var(--ap-accent, #0085db);   /* the page's buttons: the user's own colour */
  --cal-blue: #0085db;   /* an entry's blue: fixed, so the six colours stay six whatever the accent */
  --cal-green: #13deb9;
  --cal-red: #fa896b;
  --cal-amber: #ffae1f;
  --cal-violet: #7d5fff;
  --cal-cyan: #16a2c8;
  --cal-line: var(--line);
  --cal-soft: color-mix(in srgb, var(--cal-accent) 9%, var(--panel));
  --cal-shadow: 0 2px 6px rgba(37, 83, 185, .1);
}
[data-theme="dark"] .cal, :root:not([data-theme="light"]) .cal { --cal-shadow: 0 2px 10px rgba(0, 0, 0, .28); --cal-soft: color-mix(in srgb, var(--cal-accent) 16%, transparent); }
[data-theme="light"] .cal { --cal-shadow: 0 2px 6px rgba(37, 83, 185, .1); }
.c-blue { --c: var(--cal-blue); } .c-green { --c: var(--cal-green); } .c-red { --c: var(--cal-red); }
.c-amber { --c: var(--cal-amber); } .c-violet { --c: var(--cal-violet); } .c-cyan { --c: var(--cal-cyan); }

.cal { container: cal / inline-size; font-family: "Plus Jakarta Sans", "Noto Sans Georgian", -apple-system, "Segoe UI", sans-serif; }
.cal-card { display: flex; flex-direction: column; gap: 16px; padding: 24px; border-radius: var(--ap-radius, 18px); background: var(--panel); box-shadow: var(--cal-shadow); color: var(--text); }

/* ---- toolbar ---- */
.cal-toolbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.cal-nav, .cal-right, .cal-views { display: flex; align-items: center; gap: 6px; }
.cal-right { justify-content: flex-end; gap: 12px; }
.cal-title { margin: 0; font-size: 20px; font-weight: 700; text-align: center; white-space: nowrap; }
.cal-btn { min-height: 36px; padding: 0 14px; border: 1px solid var(--cal-line); border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.cal-btn:hover { border-color: var(--cal-accent); color: var(--cal-accent); }
.cal-arrow { width: 36px; padding: 0; font-size: 20px; line-height: 1; }
.cal-views { gap: 0; }
.cal-views .cal-btn { border-radius: 0; margin-left: -1px; }
.cal-views .cal-btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.cal-views .cal-btn:last-child { border-radius: 0 8px 8px 0; }
.cal-views .cal-btn[aria-pressed="true"] { position: relative; border-color: var(--cal-accent); background: var(--cal-accent); color: #fff; }
.cal-add { min-height: 36px; white-space: nowrap; }

/* ---- the kinds: legend and filter in one ---- */
.cal-layers { display: flex; flex-wrap: wrap; gap: 8px; }
.cal-layer { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border: 1px solid var(--cal-line); border-radius: 999px; background: none; color: var(--text); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.cal-layer i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.cal-layer[aria-pressed="false"] { color: var(--muted); opacity: .6; }
.cal-layer[aria-pressed="false"] i { background: none; box-shadow: inset 0 0 0 2px var(--c); }

/* ---- an item: own (solid) or the system's (soft, coloured edge) ---- */
.cal-ev { display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0; padding: 3px 8px; border: 0; border-radius: 6px; font: inherit; font-size: 12px; font-weight: 600; line-height: 1.35; text-align: left; cursor: pointer; }
.cal-ev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev time { flex: none; font-variant-numeric: tabular-nums; opacity: .85; }
.cal-ev.is-own { background: var(--c); color: #fff; }
.cal-ev.is-sys { background: color-mix(in srgb, var(--c) 14%, transparent); box-shadow: inset 3px 0 0 var(--c); color: var(--text); }
.cal-ev.is-cont { border-top-left-radius: 0; border-bottom-left-radius: 0; opacity: .85; }
.cal-ev:hover { filter: brightness(1.06); }
.cal-ev:focus-visible, .cal-btn:focus-visible, .cal-layer:focus-visible { outline: 2px solid var(--cal-accent); outline-offset: 2px; }

/* ---- the month ---- */
.cal-month { border: 1px solid var(--cal-line); border-radius: 12px; overflow: hidden; }
.cal-week-head { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--panel); border-bottom: 1px solid var(--cal-line); }
.cal-week-head div { padding: 10px 8px; font-size: 13px; font-weight: 700; text-align: center; }
.cal-week-head .is-weekend { color: var(--cal-red); }
.cal-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(118px, auto); }
.cal-day { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 6px 6px 8px; border-right: 1px solid var(--cal-line); border-bottom: 1px solid var(--cal-line); cursor: pointer; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:nth-last-child(-n+7) { border-bottom: 0; }
.cal-day:hover { background: color-mix(in srgb, var(--cal-accent) 4%, transparent); }
.cal-day.is-out { background: color-mix(in srgb, var(--muted) 6%, transparent); }
.cal-day.is-out .cal-num { color: var(--muted); opacity: .6; }
.cal-day.is-today { background: var(--cal-soft); }
.cal-num { align-self: flex-end; min-width: 28px; height: 28px; padding: 0 6px; border: 0; border-radius: 999px; background: none; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.cal-num:hover { background: var(--panel-muted); }
.cal-day.is-weekend .cal-num, .cal-day.is-holiday .cal-num { color: var(--cal-red); }
.cal-day.is-today .cal-num { background: var(--cal-accent); color: #fff; }
.cal-more { align-self: flex-start; padding: 2px 6px; border: 0; background: none; color: var(--cal-accent); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.cal-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.cal-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* ---- the week / the day ---- */
.cal-grid { border: 1px solid var(--cal-line); border-radius: 12px; overflow: hidden; }
.cal-g-head, .cal-g-all, .cal-g-body { display: grid; grid-template-columns: 64px repeat(var(--cols), minmax(0, 1fr)); }
.cal-g-head { border-bottom: 1px solid var(--cal-line); background: var(--panel); }
.cal-g-day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 0; border-left: 1px solid var(--cal-line); background: none; color: var(--text); font: inherit; cursor: pointer; }
.cal-g-day small { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-g-day b { display: grid; place-items: center; min-width: 32px; height: 32px; border-radius: 999px; font-size: 16px; }
.cal-g-day.is-holiday b { color: var(--cal-red); }
.cal-g-day.is-today b { background: var(--cal-accent); color: #fff; }
.cal-g-all { border-bottom: 1px solid var(--cal-line); }
.cal-g-label { display: grid; place-items: center; padding: 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; }
.cal-g-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; min-height: 40px; padding: 5px; border-left: 1px solid var(--cal-line); cursor: pointer; }
.cal-scroll { max-height: min(640px, calc(100vh - 330px)); min-height: 280px; overflow-y: auto; }
.cal-g-body { position: relative; grid-template-rows: calc(24 * var(--hour)); }
.cal-g-hours { grid-row: 1; grid-column: 1 / -1; display: grid; grid-template-rows: repeat(24, var(--hour)); pointer-events: none; }
.cal-g-hour { border-top: 1px solid var(--cal-line); }
.cal-g-hour:first-child { border-top: 0; }
.cal-g-hour span { display: block; width: 64px; padding: 2px 8px 0 0; font-size: 11.5px; color: var(--muted); text-align: right; transform: translateY(-9px); }
.cal-g-hour:first-child span { transform: none; }
.cal-g-col { grid-row: 1; position: relative; border-left: 1px solid var(--cal-line); cursor: pointer; }
.cal-g-col:nth-child(2) { grid-column: 2; } .cal-g-col:nth-child(3) { grid-column: 3; } .cal-g-col:nth-child(4) { grid-column: 4; }
.cal-g-col:nth-child(5) { grid-column: 5; } .cal-g-col:nth-child(6) { grid-column: 6; } .cal-g-col:nth-child(7) { grid-column: 7; } .cal-g-col:nth-child(8) { grid-column: 8; }
.cal-g-col.is-today { background: color-mix(in srgb, var(--cal-accent) 4%, transparent); }
.cal-ev.is-timed { position: absolute; flex-direction: column; align-items: flex-start; gap: 0; padding: 4px 7px; overflow: hidden; }
.cal-ev.is-timed span { white-space: normal; }
.cal-now { position: absolute; left: 0; right: 0; z-index: 1; height: 2px; background: var(--cal-red); pointer-events: none; }
.cal-now::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--cal-red); }

/* ---- a list of days (a phone's week) and rows (also the dashboard) ---- */
.cal-agenda { display: grid; gap: 12px; }
.cal-a-day { padding: 12px; border: 1px solid var(--cal-line); border-radius: 12px; cursor: pointer; }
.cal-a-day.is-today { border-color: var(--cal-accent); background: var(--cal-soft); }
.cal-a-day h4, .sd-agenda-day h4 { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.cal-a-day h4 b { font-size: 20px; }
.sd-agenda-day h4 small { font-size: 12px; font-weight: 500; color: var(--muted); }
.cal-a-none { margin: 0; font-size: 12.5px; color: var(--muted); }
.cal-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; margin-top: 4px; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--c) 10%, transparent); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.cal-row i { flex: none; width: 4px; align-self: stretch; border-radius: 4px; background: var(--c); }
.cal-row span { display: flex; flex-direction: column; min-width: 0; }
.cal-row b { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-row small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-row:hover { background: color-mix(in srgb, var(--c) 16%, transparent); }

/* ---- the entry's window ---- */
.cal-colors { display: flex; gap: 10px; }
.cal-color { width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--c); cursor: pointer; }
.cal-color[aria-checked="true"] { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--c); }
.cal-color:disabled { cursor: default; opacity: .5; }
.cal-color[aria-checked="true"]:disabled { opacity: 1; }
.cal-check { display: inline-flex; align-items: center; gap: 8px; margin: 2px 0 12px; font-size: 13.5px; cursor: pointer; }
.cal-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; max-height: 220px; overflow-y: auto; }
.field .cal-person { margin: 0; color: var(--text); font-weight: 500; }
.field .cal-person, .cal-person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--cal-line); border-radius: 10px; cursor: pointer; }
.cal-person:has(input:checked) { border-color: var(--cal-accent); background: var(--cal-soft); }
.cal-person input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--cal-accent); }
.cal-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--cal-accent); }
.cal-person span { display: flex; flex-direction: column; min-width: 0; }
.cal-person b { font-size: 13px; }
.cal-person small { font-size: 11.5px; color: var(--muted); }

/* ---- the system item's window ---- */
.cal-info { display: grid; gap: 14px; justify-items: start; }
.cal-info p { margin: 0; line-height: 1.55; }
.cal-info-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.cal-info-nums div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--panel-muted); }
.cal-info-nums small { font-size: 12px; color: var(--muted); }
.cal-info-nums b { font-size: 20px; font-variant-numeric: tabular-nums; }
.cal-info-nums em { font-size: 12px; font-style: normal; color: var(--muted); }
.cal-info-list { display: grid; gap: 4px; width: 100%; max-height: 50vh; overflow-y: auto; }
.cal-info-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border: 0; border-radius: 10px; background: var(--panel-muted); color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.cal-info-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-info-row:hover { color: var(--cal-accent); }

/* ---- the dashboard's "today and tomorrow", beside the quick actions ---- */
/* the month at half the width; beside it "today and tomorrow" and the quick actions, one under the other */
#view-dashboard .sd-cal { grid-column: span 6; grid-row: span 2; display: flex; flex-direction: column; gap: 14px; padding: 20px 24px; min-width: 0; }
#view-dashboard .sd-cal-nav { display: flex; align-items: center; gap: 6px; }
#view-dashboard .sd-cal .cal-btn { min-height: 32px; padding: 0 12px; font-size: 13px; }
#view-dashboard .sd-cal .cal-arrow { width: 32px; padding: 0; font-size: 18px; }
#view-dashboard .sd-cal .cal-body { flex: 1; display: flex; flex-direction: column; }
#view-dashboard .sd-cal .cal-month { flex: 1; display: flex; flex-direction: column; }
#view-dashboard .sd-cal .cal-week-head { position: static; }
#view-dashboard .sd-cal .cal-week-head div { padding: 8px 4px; font-size: 12.5px; }
#view-dashboard .sd-cal .cal-days { flex: 1; grid-auto-rows: minmax(78px, 1fr); }
#view-dashboard .sd-cal .cal-day { gap: 2px; padding: 4px 4px 5px; }
#view-dashboard .sd-cal .cal-num { min-width: 24px; height: 24px; font-size: 12.5px; }
#view-dashboard .sd-cal .cal-ev { padding: 2px 6px; font-size: 11.5px; }
#view-dashboard .sd-cal .cal-more { padding: 0 6px; font-size: 11px; }
#view-dashboard .sd-agenda { grid-column: span 6; display: flex; flex-direction: column; gap: 14px; padding: 20px 24px; }
#view-dashboard .sd-agenda + .sd-quick { grid-column: span 6; }
#view-dashboard .sd-agenda-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 24px; align-items: start; }
#view-dashboard .sd-agenda-list > .empty-state, #view-dashboard .sd-agenda-add { grid-column: 1 / -1; }
#view-dashboard .sd-agenda-add { justify-self: start; display: inline-flex; align-items: center; gap: 6px; }
@container dash (max-width: 1180px) {
  #view-dashboard .sd-cal, #view-dashboard .sd-agenda, #view-dashboard .sd-agenda + .sd-quick { grid-column: 1 / -1; grid-row: auto; }
}

/* ---- smaller screens ---- */
@container cal (max-width: 900px) {
  .cal-toolbar { grid-template-columns: 1fr auto; }
  .cal-title { grid-column: 1 / -1; grid-row: 1; text-align: left; }
  .cal-days { grid-auto-rows: minmax(96px, auto); }
}
@container cal (max-width: 620px) {
  .cal-card { padding: 16px; gap: 12px; }
  .cal-title { font-size: 17px; }
  .cal-toolbar { grid-template-columns: 1fr; }
  .cal-right { justify-content: space-between; }
  .cal-layer { min-height: 30px; padding: 0 10px; font-size: 12px; }
  .cal-days { grid-auto-rows: minmax(58px, auto); }
  .cal-day { align-items: center; padding: 4px 2px; }
  .cal-num { align-self: center; }
  .cal-week-head div { padding: 8px 2px; font-size: 12px; }
  .cal-g-head, .cal-g-all, .cal-g-body { grid-template-columns: 48px repeat(var(--cols), minmax(0, 1fr)); }
  .cal-g-hour span { width: 48px; }
}
