.plan-hours{grid-template-columns:1fr 1fr;gap:14px}.plan-advanced{margin:17px 0;border-top:1px solid var(--line);border-bottom:1px solid var(--line)}.plan-advanced>summary{padding:15px 3px;min-height:48px;font-size:13px;cursor:pointer;color:var(--muted)}.plan-advanced-fields{padding:7px 0 18px;display:flex;flex-direction:column;gap:13px}.plan-advanced-fields>.field{margin:0}.auto-plan-list{display:flex;flex-direction:column;gap:10px;margin:22px 0}.auto-plan-row{display:flex;align-items:center;gap:13px;border-radius:18px;padding:11px;background:var(--surface-2)}.auto-plan-row>div{min-width:0}.auto-plan-row strong{font-size:14px;line-height:1.5;overflow-wrap:anywhere}.auto-plan-row p{font-size:12px;color:var(--muted);margin-top:4px;font-variant-numeric:tabular-nums}.auto-plan-row .calendar-event-icon{width:48px;min-width:48px;height:50px;border-radius:15px}.auto-plan-overflow{margin-top:20px;padding-top:12px;border-top:1px solid var(--line)}.auto-plan-overflow>summary{min-height:44px;font-size:13px;cursor:pointer}.auto-plan-overflow>p{margin:10px 0 16px;font-size:12px;line-height:1.65}.routine-switch{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:54px;margin:12px 0;font-size:13px}.routine-switch>span{display:flex;align-items:center;gap:10px;min-width:0}.routine-switch svg{color:var(--muted);flex-shrink:0}.routine-switch>input{width:23px;height:23px;min-width:23px;accent-color:var(--accent);cursor:pointer}.routine-switch:has(input:focus-visible){outline:2px solid var(--accent);outline-offset:5px;border-radius:8px}

