:root {
  color-scheme: light;
  --ink: #292932;
  --muted: #696975;
  --paper: #f5f6f8;
  --panel: #ffffff;
  --line: #dfe1e7;
  --soft-line: #ebecef;
  --accent: #b63860;
  --accent-dark: #93294d;
  --accent-soft: #fbeef3;
  --accent-line: #dfafbf;
  --surface-soft: #f7f8fa;
  --success: #2d745b;
  --danger: #b23e4b;
  --mint: #d9ece4;
  --gold: #f7e9bb;
  --blue: #dce8f5;
  --focus-ring: rgba(182, 56, 96, 0.16);
  --shadow: 0 8px 24px rgba(36, 38, 48, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 21, 18, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(23, 21, 18, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  border: 3px solid var(--line);
  background: var(--panel);
  box-shadow: 8px 8px 0 var(--line);
  padding: 28px;
}

.login-panel h1 {
  font-size: 42px;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 1680px;
  margin: 0 auto;
  padding: 22px;
}

.compact-shell {
  max-width: 1500px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  border: 3px solid var(--line);
  background: var(--panel);
  box-shadow: 8px 8px 0 var(--line);
  padding: 20px 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 17px;
}

.topbar-actions,
.section-heading,
.prompt-header,
.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cloud-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 2px solid var(--line);
  background: var(--mint);
  padding: 5px 9px;
  color: #164e3d;
  font-size: 12px;
  font-weight: 900;
}

.topbar-actions,
.section-heading {
  justify-content: space-between;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.15fr) minmax(360px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(230px, 0.62fr) minmax(430px, 1fr) minmax(420px, 1.08fr);
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  border: 3px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.library-panel {
  border-top-color: var(--mint);
}

.creator-panel {
  border-top-color: var(--accent);
}

.results-panel {
  border-top-color: var(--gold);
  container-type: inline-size;
}

.count-pill,
.status-dot {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 13px;
  font-weight: 800;
}

.status-dot {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rights-box {
  margin: 16px 0;
  border: 2px solid var(--line);
  background: #fff5d7;
  padding: 12px;
}

.api-strip {
  display: grid;
  grid-template-columns: minmax(150px, 0.65fr) 1fr;
  gap: 10px;
  align-items: end;
  margin: 16px 0;
  border: 2px solid var(--line);
  background: #edf8f4;
  padding: 12px;
}

.api-status {
  min-height: 42px;
  border: 2px solid var(--line);
  background: #fff;
  padding: 10px 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.api-status.ok {
  color: #14664f;
}

.api-status.warn {
  color: var(--accent-dark);
}

.tool-switch {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
  border: 2px solid var(--line);
  background: #fff;
  padding: 8px;
}

.tool-tab {
  border: 2px solid var(--line);
  background: #f8efe3;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.tool-tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
}

.tool-state-chip {
  border: 2px solid var(--line);
  background: var(--mint);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.workflow-status {
  margin: 0 0 14px;
  border: 2px solid var(--line);
  background: #fffdf5;
  padding: 9px 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.45;
}

.checkbox-row {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 13px;
  line-height: 1.45;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.stacked-form,
.creative-form {
  display: grid;
  gap: 12px;
}

.upload-card {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.upload-status {
  margin: -4px 0 0;
  border: 2px solid var(--soft-line);
  background: #fffdf5;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.hidden-fields {
  display: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.field-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr;
  gap: 10px;
}

.field-grid.two-col {
  grid-template-columns: 1fr 1fr;
}

.quick-row {
  display: grid;
  grid-template-columns: 0.7fr 1fr;
  gap: 10px;
}

.consistency-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  border: 2px solid var(--line);
  background: #fff;
  padding: 8px;
}

.consistency-control legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.consistency-control label {
  position: relative;
  display: block;
  cursor: pointer;
}

.consistency-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.consistency-control span {
  display: grid;
  gap: 2px;
  min-height: 52px;
  border: 2px solid var(--soft-line);
  background: #f7f3ec;
  padding: 8px 9px;
}

.consistency-control small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.consistency-control input:checked + span {
  border-color: var(--line);
  background: var(--mint);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.big-copy textarea {
  min-height: 130px;
  font-size: 20px;
  line-height: 1.45;
  font-weight: 800;
}

#promptAdvice {
  min-height: 86px;
  background: #fffdf5;
}

.external-reference-card {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.tool-panel {
  border: 2px solid var(--line);
  background: #f8fbfc;
  padding: 12px;
}

.tool-panel[hidden] {
  display: none;
}

.reference-tool-panel {
  display: grid;
  gap: 12px;
  border-top: 5px solid var(--blue);
}

.reference-mini-notice {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--line);
  background: #eef6fb;
  padding: 10px;
  color: #244f6c;
  font-size: 13px;
  font-weight: 900;
}

.reference-mini-notice[hidden] {
  display: none;
}

.reference-mini-notice div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.reference-mini-notice span {
  overflow: hidden;
  color: #41667b;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.reference-head h3 {
  font-size: 18px;
}

.reference-file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 38px;
  border: 2px solid var(--line);
  background: var(--gold);
  color: var(--ink);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--line);
}

.reference-file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.reference-hint {
  margin: 0;
  border: 2px solid var(--line);
  background: #eef6fb;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.reference-mode-row {
  display: grid;
}

.external-reference-preview {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--line);
  background: #edf8f4;
  padding: 9px;
}

.external-reference-preview[hidden] {
  display: none;
}

.external-reference-preview img {
  width: 72px;
  height: 72px;
  border: 2px solid var(--line);
  background: #fff;
  object-fit: cover;
}

.external-reference-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: #14664f;
  font-size: 13px;
  font-weight: 900;
}

.external-reference-copy span {
  overflow: hidden;
  color: #2c6657;
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.external-reference-preview .ghost-button {
  grid-column: auto;
}

.reference-analysis {
  display: grid;
  gap: 8px;
  border: 2px solid var(--line);
  background: #191713;
  color: #fff8ef;
}

.reference-analysis[hidden] {
  display: none;
}

.analysis-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 2px solid #3b362f;
  padding: 10px;
  color: #fff8ef;
  font-size: 13px;
  font-weight: 900;
}

.analysis-head .ghost-button {
  min-height: 32px;
  box-shadow: none;
}

#referenceAnalysisSummary {
  max-height: 150px;
  padding: 12px;
}

.adjustment-notice {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--line);
  background: #edf8f4;
  padding: 9px;
  color: #14664f;
  font-size: 13px;
  font-weight: 900;
}

