/* T497 (doc 57/65 Routines rebuild): clean-slate the Routines list/search/
   summary anatomy. Single source of truth — nothing routines-shaped leaks
   into app-shell/chrome-visual.css, design-system/foundation.css, or
   app-shell/overlays.css anymore (same method as T495 Today / T496
   Workforce). The create-routine modal (.routine-setup*), tag/engine/model
   fields, and the routine detail overlay are untouched below and kept
   verbatim from the pre-rebuild file. */
.routines-section {
  --routine-rule:color-mix(in srgb,var(--ui-line) 72%,transparent);
}

/* ── Summary strip (Next run / Enabled / Health) — glass card, doc-57 card
   language (radius/background/shadow now owned here, not chrome-visual). */
.routine-summary {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  margin:18px 0;
  border:1px solid var(--ui-line);
  border-radius:1.125rem;
  overflow:hidden;
  background:color-mix(in srgb, var(--ui-text) 3%, var(--ui-panel));
  backdrop-filter:blur(10px);
  box-shadow:0 12px 40px rgba(0,0,0,.18);
}
html[data-theme="light"] .routine-summary {
  background:#fcfbf7;
  border-color:rgba(20,32,51,.1);
  box-shadow:0 10px 30px rgba(20,32,51,.07);
}
.routine-summary > div { display:grid; gap:4px; padding:16px 18px; }
.routine-summary > div + div { border-left:1px solid var(--ui-line); }
.routine-summary span {
  color:var(--ui-muted);
  font:700 9px/1 ui-monospace,Menlo,monospace;
  letter-spacing:.12em;
  text-transform:uppercase;
}
.routine-summary strong { font-family:var(--font-ui,inherit); font-size:1.25rem; font-weight:650; }
.routine-summary small { color:var(--ui-text-soft); }

/* ── Toolbar: search + tag filters + count + create button ── */
.routine-toolbar {
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between;
  gap:8px; padding:.4rem 0; margin-top:.4rem; margin-bottom:12px;
  border-top:1px solid var(--ui-line-soft);
}
/* Search: the design system's ONE input-surface contract (form-controls.css
   "input:not(...) { background: var(--ui-input) }"). The pre-rebuild field
   explicitly overrode this to var(--ui-panel)
   (a raised-card token, not an input token) in two places at once — that
   duplication + wrong token was operator defect #1 (search background didn't
   match the design system's input surfaces). Fixed by declaring the input
   token once here. */
.routine-search {
  width:min(260px,100%); min-width:190px; height:36px; padding:0 10px;
  border:1px solid var(--ui-line); border-radius:.65rem;
  background:var(--ui-input); color:var(--ui-text);
  font-family:var(--font-ui,inherit); font-size:.88rem;
  transition:border-color 140ms ease;
}
.routine-search:focus {
  outline:none; border-color:color-mix(in srgb, var(--ui-accent) 45%, transparent);
}
.routine-search::placeholder { color:var(--ui-muted); }
.routine-filters, .routine-tag-options, .routine-selected-tags {
                  display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.routine-filter, .routine-tag-option, .routine-selected-tag {
                  min-height:30px; padding:5px 10px; border:1px solid var(--ui-line);
                  border-radius:999px; background:var(--ui-hover); color:var(--ui-text-soft);
                  font-size:11px; }
.routine-filter[aria-pressed="true"], .routine-tag-option[aria-pressed="true"] {
                  border-color:color-mix(in srgb, var(--ui-accent) 40%, transparent); background:var(--ui-accent-soft);
                  color:var(--ui-accent); }
.routine-selected-tag { display:inline-flex; align-items:center; gap:6px;
                        border-color:var(--ui-success-line); background:var(--ui-success-soft); }
.routine-selected-tag button { width:16px; height:16px; padding:0; border:0;
                               background:transparent; color:var(--ui-muted); line-height:1; }
.routine-tag-field { display:grid; gap:7px; }
.routine-modal-section {
  padding:11px 12px;
  border:1px solid var(--ui-line);
  border-radius:9px;
  background:var(--ui-panel-soft);
}
.routine-edit-tags { display:grid; gap:8px; max-width:780px; margin:0 auto 16px;
                     padding:12px; border:1px solid var(--ui-line); border-radius:9px;
                     background:var(--ui-raised); }
.routine-edit-tags-head { display:flex; align-items:start; justify-content:space-between;
                          gap:10px; }
.routine-edit-tags-head p { color:var(--ui-muted); font-size:11.5px; }
.routine-tag-create { display:flex; gap:7px; }
.routine-tag-create input { flex:1; }
.routine-tags { display:flex; flex-wrap:wrap; gap:5px; margin-top:7px; }
.routine-tag { border-radius:999px; padding:3px 7px; background:var(--ui-neutral-soft);
               color:var(--ui-text-soft); font-size:10px; }
.routine-header-actions { display:flex; align-items:center; gap:10px; }
#routine-setup-overlay .modal-panel {
  width:min(840px,100%); height:auto; max-height:92vh;
}
.routine-setup-modal-body { min-height:0; overflow:auto; padding:10px 20px; }
.routine-setup {
  display:grid;
  grid-template-columns:minmax(0,1.35fr) minmax(260px,.65fr);
  align-items:start;
  gap:10px 12px;
}
.routine-setup label { display:grid; gap:5px; color:var(--ui-text-soft); font-size:11px;
                       font-weight:650; }
