/* ==========================================================================
   MesonX AI Studio — visual agentic workflow canvas
   Ported from the MyFamilyAssistant.ai canvas, restyled for Mesonsoft:
   light glass surfaces, violet→pink gradient accents, lavender borders.
   ========================================================================== */

.ms-studio-root{width:100%;max-width:100%}
.ms-studio-root.ms-studio-root-page{width:100%;max-width:100%}

/* ---------- Compact app masthead (not a marketing hero) ---------- */
.ms-studio-masthead{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;flex-wrap:wrap;padding:34px 4px 20px}
.ms-studio-mast-copy{max-width:720px;min-width:0}
.ms-studio-masthead .ms-cai-eyebrow{margin-bottom:10px}
.ms-studio-mast-h1{margin:0;font-size:clamp(26px,3.4vw,38px);font-weight:800;line-height:1.14;letter-spacing:-1.1px;color:#171f2b}
.ms-studio-mast-sub{margin:10px 0 0;font-size:15px;line-height:1.6;color:#5b6675}
.ms-studio-mast-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}

/* ---------- The builder is the hero: full-bleed, tall ---------- */
.ms-studio-stagewrap{position:relative;padding:10px;border-radius:26px;border:1px solid #ece6f6;background:linear-gradient(165deg,#fdfcff,#f7f4fd);box-shadow:0 34px 70px -46px rgba(124,58,237,.55);margin-bottom:8px}
.ms-studio-stagewrap .ms-studio-wrap{border-radius:18px;box-shadow:none}
.ms-studio-stagewrap .ms-studio-body{min-height:min(74vh,760px)}
.ms-studio-stagewrap .ms-studio-palette{max-height:none}
.ms-studio-stagewrap .ms-studio-stage{min-height:min(70vh,720px)}

/* ---------- Shell ---------- */
.ms-studio-wrap{overflow:hidden;border-radius:20px;border:1px solid #ece6f6;background:#fff;box-shadow:0 26px 54px -40px rgba(124,58,237,.5);font-family:inherit}
.ms-studio-head{display:flex;align-items:center;gap:8px;padding:14px 18px;border-bottom:1px solid #f1ebfa;background:linear-gradient(120deg,#fbf9ff,#fdf3f8)}
.ms-studio-head .ms-vb-dot{width:9px;height:9px;border-radius:50%;background:#e6dff2}
.ms-studio-head .ms-vb-dot:nth-child(1){background:#ff5f57}
.ms-studio-head .ms-vb-dot:nth-child(2){background:#febc2e}
.ms-studio-head .ms-vb-dot:nth-child(3){background:#28c840}
.ms-studio-title{font-size:14.5px;font-weight:700;letter-spacing:-.2px;color:#171f2b}
.ms-studio-chip{display:inline-flex;align-items:center;gap:5px;margin-left:auto;padding:4px 11px;border-radius:999px;font-size:11.5px;font-weight:700;letter-spacing:.03em;color:#7c3aed;background:rgba(124,58,237,.09);border:1px solid rgba(124,58,237,.18)}
.ms-studio-chip.is-run{color:#0ea77e;background:rgba(14,167,126,.1);border-color:rgba(14,167,126,.2)}
.ms-studio-chip.is-busy{color:#c04bff;background:rgba(192,75,255,.1);border-color:rgba(192,75,255,.22)}

/* ---------- 3-column body ---------- */
.ms-studio-body{display:grid;grid-template-columns:246px minmax(0,1fr);min-height:520px}
@media (max-width:900px){.ms-studio-body{grid-template-columns:1fr}}

/* ---------- Palette ---------- */
.ms-studio-palette{padding:16px 14px;border-right:1px solid #f1ebfa;background:linear-gradient(180deg,#fdfcff,#faf7ff);max-height:600px;overflow-y:auto}
@media (max-width:900px){.ms-studio-palette{border-right:none;border-bottom:1px solid #f1ebfa;max-height:none}}
.ms-studio-palette-title{margin:0 0 4px;font-size:11px;font-weight:800;letter-spacing:.1em;text-transform:uppercase;color:#8b86a3}
.ms-studio-group{margin:14px 0 6px;font-size:11.5px;font-weight:700;color:#171f2b}
.ms-studio-item{display:flex;align-items:center;gap:10px;margin-bottom:6px;padding:9px 10px;border-radius:12px;border:1px solid #f1ebfa;background:#fff;cursor:grab;transition:border-color .2s ease,transform .2s ease,box-shadow .2s ease}
.ms-studio-item:hover{border-color:rgba(159,102,255,.5);transform:translateX(2px);box-shadow:0 10px 22px -18px rgba(124,58,237,.8)}
.ms-studio-item:active{cursor:grabbing}
.ms-studio-ico{display:grid;place-items:center;width:26px;height:26px;flex:0 0 26px;border-radius:9px;color:#fff}
.ms-studio-ico svg{width:14px;height:14px}
.ms-studio-item p{margin:0;font-size:12.5px;font-weight:600;color:#171f2b;line-height:1.25}
.ms-studio-item span{display:block;margin-top:1px;font-size:10.5px;color:#8b86a3}

/* ---------- Toolbar ---------- */
.ms-studio-toolbar{display:flex;flex-wrap:wrap;gap:6px;margin-top:16px;padding-top:14px;border-top:1px solid #f1ebfa}
.ms-studio-btn{padding:7px 12px;border-radius:10px;border:1px solid #e6dff2;background:#fff;font-family:inherit;font-size:12px;font-weight:700;color:#5b6675;cursor:pointer;transition:all .2s ease}
.ms-studio-btn:hover{border-color:#9F66FF;color:#7c3aed}
.ms-studio-btn:disabled{opacity:.45;cursor:not-allowed}
.ms-studio-btn.is-primary{color:#fff;border-color:transparent;background:linear-gradient(120deg,#9F66FF,#FF196E);box-shadow:0 12px 24px -14px rgba(159,102,255,.9)}
.ms-studio-btn.is-primary:hover{filter:brightness(1.06);color:#fff}
.ms-studio-btn.is-danger:hover{border-color:#f43f5e;color:#e11d48}

/* ---------- Canvas column ---------- */
.ms-studio-canvascol{display:flex;flex-direction:column;min-width:0}
.ms-studio-hintbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 16px;border-bottom:1px solid #f1ebfa;background:#fdfcff}
.ms-studio-hintbar .ms-studio-chip{margin-left:0}
.ms-studio-stage{position:relative;flex:1;min-height:440px;background:#fff}
.ms-studio-stage .react-flow__attribution{display:none}
.ms-studio-stage .react-flow__controls{border:1px solid #ece6f6;border-radius:10px;overflow:hidden;box-shadow:0 10px 24px -18px rgba(124,58,237,.7)}
.ms-studio-stage .react-flow__controls-button{background:#fff;border-bottom:1px solid #f1ebfa;color:#5b6675}
.ms-studio-stage .react-flow__controls-button:hover{background:#faf7ff}
.ms-studio-stage .react-flow__minimap{border:1px solid #ece6f6;border-radius:10px;background:#fff}


/* ---------- Nodes ---------- */
.ms-studio-node{position:relative;min-width:196px;padding:11px 13px;border-radius:14px;border:1px solid #ece6f6;background:#fff;box-shadow:0 14px 30px -24px rgba(31,41,55,.55);transition:border-color .2s ease,box-shadow .2s ease,transform .2s ease}
.ms-studio-node::before{content:"";position:absolute;inset:0 auto 0 0;width:4px;border-radius:14px 0 0 14px;background:var(--ms-accent,#9F66FF)}
.ms-studio-node.is-selected{border-color:var(--ms-accent,#9F66FF);box-shadow:0 0 0 3px color-mix(in srgb,var(--ms-accent,#9F66FF) 18%,transparent),0 18px 34px -22px rgba(124,58,237,.7)}
.ms-studio-node-top{display:flex;align-items:center;gap:8px;margin-bottom:5px}
.ms-studio-node-ico{display:grid;place-items:center;width:24px;height:24px;flex:0 0 24px;border-radius:8px;background:color-mix(in srgb,var(--ms-accent,#9F66FF) 14%,#fff);color:var(--ms-accent,#9F66FF)}
.ms-studio-node-ico svg{width:13px;height:13px}
.ms-studio-node-label{flex:1;min-width:0;font-size:12.5px;font-weight:700;line-height:1.25;color:#171f2b;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ms-studio-node-input{width:100%;padding:4px 6px;border-radius:7px;border:1px solid #d9cff5;background:#fdfcff;font-family:inherit;font-size:12.5px;font-weight:700;color:#171f2b;outline:none}
.ms-studio-node-input:focus{border-color:#9F66FF;box-shadow:0 0 0 3px rgba(159,102,255,.16)}
.ms-studio-node-meta{display:flex;align-items:center;gap:6px;margin-top:6px}
.ms-studio-node-type{font-size:10px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:#8b86a3}
.ms-studio-status{display:inline-flex;align-items:center;gap:4px;margin-left:auto;padding:2px 8px;border-radius:999px;font-size:10px;font-weight:700}
.ms-studio-status i{width:5px;height:5px;border-radius:50%;background:currentColor}
.ms-studio-node-del{position:absolute;top:-8px;right:-8px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;border:1px solid #ece6f6;background:#fff;color:#8b86a3;font-size:13px;line-height:1;cursor:pointer;opacity:0;transition:opacity .18s ease,color .18s ease,border-color .18s ease}
.ms-studio-node:hover .ms-studio-node-del,.ms-studio-node:focus-within .ms-studio-node-del{opacity:1}
.ms-studio-node-del:hover{color:#e11d48;border-color:#fecdd3}
.ms-studio-node.is-running{border-color:#c04bff;box-shadow:0 0 0 3px rgba(192,75,255,.16),0 18px 34px -22px rgba(192,75,255,.8)}
.ms-studio-node.is-completed{border-color:rgba(14,167,126,.55)}
.ms-studio-node.is-failed{border-color:#f43f5e;box-shadow:0 0 0 3px rgba(244,63,94,.14)}
.ms-studio-hint{margin:4px 0 0;font-size:9.5px;line-height:1.4;color:#8b86a3}
.ms-studio-handle{width:9px!important;height:9px!important;border:2px solid #fff!important;background:var(--ms-accent,#9F66FF)!important}

/* ---------- Inspector ---------- */
.ms-studio-inspector{padding:16px 18px;border-top:1px solid #f1ebfa;background:linear-gradient(180deg,#fdfcff,#faf7ff)}
.ms-studio-insp-head{display:flex;align-items:center;gap:8px;margin-bottom:10px}
.ms-studio-insp-head strong{font-size:13px;color:#171f2b}
.ms-studio-insp-head span{font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:#8b86a3}
.ms-studio-insp-close{margin-left:auto;border:none;background:none;color:#8b86a3;font-size:16px;cursor:pointer;line-height:1}
.ms-studio-insp-close:hover{color:#e11d48}
.ms-studio-insp-grid{display:grid;gap:10px;grid-template-columns:repeat(auto-fit,minmax(190px,1fr))}
.ms-studio-field label{display:block;margin-bottom:4px;font-size:11px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;color:#8b86a3}
.ms-studio-field input,.ms-studio-field textarea{width:100%;padding:8px 10px;border-radius:9px;border:1px solid #e6dff2;background:#fff;font-family:inherit;font-size:12.5px;color:#171f2b;outline:none;transition:border-color .2s ease,box-shadow .2s ease}
.ms-studio-field textarea{min-height:66px;resize:vertical;line-height:1.55}
.ms-studio-field input:focus,.ms-studio-field textarea:focus{border-color:#9F66FF;box-shadow:0 0 0 3px rgba(159,102,255,.15)}

/* ---------- Output pane ---------- */
.ms-studio-output{padding:16px 18px;border-top:1px solid #f1ebfa;background:#fff}
.ms-studio-output-head{display:flex;align-items:center;gap:8px;margin-bottom:10px}
.ms-studio-output-head strong{font-size:13px;color:#171f2b}
.ms-studio-output-body{max-height:190px;overflow-y:auto;padding:14px 16px;border-radius:12px;border:1px solid #ece6f6;background:linear-gradient(165deg,#fdfcff,#f7f4fd);font-size:12.5px;line-height:1.7;white-space:pre-wrap;color:#3d4756}
.ms-studio-output-body strong{color:#171f2b}
.ms-studio-runbar{display:flex;align-items:center;gap:8px;padding:11px 16px;border-bottom:1px solid #f1ebfa;background:#fdfcff}
.ms-studio-progress{flex:1;height:5px;border-radius:99px;background:#efe9fb;overflow:hidden}
.ms-studio-progress i{display:block;height:100%;border-radius:99px;background:linear-gradient(90deg,#9F66FF,#FF196E);transition:width .3s ease}
.ms-studio-runstat{font-size:11.5px;font-weight:700;color:#7c3aed;white-space:nowrap}

@media (prefers-reduced-motion:reduce){
  .ms-studio-item,.ms-studio-node,.ms-studio-btn,.ms-studio-node-del,.ms-studio-progress i{transition:none}
}


/* ---------- "How it works" steps (page body) ---------- */
.ms-ag-steps{display:grid;gap:16px;grid-template-columns:repeat(auto-fit,minmax(215px,1fr));margin-top:30px}
.ms-ag-step{display:flex;flex-direction:column;padding:26px 24px;border-radius:18px;border:1px solid #ece6f6;background:linear-gradient(165deg,#fdfcff,#f7f4fd);box-shadow:0 22px 44px -34px rgba(159,102,255,.45);transition:border-color .25s ease,transform .25s ease}
.ms-ag-step:hover{border-color:#9F66FF;transform:translateY(-3px)}
.ms-ag-step .ms-ag-steps-num{font-size:26px;margin-bottom:6px}
.ms-ag-step h3{margin:0 0 8px;font-size:16.5px;font-weight:700;letter-spacing:-.2px;color:#171f2b}
.ms-ag-step p{margin:0;font-size:13.5px;line-height:1.65;color:#5b6675}