.sheet:has(.plan-hours) .sheet-content > .segmented{margin-bottom:18px}
/* One continuous, readable day. The page itself owns scrolling. */
#app[data-view="calendar"]{max-width:900px}
#app[data-view="calendar"] .page-heading{display:flex;align-items:center;justify-content:space-between;margin:0 0 12px}
#app[data-view="calendar"] .page-heading h1{font-size:28px;letter-spacing:-.8px}
#app[data-view="calendar"] .page-heading .icon-btn{background:var(--surface-2);color:var(--text);border-radius:15px}
.calendar-navigation{margin-bottom:18px}
.calendar-month-picker{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;min-height:44px}
.calendar-month-picker .compact-date{margin:0;max-width:100%;flex:1}
.calendar-month-picker .date-trigger{background:transparent;border:0;padding-left:0;justify-content:flex-start;min-height:44px;font-size:15px;text-transform:capitalize;max-width:100%}
.calendar-week-strip{display:flex;align-items:center;gap:2px}
.calendar-week-strip>.icon-btn{min-width:27px;width:27px;height:52px;border-radius:10px}
.calendar-week-strip>.icon-btn svg{width:18px}
.calendar-week-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));flex:1;gap:4px;min-width:0}
.calendar-week-day{display:flex;flex-direction:column;align-items:center;gap:4px;border-radius:17px;min-width:0;padding:9px 0 7px;min-height:72px}
.calendar-week-day>span{font-size:11px;color:var(--muted)}
.calendar-week-day>strong{font-size:17px;font-weight:600;line-height:24px;width:29px;height:29px;display:grid;place-items:center;border-radius:50%}
.calendar-week-day.selected{background:var(--accent-soft)}
.calendar-week-day.selected>strong{color:var(--text)}
.calendar-week-day.today>strong{background:var(--accent);color:var(--accent-contrast)}
.calendar-week-day>i{width:4px;height:4px;border-radius:50%;background:transparent}
.calendar-week-day>i.has-plan{background:var(--accent)}
/* Event-based agenda: short entries stay readable, longer entries stretch the capsule. */
.day-agenda{--time-width:54px;--track-width:70px;background:var(--surface);border-radius:26px;padding:18px 20px 24px;min-width:0}
.day-agenda[data-swipe-days="true"]{touch-action:pan-y pinch-zoom}
.agenda-boundary{display:grid;grid-template-columns:var(--time-width) 1fr;gap:12px;align-items:center;color:var(--muted);padding:8px 0 22px;font-size:13px}
.agenda-boundary time{font-size:12px;font-variant-numeric:tabular-nums}
.agenda-end{padding-top:22px;padding-bottom:0}
.agenda-event{display:grid;grid-template-columns:var(--time-width) var(--track-width) minmax(0,1fr) 46px;position:relative;min-height:calc(var(--event-height,102px) + 24px);isolation:isolate}
.agenda-time{display:flex;flex-direction:column;justify-content:space-between;align-items:flex-start;padding:12px 0;font-size:13px;font-weight:500;font-variant-numeric:tabular-nums;line-height:1.4;color:var(--text)}
.agenda-time>span{font-size:12px;color:var(--muted)}
.agenda-track{position:relative;display:flex;justify-content:center;align-items:stretch;padding:12px 0}
.agenda-track:before{content:'';position:absolute;top:0;bottom:0;left:calc(50% - 1px);width:2px;background:var(--line);z-index:-1}
.agenda-icon{padding:0;align-self:stretch;min-height:var(--event-height,102px);width:60px;min-width:60px;border-radius:999px;display:grid;place-items:center;background:var(--surface-3);background:color-mix(in srgb,var(--event-color) 24%,var(--surface));color:var(--text);border:0;box-shadow:none;position:relative}
.agenda-icon svg{width:29px;height:29px;flex:none}
.agenda-content{align-self:center;padding:18px 14px;min-width:0}
.agenda-title{display:block;text-align:left;padding:0;width:100%;min-height:48px}
.agenda-title h3{font-size:18px;font-weight:600;line-height:1.4;letter-spacing:-.25px;overflow-wrap:anywhere;margin-top:4px}
.agenda-duration{font-size:13px;font-variant-numeric:tabular-nums;color:var(--muted);line-height:1.6}
.agenda-progress{font-size:12px;color:var(--muted);line-height:1.6;margin-top:5px}
.agenda-event .agenda-action{width:44px;min-width:44px;height:48px;margin:0;color:var(--event-color);align-self:center;display:grid;place-items:center;background:transparent;border:0}
.agenda-action .empty-circle{width:26px;height:26px;border-width:2px;border-color:var(--event-color)}
.agenda-event.is-complete .agenda-title h3{color:var(--text)}
.agenda-event.is-complete .agenda-icon{background:var(--green-soft)}
.agenda-routine-mark{align-self:center;text-align:center;color:var(--muted)}
.agenda-event.is-routine .agenda-title h3{color:var(--text)}
.agenda-collision{font-size:12px;line-height:1.5;color:var(--yellow);margin-top:7px}
.agenda-gap{display:grid;grid-template-columns:var(--time-width) var(--track-width) minmax(0,1fr);min-height:100px;isolation:isolate}
.agenda-gap .agenda-track{padding:0}
.agenda-gap .agenda-track:before{background:none;border-left:2px dashed var(--line)}
.agenda-gap .agenda-time{padding:14px 0}
.agenda-gap-body{padding:22px 14px;text-align:left;align-self:stretch;display:flex;flex-direction:column;justify-content:center;gap:8px;min-width:0;color:var(--muted)}
.agenda-gap-body>span{font-size:14px;line-height:1.6}
.agenda-gap-body>span svg{margin-right:4px;color:var(--accent-ink)}
.agenda-gap-body strong{font-weight:500;color:var(--text)}
.agenda-gap-body>small{font-size:12px;color:var(--accent-ink);display:flex;gap:6px;align-items:center}
.agenda-gap-body:hover{color:var(--text);background:var(--surface-2);border-radius:14px}
.calendar-menu-actions{border-top:1px solid var(--line);padding-top:12px;margin-top:12px;display:grid;gap:5px}
.calendar-view-menu{margin-bottom:0}
.calendar-unscheduled{margin:20px 0}
.calendar-below{margin:22px 0 0;padding:20px;border:1px solid var(--line);border-radius:25px;background:var(--surface)}
.calendar-below-heading h2{font-size:18px;margin:0 0 5px}
.calendar-below-heading p{font-size:12px;line-height:1.5;color:var(--muted);margin:0}
.calendar-quick-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin:17px 0 22px}
.calendar-quick-actions .btn{white-space:normal;text-align:center;min-height:50px}
.calendar-unscheduled-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;border-top:1px solid var(--line);padding-top:15px;margin-bottom:11px}
.calendar-unscheduled-heading h3{font-size:14px;margin:0}
.calendar-unscheduled-heading .btn{white-space:normal;text-align:right;font-size:12px}
.calendar-candidates{display:grid;gap:13px}
.calendar-candidate{min-width:0}
.calendar-candidate>.btn{margin:7px 0 0 auto;display:flex;width:max-content;max-width:100%}
.calendar-candidate .task-card{margin:0}
.calendar-event-icon{position:relative;display:grid;place-items:center;width:54px;height:56px;min-width:54px;border:0;border-radius:18px;background:var(--surface-3);background:color-mix(in srgb,var(--event-color,var(--accent)) 18%,var(--surface));color:var(--text)}
.calendar-event-icon>svg{width:30px;height:30px}
.calendar-month{padding:22px 12px;background:var(--surface);border-radius:24px}
.calendar-month>h2{text-align:center;font-size:18px;margin-bottom:20px;text-transform:capitalize}
.calendar-month-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:7px 3px}
.calendar-weekday{text-align:center;font-size:11px;color:var(--muted);padding:5px 0}
.calendar-month-cell{display:flex;align-items:center;justify-content:center;flex-direction:column;gap:6px;min-width:0;min-height:60px;padding:6px 0;border:1px solid transparent;border-radius:14px}
.calendar-month-cell>strong{font-size:15px;font-weight:500;line-height:1}
.calendar-month-cell.today{border-color:var(--accent-border)}
.calendar-month-cell.selected{background:var(--accent);color:var(--accent-contrast)}
.calendar-month-count{font-size:10px;min-width:17px;height:17px;border-radius:6px;background:color-mix(in srgb,currentColor 12%,transparent)}
.calendar-month-empty{height:17px}
.calendar-month>p{margin:15px 5px 0;font-size:11px;line-height:1.6}
@media(max-width:560px){
 #app[data-view="calendar"]{padding:20px 16px 164px}
 #app[data-view="calendar"] .page-heading h1{font-size:25px}
 .calendar-week-days{gap:1px}.calendar-week-day{border-radius:14px}.calendar-week-day>strong{font-size:16px}
 .routine-switch{font-size:12px;line-height:1.6}.auto-plan-row strong{font-size:13px}.auto-plan-row p{font-size:11px}
 .calendar-below{padding:18px 13px 20px;margin-top:16px;border-radius:22px}
 .calendar-quick-actions{gap:7px}.calendar-quick-actions .btn{font-size:11px;padding:9px 8px}
}
.calendar-month-heading{display:grid;grid-template-columns:44px 1fr 44px;align-items:center;gap:8px;margin-bottom:16px}.calendar-month-heading h2{text-align:center;font-size:16px;text-transform:capitalize}.calendar-month-heading .icon-btn{background:var(--surface-2)}

