/* Calendar mode (Functie C) — raster Day/Week/Month, Events, dialogen. Gebruikt de tokens uit tokens.css. */

.mode-switch { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--color-bg-muted); }
.mode-switch button { padding: 5px 12px; border-radius: 6px; font: 600 12px/1.3 var(--font-body); color: var(--color-text-muted); }
.mode-switch button.is-active { background: var(--color-bg-surface); color: var(--color-text-default); box-shadow: 0 1px 2px rgba(27, 25, 22, .08); }
.cal-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-sets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.quiet-mark { border-style: dashed; color: var(--color-text-subtle); }

.cal-empty { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; max-width: 460px; padding: 48px 32px; }

/* --- Day / Week --- */
.cal-grid { --gutter: 56px; height: 100%; min-height: 0; overflow-y: auto; position: relative; scroll-snap-type: y proximity; }
.cal-top { position: sticky; top: 0; z-index: 5; background: var(--color-bg-surface); }
.cal-head, .cal-allday { display: grid; grid-template-columns: var(--gutter) repeat(var(--cols), 1fr); border-bottom: 1px solid var(--color-border-default); }
.cal-dayhead { display: flex; align-items: baseline; justify-content: center; gap: 6px; padding: 8px 4px; border-left: 1px solid var(--color-border-default); }
.cal-dayhead .dow { font: 600 11px/1 var(--font-body); text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-subtle); }
.cal-dayhead .dnum { font: 600 18px/1 var(--font-display, var(--font-body)); color: var(--color-text-default); }
.cal-dayhead.is-today .dnum { display: inline-grid; place-items: center; min-width: 28px; height: 28px; border-radius: 14px; background: var(--color-bg-inverse); color: var(--color-text-inverse); font-size: 15px; }
.cal-dayhead:hover .dow { color: var(--color-text-default); }
.cal-gutter { display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; }
.cal-allday { min-height: 30px; }
.cal-allday-col { display: flex; flex-direction: column; gap: 2px; padding: 3px; border-left: 1px solid var(--color-border-default); min-width: 0; }
.cal-body { display: grid; grid-template-columns: var(--gutter) 1fr; position: relative; padding-top: 8px; }
.cal-hours { position: relative; }
.cal-hour { height: var(--hour, 48px); position: relative; scroll-snap-align: start; }
.cal-hour span { position: absolute; top: -7px; right: 8px; font: 400 11px/1 var(--font-mono, var(--font-body)); color: var(--color-text-subtle); }
.cal-cols { display: grid; grid-template-columns: repeat(var(--cols), 1fr); height: calc(24 * var(--hour, 48px)); }
.cal-col { position: relative; border-left: 1px solid var(--color-border-default); min-width: 0; touch-action: pan-y;
  background-image: repeating-linear-gradient(to bottom, var(--color-border-default) 0 1px, transparent 1px var(--hour, 48px)),
                    repeating-linear-gradient(to bottom, transparent 0 calc(var(--hour, 48px) / 2), rgba(231, 229, 227, .45) calc(var(--hour, 48px) / 2) calc(var(--hour, 48px) / 2 + 1px), transparent calc(var(--hour, 48px) / 2 + 1px) var(--hour, 48px)); }
