:root {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  color: #271a18;
  background: #f4f0e8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.template-card:disabled {
  cursor: default;
  opacity: 1;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(177, 22, 28, 0.08), transparent 34%),
    linear-gradient(180deg, #fffdf8 0%, #e8edf0 100%);
}

.control-panel,
.preview-panel {
  border: 1px solid rgba(91, 51, 38, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 20px 70px rgba(81, 49, 34, 0.12);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: calc(100vh - 48px);
  padding: 24px;
}

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

.brand-mark {
  width: 58px;
  height: 58px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: #fff4cf;
  background: linear-gradient(145deg, #b7141a, #e34227);
  font-size: 32px;
  font-weight: 900;
  box-shadow: 0 12px 32px rgba(178, 20, 26, 0.28);
}

.eyebrow {
  margin: 0 0 4px;
  color: #805f22;
  font-size: 13px;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.2;
}

.upload-card,
.template-section,
.status-card {
  border-radius: 8px;
  border: 1px solid rgba(91, 51, 38, 0.12);
  background: #fffaf1;
  padding: 16px;
}

.upload-zone {
  min-height: 112px;
  display: grid;
  place-items: center;
  gap: 8px;
  border: 1.5px dashed rgba(178, 20, 26, 0.45);
  border-radius: 8px;
  color: #9f1419;
  background: linear-gradient(180deg, #fff8e8, #fffdf7);
  font-weight: 800;
}

.upload-zone input {
  display: none;
}

.upload-icon {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #fff7d8;
  background: #b7141a;
  font-size: 22px;
}

.ghost-button,
.primary-button,
.secondary-button,
.preview-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(151, 65, 30, 0.18);
  background: #fffdf7;
  color: #793016;
  font-weight: 800;
}

.ghost-button {
  width: 100%;
  margin-top: 12px;
}

.primary-button {
  min-height: 52px;
  border: none;
  color: #fff7d8;
  background: linear-gradient(135deg, #af1218, #e04327);
  box-shadow: 0 16px 30px rgba(175, 18, 24, 0.26);
}

.secondary-button {
  min-height: 52px;
  color: #8b191d;
  background: #fff6df;
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.55;
  box-shadow: none;
}

.export-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.file-name {
  margin: 12px 0 0;
  color: #66412c;
  font-size: 13px;
  line-height: 1.5;
}

.muted {
  color: #8b7d70;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: #8b2a16;
}

.template-grid {
  display: grid;
  gap: 10px;
}

.template-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 4px;
  width: 100%;
  min-height: 84px;
  padding: 10px;
  text-align: left;
  border: 1px solid rgba(91, 51, 38, 0.13);
  border-radius: 8px;
  background: #fffdf7;
  color: #321a13;
}

.template-card.selected {
  border-color: #b7141a;
  box-shadow: 0 0 0 3px rgba(183, 20, 26, 0.1);
}

.template-thumb {
  grid-row: 1 / 3;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  border: 1px solid rgba(255, 228, 150, 0.52);
}

.template-card strong {
  font-size: 15px;
}

.template-card small {
  color: #75695f;
  line-height: 1.35;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric-row span {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 8px;
  background: #f5f7f5;
  color: #65706a;
  font-size: 12px;
}

.metric-row strong {
  color: #9f1419;
  font-size: 20px;
}

.preview-panel {
  min-width: 0;
  min-height: calc(100vh - 48px);
  padding: 22px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

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

.preview-actions button {
  padding: 0 16px;
}

.preview-body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(240px, 320px);
  gap: 18px;
}

.poster-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(45deg, rgba(70, 81, 82, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(70, 81, 82, 0.08) 25%, transparent 25%),
    #edf0ee;
  background-size: 22px 22px;
}

#previewCanvas {
  width: min(100%, 560px, calc((100vh - 150px) * 997 / 1577));
  max-height: calc(100vh - 140px);
  aspect-ratio: 997 / 1577;
  object-fit: contain;
  box-shadow: 0 22px 54px rgba(42, 31, 27, 0.2);
}

.row-list {
  min-height: 0;
  max-height: calc(100vh - 140px);
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding-right: 4px;
}

.row-item {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(91, 51, 38, 0.12);
  background: #fffdf7;
  text-align: left;
  color: #321a13;
}

.row-item.active {
  border-color: #b7141a;
  box-shadow: 0 0 0 3px rgba(183, 20, 26, 0.1);
}

.row-item.invalid {
  border-color: rgba(183, 20, 26, 0.45);
  background: #fff3ee;
}

.row-item span,
.row-item small,
.empty-list {
  color: #75695f;
}

.row-item strong {
  line-height: 1.35;
}

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

  .control-panel,
  .preview-panel {
    min-height: auto;
  }

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

  .row-list {
    max-height: 360px;
  }
}
