/* Calendário (cal-) */
.cal {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 12px var(--gutter-r) 24px var(--gutter-l);
  display: flex; flex-direction: column; gap: 10px;
}
.cal-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.cal-title { margin: 0; font: 700 26px/1.1 var(--font-display); letter-spacing: .01em; min-width: 9ch; }
.cal-nav { display: inline-flex; gap: 4px; }
.cal-btn {
  min-width: 36px; height: 34px; padding: 0 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); border-radius: var(--r); font-weight: 600;
}
.cal-btn:hover { border-color: var(--accent); color: var(--accent); }
.cal-btn:focus-visible, .cal-chip:focus-visible, .cal-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-note { margin: 0 0 0 auto; color: var(--muted); font-size: 13px; }

/* Legenda das obras */
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.cal-leg {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; height: 30px; padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--obra) 40%, var(--line)); border-radius: 999px;
  background: color-mix(in srgb, var(--obra) 12%, var(--card)); color: var(--fg); font-size: 13px; font-weight: 600;
}
.cal-leg:hover { border-color: var(--obra); }
.cal-leg:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-leg-dot { width: 10px; height: 10px; flex: none; border-radius: 3px; background: var(--obra); }
.cal-leg-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
.cal-leg-c { font: 500 12px var(--font-mono); color: var(--muted); }
.cal-leg.is-off { opacity: .45; background: transparent; border-style: dashed; }
.cal-leg.is-off .cal-leg-n { text-decoration: line-through; }
.cal-leg.is-off .cal-leg-dot { background: transparent; box-shadow: inset 0 0 0 2px var(--obra); }

.cal-grid-wrap { display: flex; flex-direction: column; flex: 1 0 auto; }
.cal-wd { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-bottom: 4px; }
.cal-wd span { font: 600 12px var(--font-body); text-transform: uppercase; color: var(--muted); padding: 0 6px; letter-spacing: .04em; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(110px, auto); gap: 4px; flex: 1 0 auto;
}
.cal-day {
  min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 4px 4px 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.cal-day.is-out { background: transparent; }
.cal-day.is-out .cal-dnum { color: var(--muted); opacity: .6; }
.cal-dnum { font: 500 12px var(--font-mono); font-variant-numeric: tabular-nums; padding: 1px 4px; align-self: flex-start; border-radius: 4px; }
.cal-day.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.is-today .cal-dnum { background: var(--accent); color: var(--accent-fg); }
.cal-list { display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-height: 24px; }

.cal-chip {
  display: flex; align-items: center; gap: 4px; width: 100%; min-width: 0;
  padding: 3px 6px; border: 1px solid transparent; border-left: 3px solid var(--obra, var(--line)); border-radius: 4px;
  background: color-mix(in srgb, var(--obra, var(--muted)) 16%, var(--card));
  color: var(--fg); font-size: 12px; line-height: 1.3; text-align: left;
  touch-action: manipulation;
}
.cal-chip:hover { border-color: var(--obra, var(--accent)); background: color-mix(in srgb, var(--obra, var(--muted)) 26%, var(--card)); }
.cal-chip-t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip-overdue { border-top-color: var(--danger); border-right-color: var(--danger); border-bottom-color: var(--danger); font-weight: 600; }
.cal-late {
  flex: none; display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  background: var(--danger); color: var(--accent-fg); font: 700 11px/1 var(--font-body);
}
.cal-chip-soon { font-weight: 600; }
.cal-chip-done { opacity: .55; }
.cal-chip-done .cal-chip-t { text-decoration: line-through; color: var(--muted); }
.cal-dots { display: inline-flex; gap: 2px; flex: none; }
.cal-dot { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--card); box-sizing: content-box; }
.cal-more {
  align-self: flex-start; border: 0; background: none; color: var(--accent);
  font-size: 12px; font-weight: 600; padding: 1px 4px; border-radius: 4px;
}
.cal-more:hover { background: var(--accent-soft); }
.cal-ghost { opacity: .4; }
.cal-chosen { border-color: var(--accent); }
.cal-drag { box-shadow: var(--shadow-lift); }

.cal-agenda { display: none; flex-direction: column; gap: 12px; }
.cal-ag-head { margin: 0 0 4px; font: 600 13px var(--font-mono); color: var(--muted); }
.cal-ag-day.is-today .cal-ag-head { color: var(--accent); }
.cal-ag-list .cal-chip { padding: 8px 10px; font-size: 14px; }
.cal-empty { color: var(--muted); margin: 8px 0; }

@media (max-width: 700px) {
  .cal-grid-wrap { display: none; }
  .cal-agenda { display: flex; }
  .cal-note { margin-left: 0; flex-basis: 100%; }
  .cal-title { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .cal * { transition: none !important; animation: none !important; }
}
