/* Model connections share the workspace's semantic palette and controls. */
#model-settings{color:var(--ink)}
html[data-theme="dark"] .workspace-shell:has(#model-settings) .site-header{background:var(--canvas);color:var(--ink)}
.model-page-caption{color:var(--muted);font-size:13px;margin-top:12px;line-height:1.7}
.model-page-body{max-width:1120px}
.model-section{margin-bottom:32px}
.model-section-heading{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:16px}
.model-section-heading h2{font-size:17px}
.model-section-heading p,.model-default-row p,.model-dialog-caption{color:var(--muted);font-size:13px;margin-top:4px}
.model-section-heading .button{flex-shrink:0;min-height:44px}
.model-defaults{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-card,12px);padding:0 24px}
.model-default-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,43%);gap:24px;align-items:center;padding:20px 0}
.model-default-row+.model-default-row{border-top:1px solid var(--line)}
.model-default-row label{font-weight:600}
.model-default-row select{width:100%;min-width:0;min-height:44px;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:8px;padding:8px 12px}
.model-connections{display:grid;gap:16px}
.model-provider{border:1px solid var(--line);border-radius:var(--radius-card,12px);background:var(--surface);padding:20px 24px 12px;min-width:0}
.model-provider header{display:flex;justify-content:space-between;align-items:center;gap:16px}
.model-provider-title{min-width:0;flex:1}
.model-provider-title h3{display:inline;font-size:16px;overflow-wrap:anywhere}
.model-state{display:inline-block;font-size:12px;color:var(--muted);margin-left:12px}
.model-provider-title p{font-size:12px;color:var(--muted);margin-top:3px}
.model-actions{display:flex;gap:8px;align-items:center;flex-shrink:0}
.model-actions button,.model-provider footer button{min-height:44px;min-width:44px;white-space:nowrap}
.model-list{list-style:none;padding:0;margin:16px 0 0;border-top:1px solid var(--line)}
.model-list li{padding:14px 0;display:flex;gap:16px;align-items:center;justify-content:space-between}
.model-list li+li{border-top:1px solid var(--line)}
.model-identity{min-width:0;display:grid;gap:2px}
.model-identity strong{font-weight:500;overflow-wrap:anywhere}
.model-identity span,.model-identity small{font-size:12px;color:var(--muted);overflow-wrap:anywhere}
.model-provider footer{display:flex;align-items:center;gap:14px;border-top:1px solid var(--line);padding-top:8px;flex-wrap:wrap}
.model-remove{margin-left:auto}
.model-inline-status{font-size:13px;color:var(--muted);min-height:0;margin-top:8px;overflow-wrap:anywhere}
.model-inline-status:empty{display:none}
.model-inline-status.error{color:var(--danger)}
.model-no-models{font-size:13px;color:var(--muted)}
.model-empty{text-align:center;border:1px dashed var(--line);border-radius:12px;padding:32px 24px;color:var(--muted)}
.model-empty strong{display:block;color:var(--ink);font-size:15px;font-weight:500;margin-bottom:8px}
.model-empty p{font-size:13px}
.model-help{border-top:1px solid var(--line);padding-top:12px;margin-top:24px;color:var(--muted);font-size:13px}
.model-help summary,.model-advanced summary{min-height:44px;display:list-item;align-content:center;cursor:pointer}
.model-help p{margin:8px 0;max-width:760px}
.model-config-dialog{width:min(540px,calc(100vw - 32px))}
.model-config-dialog .field{margin-bottom:16px}
.model-config-dialog .field label{color:var(--ink)}
.model-config-dialog .dialog-body{overflow-x:hidden}
.model-config-dialog input:not([type=checkbox]),.model-config-dialog select{min-height:44px;width:100%;min-width:0}
.model-config-dialog select{border:1px solid var(--line);border-radius:8px;padding:8px 12px;background:var(--surface);color:var(--ink)}
.model-config-dialog .hint{display:block;font-size:12px;color:var(--muted);line-height:1.6;margin-top:5px}
.model-config-dialog .model-dialog-caption{margin-bottom:16px}
.model-advanced{border-top:1px solid var(--line);margin-top:8px}
.model-capabilities{border:0;margin:0 0 16px;padding:0}
.model-capabilities legend{font-size:13px;font-weight:500;margin-bottom:4px}
.model-check{display:flex;align-items:center;gap:10px;min-height:44px;cursor:pointer;font-size:14px}
.model-check input{width:16px;height:16px;flex:none;margin:0;accent-color:var(--accent)}
.model-check:has(input:disabled){color:var(--muted);cursor:default}
.model-config-dialog .text-button{min-height:44px;min-width:44px}
@media(max-width:760px){.model-default-row{grid-template-columns:1fr;gap:12px}.model-defaults{padding:0 20px}.model-provider{padding:20px 20px 12px}.model-provider header{align-items:flex-start;flex-direction:column}.model-provider header .model-actions{width:100%}.model-provider header .model-actions button{flex:1}.model-section-heading{align-items:flex-start;gap:12px}.model-section-heading h2{font-size:16px}.model-section-heading p{max-width:250px}.model-state{margin-left:8px}.model-actions{gap:4px}.model-list li{gap:8px}.model-provider footer{gap:10px}.model-page-caption{max-width:90%}}
@media(max-width:420px){.model-section-heading{flex-wrap:wrap}.model-section-heading .button{margin-left:auto}.model-defaults{padding:0 16px}.model-provider{padding:16px}.model-remove{margin-left:0}.model-list li{align-items:flex-start}.model-config-dialog{width:calc(100vw - 16px)}}

