/* Four 250px tiles + three 16px gaps fit 1048px. Auto-fit fills the actual item count. */
body .ml-library,body .ml-jobs,body .ml-dialog{--ml-ink:#202b35;--ml-muted:#596775;--ml-line:#e2e7eb;--ml-control:#c8d0d8;--ml-soft:#f2f6f8;--ml-accent:#245970;color:var(--ml-ink);font-family:inherit;font-size:14px;line-height:1.5;box-sizing:border-box}
body .ml-library *,body .ml-jobs *,body .ml-dialog *{box-sizing:border-box}
body .ml-library{background:#fff;border:1px solid var(--ml-line);border-radius:12px;padding:24px}
body .ml-library-head,body .ml-toolbar,body .ml-grid-heading,body .ml-dialog-head,body .ml-preview-meta,body .ml-dialog-actions,body .ml-composer-actions{display:flex;align-items:center;justify-content:space-between;gap:12px}
body .ml-library-head{align-items:flex-start;flex-wrap:wrap;margin-bottom:24px}body .ml-library h2,body .ml-jobs h2{font-size:20px;line-height:1.4;margin:0;font-weight:600}body .ml-library-head p{color:var(--ml-muted);margin:6px 0 0}body .ml-toolbar{justify-content:flex-end;flex-wrap:wrap}
body .ml-library button,body .ml-jobs button,body .ml-dialog button,body .ml-dialog a{font:inherit;letter-spacing:normal;cursor:pointer}
body .ml-library button:not(.ml-thumb),body .ml-jobs button,body .ml-dialog button{min-height:38px;padding:8px 14px;margin:0;border:1px solid var(--ml-control);border-radius:8px;background:#fff;color:var(--ml-ink);box-shadow:none;line-height:20px;font-weight:500;white-space:nowrap}
body .ml-library button.ml-primary,body .ml-dialog button.ml-primary{background:#233944;color:#fff;border-color:#233944}body .ml-dialog button.ml-danger{background:#fff;color:#a6232b;border-color:#d8b3b6}
body .ml-library button:hover,body .ml-jobs button:hover,body .ml-dialog button:hover{filter:brightness(.96)}body .ml-library :focus-visible,body .ml-dialog :focus-visible{outline:2px solid var(--ml-accent);outline-offset:3px}body .ml-dialog button:disabled{cursor:wait;background:#e8edf0;color:#55616c;border-color:#d2d9df;opacity:1}
body .ml-filters{display:flex;align-items:flex-end;gap:12px;padding:16px;background:var(--ml-soft);border-radius:8px}body .ml-filters label,body .ml-form label,body .ml-composer label{display:grid;gap:8px;margin:0;font-size:13px;font-weight:500;min-width:0}body .ml-search{flex:1}body .ml-filters select{min-width:150px}
body .ml-library input,body .ml-library select,body .ml-dialog input:not([type=file]),body .ml-dialog textarea,body .ml-dialog select{width:100%;min-height:40px;border:1px solid var(--ml-control);border-radius:8px;background:#fff;color:var(--ml-ink);font:inherit;margin:0;padding:9px 12px;box-shadow:none;line-height:20px}
body .ml-library input::placeholder,body .ml-dialog textarea::placeholder{color:#677481;opacity:1}body .ml-library select,body .ml-dialog select{appearance:none;padding-right:36px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23596775' stroke-width='1.5'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;cursor:pointer}
body .ml-grid-heading{color:var(--ml-muted);font-size:12px;margin:20px 0 12px}body .ml-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(250px,100%),1fr));gap:16px;align-items:stretch}body .ml-card{min-width:0;border:1px solid var(--ml-line);border-radius:10px;overflow:hidden;background:#fff;display:flex;flex-direction:column;box-shadow:none}
body .ml-thumb{height:232px;width:100%;position:relative;display:block;border:0;border-radius:0;padding:0;margin:0;overflow:hidden;background:#edf1f3;cursor:pointer;color:var(--ml-muted)}body .ml-thumb img{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;background:#edf1f3}body .ml-thumb img[hidden]{display:none}body .ml-fallback{position:absolute;inset:0;display:grid;place-content:center;font-size:13px}body .ml-kind{position:absolute;bottom:10px;left:10px;background:#fff;color:#34434c;border-radius:4px;padding:2px 8px;font-size:12px}body .ml-play{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);display:grid;place-content:center;width:44px;height:44px;border-radius:50%;background:#243841d9;color:white;font-size:18px}
body .ml-info{padding:16px;display:flex;flex-direction:column;gap:8px;flex:1}body .ml-info>strong{font-size:14px;line-height:21px;overflow-wrap:anywhere;font-weight:600}body .ml-info>small{font-size:12px;color:var(--ml-muted);font-variant-numeric:tabular-nums}body .ml-actions{display:flex;gap:4px 12px;flex-wrap:wrap;align-items:center;margin-top:auto;padding-top:8px}body .ml-actions a,body .ml-actions button:not(.ml-thumb){font-size:13px;color:var(--ml-muted);padding:0;min-height:32px;border:0;background:transparent;text-decoration:none}body .ml-actions button.ml-ai-action{color:var(--ml-accent);font-weight:600;margin-right:auto}body .ml-actions a:hover{text-decoration:underline}body .ml-empty{grid-column:1/-1;padding:28px 16px;text-align:center;background:var(--ml-soft);border-radius:8px}body .ml-empty p{color:var(--ml-muted);margin:8px 0 0}
body .ml-jobs{padding:24px 0;margin-top:8px}body .ml-jobs>header{display:flex;align-items:baseline;justify-content:space-between;gap:16px;margin-bottom:12px}body .ml-jobs>header>span{color:var(--ml-muted);font-size:12px}body .ml-job{display:flex;align-items:center;gap:16px;border-bottom:1px solid var(--ml-line);padding:12px 0}body .ml-job>div{flex:1;min-width:0}body .ml-job strong{font-weight:500;overflow-wrap:anywhere}body .ml-job p{font-size:12px;color:var(--ml-muted);margin:4px 0 0}body .ml-job>.ops-status{flex:none;white-space:nowrap}body .ml-muted{color:var(--ml-muted)}
body .ml-dialog{padding:0;border:1px solid var(--ml-line);border-radius:14px;background:#fff;max-width:calc(100vw - 40px);max-height:calc(100dvh - 40px);box-shadow:0 24px 80px #14232e33;overflow:auto}body .ml-dialog::backdrop{background:#17253080}body .ml-dialog-head{padding:16px 20px;border-bottom:1px solid var(--ml-line);background:#fff;position:sticky;top:0;z-index:2}body .ml-dialog-head h2{margin:0;font-size:16px;font-weight:600;overflow-wrap:anywhere;min-width:0}body .ml-dialog button.ml-icon-button{width:36px;height:36px;min-height:36px;padding:4px;font-size:24px;border:0;background:var(--ml-soft);flex:none}body .ml-compact{width:520px}body .ml-form{padding:24px;display:grid;gap:16px}body .ml-form p{margin:0}body .ml-dialog small{font-size:12px;color:var(--ml-muted);line-height:1.6}body .ml-dialog textarea{resize:vertical;min-height:92px}body .ml-dialog-actions{justify-content:flex-end;margin-top:4px}body .ml-error{color:#a6232b;font-size:13px}body .ml-error:empty{display:none}
body .ml-form .ml-file-zone{position:relative;padding:32px 20px;border:1px solid var(--ml-control);border-radius:10px;background:var(--ml-soft);text-align:center;place-items:center;cursor:pointer;overflow:hidden}body .ml-file-title{display:inline-block;background:#fff;border:1px solid var(--ml-control);border-radius:8px;padding:8px 16px;color:var(--ml-ink)}body .ml-file-zone [data-file-name]{font-size:13px;font-weight:400;color:var(--ml-muted);overflow-wrap:anywhere;max-width:100%}body .ml-file-input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}body .ml-file-zone:focus-within,body .ml-file-zone.is-dragging{outline:2px solid var(--ml-accent);outline-offset:2px}
body .ml-studio{width:1180px;overflow:hidden}body .ml-studio-body{display:grid;grid-template-columns:minmax(0,1fr) 400px;height:min(730px,calc(100dvh - 130px));min-height:400px}body .ml-preview-pane{display:flex;flex-direction:column;min-width:0;min-height:0;background:#edf1f3}body .ml-viewer-wrap{display:flex;align-items:center;justify-content:center;flex:1;min-height:0;padding:24px}body .ml-viewer{display:block;max-width:100%;max-height:100%;object-fit:contain;width:auto;height:auto}body .ml-preview-meta{padding:14px 20px;font-size:12px;color:var(--ml-muted);background:#f7f9fa;border-top:1px solid var(--ml-line)}body .ml-preview-meta a{color:var(--ml-accent);text-decoration:none;font-size:13px}
body .ml-chat-pane{display:flex;flex-direction:column;min-height:0;border-left:1px solid var(--ml-line);background:#fff}body .ml-chat-heading{padding:20px 20px 12px}body .ml-chat-heading h3{margin:0 0 6px;font-size:16px;font-weight:600}body .ml-chat-heading p{font-size:12px;color:var(--ml-muted);margin:0;line-height:1.6}body .ml-chat-log{flex:1;overflow:auto;padding:8px 20px 16px;min-height:120px;overscroll-behavior:contain}body .ml-chat-empty{padding:20px 0;font-size:14px}body .ml-chat-empty strong{font-weight:500}body .ml-chat-empty p{color:var(--ml-muted);font-size:13px;margin:8px 0 16px}body .ml-chat-empty button{font-size:12px;white-space:normal;text-align:left;background:var(--ml-soft)}body .ml-message{padding:12px 0;font-size:14px;overflow-wrap:anywhere}body .ml-message strong{font-size:12px;color:var(--ml-muted);font-weight:500}body .ml-message p{margin:6px 0 0;white-space:pre-wrap;line-height:1.7}body .ml-message.user{background:var(--ml-soft);border-radius:8px;padding:12px;margin:8px 0}body .ml-composer{padding:16px 20px;border-top:1px solid var(--ml-line);background:#fff}body .ml-composer>label{font-size:12px;color:var(--ml-muted);margin-bottom:8px}body .ml-composer-actions{justify-content:flex-end;margin:10px 0}body .ml-composer button{font-size:13px}body .ml-chat-status{font-size:12px;color:var(--ml-accent);margin:8px 0;line-height:1.6}body .ml-chat-status:empty{display:none}body .ml-output-options{margin-top:8px;font-size:12px;color:var(--ml-muted)}body .ml-output-options summary{cursor:pointer;min-height:24px}body .ml-options-row{display:flex;gap:12px;margin-top:8px}body .ml-options-row>label{flex:1;font-size:12px}body .ml-options-row select{min-height:36px;font-size:12px;padding-top:7px;padding-bottom:7px}body .ml-result{padding:12px 20px;background:#edf5f7;color:#274f60;font-size:13px}body .ml-result[hidden]{display:none}body .ml-result p{margin:0 0 8px}body .ml-result button{font-size:12px;white-space:normal}body .ml-preview-only .ml-studio-body{grid-template-columns:1fr}
body .ml-dialog .ws-select-popup{border:1px solid var(--ml-control);border-radius:10px;box-shadow:0 8px 24px #15263224;background:#fff;color:var(--ml-ink);padding:6px}body .ml-dialog .ws-select-option{padding:10px 12px;border-radius:6px;font-size:14px}body .ml-dialog .ws-select-option.is-active{background:#eaf1f4;color:#214c60}
@media(max-width:1000px){body .ml-studio-body{grid-template-columns:minmax(0,1fr) 360px}body .ml-library{padding:20px}body .ml-grid{grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr))}}
@media(max-width:680px){body .ml-library{padding:16px}body .ml-library-head{gap:16px;margin-bottom:16px}body .ml-library-head h2{font-size:20px}body .ml-library-head p{font-size:13px}body .ml-toolbar{width:100%;justify-content:flex-start;gap:8px}body .ml-library button:not(.ml-thumb),body .ml-dialog button,body .ml-jobs button{min-height:44px}body .ml-filters{flex-wrap:wrap;padding:12px;gap:10px}body .ml-search{flex:1 1 100%}body .ml-filters label:not(.ml-search){flex:1;min-width:0}body .ml-filters select{min-width:0}body .ml-filters>button{display:none}body .ml-grid-heading>span:last-child{display:none}body .ml-grid{grid-template-columns:1fr}body .ml-thumb{height:240px}body .ml-jobs>header{display:block}body .ml-jobs>header>span{display:block;margin-top:6px}body .ml-job{flex-wrap:wrap;gap:8px}body .ml-job>div{flex-basis:100%}body .ml-dialog{max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);border-radius:12px}body .ml-dialog-head{padding:12px 16px}body .ml-form{padding:20px}body .ml-studio{overflow:auto}body .ml-studio-body{display:flex;flex-direction:column;height:auto;min-height:0}body .ml-preview-pane{height:240px;flex-shrink:0}body .ml-viewer-wrap{padding:12px}body .ml-preview-meta{padding:10px 16px}body .ml-chat-pane{border-left:0;border-top:1px solid var(--ml-line);min-height:480px}body .ml-chat-log{max-height:280px;min-height:100px}body .ml-chat-heading{padding:16px 16px 8px}body .ml-composer{padding:16px}body .ml-dialog textarea{font-size:16px}body .ml-chat-empty{padding:8px 0}body .ml-composer-actions button{flex:1}body .ml-preview-only .ml-preview-pane{height:65vh}}

body.workspace-redesign .ml-library-head,body.workspace-redesign .ml-jobs>header,body.workspace-redesign .ml-dialog-head,body.workspace-redesign .ml-chat-heading{height:auto;min-height:0;background:transparent;border-bottom:0;box-shadow:none}
body.workspace-redesign .ml-library-head{padding:0;margin:0 0 24px}body.workspace-redesign .ml-jobs>header{padding:0;margin:0 0 12px}body.workspace-redesign .ml-dialog-head{padding:16px 20px;border-bottom:1px solid var(--ml-line)}body.workspace-redesign .ml-chat-heading{padding:20px 20px 12px}

body.workspace-redesign .ml-chat-heading{display:block}body.workspace-redesign .ml-jobs{min-height:0}body.workspace-redesign .ml-dialog .ml-studio-body{margin:0}

body .ml-studio-body{min-height:0}body .ml-chat-pane{overflow:auto}body .ml-composer{flex-shrink:0}
