/* ============================================================
   studio-ai.css — Studio AI panel as a persistent docked sidebar
   + auto-summary card + global chat chrome.
   Loaded AFTER studio.css so it overrides the verbatim drawer
   (.ai-panel position/transform) without editing studio.css.
   All colors via design tokens → light + dark both work.
   ============================================================ */

/* row that holds the 2-pane workspace + the docked AI sidebar */
.studio-body { flex: 1; min-height: 0; display: flex; }
.studio-main { min-width: 0; }            /* let the 2-pane grid shrink to fit */

/* verbatim .ai-panel is an absolute slide-in drawer → make it a docked column */
.ai-panel {
  position: relative;
  transform: none;
  flex: 0 0 380px;
  width: 380px;
}

/* collapsed: hide the docked column (toggled by #aiToggle / #aiClose) */
.studio.ai-collapsed .ai-panel { display: none; }

/* ---------------- auto-summary card ---------------- */
.ai-summary {
  flex: none;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.ai-summary-head { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.ai-summary-title {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-ui); font-weight: 600; font-size: 12px;
  letter-spacing: .08em; text-transform: uppercase; color: var(--coral-deep);
}
.ai-summary-refresh {
  margin-left: auto; width: 26px; height: 26px; flex: none;
  border-radius: 7px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-3); cursor: pointer; font-size: 14px; line-height: 1; transition: all .15s;
}
.ai-summary-refresh:hover { color: var(--ink); border-color: var(--line-2); }
.ai-summary-refresh.spinning { animation: fp-spin 1s linear infinite; }
.ai-summary-body {
  font-family: var(--font-body); font-size: 14px; line-height: 1.62; color: var(--ink-2);
  max-height: 30vh; overflow: auto;
}
.ai-summary-body code {
  font-family: var(--font-mono); font-size: 12.5px; background: var(--bg-2);
  padding: 1px 5px; border-radius: 5px;
}
.ai-summary-body b { color: var(--ink); }
.ai-summary-empty { color: var(--ink-3); font-family: var(--font-ui); font-size: 13px; }
.ai-summary-skel {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--ink-3); font-family: var(--font-ui); font-size: 13px;
}
.ai-summary-skel::before {
  content: ''; width: 13px; height: 13px; flex: none;
  border: 2px solid var(--line-2); border-top-color: var(--coral); border-radius: 99px;
  animation: fp-spin .8s linear infinite;
}
@keyframes fp-spin { to { transform: rotate(360deg); } }

/* ---------------- global / node context chip ---------------- */
.ai-ctx { display: inline-flex; align-items: center; gap: 4px; }
.ai-ctx.is-node { background: var(--blue-soft); color: var(--blue); }
.ai-ctx .ctx-x {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  font-size: 12px; line-height: 1; padding: 0 0 0 4px; opacity: .75;
}
.ai-ctx .ctx-x:hover { opacity: 1; }

/* ---------------- responsive: < 900px → overlay drawer ---------------- */
@media (max-width: 900px) {
  /* full-screen overlay when open; the desktop `.ai-collapsed { display:none }`
     rule reliably hides it when collapsed (transform-slide was flaky). */
  .ai-panel {
    position: fixed; top: 56px; right: 0; bottom: 0; left: 0;
    width: auto; z-index: 40; border-left: 0;
  }
}