.routine-setup input, .routine-setup textarea, .routine-setup select {
                       width:100%; min-width:0; border:1px solid var(--ui-line);
                       border-radius:7px; background:var(--ui-input); color:var(--ui-text);
                       padding:9px 10px; font:inherit; font-size:13px; }
.routine-setup textarea { resize:vertical; overflow-y:auto; min-height:132px;
                          max-height:480px; line-height:1.45; }
.routine-setup input:focus, .routine-setup textarea:focus,
.routine-setup select:focus, .routine-config-edit select:focus {
                       outline:2px solid var(--ui-accent-faint); border-color:var(--ui-accent); }
.routine-model-fields {
  grid-column:1/-1;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px 10px;
}
.routine-model-note { grid-column:1/-1; margin:0; color:var(--ui-muted); font-size:11px; }
.routine-engine-availability { grid-column:1/-1; display:flex; flex-wrap:wrap; gap:6px; }
.routine-engine-state { display:inline-flex; align-items:center; gap:5px;
                        padding:5px 7px; border:1px solid var(--ui-line);
                        border-radius:7px; background:var(--ui-muted-surface); }
.routine-engine-state strong { color:var(--ui-text); font-size:10.5px; }
.routine-engine-state small { color:var(--ui-muted); font-size:10px; }
.routine-engine-state.is-ready small { color:var(--ui-success); }
.routine-engine-state.is-unavailable { border-color:var(--ui-danger); }
.routine-config-edit { display:grid; grid-template-columns:1fr 1fr auto; gap:9px;
                       align-items:end; max-width:780px; margin:0 auto 16px;
                       padding:12px; border:1px solid var(--ui-line); border-radius:9px;
                       background:var(--ui-muted-surface); }
.routine-config-edit label { display:grid; gap:5px; color:var(--ui-text-soft);
                             font-size:11px; font-weight:650; }
.routine-config-edit select { width:100%; min-width:0; border:1px solid var(--ui-line);
                              border-radius:7px; background:var(--ui-input);
                              color:var(--ui-text); padding:9px 10px; }
.routine-config-result { grid-column:1/-1; min-height:17px; margin:0;
                         color:var(--ui-muted); font-size:11px; }
.routine-setup-guidance { display:grid; gap:4px; margin-top:-2px; padding:8px 11px;
                          border:1px solid var(--ui-line); border-radius:8px;
                          background:var(--ui-muted-surface); }
.routine-setup-guidance strong { color:var(--ui-text); font-size:11.5px; }
.routine-setup-guidance p { margin:0; color:var(--ui-muted); font-size:11px; line-height:1.5; }
#routine-setup-example { color:var(--ui-text-soft); }
.routine-setup-actions { display:flex; justify-content:flex-end; }
.routine-setup > .routine-form-step,
.routine-setup > .routine-setup-actions,
.routine-setup > .routine-setup-help,
.routine-setup > #routine-setup-result,
.routine-setup > #routine-specific-fields {
  grid-column:1/-1;
}
.routine-setup > .routine-trigger-kind { grid-column:1; }
.routine-setup > .routine-trigger-kind + label { grid-column:2; }
.routine-setup button { min-height:36px; white-space:nowrap; }
.routine-setup-help { margin:0; color:var(--ui-muted); font-size:11px; }
#routine-setup-result { min-height:1.3em; margin:0; color:var(--ui-text-soft); font-size:12px; }
.routine-setup-confirm { display:grid; justify-items:center; gap:10px; text-align:center;
                         padding:26px 20px;
                         border:1px solid var(--ui-line); border-radius:10px; background:var(--ui-muted-surface); }
