/* ==========================================================================
   DigiBot Studio — studio-only styles (uses the theme tokens from style.css)
   ========================================================================== */

.studio {
  --st-chat-w: 440px;
  --st-page-bg: #ffffff;            /* default background of the student's page */
  /* Code colours: the code panel is dark (--code-bg) in BOTH themes */
  --hl-tag: #ffc23d;
  --hl-attr: #c6b3ff;
  --hl-str: #8fe3b0;
  --hl-com: #8c84ad;
  --hl-doc: #7fb2f0;
  --hl-punc: #a79fc7;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  min-height: 440px;
  background: var(--bg);
  color: var(--text);
}
body[data-page="studio"] .presenter-badge { display: none !important; }
body[data-page="studio"] .toast-region { bottom: auto; top: calc(var(--header-h) + 12px); }

/* ---------- Mobile segmented control ---------- */
.st-mtabs {
  display: none; gap: 4px; flex: none;
  padding: 6px 10px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.st-mtab {
  position: relative; flex: 1 1 0; min-height: 38px; padding: 6px 8px;
  font: inherit; font-size: .88rem; font-weight: 700;
  border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.st-mtab[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); border-color: var(--accent); }
.st-mtab.has-new::after {
  content: ""; position: absolute; top: 7px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface);
}

/* ---------- Banner ---------- */
.st-banner {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  padding: 10px 16px; font-size: .92rem; line-height: 1.45;
  background: var(--warn-soft); color: var(--text); border-bottom: 1px solid var(--border);
}
.st-banner[hidden] { display: none; }
.st-banner[data-tone="danger"] { background: var(--danger-soft); }
.st-banner[data-tone="info"] { background: var(--info-soft); }
.st-banner__icon { font-size: 1.25rem; line-height: 1; }
.st-banner__text { flex: 1 1 260px; min-width: 0; }
.st-banner__actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Two-column grid ---------- */
.st-grid {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: var(--st-chat-w) minmax(0, 1fr);
}

