:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9e0ea;
  --accent: #1769aa;
  --accent-strong: #0f4c81;
  --success: #18794e;
  --warning: #b54708;
  --danger: #b42318;
  --code-bg: #050807;
  --shadow: 0 12px 28px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

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

input {
  min-width: 0;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

button.primary,
#copyHtmlBtn {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

button.primary:hover,
#copyHtmlBtn:hover {
  color: #fff;
  background: var(--accent-strong);
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  max-width: 1480px;
  margin: 0 auto 14px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.25;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(360px, 0.85fr) minmax(460px, 1fr);
  gap: 14px;
  max-width: 1760px;
  margin: 0 auto;
  min-height: calc(100vh - 122px);
}

.editor-pane,
.template-pane,
.preview-pane {
  display: flex;
  min-width: 0;
  min-height: 640px;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #fbfcfe;
  font-size: 13px;
}

.pane-head strong {
  color: var(--text);
  font-size: 14px;
}

.view-tools label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.view-tools select {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--text);
  background: #fff;
}

.template-url {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.template-url input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  outline: 0;
  background: #fbfcfe;
}

.template-url input:focus {
  border-color: var(--accent);
  background: #fff;
}

#markdownInput {
  width: 100%;
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  padding: 20px;
  color: #111827;
  background: #fff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  line-height: 1.75;
}

#articleTemplateInput {
  overflow: auto;
  width: 100%;
  min-height: 220px;
  max-height: 260px;
  border: 0;
  outline: 0;
  padding: 18px;
  color: #111827;
  font-size: 14px;
  line-height: 1.7;
  background: #fbfcfe;
}

#articleTemplateInput:empty::before {
  content: "从公众号网页复制内容后粘贴到这里，会尽量保留原网页样式";
  color: #98a2b3;
}

#articleTemplateInput img {
  max-width: 100%;
  height: auto;
}

#templatePreview {
  overflow: auto;
  flex: 1;
  border-top: 1px solid var(--line);
  background: #fff;
}

.preview-pane {
  background: #eef2f7;
}

#wechatPreview {
  flex: 1;
  overflow: auto;
  margin: 0;
}

#wechatPreview,
#templatePreview {
  min-width: 0;
}

.wechat-article {
  padding: 28px 26px 44px;
  background: #fff;
  color: #2b2f36;
  font-size: 14px;
  line-height: 1.85;
  word-break: break-word;
}

.wechat-article.compact {
  font-size: 14px;
  line-height: 1.72;
}

.wechat-article h1 {
  margin: 0 0 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid #1769aa;
  color: #111827;
  font-size: 17px;
  line-height: 1.35;
}

.wechat-article h2 {
  margin: 32px 0 14px;
  padding-left: 12px;
  border-left: 5px solid #1769aa;
  color: #111827;
  font-size: 17px;
  line-height: 1.45;
}

.wechat-article h3 {
  margin: 24px 0 10px;
  color: #0f4c81;
  font-size: 16px;
  line-height: 1.45;
}

.wechat-article p {
  margin: 12px 0;
}

.wechat-article ul,
.wechat-article ol {
  margin: 12px 0;
  padding-left: 24px;
}

.wechat-article li {
  margin: 6px 0;
}

.wechat-article strong {
  color: #111827;
}

.wechat-article blockquote,
.wechat-article .callout {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid #c9d7ea;
  border-left: 5px solid #1769aa;
  background: #f3f8ff;
}

.wechat-article .callout.warning {
  border-color: #f7d7b0;
  border-left-color: var(--warning);
  background: #fff8ed;
}

.wechat-article .callout.danger {
  border-color: #fecdca;
  border-left-color: var(--danger);
  background: #fff5f5;
}

.wechat-article .callout.success {
  border-color: #bfe3cf;
  border-left-color: var(--success);
  background: #f1fbf5;
}

.wechat-article .callout-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.wechat-article code {
  padding: 2px 5px;
  border-radius: 4px;
  color: #b42318;
  background: #fff1f0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.wechat-article pre {
  overflow: auto;
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: 8px;
  color: #12d66b;
  background: var(--code-bg);
  line-height: 1.65;
}

.wechat-article pre code {
  display: block;
  padding: 0;
  color: #12d66b;
  background: transparent;
  font-size: 14px;
  white-space: pre;
}

.wechat-article table {
  width: 100%;
  margin: 16px 0;
  border-collapse: collapse;
  font-size: 14px;
}