.plan-repeat{padding:16px;border:1px solid var(--line);border-radius:18px;margin:18px 0;background:var(--surface-2)}
.plan-repeat .field{margin:0 0 14px}
.plan-repeat .field:last-child{margin-bottom:0}
.plan-repeat-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:5px;margin:12px 0 16px}
.plan-repeat-days label{position:relative;text-align:center;cursor:pointer}
.plan-repeat-days input{position:absolute;opacity:0;inset:0;width:100%;height:100%}
.plan-repeat-days span{display:grid;place-items:center;min-height:44px;border-radius:11px;border:1px solid var(--line);font-size:12px}
.plan-repeat-days input:checked+span{background:var(--accent);color:var(--accent-contrast);border-color:var(--accent)}
.plan-repeat-days input:focus-visible+span{outline:2px solid var(--accent-ink);outline-offset:2px}
.plan-repeat-note{line-height:1.65;font-size:13px;margin:12px 0;color:var(--muted)}
.plan-series-actions{display:grid;gap:10px;margin:18px 0}
.plan-advanced-fields{display:grid;gap:16px;padding-top:16px}

@media(max-width:560px){
 .day-agenda{--time-width:42px;--track-width:56px;padding:14px 10px 20px;border-radius:24px}
 .agenda-event{grid-template-columns:var(--time-width) var(--track-width) minmax(0,1fr) 44px}
 .agenda-time{font-size:12px}.agenda-time>span{font-size:11px}
 .agenda-icon{width:48px;min-width:48px;box-shadow:none}.agenda-icon svg{width:27px;height:27px}
 .agenda-content{padding:16px 9px}.agenda-title h3{font-size:16px;line-height:1.45}
 .agenda-duration,.agenda-progress{font-size:12px}
 .agenda-event .agenda-action{width:44px;min-width:44px;height:48px}.agenda-action .empty-circle{width:24px;height:24px}
 .agenda-routine-mark svg{width:17px}.agenda-collision{font-size:11px}
 .agenda-gap-body{padding:20px 9px}.agenda-gap-body>span{font-size:13px}.agenda-gap-body>small{font-size:12px}
 .agenda-boundary{font-size:12px;gap:7px}.agenda-boundary time{font-size:11px}
}

/* The agenda is a single surface in either theme, including its untimed rows.
   Scope these rules to the agenda so legacy dark component styles cannot make
   a light page contain dark cards or pale text. Solid colors are the fallback
   for Android WebViews without color-mix support. */
