/* ============================================================
   studio.css — Studio (code editor + flowchart) screen
   ============================================================ */

.studio { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.studio-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 1fr) 1.25fr; }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.pane.left { border-right: 1px solid var(--line); background: #fbfaf6; }
.pane-head {
  height: 50px; flex: none; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.pane-title { font-family: var(--font-ui); font-weight: 600; font-size: 13px; letter-spacing: .02em; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.pane-head .spacer { flex: 1; }

/* studio top toolbar */
.studio-bar {
  height: 56px; flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; border-bottom: 1px solid var(--line); background: rgba(250,249,245,.9); backdrop-filter: blur(8px);
}
.studio-bar .logo { font-size: 17px; }
.studio-bar .sep { width: 1px; height: 24px; background: var(--line-2); }
.studio-bar .spacer { flex: 1; }

/* segmented control */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 3px; gap: 2px; }
.seg button {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px; color: var(--ink-3);
  border: 0; background: transparent; padding: 7px 15px; border-radius: 99px; cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 7px;
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg button:not(.active):hover { color: var(--ink-2); }

/* flow selector */
.flow-select {
  font-family: var(--font-ui); font-weight: 600; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line-2); background: var(--surface); border-radius: 10px; padding: 8px 32px 8px 13px; cursor: pointer;
  appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%2387847a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}

/* ---------------- code editor ---------------- */
.editor { flex: 1; min-height: 0; position: relative; display: flex; overflow: hidden; font-family: var(--font-mono); font-size: 13px; line-height: 21px; }
.gutter {
  flex: none; width: 52px; text-align: right; padding: 14px 10px 14px 0; color: var(--ink-3);
  user-select: none; background: #f7f5ef; border-right: 1px solid var(--line); overflow: hidden; white-space: pre;
}
.gutter .gln.hot { color: var(--coral-deep); font-weight: 700; }
.code-area { flex: 1; min-width: 0; position: relative; overflow: auto; }
.code-scroll { position: relative; min-height: 100%; }
.hl-lines { position: absolute; inset: 0; pointer-events: none; }
.hl-band { position: absolute; left: 0; right: 0; background: rgba(217,119,87,.13); border-left: 3px solid var(--coral); }
.code-pre, .code-ta {
  margin: 0; padding: 14px 18px; font-family: var(--font-mono); font-size: 13px; line-height: 21px;
  white-space: pre; tab-size: 4; border: 0; letter-spacing: 0;
}
.code-pre { position: relative; pointer-events: none; color: var(--ink); min-height: 100%; }
.code-ta {
  position: absolute; inset: 0; width: 100%; height: 100%; resize: none; outline: none; background: transparent;
  color: transparent; caret-color: var(--coral-deep); overflow: hidden;
}
.code-ta::selection { background: rgba(106,155,204,.28); }

/* python syntax highlight */
.tok-kw { color: #b05a36; font-weight: 600; }
.tok-def { color: #6a9bcc; font-weight: 600; }
.tok-str { color: #788c5d; }
.tok-num { color: #c25e3f; }
.tok-com { color: #a8a496; font-style: italic; }
.tok-bi  { color: #9a7bbf; }

/* ---------------- flowchart canvas ---------------- */
.canvas-wrap { flex: 1; min-height: 0; position: relative; background:
  radial-gradient(circle at center, #ffffff 0%, #faf9f5 100%); overflow: hidden; }
.fc-grid { position: absolute; inset: 0; background-image:
  radial-gradient(var(--line) 1.1px, transparent 1.1px); background-size: 22px 22px; opacity: .55; }
.fc-zoom { position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform; }
.fc-svg { display: block; }
.canvas-wrap.interactive { cursor: grab; }
.canvas-wrap.interactive.grabbing { cursor: grabbing; }

.zoom-ctl { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 1px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); overflow: hidden; z-index: 5; }
.zoom-ctl button { width: 38px; height: 36px; border: 0; background: var(--surface); color: var(--ink-2); font-size: 17px; cursor: pointer; font-family: var(--font-ui); transition: background .12s; }
.zoom-ctl button:hover { background: var(--surface-2); color: var(--ink); }
.zoom-ctl button + button { border-top: 1px solid var(--line); }
.zoom-badge { position: absolute; left: 16px; bottom: 16px; z-index: 5; }

.fc-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 40px; }
.fc-empty .ico { width: 56px; height: 56px; border-radius: 16px; background: var(--coral-soft); display: grid; place-items: center; margin: 0 auto 18px; }
.fc-error { color: var(--coral-deep); font-family: var(--font-mono); font-size: 13px; background: #fbe9e2; border: 1px solid #f0c9bb; padding: 14px 16px; border-radius: 12px; max-width: 420px; }

/* node styles (shared by export) injected via JS too */

/* ---------------- AI panel ---------------- */
.ai-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 380px; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: -16px 0 40px -20px rgba(20,20,19,.25); z-index: 30;
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .32s cubic-bezier(.3,.7,.3,1);
}
.ai-panel.open { transform: none; }
.ai-head { height: 56px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.ai-head .x { margin-left: auto; width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent; cursor: pointer; color: var(--ink-3); font-size: 18px; }
.ai-head .x:hover { background: var(--surface-2); color: var(--ink); }
.ai-body { flex: 1; min-height: 0; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ai-ctx { font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; color: var(--coral-deep); background: var(--coral-soft); padding: 5px 11px; border-radius: 99px; align-self: flex-start; }
.msg { max-width: 92%; padding: 11px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: var(--coral); color: #fff; border-bottom-right-radius: 5px; font-family: var(--font-ui); }
.msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 5px; }
.msg.bot code { font-family: var(--font-mono); font-size: 12.5px; background: var(--bg-2); padding: 1px 5px; border-radius: 5px; }
.ai-foot { flex: none; padding: 14px; border-top: 1px solid var(--line); display: flex; gap: 9px; }
.ai-foot .input { flex: 1; }

@media (max-width: 900px) {
  .studio-main { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .pane.left { border-right: 0; border-bottom: 1px solid var(--line); }
  .ai-panel { width: 100%; }
}
