:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #1a1d24;
  --ink-soft: #5b6472;
  --line: #e4e7ec;
  --line-strong: #d3d8e0;
  --accent: #2f3e57;
  --accent-soft: #eef1f6;
  --ok: #2e7d5b;
  --warn: #b8791f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 28, 45, 0.06), 0 6px 24px rgba(20, 28, 45, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 38px; height: 38px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 20px;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: 0.2px; }
.topbar h1 .sub { color: var(--ink-soft); font-weight: 500; font-size: 13px; }
.tagline { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.bad { background: #c0392b; }
.health-text { font-size: 12.5px; color: var(--ink-soft); }

/* Workspace */
.workspace {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  gap: 18px; padding: 18px 24px; min-height: 0;
}
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-height: 0;
  overflow: hidden;
}

/* Controls */
.controls { padding: 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.select {
  appearance: none; width: 100%; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; color: var(--ink); font-size: 14px; font-family: inherit;
  cursor: pointer;
}
.select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Toggle */
.toggle { display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong);
  position: relative; flex: none; transition: background .18s ease;
}
.track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .18s ease;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle-label { font-size: 13.5px; font-weight: 550; display: flex; flex-direction: column; }
.toggle-label small { font-size: 11.5px; color: var(--ink-soft); font-weight: 400; }

/* Editor */
.editor-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 16px; }
.editor-head, .preview-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--ink-soft); font-weight: 600; margin-bottom: 10px;
}
.editor-tools, .preview-tools { display: flex; align-items: center; gap: 8px; }
.editor {
  flex: 1; width: 100%; resize: none; padding: 14px;
  border: 1px solid var(--line); border-radius: 8px;
  font-family: "SFMono-Regular", "JetBrains Mono", Consolas, monospace;
  font-size: 13.5px; line-height: 1.7; color: var(--ink);
  background: #fcfcfd; min-height: 240px;
}
.editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Action row */
.action-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 22px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity .15s ease, transform .05s ease;
}
.btn-primary:hover { opacity: .92; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost {
  background: transparent; color: var(--ink-soft); border: 1px solid var(--line-strong);
  padding: 6px 12px; border-radius: 7px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.status { font-size: 12.5px; color: var(--ink-soft); }
.status.err { color: #c0392b; }
.status.ok { color: var(--ok); }

/* Preview */
.preview-panel { background: #fff; }
.frame-scroll { flex: 1; overflow: auto; padding: 22px; background: #fafbfc; }
.article-frame {
  max-width: 680px; margin: 0 auto; background: #fff;
  padding: 10px 4px; min-height: 100%;
}
.article-frame .placeholder { color: #aab1bd; text-align: center; padding-top: 60px; font-size: 14px; }
.meta { font-size: 11.5px; color: var(--ink-soft); }

/* Footer */
.footer { padding: 10px 24px; border-top: 1px solid var(--line); background: var(--surface); font-size: 12px; color: var(--ink-soft); }

/* Responsive */
@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; }
  .editor { min-height: 180px; }
}