.adjustment-image-tool {
  display: grid;
  grid-column: 1 / -1;
  gap: 9px;
  border-top: 2px solid #b9d9cd;
  padding-top: 9px;
}

.adjustment-image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.adjustment-image-head > div,
.adjustment-image-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.adjustment-image-head span,
.adjustment-image-copy span {
  color: #2c6657;
  font-size: 12px;
  line-height: 1.35;
}

.adjustment-file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 36px;
  border: 2px solid var(--line);
  background: #fff;
  padding: 7px 11px;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--line);
}

.adjustment-file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.adjustment-image-preview {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 9px;
  border: 2px solid #14664f;
  background: #fff;
  padding: 8px;
}

.adjustment-image-preview[hidden],
.adjustment-image-preview pre[hidden] {
  display: none;
}

.adjustment-image-preview > img {
  width: 64px;
  height: 64px;
  border: 2px solid var(--line);
  object-fit: cover;
}

.adjustment-image-actions {
  display: flex;
  gap: 7px;
}

.adjustment-image-actions .ghost-button {
  min-height: 34px;
  padding: 6px 9px;
  box-shadow: 2px 2px 0 var(--line);
  font-size: 11px;
}

#adjustmentImageAnalysis {
  grid-column: 1 / -1;
  max-height: 126px;
  margin: 0;
  overflow: auto;
  border: 2px solid var(--line);
  background: #191713;
  padding: 10px;
  color: #fff8ef;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.adjustment-notice[hidden] {
  display: none;
}

.adjustment-notice img {
  width: 54px;
  height: 54px;
  border: 2px solid var(--line);
  background: #fff;
  object-fit: cover;
}