/* ---------- Chat column ---------- */
.st-chat {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--bg-soft); border-right: 1px solid var(--border);
}
.st-status {
  flex: none; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 8px;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.st-status__right { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.st-engine {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: .74rem; font-weight: 700; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 99px;
}
.st-engine { min-width: 0; max-width: 100%; }
.st-engine__dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.st-engine__text { overflow: hidden; text-overflow: ellipsis; }
.st-conn {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  min-height: 30px; padding: 3px 11px; border-radius: 99px;
  font: inherit; font-size: .8rem; font-weight: 800;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); cursor: pointer;
}
.st-conn:hover { border-color: var(--accent); }
.st-conn__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); flex: none; }
.st-conn[data-state="checking"] .st-conn__dot { animation: st-pulse 1s ease-in-out infinite; }
.st-conn[data-state="live"] .st-conn__dot { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.st-conn[data-state="byok"] .st-conn__dot { background: var(--info); box-shadow: 0 0 0 3px var(--info-soft); }
.st-conn[data-state="demo"] .st-conn__dot,
.st-conn[data-state="offline"] .st-conn__dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.st-conn[data-state="paused"] .st-conn__dot { background: var(--warn); animation: st-pulse 1.6s ease-in-out infinite; }
.st-conn[data-state="noai"] .st-conn__dot { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.st-iconbtn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border-radius: 50%; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-size: .95rem; cursor: pointer;
}
.st-iconbtn:hover { border-color: var(--accent); }
.st-switch { font-size: .78rem; font-weight: 700; white-space: nowrap; }

/* Scripted demo panel */
.st-demo {
  flex: none; margin: 10px 12px 0; max-height: 36%; overflow: auto;
  border: 1px solid var(--accent); border-radius: 12px; background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.st-demo[hidden] { display: none; }
.st-demo > summary {
  cursor: pointer; list-style: none; padding: 8px 12px;
  font-weight: 800; font-size: .88rem; display: flex; align-items: center; gap: 6px;
}
.st-demo > summary::-webkit-details-marker { display: none; }
.st-demo > summary::after { content: "▾"; margin-left: auto; color: var(--text-muted); transition: transform .15s ease; }
.st-demo:not([open]) > summary::after { transform: rotate(-90deg); }
.st-demo__title { flex: none; white-space: nowrap; }
.st-demo__sub { min-width: 0; font-weight: 600; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-demo__intro { margin: 0 12px 6px; font-size: .8rem; color: var(--text-muted); line-height: 1.4; }
.st-demo__list { list-style: none; margin: 0; padding: 0 6px 8px; display: grid; gap: 2px; }
.st-demo__list li { margin: 0; }
.st-step {
  width: 100%; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; align-items: start;
  padding: 6px 8px; border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--text); font: inherit; font-size: .83rem; line-height: 1.35;
  text-align: left; cursor: pointer;
}
.st-step:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); }
.st-step:disabled { opacity: .55; cursor: not-allowed; }
.st-step__n {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 2px solid var(--border-strong); font-weight: 800; font-size: .72rem;
}
.st-step__t { display: block; font-weight: 700; }
.st-step__p { display: block; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-step.is-done .st-step__n { background: var(--success); border-color: var(--success); color: var(--surface); }

/* Messages */
.st-messages {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 12px 10px; display: flex; flex-direction: column; gap: 12px;
}
.st-msg { display: flex; gap: 10px; align-items: flex-start; min-width: 0; animation: st-in .2s ease both; }
.st-msg--user { justify-content: flex-end; }
.st-avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1rem;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: var(--shadow-sm);
}
.st-bubble {
  min-width: 0; padding: 10px 14px; border-radius: 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  font-size: .95rem; line-height: 1.55; overflow-wrap: anywhere;
}
.st-msg--bot .st-bubble { flex: 1 1 auto; border-top-left-radius: 6px; }
.st-msg--user .st-bubble {
  max-width: 88%; background: var(--primary); color: var(--on-primary);
  border-color: transparent; border-top-right-radius: 6px; white-space: pre-wrap;
}
.st-msg--note .st-bubble { background: var(--surface-2); box-shadow: none; }
.st-bubble.is-error { background: var(--danger-soft); border-color: var(--danger); }
.st-tag {
  display: inline-block; margin-bottom: 4px; padding: 1px 8px; border-radius: 99px;
  font-size: .72rem; font-weight: 800; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--on-primary) 18%, transparent);
}
.st-text:empty { display: none; }
.st-text > :first-child { margin-top: 0; }
.st-text > :last-child { margin-bottom: 0; }
.st-text p { margin: 0 0 .6em; }
.st-text ul, .st-text ol { margin: 0 0 .6em; padding-left: 1.25em; }
.st-text li { margin: .15em 0; }
.st-text pre { font-size: .78rem; padding: 10px 12px; margin: 0 0 .6em; border-radius: 10px; white-space: pre-wrap; }
.st-text code { font-size: .86em; }
.st-status-line { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 600; color: var(--text-muted); }
.st-status-line[hidden] { display: none; }
.st-status-line + .st-text:not(:empty) { margin-top: 6px; }
.st-spin {
  flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: st-spin .8s linear infinite;
}
.st-spin[hidden] { display: none; }
.st-meta { margin-top: 8px; font-size: .76rem; font-weight: 700; color: var(--text-muted); }
.st-meta[hidden] { display: none; }
.st-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.st-actions[hidden] { display: none; }
.st-tip {
  margin-top: 10px; padding: 8px 10px; border-radius: 10px;
  background: var(--accent-soft); font-size: .86rem; line-height: 1.45;
}
.st-changed { margin-top: 10px; font-size: .86rem; line-height: 1.45; color: var(--text-muted); }
.st-changed p { margin: 0 0 .2em; color: var(--text); }
.st-changed ul { margin: 0; padding-left: 1.2em; }

