:root {
  background: #0b0b0b;
  color: #f4f0e8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #0b0b0b;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.app-shell {
  --canvas: #0b0b0b;
  --surface-1: #151515;
  --surface-2: #1d1d1d;
  --surface-3: #282622;
  --hairline: #2e2c28;
  --hairline-strong: #4a453d;
  --ink: #f4f0e8;
  --ink-muted: #d8d2c7;
  --ink-subtle: #aaa294;
  --ink-tertiary: #756f65;
  --accent: #f4f0e8;
  --accent-warm: #c8a86a;
  display: grid;
  gap: 14px;
  min-height: 100vh;
  padding: 14px;
  background: var(--canvas);
  color: var(--ink);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #111111;
  font-weight: 800;
}

.brand span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 14px;
  font-weight: 650;
}

.brand small {
  color: var(--ink-subtle);
  font-size: 12px;
}

.topbar-actions,
.panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.metric-pill,
.api-link,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #101010;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.api-link:hover,
.secondary-button:not(:disabled):hover {
  border-color: var(--hairline-strong);
  color: var(--ink);
}

.generation-workspace {
  display: grid;
  grid-template-columns: clamp(310px, 24vw, 390px) clamp(190px, 15vw, 260px) minmax(420px, 1fr);
  gap: 14px;
  height: calc(100vh - 90px);
  min-height: 720px;
  align-items: stretch;
}

.generator-sidebar,
.batch-history,
.results-panel {
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--surface-1);
}

.generator-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 100%;
  padding: 16px;
  overflow: auto;
}

.batch-history,
.results-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  min-height: 100%;
  padding: 16px;
  overflow: hidden;
}

.studio-heading {
  display: grid;
  gap: 8px;
}

.studio-heading h1 {
  max-width: 380px;
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  line-height: 1.18;
}

.eyebrow {
  margin: 0;
  color: var(--ink-subtle);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field-block {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
}

.field-copy {
  color: var(--ink-subtle);
  font-size: 11px;
  line-height: 1.4;
}

.studio-field {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  outline: 0;
  background: #101010;
  color: var(--ink);
}

.studio-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244, 240, 232, 0.12);
}

.prompt-field {
  min-height: 180px;
  resize: vertical;
  line-height: 1.55;
}

.prompt-chip-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.prompt-chip {
  min-height: 38px;
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #101010;
  color: var(--ink-subtle);
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
}

.prompt-chip:hover {
  border-color: var(--hairline-strong);
  color: var(--ink);
}

.parameter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.server-note {
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #101010;
  color: var(--ink-subtle);
  font-size: 12px;
  line-height: 1.5;
}

.server-note strong {
  color: var(--accent-warm);
}

.edit-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #101010;
}

.edit-panel .section-heading {
  align-items: center;
}

.edit-panel .section-heading h2 {
  font-size: 17px;
}

#mask-status {
  padding: 5px 8px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-subtle);
  font-size: 12px;
  white-space: nowrap;
}

.edit-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.edit-upload {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 76px;
  padding: 14px;
  border: 1px dashed var(--hairline-strong);
  border-radius: 8px;
  background: #151515;
  color: var(--ink-subtle);
  text-align: left;
  cursor: pointer;
}

.edit-upload:hover {
  border-color: var(--ink-tertiary);
  color: var(--ink);
}

.edit-upload strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-upload span {
  font-size: 12px;
  line-height: 1.45;
}

.edit-stage {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #151515 25%, transparent 25%),
    linear-gradient(-45deg, #151515 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151515 75%),
    linear-gradient(-45deg, transparent 75%, #151515 75%),
    #101010;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  aspect-ratio: 1;
  touch-action: none;
}

.edit-stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.edit-mask-canvas {
  display: none;
}

.edit-overlay-canvas {
  cursor: crosshair;
}

.edit-mask-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.brush-slider {
  width: 100%;
  accent-color: var(--accent);
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #111111;
  font-weight: 750;
  cursor: pointer;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.generation-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #7f1d1d;
  border-radius: 8px;
  background: rgba(127, 29, 29, 0.18);
  color: #fca5a5;
  font-size: 13px;
  line-height: 1.5;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.1;
}

.batch-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
}

.batch-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #101010;
  color: var(--ink-subtle);
  text-align: left;
  cursor: pointer;
}

.batch-card:hover,
.batch-card.active {
  border-color: var(--hairline-strong);
  background: var(--surface-2);
  color: var(--ink);
}

.batch-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.batch-card span:nth-child(2) {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.results-board {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: #101010;
}

.empty-results,
.compact-empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
  color: var(--ink-subtle);
  text-align: center;
}

.compact-empty {
  min-height: 120px;
  border: 1px dashed var(--hairline-strong);
  border-radius: 8px;
}

.empty-results strong,
.compact-empty strong {
  color: var(--ink);
}

.result-list {
  --result-card-size: 360px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 14px;
  padding: 14px;
}

.result-card {
  width: min(100%, var(--result-card-size));
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--surface-2);
}

.result-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #0f0f0f;
}

.loading-progress-card {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  min-height: 360px;
  padding: 32px;
  text-align: center;
}

.loading-progress-flow {
  position: relative;
  width: min(260px, 72vw);
  height: 10px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: #151515;
  box-shadow: inset 0 0 0 1px rgba(244, 240, 232, 0.03);
}

.loading-progress-flow span {
  content: "";
  position: absolute;
  inset: 1px auto 1px 1px;
  width: 38%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-warm), var(--accent));
  box-shadow: 0 0 22px rgba(200, 168, 106, 0.28);
  animation: progress-flow 1600ms ease-in-out infinite;
}

.loading-progress-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(260px, 72vw);
}

.loading-progress-steps span {
  height: 6px;
  border-radius: 50%;
  background: var(--surface-3);
  animation: progress-step 1800ms ease-in-out infinite;
}

.loading-progress-steps span:nth-child(2) {
  animation-delay: 180ms;
}

.loading-progress-steps span:nth-child(3) {
  animation-delay: 360ms;
}

.loading-progress-copy {
  display: grid;
  gap: 7px;
  max-width: 320px;
}

.loading-progress-copy strong {
  font-size: 16px;
}

.loading-progress-copy p {
  margin: 0;
  color: var(--ink-subtle);
  font-size: 13px;
  line-height: 1.5;
}

.result-meta {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.result-meta p {
  display: -webkit-box;
  min-height: 40px;
  margin: 0;
  overflow: hidden;
  color: var(--ink-subtle);
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@keyframes progress-flow {
  0% {
    transform: translateX(-10%);
  }

  50% {
    transform: translateX(165%);
  }

  100% {
    transform: translateX(-10%);
  }
}

@keyframes progress-step {
  0%,
  100% {
    background: var(--surface-3);
    transform: scaleX(1);
  }

  50% {
    background: var(--accent-warm);
    transform: scaleX(1.06);
  }
}

@media (max-width: 980px) {
  .generation-workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .batch-history,
  .results-panel {
    min-height: 360px;
  }
}

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

  .topbar,
  .action-row,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .prompt-chip-row {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .panel-actions {
    width: 100%;
    justify-content: space-between;
  }
}