.routine-setup-confirm h3 { margin:0; font-size:15px; }
#routine-setup-confirm-detail { margin:0; max-width:44ch; color:var(--ui-text-soft); font-size:12px; }
.routine-setup-confirm-mark { display:grid; place-items:center; width:40px; height:40px;
                              border-radius:50%; background:var(--ui-accent-soft); color:var(--ui-success);
                              font-size:20px; }
.routine-setup-confirm-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; }

/* ── Routine cards ────────────────────────────────────────────────────
   Doc-57 card grammar: ONE bordered/rounded
   glass surface per routine; hover/focus recolors that whole outer surface
   (defect #3 — the old rule split hover between .routine-row's border and
   .routine-open's inner-only background, leaving the toggle/chevron zone on
   the right unlit); toggle + chevron are quiet borderless icon controls,
   not boxed regions with their own border-left dividers (defect #2 — the
   "stray chrome" was exactly those two divided/padded boxes stacked on the
   row's right edge). */
.routine-row {
  --card-tint: color-mix(in srgb, var(--ui-text) 3%, var(--ui-panel));
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:.5rem;
  overflow:hidden;
  border:1px solid var(--ui-line);
  border-radius:1.125rem;
  background:var(--card-tint);
  backdrop-filter:blur(10px);
  box-shadow:0 12px 40px rgba(0,0,0,.18);
  transition:background 140ms ease, border-color 140ms ease;
}
html[data-theme="light"] .routine-row {
  background:#fcfbf7;
  border-color:rgba(20,32,51,.1);
  box-shadow:0 10px 30px rgba(20,32,51,.07);
}
.routine-row:hover,
.routine-row:focus-within {
  background:color-mix(in srgb, var(--ui-text) 5%, var(--card-tint));
  border-color:color-mix(in srgb, var(--ui-accent) 25%, var(--ui-line));
}
/* The light-theme base rule above (html[data-theme="light"] .routine-row)
   outranks the bare .routine-row:hover rule on specificity (extra `html`
   element + attribute selector), which would silently kill the whole-card
   hover fix in light mode — the exact class of bug defect #3 was about.
   Re-declare hover at matching specificity so it actually wins in light. */