/* Welcome */
.st-welcome__label { margin: .4em 0 .3em !important; font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.st-starters { display: grid; gap: 6px; margin: 0 0 12px; }
.st-starter {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; align-items: start;
  padding: 9px 11px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: .88rem; line-height: 1.35;
  text-align: left; cursor: pointer; transition: border-color .15s ease, background .15s ease, transform .08s ease;
}
.st-starter:hover { border-color: var(--accent); background: var(--accent-soft); }
.st-starter:active { transform: translateY(1px); }
.st-starter__emoji { font-size: 1.2rem; line-height: 1.2; }
.st-starter strong { display: block; }
.st-starter small { display: block; color: var(--text-muted); font-size: .8rem; margin-top: 1px; }
.st-welcome__tip { margin-top: 10px !important; font-size: .82rem; color: var(--text-muted); }

/* Composer */
.st-composer { flex: none; padding: 8px 12px 10px; background: var(--surface); border-top: 1px solid var(--border); }
.st-context { display: flex; align-items: center; gap: 6px; min-height: 26px; margin-bottom: 6px; font-size: .8rem; color: var(--text-muted); }
.st-context:empty { display: none; }
.st-ctx-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-ctx-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0;
  padding: 2px 3px 2px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--text); border: 1px solid var(--accent);
  font-weight: 700; animation: st-pop .25s ease;
}
.st-ctx-chip__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.st-ctx-chip code { background: none; border: 0; padding: 0; font-size: .92em; }
.st-ctx-x {
  flex: none; width: 24px; height: 24px; display: grid; place-items: center; padding: 0;
  border-radius: 50%; border: 0; background: transparent; color: inherit; font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.st-ctx-x:hover { background: color-mix(in srgb, var(--text) 12%, transparent); }
.st-tools { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.st-tool {
  min-height: 30px; padding: 4px 9px; border-radius: 99px;
  font: inherit; font-size: .77rem; font-weight: 700; white-space: nowrap; letter-spacing: -.005em;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer;
}
.st-tool:hover:not(:disabled) { border-color: var(--accent); }
.st-tool[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.st-tool:disabled { opacity: .5; cursor: not-allowed; }
.st-photos { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.st-photos[hidden] { display: none; }
.st-photo {
  display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 10px;
  border: 1px solid var(--accent); background: var(--accent-soft); animation: st-pop .25s ease;
}
.st-photo img { flex: none; width: 40px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--surface); }
.st-photo select, .st-photo input {
  min-width: 0; min-height: 30px; padding: 2px 6px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .78rem;
}
.st-photo select { flex: none; max-width: 46%; }
.st-photo input { flex: 1 1 auto; }
.st-form {
  border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.st-form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.st-input {
  display: block; width: 100%; min-height: 50px; max-height: 200px; margin: 0; resize: none;
  padding: 10px 12px 4px; border: 0; outline: none; background: transparent; color: var(--text);
  font: inherit; font-size: 1rem; line-height: 1.5;
}
.st-input:focus-visible { outline: none; }
.st-input::placeholder { color: var(--text-muted); opacity: .9; }
.st-form__bar { display: flex; align-items: center; gap: 8px; padding: 2px 6px 6px 12px; }
.st-hint { flex: 1 1 auto; min-width: 0; font-size: .72rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-hint kbd { font-size: .68rem; padding: 0 .35em; }
.st-count { flex: none; font-size: .74rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.st-count.is-warn { color: var(--danger); font-weight: 800; }
.st-send, .st-stop { flex: none; }
.st-send[hidden], .st-stop[hidden] { display: none; }
.st-stop { border-color: var(--danger); color: var(--danger); }
.st-stop:hover { background: var(--danger-soft); border-color: var(--danger); }
.st-privacy { margin: 6px 2px 0; font-size: .72rem; line-height: 1.4; color: var(--text-muted); }

/* ---------- Workspace ---------- */
.st-work { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.st-toolbar {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px;
  padding: 7px 12px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.st-seg {
  display: inline-flex; gap: 2px; padding: 3px; flex: none;
  border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border);
}
.st-seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 30px; min-width: 34px; padding: 4px 11px; border-radius: 8px;
  font: inherit; font-size: .84rem; font-weight: 700;
  border: 0; background: transparent; color: var(--text-muted); cursor: pointer;
}
.st-seg button:hover { color: var(--text); }
.st-seg button[aria-selected="true"], .st-seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.st-seg svg { width: 17px; height: 17px; }
.st-devices button { padding: 4px 8px; }
.st-tbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex: none;
  min-height: 34px; min-width: 34px; padding: 4px 9px; border-radius: 10px;
  font: inherit; font-size: .84rem; font-weight: 700; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
a.st-tbtn { text-decoration: none; }
.st-tbtn:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); }
.st-tbtn:disabled { opacity: .45; cursor: not-allowed; }
.st-tbtn svg { width: 17px; height: 17px; flex: none; }
.st-pick[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.st-pick[aria-pressed="true"]:hover:not(:disabled) { background: var(--brand-amber-2); border-color: var(--brand-amber-2); }
.st-tsep { width: 1px; height: 22px; background: var(--border); flex: none; }
.st-versions {
  display: flex; align-items: center; gap: 4px; min-width: 0; max-width: 300px;
  overflow-x: auto; padding: 2px; scrollbar-width: thin;
}
.st-vempty { font-size: .78rem; color: var(--text-muted); white-space: nowrap; padding: 0 4px; }
.st-vchip {
  flex: none; min-height: 26px; padding: 2px 9px; border-radius: 99px;
  font: inherit; font-size: .76rem; font-weight: 800; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.st-vchip:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.st-vchip.is-current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.st-vchip:disabled { cursor: not-allowed; opacity: .6; }
.st-vchip.is-new { animation: st-pop .35s ease; }
.st-spacer { flex: 1 1 auto; }

/* Stage: preview + code */
.st-stage {
  position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden;
  background-color: var(--bg-soft);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 18px 18px;
}
.st-stage:fullscreen { background-color: var(--bg-soft); }
.st-stage.is-full { position: fixed; inset: 0; z-index: 300; }
.st-preview, .st-codewrap { position: absolute; inset: 0; }
.st-preview[hidden], .st-codewrap[hidden] { display: none; }
.st-device { position: absolute; inset: 0; background: var(--st-page-bg); }
.st-device iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--st-page-bg); }
.st-preview[data-device="tablet"] .st-device,
.st-preview[data-device="phone"] .st-device {
  inset: auto; top: 16px; left: 50%;
  box-sizing: content-box; border: 12px solid var(--brand-ink); border-radius: 30px; overflow: hidden;
  transform-origin: top center; box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-strong);
}
.st-preview[data-device="phone"] .st-device { border-radius: 42px; border-width: 12px 10px; }
.st-preview.is-building .st-device { box-shadow: var(--shadow-lg), 0 0 0 3px var(--accent); }
.st-preview[data-device="desktop"].is-building .st-device { box-shadow: inset 0 0 0 3px var(--accent); }

.st-empty {
  position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; padding: 24px;
  background-color: var(--bg-soft);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 18px 18px;
}
.st-empty[hidden] { display: none; }
.st-empty__card { max-width: 340px; text-align: center; }
.st-empty__art { width: 200px; height: auto; margin: 0 auto 14px; display: block; filter: drop-shadow(0 8px 20px color-mix(in srgb, var(--brand-ink) 18%, transparent)); }
.st-empty__art .a1 { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.5; }
.st-empty__art .a2 { fill: var(--surface-2); }
.st-empty__art .a3 { fill: var(--danger); }
.st-empty__art .a4 { fill: var(--accent); }
.st-empty__art .a5 { fill: var(--success); }
.st-empty__art .a6 { fill: var(--accent); opacity: .75; }
.st-empty__title { margin: 0 0 4px; font-weight: 800; font-size: 1.1rem; }
.st-empty__text { margin: 0 0 14px; color: var(--text-muted); font-size: .92rem; }

.st-pill, .st-pickhint {
  position: absolute; left: 50%; z-index: 3; transform: translateX(-50%);
  max-width: calc(100% - 24px); padding: 7px 14px; border-radius: 99px;
  font-size: .84rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: var(--shadow); pointer-events: none;
}
.st-pill { bottom: 16px; background: var(--primary); color: var(--on-primary); animation: st-pill-in .25s ease; }
.st-pill[hidden], .st-pickhint[hidden] { display: none; }
.st-pickhint { top: 12px; background: var(--accent); color: var(--on-accent); }
.st-pickhint kbd { background: transparent; border-color: currentColor; color: inherit; font-size: .72rem; }
.st-jserr {
  position: absolute; left: 12px; bottom: 12px; z-index: 3; max-width: calc(100% - 24px);
  padding: 7px 12px; border-radius: 10px; text-align: left;
  font: inherit; font-size: .82rem; font-weight: 700; line-height: 1.35;
  background: var(--danger-soft); color: var(--text); border: 1px solid var(--danger);
  box-shadow: var(--shadow); cursor: pointer;
}
.st-jserr[hidden] { display: none; }
.st-exitfs { position: absolute; top: 10px; right: 10px; z-index: 4; box-shadow: var(--shadow); }
.st-exitfs[hidden] { display: none; }

/* Code view (dark in both themes) */
.st-codewrap { background: var(--code-bg); }
.st-code {
  height: 100%; margin: 0; border-radius: 0; overflow: auto;
  padding: 16px 18px 48px; background: var(--code-bg); color: var(--code-text);
  font-size: .82rem; line-height: 1.6; white-space: pre; tab-size: 2;
}
.st-code:focus-visible { outline-offset: -3px; }
.st-code .hl-tag { color: var(--hl-tag); font-weight: 600; }
.st-code .hl-attr { color: var(--hl-attr); }
.st-code .hl-str { color: var(--hl-str); }
.st-code .hl-com { color: var(--hl-com); font-style: italic; }
.st-code .hl-doc { color: var(--hl-doc); }
.st-code .hl-punc { color: var(--hl-punc); }
.st-code .hl-empty { color: var(--code-muted); font-family: var(--font); font-size: .95rem; }

/* ---------- Dialogs ---------- */
.st-dialog {
  width: min(calc(100vw - 32px), 480px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: var(--radius-lg); overflow: auto;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.st-dialog--wide { width: min(calc(100vw - 32px), 900px); }
.st-dialog::backdrop { background: color-mix(in srgb, var(--brand-ink) 62%, transparent); backdrop-filter: blur(3px); }
.st-dialog[open] { animation: st-dlg .2s ease; }
.st-dialog__body { position: relative; padding: 26px 24px 22px; }
.st-dialog h2 { margin: 0 0 8px; padding-right: 36px; font-size: 1.3rem; }
.st-dialog p { font-size: .95rem; }
.st-dialog__icon { font-size: 2rem; line-height: 1; margin-bottom: 10px; }
.st-dialog__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.st-dialog__alt { margin: 14px 0 0; color: var(--text-muted); }
.st-dialog__alt:empty { display: none; }
.st-dialog__note { margin: 16px 0 0; font-size: .88rem; padding: 12px 14px; }
.st-dialog__x {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; border: 0;
  background: transparent; color: var(--text-muted); font-size: 1.05rem; cursor: pointer;
}
.st-dialog__x:hover { background: var(--surface-2); color: var(--text); }
.st-dialog .form-field { margin-top: 14px; }
.st-err { min-height: 1.3em; margin: 2px 0 0 !important; color: var(--danger); font-size: .88rem !important; font-weight: 700; }
.st-linkbtn {
  padding: 0; border: 0; background: none; color: var(--link); cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.st-linkbtn:hover { text-decoration-thickness: 2px; }
.st-check { display: flex; gap: 10px; align-items: flex-start; margin: 2px 0 6px; font-size: .92rem; cursor: pointer; }
.st-check input { flex: none; width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }
.st-keystatus { min-height: 1.4em; margin: 6px 0 0 !important; font-weight: 700; font-size: .92rem !important; }
.st-keystatus[data-tone="ok"] { color: var(--success); }
.st-keystatus[data-tone="bad"] { color: var(--danger); }
.st-keystatus[data-tone="info"] { color: var(--text-muted); }

.st-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 16px; }
.st-tpl {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  padding: 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
.st-tpl:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.st-tpl.is-loading { opacity: .6; pointer-events: none; }
.st-tpl__emoji {
  width: 52px; height: 52px; margin-bottom: 6px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.7rem; background: var(--accent-soft);
}
.st-tpl__title { font-weight: 800; font-size: 1rem; }
.st-tpl__desc { font-size: .86rem; line-height: 1.45; color: var(--text-muted); }

/* ---------- Animations ---------- */
@keyframes st-spin { to { transform: rotate(360deg); } }
@keyframes st-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes st-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes st-pop { 0% { transform: scale(.92); opacity: .4; } 100% { transform: none; opacity: 1; } }
@keyframes st-dlg { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes st-pill-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Presenter mode ---------- */
body.presenter .studio { --st-chat-w: 470px; }
body.presenter .st-bubble { font-size: 1.1rem; }
body.presenter .st-input { font-size: 1.15rem; }
body.presenter .st-code { font-size: 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1359px) {
  .studio { --st-chat-w: 400px; }
  .st-tools .st-lbl { display: none; }
}
@media (max-width: 1100px) {
  .studio { --st-chat-w: 380px; }
  .st-toolbar .st-lbl { display: none; }
  .st-versions { max-width: 220px; }
}
@media (max-width: 899px) {
  .st-mtabs { display: flex; }
  .st-grid { grid-template-columns: minmax(0, 1fr); }
  .st-chat { border-right: 0; }
  .studio[data-mview="chat"] .st-work { display: none; }
  .studio:not([data-mview="chat"]) .st-chat { display: none; }
  .st-seg--view { display: none; }
  .st-versions { order: 20; flex: 1 1 90px; max-width: none; }
  .st-spacer { display: none; }
  body.presenter .studio { --st-chat-w: auto; }
}
@media (max-width: 600px) {
  .st-devices, .st-tsep { display: none; }
  .st-hint { visibility: hidden; }
  .st-tools { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -2px; padding-left: 2px; }
  .st-tools::-webkit-scrollbar { display: none; }
  .st-tools .st-lbl { display: none; }
  .st-messages { padding: 12px 10px 8px; }
  .st-msg--user .st-bubble { max-width: 92%; }
  .st-avatar { width: 28px; height: 28px; font-size: .9rem; }
  .st-dialog__body { padding: 22px 18px 18px; }
  .st-banner { padding: 8px 12px; font-size: .86rem; }
}
@media (prefers-reduced-motion: reduce) {
  .st-spin { animation: none !important; border-top-color: var(--accent); }
}
