/* Team calendar. Person colours come from a fixed palette of eight (cal-p0 to
   cal-p7), picked by user id, with a tint for the chip background and a solid
   for the bar and dot. Red is kept for overdue. */
.cal-p0 { --pc: #1E4FBF; --pcbg: #E6EEFB; }
.cal-p1 { --pc: #0F766E; --pcbg: #DDF3F0; }
.cal-p2 { --pc: #6D3FC4; --pcbg: #EFEAFB; }
.cal-p3 { --pc: #B45309; --pcbg: #FDEBD3; }
.cal-p4 { --pc: #BE185D; --pcbg: #FCE7F1; }
.cal-p5 { --pc: #3F7D1E; --pcbg: #E8F3DC; }
.cal-p6 { --pc: #0E7490; --pcbg: #DCF1F7; }
.cal-p7 { --pc: #7C4A21; --pcbg: #F1E6DC; }
:root[data-theme="dark"] .cal-p0 { --pc: #8FB0F0; --pcbg: #16264D; }
:root[data-theme="dark"] .cal-p1 { --pc: #5EEAD4; --pcbg: #0F3330; }
:root[data-theme="dark"] .cal-p2 { --pc: #C4B0FF; --pcbg: #2A1F52; }
:root[data-theme="dark"] .cal-p3 { --pc: #F5B25E; --pcbg: #3A2A0A; }
:root[data-theme="dark"] .cal-p4 { --pc: #F9A8D4; --pcbg: #43142D; }
:root[data-theme="dark"] .cal-p5 { --pc: #A3E07A; --pcbg: #1C3310; }
:root[data-theme="dark"] .cal-p6 { --pc: #7DD3EA; --pcbg: #0C3340; }
:root[data-theme="dark"] .cal-p7 { --pc: #E0B48C; --pcbg: #3A2616; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cal-p0 { --pc: #8FB0F0; --pcbg: #16264D; }
  :root:not([data-theme="light"]) .cal-p1 { --pc: #5EEAD4; --pcbg: #0F3330; }
  :root:not([data-theme="light"]) .cal-p2 { --pc: #C4B0FF; --pcbg: #2A1F52; }
  :root:not([data-theme="light"]) .cal-p3 { --pc: #F5B25E; --pcbg: #3A2A0A; }
  :root:not([data-theme="light"]) .cal-p4 { --pc: #F9A8D4; --pcbg: #43142D; }
  :root:not([data-theme="light"]) .cal-p5 { --pc: #A3E07A; --pcbg: #1C3310; }
  :root:not([data-theme="light"]) .cal-p6 { --pc: #7DD3EA; --pcbg: #0C3340; }
  :root:not([data-theme="light"]) .cal-p7 { --pc: #E0B48C; --pcbg: #3A2616; }
}

.cal-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.cal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.cal-title { margin: 0 0 0 6px; font-size: 20px; line-height: 28px; font-weight: 600; }
.cal-opts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-opts .input { width: auto; min-width: 150px; height: 34px; }
.cal-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 12px; }
.cal-gnote { margin-bottom: 12px; }
.cal-gnote a { font-weight: 600; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-2); }
.cal-key { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.cal-keyh { color: var(--text-3); font-size: 12px; }
.cal-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pc, var(--text-3)); flex: none; display: inline-block; }
.cal-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.cal-toggle input { width: 16px; height: 16px; accent-color: var(--navy); }

/* month grid */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; background: var(--surface); }
.cal-dow { padding: 8px 8px; font-size: 12px; font-weight: 600; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: left; }
.cal-dow .short { display: none; }
.cal-cell { min-height: 118px; padding: 4px 5px 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; background: var(--surface); }
.cal-grid > :nth-child(7n) { border-right: 0; }
.cal-cell.wknd { background: var(--surface-2); }
.cal-cell.out { background: var(--surface-2); }
.cal-cell.out .cal-num { color: var(--text-3); font-weight: 400; }
.cal-cell:hover { background: var(--navy-tint); }
.cal-num { align-self: flex-start; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); min-width: 24px; height: 24px; border-radius: 12px; padding: 0 6px; }
.cal-cell.today .cal-num { background: var(--crimson-solid); color: #fff; }
.cal-chip { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--pc, var(--border-strong)); border-radius: 4px; background: var(--pcbg, var(--surface-3)); color: var(--text); font-size: 12px; line-height: 16px; padding: 2px 5px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.cal-chip:hover { filter: brightness(.97); text-decoration: none; }
.cal-chip.done { font-weight: 500; }
.cal-chip.overdue { background: var(--crimson-tint); border-left-color: var(--crimson); color: var(--crimson-text); font-weight: 600; }
.cal-m { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; border: 1px solid currentColor; border-radius: 3px; padding: 0 3px; margin-right: 4px; opacity: .85; }
.cal-google { --pc: var(--text-3); --pcbg: var(--surface-3); color: var(--text-2); cursor: pointer; }
.cal-tag { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; margin-right: 5px; color: var(--text-3); }
.cal-more { align-self: flex-start; border: 0; background: none; color: var(--navy); font-size: 12px; cursor: pointer; padding: 0 2px; }
.cal-more:hover { text-decoration: underline; }
.cal-leave { display: block; font-size: 11px; line-height: 16px; font-weight: 600; padding: 1px 6px; border-radius: 10px; border: 1px dashed var(--pc); color: var(--pc); background: transparent; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-hrs { margin-top: auto; display: flex; flex-wrap: wrap; gap: 2px 10px; padding-top: 2px; }
.cal-hours { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; line-height: 14px; color: var(--text-2); }

/* week view */
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.cal-col { border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); min-width: 0; overflow: hidden; }
.cal-col.wknd { background: var(--surface-2); }
.cal-col.today { border-color: var(--crimson); }
.cal-colhead { display: flex; align-items: baseline; gap: 6px; width: 100%; border: 0; border-bottom: 1px solid var(--border); background: var(--surface-2); padding: 8px 10px; cursor: pointer; text-align: left; }
.cal-colhead .dow { font-size: 12px; font-weight: 600; color: var(--text-3); }
.cal-colhead .n { font-size: 17px; font-weight: 600; }
.cal-col.today .cal-colhead .n { color: var(--crimson); }
.cal-total { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-2); }

/* what a day holds: week column, phone list, day panel */
.cal-detail { display: flex; flex-direction: column; gap: 10px; padding: 8px; min-width: 0; }
.modal .cal-detail { padding: 0; }
.cal-detail.empty { display: none; }
.cal-person h4 { margin: 0 0 4px; font-size: 13px; line-height: 18px; display: flex; align-items: center; gap: 6px; }
.cal-person { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-item { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cal-detail .cal-chip { white-space: normal; overflow-wrap: anywhere; }
.cal-ctx { font-size: 11px; line-height: 15px; color: var(--text-3); padding-left: 8px; overflow-wrap: anywhere; }
.cal-line { font-size: 12px; line-height: 16px; color: var(--text-2); }
.cal-none { font-size: 13px; color: var(--text-3); padding: 2px 0; }
.cal-detail .cal-leave { white-space: normal; align-self: flex-start; }

/* phone list, used instead of the month grid */
.cal-agenda { display: none; flex-direction: column; gap: 10px; }
.cal-aday { border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); overflow: hidden; cursor: pointer; }
.cal-aday.today { border-color: var(--crimson); }
.cal-ahead { font-weight: 600; font-size: 14px; padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }

@media (max-width: 1100px) {
  .cal-week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-cell { min-height: 96px; }
  .cal-dow .long { display: none; }
  .cal-dow .short { display: inline; }
}
@media (max-width: 767px) {
  .cal-grid { display: none; }
  .cal-agenda { display: flex; }
  .cal-week { grid-template-columns: minmax(0, 1fr); }
  .cal-title { font-size: 17px; line-height: 24px; margin-left: 2px; }
  .cal-bar { gap: 8px; }
  .cal-opts { width: 100%; }
  .cal-opts .input { flex: 1; min-width: 0; }
}

/* Google chips are buttons now; done and delegated states */
.cal-google { font-family: inherit; }
.cal-google .cal-gtext { overflow: hidden; text-overflow: ellipsis; }
.cal-google.gdone { opacity: .7; }
.cal-google.gdone .cal-gtext { text-decoration: line-through; color: var(--text-3); }
.cal-tick { font-weight: 700; color: var(--text-2); }
.cal-deleg { display: inline-block; margin-right: 4px; padding: 0 4px; border: 1px solid currentColor; border-radius: 3px; font-size: 10px; line-height: 13px; font-weight: 700; color: var(--navy); opacity: .9; vertical-align: 1px; }
:root[data-theme="dark"] .cal-deleg { color: var(--text-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cal-deleg { color: var(--text-2); } }
.cal-chip:focus-visible { outline: 2px solid var(--navy); outline-offset: 1px; }

/* the action menu */
.cal-menu-scrim { display: none; }
.cal-menu { position: fixed; z-index: 45; min-width: 220px; max-width: min(320px, calc(100vw - 16px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-lg); padding: 6px; font-family: var(--font-sans); }
.cal-menu-note { padding: 4px 10px; font-size: 12px; line-height: 16px; color: var(--text-3); overflow-wrap: anywhere; }
.cal-menu-note:first-child { color: var(--text-2); font-weight: 600; }
.cal-menu-note:last-of-type { padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.cal-menu-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 14px; font-family: inherit; text-decoration: none; }
.cal-menu-item:hover, .cal-menu-item:focus-visible { background: var(--surface-2); outline: none; text-decoration: none; }
.cal-menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--navy); }
@media (max-width: 767px) {
  .cal-menu-scrim { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(10, 18, 36, .38); }
  .cal-menu { left: 0; right: 0; bottom: 0; top: auto; max-width: none; border-radius: 14px 14px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .cal-menu-item { padding: 13px 12px; font-size: 16px; }
}

/* 2.14.0 task categories. The colours (--cc, --ccbg) are in /css/categories.css, generated from server/services/categories.js.
   Red is Call, so overdue can no longer rely on red alone: every overdue chip carries an "Overdue" badge and a dashed outline. */
.cal-chip.cal-cat { border-left-width: 4px; border-left-color: var(--cc); background: var(--ccbg); color: var(--text); }
.cal-chip.overdue { outline: 1.5px dashed var(--crimson-text); outline-offset: -1.5px; }
.cal-chip.overdue.cal-cat { border-left-color: var(--cc); background: var(--ccbg); color: var(--text); font-weight: 600; }
.cal-od { display: inline-block; font-size: 10px; line-height: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; background: var(--crimson-solid); color: #fff; border-radius: 3px; padding: 0 4px; margin-right: 4px; vertical-align: 1px; }
.cal-catlegend { margin-bottom: 12px; align-items: center; }
.cal-catkey .cal-dot { background: var(--cc); border-radius: 2px; }