.adjustment-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.adjustment-copy span {
  color: #2c6657;
  font-size: 12px;
  line-height: 1.35;
}

.advanced-panel {
  border: 2px solid var(--line);
  background: #fff;
  padding: 10px;
}

.advanced-panel summary {
  cursor: pointer;
  color: var(--accent-dark);
  font-weight: 900;
}

.advanced-panel[open] {
  display: grid;
  gap: 12px;
}

.primary-button,
.ghost-button {
  border: 2px solid var(--line);
  min-height: 40px;
  padding: 9px 13px;
  color: var(--ink);
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--line);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.ghost-button {
  background: #fff;
}

.primary-button:hover,
.ghost-button:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--line);
}

.full-width {
  width: 100%;
}

.character-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.compact-list {
  gap: 10px;
}

.character-card {
  border: 2px solid var(--line);
  background: #fff;
  padding: 12px;
}

.character-card.active {
  outline: 4px solid rgba(145, 201, 182, 0.55);
}

.character-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.character-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-danger-button {
  width: 32px;
  height: 32px;
  border: 2px solid var(--line);
  background: #fff0ec;
  color: var(--accent-dark);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.character-card h3 {
  font-size: 18px;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.thumb-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 2px solid var(--line);
  background: #fff;
}

.thumb-grid img.loading-thumb {
  background: repeating-linear-gradient(45deg, #fff, #fff 6px, #edf8f4 6px, #edf8f4 12px);
}

.character-notes {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.compact-list .character-notes {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.prompt-card {
  margin-top: 16px;
  border: 2px solid var(--line);
  background: #191713;
  color: #fff8ef;
}

.prompt-header {
  justify-content: space-between;
  border-bottom: 2px solid #3b362f;
  padding: 12px;
}

.prompt-header .ghost-button {
  min-height: 32px;
  box-shadow: none;
}

pre {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.55;
  padding: 14px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.results-empty {
  grid-column: 1 / -1;
  margin: 0;
  border: 2px dashed var(--soft-line);
  background: #fffdf8;
  padding: 22px 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.55;
  text-align: center;
}

.load-more-results {
  width: 100%;
  min-height: 42px;
  margin-top: 12px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  box-shadow: 3px 3px 0 var(--line);
}

.load-more-results:hover {
  background: var(--gold);
}

.load-more-results[hidden] {
  display: none;
}

.task-center {
  margin: 16px 0 12px;
  border: 2px solid var(--line);
  background: #f5f8f7;
  padding: 11px;
}

.task-center-head,
.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.performance-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 12px;
  border: 2px solid var(--line);
  background: #191713;
  color: #fff;
}

.performance-strip div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px;
  text-align: center;
}

.performance-strip div + div {
  border-left: 1px solid #4b453e;
}

.performance-strip span {
  color: #bbb3a7;
  font-size: 9px;
  font-weight: 900;
}

.performance-strip strong {
  overflow: hidden;
  color: #fff8ef;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 8px;
}

.result-filters button {
  min-height: 32px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.result-filters button.active {
  background: var(--gold);
  color: var(--ink);
}

.task-center-head {
  padding-bottom: 9px;
  border-bottom: 2px solid var(--soft-line);
}

.task-center-head h3 {
  font-size: 16px;
}

.task-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.task-count.active {
  color: #14664f;
}

.job-list {
  display: grid;
  gap: 7px;
  padding-top: 9px;
}

.job-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.job-item {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.job-indicator {
  width: 8px;
  height: 8px;
  border: 1px solid var(--line);
  background: #bbb;
}

.job-indicator.is-active {
  background: var(--accent);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.job-item.succeeded .job-indicator {
  background: var(--mint);
}

.job-item.failed .job-indicator {
  background: var(--accent);
}

.job-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.job-copy strong,
.job-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-copy strong {
  font-size: 12px;
}

.job-copy span,
.job-item time {
  color: var(--muted);
  font-size: 11px;
}

.job-copy small {
  color: #14664f;
  font-size: 10px;
  font-weight: 900;
}

.job-side {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.job-side button {
  min-height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 4px 8px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 900;
}

.result-toolbar {
  padding: 0 2px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.text-danger-button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  padding: 3px 0;
}

@keyframes pulse-dot {
  50% { opacity: 0.35; transform: scale(0.7); }
}

.result-card {
  overflow: hidden;
  border: 2px solid var(--line);
  background: #fff;
  transition: transform 140ms ease, box-shadow 140ms ease, outline-color 140ms ease;
}

.result-card.selected-adjustment {
  outline: 4px solid var(--mint);
  box-shadow: 6px 6px 0 var(--line);
}

.result-card.selected-adjustment::before {
  content: "当前调整参考";
  display: block;
  border-bottom: 2px solid var(--line);
  background: var(--mint);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
}

.result-preview-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 5;
  border: 0;
  border-bottom: 2px solid var(--line);
  background: #fff;
  padding: 0;
  overflow: hidden;
}

.result-preview-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
  transition: transform 160ms ease;
}

.result-preview-button:hover img {
  transform: scale(1.025);
}

.mock-overlay {
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(23, 21, 18, 0.35);
  pointer-events: none;
}

.result-body {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.result-meta,
.result-brief {
  margin: 0;
  line-height: 1.4;
}

.result-meta {
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 900;
}

.result-brief {
  color: var(--muted);
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-row {
  flex-wrap: wrap;
  align-items: stretch;
}

.result-actions,
.status-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}

.result-actions {
  align-items: stretch;
}

.status-row button,
.result-actions button {
  border: 2px solid var(--line);
  background: #fff;
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 900;
}

.result-actions [data-action="delete"] {
  color: #fff;
  background: var(--accent-dark);
}

.result-actions [data-action="retry"] {
  background: #edf8f4;
}

.result-actions [data-action="retry"]:hover {
  background: var(--mint);
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  background: var(--gold);
  color: var(--ink);
  padding: 6px 4px;
  font-size: 10px;
  font-weight: 900;
  text-decoration: none;
}

@container (min-width: 760px) {
  .results-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.status-row button.active {
  background: var(--gold);
  box-shadow: inset 0 0 0 2px rgba(23, 21, 18, 0.16);
}

.preview-dialog {
  width: min(92vw, 720px);
  border: 3px solid var(--line);
  background: #111;
  padding: 0;
}

.preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.preview-dialog-inner {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 70vh;
  padding: 18px;
}

.preview-dialog img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  background: #fff;
}

.preview-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
}

@media (max-width: 1180px) {
  .workspace,
  .studio-layout {
    grid-template-columns: minmax(240px, 0.8fr) minmax(420px, 1.2fr);
  }

  .library-panel {
    grid-column: 1;
  }

  .creator-panel {
    grid-column: 2;
  }

  .results-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .workspace,
  .studio-layout,
  .field-grid,
  .field-grid.two-col,
  .api-strip,
  .quick-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .topbar,
  .topbar-actions {
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
  }

  .library-panel,
  .creator-panel,
  .results-panel {
    grid-column: auto;
  }

  .tool-switch,
  .reference-mini-notice,
  .external-reference-preview {
    grid-template-columns: 1fr;
  }

  .reference-head {
    align-items: stretch;
    flex-direction: column;
  }

  .reference-file-button {
    width: 100%;
  }

  .external-reference-preview {
    grid-template-columns: 56px 1fr;
  }

  .external-reference-preview .ghost-button {
    grid-column: 1 / -1;
  }

  .adjustment-notice {
    grid-template-columns: 48px 1fr;
  }

  .adjustment-notice .ghost-button {
    grid-column: 1 / -1;
  }

  .adjustment-image-head {
    align-items: stretch;
    flex-direction: column;
  }

  .adjustment-file-button {
    width: 100%;
  }

  .adjustment-image-preview {
    grid-template-columns: 52px 1fr;
  }

  .adjustment-image-preview > img {
    width: 52px;
    height: 52px;
  }

  .adjustment-image-actions {
    grid-column: 1 / -1;
  }

  .adjustment-image-actions .ghost-button {
    grid-column: auto;
    flex: 1;
  }
}

@media (max-width: 520px) {
  .results-grid,
  .consistency-control {
    grid-template-columns: 1fr;
  }
}

/* A quieter workspace keeps the artwork and primary action in focus. */
body { background: var(--paper); }
.mobile-only, .mobile-workspace-nav { display: none; }
.topbar { border-width: 1px; border-radius: 8px; box-shadow: none; padding: 16px 20px; }
.topbar h1 { font-size: 24px; }
.eyebrow, .cloud-badge { display: none; }
.primary-button, .ghost-button, .primary-button:hover, .ghost-button:hover { box-shadow: none; transform: none; }
.prompt-card { background: #f6f8f8; border: 1px solid var(--line); color: var(--ink); padding: 12px; }
.prompt-card summary, .performance-details summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.prompt-card pre { color: var(--muted); max-height: 240px; overflow: auto; }
.prompt-card > button { margin-top: 10px; }
.performance-details { color: var(--muted); }
.panel { border-width: 1px; border-radius: 8px; box-shadow: none; }
button, .ghost-button, .reference-file-button, .adjustment-file-button {
  box-shadow: none; border-width: 1px; border-radius: 5px;
}
input, select, textarea { border-width: 1px; border-radius: 5px; }
.tool-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; background: #eef1f2; border: 0; border-radius: 6px; }
.tool-switch .tool-tab { flex: 1; min-width: 0; padding: 10px 6px; font-size: 14px; background: transparent; border: 0; box-shadow: none; }
.tool-switch .tool-tab.active { background: white; color: var(--accent-dark); box-shadow: 0 1px 3px #00000012; }
.workflow-status, .reference-hint, .reference-head .eyebrow { display: none; }
.reference-tool-panel, .adjustment-notice, .external-reference-preview,
.reference-analysis, .api-strip, .consistency-control { border-width: 1px; box-shadow: none; }
.reference-analysis { background: #f3f5f6; color: var(--ink); }
.reference-analysis pre { color: var(--muted); max-height: 150px; overflow: auto; }
.result-card { border-width: 1px; border-radius: 6px; box-shadow: none; overflow: hidden; }
.eyebrow { font-size: 11px; letter-spacing: 0; }
.creative-form { gap: 16px; }
#expandToolPanel { display: grid; gap: 14px; }
#expandPreview { display: grid; gap: 10px; }
#expandThumb { display: block; width: 100%; max-height: 300px; object-fit: contain; background: #eef1f2; border-radius: 4px; }
#expandFileName { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.expand-caveat { margin: 0; color: var(--muted); font-size: 12px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 600px) {
  .topbar-actions { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .topbar-actions button { flex: 1 1 auto; padding: 8px; font-size: 12px; }
  .tool-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tool-state-chip { display: none; }
  .tool-switch .tool-tab { font-size: 13px; }
}

@media (max-width: 760px) {
  html { scroll-padding-top: 70px; }
  .app-shell { padding: 10px 10px calc(100px + env(safe-area-inset-bottom)); }
  .topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 8px; }
  .topbar h1 { font-size: 19px; line-height: 1.4; }
  .mobile-only { display: block; }
  .topbar-actions { display: none; grid-column: 1 / -1; }
  .mobile-menu-open .topbar-actions { display: flex; }
  .mobile-workspace-nav { position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; background: var(--paper); padding: 8px 0; margin-bottom: 8px; }
  .mobile-workspace-nav button { min-height: 46px; border: 1px solid var(--line); background: white; font-size: 15px; }
  .mobile-workspace-nav button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent-line); }
  body[data-mobile-view="create"] .library-panel,
  body[data-mobile-view="create"] .results-panel,
  body[data-mobile-view="assets"] .creator-panel,
  body[data-mobile-view="assets"] .results-panel,
  body[data-mobile-view="results"] .creator-panel,
  body[data-mobile-view="results"] .library-panel { display: none; }
  .panel { padding: 14px; }
  .section-heading { gap: 8px; margin-bottom: 12px; }
  .section-heading h2 { font-size: 20px; }
  .mobile-character-button { width: 100%; min-height: 44px; background: var(--surface-soft); color: var(--ink); border: 1px solid var(--line); padding: 10px; margin: 0 0 12px; text-align: left; overflow-wrap: anywhere; }
  .api-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; }
  .api-strip > label { flex: 1; min-width: 115px; }
  .api-status { flex: 1; font-size: 11px; padding: 6px; border: 0; background: transparent; }
  .tool-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tool-switch .tool-tab { min-height: 46px; font-size: 13px; }
  input, textarea, select { font-size: 16px; max-width: 100%; }
  input:not([type="checkbox"]):not([type="radio"]), select, button, .download-button, .reference-file-button, .adjustment-file-button { min-height: 44px; }
  input[type="file"] { width: 100%; padding: 8px; font-size: 14px; }
  textarea { min-height: 100px; }
  .quick-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .quick-row:has(label[hidden]) { grid-template-columns: 1fr; }
  .consistency-control { grid-template-columns: 1fr 1fr; gap: 8px; }
  .consistency-control label { min-width: 0; }
  .consistency-control small { font-size: 11px; }
  #generateBtn { position: fixed; z-index: 30; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); width: calc(100% - 20px); min-height: 52px; box-shadow: 0 0 0 10px var(--paper), 0 -8px 18px #0000000d; font-size: 16px; }
  body:has(textarea:focus, input[type="text"]:focus) #generateBtn { position: static; width: 100%; box-shadow: none; }
  .creative-form { padding-bottom: 12px; }
  #expandThumb { max-height: 230px; }
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .result-body { padding: 8px; }
  .result-brief { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; }
  .result-meta { font-size: 11px; overflow-wrap: anywhere; }
  .result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
  .result-actions [data-action="retry"] { grid-column: 1 / -1; grid-row: 2; }
  .result-actions a, .result-actions button { font-size: 12px; padding: 6px 3px; min-width: 0; }
  .status-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; }
  .status-row button { padding: 6px 0; font-size: 10px; min-width: 0; }
  .preview-dialog { width: calc(100vw - 16px); max-width: none; max-height: 92dvh; border: 0; border-radius: 6px; }
  .preview-dialog-inner { min-height: 0; padding: 54px 8px 12px; }
  .preview-dialog img { max-height: 76dvh; }
  .preview-close { top: 6px; right: 6px; min-width: 60px; }
  .job-list { max-height: 220px; overflow-y: auto; }
  .task-center:has(.job-empty) { display: none; }
  .results-empty { grid-column: 1 / -1; }
}
@media (max-width: 359px) {
  .results-grid { grid-template-columns: 1fr; }
}

.brand-secret { display: inline; color: inherit; background: transparent; border: 0; padding: 0; border-radius: 0; font: inherit; line-height: inherit; text-align: inherit; cursor: pointer; }
.little-note { position: fixed; z-index: 40; right: 20px; bottom: 20px; width: min(350px, calc(100vw - 32px)); padding: 16px 70px 16px 18px; border: 1px solid #edc8cf; border-left: 3px solid #c4657b; border-radius: 8px; background: #fffafb; box-shadow: 0 6px 24px #53293618; animation: note-arrive 180ms ease-out; }
.little-note strong { display: block; color: #9d465d; font-size: 12px; font-weight: 600; }
.little-note p { margin: 6px 0 0; color: #573d45; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.little-note button { position: absolute; right: 8px; top: 8px; min-width: 48px; min-height: 44px; padding: 8px; border: 0; background: transparent; color: #9d465d; font-size: 12px; }
@keyframes note-arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 760px) {
  .little-note { right: 10px; bottom: calc(16px + env(safe-area-inset-bottom)); width: calc(100vw - 20px); }
  body[data-mobile-view="create"] .little-note { bottom: calc(80px + env(safe-area-inset-bottom)); }
  body:has(textarea:focus, input:focus, select:focus) .little-note { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .little-note { animation: none; }
}

/* Neutral work surfaces; rose for intent, green only for successful states. */
.library-panel, .creator-panel, .results-panel { border-top-color: var(--line); }
.rights-box, .api-strip, .upload-status, .reference-tool-panel,
.external-reference-preview, .reference-mini-notice, .adjustment-notice,
.adjustment-image-preview, .task-center, .performance-strip {
  background: var(--surface-soft);
  border-color: var(--line);
}
.rights-box, .upload-status { border-width: 1px; }
.external-reference-copy, .external-reference-copy span,
.reference-mini-notice, .reference-mini-notice span,
.adjustment-copy, .adjustment-copy span,
.adjustment-image-copy, .adjustment-image-copy span { color: var(--muted); }
.api-status.ok, .task-count.active, .job-copy small { color: var(--success); }
.api-status.warn, .login-error, .text-danger-button { color: var(--danger); }
.job-item.succeeded .job-indicator { background: var(--success); }
.job-item.failed .job-indicator { background: var(--danger); }
.tool-switch { background: #eff0f3; }
.tool-state-chip { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent-line); }
.consistency-control span { background: var(--surface-soft); border-color: var(--line); }
.consistency-control input:checked + span { background: var(--accent-soft); border-color: var(--accent-line); box-shadow: none; color: var(--accent-dark); }
.consistency-control input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
#promptAdvice { background: white; }
.reference-file-button, .adjustment-file-button { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-dark); }
.analysis-head { border-bottom-color: var(--line); color: var(--ink); }
.reference-analysis, .reference-analysis pre, .adjustment-image-preview pre { background: var(--surface-soft); color: var(--muted); }
.reference-analysis .analysis-head { color: var(--ink); }
.prompt-card, .prompt-card pre, .prompt-card summary { background: var(--surface-soft); color: var(--muted); }
.primary-button:hover { background: var(--accent-dark); }
.ghost-button:hover, .load-more-results:hover { background: var(--surface-soft); }
.download-button { background: #eef3f9; border-color: #d4deeb; color: #3c5976; }
.download-button:hover { background: #e4edf7; }
.result-actions [data-action="delete"] { background: white; border-color: var(--line); color: var(--danger); }
.result-actions [data-action="delete"]:hover { background: #fff1f2; }
.result-actions [data-action="retry"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-dark); }
.result-actions [data-action="retry"]:hover { background: #f7e1e9; }
.result-filters button.active { background: #3c3e49; border-color: #3c3e49; color: white; }
.status-row button.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-dark); box-shadow: none; }
.status-row button[data-status="favorite"].active { background: #fff5d8; border-color: #e8d6a3; color: #80631e; }
.status-row button[data-status="problem"].active { background: #fff1f2; border-color: #e8bec4; color: var(--danger); }
.result-card.selected-adjustment { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: none; }
.result-card.selected-adjustment::before { background: var(--accent-soft); color: var(--accent-dark); border-bottom-color: var(--accent-line); }
.character-card.active { border-color: var(--accent-line); outline: 2px solid var(--accent-line); outline-offset: 2px; }
.adjustment-image-tool { border-top-color: var(--line); }
.adjustment-notice { color: var(--ink); }
#resetDemoBtn { background: white; color: var(--muted); border-color: var(--line); }
#resetDemoBtn:hover { background: var(--surface-soft); }
#characterUploadBtn { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent-line); }
.results-empty { border-color: var(--line); background: var(--surface-soft); }
.result-meta { color: var(--muted); }
.performance-strip span { color: var(--muted); }
.performance-strip strong { color: var(--ink); }
.performance-strip div + div { border-left-color: var(--line); }
#adjustmentImageAnalysis { background: var(--surface-soft); color: var(--muted); }
.tool-panel { background: var(--surface-soft); }

.workspace-login { background: #f7f8fa; }
.workspace-login .login-screen { min-height: 100dvh; }
.workspace-login .login-panel { max-width: 360px; padding: 32px; border: 1px solid #e4e6eb; border-radius: 8px; background: white; box-shadow: 0 12px 40px #20253308; gap: 22px; }
.workspace-login h1 { font-size: 24px; font-weight: 650; line-height: 1.5; margin-bottom: 8px; }
.workspace-login label { font-size: 13px; font-weight: 500; color: #686b77; }
.workspace-login input { font-size: 16px; min-height: 46px; border-width: 1px; border-radius: 6px; }
.workspace-login #loginButton { min-height: 46px; font-size: 14px; font-weight: 600; }
.workspace-login .login-error:empty { display: none; }
