:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --panel-2: #eef4f1;
  --ink: #1d2524;
  --muted: #687572;
  --line: #d9e1dc;
  --accent: #0f766e;
  --accent-2: #b7412f;
  --accent-3: #2f5ea8;
  --soft: #e3efe9;
  --warn: #fff4d7;
  --shadow: 0 18px 45px rgba(34, 49, 46, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(244, 246, 243, 0.92), rgba(235, 240, 237, 0.96)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%23cbd8d2' stroke-width='1'%3E%3Cpath d='M0 80h160M80 0v160'/%3E%3C/g%3E%3C/svg%3E");
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 16px;
  background: #16211f;
  color: #f6fbf8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #dff8ee;
  color: #0e695f;
  font-weight: 800;
}

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

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

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

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: #d9e7e2;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #263532;
  color: #ffffff;
}

.workspace {
  padding: 24px;
}

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

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

h1 {
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.1;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 17px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.topbar p {
  margin-top: 8px;
}

.status-strip,
.action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.tool-card .action-row {
  margin-top: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
}

.pill.good {
  color: #0f665e;
  border-color: #b7dad2;
  background: #e8f7f2;
}

.pill.warn {
  color: #8a5a00;
  border-color: #ead28b;
  background: var(--warn);
}

.panel {
  display: none;
  animation: fadeIn 0.18s ease-out;
}

.panel.active {
  display: block;
}

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

.section-head p {
  margin-top: 7px;
}

.two-col,
.editor-grid,
.notebook-layout,
.prompt-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.tool-card,
.candidate,
.template-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.phone-preview {
  display: grid;
  gap: 12px;
  max-width: 420px;
  min-height: 430px;
  border: 1px solid #cbd8d2;
  border-radius: 24px;
  padding: 14px;
  background: #101816;
  color: #f6fbf8;
}

.phone-bar {
  justify-self: center;
  min-width: 138px;
  border-radius: 999px;
  padding: 7px 12px;
  background: #24322f;
  color: #dbe8e3;
  text-align: center;
  font-size: 13px;
}

.phone-preview textarea {
  border-color: #33433f;
  background: #f6fbf8;
}

.transfer-assets {
  display: grid;
  gap: 8px;
  min-height: 96px;
  border: 1px dashed #526560;
  border-radius: 8px;
  padding: 10px;
  color: #c4d4cf;
}

.transfer-chip {
  display: grid;
  gap: 3px;
  border-radius: 8px;
  padding: 10px;
  background: #24322f;
}

.transfer-chip span {
  color: #aebfba;
  font-size: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: #34413e;
  font-size: 14px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fbfdfc;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #73b8ae;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.tool-card > label + label,
.tool-card > textarea + label,
.tool-card > input + label,
.tool-card > .form-grid + label,
.tool-card > .notice {
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
}

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

.primary-button:hover {
  background: #0b625b;
}

.secondary-button {
  border: 1px solid #b9d2cb;
  color: #0f665e;
  background: #e8f7f2;
}

.ghost-button {
  border: 1px solid var(--line);
  color: #34413e;
  background: var(--panel);
}

.danger {
  color: #a63224;
  border-color: #e2b2a9;
}

.full {
  width: 100%;
  margin-top: 14px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: #6a342d;
  background: #fae7e2;
}

.notice {
  border-left: 4px solid var(--accent-3);
  padding: 10px 12px;
  border-radius: 6px;
  background: #edf3ff;
  color: #41516b;
  line-height: 1.5;
}

.result-box {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 230px;
  border: 1px dashed #b7c6c0;
  border-radius: 8px;
  padding: 14px;
  background: var(--panel-2);
  color: #45524f;
  line-height: 1.55;
}

.result-box.tall {
  min-height: 360px;
}

.demo-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.demo-panel h3 {
  margin-bottom: 12px;
}

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

.demo-card {
  display: grid;
  gap: 8px;
  min-height: 104px;
  border: 1px solid #bed8d1;
  border-radius: 8px;
  padding: 14px;
  background: #f5fbf8;
  color: var(--ink);
  text-align: left;
}

.demo-card:hover {
  border-color: #72b7ad;
  background: #e8f7f2;
}

.demo-card span {
  color: var(--muted);
  line-height: 1.45;
}

.upload-zone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 170px;
  border: 2px dashed #adc6be;
  border-radius: 8px;
  background: #f9fcfa;
  text-align: center;
  margin-bottom: 16px;
}

.upload-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-zone strong,
.upload-zone span {
  display: block;
}

.upload-zone span {
  margin-top: 8px;
  color: var(--muted);
}

.asset-grid,
.image-board,
.frame-list,
.queue-list,
.candidate-list {
  display: grid;
  gap: 12px;
}

.asset-grid,
.image-board {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.asset-card,
.image-card,
.queue-item,
.frame-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.asset-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
}

.asset-thumb,
.image-thumb {
  overflow: hidden;
  border-radius: 6px;
  background: linear-gradient(135deg, #dbe9e4, #f5e5cf 48%, #cbdcf4);
}

.asset-thumb {
  width: 74px;
  height: 74px;
}

.asset-thumb img,
.asset-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.asset-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

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

.form-grid.wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 0;
}

.candidate {
  display: grid;
  gap: 10px;
}

.candidate h3 {
  color: #0f665e;
}

.candidate textarea {
  min-height: 168px;
}

.candidate-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.image-card {
  overflow: hidden;
}

.image-thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  color: #ffffff;
  font-size: 42px;
  font-weight: 800;
}

.image-card-body {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8e5;
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

#videoPreview {
  width: 100%;
  min-height: 220px;
  margin-top: 12px;
  border-radius: 8px;
  background: #121615;
}

.frame-list {
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  margin-top: 14px;
}

.frame-chip {
  display: grid;
  place-items: center;
  min-height: 74px;
  color: #40514d;
  background: #edf4f1;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

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

.metrics strong {
  font-size: 25px;
}

.metrics span {
  margin-top: 5px;
  color: var(--muted);
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.queue-item span {
  color: var(--muted);
  font-size: 13px;
}

.queue-state {
  justify-self: end;
  border-radius: 999px;
  padding: 6px 10px;
  color: #0f665e;
  background: #e8f7f2;
  font-size: 13px;
  font-weight: 700;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

  .brand {
    padding-bottom: 12px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .nav-item {
    text-align: center;
  }

  .topbar,
  .section-head {
    display: grid;
  }

  .two-col,
  .editor-grid,
  .notebook-layout,
  .prompt-grid,
  .demo-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .form-grid,
  .form-grid.wide,
  .metrics {
    grid-template-columns: 1fr;
  }

  .asset-grid,
  .image-board {
    grid-template-columns: 1fr;
  }

  .queue-item {
    grid-template-columns: 1fr;
  }

  .queue-state {
    justify-self: start;
  }
}
