:root {
  color-scheme: light;
  --ink: #171512;
  --muted: #6f6861;
  --paper: #f7f3ec;
  --panel: #fffdf8;
  --line: #24211d;
  --soft-line: #ded6ca;
  --accent: #f05d46;
  --accent-dark: #b43c2c;
  --mint: #91c9b6;
  --gold: #e5bc52;
  --blue: #78a7c9;
  --shadow: 0 18px 40px rgba(33, 28, 20, 0.12);
}

* {
  box-sizing: border-box;
}

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 rgba(240, 93, 70, 0.25);
}

.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;
  }
}