#app[data-view="calendar"] .day-agenda,
#app[data-view="calendar"] .flexible-pending,
.agenda-event.drag-ghost {
 background:var(--surface);
 color:var(--text);
 border:1px solid var(--line);
 box-shadow:none;
}
:is(.day-agenda,.flexible-pending,.agenda-event.drag-ghost) .agenda-content {
 background:transparent;
 color:var(--text);
}
:is(.day-agenda,.flexible-pending,.agenda-event.drag-ghost) .agenda-title,
:is(.day-agenda,.flexible-pending,.agenda-event.drag-ghost) .agenda-title h3,
:is(.day-agenda,.flexible-pending) .agenda-event:is(.is-routine,.is-complete) .agenda-title h3 {
 color:var(--text);
}
:is(.day-agenda,.flexible-pending,.agenda-event.drag-ghost) :is(.agenda-duration,.agenda-progress,.agenda-boundary,.agenda-routine-mark,.calendar-reorder-hint,.flexible-day-summary) {
 color:var(--muted);
}
:is(.day-agenda,.flexible-pending,.agenda-event.drag-ghost) .agenda-time { color:var(--text); }
:is(.day-agenda,.flexible-pending,.agenda-event.drag-ghost) .agenda-time>span { color:var(--muted); }
:is(.day-agenda,.flexible-pending,.agenda-event.drag-ghost) .agenda-track:before { background:var(--line); }
:is(.day-agenda,.flexible-pending,.agenda-event.drag-ghost) .agenda-icon {
 background:var(--surface-3);
 background:color-mix(in srgb,var(--event-color,var(--accent)) 20%,var(--surface));
 color:var(--text);
 border:1px solid var(--event-color,var(--accent));
 box-shadow:none;
}
:is(.day-agenda,.flexible-pending) .agenda-event.is-complete .agenda-icon {
 background:var(--completion-surface,var(--surface-3));
 color:var(--success);
 border-color:var(--success);
 box-shadow:none;
}
:is(.day-agenda,.flexible-pending) .agenda-event .agenda-action { color:var(--accent-ink); }
:is(.day-agenda,.flexible-pending) .agenda-action .empty-circle { border-color:currentColor; }
:is(.day-agenda,.flexible-pending) .agenda-event.is-complete .agenda-action {
 color:var(--success);
 background:var(--completion-surface,var(--surface-3));
}
:is(.day-agenda,.flexible-pending) .agenda-completed-label { color:var(--success); }
:is(.day-agenda,.flexible-pending) .agenda-gap .agenda-track:before { background:none; border-color:var(--line); }
:is(.day-agenda,.flexible-pending) .agenda-gap-body { color:var(--muted); }
:is(.day-agenda,.flexible-pending) .agenda-gap-body strong { color:var(--text); }
:is(.day-agenda,.flexible-pending) .agenda-gap-body>span svg,
:is(.day-agenda,.flexible-pending) .agenda-gap-body>small,
:is(.day-agenda,.flexible-pending) .flexible-set-time { color:var(--accent-ink); }
:is(.day-agenda,.flexible-pending) .agenda-gap-body:hover { background:var(--surface-2); }
:is(.day-agenda,.flexible-pending) .agenda-collision { color:var(--yellow); }

/* Large system text needs a wider clock column rather than touching the icon
   or the beginning/end-of-day labels. This follows the actual digit width. */
.day-agenda:not(.flexible-day){--time-width:max(54px,3.8ch)}
.day-agenda:not(.flexible-day)>.agenda-event{--time-width:inherit;--track-width:inherit;grid-template-columns:var(--time-width) var(--track-width) minmax(0,1fr) 46px}
.day-agenda:not(.flexible-day)>.agenda-gap{grid-template-columns:var(--time-width) var(--track-width) minmax(0,1fr)}
@media(max-width:560px){
 .day-agenda:not(.flexible-day){--time-width:max(42px,3.8ch);--track-width:52px}
 .day-agenda:not(.flexible-day)>.agenda-event{grid-template-columns:var(--time-width) var(--track-width) minmax(0,1fr) 44px}
}
@media(max-width:360px){.day-agenda:not(.flexible-day){--track-width:47px}}

/* At a narrow width with enlarged text, give the title the action column too.
   The completion action follows the description, so no words need clipping. */
.day-agenda:not(.flexible-day){container-name:calendar-day;container-type:inline-size}
@container calendar-day (max-width:12em){
 .day-agenda:not(.flexible-day)>.agenda-event>.agenda-time{grid-column:1;grid-row:1 / span 2}
 .day-agenda:not(.flexible-day)>.agenda-event>.agenda-track{grid-column:2;grid-row:1 / span 2}
 .day-agenda:not(.flexible-day)>.agenda-event>.agenda-content{grid-column:3 / -1;grid-row:1}
 .day-agenda:not(.flexible-day)>.agenda-event>:is(.agenda-action,.agenda-routine-mark){grid-column:3 / -1;grid-row:2;justify-self:end;margin-bottom:12px}
}
