:root {
  color-scheme: light;
  --ink: #18202b;
  --muted: #667085;
  --line: #d8dee8;
  --line-strong: #b9c2cf;
  --canvas: #f3f0ea;
  --panel: #fffdf9;
  --panel-strong: #ffffff;
  --nav: #121a24;
  --nav-soft: #1f2b39;
  --accent: #2f766f;
  --accent-strong: #1f5f58;
  --amber: #d19034;
  --rose: #b45d68;
  --blue: #416f9f;
  --shadow: 0 18px 42px rgba(30, 35, 45, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(47, 118, 111, 0.1), transparent 32%),
    linear-gradient(225deg, rgba(180, 93, 104, 0.08), transparent 36%),
    var(--canvas);
  color: var(--ink);
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid rgba(65, 111, 159, 0.45);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}

.sidebar {
  background: linear-gradient(180deg, var(--nav), #0e141c);
  color: #f5f7fa;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: linear-gradient(145deg, #2f766f, #b45d68);
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #aeb8c4;
  font-size: 13px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 11px 12px;
  background: transparent;
  color: #dce4ed;
  text-align: left;
}

.nav-item span {
  color: #7f8fa3;
  font-size: 12px;
  width: 22px;
}

.nav-item:hover,
.nav-item.active {
  background: var(--nav-soft);
  border-color: rgba(255, 255, 255, 0.08);
  color: white;
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.note-kicker,
.eyebrow {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-note .note-kicker {
  color: #d6a65c;
}

.sidebar-note p,
.help-text {
  color: #748094;
  line-height: 1.5;
  margin: 8px 0 0;
  font-size: 14px;
}

.sidebar-note p {
  color: #b8c2ce;
}

.workspace {
  padding: 18px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(22px, 2.4vw, 34px);
  line-height: 1.08;
  max-width: 760px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.eyebrow {
  margin: 0;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-pill,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  padding: 6px 11px;
  color: #3d4856;
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.ready {
  border-color: rgba(47, 118, 111, 0.35);
  color: var(--accent-strong);
}

.status-pill.error {
  border-color: rgba(180, 93, 104, 0.45);
  color: #953f4c;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.14fr) minmax(360px, 0.86fr);
  gap: 14px;
  align-items: start;
}

.panel-stack,
.results-panel,
.panel {
  min-width: 0;
}

.panel,
.results-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 249, 0.92);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel[hidden] {
  display: none;
}

.panel-heading,
.result-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.panel-heading h2,
.result-header h2 {
  margin: 4px 0 0;
  font-size: 20px;
  letter-spacing: 0;
}

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

.span-2 {
  grid-column: 1 / -1;
}

.field,
.upload-zone {
  display: grid;
  gap: 7px;
}

.field[hidden],
.upload-zone[hidden] {
  display: none !important;
}

.field span,
.upload-title {
  font-size: 13px;
  font-weight: 760;
  color: #3c4654;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.45;
}

#generate-prompt {
  min-height: 140px;
}

#edit-prompt {
  min-height: 126px;
}

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

.field-pair[hidden] {
  display: none !important;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #3c4654;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.icon-button,
.segmented-control button {
  border-radius: var(--radius);
  border: 1px solid transparent;
  min-height: 40px;
  padding: 9px 13px;
  font-weight: 750;
}

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

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

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.secondary-button,
.icon-button,
.segmented-control button {
  background: #f6f3ed;
  border-color: var(--line);
  color: #324050;
}

.secondary-button:hover,
.icon-button:hover,
.segmented-control button:hover {
  background: white;
  border-color: var(--line-strong);
}

.compact {
  min-height: 34px;
  padding: 7px 11px;
}

.upload-zone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  min-height: 104px;
  align-content: center;
  padding: 16px;
  background: #faf7f1;
  color: #667085;
}

.edit-upload {
  min-height: 76px;
  padding: 12px 14px;
}

.upload-zone.subtle {
  background: #f8faf8;
}

.upload-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.upload-zone span {
  overflow-wrap: anywhere;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #f6f3ed;
}

.segmented-control button {
  border: 0;
  border-radius: 0;
  min-height: 34px;
}

.segmented-control button.active {
  background: var(--ink);
  color: white;
}

.template-grid,
.gallery-grid,
.result-grid {
  display: grid;
  gap: 12px;
}

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

.template-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.template-category-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f3ed;
  padding: 4px 6px 4px 10px;
}

.template-category-filter span {
  color: #596579;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.template-category-filter select {
  min-height: 28px;
  border: 0;
  background: transparent;
  padding: 2px 24px 2px 4px;
}

.template-count {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.template-card,
.result-card,
.gallery-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  overflow: hidden;
}

.template-card {
  display: grid;
  gap: 12px;
  grid-template-rows: auto auto auto 1fr;
  padding: 12px;
  text-align: left;
}

.template-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.template-strip {
  height: 6px;
  border-radius: 999px;
}

.template-preview {
  display: block;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(47, 118, 111, 0.1), rgba(209, 144, 52, 0.14)),
    #eef1f4;
}