html[data-theme="light"] .routine-row:hover,
html[data-theme="light"] .routine-row:focus-within {
  background:color-mix(in srgb, var(--ui-text) 4%, #fcfbf7);
  border-color:color-mix(in srgb, var(--ui-accent) 30%, rgba(20,32,51,.1));
}
.routine-row.invalid { border-color:var(--ui-danger-line); }
.routine-open {
  display:grid;
  min-width:0;
  min-height:4.4rem;
  padding:.85rem 1rem;
  align-items:center;
  border:0;
  background:transparent;
  color:inherit;
  grid-template-columns:76px minmax(150px,1.25fr) minmax(150px,1fr)
                        minmax(150px,.9fr);
  gap:12px;
  text-align:left;
}
.routine-open::after { content:none; }
.routine-time {
  display:flex;
  align-items:center;
  gap:7px;
  color:var(--ui-muted);
  font-family:var(--font-mono,ui-monospace,Menlo,monospace);
  font-size:.68rem;
  font-weight:650;
  line-height:1;
}
.routine-schedule-dot {
  width:7px;
  height:7px;
  flex:0 0 auto;
  border-radius:50%;
  background:var(--ui-success);
  box-shadow:0 0 9px color-mix(in srgb,var(--ui-success) 55%,transparent);
}
.routine-row--disabled .routine-schedule-dot,
.routine-row--completed .routine-schedule-dot {
  background:var(--ui-muted);
  box-shadow:none;
}
.routine-row--attention .routine-schedule-dot,
.routine-row.invalid .routine-schedule-dot {
  background:var(--ui-warning);
  box-shadow:0 0 9px color-mix(in srgb,var(--ui-warning) 50%,transparent);
}
.routine-primary { display:grid; min-width:0; align-content:center; gap:2px; }
.routine-name { color:var(--ui-text); font-size:.92rem; font-weight:600; }
.routine-cadence,
.routine-runtime {
  display:block;
  min-width:0;
  overflow:hidden;
  color:var(--ui-muted);
  font-size:.68rem;
  line-height:1.25;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.routine-runtime { font:9px/1.25 ui-monospace,Menlo,monospace; }
.routine-detail { min-width:0; color:var(--ui-text-soft); font-size:12px; }
.routine-detail small {
  display:block;
  margin-bottom:3px;
  color:var(--ui-muted);
  font:9px/1 ui-monospace,Menlo,monospace;
  letter-spacing:.06em;
  text-transform:uppercase;
}
.routine-detail > span { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
.routine-detail .chip {
  display:inline-flex; align-items:center; gap:.3rem;
  padding:.18rem .6rem; border-radius:999px;
  font-family:var(--font-mono,ui-monospace,Menlo,monospace); font-size:.65rem; font-weight:600;
  border:1px solid transparent;
}
.routine-detail .chip::before {
  content:""; width:.4rem; height:.4rem; border-radius:999px; background:currentColor;
}
.routine-health {
  color:var(--ui-muted);
  font-size:10px;
  font-weight:650;
}
.routine-health--healthy { color:var(--ui-success); }
.routine-health--attention,
.routine-health--invalid { color:var(--ui-warning); }
/* Right-side actions: quiet icon controls, no border-left divider chrome,
   no boxed padding zones — a flex group sitting inside the card, its
   background staying transparent so the card's own :hover fill shows
   through evenly (this is the whole fix for defect #3). */
.routine-row-actions {
  display:flex;
  align-items:center;
  gap:.3rem;
  padding-right:.6rem;
}
.routine-toggle {
  display:inline-flex;
  align-items:center;
  gap:6px;
  min-height:36px;
  padding:.3rem .55rem;
  border:0;
  border-radius:999px;
  background:transparent;
  color:var(--ui-muted);
  font:650 9px/1 ui-monospace,Menlo,monospace;
  transition:background 140ms ease, color 140ms ease;
}
.routine-toggle:hover:not(:disabled) { background:var(--ui-hover); color:var(--ui-text); }
.routine-toggle-track {
  position:relative;
  width:28px;
  height:16px;
  border:1px solid var(--ui-line);
  border-radius:999px;
  background:var(--ui-muted-surface);
}
.routine-toggle-track > span {
  position:absolute;
  top:2px;
  left:2px;
  width:10px;
  height:10px;
  border-radius:50%;
  background:var(--ui-muted);
  transition:transform 150ms ease, background-color 150ms ease;
}
.routine-toggle[aria-checked="true"] { color:var(--ui-success); }
.routine-toggle[aria-checked="true"] .routine-toggle-track {
  border-color:var(--ui-success-line);
  background:var(--ui-success-soft);
}
.routine-toggle[aria-checked="true"] .routine-toggle-track > span {
  background:var(--ui-success);
  transform:translateX(12px);
}
.routine-chevron {
  display:grid;
  width:1.75rem;
  height:1.75rem;
  place-items:center;
  border:0;
  border-radius:.5rem;
  background:transparent;
  color:var(--ui-muted);
  opacity:.7;
  transition:background 140ms ease, color 140ms ease, opacity 140ms ease;
}
.routine-chevron .ui-icon { width:18px; height:18px; }
.routine-chevron:hover,
.routine-chevron:focus-visible { background:var(--ui-hover); color:var(--ui-accent); opacity:1; }
.routine-row:hover .routine-chevron { opacity:1; color:var(--ui-accent); }
.routine-note {
  display:flex;
  align-items:baseline;
  gap:1rem;
  margin-top:1.1rem;
  padding-top:.85rem;
  border-top:1px solid var(--ui-line);
}
.routine-note span {
  color:var(--ui-accent);
  font:600 .55rem/1 ui-monospace,Menlo,monospace;
  letter-spacing:.06em;
  text-transform:uppercase;
  white-space:nowrap;
}
.routine-note p { color:var(--ui-muted); font-size:.65rem; }
.routine-form-step {
  color:var(--ui-accent);
  font:700 10px/1 ui-monospace,Menlo,monospace;
  letter-spacing:.14em;
}
.routine-setup-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.routine-setup-grid .wide { grid-column:1/-1; }
.routine-context-policy {
  display:grid;
  gap:10px;
  grid-column:1;
  padding:12px;
  border:1px solid var(--ui-line);
  border-radius:9px;
  background:var(--ui-muted-surface);
}
.routine-tag-field { grid-column:2; align-self:stretch; }
.routine-specific-list { display:grid; gap:9px; margin-bottom:9px; }
.routine-specific-row {
  display:grid;
  grid-template-columns:1fr .8fr 1fr 42px;
  align-items:end;
  gap:8px;
}
.routine-specific-row label { min-width:0; }
.routine-specific-row label:nth-child(4) { grid-column:1/4; }
.routine-specific-remove {
  grid-column:4;
  grid-row:2;
  width:42px;
  min-height:40px;
  padding-inline:0;
  color:var(--ui-danger);
}
/* Operator round (2026-09-05): "calm". The accent-bordered, accent-gradient
   panel shouted for attention on a page whose whole message is "nothing is
   scheduled yet". Now a quiet card on the board's normal surface — the single
   primary action is the only accent in the block. */
.routine-empty-state {
  display:grid;
  justify-items:center;
  gap:8px;
  min-height:220px;
  padding:44px 22px;
  border:1px solid var(--ui-line);
  border-radius:12px;
  background:var(--ui-panel);
  text-align:center;
}
.routine-empty-state-mark {
  display:grid;
  width:42px;
  height:42px;
  place-items:center;
  border-radius:50%;
  /* Quieter than --ui-accent-medium: the mark identifies the page, it is not
     the call to action. Holds the Routines clock glyph, not a decorative ✦. */
  background:var(--ui-accent-soft);
  color:var(--ui-accent);
}
.routine-empty-state-mark .ui-icon { width:20px; height:20px; }
/* First-paint skeletons: routine rows and the three summary values, in the
   real layout (shared vocabulary, design-system/loading.css). */
#routines-grid[data-cc-loading] .cc-skel-list { gap:8px; }
#routines-grid[data-cc-loading] .cc-skel-row {
  min-height:56px;
  padding:0 14px;
  border:1px solid var(--ui-line);
  border-radius:10px;
  background:var(--ui-panel);
}
.routine-summary strong .cc-skel--pill { height:20px; width:92px; }
.routine-empty-state h3 { margin:4px 0 0; color:var(--ui-text); font-size:17px; }
.routine-empty-state p { max-width:440px; margin:0; color:var(--ui-text-soft); line-height:1.5; }
.routine-empty-state .button { margin-top:8px; }
.routine-approval-policy {
  display:grid !important;
  position:relative;
  grid-template-columns:28px minmax(0,1fr);
  align-items:center;
  gap:9px !important;
  width:100%;
  min-height:48px;
  padding:8px 10px;
  border:1px solid color-mix(in srgb, var(--ui-accent) 40%, transparent);
  border-radius:8px;
  background:var(--ui-accent-soft);
  cursor:pointer;
}
.routine-approval-policy input {
  position:absolute;
  width:1px;
  height:1px;
  opacity:0;
  pointer-events:none;
}
.routine-approval-icon {
  display:grid;
  width:28px;
  height:28px;
  place-items:center;
  border-radius:50%;
  border:1px solid var(--ui-line);
  background:var(--ui-input);
  color:transparent;
  font-size:13px;
}
.routine-approval-policy input:checked + .routine-approval-icon {
  border-color:var(--ui-accent);
  background:var(--ui-accent-medium);
  color:var(--ui-accent);
}
.routine-approval-policy input:focus-visible + .routine-approval-icon {
  outline:2px solid var(--ui-accent);
  outline-offset:2px;
}
.routine-approval-policy > span:last-child { display:grid; gap:2px; }
.routine-approval-policy strong { color:var(--ui-text); font-size:11.5px; }
.routine-approval-policy small {
  color:var(--ui-text-soft);
  font-size:10.5px;
  font-weight:500;
  line-height:1.35;
}
.routine-context-policy .routine-approval-policy.manage-switch {
  display:block !important;
  position:relative;
  width:auto;
  height:auto;
  min-height:44px;
  padding-left:52px;
}
.routine-context-policy .routine-approval-policy.manage-switch input {
  position:absolute; inset:0 auto auto 0; width:40px; height:22px;
  opacity:0; pointer-events:auto;
}
.routine-context-policy .routine-approval-policy.manage-switch .track {
  inset:0 auto auto 0; width:40px; height:22px;
}
.routine-context-policy .routine-approval-policy.manage-switch .thumb { top:2px; left:2px; }
.routine-setup select {
  min-height:40px;
  border:1px solid var(--ui-line);
  border-radius:7px;
  color:var(--ui-text);
  padding:8px 10px;
  background:var(--ui-input);
}
.routine-setup input,
.routine-setup textarea { background:var(--ui-input); }
.routine-setup textarea { min-height:96px; }
.routine-trigger-kind {
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:3px;
  padding:3px;
  border:1px solid var(--ui-line);
  border-radius:8px;
  background:var(--ui-muted-surface);
}
.routine-trigger-kind legend {
  grid-column:1/-1;
  width:100%;
  margin-bottom:3px;
  color:var(--ui-text-soft);
  font-size:11px;
  font-weight:650;
}
.routine-trigger-choice {
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:34px;
  padding:7px 9px;
  border:0;
  border-radius:6px;
  background:transparent;
  text-align:center;
}
.routine-trigger-choice input {
  position:absolute;
  width:1px;
  height:1px;
  opacity:0;
}
.routine-trigger-choice:has(input:checked) {
  border:0;
  background:var(--ui-accent-soft);
  color:var(--ui-accent);
  box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--ui-accent) 36%,transparent);
}
.routine-trigger-choice:has(input:focus-visible) {
  outline:2px solid var(--ui-accent);
  outline-offset:1px;
}
.routine-setup-actions {
  order:3;
  position:sticky;
  z-index:2;
  bottom:0;
  margin:0;
  padding:10px 0 0;
  border-top:1px solid var(--ui-line);
  background:color-mix(in srgb,var(--ui-panel) 96%,transparent);
  backdrop-filter:blur(8px);
}
.routine-setup-help { order:1; }
#routine-setup-result { order:2; }
@media (max-width:760px) {
  .routine-summary { grid-template-columns:1fr; }
  .routine-summary > div + div { border-left:0; border-top:1px solid var(--ui-line); }
  .routine-setup { grid-template-columns:1fr; }
  .routine-setup > .routine-trigger-kind,
  .routine-setup > .routine-trigger-kind + label,
  .routine-context-policy,
  .routine-tag-field { grid-column:1; }
  .routine-setup-grid { grid-template-columns:1fr; }
  .routine-setup-grid .wide { grid-column:auto; }
  .routine-model-fields, .routine-config-edit { grid-template-columns:1fr; }
  .routine-model-note, .routine-config-result { grid-column:1; }
  .routine-specific-row { grid-template-columns:1fr 1fr; }
  .routine-specific-row label:nth-child(3) { grid-column:1/-1; }
  .routine-specific-row label:nth-child(4) { grid-column:1; }
  .routine-specific-remove { grid-column:2; grid-row:auto; }
  .routine-note { align-items:flex-start; flex-direction:column; gap:5px; }
  .routine-row { grid-template-columns:1fr; }
  .routine-open {
    grid-template-columns:58px minmax(0,1fr);
    gap:8px 10px;
    padding:.75rem;
  }
  .routine-next,
  .routine-result { grid-column:2; }
  .routine-runtime { display:none; }
  .routine-row-actions {
    justify-content:flex-end;
    padding:0 .75rem .6rem;
  }
  .routine-setup-actions {
    bottom:0;
  }
}
.routine-model-attention {
  display:block;
  margin-top:7px;
  padding:7px 9px;
  border-left:3px solid var(--ui-warning);
  border-radius:6px;
  background:var(--ui-warning-soft);
  color:var(--ui-warning);
  font-size:10.5px;
  line-height:1.45;
}
.routine-model-attention code { color:inherit; }

