/* Shared component styles. Theme values are supplied by /theme.css. */
:root {
  --bg: #fafbf9;
  --surface: #ffffff;
  --surface-alt: #f1f5ef;
  --surface-raised: #ffffff;
  --sidebar: #f1f4ee;
  --input: #ffffff;
  --hover: #e9efe5;
  --selected: #e1eadc;
  --border: #dfe6db;
  --border-strong: #bdcbb5;
  --text: #263a32;
  --text-secondary: #5e7163;
  --text-muted: #7b897b;
  --accent: #285f49;
  --accent-hover: #1d4c39;
  --accent-soft: #e9f0e3;
  --on-accent: #ffffff;
  --focus: #95b18a;
  --success: #3c7a48;
  --success-bg: #edf5e8;
  --success-border: #c6dabb;
  --warning: #94652b;
  --warning-bg: #fff2d9;
  --warning-border: #dfc18f;
  --danger: #a34d45;
  --danger-hover: #873e38;
  --danger-bg: #fff2ef;
  --danger-border: #d8b6b1;
  --info: #3b6e8c;
  --info-bg: #edf4fa;
  --info-border: #bed4e4;
  --overlay: #1d302d66;
  --shadow: #19351c26;
  --stage: #0a110d;
  --stage-text: #f5f8f3;
  --preview: #edf2e9;
  --tooltip: #273e31;
  --tooltip-text: #ffffff;
  --skeleton: #e6ece0;
  --scrollbar: #bdcbb5;
  --switch-track: #cbd3c5;
  --switch-thumb: #ffffff;
  --green: var(--accent);
  --line: var(--border);
  --muted: var(--text-muted);
  --shadow-color: var(--shadow);
  --preview-bg: var(--preview);
  --stage-bg: var(--stage);
  --stage-border: color-mix(in srgb, var(--stage-text) 16%, transparent);
  --stage-overlay: color-mix(in srgb, var(--stage) 78%, transparent);
  --font-body: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: Georgia, "Songti SC", "SimSun", serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --font-scale: 1;
  --radius-control: 8px;
  --radius-card: 14px;
  --radius-dialog: 18px;
  --space-scale: 1;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  font-size: calc(14px * var(--font-scale));
  font-synthesis: none;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 280px;
  background: var(--bg);
}
button,input,textarea,select {
  font: inherit;
}
button,a,input,textarea,select {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  border-radius: var(--radius-control);
  padding: calc(9px * var(--space-scale)) calc(13px * var(--space-scale));
  transition: background .16s;
}
button:hover {
  background: var(--hover);
}
button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
button.primary,.button.primary {
  background: var(--green);
  color: var(--on-accent);
  border-color: var(--green);
}
button.primary:hover,.button.primary:hover {
  background: var(--accent-hover);
}
input,textarea,select {
  color: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: calc(11px * var(--space-scale)) calc(12px * var(--space-scale));
  background: var(--input);
  min-width: 0;
}
input:focus,textarea:focus,select:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
input[type=checkbox],input[type=radio] {
  accent-color: var(--green);
  width: 16px;
  height: 16px;
  padding: 0;
}
label {
  display: flex;
  flex-direction: column;
  gap: calc(8px * var(--space-scale));
}
form>label+label {
  margin-top: calc(18px * var(--space-scale));
}
a {
  color: inherit;
  text-decoration: none;
}
h1,h2,p {
  margin: 0;
}
h2 {
  font-size: 1.5rem;
  font-weight: 600;
}
small {
  font-size: 0.8571rem;
}
.muted {
  color: var(--muted);
}
.error,.form-error,.danger-text {
  color: var(--danger);
}
.form-error {
  min-height: 18px;
  font-size: 0.9286rem;
  margin: calc(12px * var(--space-scale)) 0;
}
.primary {
  font-weight: 500;
}
.wide {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(13px * var(--space-scale)) calc(16px * var(--space-scale));
}
.eyebrow {
  font-size: 0.7143rem;
  letter-spacing: 2px;
  font-weight: 600;
  color: var(--text-muted);
}
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 25% 20%,var(--preview),transparent 50%),var(--bg);
}
.login-card {
  width: 370px;
  max-width: calc(100vw - 40px);
  padding: calc(42px * var(--space-scale)) calc(26px * var(--space-scale));
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 16px;
  font: 1.9286rem var(--font-display);
  margin-bottom: calc(28px * var(--space-scale));
}
.login-card h1 {
  font: 2.7143rem var(--font-display);
  margin: calc(12px * var(--space-scale)) 0;
}
.login-card form {
  margin: calc(32px * var(--space-scale)) 0 calc(24px * var(--space-scale));
}
.login-card>small {
  color: var(--text-muted);
}
.studio {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: calc(22px * var(--space-scale)) calc(14px * var(--space-scale)) calc(14px * var(--space-scale));
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  transition: width .2s ease, padding .2s ease, transform .2s ease;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font: 1.7857rem var(--font-display);
  padding: 0 10px;
  margin-bottom: calc(22px * var(--space-scale));
  color: var(--green);
  flex-shrink: 0;
}
.brand>span {
  font: 600 1.2857rem var(--font-body);
}
.brand small {
  font: 0.6429rem var(--font-body);
  letter-spacing: 1.5px;
  display: block;
  margin-top: calc(5px * var(--space-scale));
  color: var(--text-muted);
}
.new-space {
  border-color: var(--border-strong);
  text-align: left;
  padding: calc(11px * var(--space-scale)) calc(12px * var(--space-scale));
  background: var(--surface);
  box-shadow: 0 2px 4px var(--shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  flex-shrink: 0;
}
.new-space>.side-icon {
  font-size: 1.2857rem;
  margin-right: 0;
}
.side-label {
  font-size: 0.7857rem;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: calc(24px * var(--space-scale)) 10px calc(10px * var(--space-scale));
}
#spaces {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.space {
  display: flex;
  gap: calc(12px * var(--space-scale));
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: calc(12px * var(--space-scale)) calc(14px * var(--space-scale));
  margin-bottom: calc(4px * var(--space-scale));
  color: var(--text-secondary);
}
.space>span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.space.selected {
  background: var(--selected);
  color: var(--accent);
  font-weight: 500;
}
.side-empty {
  color: var(--text-muted);
  line-height: 1.9;
  padding: calc(8px * var(--space-scale)) calc(13px * var(--space-scale));
  font-size: 0.8571rem;
}
.side-bottom {
  border-top: 1px solid var(--border);
  padding-top: calc(12px * var(--space-scale));
  margin-top: auto;
  flex-shrink: 0;
}
.side-bottom button {
  display: flex;
  width: 100%;
  gap: calc(11px * var(--space-scale));
  align-items: center;
  background: transparent;
  border: 0;
  text-align: left;
  padding: calc(10px * var(--space-scale));
  min-height: 40px;
}
.side-bottom button>span:nth-child(2) {
  flex: 1;
}
.avatar {
  display: inline-grid;
  place-items: center;
  background: var(--selected);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.8571rem;
  color: var(--text-secondary);
}
.main {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
}
.topbar {
  height: auto;
  flex-shrink: 0;
  padding: calc(12px * var(--space-scale)) calc(30px * var(--space-scale));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  min-height: 64px;
  gap: 14px;
}
.topbar .eyebrow {
  font-size: 0.6429rem;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8571rem;
}
.icon {
  border: 0;
  background: transparent;
  font-size: 1.5714rem;
  line-height: 1;
  padding: 4px;
  color: var(--text-secondary);
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
}
.mobile-menu {
  display: none;
}
.conversation {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: calc(24px * var(--space-scale)) calc(30px * var(--space-scale));
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scroll-padding-bottom: 24px;
}
.empty {
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 16px 0 28px;
}
.empty-art {
  position: relative;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  margin: 0 0 20px;
  background: var(--accent-soft);
  border-radius: 28px;
  transform: rotate(-8deg);
}
.empty-art:before {
  content: '';
  position: absolute;
  width: 80px;
  height: 80px;
  border: 1px solid var(--border-strong);
  border-radius: 25px;
  transform: rotate(19deg);
}
.empty-art span {
  font-size: 3.6429rem;
  color: var(--text-secondary);
  transform: rotate(8deg);
}
.empty h1 {
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: 1px;
  margin: 12px 0;
}
.empty p {
  line-height: 1.9;
  color: var(--text-muted);
  font-size: 0.9286rem;
}
.inspirations {
  display: flex;
  gap: calc(10px * var(--space-scale));
  margin-top: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.inspirations button {
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.8571rem;
  padding: calc(8px * var(--space-scale)) calc(14px * var(--space-scale));
}
.compose-wrap {
  width: calc(100% - 60px);
  max-width: 1040px;
  margin: 0 auto;
  flex-shrink: 0;
  padding: 10px 0 max(12px, env(safe-area-inset-bottom));
}
#composer {
  border: 0;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  background: transparent;
  box-shadow: none;
  padding: calc(14px * var(--space-scale)) calc(16px * var(--space-scale)) calc(12px * var(--space-scale));
}
#composer:focus-within {
  border-color: transparent;
  box-shadow: none;
}
#prompt {
  width: 100%;
  border: 0;
  resize: none;
  max-height: min(160px, 24dvh);
  min-height: 52px;
  padding: 0;
  line-height: 1.7;
  background: transparent;
  border-radius: 0;
  font-size: 1rem;
}
#prompt:focus {
  outline: 0;
}
#prompt::placeholder {
  color: var(--text-muted);
}
.compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: calc(8px * var(--space-scale));
  gap: 12px;
}
.compose-actions>div {
  display: flex;
  align-items: center;
  gap: 12px;
}
.compose-actions .text-button {
  padding: calc(7px * var(--space-scale)) 0;
}
.generation-config-trigger {
  display: none;
}
.send {
  padding: 0;
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-size: 1.5rem;
  border-radius: var(--radius-control);
}
.send:hover {
  background: var(--accent-hover);
}
.keyhint {
  font-size: 0.7143rem;
  color: var(--text-muted);
}
.model-bar {
  display: grid;
  gap: 0;
  margin-top: 0;
  padding: 8px 4px;
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr);
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}
.model-bar>label,.size-control {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
  border-left: 1px solid var(--border);
  gap: calc(3px * var(--space-scale));
  position: relative;
}
.model-bar>label:first-child {
  border: 0;
  padding-left: 12px;
}
.model-bar>label>span,.size-control>span {
  display: block;
  font-size: 0.7143rem;
  color: var(--text-muted);
}
.model-bar select {
  border: 0;
  padding: calc(3px * var(--space-scale)) calc(20px * var(--space-scale)) calc(3px * var(--space-scale)) 0;
  border-radius: 0;
  font-size: 0.8571rem;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-overflow: ellipsis;
}
.size-control {
  flex: initial;
  display: block;
}
.size-control>button {
  border: 0;
  background: transparent;
  padding: calc(4px * var(--space-scale)) 0;
  font-size: 0.8571rem;
  text-align: left;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 28px;
}
.compose-note {
  text-align: center;
  font-size: 0.7143rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.size-popover {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 12px 45px var(--shadow);
  border-radius: var(--radius-dialog);
  width: 290px;
  padding: calc(20px * var(--space-scale));
  z-index: 5;
  max-width: calc(100vw - 32px);
  max-height: min(520px, 72dvh);
  overflow: auto;
}
.option-group+.option-group {
  margin-top: calc(19px * var(--space-scale));
}
.option-group>span {
  font-size: 0.8571rem;
  display: block;
  margin-bottom: calc(8px * var(--space-scale));
  color: var(--text-muted);
}
.segments {
  display: flex;
  gap: calc(5px * var(--space-scale));
}
.segments button {
  flex: 1;
  padding: calc(8px * var(--space-scale));
  font-size: 0.8571rem;
  border: 1px solid var(--border);
}
.segments .chosen,.admin-tabs .chosen {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-strong);
}
.option-group small {
  display: block;
  margin-top: calc(8px * var(--space-scale));
  font-size: 0.7143rem;
}
.thread {
  max-width: 1120px;
  margin: auto;
  width: 100%;
}
.message {
  margin: calc(10px * var(--space-scale)) 0 calc(28px * var(--space-scale));
}
.message-label {
  font-size: 0.7857rem;
  color: var(--text-muted);
  margin-bottom: calc(10px * var(--space-scale));
}
.message.user {
  margin-left: auto;
  max-width: 90%;
  width: fit-content;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-card) var(--radius-card) calc(var(--radius-card) * 0.286) var(--radius-card);
  padding: calc(16px * var(--space-scale)) calc(20px * var(--space-scale));
}
.message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
  font-size: 1rem;
}
.message.user .message-label {
  display: none;
}
.message.assistant {
  padding: calc(4px * var(--space-scale)) 0;
}
.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: 16px;
  margin-top: calc(16px * var(--space-scale));
}
.image-card {
  margin: 0;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--surface);
}
.image-preview {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--preview);
}
.image-preview img {
  width: 100%;
  height: auto;
  max-height: 430px;
  object-fit: contain;
  display: block;
}
.image-card figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px * var(--space-scale));
  font-size: 0.7143rem;
  gap: calc(5px * var(--space-scale));
  color: var(--text-muted);
}
.image-card figcaption>div {
  display: flex;
  gap: calc(8px * var(--space-scale));
  align-items: center;
}
.image-card figcaption button {
  font-size: 0.7143rem;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text-secondary);
}
.prompt-detail {
  color: var(--text-muted);
  font-size: 0.7857rem;
  margin-top: calc(15px * var(--space-scale));
}
.prompt-detail summary {
  cursor: pointer;
}
.prompt-detail p {
  line-height: 1.7;
  margin-top: calc(10px * var(--space-scale));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.8571rem;
}
.task-note {
  font-size: 0.8571rem;
  color: var(--text-muted);
  margin-top: calc(12px * var(--space-scale));
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.task-progress {
  display: flex;
  align-items: center;
  gap: calc(12px * var(--space-scale));
  padding: calc(17px * var(--space-scale)) calc(18px * var(--space-scale));
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-card);
  margin: calc(20px * var(--space-scale)) 0;
}
.task-progress>div {
  flex: 1;
}
.task-progress b {
  font-size: 0.8571rem;
  font-weight: 500;
}
.task-progress small {
  display: block;
  color: var(--text-muted);
  font-size: 0.7857rem;
  margin-top: calc(5px * var(--space-scale));
}
.pulse {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 1.7s infinite;
}
@keyframes pulse {
  50% {
    opacity: .3;
  }
}
.reference-chips {
  display: flex;
  gap: calc(8px * var(--space-scale));
  flex-wrap: wrap;
  padding: 12px 16px 0;
  max-height: 102px;
  overflow: auto;
  overscroll-behavior: contain;
}
.reference-chips:empty {
  display: none;
}
.ref-chip {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--space-scale));
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: calc(4px * var(--space-scale)) calc(6px * var(--space-scale)) calc(4px * var(--space-scale)) calc(4px * var(--space-scale));
  font-size: 0.7857rem;
}
.ref-chip img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
}
.ref-chip button {
  padding: calc(2px * var(--space-scale)) calc(5px * var(--space-scale));
  border: 0;
  background: transparent;
  font-size: 1.2143rem;
  color: var(--text-muted);
}
dialog {
  border: 1px solid var(--border);
  max-height: min(900px, calc(100dvh - 32px));
  max-width: calc(100vw - 32px);
  width: 490px;
  padding: calc(27px * var(--space-scale));
  border-radius: var(--radius-dialog);
  box-shadow: 0 20px 90px var(--shadow);
  background: var(--surface-raised);
  color: inherit;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
dialog:has(.admin-panel) {
  width: 920px;
}
dialog:has(.code-input) {
  width: 760px;
}
dialog:has(.preview-modal) {
  width: 900px;
}
dialog::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(3px);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: calc(20px * var(--space-scale));
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-head h2 {
  font-size: 1.4286rem;
}
.modal-head p {
  font-size: 0.8571rem;
  line-height: 1.8;
  margin-top: calc(8px * var(--space-scale));
}
.modal-footer {
  display: flex;
  align-items: center;
  gap: calc(12px * var(--space-scale));
  justify-content: flex-end;
  margin-top: calc(25px * var(--space-scale));
}
.modal-footer>span {
  margin-right: auto;
  font-size: 0.7857rem;
}
.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: calc(20px * var(--space-scale));
  padding: calc(10px * var(--space-scale)) 0 calc(18px * var(--space-scale));
  font-size: 0.8571rem;
}
.admin-toolbar button {
  font-size: 0.8571rem;
}
.user-row {
  display: flex;
  align-items: center;
  gap: calc(12px * var(--space-scale));
  border-bottom: 1px solid var(--border);
  padding: calc(15px * var(--space-scale)) 0;
}
.user-row .grow {
  flex: 1;
}
.user-row small {
  display: block;
  color: var(--text-muted);
  margin-top: calc(5px * var(--space-scale));
}
.user-row button {
  font-size: 0.8571rem;
}
.model-table {
  width: 100%;
  overflow-x: auto;
}
.model-row {
  display: grid;
  grid-template-columns: 40px minmax(220px,1fr) 65px 40px 52px;
  gap: calc(14px * var(--space-scale));
  align-items: center;
  padding: calc(11px * var(--space-scale)) calc(3px * var(--space-scale));
  border-bottom: 1px solid var(--border);
  min-width: 550px;
}
.model-row input {
  width: 100%;
  padding: calc(8px * var(--space-scale)) calc(9px * var(--space-scale));
  font-size: 0.8571rem;
}
.model-row input[type=checkbox],.model-row input[type=radio] {
  width: 16px;
}
.model-row label {
  gap: calc(6px * var(--space-scale));
}
.model-row small {
  font-size: 0.7143rem;
  color: var(--text-muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-row button {
  padding: calc(8px * var(--space-scale));
  font-size: 0.7857rem;
}
.table-head {
  font-size: 0.7857rem;
  color: var(--text-muted);
}
.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(230px,1fr));
  gap: calc(15px * var(--space-scale));
}
.node-card b {
  font-size: 0.9286rem;
  font-weight: 500;
}
.node-card>span {
  font-size: 0.7857rem;
  color: var(--text-muted);
}
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  margin-right: calc(9px * var(--space-scale));
}
.status-dot.online {
  background: var(--success);
}
.code-input,pre {
  font: 0.8571rem/1.6 var(--font-mono);
  white-space: pre;
  overflow: auto;
}
.code-input {
  width: 100%;
  resize: vertical;
}
.preview-modal>img {
  width: 100%;
  max-height: 65dvh;
  object-fit: contain;
}
.preview-modal .button {
  display: block;
  width: fit-content;
  padding: calc(10px * var(--space-scale)) calc(20px * var(--space-scale));
  border-radius: var(--radius-control);
  margin-top: calc(18px * var(--space-scale));
  margin-left: auto;
}
.preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: calc(12px * var(--space-scale));
  margin-top: calc(18px * var(--space-scale));
}
.preview-actions .button {
  display: inline-flex;
  align-items: center;
  margin: 0;
}
.preview-actions button {
  padding: calc(10px * var(--space-scale)) calc(20px * var(--space-scale));
  border-radius: var(--radius-control);
  font-size: 0.9286rem;
}
.preview-hint {
  margin-top: calc(10px * var(--space-scale));
  text-align: right;
  line-height: 1.7;
}
[hidden] {
  display: none!important;
}
@media(max-width:1100px) {
  .sidebar {
    width: 224px;
    padding: 20px 12px 12px;
  }
  .topbar {
    padding-left: 22px;
    padding-right: 22px;
  }
  .compose-wrap {
    width: calc(100% - 44px);
  }
  .conversation {
    padding: 20px 22px;
  }
  .model-bar>label,.size-control {
    padding: 0 calc(10px * var(--space-scale));
  }
  .keyhint {
    display: none;
  }
}
@media(max-width:700px) {
  .sidebar {
    position: fixed;
    z-index: 8;
    height: 100dvh;
    transform: translateX(-100%);
    width: min(288px, calc(100vw - 48px));
    transition: transform .2s;
    box-shadow: 12px 0 48px var(--shadow);
    padding: 22px 14px 14px;
  }
  .menu-open .sidebar {
    transform: translateX(0);
  }
  .mobile-menu {
    display: inline-grid;
    margin-right: 4px;
  }
  .topbar {
    height: auto;
    justify-content: flex-start;
    padding: 10px 12px;
    min-height: 60px;
    gap: 6px;
  }
  .topbar>div {
    flex: initial;
  }
  .topbar h2 {
    font-size: 1rem;
    max-width: none;
  }
  .conversation {
    padding: 18px 16px;
  }
  .empty {
    padding-bottom: calc(25px * var(--space-scale));
    min-height: 0;
    padding: 12px 0 18px;
  }
  .empty h1 {
    font-size: 1.7143rem;
  }
  .empty .eyebrow {
    font-size: 0.5714rem;
  }
  .empty-art {
    width: 64px;
    height: 64px;
    margin-bottom: 18px;
    border-radius: 20px;
  }
  .empty-art:before {
    width: 60px;
    height: 60px;
    border-radius: 18px;
  }
  .empty-art span {
    font-size: 2.8571rem;
  }
  .inspirations {
    gap: calc(6px * var(--space-scale));
    flex-wrap: wrap;
    justify-content: center;
    margin-top: calc(24px * var(--space-scale));
  }
  .inspirations button {
    font-size: 0.7143rem;
    padding: calc(7px * var(--space-scale)) calc(10px * var(--space-scale));
  }
  .compose-wrap {
    width: calc(100% - 24px);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .model-bar {
    flex-wrap: wrap;
    row-gap: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 4px;
  }
  .model-bar label {
    flex: 1;
    max-width: none;
  }
  .size-control {
    flex-basis: auto;
    border: 0;
    padding-left: 0;
    display: block;
    gap: 0;
    align-items: center;
    padding: 5px 9px;
  }
  .size-control>button {
    width: 100%;
  }
  .size-control>span {
    font-size: 0.7143rem;
  }
  .size-popover {
    bottom: calc(100% + 10px);
    right: 0;
    width: min(300px, calc(100vw - 32px));
  }
  .compose-note {
    margin-top: calc(7px * var(--space-scale));
    font-size: 0.6429rem;
  }
  .message.user {
    max-width: 95%;
    padding: calc(13px * var(--space-scale)) calc(16px * var(--space-scale));
  }
  .images-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  }
  .image-preview img {
    max-height: 440px;
  }
  .admin-tabs {
    gap: calc(2px * var(--space-scale));
  }
  .admin-tabs button {
    padding: calc(8px * var(--space-scale));
    font-size: 0.8571rem;
  }
  .user-row {
    gap: calc(8px * var(--space-scale));
  }
  .user-row button {
    padding: calc(7px * var(--space-scale));
    font-size: 0.7857rem;
  }
  .admin-toolbar .muted {
    font-size: 0.7857rem;
  }
  dialog {
    padding: calc(20px * var(--space-scale));
  }
  .modal-footer>span {
    max-width: 50%;
  }
  .task-progress {
    padding: calc(13px * var(--space-scale));
  }
  .task-progress small {
    line-height: 1.6;
    font-size: 0.7143rem;
  }
}
.reference-library-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: calc(10px * var(--space-scale));
  margin-top: calc(20px * var(--space-scale));
}
.reference-library-grid button {
  padding: 0;
  overflow: hidden;
  height: 120px;
}
.reference-library-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.workspace-group {
  margin-bottom: calc(8px * var(--space-scale));
}
.workspace-row {
  display: flex;
  align-items: center;
  gap: calc(2px * var(--space-scale));
}
.workspace-row .space {
  min-width: 0;
  flex: 1;
  margin: 0;
  padding: calc(11px * var(--space-scale)) calc(8px * var(--space-scale));
  gap: calc(8px * var(--space-scale));
}
.new-conversation-icon {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  padding: calc(6px * var(--space-scale));
  font-size: 1.2857rem;
}
.session {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--space-scale));
  width: 100%;
  padding: calc(9px * var(--space-scale)) calc(10px * var(--space-scale));
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--text-secondary);
  font-size: 0.8571rem;
  margin: calc(2px * var(--space-scale)) 0;
}
.session>span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session.selected {
  background: var(--selected);
  color: var(--accent);
  font-weight: 600;
}
.new-conversation {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8571rem;
  padding: calc(9px * var(--space-scale)) calc(10px * var(--space-scale));
}
.thread-actions {
  display: flex;
  flex-shrink: 0;
  gap: calc(2px * var(--space-scale));
}
.topbar>div:not(.thread-actions) {
  min-width: 0;
  flex: 1;
}
.topbar h2 {
  font-size: 1.1429rem;
  margin-top: 4px;
  max-width: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
@media(max-width:700px) {
  .topbar {
    gap: 6px;
    height: auto;
    min-height: 60px;
    padding: 10px 12px;
  }
  .thread-actions {
    gap: 0;
  }
  .thread-actions .text-button {
    padding: 7px 4px;
    font-size: .7143rem;
  }
  .topbar h2 {
    max-width: none;
    font-size: 1rem;
  }
}
.sidebar-close,.sidebar-backdrop {
  display: none;
}
.user-task-status {
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding: calc(12px * var(--space-scale)) 0;
  max-height: min(190px, 24dvh);
  overflow: auto;
  flex-shrink: 0;
}
.status-heading {
  display: flex;
  justify-content: space-between;
  font-size: 0.7857rem;
  color: var(--text-secondary);
  padding: 0 calc(10px * var(--space-scale));
}
.status-heading>span {
  color: var(--text-muted);
}
.status-label {
  font-size: 0.7143rem;
  color: var(--text-muted);
  padding: calc(12px * var(--space-scale)) calc(10px * var(--space-scale)) calc(4px * var(--space-scale));
}
.status-empty {
  font-size: 0.7857rem;
  color: var(--text-muted);
  padding: calc(10px * var(--space-scale));
}
.status-task small {
  display: block;
  font-size: 0.7143rem;
  color: var(--text-muted);
  margin-top: calc(4px * var(--space-scale));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-task .pulse {
  flex-shrink: 0;
  width: 6px;
  height: 6px;
}
.queue-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--scrollbar);
  flex-shrink: 0;
}
@media(max-width:700px) {
  .sidebar-close {
    display: block;
    position: absolute;
    right: 10px;
    top: 12px;
    z-index: 2;
  }
  .menu-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    border: 0;
    border-radius: 0;
    z-index: 19;
  }
  .menu-open .sidebar {
    z-index: 20;
  }
  .user-task-status {
    max-height: 180px;
  }
}
.status-task b {
  display: flex;
  font-size: 0.7857rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-model {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-value {
  flex-shrink: 0;
}
/* Shared controls and popovers use the studio palette on every platform. */
.model-control {
  flex: 1;
  min-width: 0;
  padding: 0 12px;
  border-left: 1px solid var(--border);
  position: relative;
}
.model-control:first-child {
  border: 0;
  padding-left: 12px;
}
.model-control>span {
  display: block;
  font-size: 0.7143rem;
  color: var(--text-muted);
}
.picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(8px * var(--space-scale));
  width: 100%;
  border: 0;
  background: transparent;
  padding: calc(4px * var(--space-scale)) 0;
  font-size: .8571rem;
  text-align: left;
  min-height: 28px;
}
.picker-trigger>span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-trigger>span:last-child {
  color: var(--text-muted);
  flex-shrink: 0;
}
.picker-trigger[aria-expanded=true] {
  color: var(--accent);
}
.popover-panel {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  box-shadow: 0 12px 45px var(--shadow);
  border-radius: var(--radius-dialog);
}
.model-popover {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: min(340px,50dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: calc(7px * var(--space-scale));
  z-index: 6;
}
.model-control[data-model-control=image] .model-popover {
  left: auto;
  right: 0;
}
.picker-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(12px * var(--space-scale));
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  padding: calc(11px * var(--space-scale)) calc(12px * var(--space-scale));
  text-align: left;
  font-size: 0.8571rem;
  line-height: 1.5;
  border-radius: var(--radius-control);
}
.picker-option>span:first-child {
  overflow-wrap: anywhere;
}
.picker-option>span:last-child {
  flex-shrink: 0;
}
.picker-option.chosen {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-strong);
}
.picker-option:focus-visible,.rename-icon:focus-visible,.picker-trigger:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.session-row {
  display: flex;
  align-items: center;
  gap: calc(2px * var(--space-scale));
  min-width: 0;
}
.session-row .session {
  flex: 1;
  min-width: 0;
}
.rename-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 32px;
  border: 0;
  background: transparent;
  padding: calc(6px * var(--space-scale));
  color: var(--text-secondary);
  border-radius: var(--radius-control);
}
.rename-icon:hover {
  color: var(--accent);
  background: var(--selected);
}
.session-row .rename-icon {
  width: 28px;
}
.session-list {
  margin: calc(4px * var(--space-scale)) 0 calc(12px * var(--space-scale)) calc(16px * var(--space-scale));
  padding-left: calc(7px * var(--space-scale));
  border-left: 1px solid var(--border);
  margin-left: calc(14px * var(--space-scale));
}
@media(max-width:1100px) {
  .model-control {
    padding: 0 10px;
  }
}
@media(max-width:700px) {
  .model-control {
    flex: initial;
    max-width: none;
    padding: 5px 9px;
    border-left: 0;
  }
  .model-popover {
    width: 310px;
  }
  .rename-icon {
    width: 32px;
    height: 34px;
  }
}
.native-admin-link {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  padding: calc(9px * var(--space-scale)) calc(13px * var(--space-scale));
  color: var(--green);
  font-size: 0.8571rem;
}
.native-admin-link:hover {
  background: var(--hover);
}
.native-admin-link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
@media(max-width:700px) {
  .admin-toolbar:has(.native-admin-link) {
    flex-wrap: wrap;
    gap: calc(10px * var(--space-scale));
  }
}
.status-task .status-detail {
  white-space: normal;
  line-height: 1.5;
  color: var(--text-secondary);
}
.status-task>span:last-child {
  min-width: 0;
  flex: 1;
}
.status-task {
  display: flex;
  align-items: flex-start;
  gap: calc(9px * var(--space-scale));
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: calc(9px * var(--space-scale)) calc(10px * var(--space-scale));
  min-width: 0;
}
.status-task>.pulse,.status-task>.queue-dot {
  margin-top: calc(5px * var(--space-scale));
}
.image-review {
  padding: calc(12px * var(--space-scale)) calc(15px * var(--space-scale));
  border-top: 1px solid var(--line);
  font-size: 0.7857rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.image-review summary {
  cursor: pointer;
  color: var(--text-secondary);
}
.image-review p {
  margin: calc(8px * var(--space-scale)) 0;
}
.image-review small {
  color: var(--text-muted);
}
.image-review ul {
  padding-left: calc(18px * var(--space-scale));
}
.image-review.review-issues summary {
  color: var(--warning);
}
/* Gallery */
#gallery-nav {
  padding: 0 calc(4px * var(--space-scale));
}
.gallery-nav {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--space-scale));
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  padding: calc(11px * var(--space-scale)) calc(12px * var(--space-scale));
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  font-size: 0.9286rem;
  margin: calc(2px * var(--space-scale)) 0 0;
}
.gallery-nav:hover {
  background: var(--hover);
}
.gallery-nav.selected {
  background: var(--selected);
  color: var(--accent);
  font-weight: 600;
}
.gallery-nav .grow {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-nav small {
  min-width: 24px;
  text-align: center;
  font-size: 0.7143rem;
  color: var(--text-secondary);
  background: var(--accent-soft);
  border-radius: var(--radius-control);
  padding: calc(2px * var(--space-scale)) calc(7px * var(--space-scale));
}
.gallery-nav-icon {
  font-size: 1.1429rem;
  line-height: 1;
  color: var(--text-secondary);
}
.gallery-mode .conversation,.gallery-mode .compose-wrap,.gallery-mode .model-bar,.gallery-mode .thread-actions {
  display: none!important;
}
.gallery-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.gallery-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: calc(14px * var(--space-scale)) calc(30px * var(--space-scale));
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-wrap: wrap;
}
.gallery-summary {
  display: flex;
  align-items: baseline;
  gap: calc(7px * var(--space-scale));
  min-width: 0;
  flex: 1 1 170px;
  flex-wrap: wrap;
}
.gallery-summary b {
  font: 2rem/1 var(--font-display);
  color: var(--accent);
  font-weight: 500;
}
.gallery-summary span {
  font-size: 0.9286rem;
  color: var(--text-secondary);
}
.gallery-summary small {
  font-size: 0.7143rem;
  color: var(--text-muted);
  margin-left: calc(5px * var(--space-scale));
  white-space: nowrap;
}
.gallery-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
  max-width: 100%;
}
.gallery-filter-wrap {
  position: relative;
  min-width: 0;
}
.gallery-filter {
  display: flex;
  align-items: center;
  gap: calc(12px * var(--space-scale));
  max-width: 230px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-control);
  padding: 8px 10px;
  font-size: 0.8571rem;
  color: var(--text-secondary);
}
.gallery-filter>.gallery-filter-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-filter>span[aria-hidden] {
  color: var(--text-muted);
  flex-shrink: 0;
}
.gallery-select-toggle {
  padding: 8px 12px;
  min-height: 36px;
  flex-shrink: 0;
  white-space: nowrap;
  font-size: .8571rem;
}
.gallery-select-toggle[aria-pressed=true], .gallery-select-toggle.chosen {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--border-strong);
}
.gallery-filter[aria-expanded=true] {
  border-color: var(--focus);
  background: var(--accent-soft);
  color: var(--accent);
}
.gallery-popover {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  z-index: 30;
  width: 280px;
  max-height: min(380px,60dvh);
  overflow: auto;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 16px 50px var(--shadow);
  padding: calc(6px * var(--space-scale));
  overscroll-behavior: contain;
}
#gallery-conversation-popover {
  left: auto;
  right: 0;
}
.gallery-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(12px * var(--space-scale));
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: calc(10px * var(--space-scale)) calc(11px * var(--space-scale));
  border-radius: var(--radius-control);
  font-size: 0.8571rem;
  line-height: 1.45;
}
.gallery-option>small {
  color: var(--text-muted);
  font-size: 0.7143rem;
  flex-shrink: 0;
}
.gallery-option.chosen {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-strong);
}
.gallery-option:hover {
  background: var(--hover);
}
.gallery-popover-sep {
  height: 1px;
  background: var(--border);
  margin: calc(6px * var(--space-scale)) calc(4px * var(--space-scale));
}
.gallery-popover-empty {
  font-size: 0.7857rem;
  color: var(--text-muted);
  padding: calc(12px * var(--space-scale)) calc(11px * var(--space-scale));
  line-height: 1.6;
}
.gallery-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 30px 30px;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.gallery-grid {
  columns: 230px;
  column-gap: 16px;
}
.gallery-card {
  display: block;
  width: 100%;
  margin: 0 0 16px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--preview);
  break-inside: avoid;
  position: relative;
  text-align: left;
  transition: border-color .15s,box-shadow .15s,transform .15s;
  user-select: none;
  -webkit-touch-callout: none;
}
.gallery-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 7px 24px var(--shadow);
  transform: translateY(-1px);
}
.gallery-card:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.gallery-card img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  background: var(--preview);
}
.gallery-card-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  background: var(--stage-overlay);
  color: var(--stage-text);
  border-radius: var(--radius-control);
  padding: calc(3px * var(--space-scale)) calc(7px * var(--space-scale));
  font-size: 0.6429rem;
  letter-spacing: .3px;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.gallery-card-check {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--stage-text) 80.0%, transparent);
  background: var(--stage-overlay);
  color: transparent;
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s,background .12s;
}
.gallery-view.selecting .gallery-card-check {
  opacity: 1;
}
.gallery-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20.0%, transparent);
}
.gallery-card.selected .gallery-card-check {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
.gallery-card.located {
  animation: located 2.2s ease;
}
@keyframes located {
  0%,100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0.0%, transparent);
  }
  18%,70% {
    box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 33.3%, transparent);
  }
}
.gallery-empty {
  min-height: 330px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: calc(35px * var(--space-scale)) 0;
}
.gallery-empty .empty-art {
  width: 70px;
  height: 70px;
  border-radius: 22px;
  margin-bottom: calc(24px * var(--space-scale));
}
.gallery-empty .empty-art:before {
  width: 64px;
  height: 64px;
  border-radius: 19px;
}
.gallery-empty .empty-art span {
  font-size: 2.4286rem;
}
.gallery-empty h1 {
  font-size: 1.7143rem;
  font-weight: 500;
  margin: calc(10px * var(--space-scale)) 0 calc(8px * var(--space-scale));
}
.gallery-empty p {
  color: var(--text-muted);
  font-size: 0.8571rem;
  line-height: 1.8;
}
.gallery-empty button {
  margin-top: calc(20px * var(--space-scale));
}
.gallery-skeleton-card {
  height: 210px;
  border-radius: var(--radius-card);
  margin: 0 0 calc(14px * var(--space-scale));
  break-inside: avoid;
  background: linear-gradient(100deg,var(--skeleton) 20%,var(--surface) 40%,var(--skeleton) 60%);
  background-size: 220% 100%;
  animation: galleryShimmer 1.3s infinite linear;
}
@keyframes galleryShimmer {
  to {
    background-position: -220% 0;
  }
}
.gallery-more-wrap {
  text-align: center;
  padding: calc(14px * var(--space-scale)) 0 calc(4px * var(--space-scale));
}
.gallery-more {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.8571rem;
  padding: calc(9px * var(--space-scale)) calc(20px * var(--space-scale));
}
.gallery-loading {
  font-size: 0.7857rem;
  color: var(--text-muted);
}
.gallery-sentinel {
  height: 1px;
}
.gallery-selection-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 30px max(12px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 28px var(--shadow);
  z-index: 9;
  flex-wrap: wrap;
}
.gallery-selection-count {
  font-size: 0.8571rem;
  color: var(--text-secondary);
  flex: 1 1 100px;
}
.gallery-selection-count b {
  color: var(--accent);
  font-size: 1.0714rem;
  margin: 0 calc(2px * var(--space-scale));
}
.gallery-selection-bar .text-button {
  font-size: 0.8571rem;
  padding: calc(8px * var(--space-scale)) calc(2px * var(--space-scale));
}
.gallery-selection-actions {
  display: flex;
  gap: calc(8px * var(--space-scale));
  margin-left: auto;
  flex-wrap: wrap;
}
.gallery-selection-actions button {
  font-size: 0.8571rem;
  padding: calc(9px * var(--space-scale)) calc(16px * var(--space-scale));
}
button.danger,.button.danger {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}
button.danger:hover,.button.danger:hover {
  background: color-mix(in srgb, var(--danger-bg) 90%, var(--danger));
  color: var(--danger-hover);
  border-color: var(--danger);
}
.toast-action {
  border: 0;
  background: transparent;
  color: var(--tooltip-text);
  text-decoration: underline;
  padding: 0 0 0 calc(8px * var(--space-scale));
  font-size: 0.8571rem;
}
.gallery-view.selecting .gallery-card {
  cursor: pointer;
}
/* Lightbox */
dialog.lightbox {
  width: min(1180px,calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: 92dvh;
  padding: 0;
  border: 0;
  border-radius: var(--radius-dialog);
  background: var(--stage);
  color: var(--stage-text);
  overflow: hidden;
  box-shadow: 0 30px 120px var(--shadow);
}
dialog.lightbox::backdrop {
  background: var(--overlay);
  backdrop-filter: blur(4px);
}
.lightbox-top {
  height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 calc(18px * var(--space-scale)) 0 calc(22px * var(--space-scale));
  border-bottom: 1px solid color-mix(in srgb, var(--stage-text) 7.8%, transparent);
  color: var(--stage-text);
}
.lightbox-top .eyebrow {
  color: var(--stage-text);
}
.lightbox-top-actions {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--space-scale));
}
.lightbox-counter {
  font-size: 0.7857rem;
  color: var(--stage-text);
  letter-spacing: .5px;
}
.lightbox-top .icon {
  color: var(--stage-text);
  font-size: 1.7143rem;
}
.lightbox-top .icon:hover {
  background: color-mix(in srgb, var(--stage-text) 7.8%, transparent);
}
.lightbox-layout {
  display: grid;
  grid-template-columns: minmax(0,1fr) 350px;
  max-height: calc(92dvh - 57px);
  min-height: 0;
}
.lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(22px * var(--space-scale));
  min-width: 0;
  min-height: 300px;
  background: var(--stage);
}
.lightbox-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(92dvh - 110px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: calc(var(--radius-card) * 0.286);
  box-shadow: 0 12px 50px var(--shadow);
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--stage-text) 14.1%, transparent);
  background: var(--stage-overlay);
  color: var(--stage-text);
  font-size: 1.7857rem;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
  backdrop-filter: blur(5px);
}
.lightbox-nav:hover {
  background: var(--stage-overlay);
}
.lightbox-nav:disabled {
  opacity: .25;
}
.lightbox-nav.prev {
  left: 14px;
}
.lightbox-nav.next {
  right: 14px;
}
.lightbox-meta {
  background: var(--surface);
  color: var(--text);
  padding: calc(23px * var(--space-scale)) calc(22px * var(--space-scale)) calc(24px * var(--space-scale));
  overflow: auto;
  min-height: 0;
}
.lightbox-meta h2 {
  font-size: 1.3571rem;
  margin-bottom: calc(18px * var(--space-scale));
}
.lightbox-facts {
  margin: 0;
  display: grid;
  gap: calc(10px * var(--space-scale));
}
.lightbox-facts>div {
  display: grid;
  grid-template-columns: 52px minmax(0,1fr);
  gap: calc(10px * var(--space-scale));
  font-size: 0.7857rem;
  line-height: 1.55;
}
.lightbox-facts dt {
  color: var(--text-muted);
}
.lightbox-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
}
.lightbox-detail {
  border-top: 1px solid var(--border);
  margin-top: calc(16px * var(--space-scale));
  padding-top: calc(13px * var(--space-scale));
  font-size: 0.7857rem;
  line-height: 1.7;
  color: var(--text-secondary);
}
.lightbox-detail summary {
  cursor: pointer;
  color: var(--text-secondary);
}
.lightbox-detail p {
  margin-top: calc(9px * var(--space-scale));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.7857rem;
  line-height: 1.75;
  color: var(--text-secondary);
}
.lightbox-detail h4 {
  font-size: 0.7857rem;
  margin: calc(12px * var(--space-scale)) 0 0;
  color: var(--text-secondary);
}
.lightbox-detail ul {
  margin: calc(8px * var(--space-scale)) 0 0;
  padding-left: calc(16px * var(--space-scale));
}
.lightbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: calc(8px * var(--space-scale));
  margin-top: calc(22px * var(--space-scale));
  padding-top: calc(15px * var(--space-scale));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.lightbox-actions .button,.lightbox-actions button {
  font-size: 0.8571rem;
  padding: calc(9px * var(--space-scale)) calc(14px * var(--space-scale));
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lightbox-actions .button {
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
}
.lightbox-actions .button.primary {
  color: var(--on-accent);
  border-color: var(--accent);
}
.lightbox-actions .grow {
  flex: 1;
}
@media(max-width:1100px) {
  .gallery-grid {
    columns: 210px;
  }
  .lightbox-layout {
    grid-template-columns: minmax(0,1fr) 320px;
  }
}
@media(max-width:700px) {
  .gallery-toolbar {
    padding: 12px 16px;
    align-items: stretch;
    flex-direction: row;
    gap: 10px;
  }
  .gallery-summary b {
    font-size: 1.7143rem;
  }
  .gallery-filters {
    width: 100%;
    gap: 7px;
  }
  .gallery-filter-wrap {
    flex: 1 1 120px;
    min-width: 0;
  }
  .gallery-filter {
    width: 100%;
    max-width: none;
    justify-content: space-between;
    padding: 8px 9px;
    gap: 6px;
  }
  .gallery-popover {
    width: min(300px,calc(100vw - 44px));
  }
  .gallery-scroll {
    padding: 14px 14px 24px;
  }
  .gallery-grid {
    columns: 2;
    column-gap: 10px;
  }
  .gallery-card {
    margin-bottom: 10px;
    border-radius: var(--radius-control);
  }
  .gallery-card-badge {
    left: 6px;
    top: 6px;
    font-size: 0.5714rem;
  }
  .gallery-card-check {
    right: 6px;
    top: 6px;
    width: 21px;
    height: 21px;
  }
  .gallery-selection-bar {
    padding: 10px 14px max(10px, env(safe-area-inset-bottom));
    gap: 8px;
    flex-wrap: wrap;
  }
  .gallery-selection-actions {
    width: 100%;
    order: 3;
    margin-left: 0;
    gap: 6px;
  }
  .gallery-selection-actions button {
    flex: 1 1 110px;
    padding: 9px 10px;
  }
  .gallery-summary small {
    font-size: 0.6429rem;
  }
  dialog.lightbox {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  .lightbox-layout {
    grid-template-columns: 1fr;
    max-height: calc(100dvh - 57px);
    overflow: auto;
  }
  .lightbox-stage {
    min-height: 0;
    padding: calc(12px * var(--space-scale)) calc(12px * var(--space-scale)) calc(6px * var(--space-scale));
    max-height: 52dvh;
  }
  .lightbox-stage img {
    max-height: 50dvh;
  }
  .lightbox-meta {
    padding: calc(18px * var(--space-scale)) calc(17px * var(--space-scale)) calc(24px * var(--space-scale));
    overflow: visible;
  }
  .lightbox-meta h2 {
    font-size: 1.2143rem;
    margin-bottom: calc(14px * var(--space-scale));
  }
  .lightbox-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .lightbox-nav {
    width: 33px;
    height: 33px;
  }
  .lightbox-nav.prev {
    left: 7px;
  }
  .lightbox-nav.next {
    right: 7px;
  }
}
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translate(-50%,12px);
  background: var(--tooltip);
  color: var(--tooltip-text);
  padding: calc(12px * var(--space-scale)) calc(21px * var(--space-scale));
  border-radius: var(--radius-control);
  box-shadow: 0 4px 22px var(--shadow);
  max-width: 90vw;
  font-size: 0.9286rem;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%,0);
  pointer-events: auto;
}
.image-preview.located {
  animation: located 2.2s ease;
}
.side-bottom .side-logout {
  color: var(--danger);
  border-top: 1px solid var(--border);
  margin-top: calc(2px * var(--space-scale));
  padding-top: calc(9px * var(--space-scale));
}
.side-bottom .side-logout:hover {
  background: var(--danger-bg);
  color: var(--danger-hover);
}
.video-wrap video {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-card);
  background: var(--stage);
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: calc(6px * var(--space-scale));
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.8571rem;
}
.switch[hidden] {
  display: none;
}
.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--switch-track);
  transition: background .18s;
}
.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--switch-thumb);
  box-shadow: 0 1px 2px var(--shadow);
  transition: transform .18s;
}
.switch.on .switch-track {
  background: var(--accent);
}
.switch.on .switch-thumb {
  transform: translateX(14px);
}
.switch.on {
  color: var(--accent);
}
.model-control[data-model-control=effort] .model-popover {
  width: 220px;
}
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.switch-row .switch {
  gap: calc(8px * var(--space-scale));
  color: var(--text);
}
/* API gateways and model cards */
.admin-tabs {
  display: flex;
  gap: calc(6px * var(--space-scale));
  border-bottom: 1px solid var(--line);
  padding-bottom: calc(15px * var(--space-scale));
  margin-bottom: calc(10px * var(--space-scale));
  overflow-x: auto;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.admin-tabs button {
  border: 1px solid transparent;
  background: transparent;
  padding: calc(8px * var(--space-scale)) calc(15px * var(--space-scale));
  white-space: nowrap;
}
.gateway-switcher,.gateway-type-tabs,.gateway-actions,.gateway-import-actions {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--space-scale));
  flex-wrap: wrap;
}
.gateway-switcher button.chosen,.gateway-type-tabs button.chosen {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-strong);
}
.gateway-switcher {
  margin: calc(18px * var(--space-scale)) 0;
}
.gateway-switcher button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: calc(3px * var(--space-scale));
  max-width: 100%;
  overflow-wrap: anywhere;
}
.gateway-switcher small {
  font-size: 0.7857rem;
  color: var(--muted);
}
.gateway-form {
  padding: calc(18px * var(--space-scale));
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.gateway-fields {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: calc(14px * var(--space-scale));
}
.gateway-fields label {
  min-width: 0;
}
.gateway-fields label:last-child {
  grid-column: 1/-1;
}
.gateway-fields input {
  width: 100%;
  min-width: 0;
}
.gateway-actions {
  justify-content: flex-end;
  margin-top: calc(16px * var(--space-scale));
}
.gateway-actions .muted {
  margin-right: auto;
  font-size: 0.8571rem;
}
.gateway-catalog {
  margin-top: calc(22px * var(--space-scale));
}
.gateway-type-tabs {
  gap: calc(6px * var(--space-scale));
}
.gateway-type-tabs button {
  font-size: 0.9286rem;
}
.gateway-type-tabs small {
  margin-left: calc(4px * var(--space-scale));
  opacity: .6;
}
.gateway-search {
  margin: calc(16px * var(--space-scale)) 0 calc(8px * var(--space-scale));
}
.gateway-search input {
  margin-top: calc(6px * var(--space-scale));
}
#gateway-results {
  max-height: 380px;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.gateway-model-row {
  display: grid;
  grid-template-columns: 20px minmax(0,1fr) auto;
  gap: calc(12px * var(--space-scale));
  align-items: center;
  padding: calc(12px * var(--space-scale)) calc(3px * var(--space-scale));
  border-bottom: 1px solid var(--line);
}
.gateway-model-row:last-child {
  border-bottom: 0;
}
.gateway-model-row input {
  width: 16px;
  height: 16px;
}
.gateway-model-row b,.gateway-model-row small {
  display: block;
  overflow-wrap: anywhere;
}
.gateway-model-row b {
  font-size: 0.9286rem;
}
.gateway-model-row small {
  font-size: 0.7857rem;
  color: var(--muted);
  margin-top: calc(4px * var(--space-scale));
}
.gateway-model-row button {
  font-size: 0.8571rem;
}
.gateway-import-actions {
  padding-top: calc(16px * var(--space-scale));
  justify-content: space-between;
}
.gateway-import-actions label {
  display: flex;
  align-items: center;
  gap: calc(7px * var(--space-scale));
  font-size: 0.8571rem;
  margin: 0;
  flex-direction: row;
}
.gateway-import-actions input {
  width: 15px;
  height: 15px;
}
.gateway-import-actions .muted {
  font-size: 0.8571rem;
}
.gateway-empty {
  padding: calc(24px * var(--space-scale)) calc(4px * var(--space-scale));
  line-height: 1.7;
}
.model-row-actions {
  display: flex;
  gap: calc(5px * var(--space-scale));
  flex-wrap: wrap;
  min-width: 0;
}
.model-row-actions button {
  padding: calc(7px * var(--space-scale));
  font-size: 0.7857rem;
}
.model-card-view {
  min-width: 0;
  max-width: 100%;
}
.model-card-id {
  font-size: 0.8571rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.model-card-description {
  font-size: 0.9286rem;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 240px;
  overflow: auto;
}
.model-card-endpoints {
  display: grid;
  gap: calc(8px * var(--space-scale));
  margin: calc(18px * var(--space-scale)) 0;
}
.model-card-endpoints>div {
  padding: calc(10px * var(--space-scale));
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  overflow-wrap: anywhere;
}
.model-card-endpoints b {
  font-size: 0.8571rem;
}
.model-card-endpoints small {
  display: block;
  margin-top: calc(4px * var(--space-scale));
  color: var(--muted);
}
.model-card-view pre {
  max-height: 420px;
  max-width: 100%;
  overflow: auto;
  font-size: 0.7857rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sync-result {
  padding: calc(12px * var(--space-scale));
  font-size: 0.8571rem;
  line-height: 1.6;
  border-radius: var(--radius-control);
  background: var(--warning-bg);
  color: var(--warning);
  overflow-wrap: anywhere;
}
.picker-group-label {
  padding: calc(10px * var(--space-scale)) calc(12px * var(--space-scale)) calc(4px * var(--space-scale));
  font-size: 0.7857rem;
  color: var(--muted);
  letter-spacing: 1px;
}
.model-popover [role=group]+[role=group] {
  border-top: 1px solid var(--line);
  margin-top: calc(6px * var(--space-scale));
}
@media(max-width:700px) {
  .gateway-fields {
    grid-template-columns: 1fr;
  }
  .gateway-fields label:last-child {
    grid-column: auto;
  }
  .gateway-form {
    padding: calc(13px * var(--space-scale));
  }
  .gateway-actions>button.primary {
    width: 100%;
  }
  .gateway-type-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .gateway-type-tabs button {
    padding: calc(9px * var(--space-scale)) calc(6px * var(--space-scale));
  }
  .gateway-model-row {
    gap: calc(8px * var(--space-scale));
  }
  .gateway-import-actions>.primary {
    width: 100%;
  }
  .model-row-actions {
    flex-direction: column;
  }
  .admin-toolbar {
    flex-wrap: wrap;
    gap: calc(10px * var(--space-scale));
  }
  .admin-panel .modal-footer {
    flex-wrap: wrap;
  }
  .admin-panel .modal-footer .muted {
    font-size: 0.8571rem;
  }
}
.image-generation {
  min-width: 0;
  padding: 0 calc(12px * var(--space-scale)) calc(12px * var(--space-scale));
  font-size: 0.7857rem;
  line-height: 1.7;
}
.image-generation-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: calc(3px * var(--space-scale)) calc(14px * var(--space-scale));
  margin: 0;
  color: var(--text-secondary);
  min-width: 0;
  text-align: left;
}
.image-generation-model {
  flex: 1 1 120px;
  font-weight: 500;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.image-generation-time {
  font-size: 0.7143rem;
  white-space: nowrap;
  color: var(--text-muted);
}
.image-generation-details {
  margin-top: calc(9px * var(--space-scale));
  padding-top: calc(9px * var(--space-scale));
  border-top: 1px solid var(--line);
  font-size: 0.7857rem;
  line-height: 1.7;
  min-width: 0;
}
.image-generation-details>summary {
  cursor: pointer;
  color: var(--text-secondary);
}
.image-generation-details dl {
  margin: calc(9px * var(--space-scale)) 0 0;
  display: grid;
  gap: calc(5px * var(--space-scale));
}
.image-generation-details dl>div {
  display: grid;
  grid-template-columns: 78px minmax(0,1fr);
  gap: calc(8px * var(--space-scale));
}
.image-generation-details dt {
  color: var(--text-muted);
}
.image-generation-details dd {
  margin: 0;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
  min-width: 0;
}
.image-generation-details p {
  margin: calc(8px * var(--space-scale)) 0 0;
}
.gallery-card-info {
  display: block;
  padding: calc(10px * var(--space-scale)) calc(12px * var(--space-scale));
  background: var(--surface-raised);
  font-size: 0.7143rem;
  line-height: 1.7;
  color: var(--text-muted);
}
.gallery-card-info>.image-generation-summary {
  margin-top: calc(4px * var(--space-scale));
}
.gallery-card-info .image-generation-model {
  flex-basis: 100%;
  font-size: 0.7857rem;
}
.lightbox-meta>.image-generation-details {
  margin: calc(16px * var(--space-scale)) 0;
  font-size: 0.8571rem;
}
.preview-modal>.image-generation {
  padding: calc(12px * var(--space-scale)) 0 0;
}
.cluster-settings {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: calc(16px * var(--space-scale));
  margin: calc(10px * var(--space-scale)) 0 calc(14px * var(--space-scale));
}
.cluster-picker,.cluster-picker:first-child {
  padding: 0;
  border: 0;
  min-width: 0;
  max-width: none;
}
.cluster-picker>.picker-trigger {
  padding: calc(10px * var(--space-scale)) calc(12px * var(--space-scale));
  margin-top: calc(6px * var(--space-scale));
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--input);
  min-height: 41px;
}
.cluster-picker .model-popover {
  position: fixed;
  bottom: auto;
  right: auto;
  z-index: 12;
  width: 280px;
  margin: 0;
}
.cluster-picker .picker-option {
  font-size: 0.8571rem;
}
/* Prompt library and model assignments share the existing admin pickers. */
.prompt-manager,.prompt-workbench>* {
  min-width: 0;
}
.prompt-intro,.prompt-help {
  font-size: 0.7857rem;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.prompt-intro {
  margin: calc(16px * var(--space-scale)) 0 calc(8px * var(--space-scale));
}
.prompt-workbench {
  display: grid;
  grid-template-columns: minmax(210px, .7fr) minmax(0, 1.3fr);
  gap: calc(18px * var(--space-scale));
  align-items: start;
}
.prompt-library {
  display: flex;
  flex-direction: column;
  gap: calc(10px * var(--space-scale));
  max-height: 700px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.prompt-library-card {
  min-width: 0;
  padding: calc(12px * var(--space-scale));
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
}
.prompt-library-card.chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.prompt-template-open {
  display: flex;
  width: 100%;
  align-items: start;
  justify-content: space-between;
  gap: calc(10px * var(--space-scale));
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.prompt-template-open>span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}
.prompt-template-open b {
  font-size: 0.9286rem;
}
.prompt-template-open small {
  display: block;
  margin-top: calc(6px * var(--space-scale));
  font-size: 0.7143rem;
  line-height: 1.7;
}
.prompt-status-on {
  color: var(--accent);
}
.prompt-library-excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  margin: calc(10px * var(--space-scale)) 0;
  color: var(--text-muted);
  font-size: 0.7857rem;
  line-height: 1.8;
  white-space: pre-wrap;
}
.prompt-template-actions {
  display: flex;
  flex-wrap: wrap;
  gap: calc(6px * var(--space-scale));
}
.prompt-template-actions button {
  flex: 1 1 auto;
  font-size: 0.7857rem;
  padding: calc(7px * var(--space-scale)) calc(9px * var(--space-scale));
}
.prompt-library-empty,.prompt-editor-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius-card);
  padding: calc(20px * var(--space-scale));
  font-size: 0.8571rem;
  line-height: 1.8;
}
.prompt-editor {
  padding: calc(18px * var(--space-scale));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.prompt-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: calc(8px * var(--space-scale));
  margin-bottom: calc(15px * var(--space-scale));
}
.prompt-section-heading h3 {
  font-size: 1rem;
}
.prompt-section-heading>span {
  font-size: 0.7857rem;
}
.prompt-editor fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.prompt-editor fieldset>label+label {
  margin-top: calc(16px * var(--space-scale));
}
.prompt-editor input:not([type=checkbox]),.prompt-editor textarea {
  width: 100%;
  min-width: 0;
}
.prompt-editor textarea {
  font-family: inherit;
  font-size: 0.8571rem;
  line-height: 1.85;
  min-height: 230px;
  max-height: 65dvh;
  overflow-y: auto;
  resize: vertical;
}
.prompt-editor-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: calc(10px * var(--space-scale));
  margin: calc(13px * var(--space-scale)) 0;
}
.prompt-editor .prompt-enabled {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: calc(8px * var(--space-scale));
  margin: 0;
  font-size: 0.8571rem;
}
.prompt-enabled input {
  width: 16px;
  height: 16px;
  margin: 0;
}
.prompt-editor-meta small {
  font-size: 0.7143rem;
}
.prompt-bindings {
  margin-top: calc(28px * var(--space-scale));
  padding-top: calc(24px * var(--space-scale));
  border-top: 1px solid var(--line);
}
.prompt-model-bindings {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: calc(18px * var(--space-scale));
  margin-top: calc(20px * var(--space-scale));
}
.prompt-model-binding {
  min-width: 0;
}
.prompt-manager .cluster-picker {
  width: 100%;
}
.prompt-manager .picker-trigger {
  width: 100%;
  max-width: 100%;
}
.prompt-manager .picker-trigger>span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prompt-manager .picker-option>span:first-child,
.prompt-manager .model-control>span,
.prompt-binding-detail {
  overflow-wrap: anywhere;
}
.prompt-manager .picker-option>span:first-child {
  min-width: 0;
  white-space: normal;
  text-align: left;
}
.prompt-binding-detail {
  display: block;
  margin-top: calc(7px * var(--space-scale));
  font-size: 0.7143rem;
  line-height: 1.8;
}
.prompt-error {
  margin-top: calc(12px * var(--space-scale));
  color: var(--danger);
  font-size: 0.8571rem;
  overflow-wrap: anywhere;
}
.prompt-editor-footer,.prompt-settings-footer {
  flex-wrap: wrap;
  gap: calc(8px * var(--space-scale));
}
.prompt-image-panel {
  min-width: 0;
  margin-top: calc(20px * var(--space-scale));
  margin-bottom: calc(28px * var(--space-scale));
  padding-bottom: calc(24px * var(--space-scale));
  border-bottom: 1px solid var(--line);
}
.prompt-image-model-meta {
  display: flex;
  flex-wrap: wrap;
  gap: calc(8px * var(--space-scale)) calc(14px * var(--space-scale));
  margin: calc(10px * var(--space-scale)) 0 calc(16px * var(--space-scale));
  font-size: 0.7143rem;
  line-height: 1.8;
}
.prompt-image-model-meta code {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.prompt-image-editor h4 {
  margin: 0;
  font-size: 0.9286rem;
}
.prompt-creative-heading {
  font-size: 1rem;
}
.prompt-image-footer {
  flex-wrap: wrap;
  gap: calc(10px * var(--space-scale));
}
.prompt-image-footer>span {
  flex: 1 1 100%;
  min-width: 0;
  font-size: 0.7143rem;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.prompt-image-actions {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: calc(8px * var(--space-scale));
}
.prompt-image-actions button {
  flex: 0 1 auto;
  min-width: 0;
}
@media(max-width:700px) {
  .prompt-workbench,.prompt-model-bindings {
    grid-template-columns: minmax(0,1fr);
  }
  .prompt-toolbar {
    flex-wrap: wrap;
    gap: 10px;
  }
  .prompt-library {
    max-height: 320px;
  }
  .prompt-editor {
    padding: 14px;
  }
  .prompt-editor textarea {
    min-height: 220px;
    max-height: 55dvh;
  }
  .prompt-settings-footer>span {
    flex: 1 1 100%;
  }
  .prompt-settings-footer>button,.prompt-editor-footer>button {
    flex: 1 1 auto;
  }
  .prompt-image-actions button {
    flex: 1 1 auto;
  }
}
.cluster-hint {
  font-size: 0.7857rem;
  line-height: 1.8;
  margin: 0 0 calc(16px * var(--space-scale));
}
.node-card {
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-card);
  min-width: 0;
}
.node-card .node-address {
  display: block;
  margin-top: calc(5px * var(--space-scale));
  font-size: 0.7857rem;
  color: var(--text-muted);
}
.node-card .cluster-picker {
  margin-top: calc(16px * var(--space-scale));
}
.node-card p {
  color: var(--text-muted);
  font-size: 0.7857rem;
  margin: calc(12px * var(--space-scale)) 0 0;
  overflow-wrap: anywhere;
}
.node-maintenance {
  background: var(--surface-alt);
}
.node-maintenance .status-dot {
  background: var(--text-muted);
}
.cluster-operation {
  padding: calc(12px * var(--space-scale)) calc(14px * var(--space-scale));
  margin: calc(16px * var(--space-scale)) 0 0;
  background: var(--surface-alt);
  border-radius: var(--radius-control);
  font-size: 0.8571rem;
  line-height: 1.7;
}
#cluster-form .modal-footer {
  margin-top: calc(18px * var(--space-scale));
}
.cluster-queue {
  white-space: nowrap;
}
@media(max-width:700px) {
  .cluster-settings {
    grid-template-columns: minmax(0,1fr);
    gap: calc(12px * var(--space-scale));
  }
  #cluster-form .node-grid {
    grid-template-columns: minmax(0,1fr);
    gap: calc(10px * var(--space-scale));
  }
  .node-card {
    padding: calc(14px * var(--space-scale));
  }
  #cluster-form .modal-footer {
    gap: calc(8px * var(--space-scale));
    flex-wrap: wrap;
  }
}
/* One surface for references, prompt, and generation controls. */
.compose-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  background: var(--input);
  box-shadow: 0 4px 20px var(--shadow);
  transition: border-color .16s, box-shadow .16s;
}
.compose-card:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent);
}
.model-bar:has([data-model-control="effort"]:not([hidden])) {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, .7fr) minmax(0, 1.3fr) minmax(0, 1fr);
}
.model-bar > :not([hidden]) {
  min-width: 0;
}
.model-control > span, .size-control > span {
  color: var(--text-muted);
}
.model-control .picker-trigger, .size-control > button {
  color: var(--text);
}
.sidebar-toggle {
  flex-shrink: 0;
}
.topbar > .sidebar-toggle {
  display: none;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 22px;
}
.sidebar-header .brand {
  margin-bottom: 0;
  padding-left: 8px;
}
.side-icon {
  width: 24px;
  flex-shrink: 0;
  text-align: center;
  font-size: 1.1429rem;
  line-height: 1;
}
.side-label-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-bottom button:hover {
  background: var(--hover);
}
.sidebar .new-space:hover {
  background: var(--hover);
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
::selection {
  background: var(--selected);
  color: var(--text);
}
* {
  scrollbar-color: var(--scrollbar) transparent;
}
button, input, textarea, select {
  caret-color: var(--accent);
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}
@media (min-width: 701px) {
  body.sidebar-collapsed .topbar > .sidebar-toggle { display: inline-grid; }
  body.sidebar-collapsed .sidebar-header .sidebar-toggle { display: none; }
  body.sidebar-collapsed .sidebar {
    width: 72px;
    padding: 20px 10px 12px;
    align-items: stretch;
  }
  body.sidebar-collapsed .sidebar .brand {
    justify-content: center;
    padding: 0;
    font-size: 1.7857rem;
  }
  body.sidebar-collapsed .sidebar .brand > span,
  body.sidebar-collapsed .side-label,
  body.sidebar-collapsed #spaces,
  body.sidebar-collapsed .user-task-status,
  body.sidebar-collapsed .side-label-text,
  body.sidebar-collapsed .gallery-nav .grow,
  body.sidebar-collapsed .gallery-nav small,
  body.sidebar-collapsed .side-bottom button > .muted {
    display: none;
  }
  body.sidebar-collapsed .sidebar-header {
    flex-direction: column;
    gap: 14px;
  }
  body.sidebar-collapsed .sidebar-header .brand {
    margin: 0;
  }
  body.sidebar-collapsed .new-space,
  body.sidebar-collapsed .gallery-nav,
  body.sidebar-collapsed .side-bottom button {
    justify-content: center;
    gap: 0;
    padding: 10px 0;
    min-height: 42px;
  }
  body.sidebar-collapsed #gallery-nav {
    padding: 8px 0 0;
  }
  body.sidebar-collapsed .new-space > span {
    margin: 0;
  }
  body.sidebar-collapsed .side-bottom {
    margin-top: auto;
  }
  body.sidebar-collapsed .side-bottom button > .avatar {
    flex: 0 0 28px;
  }
}
@media (max-width: 1100px) {
  .gallery-toolbar {
    padding-left: 22px;
    padding-right: 22px;
  }
  .gallery-scroll {
    padding-left: 22px;
    padding-right: 22px;
  }
  .gallery-selection-bar {
    padding-left: 22px;
    padding-right: 22px;
  }
}
@media (max-width: 700px) {
  .topbar > div:not(.thread-actions) {
    flex: 1;
  }
  .topbar .eyebrow {
    font-size: .5714rem;
    letter-spacing: 1.5px;
  }
  .thread-actions {
    flex: 0 0 auto;
    gap: 0;
  }
  .sidebar-header {
    padding-right: 30px;
  }
  .sidebar-header .sidebar-toggle {
    display: none;
  }
  .compose-card #composer {
    padding: 12px 12px 9px;
  }
  .compose-card .reference-chips {
    padding: 10px 12px 0;
  }
  #prompt {
    min-height: 46px;
    max-height: 21dvh;
  }
  .model-bar:has([data-model-control="effort"]:not([hidden])) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .model-bar > :not([hidden]) {
    padding: 5px 9px;
    border: 0;
  }
  .model-bar > .size-control:last-child {
    background: var(--accent-soft);
    border-radius: var(--radius-control);
  }
  .model-bar:has([data-model-control="effort"][hidden]) > .size-control {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 7px 9px;
  }
  .model-bar:has([data-model-control="effort"][hidden]) > .size-control > button {
    width: auto;
    max-width: 75%;
    min-height: 24px;
    text-align: right;
  }
  /* With thinking controls visible, the image picker occupies the left column. */
  .model-bar:has([data-model-control="effort"]:not([hidden])) .model-control[data-model-control="image"] .model-popover {
    right: auto;
    left: 0;
  }
  .model-control[data-model-control="effort"] .model-popover {
    right: 0;
    left: auto;
  }
  .gallery-toolbar {
    padding-left: 14px;
    padding-right: 14px;
  }
  .gallery-scroll {
    padding-left: 14px;
    padding-right: 14px;
  }
  .gallery-selection-bar {
    padding-left: 14px;
    padding-right: 14px;
  }
  .gallery-summary small {
    white-space: normal;
  }
  .gallery-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: stretch;
  }
  .gallery-select-toggle {
    padding: 8px 9px;
    font-size: .7857rem;
  }
  .gallery-selection-count {
    flex: 1 1 auto;
  }
  .gallery-selection-bar > .text-button {
    margin-left: auto;
  }
  .modal-head {
    gap: 12px;
    margin-bottom: 18px;
  }
  dialog {
    max-width: calc(100vw - 20px);
    padding: 18px;
    max-height: calc(100dvh - 20px);
  }
}
@media (max-height: 700px) {
  .empty-art {
    width: 58px;
    height: 58px;
    margin-bottom: 12px;
    border-radius: 18px;
  }
  .empty-art::before {
    width: 54px;
    height: 54px;
    border-radius: 16px;
  }
  .empty-art span {
    font-size: 2.2857rem;
  }
  .empty h1 {
    font-size: 1.7143rem;
    margin: 8px 0;
  }
  .inspirations {
    margin-top: 16px;
  }
  .compose-note {
    display: none;
  }
  .user-task-status {
    max-height: 130px;
  }
}
@media (max-height: 520px) {
  .sidebar { overflow-y: auto; overscroll-behavior: contain; }
  .sidebar-header, #gallery-nav { flex-shrink: 0; }
  #spaces { flex: 1 0 auto; overflow: visible; }
  .topbar {
    min-height: 52px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .compose-wrap {
    padding-top: 6px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  .compose-card #composer {
    padding-top: 9px;
    padding-bottom: 7px;
  }
  #prompt {
    min-height: 30px;
    max-height: 16dvh;
  }
  .compose-actions {
    margin-top: 4px;
  }
  .model-bar {
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .empty {
    height: auto;
    min-height: 100%;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* Mobile keeps the original controls in a dialog so model capabilities stay in sync. */
@media (max-width: 700px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) {
  .generation-config-trigger { display: inline-flex; align-items: center; gap: 5px; }
  .generation-controls-slot { display: none; }
}
dialog.generation-config-modal {
  width: 490px;
}
.generation-config-modal .generation-config-controls .model-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: calc(20px * var(--space-scale));
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
}
.generation-config-modal .generation-config-controls .model-bar > :not([hidden]) {
  grid-column: auto;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
}
.generation-config-modal .model-control > span,
.generation-config-modal .size-control > span {
  display: block;
  font-size: .8571rem;
  margin-bottom: calc(7px * var(--space-scale));
}
.generation-config-modal .picker-trigger {
  min-height: 42px;
  padding: calc(10px * var(--space-scale)) calc(12px * var(--space-scale));
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--input);
}
.generation-config-modal .model-popover {
  position: fixed;
  bottom: auto;
  right: auto;
  z-index: 12;
  margin: 0;
  touch-action: pan-y;
}
.generation-config-modal .generation-config-controls .size-control > button {
  display: none;
}
.generation-config-modal .size-popover {
  position: static;
  width: auto;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  overflow: visible;
}
.generation-config-modal .segments {
  flex-wrap: wrap;
}
.generation-config-modal .segments button {
  flex: 1 0 auto;
  min-height: 38px;
}
.generation-config-modal .modal-footer .primary {
  min-width: 100px;
}