/* Independent settings surface: the workspace and its media stay mounted. */
dialog#model-settings-modal{width:min(1080px,calc(100vw - 48px));max-width:none;height:min(860px,calc(100dvh - 48px));max-height:calc(100dvh - 48px);padding:0;border:1px solid var(--line);border-radius:16px;background:var(--canvas);color:var(--ink);overflow:hidden}
#model-settings-modal::backdrop{background:rgba(20,24,32,.28);backdrop-filter:none}
.model-popup-layout{display:flex;flex-direction:column;height:100%;min-height:0}
.model-popup-header{display:flex;flex:none;align-items:flex-start;justify-content:space-between;gap:16px;padding:20px 28px;border-bottom:1px solid var(--line);background:var(--surface)}
.model-popup-header h2{margin:0;font-size:22px;line-height:1.4;font-weight:600}
.model-popup-header p{margin:6px 0 0;color:var(--muted);font-size:13px;line-height:1.6}
.model-popup-header .icon-button{min-width:44px;min-height:44px;flex:none}
.model-popup-notice{flex:none;padding:10px 28px;border-bottom:1px solid var(--line);background:var(--surface);color:var(--ink);font-size:13px;line-height:1.6;overflow-wrap:anywhere}
.model-popup-notice.is-error{color:var(--danger)}
.model-popup-body{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable;scroll-padding-block:24px}
#model-settings-modal .page-body{padding:28px;margin:0;width:auto;max-width:none}
#model-settings-modal .model-section:last-child{margin-bottom:0}
#model-settings-modal :is(button,select,summary):focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.model-popup-loading,.model-popup-error{padding:32px 28px;color:var(--muted);font-size:14px}
.model-popup-loading{display:flex;align-items:center;gap:12px}
.model-popup-error p{margin:0 0 16px;color:var(--ink);overflow-wrap:anywhere}
@media(max-width:760px){dialog#model-settings-modal{width:calc(100vw - 24px);height:calc(100dvh - 24px);max-height:calc(100dvh - 24px);border-radius:12px}.model-popup-header{padding:16px 20px}.model-popup-header h2{font-size:20px}#model-settings-modal .page-body{padding:24px 20px}}
@media(max-width:420px){.model-popup-header{padding:14px 16px}#model-settings-modal .page-body{padding:20px 16px}.model-popup-loading,.model-popup-error{padding:24px 16px}}
