.calendar-page{display:grid;gap:var(--s5)}
.calendar-toolbar,.calendar-navigation,.calendar-view-controls,.calendar-legend,.calendar-event-actions,.calendar-day-actions,.calendar-plan-pause{display:flex;align-items:center;gap:var(--s3);flex-wrap:wrap}
.calendar-toolbar{justify-content:space-between}.calendar-navigation{gap:var(--s2);flex-wrap:nowrap}.calendar-navigation h2{font-size:var(--text-lg);margin:0;min-width:0}.calendar-navigation .icon-btn{flex-shrink:0}
.calendar-mode{display:flex;border:1px solid var(--border);border-radius:var(--r2);padding:var(--s1);background:var(--surface-input)}
.calendar-mode button{min-height:44px;padding:var(--s2) var(--s3);border:0;border-radius:var(--r1);background:transparent;color:var(--text-secondary);font:inherit;cursor:pointer}.calendar-mode button.is-selected{background:var(--surface-elevated);color:var(--text-primary)}
.calendar-layout{display:grid;gap:var(--s5);align-items:start}.calendar-board{padding:var(--s2);overflow:hidden}.calendar-weekdays,.calendar-days{display:grid;grid-template-columns:repeat(7,minmax(0,1fr))}.calendar-weekdays span{text-align:center;font-size:var(--text-xs);color:var(--text-muted);padding:var(--s3) 0;font-weight:600}
.calendar-day{display:flex;flex-direction:column;gap:var(--s1);min-width:0;min-height:70px;padding:var(--s2) var(--s1);border:1px solid transparent;border-top-color:var(--border);border-radius:var(--r1);background:transparent;color:var(--text-primary);font:inherit;text-align:left;cursor:pointer}
.calendar-day:hover{background:var(--surface-elevated)}.calendar-day.is-selected{border-color:var(--accent);background:var(--surface-elevated)}.calendar-day.is-today .calendar-day-number{background:var(--accent);color:var(--background);border-radius:50%}.calendar-day.outside-month .calendar-day-number{color:var(--text-muted)}.calendar-day.is-today.outside-month .calendar-day-number{color:var(--background)}
.calendar-day-number{display:grid;place-items:center;width:28px;height:28px;align-self:center;font-size:var(--text-sm);font-variant-numeric:tabular-nums}.calendar-day-items{display:flex;justify-content:center;gap:2px;flex-wrap:wrap}.calendar-marker{display:inline-flex;align-items:center;gap:var(--s1);color:var(--accent);min-width:0}.calendar-marker span{display:none}.calendar-marker.is-completed{color:var(--success)}.calendar-marker.is-pause{color:var(--text-secondary)}.calendar-more{font-size:10px;color:var(--text-muted)}
.calendar-legend{padding:var(--s3) var(--s2);font-size:var(--text-xs);color:var(--text-secondary);gap:var(--s3)}.calendar-legend span{display:flex;align-items:center;gap:var(--s1)}
.calendar-detail{min-width:0;display:grid;gap:var(--s3)}.calendar-detail .section-title{margin-bottom:0}.calendar-detail .section-title h2{font-size:var(--text-lg)}.calendar-event{padding:var(--s4)}.calendar-event-heading{display:flex;align-items:center;gap:var(--s3)}.calendar-event-heading>div{min-width:0}.calendar-event h3{font-size:var(--text-base);overflow-wrap:anywhere;margin:var(--s1) 0}.calendar-event-icon{display:grid;place-items:center;width:36px;height:36px;border-radius:var(--r1);background:var(--surface-input);color:var(--accent);flex-shrink:0}.calendar-event.is-pause .calendar-event-icon{color:var(--text-secondary)}.calendar-event-actions{margin-top:var(--s3)}.calendar-event-actions .btn{font-size:var(--text-sm);padding-inline:var(--s3)}.calendar-day-actions>*{flex:1}.calendar-plan-pause>div{flex:1;min-width:160px}.calendar-plan-pause p{margin:var(--s2) 0 0}
.calendar-context h2{font-size:var(--text-lg)}.calendar-totals{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--s4);margin:var(--s4) 0}.calendar-totals span{display:flex;flex-direction:column;gap:var(--s1);font-size:var(--text-xs);color:var(--text-secondary)}.calendar-totals strong{color:var(--text-primary);font-size:var(--h2);font-variant-numeric:tabular-nums}
@media(min-width:760px){.calendar-board{padding:var(--s4)}.calendar-day{min-height:112px;padding:var(--s2)}.calendar-day-number{align-self:flex-start}.calendar-day-items{flex-direction:column;align-items:stretch;justify-content:flex-start;flex-wrap:nowrap}.calendar-marker{font-size:var(--text-xs);line-height:1.5}.calendar-marker span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.calendar-marker svg{flex-shrink:0}.calendar-totals{grid-template-columns:repeat(4,minmax(0,1fr))}.calendar-week .calendar-day{min-height:180px}.calendar-navigation h2{font-size:var(--h3)}}
@media(min-width:1200px){.calendar-layout{grid-template-columns:minmax(0,1fr) minmax(260px,320px)}.calendar-detail{position:sticky;top:var(--s5)}}

