:root {
  /* 宣纸浅色 (Default) */
  --bg-app: #fafcfb;
  --bg-rail: #f6f8f7;
  --bg-surface: #ffffff;
  --bg-subtle: #f3f5f6;
  --bg-hover: #edf1f0;
  --border: #e6eae8;
  --border-strong: #d4dcd8;
  --text-main: #1f2421;
  --text-sub: #5c6660;
  --text-muted: #939d97;
  --primary: #058a57;
  --primary-hover: #047348;
  --primary-soft: #ecf8f2;
  --primary-border: #b8e6cf;
  --danger: #dc2626;
  --serif: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --shadow-sm: 0 1px 3px rgba(16, 24, 20, 0.04);
  --shadow-md: 0 12px 32px rgba(16, 24, 20, 0.1);
}

html[data-appearance="dark"] {
  /* 曜石深色 */
  --bg-app: #111614;
  --bg-rail: #151b18;
  --bg-surface: #1a211e;
  --bg-subtle: #222b27;
  --bg-hover: #29342f;
  --border: #2a3430;
  --border-strong: #394741;
  --text-main: #edf2ef;
  --text-sub: #a9b5ae;
  --text-muted: #74827b;
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-soft: rgba(16, 185, 129, 0.14);
  --primary-border: rgba(16, 185, 129, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--sans);
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Left Navigation Rail */
.nav-rail {
  width: 196px;
  background: var(--bg-rail);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.18s ease, opacity 0.18s ease;
}
.nav-rail.collapsed {
  width: 0;
  border-right: none;
  overflow: hidden;
  opacity: 0;
}

.nav-brand {
  padding: 18px 14px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.nav-brand-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.nav-brand-en {
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.nav-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.rail-collapse-btn {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-sub);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1;
}
.rail-collapse-btn:hover { color: var(--primary); border-color: var(--primary-border); }

.nav-cta-wrap {
  padding: 0 12px 14px;
}

.btn-emerald-pill {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--primary);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease;
}
.btn-emerald-pill:hover { background: var(--primary-hover); }

.nav-menu {
  flex: 1;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group-label {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 8px 4px;
}

.nav-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-sub);
  padding: 8px 10px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  transition: all 0.12s ease;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-main); }
.nav-item.active {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
  font-weight: 600;
}

.nav-label { flex: 1; }

.nav-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
}

.nav-count {
  font-size: 11px;
  color: var(--text-muted);
}

.nav-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.appearance-btn {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-sub);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: inherit;
}
.appearance-btn:hover { border-color: var(--primary-border); color: var(--text-main); }

.nav-version {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* Main Area */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view-panel {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}
.view-panel.active { display: flex; }

/* Buttons & Inputs */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary { background: var(--bg-surface); border-color: var(--border-strong); color: var(--text-main); }
.btn-secondary:hover { background: var(--bg-subtle); }
.btn-ghost { background: transparent; color: var(--text-sub); }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-main); }

.link-btn {
  border: none;
  background: none;
  color: var(--primary);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }
.danger-text { color: var(--danger) !important; }