.cal-col.is-today { background-color: var(--color-bg-subtle); }
.cal-now { position: absolute; left: -1px; right: 0; height: 2px; background: #D93025; z-index: 4; pointer-events: none; }
.cal-now::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 5px; background: #D93025; }

.ev { position: absolute; z-index: 2; overflow: hidden; padding: 3px 6px 2px; border-radius: 6px; cursor: pointer; user-select: none; touch-action: none;
  background: color-mix(in srgb, var(--ev) 16%, var(--color-bg-surface)); border-left: 3px solid var(--ev); color: var(--color-text-default); }
.ev:hover { background: color-mix(in srgb, var(--ev) 24%, var(--color-bg-surface)); }
.ev-title { font: 600 12px/1.25 var(--font-body); overflow: hidden; text-overflow: ellipsis; }
.ev-meta { font: 400 11px/1.3 var(--font-body); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.is-short { display: flex; gap: 6px; align-items: baseline; padding-top: 1px; }
.ev.is-short .ev-title { white-space: nowrap; flex: none; max-width: 70%; }
.ev.is-free { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ev) 10%, var(--color-bg-surface)) 0 6px, var(--color-bg-surface) 6px 12px); }
.ev.is-readonly { cursor: default; }
.ev.is-pending, .mev.is-pending { outline: 1px dashed var(--color-text-subtle); outline-offset: -1px; }
.ev.is-dragging { z-index: 6; box-shadow: 0 8px 20px rgba(27, 25, 22, .18); opacity: .92; }
.ev-rec { font-weight: 400; color: var(--color-text-subtle); }
.ev-link { color: var(--color-text-default); }
.ev-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.ev-ideal { position: absolute; left: 0; right: 0; z-index: 1; pointer-events: none; padding: 2px 6px;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ev) 12%, transparent) 0 5px, transparent 5px 10px); border-left: 2px solid color-mix(in srgb, var(--ev) 45%, transparent); }
.ev-ideal span { font: 600 10px/1.2 var(--font-body); text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-subtle); }
.cal-sel { position: absolute; left: 2px; right: 2px; z-index: 3; border-radius: 6px; background: color-mix(in srgb, var(--color-bg-inverse) 12%, transparent); border: 1px solid var(--color-bg-inverse); font: 600 11px/1.2 var(--font-body); padding: 3px 6px; pointer-events: none; }

