.calendar-view {
  display: none;
  position: relative;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  grid-template-rows: auto auto minmax(0, 1fr);
  /* The rows were written as minmax(0, 1fr) and the column was left implicit,
     which is not the same default: an implicit track is `auto`, whose minimum
     is MIN-CONTENT, so the single column grows past the element whenever the
     content cannot fit — and `overflow: hidden` above then cuts the excess
     rather than scrolling it. Measured on a phone: a 343px view with a 349px
     column, so 6px of every row was gone. Stating the column the same way the
     rows are stated is the fix at every width; where there is room it behaves
     exactly as before. */
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.media-panel.calendar-mode .calendar-view { display: grid; }

/* ── Agenda as a standalone Bento widget ──────────────────────
   Calendar/Tasks/Timer moved out of the media panel into their own
   .agenda-panel. The legacy media↔calendar toggle is retired; the
   calendar view is always shown here and fills the tile. The mini
   now-playing (calendar-top) is redundant beside the Media tile. */
.agenda-panel {
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.agenda-panel .calendar-view {
  display: grid;
  flex: 1 1 auto;
  grid-template-rows: auto minmax(0, 1fr);
}
.agenda-panel .calendar-top { display: none; }

.calendar-top,
.calendar-nav,
.event-form-row,
.event-item-top,
.calendar-mini-player {
  display: flex;
  align-items: center;
}

.calendar-top {
  min-height: 0;
}

.calendar-kicker {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.3px;
  text-transform: uppercase;
}

.calendar-title {
  margin-top: 2px;
  color: var(--text);
  font-size: 22.5px;
  font-weight: 900;
  line-height: 1;
}

.calendar-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.calendar-mini-player {
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 14px;
  border: 1px solid rgba(var(--accent-rgb),0.18);
  background: radial-gradient(100% 150% at 0% 0%, rgba(var(--accent-rgb),0.18), transparent 58%), var(--surface-alt);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 10px 26px rgba(0,0,0,0.18);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
}

.calendar-mini-player:hover {
  border-color: rgba(var(--accent-rgb),0.34);
  background: radial-gradient(100% 150% at 0% 0%, rgba(var(--accent-rgb),0.24), transparent 58%), var(--surface-alt);
}

.calendar-mini-player:active { transform: scale(0.992); }

.calendar-mini-player:not(.show) { display: none; }

.mini-now {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-cover {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: linear-gradient(145deg, rgba(var(--accent-rgb),0.18), color-mix(in srgb, var(--color-info), transparent 88%)), var(--surface-alt);
  background-size: cover;
  background-position: center;
  box-shadow: 0 8px 20px rgba(0,0,0,0.26);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.mini-cover.has-image .mini-pulse { display: none; }

.mini-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px rgba(var(--accent-rgb),0.58);
  flex-shrink: 0;
}

.mini-title {
  color: var(--text);
  font-size: 14.5px;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-sub {
  color: var(--muted-text);
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.mini-action {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--control-bg);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.mini-action svg { width: 14px; height: 14px; fill: currentColor; }

.calendar-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 6px;
  padding: 9px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
  background: var(--surface-alt);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.calendar-nav { justify-content: space-between; gap: 10px; }

.calendar-month {
  color: var(--text);
  font-size: 15.5px;
  font-weight: 900;
  text-transform: capitalize;
}

.calendar-nav-actions { display: flex; gap: 6px; }

.calendar-arrow {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  background: var(--control-bg);
  color: var(--text);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.16s ease, border-color 0.16s ease;
}
.calendar-arrow:hover { background: rgba(var(--accent-rgb),0.10); border-color: rgba(var(--accent-rgb),0.30); }
.calendar-arrow svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekdays span {
  color: var(--dim-text);
  font-size: 10px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.calendar-days {
  min-height: 0;
  grid-template-rows: repeat(var(--calendar-weeks, 5), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}

.day-cell {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  position: relative;
  font-size: 13.5px;
  line-height: 1;
  font-weight: 850;
  display: grid;
  place-items: center;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.day-cell:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb),0.28);
  background: rgba(var(--accent-rgb),0.055);
}

.day-cell.empty { opacity: 0; pointer-events: none; }
.day-cell.today { color: var(--green); border-color: rgba(var(--accent-rgb),0.32); }
.day-cell.selected { background: rgba(var(--accent-rgb),0.16); border-color: rgba(var(--accent-rgb),0.56); color: var(--text); }

.day-cell.has-events::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(var(--accent-rgb),0.55);
  transform: translateX(-50%);
}

.upcoming-block {
  min-height: 0;
  padding: 8px 9px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.07);
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow: hidden;
}

.upcoming-title {
  color: var(--muted-text);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.upcoming-list {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 5px;
}

.upcoming-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 5px 7px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid rgba(255,255,255,0.05);
}

.upcoming-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(var(--accent-rgb),0.5);
}

.upcoming-name {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upcoming-when {
  color: var(--green);
  font-size: 10.5px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.upcoming-list .event-empty {
  padding: 6px;
  border-radius: 9px;
  font-size: 11px;
}

/* ── Calendar / Task view toggle ────────────────────────────── */

.cal-task-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface-alt);
  border: 1px solid rgba(255,255,255,0.055);
  border-radius: 22px;
  padding: 3px;
}

.cal-task-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: none;
  border-radius: 18px;
  padding: 6px 10px;
  cursor: pointer;
  background: transparent;
  color: var(--dim-text);
  transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
  will-change: background, color;
}
/* `display: flex` above outranks the UA `[hidden]{display:none}` rule — without
   this an extracted Attività/Timer/Note tab stays clickable and opens an empty pane. */
.cal-task-btn[hidden] { display: none; }

.cal-task-btn svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cal-task-btn.active {
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--accent);
  box-shadow: 0 1px 6px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* ── Calendar / Task panes ──────────────────────────────────── */

.cal-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 8px;
  overflow: hidden;
}

.cal-pane[hidden] { display: none; }

.cal-pane .calendar-card { flex: 1; }

/* tasks pane inherits TasksPanel.css selectors — just reset outer padding */
.cal-pane .tasks-add-row,
.cal-pane .tasks-controls-row,
.cal-pane .tasks-scroll {
  flex-shrink: 0;
}

.cal-pane .tasks-scroll {
  flex: 1;
  min-height: 0;
}

/* Standalone Calendar widget (extracted from the Agenda hub) */
.calendar-panel {
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* The moved .calendar-card must FILL the tile (like it does via flex:1 inside the
   hub's .cal-pane), otherwise the month grid collapses to its minimum and the
   days render tiny instead of filling the available box. */
.calendar-panel > .calendar-card {
  flex: 1 1 auto;
  min-height: 0;
}