.kf-input, .kf-textarea, .kf-select, .kf-select-sm {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.kf-input:focus, .kf-textarea:focus, .kf-select:focus { border-color: var(--primary); }
.kf-select { width: 100%; }
.kf-select-sm { padding: 4px 7px; font-size: 12px; }
.mono { font-family: Menlo, Monaco, Consolas, monospace; font-size: 12.5px; }

.muted-sm { font-size: 12px; color: var(--text-muted); margin: 4px 0 0; line-height: 1.6; }
.muted-xs { font-size: 11px; color: var(--text-muted); }
.hidden { display: none !important; }

/* Editor Topbar */
.editor-topbar {
  height: 52px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.et-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.title-pill-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px;
  flex: 1;
  max-width: 520px;
}
.title-pill-wrap:focus-within {
  border-color: var(--primary-border);
  background: var(--bg-surface);
}

.title-pill-label {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.title-pill-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
}

.char-counter {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.char-counter.over { color: var(--danger); font-weight: 600; }

.et-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.panel-toggle-group {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.toggle-pill {
  border: none;
  background: transparent;
  color: var(--text-sub);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.toggle-pill.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* Editor Body (3 inner columns) */
.editor-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* Center Canvas */
.canvas-col {
  flex: 1;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-app);
}

.canvas-toolbar {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.ct-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.ct-btn, .ct-fmt {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-sub);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
}
.ct-btn:hover, .ct-fmt:hover {
  border-color: var(--primary-border);
  color: var(--primary);
  background: var(--primary-soft);
}
.ct-btn.accent {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
  font-weight: 600;
}

.canvas-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 60px;
}

.manuscript-wrap {
  max-width: 680px;
  margin: 0 auto;
}

.meta-drawer {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.meta-grid { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.cover-row { display: flex; gap: 10px; align-items: center; }
.cover-box {
  width: 92px;
  height: 40px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.cover-box img { width: 100%; height: 100%; object-fit: cover; }
.cover-inputs { flex: 1; display: flex; gap: 6px; align-items: center; min-width: 0; }

/* Progressive Disclosure Block Cards */
.blocks-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kf-block {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
  position: relative;
}
.kf-block:hover { border-color: var(--border-strong); }
.kf-block.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.kf-block-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.kf-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-sub);
}
.kf-pill.h1, .kf-pill.h2, .kf-pill.h3 { background: #fef3c7; color: #b45309; }
.kf-pill.lead { background: #f3e8ff; color: #7e22ce; }
.kf-pill.paragraph { background: var(--primary-soft); color: var(--primary); }
.kf-pill.list { background: #e0f2fe; color: #0369a1; }

.kf-ctx-bar {
  display: none;
  align-items: center;
  gap: 4px;
}
.kf-block.selected .kf-ctx-bar { display: flex; }

.ctx-seg {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: 6px;
  padding: 1px;
  margin-right: 4px;
}
.ctx-seg button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
  cursor: pointer;
  font-family: inherit;
}
.ctx-seg button.active { background: var(--bg-surface); color: var(--primary); }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-sub);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: var(--bg-subtle); color: var(--text-main); }
.icon-btn.danger:hover { background: #fee2e2; color: var(--danger); }

.kf-editor-input, .kf-editor-ta {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.8;
  resize: none;
  padding: 0;
}
.kf-editor-input.h1 { font-family: var(--serif); font-size: 18px; font-weight: 700; }
.kf-editor-input.h2 { font-size: 16px; font-weight: 700; }
.kf-editor-input.h3 { font-size: 14.5px; font-weight: 700; color: var(--text-sub); }

.kf-code-ta {
  background: #141a21;
  color: #e2e8f0;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  padding: 10px 12px;
  border-radius: 7px;
  line-height: 1.6;
}

.kf-list-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}
.kf-list-idx {
  font-family: Menlo, monospace;
  font-size: 12px;
  color: var(--primary);
  min-width: 22px;
}

.kf-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 6px;
}
.kf-table th, .kf-table td {
  border: 1px solid var(--border);
  padding: 4px 6px;
}
.kf-table th { background: var(--bg-subtle); }
.kf-table input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 13px;
}

.canvas-statusbar {
  height: 34px;
  padding: 0 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.save-ok { color: var(--primary); }

/* Right Panel A: Hierarchical Style Panel */
.style-panel {
  width: 274px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sp-header, .pp-header {
  height: 40px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.sp-title, .pp-title { font-size: 12.5px; font-weight: 600; color: var(--text-main); }
.sp-head-actions { display: flex; gap: 6px; }
.pp-hint { font-size: 11px; color: var(--text-muted); }

.sp-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sp-card {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 11px;
  background: var(--bg-app);
}
.sp-field-row { display: flex; flex-direction: column; gap: 6px; }
.sp-label { font-size: 11.5px; font-weight: 600; color: var(--text-sub); }
.sp-desc { font-size: 11px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.sp-custom-del { margin-top: 4px; }

.sp-acc {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-surface);
  transition: border-color 0.15s ease;
  overflow-x: hidden;
}
.sp-acc.highlight-acc {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.sp-acc summary {
  list-style: none;
  padding: 9px 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}
.sp-acc summary > span:first-child {
  white-space: nowrap;
  flex-shrink: 0;
}
.sp-acc summary::-webkit-details-marker { display: none; }
.acc-val {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sp-acc-body {
  padding: 6px 11px 11px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}

.sp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-sub);
  min-width: 0;
}
.sp-row > span:first-child {
  white-space: nowrap;
  flex-shrink: 0;
}
.sp-row .kf-select-sm {
  flex: 1;
  min-width: 0;
  max-width: 156px;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-inline { display: flex; align-items: center; gap: 6px; }
.sp-inline input[type="color"] {
  width: 24px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0;
  background: none;
  cursor: pointer;
}

/* Compact Style Picker Trigger & Floating Visual Popover */
.style-picker-trigger {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: inherit;
  transition: all 0.14s ease;
}
.style-picker-trigger:hover {
  border-color: var(--primary-border);
  background: var(--primary-soft);
}
.spt-preview {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  pointer-events: none;
}
.spt-action {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}

.style-popover {
  position: fixed;
  width: 348px;
  max-height: 460px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(16, 24, 20, 0.16);
  z-index: 95;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.style-popover-head {
  flex-shrink: 0;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-app);
}

.style-popover .style-card-grid {
  flex: 1;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.style-thumb-card {
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 9px;
  padding: 9px 9px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  transition: all 0.14s ease;
  font-family: inherit;
}

.style-thumb-card:hover {
  border-color: var(--primary-border);
  transform: translateY(-1px);
}

.style-thumb-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.style-thumb-stage {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.style-thumb-name {
  font-size: 11px;
  color: #5c6660;
  font-weight: 500;
}

.style-thumb-card.active .style-thumb-name {
  color: var(--primary);
  font-weight: 700;
}

/* Compact Dropdown with Bottom Custom Slider + Number Input */
.num-ctrl {
  position: relative;
}

.nc-dropdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nc-label {
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
  flex-shrink: 0;
}

.nc-trigger {
  flex: 1;
  min-width: 0;
  max-width: 156px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: inherit;
  transition: border-color 0.12s ease;
}
.nc-trigger-val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Draggable Column Resizer */
.col-resizer {
  width: 5px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  transition: background 0.14s ease;
}
.col-resizer:hover,
.col-resizer.dragging {
  background: var(--primary-border);
}
body.resizing-col {
  cursor: col-resize !important;
  user-select: none !important;
}
.nc-trigger:hover,
.nc-trigger.open {
  border-color: var(--primary);
}
.nc-caret {
  font-size: 10px;
  color: var(--text-muted);
}

.nc-menu {
  position: fixed;
  width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(16, 24, 20, 0.16);
  padding: 5px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nc-option {
  border: none;
  background: transparent;
  color: var(--text-main);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: inherit;
  text-align: left;
}
.nc-option:hover {
  background: var(--bg-subtle);
}
.nc-option.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nc-custom-box {
  margin-top: 3px;
  padding: 7px 8px 5px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nc-custom-title {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.nc-custom-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.nc-slider {
  flex: 1;
  min-width: 0;
  accent-color: var(--primary);
  height: 4px;
  cursor: pointer;
}

.nc-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: 6px;
  padding: 2px 5px;
  flex-shrink: 0;
}
.nc-input-wrap:focus-within {
  border-color: var(--primary);
}

.nc-number {
  width: 36px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 11.5px;
  text-align: right;
  font-family: inherit;
}

.nc-unit {
  font-size: 10.5px;
  color: var(--text-muted);
}

/* Right Panel B: Fixed-Width Live Preview (Authentic 9:19.5 iPhone Frame) */
.preview-panel {
  width: 380px;
  min-width: 380px;
  max-width: 380px;
  background: var(--bg-rail);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.pp-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 16px 18px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.phone-scale-box {
  position: relative;
  flex-shrink: 0;
}

.phone-device {
  position: relative;
  width: 397px;   /* 375px inner WeChat screen + 11px*2 frame */
  height: 834px;  /* 812px inner screen + 11px*2 frame (exact iPhone 1:2.10 ratio) */
  padding: 10px;
  border-radius: 54px;
  background: linear-gradient(145deg, #2c3135 0%, #151719 50%, #262a2e 100%);
  box-shadow:
    0 24px 52px rgba(15, 23, 20, 0.18),
    0 6px 16px rgba(15, 23, 20, 0.08),
    inset 0 0 0 1.5px rgba(255, 255, 255, 0.16),
    inset 0 0 0 3px rgba(0, 0, 0, 0.55);
  transform-origin: top left;
}

/* Subtle metallic side hardware buttons */
.phone-hw-btn {
  position: absolute;
  width: 3px;
  background: linear-gradient(180deg, #3c4247, #1c1f22);
  border-radius: 2px;
  pointer-events: none;
}
.phone-btn-silent { left: -3px; top: 118px; height: 28px; }
.phone-btn-vol-up { left: -3px; top: 168px; height: 52px; }
.phone-btn-vol-down { left: -3px; top: 232px; height: 52px; }
.phone-btn-power { right: -3px; top: 188px; height: 76px; }

.phone-card {
  width: 100%;
  height: 100%;
  background: #ffffff;
  color: #191919;
  border-radius: 44px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.phone-statusbar {
  height: 44px;
  padding: 6px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: #191919;
  background: #ffffff;
  flex-shrink: 0;
}

.phone-time {
  width: 48px;
}

.phone-island {
  width: 102px;
  height: 26px;
  border-radius: 999px;
  background: #0d0e10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.phone-island-cam {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2b3c59 0%, #0d1320 65%, #07090d 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.phone-status-icons {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  color: #191919;
}

.wx-nav-bar {
  height: 36px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #191919;
  background: #ffffff;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.wx-nav-back,
.wx-nav-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: #191919;
}

/* Exact WeChat mobile #js_content built-in padding: 20px left/right — scrolls INSIDE the fixed phone! */
.phone-content-wrap {
  padding: 14px 20px 32px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
}
.phone-content-wrap::-webkit-scrollbar {
  width: 4px;
}
.phone-content-wrap::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.16);
  border-radius: 999px;
}
.phone-content-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.wx-title {
  margin: 0 0 14px;
  font-size: 22px;
  line-height: 1.4;
  font-weight: 500;
  color: #191919;
  letter-spacing: 0.2px;
}

.wx-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: rgba(0, 0, 0, 0.32);
  margin-bottom: 22px;
}
.wx-orig {
  font-size: 12px;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.05);
  color: rgba(0, 0, 0, 0.45);
  border-radius: 3px;
}
.wx-author { color: #576b95; font-weight: 400; }

.wx-footer-bar {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.35);
}

.phone-home-bar {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  flex-shrink: 0;
}
.phone-home-bar span {
  width: 120px;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
}

.wx-body [data-style-group] {
  cursor: pointer;
  transition: outline 0.12s ease;
}
.wx-body [data-style-group]:hover {
  outline: 1px dashed rgba(5, 138, 87, 0.45);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Centered Pages (My Articles & Settings) */
.centered-page {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
}
.page-sub { margin: 6px 0 0; font-size: 13px; color: var(--text-muted); }
.page-head-actions { display: flex; gap: 8px; }

.articles-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.art-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: border-color 0.14s ease;
}
.art-card:hover { border-color: var(--primary-border); }
.art-card-title { font-size: 15.5px; font-weight: 600; margin-bottom: 5px; }
.art-card-abs { font-size: 12.5px; color: var(--text-sub); margin-bottom: 6px; line-height: 1.5; }
.art-card-meta { font-size: 11.5px; color: var(--text-muted); }
.art-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Settings Cards */
.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 16px;
}

.sc-account-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sc-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sc-account-info { flex: 1; }
.sc-name-row { display: flex; align-items: center; gap: 8px; font-size: 15px; }

.sc-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.sc-title { margin: 0; font-size: 15px; font-weight: 700; }

.sc-wechat-list { display: flex; flex-direction: column; gap: 8px; }
.wechat-item {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 12px 14px;
  background: var(--bg-app);
  font-size: 12.5px;
  line-height: 1.6;
}

.new-key-banner {
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.nkb-title { font-size: 12px; font-weight: 600; color: var(--primary); }

.mcp-snippet {
  background: #141a21;
  color: #e2e8f0;
  font-family: Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0 0;
}

.key-list { display: flex; flex-direction: column; gap: 8px; }
.key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-app);
  font-size: 12.5px;
}

/* Split-Pane Literary Login Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 20, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.login-split-card {
  width: 100%;
  max-width: 720px;
  min-height: 410px;
  background: var(--bg-surface);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: grid;
  grid-template-columns: 39% 61%;
}

.login-left {
  background: linear-gradient(155deg, #ecf8f2 0%, #f6fbf8 60%, #ffffff 100%);
  padding: 34px 28px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  color: #1f2421;
}

.login-brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #058a57;
  color: #ffffff;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.login-brand-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}
.login-brand-name span {
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
  color: #6b7280;
}

.login-quote {
  margin: 28px 0 auto;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.95;
  color: #374151;
}

.login-foot-note {
  font-size: 11.5px;
  color: #6b7280;
  letter-spacing: 1px;
}

.login-right {
  padding: 40px 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-heading {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: 6px;
}

.login-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.login-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
}
.login-tab.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.login-sub {
  margin: 0 0 26px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 13.5px;
  outline: none;
  font-family: inherit;
}
.login-input:focus { border-color: var(--primary); }

.login-code-row { display: flex; gap: 8px; }
.login-code-row .login-input { flex: 1; }

.otp-dev-hint {
  font-size: 12px;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: 8px;
  padding: 8px 10px;
  line-height: 1.5;
}

.auth-error { font-size: 12px; color: var(--danger); min-height: 16px; line-height: 1.5; }
.login-submit-btn { padding: 10px; font-size: 14px; border-radius: 9px; }

.pwd-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pwd-wrap .login-input {
  padding-right: 38px;
}
.pwd-eye-btn {
  position: absolute;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 5px;
  opacity: 0.7;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.pwd-eye-btn:hover,
.pwd-eye-btn.shown {
  opacity: 1;
  color: var(--primary);
}

.login-foot-links {
  display: flex;
  justify-content: flex-end;
  margin-top: -4px;
}

/* Standard Modals */
.modal-card {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 15.5px; }
.modal-close { border: none; background: transparent; font-size: 22px; color: var(--text-muted); cursor: pointer; }
.modal-body { padding: 16px 18px; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.publish-checklist {
  background: var(--bg-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.check-ok { color: var(--primary); }
.check-warn { color: #b45309; }
.publish-result { padding: 10px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 12px; word-break: break-all; }
.publish-result.success { background: var(--primary-soft); border: 1px solid var(--primary-border); color: var(--primary); }
.publish-result.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.publish-logs-list { max-height: 140px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.publish-log-item { flex-shrink: 0; font-size: 12px; padding: 6px 8px; border-radius: 6px; background: var(--bg-subtle); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2421;
  color: #ffffff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  z-index: 200;
  box-shadow: var(--shadow-md);
}

/* Floating Text Selection Bubble */
.selection-bubble {
  position: fixed;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 8px;
  background: #1f2421;
  color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 20, 0.28);
  transform: translate(-50%, -100%);
  pointer-events: auto;
}

.sb-row {
  display: flex;
  align-items: center;
  gap: 3px;
}

.sb-color-row {
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  gap: 5px;
}

.sb-sep {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.16);
  margin: 0 2px;
}

.sb-mini-label {
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.58);
  margin-right: 1px;
}

.sb-btn {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease, color 0.12s ease;
}
.sb-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}
.sb-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.sb-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.sb-dot:hover {
  transform: scale(1.18);
  border-color: #ffffff;
}

.sb-color-pick {
  width: 18px;
  height: 18px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  border-radius: 4px;
}

@media (max-width: 1320px) {
  .style-panel { width: 256px; }
}

/* Quick Accent Swatches & Theme Generator Modal */
.sp-theme-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.sp-gen-btn {
  border: 1px dashed var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s ease;
}
.sp-gen-btn:hover {
  border-style: solid;
  background: var(--primary);
  color: #ffffff;
}
.accent-swatch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 0 6px;
}
.accent-swatch {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  padding: 0;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.accent-swatch:hover {
  transform: scale(1.14);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}
.accent-swatch.active {
  transform: scale(1.06);
  box-shadow: 0 0 0 2px var(--bg-surface), 0 0 0 3.5px var(--text-main);
}

.tg-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tg-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}
.tg-palette-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.tg-palette-chip {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-main);
  font-family: inherit;
  transition: all 0.12s ease;
}
.tg-palette-chip:hover {
  border-color: var(--primary-border);
}
.tg-palette-chip.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
}
.tg-chip-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.tg-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.tg-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  gap: 2px;
}
.tg-seg-btn {
  border: none;
  background: transparent;
  color: var(--text-sub);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s ease;
}
.tg-seg-btn.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(16, 24, 20, 0.1);
}
.tg-custom-colors {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tg-dual-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tg-color-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-sub);
}
.tg-pill-tag {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.tg-color-pill input[type="color"] {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  padding: 0;
  background: none;
  cursor: pointer;
}
.tg-hex-bare {
  width: 68px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tg-quick-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tg-scheme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.tg-scheme-card {
  border: 1.5px solid var(--border);
  background: #ffffff;
  border-radius: 11px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-family: inherit;
  transition: all 0.14s ease;
}
.tg-scheme-card:hover {
  border-color: var(--primary-border);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 24, 20, 0.06);
}
.tg-scheme-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.tg-scheme-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.tg-scheme-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #111827;
}
.tg-scheme-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tg-scheme-dots i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.tg-scheme-mini {
  background: #fafaf9;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 7px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tg-scheme-desc {
  font-size: 11px;
  color: #6b7280;
}
