/* Reference-matched task surfaces. Sampled from the supplied light/dark screenshots.
   All task surfaces inherit shared semantic roles in both themes. */
body:has(.routine-page, .routine-editor-page, .routine-detail-page) {
  --bg: inherit;
  --surface: inherit;
  --sunken: inherit;
  --oat: inherit;
  --border: inherit;
  --border-strong: inherit;
  --text: inherit;
  --text-2: inherit;
  --text-3: inherit;
  --accent: inherit;
  --accent-soft: inherit;
  --accent-strong: inherit;
  --neutral-bg: inherit;
  --routine-panel: var(--input-bg);
  --routine-tool: var(--control-bg);
  --routine-selected: var(--selected-bg);
  --routine-primary: var(--primary-bg);
  --routine-on-primary: var(--primary-fg);
  --focus-ring: inherit;
  --focus-glow: inherit;
  background: var(--bg);
  color: var(--text);
}
html[data-theme="dark"] body:has(.routine-page, .routine-editor-page, .routine-detail-page) {
  --bg: inherit;
  --surface: inherit;
  --sunken: inherit;
  --oat: inherit;
  --border: inherit;
  --border-strong: inherit;
  --text: inherit;
  --text-2: inherit;
  --text-3: inherit;
  --accent: inherit;
  --accent-soft: inherit;
  --accent-strong: inherit;
  --neutral-bg: inherit;
  --routine-panel: var(--input-bg);
  --routine-tool: var(--control-bg);
  --routine-selected: var(--selected-bg);
  --routine-primary: var(--primary-bg);
  --routine-on-primary: var(--primary-fg);
  --routine-danger: var(--danger);
  --focus-ring: inherit;
  --focus-glow: inherit;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) body:has(.routine-page, .routine-editor-page, .routine-detail-page) {
  --bg: inherit;
  --surface: inherit;
  --sunken: inherit;
  --oat: inherit;
  --border: inherit;
  --border-strong: inherit;
  --text: inherit;
  --text-2: inherit;
  --text-3: inherit;
  --accent: inherit;
  --accent-soft: inherit;
  --accent-strong: inherit;
  --neutral-bg: inherit;
  --routine-panel: var(--input-bg);
  --routine-tool: var(--control-bg);
  --routine-selected: var(--selected-bg);
  --routine-primary: var(--primary-bg);
  --routine-on-primary: var(--primary-fg);
  --routine-danger: var(--danger);
  --focus-ring: inherit;
  --focus-glow: inherit;
}
}
body:has(.routine-page, .routine-editor-page, .routine-detail-page) > main.wrap { max-width: none; padding: 24px 24px 24px; }
.routine-page, .routine-editor-page { font-family: var(--font-body); }
.routine-page { width: 100%; max-width: 1280px; margin-inline: auto; box-sizing: border-box; }
.routine-page .btn, .routine-editor-page .btn { border-radius: 8px; background: var(--control-bg, var(--surface)); color: var(--text); font-size: 14px; font-weight: 400; border-color: var(--border); box-shadow: none; }
.routine-editor-page .btn-primary { background: var(--routine-primary); border-color: var(--routine-primary); color: var(--routine-on-primary); }
.routine-page .btn:hover, .routine-editor-page .btn:hover { filter: brightness(.95); }
.routine-page { gap: 14px; }
.routine-hero { align-items: flex-start; }
.routine-title-row h1 { font-family: var(--font-heading); font-size: 18px; font-weight: 450; letter-spacing: 0; }
.routine-heading > p { margin: 4px 0 0; font-size: 14px; }
.routine-count { margin-left: 8px; font-size: 12px; }
.routine-page .routine-new-button { padding: 5px 12px; background: var(--primary-bg, var(--surface)); color: var(--primary-fg, var(--text)); border-color: var(--primary-bg, var(--border)); }
.routine-toolbar { margin-top: 14px; }
.routine-view-switch { border-radius: 8px; padding: 2px; }
.routine-view-switch button { font-size: 14px; padding: 5px 10px; }
.routine-view-switch button[aria-pressed="true"] { box-shadow: none; }
.routine-toolbar-actions { gap: 12px; }
.routine-toggle { font-size: 14px; }
.routine-filter summary { box-shadow: none; font-size: 14px; }
.routine-filter-popover { width: 275px; box-sizing: border-box; padding: 10px 8px; }
.routine-filter-popover label { position: relative; padding: 9px 12px; font-size: 15px; }
.routine-filter-popover input { position: absolute; opacity: 0; }
.routine-filter-popover label:has(input:checked)::after { content: "✓"; margin-left: auto; }
.routine-filter-popover label:has(input:focus-visible) { outline: 2px solid var(--focus-ring); }
.routine-filter-popover legend { padding: 4px 12px; }
.routine-search { width: min(380px, 26vw); }
.routine-search input { font-size: 14px; }
.routine-list { gap: 8px; }
.routine-card { display: block; position: relative; min-height: 60px; border: 0; border-radius: 12px; background: var(--task-card-bg, var(--sunken)); box-shadow: var(--task-card-outline, none); }
.routine-card:hover { background: var(--panel-bg, var(--sunken)); box-shadow: var(--task-card-outline, none); }
.routine-card-row { display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 0 14px; }
.routine-card-main { flex: 1; min-width: 0; padding: 9px 0; }
.routine-card-main h2 { margin: 0; font: inherit; font-size: 15px; font-weight: 450; line-height: 1.4; }
.routine-card-main h2 a { color: var(--text); text-decoration: none; }
.routine-card-main h2 a::after { content: ""; position: absolute; inset: 0; }
.routine-card-row > a { position: relative; z-index: 1; }
.routine-card-row > details { z-index: 1; }
.routine-card:has(.routine-row-details[open]) { z-index: 3; }
.routine-card:has(.routine-card-main h2 a:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.routine-card-main h2 a:hover { text-decoration: underline; }
.routine-row-schedule { margin: 3px 0 0; color: var(--text-3); font-size: 13px; }
.routine-row-status { display: flex; gap: 8px; }
.routine-badge, .routine-state { margin: 0; padding: 3px 7px; border-radius: 5px; background: var(--neutral-bg); color: var(--text-2); font-size: 12px; font-weight: 400; }
.routine-row-details > summary { display: grid; place-items: center; width: 30px; height: 30px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 8px; background: var(--neutral-bg); color: var(--text-2); cursor: pointer; list-style: none; }
.routine-row-details > summary:hover, .routine-row-details[open] > summary { background: var(--routine-selected); color: var(--text); }
.routine-row-details > summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.routine-row-details[open] > summary .nav-chevron { transform: rotate(-180deg); }
.routine-row-details > summary::-webkit-details-marker { display: none; }
.routine-row-info { position: absolute; z-index: 8; right: 14px; width: min(420px, calc(100% - 28px)); box-sizing: border-box; top: calc(100% + 5px); padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--overlay-bg, var(--surface)); box-shadow: var(--tooltip-shadow); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.routine-row-info p { margin: 0 0 8px; }
.routine-row-info .routine-goal { margin: 0 0 8px; }
.routine-row-info .routine-card-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; border: 0; padding: 0; margin-bottom: 8px; }
.routine-row-info .routine-card-meta strong, .routine-row-info .routine-last strong { font-size: 12px; }
.routine-row-info .routine-card-foot { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; border: 0; padding: 0; background: transparent; }
.routine-row-info .routine-card-meta strong, .routine-row-info .routine-card-meta small { white-space: normal; overflow-wrap: anywhere; }
.routine-row-info .routine-last { display: block; }
.routine-health:not(.is-stale) { margin-top: 10px; padding: 0; border: 0; background: transparent; }
.routine-health:not(.is-stale) .routine-health-icon { color: var(--text-3); }
.routine-health:not(.is-stale) strong { color: var(--text-3); font-weight: 400; }
.routine-footnote { margin-top: 0; font-size: 12px; }
.routine-week { gap: 0; }
.routine-week button { min-height: 90px; border: 0; border-radius: 10px; }
.routine-week button.is-selected { border: 0; }
.routine-week span { font-size: 14px; font-weight: 400; }
.routine-week strong { font-size: 24px; }
.routine-week small { display: none; }
.routine-calendar-days { display: grid; gap: 22px; }
.routine-calendar-day { padding: 18px 16px; border: 0; background: transparent; scroll-margin-top: 150px; }
.routine-calendar-day.is-today { background: var(--sunken); }
.routine-calendar-day h2 { font-size: 16px; font-weight: 500; }
.routine-calendar-dot, .routine-calendar-event .routine-status-dot { display: none; }
.routine-calendar-event { background: transparent; border: 0; padding: 8px 0; }
.routine-calendar-event h3 { font-weight: 450; }
.routine-calendar-event p { color: var(--text-3); }
.routine-editor-page { gap: 22px; padding-top: 0; }
.routine-editor-crumb { font-size: 15px; gap: 6px; line-height: 20px; }
.routine-editor-crumb strong { font-weight: 450; }
.routine-editor { width: min(100%, 800px); margin: 0 auto; }
.routine-editor-banner.is-readonly { background: var(--sunken); color: var(--text-2); }
.routine-editor-banner { min-height: 36px; box-sizing: border-box; margin-bottom: 20px; padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.5; }
.routine-form-linear { gap: 18px; }
.routine-linear-field, .source-form > label.routine-linear-field { gap: 6px; }
.routine-field-label { color: var(--text-3); font-size: 14px; font-weight: 400; line-height: 20px; }
.routine-form input[type="text"], .routine-form input[type="number"], .routine-form input[type="time"], .routine-form select { height: 32px; min-height: 32px; border-radius: 7px; padding: 4px 10px; font-size: 14px; }
.routine-form input::placeholder, .routine-form textarea::placeholder { color: var(--text-3); opacity: 1; }
.routine-instructions-panel { position: relative; overflow: visible; border-radius: 12px; background: var(--routine-panel); }
.routine-form .routine-instructions-panel > textarea { display: block; height: 108px; min-height: 88px; padding: 10px 11px; border: 0; border-radius: 12px 12px 0 0; background: transparent; font-size: 14px; line-height: 1.5; resize: vertical; }
.routine-form .routine-instructions-panel > textarea:focus-visible { box-shadow: inset 0 0 0 2px var(--focus-ring); }
.routine-editor-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 32px; padding: 0 12px; }
.routine-editor-tools-bottom { background: var(--routine-tool); border-radius: 0 0 11px 11px; }
.routine-config > summary { display: flex; align-items: center; gap: 6px; padding: 6px 0; color: var(--text-3); font-size: 13px; cursor: pointer; list-style: none; }
.routine-config > summary::-webkit-details-marker { display: none; }
.routine-config summary svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.routine-chevron { width: 6px; height: 6px; margin: -3px 3px 0; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.routine-config > summary:hover, .routine-config[open] > summary { color: var(--text); }
.routine-config-panel { position: absolute; left: 0; right: 0; top: calc(100% + 7px); z-index: 15; max-height: 420px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--overlay-bg, var(--surface)); box-shadow: var(--tooltip-shadow); }
.routine-instructions-panel:has(.routine-config[open]) { z-index: 2; }
.routine-toolbar-enabled { display: inline-flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 13px; cursor: pointer; }
.routine-form input[type="checkbox"], .routine-form input[type="radio"] { accent-color: var(--accent); }
.routine-toolbar-enabled input { width: 14px; height: 14px; margin: 0; }
.routine-delivery-panel { border: 0; }
.routine-config-panel .routine-choice-title { background: transparent; }
.routine-schedule-control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 0; border: 0; border-radius: 0; background: transparent; overflow: visible; }
.routine-days > div { display: inline-grid; grid-template-columns: repeat(7, 1fr); padding: 3px; border-radius: 10px; }
.routine-days span { min-height: 28px; padding: 0 6px; font-size: 13px; }
.routine-days input:checked + span { background: var(--routine-selected); box-shadow: none; }
.routine-days label:has(input:disabled) { cursor: default; }
.routine-schedule-grid { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.routine-schedule-grid > label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.routine-schedule-grid input[type="time"] { width: 108px; }
.routine-number-field { width: 72px; }
.routine-schedule-help { margin: -10px 0 0; font-size: 12px; line-height: 1.6; }
.routine-form-footer { padding-top: 0; }
.routine-form-footer .btn { height: 32px; min-height: 32px; line-height: 20px; box-sizing: border-box; padding: 5px 12px; }
.routine-check { align-items: center; }
.routine-check > small { color: var(--text-3); font-size: 11px; font-weight: 400; }
@media (min-width: 801px) and (max-height: 760px) {
  body:has(.routine-editor-page) > main.wrap { padding-top: 16px; padding-bottom: 16px; }
  .routine-editor-page { gap: 12px; }
  .routine-editor-banner { margin-bottom: 14px; }
  .routine-form-linear { gap: 12px; }
  .routine-form .routine-instructions-panel > textarea { height: 88px; }
  .routine-schedule-help { margin-top: -4px; }
}
@media (min-width: 801px) and (max-height: 700px) {
  body:has(.routine-editor-page) > main.wrap { padding-top: 12px; padding-bottom: 8px; }
  .routine-editor-page { gap: 8px; }
  .routine-editor-banner { margin-bottom: 12px; }
  .routine-form-linear { gap: 10px; }
  .routine-form .routine-instructions-panel > textarea { height: 72px; min-height: 72px; }
}
@media (max-width: 800px) {
  body:has(.routine-page, .routine-editor-page, .routine-detail-page) > main.wrap { padding: 24px 20px 48px; }
  .routine-editor-page { gap: 20px; }
  .routine-editor-banner { margin-bottom: 18px; font-size: 13px; }
  .routine-form-linear { gap: 18px; }
  .routine-toolbar { flex-direction: row; flex-wrap: wrap; }
  .routine-search { width: 200px; }
  .routine-row-info .routine-card-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .routine-schedule-help { margin-top: -10px; }
  .routine-config-panel { max-height: 340px; }
}
@media (max-width: 480px) {
  body:has(.routine-page, .routine-editor-page, .routine-detail-page) > main.wrap { padding: 20px 16px 40px; }
  .routine-editor-crumb { font-size: 16px; }
  .routine-hero { flex-direction: row; gap: 12px; }
  .routine-heading > p { font-size: 13px; }
  .routine-count { display: none; }
  .routine-title-row h1 { font-size: 18px; }
  .routine-new-button { font-size: 13px !important; }
  .routine-toolbar-actions { width: 100%; flex-wrap: wrap; }
  .routine-search { flex: 1 1 100%; width: 100%; }
  .routine-card-row { flex-wrap: wrap; gap: 5px; padding: 10px 12px; }
  .routine-card-main { flex-basis: calc(100% - 70px); padding: 0; }
  .routine-card-main h2 { font-size: 15px; }
  .routine-row-status { order: 4; width: 100%; }
  .routine-row-schedule { font-size: 12px; }
  .routine-editor-tools { padding: 0 10px; gap: 8px; }
  .routine-config > summary, .routine-toolbar-enabled { font-size: 12px; }
  .routine-days > div { display: grid; width: 100%; }
  .routine-days span { padding: 0 6px; font-size: 13px; }
  .routine-schedule-grid { gap: 8px 12px; }
  .routine-schedule-grid > label { font-size: 13px; }
  .routine-schedule-grid input[type="time"] { width: 110px; }
  .routine-week button { min-width: 0; min-height: 72px; }
  .routine-week span { font-size: 12px; }
  .routine-week strong { font-size: 19px; }
  .routine-calendar-day { padding: 14px 10px; }
  .routine-calendar-day > header { flex-direction: row; }
  .routine-calendar-event { grid-template-columns: 48px 1fr auto; }
}
/* Reference task menu, status chips, detail composition and reused editor dialog. */
.routine-action-icon { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.routine-action-menu > summary { border-radius: 10px; background: var(--routine-tool); }
.routine-action-popover { min-width: 176px; padding: 8px; border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: 0 8px 20px #00000018, 0 2px 4px #0000000c; }
.routine-action-popover a, .routine-action-popover button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 38px; padding: 8px 10px; color: var(--text); font-size: 15px; text-align: left; border-radius: 7px; }
.routine-action-popover hr { border: 0; border-top: 1px solid var(--border); margin: 6px 10px; }
.routine-action-popover .is-danger { color: var(--routine-danger, #ae2727); }
.routine-action-popover button:disabled, .routine-icon-button:disabled { opacity: .4; cursor: not-allowed; }
.routine-schedule-badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; font-size: 13px; line-height: 20px; border-radius: 6px; border: 1px solid transparent; }
.routine-schedule-badge .routine-action-icon { width: 15px; height: 15px; }
.routine-schedule-badge.is-active { color: var(--schedule-active-fg, #086718); background: var(--schedule-active-bg, #cdeac8); border-color: var(--schedule-active-line, #8cc285); }
.routine-schedule-badge.is-paused { color: var(--schedule-paused-fg, #626262); background: var(--schedule-paused-bg, #eeeeed); border-color: var(--schedule-paused-line, #e2e2e0); }
.routine-detail-crumb { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; width: min(100%, 1280px); margin: 0 auto 42px; font-size: 15px; }
.routine-detail-page > .routine-detail-crumb { box-sizing: border-box; position: relative; left: 50%; transform: translateX(-50%); width: min(calc(100% + 48px), 1280px); margin-inline: 0; padding-inline: 28px; }
.routine-detail-crumb a { color: var(--text); text-decoration: none; }
.routine-detail-crumb > span:first-of-type { color: var(--text-3); }
.routine-detail { max-width: 1000px; margin: 0 auto; }
.routine-detail-header { padding-bottom: 34px; border-bottom: 1px solid var(--border); }
.routine-detail-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.routine-detail-title h1 { margin: 0; font-family: var(--font-heading); font-size: 30px; line-height: 1.3; font-weight: 700; letter-spacing: -.02em; overflow-wrap: anywhere; }
.routine-detail-actions { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.routine-detail-actions form, .routine-detail-status form { margin: 0; }
.routine-icon-button { width: 32px; height: 36px; border: 0; background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; padding: 6px; border-radius: 8px; cursor: pointer; }
.routine-icon-button:hover { background: var(--routine-tool); }
.routine-run-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: var(--primary-bg, #111); color: var(--primary-fg, #fff); font: inherit; font-size: 15px; line-height: 20px; white-space: nowrap; cursor: pointer; }
.routine-run-button .routine-action-icon { width: 20px; height: 20px; }
.routine-detail-description { margin: 14px 0 20px; max-width: 780px; color: var(--text-2); font-size: 16px; line-height: 1.5; }
.routine-detail-status { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.routine-runtime-badge { background: var(--runtime-bg, #f9dfa1); color: var(--runtime-fg, #775013); padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.routine-next-run { color: var(--text-3); font-size: 14px; }
.routine-status-switch { display: flex; align-items: center; width: 40px; height: 23px; padding: 3px; border: none; border-radius: 20px; background: #91918e; cursor: pointer; }
.routine-status-switch[aria-checked="true"] { background: var(--switch-active, #2c7ce0); }
.routine-status-switch i { width: 17px; height: 17px; border-radius: 50%; background: white; }
.routine-status-switch[aria-checked="true"] i { margin-left: auto; }
.routine-status-switch:disabled { cursor: not-allowed; opacity: .65; }
.routine-detail-columns { display: grid; grid-template-columns: 40% minmax(0, 1fr); gap: 34px; padding-top: 36px; }
.routine-detail-history > h2 { margin-bottom: 14px; }
.routine-history-list { display: grid; }
.routine-history-list a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 10px 0 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: 15px; text-decoration: none; }
.routine-history-list a:hover, .routine-history-list a:focus-visible { background: var(--routine-tool); border-radius: 7px; }
.routine-history-list a time { font-family: var(--font-body); }
.routine-history-list a span { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.routine-history-empty { color: var(--text-3); font-size: 14px; }
.routine-detail .wf-detail { margin-top: 24px; }
.routine-detail-settings section { margin-bottom: 34px; }
.routine-detail-settings h2, .routine-detail-history > h2 { font-size: 15px; font-weight: 400; color: var(--text-3); margin: 0 0 16px; }
.routine-detail-settings p { margin: 0 0 10px; font-size: 15px; line-height: 1.6; }
.routine-detail-settings small, .routine-permissions { color: var(--text-3); }
.routine-pipeline-instructions, .routine-instruction-preview > div { font-family: var(--font-body); color: var(--text-2); font-size: 17px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.routine-instruction-preview { display: flex; flex-direction: column; }
.routine-instruction-preview > button { order: 1; text-align: left; border: 0; background: none; padding: 0; list-style: none; cursor: pointer; color: var(--text-3); font-size: 13px; margin-top: 8px; }
.routine-instruction-preview > div { display: block; max-height: 280px; overflow: hidden; mask-image: linear-gradient(#000 75%, transparent); }
.routine-instruction-preview:has([aria-expanded="true"]) > div { max-height: none; mask-image: none; }
.routine-instruction-preview .when-open, .routine-instruction-preview:has([aria-expanded="true"]) .when-closed { display: none; }
.routine-instruction-preview:has([aria-expanded="true"]) .when-open { display: inline; }
.routine-history-disclosure { margin-top: 32px; border-top: 1px solid var(--border); padding-top: 16px; }
.routine-history-disclosure > summary { cursor: pointer; color: var(--text-3); }
.routine-run-record { border-bottom: 1px solid var(--border); padding: 12px 0; font-size: 13px; }
.routine-run-record summary { cursor: pointer; }
.routine-run-record small { display: block; color: var(--text-3); margin-top: 5px; }
.routine-run-output { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; max-height: 480px; overflow-y: auto; }
.routine-edit-dialog { box-sizing: border-box; --routine-dialog-width: 840px; --routine-dialog-padding: 26px; width: min(calc(var(--routine-dialog-width) - var(--routine-dialog-gutter, 0px)), calc(100vw - 32px)); max-height: calc(100dvh - 48px); margin: auto; padding: var(--routine-dialog-padding); padding-right: max(0px, calc(var(--routine-dialog-padding) - var(--routine-dialog-gutter, 0px))); border: 1px solid var(--border); border-radius: 16px; background: var(--overlay-bg, var(--surface)); color: var(--text); box-shadow: 0 16px 50px #0003; overflow: hidden; }
.routine-edit-dialog[open] { display: flex; flex-direction: column; }
.routine-modal-body { flex: 1; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; }
.routine-modal-body, .routine-edit-dialog textarea { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-3) 45%, transparent) transparent; }
.routine-modal-body::-webkit-scrollbar, .routine-edit-dialog textarea::-webkit-scrollbar { width: 6px; height: 6px; }
.routine-modal-body::-webkit-scrollbar-thumb, .routine-edit-dialog textarea::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-3) 45%, transparent); border-radius: 6px; }
.routine-modal-body::-webkit-scrollbar-button, .routine-edit-dialog textarea::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
.routine-edit-dialog[data-load-state] { min-height: min(925px, calc(100dvh - 48px)); }
.routine-edit-loading { display: grid; align-content: start; gap: 16px; color: var(--text-2); font-size: 13px; }
.routine-edit-loading[hidden] { display: none; }
.routine-edit-loading p { margin: 0; }
.routine-edit-skeleton { display: grid; gap: 14px; max-width: 640px; }
.routine-edit-skeleton span { display: block; background: var(--control-bg); border-radius: 6px; animation: content-wait-pulse 1.8s ease-in-out infinite; }
.routine-edit-skeleton-label { width: 108px; height: 12px; }
.routine-edit-skeleton .routine-edit-skeleton-field { width: 100%; height: 42px; }
.routine-edit-skeleton .routine-edit-skeleton-textarea { width: 100%; height: 130px; }
@media (prefers-reduced-motion: reduce) { .routine-edit-skeleton span { animation: none; } }
[data-motion="reduced"] .routine-edit-skeleton span { animation: none; }
.routine-edit-dialog::backdrop { background: #0006; backdrop-filter: blur(5px); }
.routine-modal-heading { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.routine-modal-heading h2 { font-size: 25px; font-weight: 600; margin: 0; }
.routine-edit-dialog .routine-editor { width: 100%; max-width: none; margin: 0; }
.routine-edit-dialog .routine-form-linear { gap: 18px; }
.routine-edit-dialog .routine-instructions-panel > textarea { height: 230px; }
.routine-edit-dialog .routine-editor-banner { font-size: 12px; margin-bottom: 16px; }
.routine-edit-dialog .routine-form-footer .btn-primary { background: var(--primary-bg, #111); color: var(--primary-fg, white); }
.routine-kind-switch { display: flex; gap: 16px; margin-bottom: 12px; font-size: 13px; }
.routine-kind-switch a { color: var(--text-3); text-decoration: none; padding-bottom: 5px; }
.routine-kind-switch a[aria-current] { color: var(--text); border-bottom: 1px solid currentColor; }
.routine-agent-time { white-space: nowrap; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.routine-agent-time input { width: 110px; }
.routine-editor-tools > span { color: var(--text-3); font-size: 12px; }
.routine-editor-tools > span:last-child { margin-left: auto; }
@media (max-width: 800px) {
  .routine-detail-page > .routine-detail-crumb { width: min(calc(100% + 40px), 1280px); }
  .routine-detail-crumb { margin-bottom: 26px; }
  .routine-detail-title { flex-direction: column; gap: 14px; }
  .routine-detail-title h1 { font-size: 25px; }
  .routine-detail-columns { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .routine-detail-history:empty { display: none; }
  .routine-edit-dialog { --routine-dialog-padding: 20px; max-height: calc(100dvh - 24px); }
  .routine-edit-dialog[data-load-state] { min-height: calc(100dvh - 24px); }
  .routine-edit-dialog .routine-instructions-panel > textarea { height: 190px; }
}
@media (max-width: 640px) {
  .routine-detail-page > .routine-detail-crumb { padding-inline: 16px; }
}
@media (max-width: 480px) {
  .routine-detail-page > .routine-detail-crumb { width: min(calc(100% + 32px), 1280px); }
}

.routine-result-sources { padding-left: 18px; overflow-wrap: anywhere; }
/* Keep the prompt-first form on one desktop screen, including setup guidance. */
.routine-agent-editor-page .routine-kind-switch { margin-bottom: 8px; }
.routine-agent-editor-page .routine-editor-banner { margin: 0 0 10px; }
@media (min-width: 801px) and (max-height: 800px) {
  .routine-agent-editor-page .routine-form-linear, .routine-edit-dialog .routine-form-linear { gap: 12px; }
  .routine-agent-editor-page .routine-instructions-panel > textarea { height: 88px; }
  .routine-edit-dialog .routine-instructions-panel > textarea { height: 160px; }
}
@media (min-width: 801px) and (max-height: 700px) {
  .routine-agent-editor-page .routine-form-linear, .routine-edit-dialog .routine-form-linear { gap: 8px; }
  .routine-agent-editor-page .routine-instructions-panel > textarea { height: 72px; }
  .routine-edit-dialog .routine-instructions-panel > textarea { height: 108px; min-height: 88px; }
  .routine-edit-dialog .routine-editor-banner { margin: 0 0 10px; }
  .routine-edit-dialog .routine-modal-heading { margin-bottom: 12px; }
}
@media (min-width: 801px) and (max-height: 700px) {
  .routine-agent-editor-page .routine-kind-switch { margin-bottom: 4px; }
  .routine-agent-editor-page .routine-editor-banner { margin-bottom: 6px; }
}

/* Saved feedback is a content-sized label, not a full-width banner. */
.routine-page .routine-notice.is-success { display: inline-flex; justify-self: start; width: fit-content; max-width: 100%; box-sizing: border-box; gap: 7px; padding: 4px 9px; border-radius: 6px; font-size: 12px; line-height: 18px; }
.routine-page .routine-notice.is-success > span { flex: 0 0 18px; background: transparent; }
.routine-page .routine-notice.is-success > p { min-width: 0; overflow-wrap: anywhere; }
.routine-notice-check { display: block; width: 18px; height: 18px; }
.routine-notice-check circle { stroke: color-mix(in srgb, var(--ok) 45%, white); stroke-width: 2.8; }
.routine-notice-check path { stroke: var(--ok); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }

/* Reference schedule: shallow segmented track, inset selection and upward weekday menu. */
.routine-frequency [hidden] { display: none !important; }
.routine-frequency-tabs { display: inline-flex; align-self: start; width: fit-content; max-width: 100%; margin: 0; padding: 2px; gap: 2px; border: 0; border-radius: 8px; background: var(--control-bg, var(--sunken)); }
.routine-frequency-tabs label { position: relative; margin: 0 !important; cursor: pointer; }
.routine-frequency-tabs input, .routine-weekday-menu input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.routine-frequency-tabs span { display: block; padding: 2px 8px; border-radius: 6px; color: var(--text-3); font-size: 13px; line-height: 20px; white-space: nowrap; }
.routine-frequency-tabs input:checked + span { background: var(--selected-bg, var(--routine-selected)); color: var(--text); }
.routine-frequency-tabs input:focus-visible + span, .routine-weekday-menu input:focus-visible + span { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.routine-frequency-tabs input:disabled + span { cursor: default; }
.routine-frequency-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.routine-frequency-row > label { margin: 0 !important; }
.routine-frequency-time { white-space: nowrap; display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; }
.routine-form .routine-frequency-time input[type="time"] { flex: none; width: 156px; background: var(--input-bg, var(--surface)); }
.routine-frequency-row .routine-toolbar-enabled { margin-left: auto !important; }
.routine-weekday-picker { position: relative; min-width: 156px; font-size: 14px; }
.routine-weekday-picker summary { display: flex; align-items: center; gap: 6px; height: 28px; padding: 2px 8px; border: 1px solid var(--input-line, var(--border)); border-radius: 7px; background: var(--input-bg, var(--surface)); list-style: none; cursor: pointer; }
.routine-weekday-picker summary::-webkit-details-marker { display: none; }
.routine-weekday-prefix { color: var(--text-3); }
.routine-weekday-picker summary svg { width: 15px; height: 15px; margin-left: auto; stroke: var(--text-3); fill: none; stroke-width: 1.5; }
.routine-weekday-menu { position: absolute; z-index: 30; bottom: calc(100% + 7px); left: 0; width: 216px; max-width: calc(100vw - 48px); margin: 0; padding: 5px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--overlay-bg, var(--surface)); box-shadow: var(--shadow); }
.routine-weekday-menu label { position: relative; display: flex; align-items: center; gap: 16px; margin: 0 !important; padding: 4px 9px; border-radius: 6px; line-height: 20px; cursor: pointer; }
.routine-weekday-menu label:hover { background: var(--control-hover); }
.routine-weekday-menu svg { width: 16px; height: 16px; margin-left: auto; fill: none; stroke: var(--focus-ring); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.routine-weekday-menu input:checked ~ svg { visibility: visible; }
.routine-frequency .routine-frequency-hint { margin: 0; font-size: 12px; line-height: 18px; }
@media (max-width: 540px) {
  .routine-frequency-tabs { gap: 0; }
  .routine-frequency-tabs span { padding-inline: 6px; font-size: 12px; }
  .routine-form .routine-frequency-time input[type="time"] { flex: none; width: 128px; }
  .routine-weekday-picker { min-width: 130px; }
  .routine-weekday-menu { left: auto; right: 0; }
}

/* Essential field labels remain readable; placeholders keep the softer reference tone. */
.routine-field-label { color: var(--label-fg); }
.routine-frequency-tabs input:not(:checked) + span { color: var(--label-fg); }


/* Reference two-column time picker; seven complete rows, no partial border at rest. */
.routine-time-control { position: relative; display: inline-flex; flex: none; }
.routine-form .has-time-picker input[type="time"] { padding-right: 30px; }
.has-time-picker input[type="time"]::-webkit-calendar-picker-indicator { display: none; }
.routine-form .routine-time-trigger { position: absolute; right: 1px; top: 1px; display: grid; place-items: center; width: 28px; height: calc(100% - 2px); min-height: 0; padding: 0; border: 0; border-radius: 5px; background: transparent; color: var(--text); }
.routine-time-trigger svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.routine-time-trigger:hover { background: var(--control-hover); }
.routine-time-popup { position: absolute; z-index: 35; bottom: calc(100% + 3px); left: 0; display: grid; grid-template-columns: 1fr 1fr; width: 156px; padding: 4px; border: 1px solid var(--border-strong); border-radius: 2px; background: var(--overlay-bg, var(--surface)); box-shadow: var(--shadow); }
.routine-time-popup.is-below { bottom: auto; top: calc(100% + 3px); }
.routine-time-column { height: 224px; overflow-y: auto; overscroll-behavior: contain; scroll-snap-type: y mandatory; scrollbar-width: none; font-variant-numeric: tabular-nums; }
.routine-time-column::-webkit-scrollbar { display: none; }
.routine-time-column:focus-visible { outline: 1px solid var(--focus-ring); outline-offset: -1px; }
.routine-time-option { box-sizing: border-box; height: 32px; display: grid; place-items: center; border: 1px solid transparent; scroll-snap-align: start; color: var(--text); font-size: 16px; font-weight: 400; cursor: pointer; }
.routine-time-option:hover { background: var(--control-hover); border-color: var(--border); }
.routine-time-option[aria-selected="true"] { border-color: var(--border-strong); background: var(--control-bg, var(--surface-2)); }

/* Delete confirmation follows the supplied compact reference, without unsupported file actions. */
.routine-delete-dialog { font-family: var(--font-sans); box-sizing: border-box; width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; padding: 28px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--overlay-bg, var(--surface)); color: var(--text); box-shadow: 0 16px 50px #0003; overflow-y: auto; }
.routine-delete-dialog::backdrop { background: #0009; backdrop-filter: blur(5px); }
.routine-delete-dialog h2 { margin: 0 0 8px; font-size: 18px; font-weight: 600; line-height: 1.35; }
.routine-delete-dialog p { margin: 0; color: var(--text-2); font-size: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.routine-delete-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.routine-delete-actions button { box-sizing: border-box; height: 32px; min-height: 32px; padding: 6px 14px 4px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--selected-bg, var(--sunken)); color: var(--text); font: inherit; font-size: 16px; font-weight: 500; line-height: 20px; cursor: pointer; }
.routine-delete-actions [data-delete-confirm] { background: #c93636; border-color: #c93636; color: #fff; }
.routine-delete-actions button:focus-visible { outline: 2px solid var(--border-strong); outline-offset: 2px; }
.routine-delete-actions [data-delete-confirm].is-initial-emphasis,
.routine-delete-actions [data-delete-confirm]:focus-visible { outline: 1px solid #c93636; outline-offset: 2px; }
.routine-delete-actions button:disabled { opacity: .5; cursor: default; }