/* T382: routine dialog layout adjustment for Inter metrics.
   Inter is slightly taller than system font at the same px size; tighten
   line-height and padding on this surface so body.scrollHeight stays
   within body.clientHeight at 1440x900 (t235e gate). */
.routine-setup {
  font-size: 0.95rem; /* ~14.25px vs 15px — recovers Inter's taller x-height */
}
.routine-setup-modal-body {
  padding: 8px 18px; /* slightly tighter than 10px 20px */
}
.routine-modal-section {
  padding: 8px 0; /* slightly tighter */
}

/* T498 (doc 57/65 Routines rebuild round 2): the routine DETAIL drawer.
   Operator: "the current modal is a bit ugly and squeezed together... a
   full-height side drawer that slides in from the right — same pattern as
   the agent dock but WIDER... clean-slate: strip ALL the current modal's
   CSS and structure, keep ALL the functionality." Every routine-scoped rule
   (.routine-*, .run-*, #run-log) for #routine-overlay used to live in the shared
   app-shell/overlays.css (six other dialogs' CSS lives in that file too) —
   moved here entirely, one source of truth for this surface, same principle
   T495/T496/T497 already applied elsewhere on this page.

   Motion technique is the SAME one .settings-drawer and the legacy
   .agent-dock already use (both in overlays.css) — not the newer
   .agent-dock-rail's CSS-Grid shell-push (multi-dock-push.css/T487): that
   mechanism exists so the dock can coexist with pushed page content, but
   the routine drawer and the dock are mutually exclusive by design
   (openRoutine() in connections-runtime.js closes an open dock before
   opening the drawer — the cheapest, least-surprising choice: nothing ever
   needs to make room for both at once, so there is no reason to wire a
   second shell-grid track). The technique: never display:none the drawer
   itself (display:none can't transition) — keep it permanently
   display:flex, and let transform+visibility do the show/hide, so
   translateX genuinely animates. state.js's overlay effect special-cases
   #routine-overlay into the same inert-toggle branch #settings-drawer
   already needed for the identical reason (a permanently-painted,
   off-screen-when-closed surface must still be marked unreachable).

   Desktop only (>=821px), matching multi-dock-push.css's own "one is-this-
   narrow answer" precedent for dock/topbar/nav — below 821px #routine-overlay
   keeps its original data-sheet-type="full" edge-to-edge mobile sheet
   entirely untouched (sheets.css), which already satisfies "full-height,
   first-class surface" at phone widths without needing a slide-in motion
   of its own. The old mobile-width run-list/run-log stacking rules
   (overlays.css, .routine-detail-body/.run-list/#run-log inside its own
   narrower media query) are untouched for the same reason — this drawer's
   markup kept the exact same #routine-detail-body/.run-list/#run-log
   structure and classes, just moved inside the new "Run history" section,
   so that pre-existing phone behavior keeps working unmodified. */