.wechat-article th,
.wechat-article td {
  border: 1px solid #d9e0ea;
  padding: 8px 10px;
  text-align: left;
}

.wechat-article th {
  background: #f3f6fa;
}

.wechat-article.theme-vastbase {
  padding: 30px 28px 46px;
  color: #0d1420;
  background: #fff;
  font-size: 14px;
  line-height: 1.88;
  font-family:
    -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    sans-serif;
}

.wechat-article.theme-vastbase.compact {
  font-size: 14px;
  line-height: 1.76;
}

.wechat-article.theme-vastbase h1 {
  margin: 0 0 26px;
  padding: 0;
  border: 0;
  color: #087568;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.75;
}

.wechat-article.theme-vastbase h2 {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: 36px 0 18px;
  padding: 0;
  border: 0;
  color: #222;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
}

.wechat-article.theme-vastbase h2::before {
  content: "";
  display: none;
}

.wechat-article.theme-vastbase h2::after {
  content: "";
  display: none;
}

.wechat-article.theme-vastbase .section-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 66px;
  height: 54px;
  border: 2px solid #5a78f0;
  box-shadow: 7px -6px 0 #9ed5ff;
  color: #fff;
  background: #2147a3;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0;
}

.wechat-article.theme-vastbase .section-title {
  position: absolute;
  left: 84px;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  padding: 14px 16px 16px;
  background:
    linear-gradient(90deg, #eaf3ff 0%, #f6fbff 100%),
    linear-gradient(90deg, transparent 0%, transparent 82%, #91d3ff 100%);
  background-size: 100% 100%, 100% 10px;
  background-position: 0 0, 0 100%;
  background-repeat: no-repeat;
}

.wechat-article.theme-vastbase h3 {
  margin: 24px 0 10px;
  color: #d2135f;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.55;
}

.wechat-article.theme-vastbase h3:nth-of-type(3n + 2) {
  color: #cc4a0b;
}

.wechat-article.theme-vastbase h3:nth-of-type(3n) {
  color: #145bdc;
}

.wechat-article.theme-vastbase p {
  margin: 14px 0;
  color: #263247;
}

.wechat-article.theme-vastbase ul,
.wechat-article.theme-vastbase ol {
  margin: 14px 0 20px;
  padding-left: 26px;
  color: #050505;
}

.wechat-article.theme-vastbase li {
  margin: 8px 0;
}

.wechat-article.theme-vastbase strong {
  color: #050505;
  font-weight: 800;
}

.wechat-article.theme-vastbase blockquote,
.wechat-article.theme-vastbase .callout {
  margin: 24px 0;
  padding: 18px 22px;
  border: 0;
  border-left: 6px solid #25bf6b;
  border-radius: 0;
  color: #147342;
  background: #ebfbf2;
  font-size: 14px;
  font-weight: 700;
}

.wechat-article.theme-vastbase .callout.warning {
  border-left-color: #25bf6b;
  background: #ebfbf2;
}

.wechat-article.theme-vastbase .callout.danger {
  border-left-color: #dc2626;
  background: #fff1f2;
  color: #b42318;
}

.wechat-article.theme-vastbase .callout.success {
  border-left-color: #25bf6b;
  background: #ebfbf2;
}

.wechat-article.theme-vastbase .callout-title {
  display: none;
}

.wechat-article.theme-vastbase code {
  padding: 1px 4px;
  border-radius: 3px;
  color: #476099;
  background: transparent;
  font-size: 0.95em;
}

.wechat-article.theme-vastbase pre {
  margin: 18px 0;
  border-radius: 4px;
  color: #12d66b;
  background: #050807;
}

.wechat-article.theme-vastbase pre code {
  color: #12d66b;
  background: transparent;
  font-size: 14px;
}

.wechat-article.theme-vastbase table {
  font-size: 14px;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 10px 14px;
  border-radius: 6px;
  color: #fff;
  background: rgba(17, 24, 39, 0.92);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.18s ease;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 960px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
    width: 100%;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .editor-pane,
  .template-pane,
  .preview-pane {
    min-height: 520px;
  }
}

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

  .topbar {
    padding: 14px;
  }

  .actions button {
    flex: 1 1 150px;
  }

  .template-url {
    grid-template-columns: 1fr;
  }

  .wechat-article {
    padding: 22px 16px 34px;
  }
}
