:root {
  --bg: #f3efe6;
  --panel: rgba(255, 250, 241, 0.88);
  --panel-strong: rgba(255, 248, 235, 0.98);
  --line: rgba(108, 77, 41, 0.12);
  --text: #231a10;
  --muted: #7b6751;
  --accent: #d85f2c;
  --accent-2: #f4a259;
  --accent-3: #f7d8af;
  --forest: #37503d;
  --shadow: 0 18px 60px rgba(57, 40, 20, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(247, 216, 175, 0.95), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(216, 95, 44, 0.12), transparent 24%),
    linear-gradient(180deg, #fcf7ef 0%, #f0e7d9 58%, #efe6d9 100%);
  color: var(--text);
  font-family: "Manrope", "Noto Sans SC", sans-serif;
}

body {
  padding: 18px;
}

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

button {
  cursor: pointer;
  border: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 36px);
}

.rail,
.workspace {
  min-width: 0;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: rgba(35, 26, 16, 0.95);
  color: #fff4e8;
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.brand-block {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: 24px;
  background:
    linear-gradient(150deg, rgba(255,255,255,0.14), rgba(255,255,255,0.03)),
    radial-gradient(circle at top right, rgba(244, 162, 89, 0.36), transparent 36%);
}

.brand-badge,
.section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
}

.brand-badge {
  color: #ffd8ad;
}

.brand-block h1,
.rail-card h2,
.hero h2,
.panel-head h3,
.section-head h3 {
  margin: 8px 0 10px;
  line-height: 1.02;
}

.brand-block h1 {
  font-size: 42px;
}

.brand-block p,
.rail-card p,
.hero p,
.section-head-copy,
.stage-empty p,
.field small {
  margin: 0;
  color: rgba(255, 244, 232, 0.72);
  line-height: 1.55;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rail-nav button,
.rail-card,
.hero,
.template-section,
.stage-panel,
.composer-panel,
.queue-panel {
  border: 1px solid var(--line);
}

.rail-nav button {
  text-align: left;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
  color: inherit;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.rail-nav button:hover,
.rail-nav button.active {
  transform: translateX(4px);
  background: rgba(244, 162, 89, 0.16);
  border-color: rgba(244, 162, 89, 0.36);
}

.rail-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255,255,255,0.05);
}

.rail-card-soft {
  background: rgba(247, 216, 175, 0.08);
}

.micro-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: rgba(255, 244, 232, 0.76);
}

