/* 墨刻 · UI */
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e8ebf3;
  --line-soft: #f1f3f9;
  --text: #191d26;
  --text-2: #4a5364;
  --muted: #8b93a6;
  --accent: #3b82f6;
  --accent-2: #6d5cff;
  --shadow-sm: 0 1px 2px rgba(22, 28, 45, .05);
  --shadow-md: 0 10px 34px rgba(22, 28, 45, .08);
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 12% -10%, #eaf1ff 0%, rgba(234, 241, 255, 0) 62%),
    radial-gradient(900px 460px at 96% 4%, #f0ecff 0%, rgba(240, 236, 255, 0) 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  height: 100%;
  display: grid;
  grid-template-rows: 60px minmax(0, 1fr) 36px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; }

.logo {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #4f8dff 0%, #7c5cff 100%);
  box-shadow: 0 5px 14px rgba(84, 118, 255, .32), inset 0 1px 0 rgba(255,255,255,.35);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 14.5px; letter-spacing: .3px; }
.brand-text span { font-size: 11.5px; color: var(--muted); }

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

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: #3d4757;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: background .16s, border-color .16s, color .16s, box-shadow .16s, transform .16s;
  white-space: nowrap;
}
.btn:hover { background: #f7f9ff; border-color: #d5e0ff; color: #2b6fe0; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn.primary {
  color: #fff;
  border: 1px solid transparent;
  background: linear-gradient(135deg, #4b86f9 0%, #6f5bff 100%);
  box-shadow: 0 6px 16px rgba(76, 124, 249, .30);
  padding: 8px 15px;
  font-weight: 600;
}
.btn.primary:hover {
  color: #fff;
  background: linear-gradient(135deg, #3f7cf6 0%, #6551fb 100%);
  box-shadow: 0 9px 22px rgba(76, 124, 249, .38);
}

.icon-btn { padding: 7px 8px; color: #6b7488; }

.divider-v { width: 1px; height: 18px; background: var(--line); margin: 0 2px; }

/* 下拉菜单 */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 186px; padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(22, 28, 45, .14);
  display: none;
  z-index: 40;
}
.menu.open { display: block; animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu button {
  display: block; width: 100%;
  padding: 8px 10px;
  font-family: inherit; font-size: 13px; text-align: left;
  color: var(--text-2);
  background: none; border: 0; border-radius: 8px;
  cursor: pointer;
}
.menu button:hover { background: #f4f7ff; color: #2b6fe0; }
.menu button.danger:hover { background: #fff1f1; color: #e04848; }

/* ---------- 工作区 ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(280px, var(--split, 48%)) 10px minmax(320px, 1fr);
  padding: 14px 16px 6px;
  min-height: 0;
  overflow: hidden;
}

.pane {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.pane-head {
  flex: 0 0 auto;
  height: 40px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px;
  background: linear-gradient(180deg, #fdfdff 0%, #fafbff 100%);
  border-bottom: 1px solid var(--line-soft);
}

.pane-title {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; letter-spacing: .4px;
  color: #6d768a;
  text-transform: uppercase;
}
.pane-title .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .14);
}
.pane-title .dot.purple { background: var(--accent-2); box-shadow: 0 0 0 3px rgba(109, 92, 255, .14); }

.pane-tools { display: flex; align-items: center; gap: 4px; }
.hint { font-size: 11.5px; color: #a3aabc; }

.mini {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 14px; line-height: 1;
  color: #7b8398;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.mini:hover { color: var(--accent); border-color: #d3dfff; }
.zoom-label { font-size: 11.5px; color: #98a0b3; min-width: 34px; text-align: center; }

/* 字体切换 */
.font-pick { display: inline-flex; align-items: center; }
.font-pick select {
  height: 22px;
  padding: 0 3px 0 6px;
  font-family: inherit;
  font-size: 11.5px;
  color: #6d768a;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
  cursor: pointer;
  transition: border-color .16s, color .16s;
}
.font-pick select:hover { color: var(--accent); border-color: #d3dfff; }

/* 编辑器 */
#editor {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  padding: 20px 22px 60px;
  border: 0; outline: 0; resize: none;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.9;
  letter-spacing: .1px;
  color: #2a3040;
  background: #fff;
  tab-size: 2;
}
#editor::placeholder { color: #b9c0cf; }
#editor.dragover { background: #f6f9ff; box-shadow: inset 0 0 0 2px rgba(59, 130, 246, .35); }

/* 分隔条 */
.splitter {
  position: relative;
  cursor: col-resize;
  display: grid; place-items: center;
}
.splitter span {
  width: 4px; height: 46px;
  border-radius: 4px;
  background: #e3e8f4;
  transition: background .18s, height .18s;
}
.splitter:hover span, .splitter.active span { background: linear-gradient(180deg, #7ea8ff, #9b86ff); height: 74px; }

/* 预览 */
.preview-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 22px 18px 70px;
  background:
    radial-gradient(600px 300px at 50% 0%, #fbfcff 0%, rgba(251, 252, 255, 0) 70%),
    #f7f8fc;
}
.preview-scroll::-webkit-scrollbar,
#editor::-webkit-scrollbar { width: 10px; height: 10px; }
.preview-scroll::-webkit-scrollbar-thumb,
#editor::-webkit-scrollbar-thumb {
  background: #dfe4f0; border-radius: 8px; border: 3px solid transparent; background-clip: content-box;
}
.preview-scroll::-webkit-scrollbar-thumb:hover,
#editor::-webkit-scrollbar-thumb:hover { background: #c9d2e6; background-clip: content-box; }

.paper {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 26px 46px;
  background: #fff;
  border: 1px solid #eef0f7;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(24, 30, 50, .09);
  transform-origin: top center;
}

/* 兜底：任何来源的图片都不允许撑破版心 */
#preview img {
  max-width: 100% !important;
  height: auto !important;
}

#preview:empty::before {
  content: "预览区 · 左边写点东西吧";
  display: block;
  color: #c2c8d6;
  font-size: 13px;
  text-align: center;
  padding: 40px 0;
}

/* ---------- 状态栏 ---------- */
.statusbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  font-size: 11.5px;
  color: #9aa2b4;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .6);
}
.stats, .tips { display: flex; align-items: center; gap: 10px; }
.stats i, .tips i { width: 3px; height: 3px; border-radius: 50%; background: #ccd2e0; }
.tips { opacity: .85; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 60px;
  transform: translate(-50%, 14px);
  padding: 11px 18px;
  font-size: 13px;
  color: #fff;
  background: rgba(28, 33, 46, .94);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(20, 25, 40, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 90;
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: rgba(196, 55, 55, .95); }

@media (max-width: 860px) {
  .brand-text span { display: none; }
  .top-actions .btn span { display: none; }
  .tips { display: none; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 10px minmax(0, 1fr); }
  .splitter { cursor: row-resize; }
  .splitter span { width: 46px; height: 4px; }
}