.template-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  color: #596579;
  background: #fbfaf7;
}

.template-card h3 {
  margin: 0;
  font-size: 16px;
}

.template-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.results-panel {
  padding: 16px;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.result-grid {
  min-height: 320px;
}

.empty-state {
  place-items: center;
  align-content: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 24px;
  background: rgba(255, 255, 255, 0.54);
}

.empty-visual {
  width: min(220px, 65%);
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(47, 118, 111, 0.18), rgba(209, 144, 52, 0.2)),
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(24, 32, 43, 0.04) 12px 24px);
}

.empty-visual.active {
  animation: progressPulse 1.6s ease-in-out infinite;
}

.request-progress {
  width: min(320px, 82%);
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e4e9ef;
  border: 1px solid var(--line);
}

.request-progress span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--amber));
  animation: requestProgress 1.1s ease-in-out infinite;
}

.request-running .status-pill.muted {
  border-color: rgba(209, 144, 52, 0.55);
  color: #7b541d;
}

@keyframes requestProgress {
  0% {
    transform: translateX(-105%);
  }

  100% {
    transform: translateX(245%);
  }
}

@keyframes progressPulse {
  0%,
  100% {
    opacity: 0.78;
    transform: scale(0.99);
  }

  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.result-card img,
.gallery-card img {
  display: block;
  width: 100%;
  object-fit: contain;
  background: #eceff3;
}

.result-card img {
  max-height: min(54vh, 520px);
}

.gallery-card img {
  aspect-ratio: 1 / 1;
}

.result-body,
.gallery-body {
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

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

.result-actions a,
.result-actions button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f3ed;
  color: #324050;
  padding: 7px 10px;
  text-decoration: none;
  font-weight: 750;
  font-size: 13px;
}

.details-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.details-panel summary {
  cursor: pointer;
  color: #435064;
  font-weight: 760;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 12px 0 0;
  max-height: 260px;
  overflow: auto;
  background: #121a24;
  color: #e7edf5;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
}

.toast {
  position: fixed;
  inset-inline: 50% auto;
  inset-block-end: 18px;
  translate: -50% 0;
  max-width: min(520px, calc(100vw - 32px));
  border-radius: var(--radius);
  background: #121a24;
  color: white;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  transform: translateY(8px);
}

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

@media (max-width: 1080px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .results-panel {
    position: static;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    max-width: 100%;
  }

  .nav-item {
    flex: 0 0 auto;
    min-width: 130px;
  }

  .sidebar-note {
    display: none;
  }

  .workspace {
    padding: 16px;
    overflow-x: hidden;
  }

  .topbar,
  .panel-heading,
  .result-header {
    display: grid;
  }

  .status-strip {
    justify-content: start;
  }

  .topbar h1 {
    font-size: 24px;
    max-width: 100%;
  }

  .form-grid,
  .template-grid,
  .field-pair {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }
}
