/* UI V3 routines reuse the shell, tokens, device switch and shared workflow editor. */
#app-view .routines-view{display:grid;gap:var(--v3-space-4);padding-top:var(--v3-space-3);min-width:0}
.routines-view-header{display:flex;justify-content:space-between;align-items:center;gap:var(--v3-space-3)}
.routines-view-header h3{margin:0;font-size:1.8rem;letter-spacing:-.035em;color:var(--v3-text)}
.routines-view-header p{color:var(--v3-muted);font-size:.85rem}
.routine-search{display:block;margin:var(--v3-space-3) 0}
.routine-search input{width:100%;min-height:var(--v3-touch);border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);padding:var(--v3-space-3);background:var(--v3-card);color:var(--v3-text)}
.routines-page-list{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--v3-space-3)}
#app-view .routine-card{display:flex;flex-direction:column;min-width:0;background:var(--v3-card);border:1px solid var(--v3-border);border-radius:var(--v3-radius-md);padding:var(--v3-space-4);gap:var(--v3-space-3)}
#app-view .routine-card-main{display:flex;align-items:flex-start;gap:var(--v3-space-3);min-width:0;border:0;background:transparent;color:var(--v3-text);text-align:left;padding:0;min-height:var(--v3-touch);width:100%}
.routine-page-icon{display:grid;place-items:center;width:44px;height:44px;flex-shrink:0;border-radius:var(--v3-radius-sm);background:var(--v3-secondary);color:var(--v3-primary);font-size:1.4rem}
.routine-page-copy{display:grid;gap:6px;min-width:0;overflow-wrap:anywhere}
.routine-page-copy strong{font-size:.95rem;line-height:1.4;white-space:normal}
.routine-page-copy small,.routine-page-copy>span{font-size:.78rem;color:var(--v3-muted);line-height:1.5;white-space:normal}
#app-view .routines-view .native-workflow-actions{display:flex;justify-content:flex-end;gap:var(--v3-space-2);align-items:center;margin-top:auto}
#app-view .routines-view .routine-run,#app-view .routines-view .native-workflow-edit,#app-view .routines-view .management-create-button,.routines-empty button{min-height:var(--v3-touch);min-width:var(--v3-touch);border:0;border-radius:var(--v3-radius-sm);padding:8px 12px;background:var(--v3-secondary);color:var(--v3-primary);cursor:pointer}
#app-view .routines-view .routine-run{display:flex;gap:8px;align-items:center;justify-content:center}
.routines-empty{grid-column:1/-1;padding:var(--v3-space-5);background:var(--v3-card);border:1px dashed var(--v3-border);border-radius:var(--v3-radius-md);color:var(--v3-muted);text-align:center}
.routines-view button:focus-visible,.routines-view input:focus-visible,#management-editor[data-editor-type="workflow-routine"] :is(button,input,select,textarea):focus-visible{outline:3px solid var(--v3-primary);outline-offset:3px}
#management-editor[data-editor-type="workflow-routine"] .management-editor-panel{display:flex;flex-direction:column;width:min(800px,100%);max-height:calc(100dvh - 40px);overflow:hidden;background:var(--v3-card);color:var(--v3-text);border-radius:var(--v3-radius-md);border:1px solid var(--v3-border)}
#management-editor[data-editor-type="workflow-routine"] .management-editor-header{flex-shrink:0;padding:16px;min-width:0}
#management-editor[data-editor-type="workflow-routine"] .management-editor-close{min-width:44px;min-height:44px;color:var(--v3-text)}
#management-editor[data-editor-type="workflow-routine"] .management-editor-body{overflow:auto;min-height:0;padding:12px 16px}
#management-editor[data-editor-type="workflow-routine"] .management-editor-actions{flex-shrink:0;display:flex;flex-wrap:wrap;justify-content:space-between;gap:8px;padding:12px 16px;border-top:1px solid var(--v3-border)}
.routine-primary-actions,.routine-destructive-actions{display:flex;flex-wrap:wrap;gap:6px}
.routine-primary-actions{margin-left:auto;justify-content:flex-end}
#management-editor[data-editor-type="workflow-routine"] :is(input,select,textarea,button){min-height:44px;min-width:0}
#management-editor[data-editor-type="workflow-routine"] :is(input:not([type=checkbox]),select,textarea){width:100%;border:1px solid var(--v3-border);border-radius:var(--v3-radius-sm);background:var(--v3-card);color:var(--v3-text);padding:10px}
#management-editor[data-editor-type="workflow-routine"] .workflow-editor-row{display:flex;flex-wrap:wrap;gap:8px;border:1px solid var(--v3-border);background:var(--v3-page);padding:12px;border-radius:var(--v3-radius-sm);margin-bottom:10px}
#management-editor[data-editor-type="workflow-routine"] .workflow-editor-row>select,#management-editor[data-editor-type="workflow-routine"] .workflow-editor-row>input{flex:1 1 180px}
#management-editor[data-editor-type="workflow-routine"] .workflow-editor-section-head{display:flex;justify-content:space-between;align-items:center}
#management-editor[data-editor-type="workflow-routine"] .workflow-editor-section{padding:0;border:0;background:transparent}
#management-editor[data-editor-type="workflow-routine"] button{border-radius:var(--v3-radius-sm);cursor:pointer}
#management-editor[data-editor-type="workflow-routine"] .management-editor-primary{background:var(--v3-primary);color:var(--v3-primary-contrast)}
#management-editor[data-editor-type="workflow-routine"] .management-editor-secondary{background:var(--v3-secondary);color:var(--v3-text)}
.routine-manual-note,[data-workflow-dirty]{font-size:.8rem;line-height:1.5;color:var(--v3-muted)}
@media(max-width:1100px){.routines-page-list{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:700px){.routines-page-list{grid-template-columns:1fr}#management-editor[data-editor-type="workflow-routine"]{padding:8px}#management-editor[data-editor-type="workflow-routine"] .management-editor-panel{max-height:calc(100dvh - 16px)}#management-editor[data-editor-type="workflow-routine"] .management-editor-actions{padding:8px}.routine-primary-actions{width:100%}}
/* Override the legacy modal's mobile reversal only for the routine editor. */
#management-editor[data-editor-type="workflow-routine"] .management-editor-actions{flex-direction:row}
#management-editor[data-editor-type="workflow-routine"] .routine-primary-actions button,#management-editor[data-editor-type="workflow-routine"] .routine-destructive-actions button{width:auto;flex:none}
/* Explicit height keeps native WebKit entity selects touch-sized. */
#management-editor[data-editor-type="workflow-routine"] select{height:var(--v3-touch);min-height:var(--v3-touch)}
