@font-face {
  font-family: "Xibao Sans";
  src: url("NotoSansSC-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
}

:root {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #2b1112;
  background: #f6eee9;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 4%, rgba(255, 218, 145, .55), transparent 28rem),
    linear-gradient(135deg, #fffaf4 0%, #f5e5dd 100%);
}

button, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1440px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-columns: minmax(360px, 480px) minmax(540px, 1fr);
  overflow: hidden;
  background: rgba(255, 255, 255, .88);
  border: 1px solid rgba(132, 26, 28, .12);
  border-radius: 24px;
  box-shadow: 0 22px 70px rgba(86, 20, 22, .16);
  backdrop-filter: blur(12px);
}

.editor-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  padding: 28px;
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(255,248,244,.96));
  border-right: 1px solid rgba(132, 26, 28, .1);
}

.brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 15px;
  color: #fff2b8;
  font-family: STKaiti, KaiTi, serif;
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(145deg, #e43225, #9d0710);
  box-shadow: inset 0 0 0 2px rgba(255, 222, 130, .42), 0 8px 20px rgba(151, 14, 20, .22);
}
.brand-row h1 { margin: 0; font-size: 24px; letter-spacing: .04em; }
.brand-row p { margin: 4px 0 0; color: #866567; font-size: 14px; }

.input-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.input-heading label, .list-title { font-size: 15px; font-weight: 700; }
.input-actions { display: flex; gap: 4px; }
.text-button {
  padding: 6px 8px;
  border: 0;
  color: #a21318;
  background: transparent;
  font-size: 14px;
  border-radius: 8px;
}
.text-button:hover { background: #fff0eb; }
.text-button.muted { color: #8b7777; }

textarea {
  width: 100%;
  min-height: 250px;
  margin-top: 10px;
  padding: 16px;
  resize: vertical;
  border: 1px solid #ddc8c1;
  border-radius: 14px;
  outline: none;
  color: #311516;
  background: #fff;
  line-height: 1.75;
  box-shadow: inset 0 1px 3px rgba(70, 23, 23, .04);
}
textarea:focus { border-color: #bc272c; box-shadow: 0 0 0 3px rgba(188, 39, 44, .1); }
.format-hint { margin: 8px 2px 0; color: #8d7473; font-size: 13px; }

.status-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.status-pill { padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 650; }
.status-pill.ok { color: #287343; background: #e9f7ed; }
.status-pill.error { color: #a3151b; background: #ffe8e6; }

.entry-list-wrap { display: flex; min-height: 160px; flex: 1; flex-direction: column; }
.entry-list { margin-top: 10px; overflow: auto; padding-right: 4px; }
.entry-item {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #493032;
  background: transparent;
  text-align: left;
}
.entry-item:hover { background: #fff3ef; }
.entry-item.active { border-color: #e6b7ab; background: #fff0eb; }
.entry-item.invalid { color: #9d252a; background: #fff1ef; }
.entry-index { color: #ad8c87; font-variant-numeric: tabular-nums; }
.entry-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-amount { color: #a30d14; font-weight: 750; }
.entry-reason { grid-column: 2 / 4; color: #a3151b; font-size: 12px; }

.preview-panel {
  min-width: 0;
  padding: 26px 32px 30px;
  background:
    radial-gradient(circle at 90% 5%, rgba(244, 189, 91, .24), transparent 30rem),
    linear-gradient(150deg, #3a1013 0%, #21080b 100%);
  color: #fff;
}
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.eyebrow { margin-bottom: 5px; color: #cfa9a5; font-size: 12px; letter-spacing: .12em; }
.current-title { min-height: 25px; font-size: 18px; font-weight: 700; }
.pager { display: flex; align-items: center; gap: 10px; color: #dcc6c3; font-size: 14px; }
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  color: #fff;
  background: rgba(255,255,255,.07);
  font-size: 25px;
  line-height: 1;
}
.icon-button:hover:not(:disabled) { background: rgba(255,255,255,.15); }
.icon-button:disabled { opacity: .35; cursor: default; }

.canvas-stage {
  position: relative;
  display: grid;
  width: 100%;
  height: min(69vh, 780px);
  min-height: 480px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 225, 174, .2);
  border-radius: 18px;
  background:
    linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%) 0 0 / 22px 22px,
    linear-gradient(-45deg, rgba(255,255,255,.025) 25%, transparent 25%) 0 0 / 22px 22px,
    #160507;
  box-shadow: inset 0 0 50px rgba(0,0,0,.35);
}
canvas { display: block; width: auto; height: calc(100% - 28px); min-width: 0; min-height: 0; border-radius: 8px; box-shadow: 0 18px 46px rgba(0,0,0,.42); }
.empty-preview { position: absolute; display: grid; gap: 8px; place-items: center; color: #e3cbc6; }
.empty-preview small { color: #987d7d; }

.download-row { display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; margin-top: 18px; }
.secondary-button, .primary-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 750;
}
.secondary-button { border: 1px solid rgba(255,255,255,.22); color: #fff; background: rgba(255,255,255,.08); }
.primary-button { border: 0; color: #4b1904; background: linear-gradient(135deg, #ffe7a1, #efb83f); box-shadow: 0 8px 24px rgba(226, 164, 49, .22); }
.secondary-button:hover:not(:disabled) { background: rgba(255,255,255,.14); }
.primary-button:hover:not(:disabled) { filter: brightness(1.04); }
.secondary-button:disabled, .primary-button:disabled { opacity: .42; cursor: default; }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: #cdb7b5; font-size: 13px; }
.progress-bar { flex: 1; height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.1); }
.progress-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f2b83e, #ffe9a3); transition: width .2s ease; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; width: min(720px, calc(100% - 20px)); margin: 10px auto; }
  .editor-panel { border-right: 0; border-bottom: 1px solid rgba(132, 26, 28, .1); }
  .entry-list-wrap { max-height: 300px; }
  .canvas-stage { height: 72vh; }
}

@media (max-width: 560px) {
  .editor-panel, .preview-panel { padding: 20px 16px; }
  textarea { min-height: 210px; }
  .download-row { grid-template-columns: 1fr; }
  .canvas-stage { min-height: 420px; }
}
