:root {
  color-scheme: light;
  --ink: #17202a;
  --body: #344054;
  --muted: #667085;
  --line: #d8dee8;
  --line-strong: #c3ccd9;
  --surface: #ffffff;
  --soft: #f5f7fa;
  --paper: #fbfaf7;
  --teal: #16756f;
  --teal-deep: #0c5752;
  --coral: #d95d48;
  --gold: #c58b2b;
  --blue: #365f91;
  --shadow: 0 20px 54px rgba(25, 35, 48, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(245, 247, 250, 0.88), rgba(239, 242, 246, 0.9)),
    repeating-linear-gradient(90deg, rgba(23, 32, 42, 0.025) 0, rgba(23, 32, 42, 0.025) 1px, transparent 1px, transparent 56px);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.app-shell {
  width: min(1540px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 520px);
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.16;
}

h2 {
  font-size: 18px;
  line-height: 1.24;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-pane,
.preview-pane {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.control-pane {
  position: sticky;
  top: 22px;
  display: grid;
  gap: 18px;
  padding: 18px;
}

.preview-pane {
  min-height: calc(100vh - 104px);
  padding: 20px;
}

.brief-form,
.form-block,
.source-panel,
.copy-panel {
  display: grid;
  gap: 14px;
}

.form-block {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.form-block-primary {
  gap: 10px;
}

.block-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

label {
  display: grid;
  gap: 7px;
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

select {
  appearance: auto;
}

textarea {
  min-height: 210px;
  resize: vertical;
  padding: 13px;
  color: var(--body);
  line-height: 1.68;
}

input::placeholder,
textarea::placeholder {
  color: #98a2b3;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(22, 117, 111, 0.13);
}

.primary-submit,
.download-actions button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 6px;
  font-weight: 900;
}

.primary-submit {
  width: 100%;
  background: var(--ink);
  color: #fff;
}

.primary-submit:hover:not(:disabled) {
  background: #263241;
}

.button-icon {
  font-size: 17px;
  line-height: 1;
}

.status {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(197, 139, 43, 0.34);
  border-radius: var(--radius);
  background: #fff8eb;
  color: #725322;
  line-height: 1.45;
}

.status.error {
  border-color: rgba(217, 93, 72, 0.34);
  background: #fff3f0;
  color: #8a3d2f;
}

.status.success {
  border-color: rgba(22, 117, 111, 0.32);
  background: #eef9f7;
  color: var(--teal-deep);
}

.source-panel {
  padding-top: 2px;
}

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

.preview-toolbar {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

#card-summary {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.download-actions button {
  min-width: 108px;
  padding: 0 14px;
  border: 1px solid rgba(22, 117, 111, 0.18);
  background: #eef9f7;
  color: var(--teal-deep);
}

.download-actions button:last-child {
  border-color: rgba(217, 93, 72, 0.2);
  background: #fff3f0;
  color: #963f30;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 18px;
}

dl {
  display: grid;
  gap: 9px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 0;
  min-width: 0;
  color: var(--body);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

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

.xhs-card {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid #e6dfd2;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 14px 30px rgba(25, 35, 48, 0.08);
}

.xhs-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(23, 32, 42, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(23, 32, 42, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.5;
}

.xhs-card::after {
  content: "";
  position: absolute;
  inset: auto 18px 18px 18px;
  height: 1px;
  background: rgba(23, 32, 42, 0.12);
}

.card-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  padding: 20px;
}

.card-kicker {
  width: fit-content;
  max-width: 100%;
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.card-title {
  font-size: clamp(22px, 2.4vw, 31px);
  line-height: 1.14;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.card-body {
  align-self: start;
  color: var(--body);
  font-size: clamp(14px, 1.25vw, 16px);
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.card-accent {
  margin-top: auto;
  color: var(--teal-deep);
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-image {
  flex: 0 0 120px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.card-image-fallback {
  display: grid;
  align-content: space-between;
  padding: 15px;
  background:
    linear-gradient(90deg, rgba(22, 117, 111, 0.16), transparent 58%),
    linear-gradient(0deg, rgba(197, 139, 43, 0.18), transparent 52%),
    #fefefe;
}

.card-image-fallback span {
  color: var(--ink);
  font-size: 30px;
  font-weight: 900;
}

.card-image-fallback strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.24;
  overflow-wrap: anywhere;
}

.card-bullets {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card-bullets li {
  padding: 9px 10px;
  border-left: 4px solid var(--coral);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--body);
  line-height: 1.38;
}

.xhs-card[data-type="cover"] {
  background: #f6efe2;
}

.xhs-card[data-type="quote"] {
  background: #eaf4f1;
}

.xhs-card[data-type="warning"] {
  background: #fff0eb;
}

.xhs-card[data-type="summary"] {
  background: #eef2f8;
}

.xhs-card[data-layout="image-hero"] .card-image {
  flex-basis: 42%;
  margin: -20px -20px 2px;
  border-radius: 0;
}

.xhs-card[data-layout="image-hero"] .card-title {
  font-size: clamp(25px, 3vw, 37px);
}

.xhs-card[data-layout="split"] .card-image {
  order: 3;
}

.xhs-card[data-layout="text-focus"] .card-title,
.xhs-card[data-layout="quote-focus"] .card-title {
  margin-top: auto;
  margin-bottom: 4px;
}

.xhs-card[data-layout="quote-focus"] .card-title {
  font-size: clamp(24px, 3vw, 36px);
}

.xhs-card[data-layout="quote-focus"] .card-title::before {
  content: "“";
  display: block;
  color: var(--coral);
  font-size: 54px;
  line-height: 0.72;
}

.xhs-card[data-layout="checklist"] .card-bullets li {
  border-left-color: var(--teal);
}

.xhs-card[data-layout="warning"] .card-kicker {
  background: var(--coral);
}

.xhs-card[data-layout="summary"] .card-accent {
  color: var(--blue);
}

.empty-state {
  grid-column: 1 / -1;
  min-height: 430px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(22, 117, 111, 0.08), transparent 42%),
    linear-gradient(0deg, rgba(217, 93, 72, 0.08), transparent 46%),
    #fff;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.copy-panel {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.title-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.title-pill {
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--body);
  font-weight: 800;
  line-height: 1.42;
  text-align: left;
}

.title-pill:hover {
  border-color: var(--teal);
  color: var(--teal-deep);
}

@media (max-width: 1080px) {
  .app-header,
  .workbench {
    grid-template-columns: 1fr;
  }

  .control-pane {
    position: static;
  }

  .preview-pane {
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px;
  }

  .app-header {
    gap: 12px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  h1 {
    font-size: 23px;
  }

  .control-pane,
  .preview-pane {
    padding: 14px;
  }

  .options-row,
  dl div {
    grid-template-columns: 1fr;
  }

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

  .download-actions {
    width: 100%;
  }

  .download-actions button {
    flex: 1;
    min-width: 0;
  }

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

  .title-options {
    grid-template-columns: 1fr;
  }
}
