/* Slate calendar views, shared by calendar.html and the boards-page calendar. Flat tiles, 1px hairlines, no accent colour.
   Cards are filled pills with a status dot; events are outlined blocks with a solid edge. Shape and label carry the meaning, never hue.
   A selected tile inverts (ink on paper becomes paper on ink). All motion uses --ease and --dur-*. */
.muted { color: var(--ink-2); }
.mono.muted { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.empty.small { padding: 16px 0; text-align: left; }
.cal-view, .strip-box { -webkit-user-select: none; user-select: none; }

/* Full tiles: day panel, popover, week columns, agenda */
.ctile, .etile {
  display: flex; flex-direction: column; gap: 3px; min-width: 0; width: 100%; text-align: left; text-decoration: none; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 12px; padding: 7px 9px; color: var(--ink); font: inherit;
  transition: border-color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), opacity var(--dur-2) var(--ease);
  -webkit-touch-callout: none; -webkit-user-drag: none;
}
.ctile { background: var(--paper-2); }
.etile { background: transparent; border-left: 3px solid var(--ink); border-radius: 4px 12px 12px 4px; }
.etile.allday { border-color: var(--ink-2); border-left-color: var(--ink); }
.ctile:hover, .etile:hover { border-color: var(--ink); }
.ctile.late { border-style: dashed; border-color: var(--ink); }
.ctile.done .ct-title { color: var(--ink-2); }
.ctile:focus-visible, .etile:focus-visible, .chip:focus-visible, .sc-item:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[data-drag] { cursor: grab; }
[data-tile].dragging { opacity: .35; }
.ctile.sel, .etile.sel, .sc-item.sel, .chip.sel { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.ctile.sel .ct-top, .ctile.sel .ct-sub, .etile.sel .ct-top, .etile.sel .ct-sub, .ctile.done.sel .ct-title { color: color-mix(in srgb, var(--paper) 78%, transparent); }
.ctile.sel .ct-late { color: var(--paper); border-color: var(--paper); }
.ct-top { overflow: hidden; display: flex; align-items: center; gap: 5px; color: var(--ink-2); font-size: 10px; min-width: 0; }
.ct-top .mono { font-size: 10px; }
.ct-lead { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ct-late { color: var(--ink); border: 1px solid var(--ink); border-radius: 999px; padding: 0 4px; line-height: 1.5; flex: none; }
.ct-top .ct-late { font-size: 9px; }
.ct-time { margin-left: auto; flex: none; }
.ct-title { font-size: 13px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.ct-sub { font-size: 10px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.cal-dragging, body.cal-dragging * { cursor: grabbing !important; }
body.cal-dragging, body.cal-banding { user-select: none; -webkit-user-select: none; }
body.cal-dragging .m-pop { opacity: 0; pointer-events: none; }

/* Drag ghost: the pressed tile, with two layers behind it and a count when several move together */
.cal-ghost { position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; will-change: transform; }
.cal-ghost-tile { position: relative; margin: 0 !important; width: 100% !important; opacity: .96; background: var(--paper-2); color: var(--ink); border-color: var(--ink); cursor: grabbing; }
.cal-ghost-tile.sel { background: var(--paper-2); }
.cal-ghost-layer { position: absolute; inset: 0; border: 1px solid var(--ink); border-radius: 12px; background: var(--paper-2); }
.cal-ghost-count { position: absolute; right: -8px; top: -12px; z-index: 2; background: var(--ink); color: var(--paper); border-radius: 999px; padding: 3px 9px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.cal-ghost-count[hidden] { display: none; }
.cal-band { position: fixed; z-index: 80; pointer-events: none; border: 1px solid var(--ink); border-radius: 6px; background: color-mix(in srgb, var(--ink) 8%, transparent); }
.drop-over { outline: 2px dashed var(--ink); outline-offset: -3px; }

/* Skeleton: same footprint as a tile, no motion */
.skel-tile { display: block; width: 100%; height: 24px; border: 1px dashed var(--rule); border-radius: 8px; background: var(--paper-2); align-self: center; }
.w-tiles .skel-tile, .dp-list .skel-tile, .a-day .skel-tile { height: 44px; border-radius: 12px; }

/* Fortnight strip: fixed height so nothing moves when data lands */
.strip { border: 1px solid var(--rule); border-radius: var(--radius-tile); padding: 14px 14px 12px; margin: 8px 0 16px; background: var(--paper-2); }
.strip-head { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 10px; min-height: 28px; }
.strip-head h2 { font-size: 11px; font-weight: 400; color: var(--ink-2); }
.strip-row { list-style: none; margin: 0; padding: 0 0 4px; display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; overscroll-behavior-x: contain; scrollbar-width: thin; }
.sc { flex: 0 0 124px; height: 148px; border: 1px solid var(--rule); border-radius: 12px; padding: 8px; background: var(--paper); scroll-snap-align: start; display: flex; flex-direction: column; gap: 6px; overflow: hidden; transition: border-color var(--dur-1) var(--ease); }
.sc.wknd { background: transparent; }
.sc.today { border-color: var(--ink); }
.sc.none { opacity: .7; }
.sc.late-cell { border-style: dashed; border-color: var(--ink); flex-basis: 160px; }
.sc-head { display: flex; justify-content: space-between; color: var(--ink-2); }
.sc-items { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.sc-item { display: flex; gap: 6px; align-items: baseline; text-decoration: none; font-size: 12px; line-height: 1.3; padding: 2px 4px; margin: 0 -4px; border-radius: 8px; border: 1px solid transparent; -webkit-touch-callout: none; transition: background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease); }
.sc-item:hover .sc-title { text-decoration: underline; text-underline-offset: 3px; }
.sc-item.late .sc-title { text-decoration: underline dashed; text-underline-offset: 3px; }
.sc-title { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.sc-item .dot { margin-top: 3px; }
.sc-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sc-board { font-size: 9px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-item.sel .sc-board { color: color-mix(in srgb, var(--paper) 78%, transparent); }
.sc-body .sc-title { -webkit-line-clamp: 1; }

/* Month: six rows of a fixed height, so the page never changes size.
   Each row is a grid: row 1 holds the day numbers, then one row per lane of events, then a row for "+N more".
   Day backgrounds are cells that span every row, so a multi-day bar can run straight across them. */
.m-frame { border: 1px solid var(--rule); border-radius: var(--radius-tile); background: var(--paper-2); }
.m-head, .m-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.m-head > div { padding: 10px 10px 8px; color: var(--ink-2); border-bottom: 1px solid var(--rule); }
.m-row { grid-template-rows: 34px repeat(var(--lanes, 4), 26px) 24px; row-gap: 2px; position: relative; }
.m-row + .m-row .m-cell { border-top: 1px solid var(--rule); }
.m-cell { border-left: 1px solid var(--rule); min-width: 0; transition: background-color var(--dur-1) var(--ease); }
.m-cell.c0 { border-left: 0; }
.m-cell.wknd { background: var(--paper); }
.m-cell.out { background-image: repeating-linear-gradient(135deg, transparent 0 7px, color-mix(in srgb, var(--ink) 4%, transparent) 7px 8px); }
.m-cell.today { box-shadow: inset 0 2px 0 var(--ink); }
.m-cell.sel { box-shadow: inset 0 0 0 1px var(--ink); }
.m-cell.today.sel { box-shadow: inset 0 2px 0 var(--ink), inset 0 0 0 1px var(--ink); }
.m-row:last-child .m-cell.c0 { border-bottom-left-radius: calc(var(--radius-tile) - 1px); }
.m-row:last-child .m-cell.c6 { border-bottom-right-radius: calc(var(--radius-tile) - 1px); }
.m-num { align-self: start; justify-self: start; margin: 5px 0 0 6px; display: inline-flex; gap: 6px; align-items: center; border: 1px solid transparent; background: none; border-radius: 999px; padding: 2px 8px; cursor: pointer; min-height: 26px; color: var(--ink); z-index: 1; transition: border-color var(--dur-1) var(--ease); }
.m-num:hover { border-color: var(--rule-strong); }
.m-num:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.m-num.out { color: var(--ink-2); }
.m-num.today { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.m-today { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.m-count { display: none; }
.m-more { all: unset; cursor: pointer; align-self: center; justify-self: start; margin-left: 8px; color: var(--ink-2); padding: 2px 4px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; z-index: 1; }
.m-more:hover, .m-more:focus-visible, .m-more[aria-expanded="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.m-more:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

/* Chips: one line each. Cards are pills with a status dot, events have a solid edge. Multi-day events are one continuous bar. */
.chip {
  display: flex; align-items: center; gap: 6px; min-width: 0; height: 24px; margin: 0 4px; padding: 0 9px; align-self: center; z-index: 1; box-sizing: border-box;
  border: 1px solid var(--rule-strong); color: var(--ink); text-decoration: none; font: 12px/1 var(--font-sans); cursor: pointer; text-align: left;
  transition: border-color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), opacity var(--dur-2) var(--ease);
}
.chip:hover { border-color: var(--ink); }
.chip.c-card { border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, var(--paper-2)); border-color: var(--rule); }
.chip.c-card.late { border-style: dashed; border-color: var(--ink); }
.chip.c-card.done .chip-title { color: var(--ink-2); }
.chip.c-event { border-radius: 4px 8px 8px 4px; border-left: 3px solid var(--ink); background: transparent; }
.chip.c-event.allday { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.chip.cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 1px; border-left-style: dashed; }
.chip.cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-style: dashed; }
.chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; font-weight: 500; }
/* selected: placed after the chip kinds so it wins on equal specificity */
.chip.c-card.sel, .chip.c-event.sel, .chip.c-event.allday.sel { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip.c-card.sel.done .chip-title { color: var(--paper); }
.chip-time { font-size: 10px; color: var(--ink-2); flex: none; }
.chip.sel .chip-time { color: color-mix(in srgb, var(--paper) 78%, transparent); }
.chip-edge { flex: none; font-size: 11px; color: var(--ink-2); }
.chip.sel .chip-edge { color: var(--paper); }
.chip.sel.c-event { border-left-color: var(--paper); }
.chip .dot { width: 7px; height: 7px; }

/* "+N more" popover: lives inside the week row it belongs to */
.m-pop { grid-row: 1 / -1; align-self: start; z-index: 30; margin: 4px; padding: 12px; background: var(--paper); border: 1px solid var(--ink); border-radius: var(--radius-tile); display: flex; flex-direction: column; gap: 8px; min-width: 0; animation: cal-pop var(--dur-2) var(--ease); }
.mp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mp-head strong { font-family: var(--font-display); font-weight: 500; font-size: 16px; }
.mp-x { padding: 2px 10px; min-height: 28px; }
.mp-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 280px; padding: 2px; }
.mp-add { align-self: flex-start; }
@keyframes cal-pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.day-panel { margin-bottom: 16px; height: 200px; overflow-y: auto; box-sizing: border-box; border: 1px solid var(--rule); border-radius: var(--radius-tile); padding: 16px; background: var(--paper-2); }
.dp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 10px; min-height: 48px; }
.dp-head h2 { font-size: 20px; }
.dp-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }

/* Week and fortnight. Multi-day events are bars laid over a reserved band under the day headings. */
.weeks { display: flex; flex-direction: column; gap: 8px; }
.week-block { position: relative; --span-top: 48px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.w-day { border: 1px solid var(--rule); border-radius: var(--radius-tile); padding: 10px; min-height: 260px; display: flex; flex-direction: column; gap: 8px; min-width: 0; background: var(--paper-2); outline-offset: 2px; }
.fortnight .w-day { min-height: 190px; }
.w-day.wknd { background: var(--paper); }
.w-day.today { border-color: var(--ink); box-shadow: inset 0 2px 0 var(--ink); }
.w-head { display: flex; align-items: baseline; gap: 8px; min-height: 30px; }
.w-head strong { font-family: var(--font-display); font-size: 22px; font-weight: 500; }
.w-day.today .w-head strong { background: var(--ink); color: var(--paper); border-radius: 999px; padding: 0 10px; font-size: 20px; }
.w-add { margin-left: auto; min-height: 26px; padding: 2px 10px; flex: none; }
.w-spanpad { flex: none; height: calc(var(--wl, 0) * 30px - 4px); }
.w-tiles { display: flex; flex-direction: column; gap: 6px; }
.w-empty { margin: 0; color: var(--ink-2); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.w-bar { position: absolute; margin: 0; z-index: 2; }

/* Agenda */
.agenda { display: flex; flex-direction: column; gap: 14px; }
.a-day { border: 1px solid var(--rule); border-radius: var(--radius-tile); padding: 14px 16px; background: var(--paper-2); outline-offset: 2px; }
.a-day.today { border-color: var(--ink); box-shadow: inset 0 2px 0 var(--ink); }
.a-head { display: flex; align-items: baseline; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--rule); margin-bottom: 10px; }
.a-head h2 { font-size: 20px; }
.a-head .mono { color: var(--ink-2); }
.a-today { color: var(--ink) !important; border: 1px solid var(--ink); border-radius: 999px; padding: 1px 7px; font-size: 10px; }
.a-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.a-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.a-row > .ctile, .a-row > .etile { flex: 1 1 260px; width: auto; }
.a-move { flex: none; }

/* Selection bar */
.cal-selbar {
  position: fixed; left: 50%; bottom: 20px; z-index: 40; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 32px);
  background: var(--paper); border: 1px solid var(--ink); border-radius: var(--radius-tile); padding: 10px 12px 10px 18px;
  transition: opacity var(--dur-2) var(--ease), transform var(--dur-2) var(--ease);
}
.cal-selbar.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.sb-text { display: flex; flex-direction: column; gap: 2px; }
.sb-count { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.sb-meta { font-size: 10px; }
.sb-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Date popover (datepicker.js shown as a single-day chooser) */
.cal-pop-host { position: absolute; z-index: 70; width: 340px; max-width: calc(100vw - 16px); }
.cal-pop-host .dp, .ev-dialog .dp { position: static; width: 100%; box-sizing: border-box; animation: cal-pop var(--dur-2) var(--ease); }
.cal-pop-host .dp-fw:first-child, .cal-pop-host .dp-time, .cal-pop-host .dp-sum, .cal-pop-host .dp-chips .pill:last-child { display: none; }
.cal-pop-host .dp-fields { grid-template-columns: 1fr; }
.dp { background: var(--paper); border: 1px solid var(--ink-2); border-radius: var(--radius-tile); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.dp-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dp-fw { position: relative; }
.dp-field { width: 100%; display: flex; flex-direction: column; gap: 2px; padding: 8px 28px 8px 12px; border: 1px solid var(--rule); border-radius: 12px; background: transparent; cursor: pointer; text-align: left; color: var(--ink); }
.dp-field.on { border-color: var(--ink); }
.dp-val { font: 12px var(--font-mono); }
.dp-x { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer; line-height: 1; }
.dp-x:hover { color: var(--ink); background: var(--paper-2); }
.dp-nav { display: flex; align-items: center; justify-content: space-between; }
.dp-month { font: 11px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.dp-step { width: 30px; height: 30px; border: 1px solid var(--rule); border-radius: 50%; background: none; color: var(--ink); cursor: pointer; font-size: 16px; line-height: 1; }
.dp-step:hover { border-color: var(--ink); }
.dp-grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; user-select: none; -webkit-user-select: none; }
.dp-grid th { font: 10px var(--font-mono); letter-spacing: .06em; color: var(--ink-2); padding: 6px 0; text-align: center; font-weight: 400; border-bottom: 1px solid var(--rule); }
.dp-day { height: 36px; text-align: center; vertical-align: middle; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); cursor: pointer; position: relative; font: 12px var(--font-mono); touch-action: none; }
.dp-grid tr > :last-child { border-right: 0; }
.dp-grid tbody tr:last-child .dp-day { border-bottom: 0; }
.dp-day:hover { background: var(--paper-2); }
.dp-day.out { color: var(--ink-2); opacity: .6; }
.dp-day.in { background: var(--paper-2); }
.dp-day.end { background: var(--ink); color: var(--paper); opacity: 1; }
.dp-day:focus-visible { outline: 2px solid var(--ink); outline-offset: -3px; }
.dp-day.end:focus-visible { outline-color: var(--paper); }
.dp-day.today::after { content: ""; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }
.dp-time { display: flex; align-items: center; gap: 8px; }
.dp-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.dp-chips .pill { cursor: pointer; color: var(--ink); }
.dp-chips .pill:hover { border-color: var(--ink); }
.dp-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dp-sum { color: var(--ink-2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

@media (max-width: 720px) {
  .m-row { grid-template-rows: 58px; row-gap: 0; }
  .m-row .chip, .m-row .m-more, .m-row .skel-tile, .m-pop { display: none; }
  .m-num { flex-direction: column; gap: 2px; padding: 2px 6px; align-self: center; justify-self: center; margin: 0; }
  .m-today { display: none; }
  .m-count { display: inline-block; font-size: 9px; border: 1px solid var(--ink-2); border-radius: 999px; padding: 0 5px; line-height: 1.4; }
  .m-num.today .m-count { border-color: var(--paper); }
  .m-head > div { padding: 8px 2px; text-align: center; font-size: 10px; }
  .week { grid-template-columns: 1fr; }
  .w-day, .fortnight .w-day { min-height: 0; }
  .dp-list { grid-template-columns: 1fr; }
  .a-row > .ctile, .a-row > .etile { flex-basis: 100%; }
  .sc { flex-basis: 112px; }
  .cal-selbar { bottom: 12px; padding-left: 14px; gap: 10px; }
}
@media (pointer: coarse) { .ctile, .etile { padding: 10px 12px; } .m-num { min-height: 36px; } }

/* The day chosen in the month grid is outlined in the fortnight strip too */
.sc.sel { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* Day menu: opens where a day is clicked */
.day-menu { position: absolute; z-index: 80; width: 260px; max-width: calc(100vw - 16px); box-sizing: border-box; padding: 8px; display: flex; flex-direction: column; gap: 4px; background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 14px; box-shadow: 0 10px 30px color-mix(in srgb, var(--ink) 14%, transparent); animation: cal-pop var(--dur-2) var(--ease); }
.day-menu .dm-head { color: var(--ink-2); padding: 6px 8px 4px; }
.day-menu .dm-item { justify-content: flex-start; width: 100%; box-sizing: border-box; }
.day-menu .dm-list { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; }
.day-menu .dm-board { justify-content: space-between; gap: 10px; text-align: left; }
.day-menu .dm-board .muted { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }

/* Events in the fortnight strip */
button.sc-item { font: inherit; font-size: 12px; line-height: 1.3; color: inherit; background: transparent; text-align: left; cursor: pointer; width: calc(100% + 8px); box-sizing: border-box; }
.sc-item .dot.ev { flex: none; width: 3px; height: 12px; margin-top: 2px; border: 0; border-radius: 2px; background: var(--ink); }
.sc-item.ev .sc-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dp-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dp-title > .dp-lt { font-family: var(--font-display); font-size: 13px; font-weight: 500; line-height: 1.2; letter-spacing: 0; text-transform: none; color: var(--ink-2); }
.day-panel .empty.small { margin: 12px 0 0; padding: 18px 22px; text-align: left; font-family: var(--font-display); font-weight: 500; font-size: 14px; letter-spacing: 0; text-transform: none; }
.day-menu .empty.small { margin: 4px 0 0; padding: 14px 16px; text-align: left; font-size: 11px; }
