:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #18202a;
  --muted: #667085;
  --line: #d7dde5;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warning: #b45309;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(340px, 0.72fr);
  gap: 16px;
}

.workspace,
.results-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.workspace {
  padding: 18px;
}

.results-panel {
  min-height: calc(100vh - 32px);
  padding: 18px;
}

.topbar,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 22px;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
  background: #f8fafc;
}

.status-pill.ok {
  color: var(--accent-strong);
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.08);
}

.status-pill.warn {
  color: var(--warning);
  border-color: rgba(180, 83, 9, 0.35);
  background: rgba(180, 83, 9, 0.08);
}

.generator {
  display: grid;
  gap: 14px;
}

.prompt-builder {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.builder-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.builder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 270px;
  resize: vertical;
  padding: 14px;
  line-height: 1.45;
}

select {
  height: 44px;
  padding: 0 12px;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea:focus,
select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.settings-box {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid rgba(180, 83, 9, 0.35);
  border-radius: 8px;
  background: rgba(180, 83, 9, 0.07);
  display: grid;
  gap: 12px;
}

.settings-box[hidden] {
  display: none;
}

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

.template-row button,
.ghost-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
}

.template-row button:hover,
.ghost-button:hover {
  border-color: var(--accent);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.primary-action,
.secondary-action {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  background: #111827;
}

.secondary-action:hover {
  background: #2d3748;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.message {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: #fbfcfd;
}

.message.error {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.35);
  background: rgba(180, 35, 24, 0.07);
}

.gallery {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #eef2f6;
}

.image-actions {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.image-actions a,
.image-actions button {
  flex: 1;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 10px;
  }

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

  .control-grid,
  .builder-grid,
  .template-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 25px;
  }

  .topbar,
  .panel-head,
  .builder-head {
    flex-direction: column;
  }

  .status-pill,
  .ghost-button {
    width: 100%;
  }

  .control-grid,
  .builder-grid,
  .template-row {
    grid-template-columns: 1fr;
  }
}
