:root {
  color-scheme: light;
  --bg: #f7f4ed;
  --mist: #edf8f4;
  --paper: rgba(255, 255, 252, 0.9);
  --paper-solid: #fffef9;
  --paper-soft: #f8f5ee;
  --ink: #16201d;
  --muted: #69736d;
  --subtle: #9aa49e;
  --line: rgba(179, 190, 182, 0.58);
  --line-strong: rgba(126, 145, 135, 0.72);
  --accent: #2b806e;
  --accent-strong: #175e51;
  --accent-soft: #e5f4ef;
  --gold: #d7a95e;
  --gold-soft: #fff4dd;
  --danger: #b45a4d;
  --danger-soft: #fff0ec;
  --shadow: 0 24px 70px rgba(49, 58, 50, 0.12);
  --shadow-soft: 0 14px 38px rgba(49, 58, 50, 0.08);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  font-family: "Avenir Next", "Gill Sans", "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -8%, rgba(126, 184, 162, 0.34), transparent 31rem),
    radial-gradient(circle at 92% 4%, rgba(215, 169, 94, 0.18), transparent 28rem),
    linear-gradient(125deg, rgba(255, 255, 255, 0.84), rgba(237, 248, 244, 0.74) 42%, rgba(247, 244, 237, 0.96)),
    var(--bg);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  background-image:
    linear-gradient(rgba(43, 128, 110, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(43, 128, 110, 0.035) 1px, transparent 1px);
  background-size: 58px 58px;
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.5) 45%, transparent 94%);
}

body.modal-open {
  overflow: hidden;
}

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

button,
select,
.dropzone {
  cursor: pointer;
}