/* Native date/time controls have an intrinsic minimum width in iOS WebKit. */
#calendar-entry-form .calendar-native-fields,#calendar-series-form .calendar-native-fields,#schedule-form .calendar-native-fields{grid-template-columns:repeat(2,minmax(0,1fr));align-items:start}
#calendar-entry-form label,#calendar-series-form label,#schedule-form .calendar-native-fields>label{min-width:0;max-width:100%}
#calendar-entry-form input[type=date],#calendar-entry-form input[type=time],#calendar-series-form input[type=date],#calendar-series-form input[type=time],#schedule-form input[type=time]{display:block;width:100%;min-width:0;max-width:100%;box-sizing:border-box;min-inline-size:0;inline-size:100%;padding-inline:10px;min-height:48px}
#calendar-entry-form input::-webkit-date-and-time-value,#calendar-series-form input::-webkit-date-and-time-value,#schedule-form input::-webkit-date-and-time-value{min-width:0;text-align:left}
#schedule-form .calendar-reminder-fields{grid-template-columns:minmax(0,1fr) minmax(0,130px)}
.calendar-series-row{display:flex;gap:var(--s3);flex-wrap:wrap;justify-content:space-between;border-top:1px solid var(--border);padding-block:var(--s4)}.calendar-series-row>div{min-width:0}.calendar-series-row p{margin-block:var(--s2)}
.calendar-slots{border:0;padding:0;margin:0;min-width:0}.calendar-slots legend{margin-bottom:var(--s3)}.calendar-slot{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.4fr);gap:var(--s3);align-items:center;margin-bottom:var(--s2)}.calendar-slot>label{display:flex;gap:var(--s2);align-items:center}.calendar-slot select{min-width:0;width:100%;max-width:100%}
.calendar-recovery{margin-bottom:var(--s4)}.calendar-recovery h2{font-size:var(--h3)}.calendar-recovery details{margin-block:var(--s3)}.calendar-recovery summary{cursor:pointer;min-height:44px;display:flex;align-items:center;color:var(--accent)}.calendar-change-json{white-space:pre-wrap;overflow-wrap:anywhere;max-width:100%;font-size:var(--text-xs)}
@media(max-width:359px){#calendar-entry-form .calendar-native-fields,#calendar-series-form .calendar-native-fields,#schedule-form .calendar-native-fields{grid-template-columns:minmax(0,1fr)}.calendar-slot{grid-template-columns:minmax(0,1fr)}}
.calendar-page{gap:var(--s4);grid-template-columns:minmax(0,1fr);min-width:0}
.calendar-layout{grid-template-columns:minmax(0,1fr)}
@media(min-width:1200px){.calendar-layout{grid-template-columns:minmax(0,1fr) minmax(260px,320px)}}
.calendar-page>.calendar-heading{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--s3);margin:0}
.calendar-heading h1{margin:0}.calendar-heading>.btn{min-height:44px;max-width:100%;white-space:normal;padding:var(--s3) var(--s4)}
.calendar-page h2,.calendar-totals span{overflow-wrap:anywhere}
.calendar-series-list .btn,.calendar-context .btn{max-width:100%;white-space:normal;text-align:center}
.calendar-day-number{width:min(100%,2em)}
.calendar-board{min-width:0;overflow:visible}
.calendar-board>.calendar-toolbar{padding:var(--s2);margin-bottom:var(--s2);border-bottom:1px solid var(--border);gap:var(--s2) var(--s3)}
.calendar-board .calendar-navigation{min-width:0;max-width:100%;gap:var(--s1)}
.calendar-board .calendar-navigation h2{font-size:var(--text-base);line-height:1.35;overflow-wrap:anywhere}
.calendar-board .calendar-navigation .icon-btn{min-width:44px;min-height:44px}
.calendar-board .calendar-view-controls{margin-left:auto;gap:var(--s2);max-width:100%}
.calendar-view-controls>.text-btn{min-width:44px;min-height:44px;padding:var(--s2)}
.calendar-label-short{display:none}
.calendar-board .calendar-mode button{padding:var(--s2);min-width:44px}
.calendar-board .calendar-mode{flex-wrap:wrap;min-width:0;max-width:100%}
@media(max-width:759px){.calendar-label-full{display:none}.calendar-label-short{display:inline}.calendar-board .calendar-navigation h2{font-size:var(--text-sm)}.calendar-board>.calendar-toolbar{padding:var(--s1);gap:var(--s1) var(--s2)}.calendar-view-controls{font-size:var(--text-sm)}.calendar-day{padding-inline:0}}
/* Same native modal, anchored to the visible viewport, including an open keyboard. */
#modal.calendar-day-sheet[open]{position:fixed;inset:auto 0;top:calc(var(--dialog-visible-top,0px) + var(--dialog-visible-height,100dvh));bottom:auto;transform:translateY(-100%);margin:0 auto;width:100%;max-width:720px;max-height:calc(var(--dialog-visible-height,100dvh) - max(12px,env(safe-area-inset-top,0px)));border-radius:var(--r3) var(--r3) 0 0}
.calendar-day-sheet .modal-header{padding:var(--s4) max(var(--s4),env(safe-area-inset-right,0px)) var(--s4) max(var(--s4),env(safe-area-inset-left,0px));gap:var(--s3)}
.calendar-day-sheet .modal-header h2{font-size:var(--text-lg);margin:0}
.calendar-day-sheet .modal-body{display:grid;align-content:start;gap:var(--s3);padding:var(--s4) max(var(--s4),env(safe-area-inset-right,0px)) max(var(--s5),env(safe-area-inset-bottom,0px)) max(var(--s4),env(safe-area-inset-left,0px));overscroll-behavior:contain}
.calendar-day-sheet .calendar-day-actions{flex-wrap:wrap}.calendar-day-sheet .calendar-day-actions>.btn{min-width:130px;white-space:normal;text-align:center}