.quick-links {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.quick-link {
  display: block;
  text-decoration: none;
  color: #fff4e8;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.quick-link:hover {
  transform: translateX(4px);
  background: rgba(244, 162, 89, 0.16);
  border-color: rgba(244, 162, 89, 0.36);
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero,
.template-section,
.stage-panel,
.composer-panel,
.queue-panel {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 28px 30px;
}

.hero h2 {
  font-size: clamp(34px, 4vw, 56px);
  max-width: 10ch;
}

.hero p {
  max-width: 64ch;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.hero-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.api-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 280px;
}

.api-field span,
.field span {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.api-field input,
.field input,
.field textarea,
.field select {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(108, 77, 41, 0.14);
  background: rgba(255,255,255,0.72);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.api-field input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(216, 95, 44, 0.38);
  box-shadow: 0 0 0 4px rgba(216, 95, 44, 0.08);
  transform: translateY(-1px);
}

.template-section {
  padding: 24px;
}

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

.section-head h3,
.panel-head h3 {
  font-size: 28px;
}

.section-head-copy,
.stage-meta {
  color: var(--muted);
}

.stage-panel .panel-head {
  align-items: flex-start;
}

.stage-meta {
  margin-left: auto;
  padding-top: 10px;
  font-size: 15px;
  text-align: right;
}

.template-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.template-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  min-height: 220px;
  border-radius: 24px;
  border: 1px solid rgba(108, 77, 41, 0.12);
  background:
    linear-gradient(145deg, rgba(255,255,255,0.55), rgba(255,248,235,0.82)),
    radial-gradient(circle at top right, rgba(244, 162, 89, 0.28), transparent 34%);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.template-card::after {
  content: "";
  position: absolute;
  inset: auto -10% -35% auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(216, 95, 44, 0.08);
  filter: blur(4px);
}

.template-card:hover {
  transform: translateY(-6px);
  border-color: rgba(216, 95, 44, 0.24);
  box-shadow: 0 18px 38px rgba(57, 40, 20, 0.11);
}

.template-card h4,
.task-item h4,
.stage-empty h4 {
  margin: 0;
  font-size: 22px;
}

.template-card p,
.task-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.template-meta,
.task-item-top,
.task-item-bottom,
.stage-footer,
.tag-row,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill,
.metric-chip,
.task-badge,
.task-duration,
.task-provider,
.task-status,
.quick-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill,
.metric-chip,
.quick-tag {
  background: rgba(255,255,255,0.72);
  color: var(--forest);
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.92fr) minmax(280px, 0.72fr);
  gap: 18px;
}

.stage-panel,
.composer-panel,
.queue-panel {
  padding: 22px;
}

.stage-frame {
  margin-top: 18px;
  min-height: 560px;
  padding: 36px;
  border-radius: 28px;
  background:
    radial-gradient(circle at 15% 12%, rgba(244, 162, 89, 0.28), transparent 20%),
    linear-gradient(155deg, #20170f 0%, #332419 36%, #1a120d 100%);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.stage-support {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stage-detail-card {
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(108, 77, 41, 0.12);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 26px rgba(57, 40, 20, 0.06);
}

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

.stage-detail-card h4 {
  margin: 6px 0 0;
  font-size: 18px;
}

.stage-detail-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 16px;
  display: block;
}

.stage-frame video,
.stage-frame img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 20px;
}

.stage-empty {
  max-width: 520px;
  padding: 12px;
  text-align: center;
  color: #fdf7f1;
}

.stage-empty p {
  margin-top: 14px;
  color: rgba(253, 247, 241, 0.72);
}

.stage-empty[hidden],
.stage-frame video[hidden],
.stage-frame img[hidden] {
  display: none !important;
}

.composer-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field textarea {
  resize: vertical;
  min-height: 170px;
}

.upload-field small {
  color: var(--muted);
}

.upload-preview {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(108, 77, 41, 0.1);
}

.upload-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

.upload-preview-copy {
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.quick-tag {
  border: 1px solid rgba(108, 77, 41, 0.12);
}

.quick-tag:hover {
  background: rgba(216, 95, 44, 0.09);
  color: var(--accent);
}

.primary-button,
.ghost-button,
.primary-button-wide {
  border-radius: 16px;
  padding: 14px 18px;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button,
.primary-button-wide {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fffaf5;
  box-shadow: 0 12px 24px rgba(216, 95, 44, 0.24);
}

.ghost-button {
  background: rgba(255,255,255,0.75);
  color: var(--text);
  border: 1px solid rgba(108, 77, 41, 0.12);
}

.primary-button:hover,
.primary-button-wide:hover,
.ghost-button:hover,
.task-item:hover {
  transform: translateY(-2px);
}

.text-link:hover {
  transform: translateY(-2px);
}

.primary-button-wide {
  min-width: 220px;
}

.queue-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-link {
  color: var(--accent);
  font-weight: 700;
}

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

.task-item {
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(108, 77, 41, 0.12);
  background: rgba(255,255,255,0.75);
  box-shadow: 0 12px 24px rgba(57, 40, 20, 0.06);
}

.task-item.active {
  border-color: rgba(216, 95, 44, 0.3);
  background: linear-gradient(135deg, rgba(255,245,238,0.94), rgba(255,252,246,0.92));
}

.task-title {
  margin-top: 12px;
  font-size: 18px;
}

.task-prompt {
  display: -webkit-box;
  margin-top: 8px;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.task-status[data-status="SUCCESS"] {
  background: rgba(36, 137, 79, 0.12);
  color: #207347;
}

.task-status[data-status="FAILED"] {
  background: rgba(176, 54, 54, 0.12);
  color: #a13333;
}

.task-status[data-status="PROCESSING"],
.task-status[data-status="PENDING"] {
  background: rgba(216, 95, 44, 0.12);
  color: #b95124;
}

@media (max-width: 1440px) {
  .studio-grid {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 0.95fr);
  }

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

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

@media (max-width: 1040px) {
  body {
    padding: 12px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .hero,
  .section-head,
  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .api-field {
    min-width: 0;
  }

  .template-grid,
  .studio-grid,
  .field-grid-2,
  .stage-support {
    grid-template-columns: 1fr;
  }

  .stage-frame {
    min-height: 420px;
  }
}
