/* Calendar block (cal-): agenda, month grid, detail dialog. Tokens only; phone breakpoint 720.
   Agenda: a date rail beside one grouped sheet of rows per day. Month: a framed grid whose contents slide on a month flip
   (calendar.js, WAAPI). Detail: a native dialog, a bottom sheet on phones. */
.cal { --cal-rail: 96px; --cal-cell: 116px; padding-top: var(--section); padding-bottom: var(--section); }
.cal-head { display: flex; flex-direction: column; gap: 12px; max-width: var(--w-prose); margin-bottom: 32px; }
.cal-head:empty { display: none; }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 28px; }
.cal-views { margin-left: auto; }
.cal-views .k-chip svg { flex: none; }

/* ---- agenda ---- */
.cal-days { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 28px; }
.cal-day { display: grid; grid-template-columns: var(--cal-rail) minmax(0, 1fr); gap: 24px; align-items: start; }
.cal-rail { position: sticky; top: calc(var(--header-h, 72px) + 16px); display: flex; flex-direction: column; align-items: flex-start; padding-top: 4px; }
.cal-dow, .cal-mon { font-size: 14px; font-weight: 600; line-height: 1.3; color: var(--muted); }
.cal-dnum { font-family: var(--font-display); font-size: 44px; line-height: 1; font-weight: 700; letter-spacing: -0.03em; margin: 2px 0 3px; color: var(--ink); }
.cal-rail[data-today] :is(.cal-dnum, .cal-dow) { color: var(--brand); }
.cal-evs { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-ev { position: relative; display: grid; grid-template-columns: 112px minmax(0, 1fr) auto; gap: 8px 20px; align-items: start; padding: 18px 20px; transition: background-color var(--d-fast) ease; }
.cal-ev + .cal-ev { border-top: 1px solid var(--line); }
[data-live] .cal-ev { cursor: pointer; }
.cal-when { display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.cal-t { font-size: 17px; font-weight: 700; line-height: 1.3; }
.cal-t2 { font-size: 14px; font-weight: 500; line-height: 1.3; color: var(--muted); }
.cal-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cal-title { margin: 0; font: 600 19px/1.25 var(--font); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.cal-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; font-size: 15px; font-weight: 500; color: var(--muted); }
.cal-loc { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.cal-loc svg { flex: none; }
.cal-loc + .cal-cat::before { content: "\00b7"; margin-right: 8px; }
.cal-loc span { overflow-wrap: anywhere; }
.cal-text { max-width: 60ch; font-size: 15px; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cal-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 2px; }
.cal-tags:empty { display: none; }
.cal-price { font-size: 15px; font-weight: 700; }
.cal-acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.cal-ev[data-past] :is(.cal-when, .cal-main) { opacity: .64; }
.cal-earlier { margin: 56px 0 24px; font-size: 20px; font-weight: 600; color: var(--muted); }
.cal-empty { display: flex; align-items: center; gap: 18px; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); max-width: var(--w-prose); }
.cal-empty svg { flex: none; box-sizing: content-box; padding: 12px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); }
.cal-empty p { font-size: 17px; }

/* ---- month ---- */
.cal-mbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.cal-mnav { display: flex; gap: 8px; }
.cal-nav { width: 44px; padding: 0; }
.cal-nav svg { width: 34px; height: 34px; }
.cal-nav[data-act="prev"] svg { transform: rotate(180deg); }
.cal-gridwrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-grid th { padding: 12px 10px 10px; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); }
.cal-grid td { padding: 0; vertical-align: top; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal-grid td:first-child { border-left: 0; }
.cal-grid td[aria-selected="true"] { background: var(--brand-soft); }
.cal-blank { background: var(--ground); }
.cal-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: 100%; min-height: var(--cal-cell); padding: 8px 10px; border: 0; border-radius: 0; background: transparent; text-align: left; font: inherit; color: var(--ink); }
.cal-cell:focus-visible { outline: 2px solid var(--brand); outline-offset: -3px; border-radius: 6px; }
.cal-n { display: grid; place-items: center; min-width: 30px; height: 30px; border-radius: 999px; font-size: 15px; font-weight: 600; margin: -2px 0 0 -4px; }
.cal-cell[data-past] .cal-n { color: var(--muted); }
.cal-cell[aria-current="date"] .cal-n { background: var(--brand); color: var(--on-brand); }
.cal-pips { display: flex; flex-direction: column; gap: 3px; width: 100%; min-width: 0; }
.cal-pip { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 2px 6px; border-radius: 6px; background: var(--brand-soft); font-size: 13px; font-weight: 500; line-height: 1.3; }
.cal-pip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-dot { display: block; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.cal-xtra { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.cal-dots { display: none; }
.cal-dayview { margin-top: 28px; }
.cal-dvh { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font: 600 20px/1.25 var(--font); letter-spacing: -0.01em; }
.cal-hint { color: var(--muted); }
.cal-dayview .cal-title { font-size: 18px; }

/* ---- detail dialog ---- */
.cal-dlg { padding: 0; border: 0; border-radius: var(--radius-sheet); background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 32px)); max-height: min(88vh, 780px); box-shadow: var(--shadow); overflow: hidden; }
.cal-dlg[open] { animation: cal-rise .32s var(--ease); }
.cal-dlg::backdrop { background: color-mix(in srgb, var(--ink) 52%, transparent); animation: k-fade .2s ease; }
.cal-sheet { position: relative; display: flex; flex-direction: column; max-height: min(88vh, 780px); overflow-y: auto; overscroll-behavior: contain; }
.cal-x { position: sticky; top: 12px; z-index: 2; flex: none; align-self: flex-end; width: 44px; height: 44px; margin: 12px 12px -56px 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.cal-dstage { flex: none; aspect-ratio: 16 / 9; background: var(--placeholder); }
.cal-dstage img { width: 100%; height: 100%; object-fit: cover; }
.cal-dbody { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 24px 24px 12px; background: var(--surface); }
.cal-dstage + .cal-dbody { margin-top: -24px; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; }
.cal-dtitle { font-size: clamp(24px, 3vw, 28px); line-height: 1.15; letter-spacing: -0.02em; padding-right: 44px; overflow-wrap: anywhere; }
.cal-dstage + .cal-dbody .cal-dtitle { padding-right: 0; }
.cal-facts { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.cal-facts > div { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; }
.cal-facts dt { font-size: 14px; font-weight: 500; line-height: 1.6; color: var(--muted); }
.cal-facts dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.cal-dtext { max-width: 60ch; white-space: pre-line; overflow-wrap: anywhere; }
.cal-dfoot { position: sticky; bottom: 0; display: flex; flex-direction: column; gap: 16px; margin-top: auto; padding: 16px 24px calc(20px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.cal-book { width: 100%; }
.cal-addh { margin: 0 0 8px; font-size: 14px; font-weight: 500; color: var(--muted); }
.cal-addl { display: flex; flex-wrap: wrap; gap: 8px; }

@media (hover: hover) and (pointer: fine) {
  [data-live] .cal-ev:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
  .cal-cell { transition: background-color var(--d-fast) ease; }
  .cal-cell:hover { background: var(--ground); }
  .cal-grid td[aria-selected="true"] .cal-cell:hover { background: transparent; }
}

@keyframes cal-rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes cal-slide { from { opacity: 0; transform: translateY(40px); } }

@media (max-width: 720px) {
  .cal { --cal-cell: 60px; }
  .cal-bar { margin-bottom: 20px; }
  .cal-views { margin-left: 0; }
  .cal-day { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .cal-rail { position: static; flex-direction: row; align-items: baseline; gap: 6px; padding-top: 0; }
  .cal-dnum { font-size: 28px; margin: 0; }
  .cal-dow, .cal-mon { font-size: 15px; }
  .cal-ev { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 16px; }
  .cal-when { flex-direction: row; align-items: baseline; gap: 8px; padding-top: 0; }
  .cal-acts { justify-content: stretch; }
  .cal-acts > * { flex: 1 1 0; }
  .cal-grid th { padding: 10px 0 8px; text-align: center; font-size: 12px; }
  .cal-cell { align-items: center; gap: 4px; padding: 6px 0; }
  .cal-n { margin: 0; }
  .cal-pips { display: none; }
  .cal-dots { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 3px; }
  .cal-dayview { margin-top: 24px; }
  .cal-dlg { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; max-height: 92dvh; }
  .cal-dlg[open] { animation-name: cal-slide; }
  .cal-sheet { max-height: 92dvh; }
  .cal-dbody { padding: 20px 16px 12px; }
  .cal-dfoot { padding-left: 16px; padding-right: 16px; }
  .cal-facts > div { grid-template-columns: 64px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .cal-dlg[open], .cal-dlg::backdrop { animation: k-fade .3s ease; }
}
