:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --surface: #ffffff;
  --surface-soft: #f9faf7;
  --ink: #1b2420;
  --muted: #667168;
  --line: #dce3db;
  --accent: #1f6b52;
  --accent-dark: #154936;
  --accent-soft: #e7f2ec;
  --danger: #9f2f2f;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

.shell {
  width: min(1380px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar,
.section-header,
.panel-header,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding-bottom: 22px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.topbar-actions form {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.02;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 0.92rem;
}

.muted {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.button,
.step-button,
.product-item {
  cursor: pointer;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  font-weight: 800;
  text-decoration: none;
}

.button:hover {
  background: var(--accent-dark);
}

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

.button:disabled:hover,
.button.disabled:hover {
  background: var(--accent);
}

.step-button:disabled:hover,
.step-button.disabled:hover {
  border-color: var(--line);
}

.button.secondary {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover {
  background: var(--surface-soft);
}

.workspace {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.sidebar,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgb(31 107 82 / 7%);
}

.sidebar {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.section-header,
.panel-header {
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.count,
.status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.product-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.product-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  text-align: left;
}

.product-item:hover,
.product-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.product-item span,
.product-item small {
  display: block;
}

.product-item span {
  font-weight: 800;
}

.product-item small {
  margin-top: 4px;
  color: var(--muted);
}

.studio {
  display: grid;
  gap: 16px;
}

.form-grid,
.media-grid,
.result-layout {
  display: grid;
  gap: 14px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 16px;
}

.media-grid,
.result-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.upload-box {
  display: grid;
  gap: 12px;
  padding: 16px;
}

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

.preview-grid.single {
  grid-template-columns: 1fr;
}

.preview-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.preview-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.preview-card code {
  display: block;
  overflow-wrap: anywhere;
  padding: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.step-button {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 10px;
  font-weight: 800;
}

.step-button:hover {
  border-color: var(--accent);
}

.step-button.emphasis {
  background: var(--ink);
  color: #fff;
}

.result-layout {
  padding: 0 16px 16px;
}

pre {
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101714;
  color: #e7f2ec;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.generated-preview {
  min-height: 420px;
  padding: 16px;
}

.generated-preview img {
  display: block;
  width: min(100%, 720px);
  max-height: 720px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
}

.empty {
  color: var(--muted);
}

.empty.compact {
  padding: 8px;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100% - 36px));
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 12px 28px rgb(0 0 0 / 20%);
  opacity: 0;
  transform: translateY(8px);
  transition: 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

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

.login-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgb(31 107 82 / 7%);
  padding: 24px;
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: 2rem;
}

.login-form {
  display: grid;
  gap: 14px;
}

.form-error {
  border-radius: 8px;
  background: #fbeaea;
  color: var(--danger);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 800;
}

.settings-list {
  display: grid;
  margin: 0;
  padding: 0;
}

.settings-list div {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.settings-list div:last-child {
  border-bottom: 0;
}

.settings-list dt {
  color: var(--muted);
  font-weight: 800;
}

.settings-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 1080px) {
  .workspace,
  .media-grid,
  .result-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

@media (max-width: 680px) {
  .topbar,
  .panel-header,
  .section-header,
  .actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .form-grid,
  .pipeline,
  .preview-grid,
  .settings-list div {
    grid-template-columns: 1fr;
  }
}
