/* The Chat and Render work areas share the existing SolarCompute rail. */
body.sc-studio {
  --studio-bg: #10171f;
  --studio-panel: #19232d;
  --studio-line: #334251;
  --studio-text: #edf2f6;
  --studio-muted: #a8b6c4;
  --studio-gold: #efbb62;
  margin: 0;
  background: var(--studio-bg);
  color: var(--studio-text);
  font: 400 15px/1.55 Inter, system-ui, sans-serif;
}
.sc-studio .sc-shell {
  height: var(--studio-viewport, 100dvh);
}
.sc-studio .sc-main.studio-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: var(--studio-bg);
}
.studio-workspace { min-height: 0; min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; position: relative; }
.studio-scroll { min-height: 0; min-width: 0; overflow-y: auto; overscroll-behavior-y: contain; overflow-anchor: none; }
.studio-column { width: min(100%, 52rem); margin-inline: auto; padding: 24px clamp(14px, 4vw, 32px); min-width: 0; }
.studio-welcome h2 { margin: 0 0 .35rem; font: 600 clamp(1.55rem, 4vw, 2.35rem)/1.15 "Space Grotesk", Inter, system-ui, sans-serif; }
.studio-welcome p, .studio-note { color: var(--studio-muted); margin: .3rem 0; }
.studio-suggestions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.studio-thread { display: grid; gap: 22px; }
.studio-message { min-width: 0; overflow-wrap: anywhere; }
.studio-message.user { justify-self: end; width: fit-content; max-width: min(88%, 42rem); padding: 12px 16px; background: #212e3a; border-radius: 16px 16px 4px 16px; }
.studio-message.assistant { background: none; padding-inline: 1px; min-width: 0; }
.studio-speaker { color: var(--studio-muted); font-size: .78rem; font-weight: 650; margin: 0 0 .4rem; }
.studio-message.assistant .studio-speaker::before { content: "✦"; color: var(--studio-gold); padding-right: .45rem; }
.studio-message.user .studio-message-body { white-space: pre-wrap; }
.studio-message-body > :first-child { margin-top: 0; } .studio-message-body > :last-child { margin-bottom: 0; }
.studio-message-body h1, .studio-message-body h2, .studio-message-body h3 { font-family: "Space Grotesk", Inter, system-ui, sans-serif; line-height: 1.23; }
.studio-message-body blockquote { border-left: 2px solid var(--studio-gold); padding-left: 12px; margin-left: 0; }
.studio-message-body code { background: #24313f; padding: .15em .3em; border-radius: 4px; }
.studio-message-body pre { overflow: auto; margin: 0; padding: 12px 14px; }
.studio-message-body pre code { padding: 0; background: transparent; }
.studio-code, .studio-table { max-width: 100%; overflow: auto; border: 1px solid var(--studio-line); border-radius: 10px; margin-block: 12px; }
.studio-code { background: #0e151d; }
.studio-code-bar { padding: 4px 8px; display: flex; justify-content: flex-end; border-bottom: 1px solid var(--studio-line); }
.studio-table table { border-collapse: collapse; min-width: 100%; }
.studio-table th, .studio-table td { padding: 7px 10px; border-bottom: 1px solid var(--studio-line); text-align: left; }
.studio-dock { background: var(--studio-bg); position: relative; padding: 0 0 max(10px, env(safe-area-inset-bottom)); }
.studio-dock .studio-column { padding-top: 5px; padding-bottom: 4px; }
.studio-composer { border: 1px solid var(--studio-line); border-radius: 16px; background: var(--studio-panel); padding: 9px; }
.studio-composer:focus-within { border-color: #8b774a; }
.studio-composer textarea { display: block; width: 100%; box-sizing: border-box; resize: none; min-height: 45px; max-height: min(152px, 26dvh); overflow-y: auto; border: 0; background: transparent; color: var(--studio-text); padding: 10px 8px; outline: none; font: inherit; }
.studio-controls { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.studio-tool, .studio-button, .studio-select, .studio-primary {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--studio-line); border-radius: 9px; color: var(--studio-text);
  background: transparent; min-height: 40px; padding: 4px 10px; font: inherit;
  text-decoration: none; cursor: pointer;
}
.studio-select { background: var(--studio-panel); max-width: 100%; }
.studio-tool { width: 43px; padding: 0; }
.studio-tool svg { width: 18px; height: 18px; }
.studio-primary { background: var(--studio-gold); border-color: var(--studio-gold); color: #201709; font-weight: 700; }
.studio-button:hover, .studio-tool:hover { background: #263442; }
.studio-primary:disabled, .studio-button:disabled, .studio-tool:disabled { opacity: .5; cursor: default; }
.sc-studio :focus-visible { outline: 2px solid var(--studio-gold); outline-offset: 2px; }
.sc-studio a { color: #f2c576; }
.sc-studio a.studio-button { color: var(--studio-text); }
.studio-status { margin: .3rem .4rem; color: var(--studio-muted); font-size: .82rem; }
.studio-status:empty { display: none; }
.studio-error { color: #ffa9a0; padding-top: .4rem; }
.studio-note { font-size: .8rem; }
.studio-latest { position: absolute; inset-inline-end: clamp(14px,4vw,32px); bottom: calc(100% + 7px); z-index: 2; background: var(--studio-panel); }
.sc-studio [hidden] { display: none !important; }
.studio-sequence { margin-top: 8px; }
.studio-render-history { display: grid; gap: 16px; }
.studio-render-card { min-width: 0; border: 1px solid var(--studio-line); background: var(--studio-panel); padding: 14px; border-radius: 12px; }
.studio-render-card h3 { margin: 0 0 5px; font-size: 1rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.studio-render-card .studio-status { margin-inline: 0; }
.studio-render-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.studio-render-card img { display: block; width: min(100%, 35rem); max-height: 56dvh; object-fit: contain; object-position: left; border-radius: 8px; }
.studio-reference { display: flex; gap: 8px; align-items: center; padding: 6px; }
.studio-reference img { width: 48px; height: 48px; object-fit: cover; border-radius: 7px; }
.studio-dialog { background: #17212c; border: 1px solid var(--studio-line); color: var(--studio-text); border-radius: 12px; max-width: 94vw; }
.studio-dialog::backdrop { background: #05080bcc; }
.studio-dialog img { display: block; max-width: 87vw; max-height: 76dvh; object-fit: contain; }
#studio-menu, #studio-scrim { display: none; }
@media (max-width: 760px) {
  #studio-menu { display: inline-flex; }
  .sc-studio #sc-sidebar { display: none; }
  .sc-studio.studio-drawer-open #sc-sidebar { display: flex; position: fixed; z-index: 90; inset: 0 auto 0 0; height: var(--studio-viewport, 100dvh); overflow: auto; }
  .sc-studio.studio-drawer-open #studio-scrim { display: block; position: fixed; z-index: 85; inset: 0; background: #05080bc0; border: 0; }
  .sc-studio #sc-sidebar .sc-nav { flex-direction: column; }
  .studio-controls .studio-tool, .studio-controls .studio-button, .studio-controls .studio-primary { min-height: 44px; }
  .studio-column { padding-top: 16px; }
  .studio-dock .studio-column { padding-inline: 10px; }
}

.sc-studio .studio-composer .sc-draft-attachments { max-height: 18dvh; overflow-y: auto; }
/* Keep the document fixed to the visible viewport when an on-screen keyboard resizes it. */
html:has(body.sc-studio) { overflow: hidden; overscroll-behavior: none; }
body.sc-studio, .sc-studio > .dashboard {
  height: var(--studio-viewport, 100dvh);
  min-height: 0;
  overflow: hidden;
}

.studio-scroll:has(.studio-welcome:not([hidden])) > .studio-column {
  min-height: 100%;
  display: grid;
  align-content: center;
}
.studio-welcome { padding: 0 0 16px; text-align: center; }
.studio-suggestions { justify-content: center; }
.studio-controls { justify-content: flex-start; }
.studio-controls .studio-primary, #infer-stop { margin-inline-start: auto; }
.studio-saved-attachments { color: var(--studio-muted); margin-block-end: 1rem; }
.studio-saved-attachments summary { cursor: pointer; width: fit-content; }
#infer-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding-block: 8px; }
#infer-attachments button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.studio-render-card .studio-history-reference { padding-inline: 0; }
.studio-render-card .studio-history-reference img {
  width: 48px;
  height: 48px;
  flex: none;
  object-fit: cover;
}
.studio-render-actions details { min-width: 0; align-self: center; }
.studio-render-actions details[open] { flex-basis: 100%; }
.studio-render-actions summary { cursor: pointer; min-height: 40px; padding: 8px; }
.studio-render-actions details .studio-button { margin: 2px; }
.studio-reference .studio-button { flex: none; }
.studio-reference .studio-note { min-width: 0; }
.studio-dialog { margin: auto; }

.studio-composer textarea::placeholder { color: var(--studio-muted); }
.studio-composer .sc-attachment-status { color: var(--studio-muted); margin: .25rem 0; }
.studio-composer .sc-draft-attachments li {
  background: var(--studio-bg);
  border: 1px solid var(--studio-line);
  border-radius: 8px;
  padding: 4px 6px;
  font-size: .85rem;
}
.studio-composer .sc-draft-attachments button,
#infer-attachments button {
  color: var(--studio-text);
  background: var(--studio-panel);
  border: 1px solid var(--studio-line);
  border-radius: 7px;
  padding: 4px 8px;
  font: inherit;
  cursor: pointer;
}
.studio-render-progress {
  width: min(100%, 16rem);
  height: 5px;
  display: block;
  margin-block: 0 12px;
  accent-color: var(--studio-gold);
}

.studio-render-inputs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  margin: 6px 0;
  max-height: min(120px, 24dvh);
  overflow-y: auto;
}
.studio-render-inputs:empty { display: none; }
.studio-render-inputs li {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--studio-line);
  border-radius: 8px;
}
.studio-render-inputs li span { min-width: 0; overflow-wrap: anywhere; font-size: .78rem; }
.studio-render-inputs li img { width: 38px; height: 38px; flex: none; object-fit: cover; border-radius: 5px; }
.studio-render-inputs .studio-button { font-size: .78rem; padding-inline: 6px; }
.studio-history-reference { flex-wrap: wrap; }
.studio-history-reference .studio-source-heading { flex-basis: 100%; }
.studio-source-tile {
  display: flex;
  align-items: center;
  gap: .4rem;
  max-width: 100%;
  background: var(--studio-bg);
  border: 1px solid var(--studio-line);
  border-radius: 8px;
  color: var(--studio-text);
  padding: 4px 8px 4px 4px;
  overflow-wrap: anywhere;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
}
.studio-library-dialog { width: min(30rem, 94vw); }
.studio-library-dialog h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
.studio-library-dialog form { margin-top: .5rem; }
.studio-library-list { display: grid; gap: 6px; padding: 0; max-height: 45dvh; overflow: auto; }
.studio-library-list li { list-style: none; min-width: 0; }
.studio-library-list .studio-button { width: 100%; overflow-wrap: anywhere; text-align: left; justify-content: flex-start; }

@media (max-width: 440px) {
  .studio-render .studio-controls .studio-select { max-width: 65%; }
  .studio-render .studio-controls .studio-button, .studio-render .studio-controls .studio-select {
    font-size: .83rem;
  }
}

/* Keep the rail footer and studio dock inside the same measured viewport. */
:is(.studio-chat, .workspace-account) .sc-shell { grid-template-rows: minmax(0, 1fr); }
:is(.studio-chat, .workspace-account) .sc-rail { box-sizing: border-box; min-height: 0; height: 100%; overflow: hidden; }
:is(.studio-chat, .workspace-account) .sc-rail > :not(.sc-nav) { flex-shrink: 0; }
:is(.studio-chat, .workspace-account) .sc-rail .sc-nav {
  flex: 1 1 0;
  min-height: 0;
  flex-flow: column nowrap;
  overflow: auto;
}
:is(.studio-chat, .workspace-account) .sc-rail .sc-work-account-menu {
  inset: auto 0 calc(100% + 8px);
  width: auto;
  max-height: min(440px, calc(var(--studio-viewport, 100dvh) - 100px));
}
:is(.studio-chat, .workspace-account).studio-drawer-open #sc-sidebar { overflow: hidden; }
.studio-chat .chat-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
  gap: 6px;
}
.studio-chat .studio-controls { flex-wrap: nowrap; }
.studio-chat .chat-toolbar-actions .studio-select { min-width: 0; text-overflow: ellipsis; }
.studio-chat .chat-toolbar-actions button { flex-shrink: 0; }
.studio-chat #infer-mic[aria-pressed="true"] { color: #ffa9a0; border-color: #ffa9a0; }
.studio-chat .studio-composer textarea {
  max-height: min(152px, calc(var(--studio-viewport, 100dvh) * .24));
}
.studio-chat .studio-composer .sc-draft-attachments {
  max-height: min(110px, calc(var(--studio-viewport, 100dvh) * .14));
}

.studio-reply-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  margin: 6px 0 0 -3px;
  color: var(--studio-muted);
}
.studio-reply-actions > button, .studio-reply-actions summary {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  list-style: none;
}
.studio-reply-actions summary::-webkit-details-marker { display: none; }
.studio-reply-actions > button:hover, .studio-reply-actions summary:hover,
.studio-reply-actions details[open] summary { background: #263442; color: var(--studio-text); }
.studio-reply-actions svg { width: 17px; height: 17px; }
.studio-reply-notice { font-size: .8rem; overflow-wrap: anywhere; }
.studio-reply-notice:empty { display: none; }
.studio-reply-actions details { position: relative; }
.studio-reply-options {
  position: absolute;
  z-index: 3;
  inset: auto auto calc(100% + 4px) 0;
  width: max-content;
  max-width: 11rem;
  padding: 5px;
  background: var(--studio-panel);
  border: 1px solid var(--studio-line);
  border-radius: 9px;
}
.studio-reply-options p { margin: 5px; font-size: .78rem; }
@media (pointer: coarse), (max-width: 760px) {
  .studio-reply-actions > button, .studio-reply-actions summary { width: 44px; height: 44px; }
  .studio-reply-options .studio-button { min-height: 44px; }
}