/* Blocks (C5): eigen werktijd, niet bezet */
.ev.is-block { background: var(--color-bg-surface); border: 1px dashed color-mix(in srgb, var(--ev) 70%, transparent); border-left: 3px solid var(--ev); }
.ev.is-block .ev-title::before { content: '☐ '; color: var(--ev); }
.ev.is-block.is-done { opacity: .55; }
.ev.is-block.is-done .ev-title { text-decoration: line-through; }
.ev.is-block.is-done .ev-title::before { content: '☑ '; }
/* Dag-Planning zonder tijd in "all day" (alleen met het paneel Plan open): sleep naar een tijd voor een Block */
.plan-chip { padding: 1px 7px; border-radius: 4px; border: 1px dashed #5C6BC0; background: color-mix(in srgb, #5C6BC0 8%, var(--color-bg-surface)); font: 400 11px/1.5 var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: grab; user-select: none; touch-action: none; }
.plan-chip::before { content: '☐ '; color: #5C6BC0; }
.plan-chip.is-project::before { content: '▸ '; }
.plan-chip.is-todoist { border-color: #DB4C3F; background: color-mix(in srgb, #DB4C3F 7%, var(--color-bg-surface)); }
.plan-chip.is-todoist::before { color: #DB4C3F; }
.cal-allday-col.is-drop { background: color-mix(in srgb, #5C6BC0 14%, transparent); outline: 1px dashed #5C6BC0; outline-offset: -2px; }
.ev.is-pblock .ev-title::before { content: '▸ '; }

/* Paneel Plan (rechts, zoals Morgen): projecten, steps en Todoist-taken om in te plannen */
.cal-shell { display: flex; height: 100%; min-height: 0; }
.cal-main { flex: 1; min-width: 0; height: 100%; min-height: 0; }
.cal-panel { width: 300px; flex: none; height: 100%; min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--color-border-default); background: var(--color-bg-surface); }
.cal-panel[hidden] { display: none; }
.pp-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; }
.pp-head .spacer { flex: 1; }
.pp-close { padding: 2px 9px; font-size: 18px; line-height: 1; }
.pp-search { margin: 0 12px 6px; padding: 7px 10px; border: 1px solid var(--color-border-default); border-radius: 8px; font: 400 13px/1.3 var(--font-body); background: var(--color-bg-surface); color: var(--color-text-default); }
.pp-hint { padding: 0 12px 8px; }
.pp-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 8px 24px; }
.pp-group + .pp-group { margin-top: 10px; }
.pp-group-row { display: flex; align-items: center; gap: 6px; }
.pp-filter { flex: none; height: 20px; padding: 0 8px; border-radius: var(--radius-chip); border: 1px solid var(--color-border-strong); font: 600 10.5px/1 var(--font-body); color: var(--color-text-muted); }
.pp-filter.is-on { background: var(--color-bg-inverse); border-color: var(--color-bg-inverse); color: var(--color-text-inverse); }
.pp-tprojects { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 8px; padding: 6px 8px; border-radius: 6px; background: var(--color-bg-subtle); }
.pp-tproj { display: flex; align-items: center; gap: 8px; font: 400 12px/1.4 var(--font-body); cursor: pointer; }
.pp-tproj span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-group-head { display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 4px; font: 600 11px/1 var(--font-body); text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-subtle); }
.pp-caret { width: 10px; }
.pp-count { margin-left: auto; font-weight: 400; }
.pp-item { display: grid; grid-template-columns: 1fr; row-gap: 1px; padding: 6px 8px 6px 9px; margin: 2px 0; border-radius: 6px; border: 1px solid transparent; border-left: 3px solid #5C6BC0; background: color-mix(in srgb, #5C6BC0 5%, var(--color-bg-surface)); cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y; }
.pp-item.is-armed { box-shadow: 0 6px 16px rgba(27, 25, 22, .18); border-color: #5C6BC0; transform: scale(1.02); }
.pp-item:hover { border-color: color-mix(in srgb, #5C6BC0 55%, transparent); border-left-color: #5C6BC0; }
.pp-item.is-todoist { border-left-color: #DB4C3F; background: color-mix(in srgb, #DB4C3F 5%, var(--color-bg-surface)); }
.pp-item.is-todoist:hover { border-color: color-mix(in srgb, #DB4C3F 55%, transparent); border-left-color: #DB4C3F; }
.pp-item.is-project { border-left-color: var(--color-text-default); background: var(--color-bg-subtle); }
.pp-item.has-toggle { grid-template-columns: 18px 1fr; column-gap: 4px; padding-left: 4px; }
.pp-item.is-nested { margin-left: 18px; }
.pp-toggle { grid-row: span 2; align-self: center; width: 18px; height: 22px; font-size: 11px; color: var(--color-text-subtle); }
.pp-toggle:disabled { cursor: default; }
.pp-title { font: 600 12.5px/1.3 var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-sub { font: 400 11px/1.3 var(--font-body); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-sub:empty { display: none; }
.pp-item.is-overdue .pp-sub { color: #D93025; }
.pp-empty { padding: 4px 8px 6px; }
.plan-ghost { width: 240px; }
.dlg-kind { align-self: flex-start; margin-bottom: 4px; }
/* Guests (C8): chips met het antwoord in de statuskleur; × haalt een gast weg */
.guest-chips:empty { display: none; }
.guest-chip { height: 26px; padding: 0 4px 0 10px; font-weight: 500; color: var(--color-text-default); }
.guest-chip .guest-answer:empty { display: none; }
.guest-chip.is-yes { background: var(--color-status-done-solid); border-color: var(--color-status-done-solid); color: var(--color-status-done-on-solid); }
.guest-chip.is-no { background: var(--color-status-blocked-solid); border-color: var(--color-status-blocked-solid); color: var(--color-status-blocked-on-solid); }
.guest-chip.is-maybe { background: var(--color-status-waiting-solid); border-color: var(--color-status-waiting-solid); color: var(--color-status-waiting-on-solid); }
.guest-x { width: 18px; height: 18px; border-radius: 50%; font-size: 13px; line-height: 1; color: inherit; opacity: .7; }
.guest-x:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.guests-note:empty { display: none; }
.guests-note .btn { margin-left: 6px; height: 26px; padding: 0 10px; }
.answer-switch { align-self: flex-start; }
.set-row .spacer { flex: 1; }
.answer-switch button:disabled { opacity: .5; }

/* Travel blocks (C6) */
.ev.is-travel { background: repeating-linear-gradient(90deg, var(--color-bg-muted) 0 3px, var(--color-bg-surface) 3px 6px); border-left-color: #90A4AE; color: var(--color-text-muted); }
.ev.is-travel .ev-title { font-weight: 400; }
.travel-links { display: flex; gap: 12px; flex-wrap: wrap; font: 600 12px/1.4 var(--font-body); }
.travel-links a { color: var(--color-text-default); text-decoration: underline; }
.travel-warn { color: var(--color-status-blocked-text); }
.field input[type="number"] { padding: 7px 9px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-control); background: var(--color-bg-surface); font: 400 13px/1.4 var(--font-body); color: var(--color-text-default); }

/* Adressen zoeken (Google Places) */
.ac-wrap { position: relative; }
.ac-wrap > input { width: 100%; box-sizing: border-box; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; display: flex; flex-direction: column; padding: 4px;
  border: 1px solid var(--color-border-default); border-radius: var(--radius-card); background: var(--color-bg-surface); box-shadow: 0 8px 24px rgba(27, 25, 22, .12); }
.ac-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 8px; border-radius: var(--radius-control); text-align: left; }
.ac-item:hover, .ac-item.is-active { background: var(--color-bg-subtle); }
.ac-main { font: 600 13px/1.3 var(--font-body); color: var(--color-text-default); }
.ac-sec { font: 400 11px/1.3 var(--font-body); color: var(--color-text-subtle); }

/* Rechtermuisknop-menu */
.ctx-menu { position: fixed; top: 0; left: 0; right: auto; z-index: 45; min-width: 210px; max-height: 70vh; overflow-y: auto; }
.ctx-menu .menu-back { color: var(--color-text-muted); }
.ctx-dot { display: inline-block; width: 8px; height: 8px; border-radius: 4px; margin-right: 8px; vertical-align: 1px; }

/* Zelfde afspraak in meerdere calendars: kleurverloop */
.mev.is-merged::before { background: var(--ev-dot, var(--ev)); }
.ev.is-merged { border-left-width: 3px; }

/* chips (hele dag en maand) */
.mev { display: flex; gap: 5px; align-items: baseline; min-width: 0; padding: 1px 6px; border-radius: 4px; cursor: pointer; user-select: none; touch-action: none;
  font: 400 11px/1.45 var(--font-body); color: var(--color-text-default); }
.mev::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 4px; background: var(--ev); transform: translateY(-1px); }
.mev.is-allday { background: color-mix(in srgb, var(--ev) 20%, var(--color-bg-surface)); font-weight: 600; }
.mev.is-allday::before { display: none; }
.mev.is-cont { border-top-left-radius: 0; border-bottom-left-radius: 0; opacity: .8; }
.mev:hover { background: color-mix(in srgb, var(--ev) 26%, var(--color-bg-surface)); }
.mev.is-readonly { cursor: default; }
.mev-time { color: var(--color-text-subtle); font-family: var(--font-mono, var(--font-body)); font-size: 10px; }
.mev-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mev-ghost { position: fixed; z-index: 40; pointer-events: none; box-shadow: 0 6px 16px rgba(27, 25, 22, .2); background: var(--color-bg-surface); max-width: 220px; }

/* --- Month --- */
.cal-month { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.mheads { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--color-border-default); }
.mh { padding: 8px; font: 600 11px/1 var(--font-body); text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-subtle); }
.mgrid { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: repeat(var(--weeks), minmax(96px, 1fr)); min-height: 0; overflow-y: auto; }
.mc { display: flex; flex-direction: column; gap: 2px; padding: 4px; min-width: 0; border-right: 1px solid var(--color-border-default); border-bottom: 1px solid var(--color-border-default); }
.mc.is-outside { background: var(--color-bg-subtle); }
.mc.is-outside .mc-num { color: var(--color-text-disabled); }
.mc.is-drop { background: color-mix(in srgb, var(--color-bg-inverse) 8%, transparent); }
.mc-num { align-self: flex-start; min-width: 24px; height: 24px; border-radius: 12px; font: 600 12px/24px var(--font-body); color: var(--color-text-muted); }
.mc-num:hover { background: var(--color-bg-muted); }
.mc.is-today .mc-num { background: var(--color-bg-inverse); color: var(--color-text-inverse); }
.mc-evs { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mc-more { align-self: flex-start; padding: 0 6px; font: 600 11px/1.4 var(--font-body); color: var(--color-text-subtle); }

/* --- Dialogen --- */
.dlg-wide { width: min(760px, 100%); }
.dlg-actions .spacer { flex: 1; }
.btn-danger { color: var(--color-status-blocked-text); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-grid > * { min-width: 0; }                 /* lange keuzes (Linked to) duwen de kolom niet buiten het venster */
.field-grid select { width: 100%; }
.field select, .field input[type="date"], .field input[type="time"], .set-row input[type="text"], .set-row select, .key-row input, .quick-input {
  padding: 7px 9px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-control); background: var(--color-bg-surface);
  font: 400 13px/1.4 var(--font-body); color: var(--color-text-default); outline: 0; min-width: 0; }
.field select:focus, .field input:focus, .set-row input:focus, .key-row input:focus, .quick-input:focus { border-color: var(--color-border-focus); }
.field-when { display: grid; grid-template-columns: 1fr auto; column-gap: 6px; }
.field-when .field-label { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; font: 400 13px/1.4 var(--font-body); color: var(--color-text-default); }
.dlg input[name="title"] { font: 600 16px/1.4 var(--font-body); }
.settings-sec { display: flex; flex-direction: column; gap: 8px; }
.settings-sec h3 { margin: 6px 0 0; }
.set-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-row input[type="color"] { width: 30px; height: 28px; padding: 0; border: 1px solid var(--color-border-strong); border-radius: 6px; background: none; }
.cal-row input[name="name"] { flex: 1 1 160px; }
.cal-row input[name="context_label"] { flex: 0 1 130px; }
.new-cal input { flex: 1 1 140px; }
.set-key { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--color-bg-muted); font: 600 12px/1 var(--font-mono, var(--font-body)); }
.set-row[data-set] input[name="name"] { flex: 0 1 150px; }
.key-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; }
.key-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 400 12px/1.3 var(--font-body); }
.key-row input { width: 80px; font-family: var(--font-mono, var(--font-body)); }
.quick-input { width: 100%; font-size: 15px; padding: 10px 12px; }
.quick-cmds { display: flex; flex-direction: column; }

/* --- Horizons: Events als compacte markeringen (C4) --- */
.h-agenda { display: flex; flex-direction: column; gap: 1px; margin: 0 12px 8px; padding: 6px 8px; border-radius: 8px; background: var(--color-bg-subtle); }
.h-agenda:hover { background: var(--color-bg-muted); }
.h-agenda .today-ev { font-size: 11px; line-height: 1.45; }
.h-agenda .today-ev time { min-width: 52px; font-size: 10px; }
.h-agenda .today-ev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-agenda-count { font: 600 11px/1.3 var(--font-body); color: var(--color-text-muted); }
.h-agenda-more { font: 600 10px/1.4 var(--font-body); color: var(--color-text-subtle); padding-left: 15px; }

/* --- Overview: Events van vandaag --- */
.today-events { display: flex; flex-direction: column; gap: 2px; }
.today-ev { display: flex; gap: 8px; align-items: baseline; font: 400 12px/1.5 var(--font-body); }
.today-ev::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 4px; background: var(--ev); transform: translateY(-1px); }
.today-ev time { flex: none; min-width: 74px; font: 400 11px/1.5 var(--font-mono, var(--font-body)); color: var(--color-text-subtle); }
.today-ev.is-free { color: var(--color-text-muted); }
.today-ev.is-past { opacity: .55; }

@media (max-width: 760px) {
  .cal-panel, [data-toggle-panel] { display: none !important; }
  .cal-grid { --gutter: 40px; }
  .cal-hour span { right: 4px; font-size: 10px; }
  .cal-dayhead { flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; }
  .cal-grid.is-week .ev-meta { display: none; }
  .cal-grid.is-week .ev { padding: 2px 3px; }
  .cal-grid.is-week .ev-title { font-size: 10px; }
  .mgrid { grid-template-rows: repeat(var(--weeks), minmax(72px, 1fr)); }
  .mev-time { display: none; }
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .cal-sets { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; max-width: 100%; }
  .cal-title { font-size: 16px; }
  .cal-allday .cal-gutter { font-size: 9px; padding-right: 4px; }
}

/* Strook boven de dag (FR-04): gepland zonder kloktijd, dezelfde set als Horizons */
a.plan-chip { display: block; color: inherit; text-decoration: none; cursor: pointer; border-color: var(--color-border-strong); background: var(--color-bg-surface); }
a.plan-chip::before { content: '◇ '; color: var(--color-text-subtle); }
.plan-chip[data-plan-kind="todoist"], .plan-chip[data-plan-href] { cursor: pointer; }
.plan-more, .plan-late { display: block; padding: 0 6px; font: 600 10px/1.6 var(--font-body); color: var(--color-text-muted); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-late { color: var(--color-status-paused-solid); }