.app-shell {
  width: min(1680px, calc(100vw - 44px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(255, 255, 253, 0.96), rgba(244, 251, 248, 0.9)),
    var(--paper-solid);
  box-shadow: var(--shadow-soft);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(43, 128, 110, 0.2);
  border-radius: 18px;
  background:
    radial-gradient(circle at 34% 34%, #fff 0 5px, transparent 6px),
    radial-gradient(circle at 68% 66%, rgba(215, 169, 94, 0.95) 0 5px, transparent 6px),
    linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 14px 30px rgba(43, 128, 110, 0.2);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

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

.topbar h1 {
  max-width: 820px;
  margin-bottom: 0;
  font-family: "Cormorant Garamond", "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(32px, 4.6vw, 72px);
  font-weight: 620;
  line-height: 0.95;
  letter-spacing: -0.065em;
}

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

.stats-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 238px;
  padding: 8px;
  border: 1px solid rgba(188, 197, 187, 0.5);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(18px);
}

.stats-card span {
  display: grid;
  gap: 4px;
  padding: 11px 13px;
  border-radius: 17px;
  background: rgba(255, 254, 249, 0.86);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.stats-card strong {
  color: var(--ink);
  font-size: 25px;
  line-height: 1;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.92fr) minmax(520px, 1.08fr);
  gap: 18px;
  align-items: stretch;
}

.panel {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px);
}

.composer-panel,
.preview-panel,
.gallery-panel,
.config-modal {
  padding: 20px;
}

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

.panel-heading.compact {
  margin-bottom: 14px;
}

.panel-heading.mini {
  margin-bottom: 10px;
}

.panel-heading h2 {
  margin: 0;
  font-family: "Cormorant Garamond", "Noto Serif SC", "Songti SC", serif;
  font-size: 31px;
  font-weight: 650;
  letter-spacing: -0.045em;
}

.panel-heading small {
  color: var(--muted);
  font-weight: 850;
}

.field,
.prompt-field {
  display: grid;
  gap: 8px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.field small {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.field input,
.select-field,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  outline: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field input {
  min-height: 48px;
  padding: 0 14px;
}

.field input::placeholder,
textarea::placeholder {
  color: #a4ada8;
}

.field input:focus,
textarea:focus,
.select-field:focus-within {
  border-color: rgba(43, 128, 110, 0.58);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 0 0 5px rgba(43, 128, 110, 0.1);
}

textarea {
  min-height: 190px;
  padding: 17px;
  resize: vertical;
  font-size: 18px;
  font-weight: 720;
  line-height: 1.58;
}

.toggle-field {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  width: 100%;
  margin: 2px 0 13px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(248, 245, 238, 0.78);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.toggle-field input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.ghost-button,
.secondary-button,
.primary-button,
.action-button {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.ghost-button {
  min-height: 36px;
  padding: 7px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.secondary-button,
.action-button {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 10px 13px;
  font-weight: 850;
  text-decoration: none;
}

.secondary-button.strong {
  border-color: rgba(43, 128, 110, 0.22);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.secondary-button.slim {
  min-height: 38px;
  padding-inline: 13px;
  font-size: 13px;
}

.primary-button {
  width: 100%;
  min-height: 60px;
  margin-top: 14px;
  padding: 0 22px;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-size: 17px;
  font-weight: 950;
  box-shadow: 0 16px 34px rgba(43, 128, 110, 0.24);
}

.ghost-button:hover,
.secondary-button:hover,
.primary-button:hover,
.action-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 12px 26px rgba(49, 58, 50, 0.1);
}

.secondary-button:disabled,
.secondary-button.disabled,
.action-button:disabled,
.action-button.disabled {
  cursor: not-allowed;
  color: var(--subtle);
  pointer-events: none;
  opacity: 0.55;
}

.reference-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 50px;
  margin: 8px 0 12px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(248, 245, 238, 0.72);
}

.reference-strip div {
  display: flex;
  align-items: center;
  gap: 9px;
}

.reference-strip small {
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--subtle);
  box-shadow: 0 0 0 5px rgba(155, 165, 159, 0.14);
}

.reference-strip.has-image .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(43, 128, 110, 0.14);
}

.dropzone {
  position: relative;
  display: grid;
  min-height: 180px;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 6%, rgba(43, 128, 110, 0.13), transparent 13rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.75), rgba(248, 245, 238, 0.72));
}

.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropzone-empty,
.preview-empty,
.empty-tasks {
  display: grid;
  gap: 8px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.dropzone-empty strong,
.preview-empty strong,
.empty-tasks strong {
  color: var(--ink);
  font-size: 16px;
}

.reference-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  padding: 12px;
}

.reference-list:empty {
  display: none;
}

.reference-thumb {
  position: relative;
  min-height: 136px;
  overflow: hidden;
  border: 1px solid rgba(188, 197, 187, 0.62);
  border-radius: 18px;
  background: #eef1ea;
}

.reference-thumb img {
  width: 100%;
  height: 100%;
  min-height: 136px;
  object-fit: cover;
}

.reference-thumb button {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(24, 33, 30, 0.62);
  font-size: 11px;
  font-weight: 850;
  backdrop-filter: blur(10px);
}

.reference-thumb span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  overflow: hidden;
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  background: rgba(24, 33, 30, 0.56);
  font-size: 11px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

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

.select-field {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 47px;
  padding: 0 13px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.select-field select {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
}

.preview-panel {
  display: flex;
  min-height: 100%;
  flex-direction: column;
}

.preview-stage {
  display: grid;
  flex: 1;
  place-items: center;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    radial-gradient(circle at 50% 18%, rgba(215, 169, 94, 0.12), transparent 13rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(248, 245, 238, 0.78));
}

.preview-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.config-status,
.status-text {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.diagnostics-card {
  margin-top: 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(248, 245, 238, 0.72);
}

.diagnostics-card h3 {
  margin: 0;
  font-size: 18px;
}

.diagnostics-card pre {
  max-height: 170px;
  margin: 0;
  overflow: auto;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.65 "Cascadia Mono", Consolas, monospace;
}

.gallery-panel {
  margin-top: 18px;
}

.board-heading {
  margin-bottom: 8px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.task-card {
  position: relative;
  display: grid;
  overflow: hidden;
  border: 1px solid rgba(188, 197, 187, 0.52);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.76);
  animation: rise-in 260ms ease both;
}

.task-card.running {
  border-color: rgba(43, 128, 110, 0.35);
  box-shadow: 0 0 0 4px rgba(43, 128, 110, 0.07);
}

.task-card.failed {
  border-color: rgba(180, 90, 77, 0.3);
}

.task-card.favorite {
  border-color: rgba(215, 169, 94, 0.44);
  box-shadow: 0 0 0 4px rgba(215, 169, 94, 0.09);
}

.task-media {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 230px;
  overflow: hidden;
  border: 0;
  background:
    radial-gradient(circle at 45% 15%, rgba(255, 255, 255, 0.62), transparent 9rem),
    #edf0e9;
}

.task-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.task-placeholder {
  display: grid;
  gap: 8px;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(43, 128, 110, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.task-timer {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  background: rgba(24, 33, 30, 0.65);
  font: 700 11px/1 "Cascadia Mono", Consolas, monospace;
  backdrop-filter: blur(8px);
}

.task-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
  padding: 13px;
}

.task-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--paper-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.status-pill.completed {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill.running {
  background: var(--gold-soft);
  color: #8c641f;
}

.task-title {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.chip {
  max-width: 100%;
  padding: 4px 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(248, 245, 238, 0.9);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.action-button {
  min-height: 32px;
  padding: 6px 9px;
  border-radius: 11px;
  font-size: 12px;
}

.task-actions .action-button:last-child {
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-tasks {
  min-height: 240px;
  border: 1px dashed var(--line-strong);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.5);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(244, 248, 245, 0.72);
  backdrop-filter: blur(14px);
}

.modal-backdrop[hidden] {
  display: none;
}

.config-modal {
  width: min(620px, 100%);
  box-shadow: var(--shadow);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@media (max-width: 1120px) {
  .topbar,
  .studio-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    align-items: stretch;
    justify-content: stretch;
  }

  .preview-stage {
    min-height: 380px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 22px, 1680px);
    padding: 16px 0 24px;
  }

  .topbar,
  .composer-panel,
  .preview-panel,
  .gallery-panel,
  .config-modal {
    padding: 16px;
  }

  .brand-lockup,
  .topbar-actions,
  .composer-actions {
    display: grid;
  }

  .topbar h1 {
    font-size: clamp(34px, 12vw, 58px);
  }

  .stats-card,
  .control-grid,
  .preview-actions,
  .button-row,
  .reference-list {
    grid-template-columns: 1fr;
  }

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