:root {
  --paper: #f5efe3;
  --paper-deep: #e9dfcf;
  --ink: #24211d;
  --muted: #766f65;
  --line: rgba(55, 47, 38, .14);
  --white: #fffdf8;
  --red: #b33a2e;
  --red-dark: #84281f;
  --gold: #c7923b;
  --green: #3d6b55;
  --shadow: 0 18px 45px rgba(59, 48, 35, .09);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 5%, rgba(199, 146, 59, .11), transparent 26rem),
    radial-gradient(circle at 92% 35%, rgba(179, 58, 46, .07), transparent 30rem),
    var(--paper);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

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

.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .16;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.2'/%3E%3C/svg%3E");
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 10px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(245, 239, 227, .9);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark, .gate-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px 13px 13px 4px;
  color: #fff7e9;
  background: var(--red);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 24px;
  box-shadow: 0 8px 20px rgba(179, 58, 46, .25);
}

.brand strong { display: block; font-size: 16px; letter-spacing: .04em; }
.brand small { color: var(--muted); font-size: 10px; letter-spacing: .14em; }

.connection { display: flex; align-items: center; gap: 8px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 248, .7);
  font-size: 11px;
}

.status-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a19a91;
}

.status-pill.is-ok i { background: #3d8b68; box-shadow: 0 0 0 4px rgba(61, 139, 104, .12); }
.status-pill.is-error i { background: var(--red); box-shadow: 0 0 0 4px rgba(179, 58, 46, .1); }

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
}

.workspace {
  width: min(1860px, 100%);
  margin: 0 auto;
  padding: 44px clamp(16px, 3vw, 52px) 70px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .7fr);
  gap: 50px;
  align-items: end;
  max-width: 1240px;
  margin: 0 auto 34px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--red);
  font: 700 10px/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .22em;
}

.hero h1 {
  margin: 0;
  font-family: "STSong", "SimSun", serif;
  font-size: clamp(42px, 6.5vw, 86px);
  font-weight: 600;
  line-height: .97;
  letter-spacing: -.06em;
}

.hero h1 em { color: var(--red); font-style: normal; }

.hero-copy {
  margin: 0 0 8px;
  padding-left: 22px;
  border-left: 2px solid var(--gold);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}

.steps {
  display: flex;
  width: fit-content;
  margin: 0 auto 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, .52);
}

