:root {
  color-scheme: light;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #19302c;
  background: #f4f6f5;
  font-synthesis: none;
  --text: #19302c;
  --muted: #5d706a;
  --accent: #086b5b;
  --accent-hover: #07584c;
  --line: #dce6e1;
  --surface: #fff;
  --wash: #f2f7f5;
  --danger: #9e3534;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, a, input, textarea, select, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #0a806e; outline-offset: 3px; }
h1, h2, h3, p, dl, dd, figure { margin: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: start;
  display: flex;
  flex-direction: column;
  padding: 30px 17px;
  background: #fbfcfb;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar > .brand, .sidebar > .navigation { flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; width: fit-content; font-size: 17px; font-weight: 750; letter-spacing: -.02em; white-space: nowrap; }
.brand-icon { display: grid; grid-template-columns: repeat(2, 6px); grid-auto-rows: 6px; gap: 3px; align-content: center; justify-content: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); }
.brand-icon i { background: #eaf8f2; border-radius: 1.5px; }
.brand-icon i:nth-child(2) { opacity: .55; }
.navigation { display: flex; flex-direction: column; gap: 5px; margin-top: 42px; }
.nav-link { min-height: 43px; display: flex; align-items: center; gap: 11px; padding: 9px 12px; color: var(--muted); border-radius: 8px; font-weight: 600; white-space: nowrap; }
.nav-settings { border: 0; background: transparent; text-align: left; }
.settings-status { margin-left: auto; padding: 2px 5px; color: #76551e; background: #f7efdf; border-radius: 4px; font-size: 11px; }
.nav-link:hover { background: #edf3f0; color: var(--text); }
.nav-link[aria-current="page"] { background: #e1f1eb; color: #085e51; }
.recent-section { display: flex; flex-direction: column; flex: 1; min-height: 0; margin-top: 34px; }
.recent-section h2 { padding-inline: 12px; color: var(--muted); font-size: 12px; font-weight: 650; }
.recent-history { min-height: 0; margin-top: 8px; overflow-y: auto; overscroll-behavior-y: contain; }
.recent-row { display: grid; grid-template-columns: minmax(0, 1fr) 40px; align-items: center; gap: 3px; }
.recent-empty, .recent-link { min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 12px; color: var(--muted); border-radius: 7px; }
.recent-link:hover, .recent-link[aria-current="page"] { background: #edf3f0; color: var(--text); }
.recent-link span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-delete { min-height: 30px; padding: 3px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; }
.recent-delete:enabled:hover, .recent-delete:focus-visible { color: var(--danger); background: #f9e9e8; }
.recent-delete:disabled { opacity: .45; }
.dot { flex: 0 0 7px; width: 7px; height: 7px; border-radius: 50%; background: #96a59f; }
.dot[data-status="completed"] { background: #127962; }
.dot[data-status="planned"] { background: #96803b; }
.dot[data-status="running"], .dot[data-status="planning"] { background: #51829e; }
.dot[data-status="partial"] { background: #a67323; }
.dot[data-status="failed"], .dot[data-status="deleting"] { background: #b45751; }

.companion-roam-track { flex: 1 0 0; min-height: 0; pointer-events: none; }

.sidebar-footer { flex: 0 0 auto; display: grid; gap: 12px; margin-top: 24px; min-width: 0; }
.account-trigger { width: 100%; min-height: 48px; display: flex; align-items: center; gap: 9px; padding: 7px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); text-align: left; }
.account-trigger:hover { background: var(--wash); }
.account-avatar { flex: 0 0 32px; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #e1f1eb; color: var(--accent); font-size: 13px; font-weight: 700; }
.account-identity { display: grid; flex: 1; min-width: 0; font-size: 13px; font-weight: 650; line-height: 1.2; }
.account-identity > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-identity small { color: var(--muted); margin-top: 3px; font-size: 11px; font-weight: 500; }
.account-chevron { flex: 0 0 6px; width: 6px; height: 6px; margin-inline: 1px 4px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }

.companion-dock, .companion-mobile {
  --fish-hop-height: 22px;
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  touch-action: manipulation;
}
.companion-dock { justify-self: center; }
.companion-mobile { --companion-size: 36px; --fish-hop-height: 8px; }
.companion-mobile-slot { display: none; }

/* Bluebell's original standard atlas has 8 columns and 9 rows of 192×208 cells. */
.fish-figure {
  --sprite-row: 0;
  --sprite-frames: 6;
  --sprite-still-row: 0;
  display: block;
  z-index: 1;
  width: var(--companion-size, 112px);
  aspect-ratio: 192 / 208;
  background-image: url("/bluebell-spritesheet.png");
  background-repeat: no-repeat;
  background-size: 800% 900%;
  background-position: var(--sprite-still-x, 0) calc(var(--sprite-still-row) * 12.5%);
  animation: fish-frames var(--sprite-duration, 1s) steps(var(--sprite-frames), jump-none)
    var(--sprite-delay, 0s) var(--sprite-repeat, 1);
}
[data-pose="idle"][data-state="rest"] .fish-figure { animation: fish-idle 8s linear infinite, fish-breathe 3.4s ease-in-out infinite; }
[data-pose="waiting"] .fish-figure { --sprite-row: 6; --sprite-still-row: 6; --sprite-duration: 1.25s; --sprite-repeat: infinite; }
[data-pose="working"] .fish-figure { --sprite-row: 7; --sprite-still-row: 7; --sprite-duration: .9s; --sprite-repeat: infinite; }
[data-state="done"] .fish-figure { --sprite-frames: 5; --sprite-duration: .65s; animation-name: fish-jump; }
[data-state="failure"] .fish-figure { --sprite-frames: 8; --sprite-still-row: 5; --sprite-still-x: calc(300% / 7); animation-name: fish-failure; }
[data-state="done"]:not([data-celebrate]) .fish-figure { animation: none; }
[data-fish][data-direction] .fish-figure {
  --sprite-row: 1;
  --sprite-frames: 8;
  animation: fish-frames .72s steps(8, jump-none) infinite;
}
[data-fish][data-direction="left"] .fish-figure { --sprite-row: 2; }
[data-fish][data-fish-action="spin"] .fish-figure { animation: fish-spin 1.05s ease-in-out both; }
[data-fish][data-fish-action="cute"] .fish-figure {
  animation: fish-wave .8s steps(4, jump-none) both, fish-wave-bob .8s ease-in-out both;
}
[data-fish][data-fish-action="jump"] .fish-figure {
  animation: fish-jump .64s steps(5, jump-none) both, fish-hop .64s both;
}
@keyframes fish-idle {
  0%, 66% { background-position: 0 0; animation-timing-function: steps(6, jump-none); }
  84% { background-position: calc(500% / 7) 0; animation-timing-function: steps(1, jump-start); }
  85%, 100% { background-position: 0 0; }
}
@keyframes fish-breathe { 50% { transform: translateY(-2px); } }
@keyframes fish-wave {
  from { background-position: 0 37.5%; }
  to { background-position: calc(300% / 7) 37.5%; }
}
@keyframes fish-wave-bob {
  32% { transform: translateY(-2px) rotate(5deg); }
  68% { transform: translateY(-1px) rotate(-3deg); }
}
@keyframes fish-spin {
  0% { transform: rotate(0deg) scale(1); }
  14% { transform: rotate(-12deg) scale(.92); }
  80% { transform: rotate(354deg) scale(.82); }
  100% { transform: rotate(1turn) scale(1); }
}
@keyframes fish-hop {
  0%, 100% { transform: translateY(0); }
  15% { transform: translateY(2px) scale(1.03, .95); animation-timing-function: cubic-bezier(.18,.58,.45,1); }
  45% { transform: translateY(calc(-1 * var(--fish-hop-height))); animation-timing-function: cubic-bezier(.57,0,.88,.51); }
  78% { transform: translateY(1px) scale(1.04, .93); animation-timing-function: ease-out; }
  89% { transform: translateY(-2px); }
}
@keyframes fish-frames {
  from { background-position: 0 calc(var(--sprite-row) * 12.5%); }
  to { background-position: calc((var(--sprite-frames) - 1) * 100% / 7) calc(var(--sprite-row) * 12.5%); }
}
@keyframes fish-jump {
  from { background-position: 0 50%; }
  to { background-position: calc(400% / 7) 50%; }
}
@keyframes fish-failure {
  from { background-position: 0 62.5%; }
  to { background-position: 100% 62.5%; }
}
.workspace { min-width: 0; width: 100%; max-width: 1450px; padding: 35px clamp(22px, 3.8vw, 54px) 55px; margin-inline: auto; }
.page-heading { margin: 0 0 25px; }
.page-heading h1 { font-size: clamp(29px, 3.05vw, 41px); line-height: 1.24; letter-spacing: -.045em; font-weight: 760; overflow-wrap: anywhere; }
.page-heading p { color: var(--muted); margin-top: 7px; font-size: 14px; }
.studio-grid { display: grid; grid-template-columns: minmax(282px, .82fr) minmax(0, 1.18fr); gap: 21px; align-items: start; }
.panel { min-width: 0; padding: 23px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h2 { font-size: 18px; line-height: 1.35; font-weight: 700; letter-spacing: -.015em; }
.login-page { background: var(--surface); }
.login-layout {
  --login-gutter: clamp(34px, 5vw, 76px);
  --login-form-width: 456px;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100svh;
}
.login-brand {
  grid-area: 1 / 1;
  align-self: start;
  position: relative;
  z-index: 1;
  padding: 0;
  margin: clamp(24px, 4vw, 44px) 0 0 var(--login-gutter);
}
.login-intro {
  grid-area: 1 / 1 / span 2 / 2;
  display: grid;
  align-items: center;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 100px var(--login-gutter);
  border-right: 1px solid var(--line);
  background: linear-gradient(145deg, #e1f1eb, var(--wash) 67%, #fbfcfb);
}
.login-intro::before, .login-intro::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset-inline-end: -70px;
  inset-block-end: -152px;
  width: min(58%, 380px);
  aspect-ratio: 1;
  border: 1px solid #c9ded5;
  border-radius: 40px;
  transform: rotate(-16deg);
}
.login-intro::after {
  inset-inline-end: -33px;
  inset-block-end: -190px;
  border-color: var(--line);
  background: #ffffff55;
}
.login-intro-copy { max-width: 490px; }
.login-intro-title {
  font-size: clamp(34px, 4.45vw, 67px);
  line-height: 1.16;
  letter-spacing: -.06em;
  font-weight: 800;
}
.login-intro-description { margin-top: 22px; color: var(--muted); font-size: 16px; line-height: 1.75; }
.login-area {
  grid-area: 1 / 2 / span 2 / 3;
  display: grid;
  place-items: center;
  padding: 44px var(--login-gutter);
}
.login-panel { width: min(100%, var(--login-form-width)); }
.login-panel h1 { margin-bottom: 27px; font-size: clamp(29px, 3vw, 35px); line-height: 1.2; letter-spacing: -.04em; }
.login-form { display: grid; gap: 17px; }
.login-form .button { min-height: 48px; margin-top: 4px; }
.login-account-note { margin-top: 20px; color: var(--muted); font-size: 13px; text-align: center; }
@media (max-width: 760px) {
  .login-layout {
    --login-gutter: clamp(18px, 6vw, 28px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(24px, 1fr) auto auto minmax(24px, 1fr);
  }
  .login-brand {
    grid-area: 2 / 1;
    justify-self: center;
    width: min(calc(100% - 2 * var(--login-gutter)), var(--login-form-width));
    margin: 0 0 24px;
  }
  .login-brand .brand-icon { display: grid; }
  .login-intro { display: none; }
  .login-area { grid-area: 3 / 1; padding-block: 0; }
}
.input-panel { display: grid; gap: 19px; }
.input-panel h2 { margin-bottom: 1px; }
.form-field { min-width: 0; display: grid; gap: 8px; }
.form-field label, .form-field h3 { font-size: 14px; font-weight: 650; }
.field-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-count { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.required { color: var(--accent); }
.optional { margin-left: 4px; color: var(--muted); font-size: 12px; font-weight: 400; }
.dropzone {
  min-height: 136px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px;
  text-align: center;
  background: var(--wash);
  border: 1px dashed #8eafa3;
  border-radius: 10px;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.dropzone:hover, .dropzone.is-dragover { background: #e8f5ef; border-color: var(--accent); }
.dropzone:focus-within { outline: 2px solid #0a806e; outline-offset: 3px; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-mark { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 2px; color: var(--accent); background: #e3f0eb; border-radius: 9px; }
.dropzone strong { font-size: 13px; font-weight: 650; }
.dropzone strong span { color: var(--accent); }
.dropzone small { font-size: 12px; font-weight: 400; color: var(--muted); }
.reference-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.reference { position: relative; min-width: 0; }
.reference-preview { display: block; width: 100%; aspect-ratio: 1; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--wash); }
.reference-preview img { width: 100%; height: 100%; display: block; object-fit: cover; }
.reference-remove { position: absolute; top: 4px; right: 4px; width: 24px !important; height: 24px !important; font-size: 16px !important; color: #fff; background: #233e35; }
.reference-remove:hover { background: #0d271f; }
.form-field input[type="text"], .form-field input[type="password"], .form-field textarea, select { width: 100%; border: 1px solid #cbdad4; border-radius: 8px; background: var(--surface); }
.form-field input[type="text"], .form-field input[type="password"], select { min-height: 43px; padding: 9px 11px; }
.login-form input[type="text"], .login-form input[type="password"] { min-height: 48px; background: var(--wash); font-size: 16px; }
.form-field textarea { min-height: 91px; padding: 9px 11px; resize: vertical; }
.form-field input::placeholder, .form-field textarea::placeholder { color: #657770; }
.field-error { color: var(--danger); font-size: 13px; overflow-wrap: anywhere; }
.output-settings { padding-top: 15px; border-top: 1px solid var(--line); }
.output-settings h2 { margin-bottom: 12px; }
.extra-fields-list { display: grid; gap: 12px; }
.extra-value-control { display: grid; gap: 6px; }
.extra-value-control:has(select) { grid-template-columns: minmax(0, 1fr) 102px; }
.extra-value-control select { min-width: 0; padding-inline: 8px 4px; }
.extra-fields-list label { overflow-wrap: anywhere; }
.mode-options { min-width: 0; margin: 0 0 15px; padding: 0; border: 0; }
.mode-options legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 650; }
.mode-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mode-choice { display: flex; align-items: flex-start; gap: 7px; min-width: 0; padding: 10px; border-radius: 8px; background: #f5f8f6; cursor: pointer; }
.mode-choice:hover, .mode-choice:has(input:checked) { background: #eaf5ef; }
.mode-choice input { flex: 0 0 auto; width: 14px; height: 14px; margin: 3px 0 0; accent-color: var(--accent); }
.mode-choice span { min-width: 0; }
.mode-choice strong, .mode-choice small { display: block; overflow-wrap: anywhere; }
.mode-choice strong { font-size: 13px; }
.mode-choice small { margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.output-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
.output-wide { grid-column: 1 / -1; }
.output-controls .form-field { gap: 5px; }
.output-controls label { font-size: 13px; }
.output-controls select { padding-right: 6px; }
.output-note { padding: 8px 10px; border-radius: 6px; background: var(--wash); color: var(--muted); font-size: 12px; }
.catalog-error { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
.catalog-error .button { min-height: 34px; padding: 4px 9px; font-size: 12px; }

.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 13px; margin-bottom: 19px; }
.panel-heading p { color: var(--muted); margin-top: 5px; font-size: 13px; overflow-wrap: anywhere; }
.panel-meta { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 5px; }
.format-chip, .status-chip { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; min-height: 25px; padding: 3px 9px; border-radius: 6px; background: #edf3f0; color: #405f55; font-size: 12px; line-height: 1.35; white-space: nowrap; font-weight: 650; }
.status-chip[data-status="completed"] { color: #086454; background: #e5f5ed; }
.status-chip[data-status="planned"] { color: #76551e; background: #f7efdf; }
.status-chip[data-status="running"], .status-chip[data-status="planning"] { color: #34607a; background: #e7f2f7; }
.status-chip[data-status="partial"] { color: #845d22; background: #fbf1de; }
.status-chip[data-status="failed"], .status-chip[data-status="deleting"] { color: var(--danger); background: #f9e9e8; }
.slot-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 11px; align-items: start; }
.slot { position: relative; min-width: 0; }
@media (min-width: 951px) {
  #plan-grid .slot { width: min(100%, calc(144px * var(--output-aspect, 1))); justify-self: center; }
}
.slot-media {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
  aspect-ratio: var(--output-aspect, 1);
  overflow: hidden;
  padding: 0;
  border: 1px solid #e7eeeb;
  border-radius: 10px;
  background: #eff4f2;
  color: #537a6c;
}
.slot:nth-child(1) .slot-media { background: #f6f8f7; }
.slot:nth-child(3n) .slot-media { background: #edf3ef; }
.slot:nth-child(n+6):nth-child(-n+8) .slot-media { color: #577a6f; background: #eaf2ef; }
.slot[data-state="failed"] .slot-media { background: #fbf1f0; color: var(--danger); border-color: #f4e2e1; }
button.slot-media:hover { border-color: var(--accent); }
.slot-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.slot-preview-icon {
  width: clamp(23px, 3vw, 36px);
  height: clamp(20px, 2.45vw, 29px);
  position: relative;
  border: 1.5px solid currentColor;
  border-radius: 5px;
  overflow: hidden;
}
.slot-preview-icon::before { content: ""; display: block; position: absolute; width: 24%; aspect-ratio: 1; border: 1.5px solid currentColor; border-radius: 50%; left: 15%; top: 17%; }
.slot-preview-icon::after { content: ""; position: absolute; width: 65%; aspect-ratio: 1; transform: rotate(45deg); border-top: 1.5px solid currentColor; border-left: 1.5px solid currentColor; border-radius: 3px; top: 57%; left: 39%; }
.slot-media:has(.slot-spinner) { border-color: #d3e4dd; background: #edf5f1; }
.slot-spinner {
  width: clamp(25px, 3.1vw, 42px);
  aspect-ratio: 1;
  border: 3px solid #c7dfd6;
  border-block-start-color: var(--accent);
  border-inline-end-color: var(--accent);
  border-radius: 50%;
  animation: slot-wait-spin .85s linear infinite;
}
@keyframes slot-wait-spin { to { transform: rotate(1turn); } }
.slot-title { display: block; margin-top: 6px; font-weight: 650; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.slot-caption { display: grid; gap: 4px; }
.slot-state { font-size: 12px; color: var(--muted); }
.slot-state[data-status="failed"] { color: var(--danger); }
.slot-note { overflow-wrap: anywhere; }
.slot-prompt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.slot-copy { display: grid; gap: 2px; margin-block: 3px; padding-inline-start: 7px; border-inline-start: 2px solid #94b6aa; }
.slot-copy-label { color: var(--muted); font-size: 11px; }
.slot-copy-value { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 12px; }
.slot-copy-caption { color: var(--muted); }
.slot-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; }
.slot-action { min-height: 30px; max-width: 100%; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 12px; font-weight: 650; text-align: left; overflow-wrap: anywhere; }
.slot-action:enabled:hover { text-decoration: underline; }
.slot-action:disabled { color: var(--muted); }
.slot-regenerate {
  position: absolute;
  z-index: 1;
  inset: 6px 6px auto auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  background: #fffffff2;
  font-size: 20px;
  line-height: 1;
}
.slot-regenerate:enabled:hover { background: var(--wash); }
.slot-regenerate:disabled { color: var(--muted); }
.panel-actions { display: grid; gap: 10px; margin-top: 21px; }
.new-actions { margin: 0 0 20px; }
.submit-config { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 13px; }
.submit-config .slot-action { flex-shrink: 0; padding-inline: 4px; }
.planned-actions, .task-retry, .task-action-error { margin-bottom: 14px; }
.action-row { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.button { display: inline-flex; gap: 8px; align-items: center; justify-content: center; min-height: 42px; padding: 7px 15px; font-size: 14px; text-align: center; white-space: nowrap; font-weight: 700; border-radius: 8px; border: 1px solid transparent; transition: background .16s ease; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { background: var(--accent-hover); }
.button-primary:disabled { background: #3c8376; }
.button[aria-busy="true"] { cursor: wait; }
.button-secondary { color: var(--accent); border-color: #c5d9d1; background: #fff; }
.button-secondary:hover { background: #edf6f2; }
.slot-retry { min-height: 34px; padding: 4px 10px; font-size: 12px; }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:enabled:hover { background: #832c2b; }
.button-danger:disabled { opacity: .65; }
.generate { width: 100%; min-height: 47px; font-size: 15px; }
.generate:disabled:not([aria-busy="true"]) { color: #536961; background: #e4ebe8; transition: none; }
.sparkle { font-size: 19px; line-height: 1; }
.notice { padding: 10px 12px; margin-bottom: 13px; border-radius: 8px; background: #fbf1e8; color: #75491e; font-size: 13px; overflow-wrap: anywhere; }

.history-panel { padding: 9px 22px; }
.history-message { padding: 42px 14px; text-align: center; color: var(--muted); }
.history-message .button { margin-top: 13px; }
.history-row { min-height: 70px; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 7px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.history-row:hover { background: var(--wash); border-radius: 7px; }
.history-thumb { display: grid; place-items: center; overflow: hidden; width: 44px; height: 44px; border-radius: 7px; background: var(--wash); color: #537a6c; }
.history-thumb img { width: 100%; height: 100%; object-fit: contain; }
.history-thumb .slot-preview-icon { width: 22px; height: 19px; }
.history-name { display: block; font-weight: 680; overflow-wrap: anywhere; }
.history-meta { display: block; color: var(--muted); font-size: 12px; }
.back-link { display: inline-block; margin-bottom: 7px; color: var(--accent); font-size: 13px; }
.back-link:hover { text-decoration: underline; }
.notice-panel { display: grid; justify-items: start; gap: 11px; color: var(--muted); }
.saved-description { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.saved-extra { display: grid; gap: 7px; }
.saved-extra div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 10px; }
.saved-extra dt { font-weight: 650; overflow-wrap: anywhere; }
.saved-extra dd { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.task-settings { display: grid; gap: 8px; padding-top: 13px; border-top: 1px solid var(--line); }
.task-settings div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.task-settings dt { color: var(--muted); }
.task-settings dd { font-weight: 650; text-align: right; overflow-wrap: anywhere; }

.lightbox { width: fit-content; max-width: min(94vw, 840px); max-height: 92vh; padding: 12px; border: 0; border-radius: 13px; color: var(--text); background: #fff; }
.lightbox::backdrop { background: #102821bd; }
.lightbox-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 3px 3px 8px 7px; }
.lightbox-header h2 { font-size: 15px; min-width: 0; overflow-wrap: anywhere; }
.lightbox-actions { display: flex; align-items: center; gap: 9px; }
.lightbox-download { min-height: 36px; padding: 6px 10px; white-space: nowrap; }
#lightbox-media { overflow: hidden; border-radius: 6px; }
.lightbox img { max-width: 100%; max-height: 76vh; display: block; object-fit: contain; border-radius: 6px; margin-inline: auto; }
.icon-button { display: grid; place-items: center; flex: 0 0 auto; width: 35px; height: 35px; padding: 0; border: 0; border-radius: 7px; font-size: 24px; line-height: 1; }
.close-lightbox { background: var(--wash); }
.close-lightbox:hover { background: #e5efea; }
.settings-dialog { width: min(92vw, 460px); max-height: 92vh; padding: 22px; border: 0; border-radius: 14px; color: var(--text); background: #fff; }
.settings-dialog::backdrop { background: #10282185; }
#result-title { scroll-margin-block-start: 20px; }
.delete-task-dialog .delete-task-name { margin-top: 10px; font-weight: 700; overflow-wrap: anywhere; }
.delete-task-dialog .action-row { margin-top: 16px; }
.delete-task-error { flex-basis: 100%; }
.settings-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 21px; }
.settings-header h2 { font-size: 22px; }
.settings-header p, .settings-note { margin-top: 4px; color: var(--muted); font-size: 13px; }
.api-settings-section { margin-bottom: 16px; border: 1px solid var(--line); border-radius: 9px; }
.api-settings-section > summary { padding: 10px 12px; min-height: 42px; font-weight: 650; cursor: pointer; }
.api-settings-section > .settings-note { margin: 0 12px 14px; }
.api-settings-section > .settings-form { padding: 0 12px 12px; }
.provider-readiness { display: grid; gap: 10px; margin-bottom: 16px; }
.provider-readiness div { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.provider-readiness dt { font-weight: 650; }
.provider-key-fields { display: grid; gap: 12px; }
.reference-unavailable { display: grid; place-items: center; color: #537a6c; }
.settings-form { display: grid; gap: 16px; }
.settings-form .button { justify-self: end; }
.settings-success { color: var(--accent); font-size: 13px; }
.account-actions { display: grid; gap: 8px; }
.account-actions .button { justify-content: flex-start; }
.account-feedback { margin-top: 10px; }
#account-summary, #member-update-note { overflow-wrap: anywhere; }
.account-compact-settings { display: none; }
.member-manager-dialog { width: min(94vw, 610px); }
.member-list { display: grid; gap: 0; padding: 0; margin: 8px 0 12px; list-style: none; }
.member-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 7px 14px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member-identity { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; }
.member-identity strong { overflow-wrap: anywhere; }
.member-row-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.member-row-actions .slot-action { font-size: 13px; }
.member-create { margin-top: 19px; }
.member-create-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.extra-config-dialog { width: min(94vw, 760px); }
.generation-settings-form { display: grid; gap: 7px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.generation-settings-controls { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; }
.generation-settings-controls .form-field { flex: 0 1 138px; }
.generation-settings-controls .button { min-height: 43px; }
.task-defaults-form, .storage-settings { display: grid; gap: 10px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.task-defaults-form h3, .storage-settings h3 { font-size: 16px; }
.storage-settings .provider-readiness { margin: 0; }
.task-defaults-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.extra-config-heading { margin-bottom: 12px; }
.extra-config-heading h3 { font-size: 16px; }
.extra-config-list { display: grid; gap: 13px; }
.extra-config-list:empty { display: none; }
.extra-config-row { display: grid; grid-template-columns: minmax(104px, .8fr) minmax(0, 1.4fr) auto; gap: 12px; align-items: start; padding: 12px; border-radius: 9px; background: var(--wash); }
.extra-config-values { display: grid; gap: 9px; }
.extra-config-values textarea { min-height: 74px; }
.extra-config-values .settings-note { margin: 0; font-size: 12px; }
.extra-config-remove { border: 0; padding: 8px 2px; color: var(--danger); background: transparent; font-weight: 650; font-size: 13px; }
.extra-config-remove:enabled:hover { text-decoration: underline; }
.extra-config-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.extra-config-actions #extra-config-save { margin-left: auto; }
.prompt-dialog { width: min(92vw, 620px); }
.prompt-dialog #prompt-input { min-height: 150px; max-height: 46vh; }
.prompt-copy { display: grid; gap: 10px; min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.prompt-copy legend { padding-inline: 5px; color: var(--text); font-weight: 700; }
.prompt-copy legend span { color: var(--muted); font-size: 12px; font-weight: 400; overflow-wrap: anywhere; }
.prompt-copy textarea { min-height: 65px; max-height: 22vh; }
.prompt-copy #prompt-overlay-title { min-height: 43px; }
.workspace { position: relative; }
.page-heading { padding-inline-end: 89px; }
.task-heading { padding-inline-end: 0; }
.task-heading-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.task-heading .back-link { display: inline-flex; align-items: center; min-height: 36px; }
.task-heading .reproduce-error { color: var(--danger); }
.workspace-tools { position: absolute; inset-block-start: 36px; inset-inline-end: clamp(22px, 3.8vw, 54px); display: flex; gap: 8px; }
.workspace-tools .button { min-height: 36px; padding: 5px 10px; }
.task-heading-actions .workspace-tools { position: static; flex-wrap: wrap; justify-content: flex-end; margin-inline-start: auto; gap: 10px; }
.task-heading-actions .workspace-tools .button { flex: 0 0 auto; }
.debug-open { color: var(--text); }
.debug-terminal { color: var(--accent); font-family: ui-monospace, monospace; font-weight: 700; }
.debug-dialog { width: min(94vw, 810px); }
.debug-header { margin-bottom: 12px; }
.debug-header p { overflow-wrap: anywhere; }
.debug-toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.debug-log { max-height: min(63vh, 640px); min-height: min(210px, 44vh); overflow: auto; overscroll-behavior: contain; background: var(--wash); border: 1px solid var(--line); border-radius: 9px; }
.debug-empty { color: var(--muted); padding: 18px; }
.debug-event + .debug-event { border-top: 1px solid var(--line); }
.debug-event summary { display: flex; gap: 9px; align-items: baseline; padding: 11px 12px; cursor: pointer; list-style: none; overflow-wrap: anywhere; }
.debug-event summary::-webkit-details-marker { display: none; }
.debug-event summary::after { content: ""; flex: 0 0 6px; width: 6px; height: 6px; margin: 0 3px 2px auto; border: solid var(--muted); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.debug-event[open] summary::after { transform: rotate(225deg); }
.debug-event time { flex: 0 0 auto; color: var(--muted); font: 12px ui-monospace, monospace; }
.debug-event-kind, .debug-event-slot { flex: 0 0 auto; border-radius: 4px; padding: 2px 5px; background: #e4eeea; color: #36584c; font-size: 11px; font-weight: 650; }
.debug-event[data-tone="error"] .debug-event-kind { color: var(--danger); background: #f9e9e8; }
.debug-event-title { min-width: 0; font-size: 13px; font-weight: 650; }
.debug-event-details { max-width: calc(100% - 24px); margin: 0 12px 12px; padding: 12px; color: #d7ede3; background: #152a24; border-radius: 6px; font: 12px/1.55 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.icon { display: inline-block; position: relative; flex: 0 0 auto; width: 16px; height: 16px; }
.icon-plus::before, .icon-plus::after { content: ""; position: absolute; border-radius: 2px; background: currentColor; }
.icon-plus::before { width: 12px; height: 1.6px; left: 2px; top: 7px; }
.icon-plus::after { width: 1.6px; height: 12px; left: 7px; top: 2px; }
.icon-clock { border: 1.5px solid currentColor; border-radius: 50%; }
.icon-clock::after { content: ""; position: absolute; width: 4px; height: 5px; top: 2px; left: 6px; border: solid currentColor; border-width: 0 0 1.5px 1.5px; }
.icon-sliders { display: grid; align-content: center; gap: 3px; }
.icon-sliders i { position: relative; width: 14px; height: 1px; border-radius: 2px; background: currentColor; }
.icon-sliders i::before { content: ""; position: absolute; top: -1px; left: 3px; width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.icon-sliders i:nth-child(2)::before { left: 9px; }
.icon-logout::before { content: ""; position: absolute; inset: 2px 7px 2px 1px; border: 1.5px solid currentColor; border-right: 0; border-radius: 2px 0 0 2px; }
.icon-logout::after { content: "→"; position: absolute; left: 4px; top: -3px; font-size: 16px; }
.icon-upload, .icon-download { border: solid currentColor; border-width: 0 1.5px 1.5px; border-radius: 0 0 3px 3px; height: 9px; margin-top: 6px; }
.icon-upload::before, .icon-download::before { content: ""; position: absolute; width: 1.5px; height: 10px; background: currentColor; top: -7px; left: calc(50% - .75px); }
.icon-upload::after, .icon-download::after { content: ""; position: absolute; width: 5px; height: 5px; border: solid currentColor; border-width: 1.5px 0 0 1.5px; transform: rotate(45deg); top: -7px; left: calc(50% - 3px); }
.icon-download::after { top: -3px; transform: rotate(225deg); }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 184px minmax(0, 1fr); }
  .workspace { padding-inline: 26px; }
  .panel { padding: 18px; }
  .studio-grid { gap: 15px; }
  .slot-grid { gap: 13px 7px; }
  .history-panel { padding: 7px 16px; }
  .workspace-tools { inset-inline-end: 26px; }
}

@media (max-width: 950px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .navigation { flex-direction: row; margin: 0; }
  .recent-section { display: none; }
  .navigation .nav-settings { display: none; }
  .sidebar-footer { display: block; margin-top: 0; }
  .companion-dock { display: none; }
  .companion-mobile-slot { display: block; margin-top: 11px; }
  .account-compact-settings { display: inline-flex; }
}

@media (min-width: 951px) and (max-height: 700px) {
  .companion-dock { --companion-size: 82px; }
}

@media (max-width: 730px) {
  .studio-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace { padding: 22px 16px 40px; }
  body:has(#new-view:not([hidden])) .workspace { padding-bottom: 106px; }
  body:has(#new-view:not([hidden]) :is(#submit-error, #submit-config-required):not([hidden])) .workspace { padding-bottom: 160px; }
  .new-actions { position: fixed; z-index: 1; bottom: 0; inset-inline: 0; margin: 0; padding: 10px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); background: #fbfcfb; border-top: 1px solid var(--line); }
  .sidebar { padding-inline: 13px; gap: 6px; }
  .nav-link { min-height: 39px; padding: 7px 9px; gap: 6px; font-size: 13px; }
  .account-trigger { min-height: 40px; width: 40px; justify-content: center; padding: 4px; }
  .account-avatar { flex-basis: 28px; width: 28px; height: 28px; }
  .account-trigger .account-identity, .account-trigger .account-chevron { display: none; }
  .page-heading { margin-bottom: 18px; }
  .panel { padding: 17px; }
  .history-panel { padding: 7px 10px; }
  .form-field input[type="text"], .form-field input[type="password"], .form-field textarea, select { font-size: 16px; }
  .slot-grid { gap: 14px 9px; }
  .workspace-tools { inset-block-start: 21px; inset-inline-end: 16px; gap: 6px; }
  .debug-dialog { padding: 16px; }
}

@media (max-width: 450px) {
  .nav-link:not(.nav-settings) .icon { display: none; }
  .workspace-tools #download-task { width: 36px; padding-inline: 0; }
  #download-label { display: none; }
  .extra-config-dialog { padding: 17px; }
  .member-create-fields { grid-template-columns: minmax(0, 1fr); }
  .task-defaults-controls .default-model-field { grid-column: 1 / -1; }
  .extra-config-row { grid-template-columns: minmax(0, 1fr) auto; }
  .extra-config-values { grid-column: 1 / -1; grid-row: 2; }
  .extra-config-remove { grid-column: 2; grid-row: 1; align-self: end; }
  .debug-event summary { column-gap: 6px; padding-inline: 9px; flex-wrap: wrap; }
}

@media (max-width: 365px) {
  .sidebar { padding-inline: 10px; gap: 5px; flex-wrap: wrap; }
  .brand { gap: 6px; font-size: 15px; padding-inline: 0; }
  .brand-icon { width: 27px; height: 27px; }
  .nav-link { padding-inline: 7px; font-size: 13px; }
  .mode-choice { gap: 5px; padding: 7px; }
}

@media (max-width: 325px) {
  .brand-icon { display: none; }
  .output-controls { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  :not(.fish-figure), *::before, *::after { animation: none !important; transition: none !important; }
}