@media (min-width: 821px) {
  #routine-overlay {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
    background: transparent;
    /* #routine-overlay (the outer flex/backdrop container, per the base
       .overlay rule) spans the full viewport (left:0;width:100%) even
       though only .routine-panel is meant to be visible on the right —
       now that this element is permanently display:flex (never
       display:none) so the slide-in transition can run, a transparent
       full-viewport box would otherwise silently swallow every click on
       the rest of the page while "closed". pointer-events:none restores
       click-through; .open re-enables it so the click-outside-to-close
       backdrop still works while the drawer is actually open. */
    pointer-events: none;
  }
  #routine-overlay.open {
    pointer-events: auto;
  }
  #routine-overlay .routine-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(44rem, 100vw);
    height: 100%;
    max-height: none;
    margin: 0;
    border-radius: 0;
    border-left: 1px solid var(--ui-line);
    background: var(--ui-panel);
    /* Same shadow/border grammar as .agent-dock-rail (multi-dock.css) —
       visual kinship with the dock, without its grid-push mechanism. */
    box-shadow: -1rem 0 2.5rem rgb(0 0 0 / 0.18);
    transform: translateX(105%);
    visibility: hidden;
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
  }
  #routine-overlay.open .routine-panel {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.22s ease;
  }
}
.routine-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1.2rem 0.9rem;
  border-bottom: 1px solid var(--ui-line);
}
.routine-drawer-heading {
  min-width: 0;
  display: grid;
  gap: 0.5rem;
}
.routine-drawer-heading h1 {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-ui, inherit);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ui-text);
}
/* Zone 1 (operator order): name, human schedule, enabled state, next fire —
   all visible in one glance, no scrolling to find them. */