.step {
  border: 0;
  border-radius: 999px;
  padding: 8px 15px;
  cursor: pointer;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.step span { margin-right: 5px; font-family: ui-monospace, monospace; font-size: 9px; }
.step.is-active { color: #fff; background: var(--ink); }

.desk {
  display: grid;
  grid-template-columns: minmax(300px, .82fr) minmax(440px, 1.45fr) minmax(290px, .72fr);
  gap: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, .82);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading > div:first-child { display: flex; gap: 10px; align-items: baseline; }
.panel-heading h2 { margin: 0; font-family: "STSong", "SimSun", serif; font-size: 23px; }
.panel-no { color: var(--red); font: 700 10px/1 ui-monospace, monospace; }
.panel-note { color: var(--muted); font-size: 10px; }

fieldset { min-width: 0; margin: 0 0 20px; padding: 0; border: 0; }
legend, .field > span { margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; }

.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.topic-card {
  min-height: 86px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  background: var(--white);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.topic-card:hover { transform: translateY(-2px); box-shadow: 0 10px 18px rgba(55, 47, 38, .08); }
.topic-card.is-selected { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.topic-card span { display: block; margin-bottom: 7px; color: var(--red); font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.topic-card strong { display: block; font-size: 12px; line-height: 1.45; }

.field { display: flex; min-width: 0; flex-direction: column; margin-bottom: 15px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, .7);
  transition: border-color .15s, box-shadow .15s;
}

input, select { min-height: 42px; padding: 0 12px; }
textarea { padding: 11px 12px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(199, 146, 59, .12); }

.primary-action, .publish-action, .draft-action, .secondary-action, .upload-button {
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 700;
}

.primary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 11px 16px;
  color: #fffaf1;
  background: var(--ink);
  box-shadow: 0 12px 25px rgba(36, 33, 29, .18);
}

.primary-action:hover { background: #11100e; }
.primary-action small, .publish-action small { display: block; margin-top: 3px; opacity: .65; font-size: 9px; font-weight: 500; }
.primary-action.compact { min-height: 48px; }
.action-icon { color: #e8bd6b; font-size: 24px; }

.editor-panel { min-height: 760px; }
.editor-actions { display: flex; gap: 6px; }
.text-button { padding: 5px 7px; border: 0; cursor: pointer; color: var(--muted); background: transparent; font-size: 10px; }
.text-button:hover { color: var(--red); }

.empty-state {
  display: grid;
  place-items: center;
  min-height: 620px;
  text-align: center;
  color: var(--muted);
}

.empty-state > * { max-width: 340px; }
.empty-state h3 { margin: 18px 0 6px; color: var(--ink); font: 600 24px/1.2 "STSong", "SimSun", serif; }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.7; }

.empty-visual {
  position: relative;
  width: 150px;
  height: 118px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  transform: rotate(-3deg);
  box-shadow: 12px 12px 0 var(--paper-deep);
}

.empty-visual span { display: block; height: 5px; margin: 18px 20px 0; border-radius: 9px; background: var(--paper-deep); }
.empty-visual span:nth-child(1) { width: 65%; background: var(--red); }
.empty-visual span:nth-child(2) { width: 78%; }
.empty-visual span:nth-child(3) { width: 52%; }

.is-hidden { display: none !important; }

.cover-workbench {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 14px;
  margin-bottom: 20px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}

.cover-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 2.35 / 1;
  border-radius: 11px;
  background: #d9d0c3;
}

.cover-frame img { display: none; width: 100%; height: 100%; object-fit: cover; }
.cover-frame.has-image img { display: block; }
.cover-frame.has-image .cover-placeholder { display: none; }

.cover-placeholder {
  display: grid;
  place-content: center;
  height: 100%;
  text-align: center;
  color: #7b7368;
  background: linear-gradient(135deg, #ded4c4, #c9bdab);
}
.cover-placeholder b { font-family: "STSong", serif; font-size: 20px; }
.cover-placeholder span { margin-top: 4px; font-size: 9px; }

.cover-controls .field { margin-bottom: 8px; }
.cover-controls textarea { min-height: 78px; font-size: 11px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button-row.end { justify-content: flex-end; }
.secondary-action, .upload-button { padding: 9px 12px; border: 1px solid var(--line); background: var(--white); font-size: 10px; }
.upload-button input { display: none; }

.article-title-field input {
  min-height: 52px;
  font: 600 22px/1.3 "STSong", "SimSun", serif;
}

.article-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  color: var(--muted);
  background: var(--paper);
  font-size: 9px;
}

.article-toolbar button { min-width: 29px; min-height: 26px; border: 0; border-radius: 6px; cursor: pointer; background: var(--white); font-size: 10px; }

.wechat-article {
  min-height: 520px;
  padding: clamp(20px, 5vw, 42px);
  border: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
  outline: 0;
  background: #fff;
  font-size: 15px;
  line-height: 1.9;
}

.wechat-article h2 {
  margin: 36px 0 18px;
  color: #1f2722;
  font-family: "STSong", "SimSun", serif;
  font-size: 22px;
  line-height: 1.4;
}

.wechat-article h2::before { content: ""; display: inline-block; width: 5px; height: 21px; margin-right: 9px; border-radius: 4px; vertical-align: -3px; background: var(--red); }
.wechat-article p { margin: 0 0 18px; text-align: justify; }
.wechat-article blockquote { margin: 24px 0; padding: 16px 18px; border-left: 3px solid var(--gold); color: #5f5548; background: #f7f1e7; }

.article-image {
  position: relative;
  overflow: hidden;
  margin: 24px 0 30px;
  border-radius: 10px;
  background: #eee8df;
}

.article-image img { display: block; width: 100%; min-height: 220px; object-fit: cover; }
.article-image .image-empty { display: grid; place-items: center; min-height: 240px; padding: 30px; text-align: center; color: var(--muted); background: linear-gradient(135deg, #eee7dc, #ddd2c3); font-size: 12px; }
.article-image .image-tools { position: absolute; right: 9px; bottom: 9px; display: flex; gap: 6px; }
.article-image .image-tools button { padding: 7px 10px; border: 0; border-radius: 8px; cursor: pointer; color: #fff; background: rgba(25, 23, 20, .78); font-size: 9px; backdrop-filter: blur(8px); }

.publish-panel { position: sticky; top: 88px; }
.publish-summary { margin-bottom: 18px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.summary-line { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 11px; }
.summary-line:last-child { border-bottom: 0; }
.summary-line span { color: var(--muted); }

.switch-list { margin: 12px 0 18px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch-row span { display: block; }
.switch-row strong { display: block; font-size: 11px; }
.switch-row small { color: var(--muted); font-size: 9px; }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row i { position: relative; flex: 0 0 36px; height: 21px; border-radius: 30px; background: #c9c2b8; transition: .2s; }
.switch-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: white; transition: .2s; }
.switch-row input:checked + i { background: var(--green); }
.switch-row input:checked + i::after { transform: translateX(15px); }

.publish-notice { margin-bottom: 16px; padding: 14px 16px; border-left: 3px solid var(--gold); border-radius: 0 11px 11px 0; color: #665d51; background: #f7f0e4; font-size: 10px; }
.publish-notice b { color: var(--ink); }
.publish-notice ol { margin: 8px 0 0; padding-left: 18px; line-height: 1.7; }

.draft-action { width: 100%; min-height: 43px; margin-bottom: 8px; border: 1px solid var(--line); background: var(--white); }
.publish-action { width: 100%; min-height: 58px; padding: 10px 16px; color: #fff8ee; background: var(--red); box-shadow: 0 12px 24px rgba(179, 58, 46, .22); }
.publish-action:hover { background: var(--red-dark); }
.publish-action.small { width: auto; min-height: 42px; padding: 9px 18px; }
.publish-action:disabled { cursor: not-allowed; opacity: .45; }

.publish-progress, .result-card { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.progress-head { display: flex; justify-content: space-between; font-size: 10px; }
.progress-track { overflow: hidden; height: 5px; margin: 9px 0; border-radius: 9px; background: #d9d1c4; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--red); transition: width .25s; }
.publish-progress p { margin: 0; color: var(--muted); font-size: 9px; }

.result-card { display: flex; gap: 10px; }
.result-icon { display: grid; flex: 0 0 30px; height: 30px; place-items: center; border-radius: 50%; color: white; background: var(--green); }
.result-card p { margin: 4px 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.result-card a { display: none; color: var(--red); font-size: 10px; }
.result-card a.has-link { display: inline; }

.access-gate, .confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 29, 25, .48);
  backdrop-filter: blur(14px);
}

.gate-card, .confirm-card {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 24px;
  background: var(--white);
  box-shadow: 0 30px 90px rgba(20, 18, 15, .28);
}

.gate-card h2, .confirm-card h2 { margin: 18px 0 8px; font: 600 28px/1.2 "STSong", "SimSun", serif; }
.gate-card > p:not(.eyebrow), .confirm-card > p { color: var(--muted); font-size: 12px; line-height: 1.7; }
.gate-error { display: block; min-height: 18px; margin-top: 10px; color: var(--red); font-size: 10px; text-align: center; }
.warning-mark { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 50%; color: #fff; background: var(--red); font: 800 24px/1 serif; }
.confirm-warning { margin: 18px 0; padding: 12px; border-radius: 10px; color: #6b5144; background: #f7e9df; font-size: 10px; line-height: 1.6; }
.confirm-check { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; font-size: 11px; }
.confirm-check input { width: 18px; min-height: 18px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  max-width: min(500px, calc(100vw - 30px));
  padding: 11px 18px;
  border-radius: 999px;
  color: #fff;
  background: #24211d;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
  transition: .2s;
  font-size: 11px;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.visually-hidden { position: fixed; left: -9999px; }

@media (max-width: 1250px) {
  .desk { grid-template-columns: 340px minmax(440px, 1fr); }
  .publish-panel { position: static; grid-column: 1 / -1; }
}

@media (max-width: 840px) {
  .connection .status-pill { display: none; }
  .workspace { padding-top: 28px; }
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .hero h1 { font-size: clamp(42px, 14vw, 68px); }
  .desk { grid-template-columns: 1fr; }
  .publish-panel { grid-column: auto; }
  .editor-panel { min-height: 0; }
  .empty-state { min-height: 420px; }
}

@media (max-width: 560px) {
  .topbar { min-height: 62px; padding-inline: 14px; }
  .brand-mark { width: 38px; height: 38px; }
  .workspace { padding-inline: 10px; }
  .hero { padding-inline: 8px; }
  .hero-copy { font-size: 12px; }
  .steps { width: 100%; }
  .step { flex: 1; padding-inline: 7px; }
  .panel { padding: 18px; border-radius: 17px; }
  .topic-grid, .field-row, .field-row.three, .cover-workbench { grid-template-columns: 1fr; }
  .cover-controls textarea { min-height: 88px; }
  .wechat-article { padding: 22px 18px; }
  .gate-card, .confirm-card { padding: 25px; }
}

.helper-note { margin: 10px 0 0; padding-top: 9px; border-top: 1px dashed var(--line); color: var(--red-dark); line-height: 1.6; }
