.studio-shell {
  --studio-purple: #58416f;
  --studio-deep: #26153d;
  --studio-ink: #30253a;
  --studio-border: #ded6e5;
  --studio-tint: #f7f4fa;
  --studio-focus: #9562c4;
}
.studio-shell [hidden] { display: none !important; }
.studio-shell > .studio-shell__header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  height: auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  gap: 12px 20px;
  padding: 16px clamp(16px, 3vw, 40px);
  background: var(--studio-deep);
  color: #fff;
  border-bottom: 1px solid #402a55;
}
.studio-shell__header :is(h1, strong, p, span, label) { color: inherit; }
.studio-shell__header h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: clamp(19px, 2vw, 26px); }
.studio-shell__header > :is(h1, strong, .context) { min-width: 0; max-width: 100%; }
.studio-shell__header > span { font-size: 11px; letter-spacing: .07em; }
.studio-shell__header > p { display: none; }
.studio-shell__logo { width: 120px; height: 62px; object-fit: contain; flex: 0 0 auto; }
.studio-shell__header .brand img { width: 120px; height: 62px; object-fit: contain; }
.studio-shell__apps { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin-left: auto; }
.studio-shell__apps a { color: #ede5f5; text-decoration: none; font-size: 13px; padding: 7px 2px; border-bottom: 2px solid transparent; }
.studio-shell__apps a:hover, .studio-shell__apps a[aria-current="page"] { color: #fff; border-bottom-color: #bea0d9; }
.studio-shell__tools, .studio-shell__mode { display: flex; align-items: center; gap: 9px; }
.studio-shell__tools { flex: 0 1 auto; min-width: 0; max-width: 100%; flex-wrap: wrap; }
.studio-shell__mode { font-size: 13px; margin: 0; }
.studio-shell__connection-error { flex-basis: 100%; max-width: 30em; font-size: 12px; }
.studio-shell__header .studio-shell__connections { min-width: 112px; }
.studio-shell__mode select, .studio-shell__header .studio-shell__connections {
  width: auto;
  min-height: 36px;
  margin: 0;
  border: 1px solid #d8cce3;
  border-radius: 7px;
  background: #fff;
  color: var(--studio-ink);
  font: inherit;
  padding: 7px 10px;
}
.studio-shell > main { width: 100%; max-width: none; box-sizing: border-box; }
.studio-shell .workspace { min-width: 0; }
.studio-shell #steps {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  gap: 5px;
  overflow-x: auto;
  background: #fff;
  padding: 10px 0;
  border-bottom: 1px solid var(--studio-border);
  scrollbar-width: thin;
}
.studio-shell #steps > button { flex: 0 0 auto; }
.studio-shell #steps > button:focus-visible { outline-offset: -3px; box-shadow: inset 0 0 0 3px var(--studio-focus); }
.studio-shell #steps :is([aria-current="step"], .active, .current),
.studio-shell button.primary, .studio-shell .prepare-tabs [aria-pressed="true"] { background: var(--studio-purple); color: #fff; }
.studio-shell button { font-family: inherit; }
.studio-shell :is(button, a, select, input, textarea, summary):focus-visible { outline: 3px solid var(--studio-focus); outline-offset: 3px; }
.studio-shell .connection-strip { min-width: 0; width: 100%; padding: 12px 0; margin: 0; font-size: 14px; box-sizing: border-box; }
.studio-shell .connection-strip button { white-space: normal; }
.studio-shell .studio-connection { width: 100%; min-width: 0; box-sizing: border-box; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; border: 0; background: transparent; padding: 8px 0; margin: 0; }
.studio-shell .studio-connection-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px; width: 100%; min-width: 0; font-size: 14px; line-height: 1.4; }
.studio-shell .studio-connection-bar .studio-connection-badge { font-size: inherit; }
.studio-shell .studio-connection-bar > .studio-setup-help { margin-inline-start: auto; font-size: inherit; font-weight: 600; line-height: inherit; white-space: nowrap; }
.studio-shell .studio-connection .workflow-connection-heading,
.studio-shell .studio-connection > .studio-connection-detail { display: none; }
.studio-shell .studio-connection-indicators,
.studio-shell .studio-connection-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; }
.studio-shell .studio-connection-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; line-height: 1.4; font-weight: 600; color: #64586c; }
.studio-shell .studio-connection-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.studio-shell .studio-connection-badge[data-state="ready"] { color: #216c42; }
.studio-shell .studio-connection-badge[data-state="attention"] { color: #87540c; }
.studio-shell .studio-connection-badge[data-state="checking"] .studio-connection-dot { background: transparent; border: 2px solid currentColor; border-right-color: transparent; animation: studio-shell-spin .8s linear infinite; }
.studio-shell .studio-connection-error { flex-basis: 100%; margin: 4px 0; color: #87540c; }
.studio-shell .studio-connection-controls a,
.studio-shell .studio-connection details a { font-size: 14px; margin-right: 12px; }
.studio-shell .studio-connection button { padding: 9px 14px; margin: 0; font-size: 14px; font-weight: 600; line-height: 1.4; min-height: 40px; box-sizing: border-box; }
.studio-shell .studio-connection-controls > button { border: 1px solid var(--studio-border); border-radius: 8px; background: #fff; color: var(--studio-purple); }
.studio-shell .studio-connection .studio-helper-start { display: inline-flex; align-items: center; padding: 9px 14px; margin: 0; border: 1px solid var(--studio-border); border-radius: 8px; background: #fff; color: var(--studio-purple); font-size: 14px; font-weight: 600; text-decoration: none; }
.studio-shell .studio-connection .studio-helper-start { min-height: 40px; box-sizing: border-box; line-height: 1.4; }
.studio-shell .studio-connection :is(.studio-monday-reconnect-button:disabled,.studio-helper-start[aria-disabled="true"]) { background: #ece9ef; color: #716a79; border-color: #ded9e4; cursor: default; opacity: 1; box-shadow: none; }
.studio-shell .studio-connection > details { flex-basis: 100%; font-size: 14px; }
.studio-shell .studio-connection > details > summary { text-align: right; font-size: 14px; }
html:not([data-ui-mode="advanced"]) .studio-shell .studio-connection:not([data-state="attention"]) > .studio-connection-details { display: none; }
.studio-shell .studio-helper-start-help { flex-basis: 100%; margin: 4px 0; font-size: 14px; line-height: 1.5; }
.studio-shell .studio-connections-dialog { width: min(900px, calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); box-sizing: border-box; padding: 24px; border: 1px solid var(--studio-border); border-radius: 14px; color: var(--studio-ink); background: #fff; overflow-y: auto; overscroll-behavior: contain; }
.studio-shell .studio-connections-dialog::backdrop { background: rgb(25 12 38 / 48%); }
.studio-shell .studio-connections-top { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-block: 8px; background: #fff; }
.studio-shell .studio-connections-top h2 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.studio-shell .studio-connections-top > button { flex: 0 0 auto; }
.studio-shell .studio-connections-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,250px),1fr)); gap: 14px; margin: 20px 0; }
.studio-shell .studio-connection-card { border: 1px solid var(--studio-border); border-radius: 10px; padding: 16px; min-width: 0; }
.studio-shell .studio-connection-card h3 { margin-top: 0; font-size: 16px; }
.studio-shell .studio-connection-card p { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.studio-shell .studio-connection-card button { margin: 8px 0; }
.studio-shell .studio-connection-card a { display: block; margin: 8px 0; }
.studio-shell .studio-monday-reconnect { flex-basis: 100%; }
.studio-shell .studio-monday-reconnect[hidden],
.studio-shell .studio-monday-reconnect-guide[hidden] { display: none; }
.studio-shell .studio-monday-reconnect-button { padding: 9px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--studio-purple, #594370); color: #fff; border: 1px solid var(--studio-purple, #594370); }
.studio-shell .studio-monday-reconnect-guide { margin: 12px 0; padding: 16px; border: 1px solid var(--studio-border); border-radius: 10px; background: #fff; color: var(--studio-ink); font-size: 14px; line-height: 1.5; }
.studio-shell .studio-monday-reconnect-guide p { margin: 0 0 10px; }
.studio-shell .studio-monday-reconnect-guide ol { padding-left: 22px; margin: 8px 0 14px; }
.studio-shell .studio-monday-reconnect-guide li { margin: 6px 0; }
.studio-shell .studio-monday-reconnect-guide a { display: inline-block; font-weight: 600; color: #594370; }
.studio-shell .studio-monday-reconnect-guide .studio-monday-open { padding: 10px 16px; border-radius: 8px; background: var(--studio-purple); color: #fff; text-decoration: none; font-size: 14px; }
.studio-shell .studio-monday-reconnect-guide .studio-monday-guide-close { margin-inline-start: 12px; }
.studio-shell .studio-technical { color: #74677c; font-size: 12px; }
.studio-shell textarea:is(#paper-text,#response-json,#build-chat-prompt,#editorial-chat-prompt) { width: 100%; min-height: 140px; box-sizing: border-box; }
.studio-shell main > nav:has(> .steps) { position: sticky; top: 0; z-index: 15; background: #fff; }
.studio-shell .steps { display: flex; flex-direction: row; overflow-x: auto; flex-wrap: nowrap; max-width: 100%; box-sizing: border-box; }
.studio-shell .steps > li { flex: 0 0 auto; }
.studio-shell .studio-spinner,
.studio-shell button[aria-busy="true"]::before {
  content: "";
  display: inline-block;
  width: .85em;
  height: .85em;
  margin-right: .5em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -.1em;
  animation: studio-shell-spin .8s linear infinite;
}
/* Existing workflow spinners remain the single visible busy indicator. */
.studio-shell button[aria-busy="true"]:has(.spinner, .studio-spinner)::before { content: none; display: none; animation: none; }
@keyframes studio-shell-spin { to { transform: rotate(360deg); } }
.embedded-video .studio-shell > .studio-shell__header { display: none; }
@media (max-width: 720px) {
  .studio-shell > .studio-shell__header { gap: 10px 14px; padding: 14px 16px; }
  .studio-shell__logo { width: 90px; height: 46px; }
  .studio-shell__header .brand img { width: 90px; height: 46px; }
  .studio-shell__apps { order: 3; width: 100%; margin-left: 0; gap: 2px 16px; }
  .studio-shell__tools { margin-left: auto; flex-wrap: wrap; }
  .studio-shell__header h1 { font-size: 20px; }
  .studio-shell #steps { scroll-padding-inline: 8px; }
  .studio-shell .studio-connections-dialog { padding: 16px; }
  .studio-shell .studio-connections-top { align-items: flex-start; gap: 12px; }
  .studio-shell .studio-connections-top h2 { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .studio-shell .spinner,
  .studio-shell .studio-spinner,
  .studio-shell .studio-connection-badge[data-state="checking"] .studio-connection-dot,
  .studio-shell button[aria-busy="true"]::before { animation: none; }
}

/* Shared notices: the meaning, instruction and recovery stay in one container. */
.studio-shell .studio-notice {
  --notice-background: #f7f4fa;
  --notice-border: #d6c9e4;
  --notice-accent: #58416f;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  margin: 16px 0 20px;
  padding: 16px;
  border: 1px solid var(--notice-border);
  border-left: 4px solid var(--notice-accent);
  border-radius: 10px;
  background: var(--notice-background);
  color: #30253a;
  font-size: 14px;
  line-height: 1.5;
}
.studio-shell .studio-notice[data-tone="warning"] {
  --notice-background: #fff8e8;
  --notice-border: #e7c67e;
  --notice-accent: #80520e;
}
.studio-shell .studio-notice[data-tone="error"] {
  --notice-background: #fff2f0;
  --notice-border: #e7b5af;
  --notice-accent: #a12d24;
}
.studio-shell .studio-notice__icon {
  flex: 0 0 20px;
  width: 20px;
  text-align: center;
  color: var(--notice-accent);
  font-size: 20px;
  line-height: 1.15;
}
.studio-shell .studio-notice__icon.studio-spinner { margin-top: 3px; flex-basis: 16px; }
.studio-shell .studio-notice__content { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.studio-shell .studio-notice__title { margin: 0; color: var(--notice-accent); font-size: 14px; font-weight: 700; line-height: 1.5; }
.studio-shell .studio-notice__message { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.studio-shell .studio-notice__meta { margin: 8px 0 0; color: #62596b; font-size: 13px; line-height: 1.5; }
.studio-shell .studio-notice__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.studio-shell .studio-notice__actions > :not([hidden]) { margin: 12px 0 0; }
.studio-shell .studio-notice__actions button { font: inherit; min-height: 40px; padding: 8px 14px; }
.studio-shell .studio-notice__details { margin: 12px 0 0; padding: 0; border: 0; border-radius: 0; background: transparent; font-size: 13px; }
.studio-shell .studio-notice__summary { font-size: 13px; }
.studio-shell .studio-notice__diagnostic { white-space: pre-wrap; margin: 8px 0 0; font-size: 13px; }

/* A common sequence for existing setup actions; it never supplies completion logic. */
.studio-shell .studio-stage-flow {
  display: grid;
  grid-template-columns: repeat(var(--studio-stage-count, 4), minmax(0, 1fr));
  gap: 22px;
  width: 100%;
  max-width: 1180px;
  margin: 20px 0;
  align-items: stretch;
}
.studio-shell .studio-stage-flow__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  box-sizing: border-box;
  padding: 16px;
  border: 1px solid var(--studio-border, #ded6e5);
  border-radius: 10px;
  background: #fff;
  color: var(--studio-ink, #30253a);
  font-size: 14px;
  line-height: 1.5;
}
.studio-shell .studio-stage-flow__card:not(:last-child)::after {
  content: '→';
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  color: #77618b;
  font-size: 20px;
  line-height: 1;
}
.studio-shell .studio-stage-flow__title { margin: 0; text-align: center; color: #71657e; font-size: 14px; font-weight: 700; line-height: 1.5; }
.studio-shell .studio-stage-flow__card[data-state="current"] { border-color: #8d6aaf; background: #faf7ff; }
.studio-shell .studio-stage-flow__card[data-state="current"] > .studio-stage-flow__title { color: #41285e; }
.studio-shell .studio-stage-flow__body { min-width: 0; }
.studio-shell .studio-stage-flow__body:empty { display: none; }
.studio-shell .studio-stage-flow__body :is(p, label) { margin: 0; font-size: 14px; line-height: 1.5; }
.studio-shell .studio-stage-flow__body textarea { width: 100%; max-width: 100%; min-height: 140px; box-sizing: border-box; margin-top: 8px; font: inherit; resize: vertical; }
.studio-shell .studio-stage-flow__actions { display: flex; flex-direction: column; gap: 8px; }
.studio-shell .studio-stage-flow__actions:empty { display: none; }
.studio-shell .studio-stage-flow__actions > :is(button, a) {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid #d4cbe3;
  border-radius: 8px;
  background: #fff;
  color: #4c365f;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.studio-shell .studio-stage-flow__actions > .primary { background: var(--studio-purple, #58416f); color: #fff; border-color: var(--studio-purple, #58416f); }
.studio-shell .studio-stage-flow__actions > button:disabled { cursor: default; opacity: .5; }
.studio-shell .studio-stage-flow__status { margin: 0; color: #696276; font-size: 13px; line-height: 1.5; text-align: center; overflow-wrap: anywhere; }
.studio-shell .studio-stage-flow__actions > :is(button, a):focus-visible { outline: 3px solid var(--studio-focus, #9562c4); outline-offset: 3px; }
.studio-shell .studio-stage-intro { margin: 8px 0 16px; font-size: 14px; line-height: 1.5; }
.studio-shell .studio-stage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0; }
.studio-shell .studio-stage-actions > :is(button,a) { margin: 0; font-size: 14px; }
html:not([data-ui-mode="advanced"]) .studio-shell .studio-advanced-only { display: none !important; }
@media (max-width: 800px) {
  .studio-shell .studio-stage-flow { grid-template-columns: 1fr; }
  .studio-shell .studio-stage-flow__card:not(:last-child)::after { content: '↓'; top: auto; right: 50%; bottom: -20px; transform: translateX(50%); }
}

html[data-ui-mode="basic"] .studio-connection[data-state="ready"] .studio-connection-controls {display:none}
html[data-ui-mode="basic"] .studio-copy-connection[data-state="ready"] .studio-connection-controls {display:none}