.routine-drawer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.9rem;
}
.routine-enabled-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--ui-hover);
  color: var(--ui-text-soft);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.routine-drawer-schedule {
  color: var(--ui-text-soft);
  font-size: 0.85rem;
}
.routine-drawer-next {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  color: var(--ui-text-soft);
  font-size: 0.85rem;
}
.routine-drawer-next small {
  color: var(--ui-muted);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 0.62rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.routine-drawer-head .close { flex: 0 0 auto; }
.routine-drawer-jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-bottom: 1px solid var(--ui-line);
  background: var(--ui-panel-soft, var(--ui-panel));
}
.routine-jump { min-height: 30px; padding: 0.3rem 0.75rem; font-size: 0.78rem; }
.routine-drawer-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.routine-drawer-body {
  min-height: 0;
  flex: 1;
  overflow: auto;
}
.routine-drawer-section {
  padding: 1.1rem 1.2rem 1.3rem;
  border-bottom: 1px solid var(--ui-line-soft, var(--ui-line));
}
.routine-drawer-section:last-child { border-bottom: 0; }
.routine-drawer-section-label {
  display: block;
  margin-bottom: 0.6rem;
  color: var(--ui-accent);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 0.65rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
/* Zone 2: "what it does" — the operator's stated pain point ("can't quickly
   understand what the routine actually is/does") gets the most generous
   type in the drawer, not squeezed modal copy. */
.routine-definition-copy {
  font-size: 0.98rem;
  line-height: 1.65;
}
.routine-drawer-section .routine-prompt {
  max-width: none;
  margin-top: 1rem;
}
/* Zone 3: engine/model + notify/tags — a compact metadata grid, reusing
   .routine-status/.routine-status-item verbatim (mountRoutineModelControls()
   in routines-workforce-models.js still anchors its injected Model tile via
   `#routine-status-engine.closest('.routine-status-item')`, and its
   injected #routine-config-edit block prepends into #routine-engine-pane —
   both keyed off these exact class/id names, unchanged from before this
   round). Border/background restated from scratch (was inherited from
   overlays.css's shared #routine-overlay chrome, now gone). */
.routine-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--ui-line);
  border-radius: 0.75rem;
  background: var(--ui-line);
}
.routine-status-item {
  min-width: 0;
  padding: 0.65rem 0.8rem;
  background: var(--ui-panel);
}
.routine-status-item small {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--ui-muted);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 0.6rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.routine-status-item span {
  display: block;
  overflow: hidden;
  color: var(--ui-text-soft);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#routine-engine-pane .routine-config-edit { margin-top: 0.9rem; }
/* Zone 4: run history — a full-width vertical list ("clean list... with
   room to breathe"), not the old 310px sidebar + log-pane split (that
   split made sense in an 980px-wide centered modal; at this drawer's own
   narrower width a stacked single column reads better and still keeps the
   log reachable per run — click a run, its log fills in below the list). */
.routine-runs-section .routine-detail-body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.routine-runs-section .run-list {
  display: grid;
  gap: 0.4rem;
  padding: 0;
  border: 0;
}
.run-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--ui-line);
  border-radius: 0.65rem;
  background: var(--ui-panel);
  color: inherit;
  text-align: left;
}
.run-button:hover { background: var(--ui-hover); }
.run-button.active {
  border-color: color-mix(in srgb, var(--ui-accent) 45%, transparent);
  background: var(--ui-accent-soft);
}
.run-when {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ui-text-soft);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 0.78rem;
}
.run-duration {
  flex: 0 0 auto;
  color: var(--ui-muted);
  font-family: var(--font-mono, ui-monospace, Menlo, monospace);
  font-size: 0.72rem;
}
#run-log {
  min-height: 220px;
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--ui-line);
  border-radius: 0.65rem;
  background: var(--ui-input);
  color: var(--ui-text-soft);
  font: 12.5px/1.55 ui-monospace, Menlo, monospace;
  white-space: pre-wrap;
  overflow: auto;
}
