:root {
  --bg: #f5f4f0;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(38, 48, 76, 0.1);
  --text: #1f2842;
  --muted: #66708a;
  --accent: #202e57;
  --accent-soft: rgba(54, 102, 255, 0.08);
  --shadow: 0 28px 72px rgba(50, 65, 102, 0.12);
  --radius: 0px;
  --ui-radius-lg: 14px;
  --ui-radius-md: 10px;
  --ui-radius-sm: 8px;
  --poster-width: min(100%, 420px);
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC",
    sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 196, 120, 0.18), transparent 24%),
    radial-gradient(circle at top right, rgba(117, 227, 205, 0.16), transparent 20%),
    linear-gradient(180deg, #fbfbfd 0%, #f2f3f8 100%);
}

body {
  padding: 28px 20px 48px;
}

button,
input,
textarea {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1220px, 100%);
  margin: 0 auto;
}

.hero {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-bottom: 28px;
  text-align: center;
}

.hero__eyebrow {
  display: inline-flex;
  width: fit-content;
  padding: 10px 16px;
  border-radius: var(--ui-radius-md);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(32, 46, 87, 0.1);
  backdrop-filter: blur(12px);
}

.hero h1 {
  margin: 0;
  font: 700 clamp(34px, 5vw, 58px) / 1.08 var(--serif);
  letter-spacing: 0.01em;
}

.hero p {
  max-width: 680px;
  margin: 0;
  font-size: 15px;
  line-height: 1.75;
  color: var(--muted);
}

.app-shell {
  display: grid;
  gap: 24px;
}

.gallery-view {
  display: grid;
  gap: 20px;
}

.gallery-head {
  display: flex;
  justify-content: center;
}

.filter-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.filter-chip {
  appearance: none;
  border: 1px solid rgba(31, 40, 66, 0.1);
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  border-radius: var(--ui-radius-md);
  padding: 11px 18px;
  font: 600 14px/1 var(--sans);
  cursor: pointer;
  transition:
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

.filter-chip:hover,
.filter-chip:focus-visible {
  outline: none;
  transform: translateY(-1px);
  border-color: rgba(32, 46, 87, 0.18);
  box-shadow: 0 12px 24px rgba(50, 65, 102, 0.08);
}

.filter-chip.is-active {
  color: #fff;
  background: linear-gradient(135deg, #212f58 0%, #3d64d3 100%);
  border-color: transparent;
  box-shadow: 0 16px 30px rgba(61, 100, 211, 0.24);
}

.template-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(182px, 1fr));
  gap: 20px;
  align-items: start;
}

.template-grid__empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 18px;
  border-radius: var(--ui-radius-lg);
  border: 1px dashed rgba(31, 40, 66, 0.14);
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.template-card {
  appearance: none;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  gap: 10px;
  text-align: left;
  transition: transform 180ms ease;
}

.template-card:hover,
.template-card:focus-visible {
  outline: none;
  transform: translateY(-4px);
}

.template-card__poster {
  position: relative;
  border-radius: 0;
  padding: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(243, 245, 251, 0.8));
  box-shadow: 0 18px 40px rgba(50, 65, 102, 0.1);
  transition:
    box-shadow 180ms ease,
    transform 180ms ease;
}

.template-card__preview {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(250, 251, 255, 0.96), rgba(240, 243, 250, 0.92)),
    linear-gradient(135deg, rgba(61, 100, 211, 0.08), rgba(61, 100, 211, 0));
}

.template-card__image,
.template-card__image-fallback {
  display: block;
  width: 100%;
  height: 100%;
}

.template-card__image {
  object-fit: cover;
}

.template-card__image-fallback {
  background:
    radial-gradient(circle at top left, rgba(61, 100, 211, 0.18), transparent 52%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(235, 239, 248, 0.96));
}

.template-card.is-active .template-card__poster {
  box-shadow: 0 24px 48px rgba(48, 77, 159, 0.18);
}

.template-card__poster::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0;
  border: 2px solid transparent;
  transition: border-color 180ms ease;
  pointer-events: none;
}

.template-card:hover .template-card__poster::after,
.template-card:focus-visible .template-card__poster::after,
.template-card.is-active .template-card__poster::after {
  border-color: rgba(61, 100, 211, 0.2);
}

.template-card__meta {
  display: grid;
  gap: 4px;
  padding: 0 4px;
}

.template-card__meta strong {
  font-size: 15px;
  line-height: 1.35;
}

.template-card__meta span {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

.template-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.template-card__tag {
  width: fit-content;
  padding: 5px 10px;
  border-radius: var(--ui-radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #28438a;
  background: rgba(61, 100, 211, 0.08);
}

.editor-view {
  display: grid;
  gap: 18px;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
  background: var(--panel);
  border: 1px solid rgba(31, 40, 66, 0.08);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.editor-toolbar__meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
}

.editor-toolbar__label {
  width: fit-content;
  justify-self: end;
  padding: 5px 10px;
  border-radius: var(--ui-radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #28438a;
  background: rgba(61, 100, 211, 0.08);
}

.editor-toolbar__meta strong {
  font-size: 22px;
}

.editor-toolbar__meta p {
  margin: 0;
  max-width: 420px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

.editor-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel,
.stage {
  background: var(--panel);
  border: 1px solid rgba(31, 40, 66, 0.08);
  border-radius: var(--ui-radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.panel {
  padding: 22px;
  display: grid;
  gap: 20px;
  position: sticky;
  top: 24px;
}

.stage {
  padding: 26px;
  display: grid;
  gap: 20px;
  min-height: calc(100vh - 180px);
  justify-items: center;
  align-content: start;
}

.section {
  display: grid;
  gap: 12px;
}

.section__title {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.fields {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--ui-radius-md);
  border: 1px solid rgba(31, 40, 66, 0.12);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  resize: vertical;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(61, 100, 211, 0.26);
  box-shadow: 0 0 0 4px rgba(61, 100, 211, 0.1);
  background: #fff;
}

.field textarea {
  min-height: 102px;
}

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

.button {
  appearance: none;
  border: none;
  border-radius: var(--ui-radius-md);
  padding: 13px 18px;
  cursor: pointer;
  font: 600 14px/1 var(--sans);
  letter-spacing: 0.02em;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    opacity 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  outline: none;
}

.button--primary {
  color: #fff;
  background: linear-gradient(135deg, #212f58 0%, #3d64d3 100%);
  box-shadow: 0 18px 30px rgba(61, 100, 211, 0.26);
}

.button--secondary,
.button--ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(31, 40, 66, 0.1);
}

.button--ghost {
  padding-inline: 16px;
}

.tips {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.stage__meta {
  width: min(100%, 640px);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.stage__meta strong {
  color: var(--text);
  font-weight: 600;
}

.cover-wrap {
  width: 100%;
  display: grid;
  place-items: center;
  padding: 8px 0 0;
}

.cover {
  position: relative;
  width: var(--poster-width);
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 0 !important;
  color: var(--cover-text, #2d2218);
  background: var(--cover-bg, #f7efe6);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 36px 64px rgba(72, 42, 18, 0.18);
  isolation: isolate;
  animation: poster-in 420ms ease;
}

.cover::before,
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cover::before {
  background: var(--cover-overlay, transparent);
  opacity: 0.85;
}

.cover::after {
  background: var(--cover-noise, transparent);
  mix-blend-mode: multiply;
  opacity: 0.5;
}

.cover[data-export-mode="true"]::before,
.cover[data-export-mode="true"]::after {
  content: none;
  background: none;
}

.cover__export-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cover__frame {
  position: absolute;
  inset: 16px;
  border: 1px solid var(--frame-line, rgba(99, 67, 44, 0.16));
  border-radius: 0 !important;
}

.cover__accent,
.cover__seal,
.cover__leaf,
.cover__ring,
.cover__number {
  position: absolute;
  pointer-events: none;
}

.cover__number {
  display: none !important;
}

.cover__body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 42px 34px 34px;
}

.cover__top,
.cover__bottom {
  display: grid;
  gap: 14px;
}

.cover__eyebrow {
  width: fit-content;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid var(--pill-line, rgba(140, 98, 62, 0.24));
  background: var(--pill-bg, rgba(255, 252, 247, 0.42));
  color: var(--pill-text, inherit);
  backdrop-filter: blur(8px);
}

.cover__title {
  display: grid;
  gap: 4px;
  margin: 0;
  max-width: 100%;
  font-family: var(--title-font, var(--serif));
  font-size: clamp(42px, 6.1vw, 64px);
  line-height: 1.08;
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  word-break: break-word;
}

.cover__title-line {
  display: block;
}

.cover__subtitle {
  max-width: 80%;
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--cover-muted, rgba(51, 40, 31, 0.72));
}

.cover__note {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--divider, rgba(100, 70, 48, 0.14));
  font-size: 13px;
  line-height: 1.7;
  color: var(--cover-muted, rgba(51, 40, 31, 0.72));
}

.cover__meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.cover__index,
.cover__tag {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cover-muted, rgba(51, 40, 31, 0.72));
}

.cover__tag {
  padding-bottom: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes poster-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

  .panel {
    position: static;
  }

  .stage {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  body {
    padding: 18px 14px 28px;
  }

  .hero {
    justify-items: start;
    text-align: left;
  }

  .gallery-head {
    justify-content: flex-start;
  }

  .filter-grid {
    justify-content: flex-start;
  }

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

  .editor-toolbar {
    padding: 18px;
    flex-direction: column;
    align-items: stretch;
  }

  .editor-toolbar__meta {
    justify-items: start;
    text-align: left;
  }

  .editor-toolbar__label {
    justify-self: start;
  }

  .panel,
  .stage {
    border-radius: var(--ui-radius-lg);
  }

  .panel,
  .stage {
    padding: 18px;
  }

  .stage__meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .cover {
    width: min(100%, 360px);
  }

  .cover__body {
    padding: 32px 24px 24px;
  }

  .cover__title {
    font-size: clamp(34px, 9vw, 54px);
  }

  .cover__subtitle,
  .cover__note {
    max-width: 100%;
  }
}
