:root {
  --bg: #e6eef9;
  --surface: #ffffff;
  --line: #c6d1e1;
  --text: #0b1527;
  --muted: #33455f;
  --brand: #0f4ea8;
  --brand-strong: #0c3f89;
  --brand-soft: #eaf2ff;
  --radius: 8px;
  --system-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --system-mono: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--system-sans);
  color: var(--text);
  background: var(--bg);
}

.app-shell {
  width: min(1400px, 96vw);
  margin: 18px auto;
}

.topbar {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.topbar-main {
  min-width: 0;
}

.brandline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.brand-badge {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.brand-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3c4c68;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: #121a2d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar p {
  margin: 3px 0 0;
  color: #5c6c87;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-picker {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #51607a;
  padding: 0;
  overflow: hidden;
}

.theme-picker select {
  border-radius: 999px;
  border: none;
  background: #b8cfe8;
  color: var(--text);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  cursor: pointer;
}

select,
.btn {
  border-radius: 999px;
  border: none;
  background: #b8cfe8;
  color: var(--text);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 32px;
  height: 32px;
  vertical-align: middle;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  padding-right: 12px;
}


.btn {
  cursor: pointer;
}

.btn.primary {
  background: var(--brand);
  color: #fff;
}

.btn:hover,
select:hover {
  background: #a3bddb;
}

.btn.primary:hover {
  background: var(--brand-strong);
}

.btn:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  min-height: 76vh;
  overflow: hidden;
}

.editor-panel {
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #dce7f6;
  padding: 12px 14px;
  min-height: 52px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  color: #1b2940;
}

.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

textarea {
  width: 100%;
  flex: 1;
  height: auto;
  min-height: 0;
  resize: none;
  border: 0;
  outline: none;
  padding: 16px;
  font: 14px/1.7 var(--system-mono);
  color: #0f1a2d;
  background: #f8fbff;
  overflow: auto;
}

.editor-panel .CodeMirror {
  flex: 1;
  height: auto;
  font: 14px/1.7 var(--system-mono);
  border-radius: 0 0 var(--radius) var(--radius);
}

.editor-panel .CodeMirror-gutters {
  border-right: none;
}

.editor-panel .CodeMirror {
  background: #ffffff;
  color: #1f2328;
}

.editor-panel .CodeMirror-gutters {
  background: #f6f8fb;
  color: #6e7781;
  padding: 0 4px;
}

.editor-panel .CodeMirror-linenumber {
  color: #6e7781;
  padding: 0 4px;
  min-width: 0;
}

.status {
  display: none;
}

.preview-panel {
  display: flex;
  flex-direction: column;
}

.wechat-body {
  margin: 0 auto;
  width: min(92%, 760px);
  padding: 22px 0 34px;
}

.wechat-body * {
  max-width: 100%;
}

.wechat-body p,
.wechat-body li {
  line-height: 1.9;
  font-size: 16px;
  letter-spacing: 0.015em;
}

.wechat-body ul,
.wechat-body ol {
  margin: 14px 0;
  padding: 0 0 0 2.2em;
}

.wechat-body h1,
.wechat-body h2,
.wechat-body h3,
.wechat-body h4 {
  margin: 28px 0 14px;
  line-height: 1.5;
}

.wechat-body h1 {
  font-size: 28px;
  text-align: center;
}

.wechat-body h2 {
  font-size: 24px;
}

.wechat-body h3 {
  font-size: 20px;
}

.wechat-body blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  background: var(--wx-soft);
  border-radius: 6px;
}

.wechat-body blockquote p {
  margin: 0 !important;
  padding: 4px 0;
}

.wechat-body pre {
  border-radius: 8px;
  padding: 14px;
  overflow-x: auto;
  background: #f5f7fb;
  border: 1px solid #d9e1ee;
}

.wechat-body code {
  font-family: var(--system-mono);
  font-size: 14px;
  white-space: pre;
  text-align: left;
  word-break: keep-all;
  overflow-wrap: normal;
}

.wechat-body :not(pre) > code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--wx-soft);
  display: inline;
  white-space: nowrap;
}

.wechat-body pre code.hljs,
.wechat-body .hljs {
  font-family: var(--system-mono) !important;
  background: transparent !important;
  color: #24292f !important;
}

.wechat-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
  display: block;
  overflow: auto;
}

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

.wechat-body img {
  border-radius: 10px;
}

.wechat-body hr {
  border: none;
  height: 1px;
  background: #e2e8f0;
  margin: 24px 0;
}

.theme-classic {
  --wx-text: #283345;
  --wx-accent: #2e5c9e;
  --wx-soft: #edf4ff;
}

.theme-ink {
  --wx-text: #19334f;
  --wx-accent: #0f4e81;
  --wx-soft: #e8f2fa;
}

.theme-sunset {
  --wx-text: #503127;
  --wx-accent: #d96c35;
  --wx-soft: #fff2ea;
}

.theme-forest {
  --wx-text: #244232;
  --wx-accent: #317951;
  --wx-soft: #ebf7f0;
}

.theme-plum {
  --wx-text: #3a2642;
  --wx-accent: #7a3fa0;
  --wx-soft: #f7eefc;
}

.theme-ocean {
  --wx-text: #16384f;
  --wx-accent: #0b79b5;
  --wx-soft: #e9f7ff;
}

.theme-rose {
  --wx-text: #4a2a34;
  --wx-accent: #c14f73;
  --wx-soft: #feeff4;
}

.theme-amber {
  --wx-text: #4b3518;
  --wx-accent: #c98622;
  --wx-soft: #fff6e8;
}

.theme-slate {
  --wx-text: #2d3645;
  --wx-accent: #586781;
  --wx-soft: #edf1f7;
}

.theme-mint {
  --wx-text: #1e3f35;
  --wx-accent: #2f9b7e;
  --wx-soft: #e8f8f3;
}

.theme-cocoa {
  --wx-text: #3f2c25;
  --wx-accent: #9a5f4b;
  --wx-soft: #f7efe9;
}

.theme-indigo {
  --wx-text: #272f57;
  --wx-accent: #4e64d8;
  --wx-soft: #edf0ff;
}

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

  .topbar-main {
    width: 100%;
  }

  .topbar h1 {
    white-space: normal;
  }

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

  .panel {
    min-height: auto;
  }

}

.wechat-body {
  color: var(--wx-text);
}

.wechat-body a {
  color: var(--wx-accent);
}
