@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Source+Sans+3:wght@400;500;600;700&display=swap");

:root {
  --ink: #1d2525;
  --muted: #677271;
  --paper: #f8f3e9;
  --panel: rgba(255, 252, 244, 0.82);
  --line: rgba(28, 37, 37, 0.14);
  --accent: #d85c27;
  --accent-dark: #a93f18;
  --sage: #9db99f;
  --sky: #9ec9d4;
  --shadow: 0 24px 70px rgba(30, 38, 38, 0.14);
  --radius-lg: 28px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Source Sans 3", "Gill Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(216, 92, 39, 0.24), transparent 34rem),
    radial-gradient(circle at 86% 18%, rgba(158, 201, 212, 0.34), transparent 28rem),
    linear-gradient(135deg, #fbf5e8 0%, #eef1df 46%, #dfeee9 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(420px, 1fr) 360px;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.sidebar,
.main-stage,
.preview-panel,
.job-dock {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  color: #fff9ec;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(145deg, var(--accent), #263332);
}

.brand h1,
.hero h2,
.panel-heading h3,
.preview-header h3,
.dock-header h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.04em;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mode-nav {
  display: grid;
  gap: 12px;
}

.mode-tab {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 16px;
  text-align: left;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
  transition: transform 160ms ease, background 160ms ease, border 160ms ease;
}

.mode-tab span {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
}

.mode-tab small,
.deploy-note,
.preview-empty {
  color: var(--muted);
}

.mode-tab.active {
  color: #fffaf0;
  border-color: transparent;
  background: linear-gradient(145deg, #263332, #41524d);
}

.mode-tab:hover {
  transform: translateY(-1px);
}

.deploy-note {
  margin-top: auto;
  padding: 16px;
  border: 1px dashed rgba(28, 37, 37, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.34);
}

.deploy-note p {
  margin: 0 0 8px;
}

.deploy-note p:last-child {
  margin-bottom: 0;
}

.main-stage {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

.hero {
  min-height: 136px;
  padding: 28px;
  border-radius: 24px;
  color: #fffaf0;
  background:
    linear-gradient(135deg, rgba(38, 51, 50, 0.94), rgba(67, 83, 74, 0.9)),
    radial-gradient(circle at 88% 18%, rgba(216, 92, 39, 0.42), transparent 20rem);
  overflow: hidden;
}

.hero h2 {
  max-width: 780px;
  font-size: clamp(1.8rem, 3vw, 3.3rem);
  line-height: 0.95;
}

.mode-panel {
  display: none;
}

.mode-panel.active {
  display: block;
}

.job-form {
  display: grid;
  gap: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.panel-heading h3 {
  font-size: 1.55rem;
}

.primary-action,
#refresh-jobs {
  border: 0;
  border-radius: 999px;
  color: #fffaf0;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 12px 24px rgba(169, 63, 24, 0.22);
}

.primary-action {
  padding: 13px 18px;
}

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

.field-card,
.prompt-field,
.reference-card,
.restored-job {
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.48);
}

.field-card span,
.prompt-field,
.reference-card legend {
  font-weight: 800;
}

input[type="file"] {
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(28, 37, 37, 0.16);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 14px;
  border: 1px solid rgba(28, 37, 37, 0.16);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.64);
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.reference-card {
  margin: 0;
}

.reference-card legend {
  padding: 0 6px;
  font-family: "Space Grotesk", sans-serif;
}

.reference-card legend span {
  color: var(--muted);
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
}

.reference-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

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

.style-strip figure,
.asset-card {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.style-strip img,
.asset-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #fff;
}

.style-strip figcaption,
.asset-card figcaption {
  padding: 9px 11px;
  color: var(--muted);
  font-weight: 800;
}

.preview-panel {
  min-width: 0;
  padding: 22px;
  overflow: auto;
}

.preview-header {
  margin-bottom: 18px;
}

.preview-grid,
.restored-grid {
  display: grid;
  gap: 12px;
}

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

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

.job-meta {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.44);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fffaf0;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  background: #697774;
}

.status-submitted {
  background: #6b7fba;
}

.status-running {
  background: #bb7b29;
}

.status-completed {
  background: #2e8162;
}

.status-failed {
  background: #b84331;
}

.job-dock {
  grid-column: 1 / -1;
  padding: 18px;
}

.dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

#refresh-jobs {
  padding: 10px 14px;
}

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

.queue-columns h4 {
  margin: 0 0 8px;
  font-family: "Space Grotesk", sans-serif;
}

.job-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.job-chip {
  display: grid;
  gap: 6px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
}

.job-chip strong {
  font-family: "Space Grotesk", sans-serif;
}

.job-chip small {
  color: var(--muted);
}

.job-chip.active {
  border-color: rgba(216, 92, 39, 0.5);
  box-shadow: 0 0 0 3px rgba(216, 92, 39, 0.12);
}

.error-box {
  padding: 13px;
  border-radius: 14px;
  color: #7a271a;
  background: rgba(184, 67, 49, 0.12);
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 16px;
  color: #fffaf0;
  background: #263332;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

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

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .preview-panel {
    grid-column: 1 / -1;
  }
}

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

  .sidebar {
    gap: 16px;
  }

  .mode-nav,
  .reference-grid,
  .style-strip,
  .queue-columns,
  .restored-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }
}
