:root {
  --app-bg: #eef3f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #64748b;
  --line: #d8e2ed;
  --primary: #2096d2;
  --primary-dark: #1474aa;
  --danger: #d84848;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif; background: var(--app-bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button, .file-label { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 12px; cursor: pointer; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover, .file-label:hover { border-color: var(--primary); color: var(--primary-dark); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); color: #fff; }
button.ghost { background: #fff; }
button.danger { background: #fff; color: var(--danger); border-color: #f1b7b7; }
button.full { width: 100%; margin-top: 8px; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 76px; padding: 14px 22px; background: #fff; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: .02em; }
.brand span { background: #e2f5ff; color: var(--primary-dark); border-radius: 999px; padding: 2px 8px; font-size: 12px; vertical-align: middle; }
.sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.workspace { flex: 1; display: grid; grid-template-columns: 280px minmax(420px, 540px) minmax(520px, 1fr); gap: 14px; padding: 14px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 24px rgba(15, 23, 42, .06); min-height: 0; overflow: hidden; }
.left-panel { display: flex; flex-direction: column; }
.panel-head, .preview-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: center; }
h2, h3 { margin: 0; }
.panel-head p, .preview-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.outline { padding: 10px; overflow: auto; flex: 1; }
.outline-item { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.outline-item.active { border-color: var(--primary); background: #f0faff; box-shadow: 0 0 0 2px rgba(32,150,210,.08) inset; }
.outline-main { flex: 1; min-width: 0; }
.outline-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.outline-type { margin-top: 2px; color: var(--muted); font-size: 12px; }
.outline-actions { display: grid; grid-template-columns: repeat(2, 28px); gap: 4px; }
.icon-btn { padding: 0; width: 28px; height: 28px; border-radius: 8px; }
.add-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.add-row select { flex: 1; }
.side-actions { padding: 0 10px 12px; }
.editor-panel { display: flex; flex-direction: column; }
.tabs { display: flex; padding: 10px 10px 0; gap: 6px; border-bottom: 1px solid var(--line); }
.tab { border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom: 0; }
.tab.active { background: #eef9ff; border-color: var(--primary); color: var(--primary-dark); }
.tab-page { display: none; padding: 16px; overflow: auto; }
.tab-page.active { display: block; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 13px; color: #334155; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; outline: none; background: #fff; }
textarea { resize: vertical; min-height: 140px; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace; }
textarea.small-text { min-height: 76px; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(32,150,210,.12); }
.block-form { display: grid; gap: 12px; }
.block-editor-empty { color: var(--muted); padding: 30px; text-align: center; border: 1px dashed var(--line); border-radius: 14px; }
.notice-box { margin-top: 14px; padding: 12px; background: #f8fbff; border: 1px solid var(--line); border-radius: 14px; color: #475569; font-size: 13px; line-height: 1.7; }
.notice-box code { background: #eaf6ff; padding: 1px 4px; border-radius: 4px; }
.preview-panel { display: flex; flex-direction: column; }
.preview-head h2 { font-size: 17px; }
#previewFrame { flex: 1; width: 100%; border: 0; background: #f6f8fb; min-height: 620px; }
.md-dialog { width: min(880px, calc(100vw - 40px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 20px 60px rgba(15,23,42,.25); }
.md-dialog::backdrop { background: rgba(15, 23, 42, .35); }
.dialog-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
#mdInput { width: 100%; min-height: 460px; border: 0; border-radius: 0; padding: 16px; }
.dialog-actions { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
@media (max-width: 1200px) { .workspace { grid-template-columns: 260px minmax(360px, 1fr); } .preview-panel { grid-column: 1 / -1; height: 760px; } }
@media (max-width: 820px) { .topbar { height: auto; align-items: flex-start; flex-direction: column; } .workspace { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } }
