/* =============================================
   译笔 · 中英对照写作工具 — 样式表
   风格：精炼学术，仿 Claude 排版美感
   ============================================= */

:root {
  --bg: #f9f7f4;
  --bg-page: #ffffff;
  --bg-sidebar: #f4f2ef;
  --bg-toolbar: #ffffff;
  --border: #e5e1db;
  --border-light: #ede9e3;
  --text-primary: #1a1714;
  --text-secondary: #6b6560;
  --text-hint: #a09b94;
  --accent: #c17f3a;
  --accent-light: #f5edd9;
  --accent-hover: #a66b2a;
  --zh-color: #1a1714;
  --en-color: #5a6a7a;
  --en-bg: #f0f4f8;
  --en-border: #c8d5e0;
  --locked-bg: #e8f4e8;
  --locked-border: #7db87d;
  --locked-text: #2d6b2d;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 6px;
  --radius-lg: 10px;
  --topbar-h: 52px;
  --sidebar-w: 280px;
  --nav-w: 200px;
  --pages-panel-w: 100px;
  --page-h: 1123px; /* A4 96dpi */
  --font-zh: 'Noto Serif SC', 'SimSun', serif;
  --font-en: 'Lora', Georgia, serif;
  --font-ui: 'Noto Serif SC', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---- TOPBAR ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  z-index: 100;
  flex-shrink: 0;
  position: relative;
}

.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.topbar-center { display: flex; align-items: center; justify-content: center; flex: 2; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; }

.word-count-bar {
  flex-shrink: 0;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-hint);
  letter-spacing: 0.03em;
  background: var(--bg-toolbar);
  border-top: 1px solid var(--border);
}


/* ---- HISTORY BUTTON ---- */
.history-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-toolbar);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.history-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ---- HISTORY DRAWER ---- */
.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 400;
  display: none;
}
.history-overlay.open { display: block; }

.history-drawer {
  position: fixed;
  top: 0;
  left: -320px;
  width: 300px;
  height: 100vh;
  background: var(--bg-toolbar);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  display: flex;
  flex-direction: column;
  transition: left 0.25s ease;
}
.history-drawer.open { left: 0; }

.history-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.history-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-hint);
  line-height: 1;
  padding: 0 4px;
}
.history-close-btn:hover { color: var(--text-primary); }

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
}
.history-item:hover { border-color: var(--accent); background: var(--accent-light); }
.history-item.current { border-color: var(--accent); background: var(--accent-light); }
.history-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-meta {
  font-size: 11px;
  color: var(--text-hint);
  display: flex;
  justify-content: space-between;
}
.history-item-delete {
  background: none;
  border: none;
  color: var(--text-hint);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  margin-top: 4px;
  float: right;
}
.history-item-delete:hover { color: #cc5555; }

.history-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ---- LOGO ---- */
.logo {
  font-family: var(--font-zh);
  letter-spacing: 0.05em;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.2;
}
.logo-main {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
}
.logo-sub {
  font-size: 12px;
  letter-spacing: 0.02em;
  font-weight: 200;
  color: var(--accent);
}

.doc-title-input {
  position: relative;
  z-index: 10;
}
.doc-title-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  background: #fff;
}
.doc-title-input:hover, .doc-title-input:focus { background: var(--border-light); }

.save-status {
  font-size: 11px;
  color: var(--text-hint);
  white-space: nowrap;
}

/* ---- TOOLBAR ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}

.toolbar-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: all 0.15s;
  min-width: 28px;
  font-family: var(--font-mono);
}
.toolbar-btn:hover { background: var(--border-light); color: var(--text-primary); }
.toolbar-btn.active { background: var(--accent-light); color: var(--accent); }

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

/* ---- TOP RIGHT BUTTONS ---- */
.upload-btn, .export-btn, .settings-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--font-ui);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-toolbar);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.upload-btn:hover, .export-btn:hover, .settings-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.settings-btn { font-size: 16px; padding: 6px 8px; }

/* ---- DROPDOWN ---- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-toolbar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 500;
  display: none;
  overflow: hidden;
  padding: 6px;
}
.dropdown-menu.open { display: block; }
.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-ui);
  color: var(--text-primary);
  border-radius: var(--radius);
  transition: background 0.15s;
}
.dropdown-menu button:hover { background: var(--accent-light); color: var(--accent); }
.dropdown-divider { height: 1px; background: var(--border-light); margin: 4px 0; }
.export-options { padding: 8px 12px; font-size: 12px; color: var(--text-secondary); }
.export-options label { display: block; margin-bottom: 4px; }
.export-options select { width: 100%; padding: 4px; border: 1px solid var(--border); border-radius: 4px; font-size: 12px; }

/* ---- MAIN LAYOUT ---- */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ---- NAV PANEL ---- */
.nav-panel {
  width: var(--nav-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: width 0.2s ease;
}
.nav-panel.collapsed {
  width: 0;
  border-right: none;
}

.nav-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-panel-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-hint);
}
.nav-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-hint);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}
.nav-collapse-btn:hover { color: var(--text-primary); }

.nav-expand-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-toolbar);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 8px 4px;
  z-index: 10;
  transition: all 0.15s;
}
.nav-expand-btn:hover { color: var(--accent); background: var(--accent-light); }

.nav-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 12px;
  font-size: 12px;
  font-family: var(--font-zh);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s;
  border-radius: 0;
}
.nav-item:hover { background: var(--accent-light); color: var(--accent); }
.nav-item.level-1 { font-weight: 600; font-size: 12px; padding-left: 12px; }
.nav-item.level-2 { padding-left: 20px; }
.nav-item.level-3 { padding-left: 28px; font-size: 11px; }
.nav-item.level-4 { padding-left: 36px; font-size: 11px; color: var(--text-hint); }

/* ---- EDITOR AREA ---- */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.translation-bar {
  height: 44px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
}

.translation-toggle { display: flex; align-items: center; gap: 8px; }
.toggle-label { font-size: 13px; color: var(--text-secondary); }

/* Toggle switch */
.toggle-switch { position: relative; width: 36px; height: 20px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 20px;
  transition: 0.2s;
}
.toggle-slider:before {
  content: ''; position: absolute;
  width: 14px; height: 14px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(16px); }

.style-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.style-select-wrap select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px 6px;
  font-size: 12px;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-ui);
}

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  margin-left: auto;
}
.view-btn {
  padding: 3px 10px;
  font-size: 11px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  transition: all 0.15s;
}
.view-btn.active { background: var(--bg-toolbar); color: var(--accent); box-shadow: var(--shadow-sm); }

.translate-all-btn {
  padding: 5px 12px;
  font-size: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background 0.15s;
}
.translate-all-btn:hover { background: var(--accent-hover); }

/* ---- EDITOR CONTAINER ---- */
.editor-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ---- PAGES PANEL (小地图) ---- */
.pages-panel {
  width: var(--pages-panel-w);
  background: #e8e5e0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.pages-panel-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-hint);
  padding: 8px 0 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pages-thumbs {
  flex: 1;
  overflow: hidden;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* 小地图容器 */
.doc-minimap {
  flex: 1;
  width: 72px;
  background: #f0ece6;
  border-radius: 4px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  min-height: 80px;
}

/* 小地图段落线 */
.doc-minimap-lines {
  position: absolute;
  inset: 0;
  padding: 4px 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.doc-minimap-line {
  height: 2px;
  background: #c8c2bb;
  border-radius: 1px;
  flex-shrink: 0;
}
.doc-minimap-line.heading { background: #a09080; height: 3px; }
.doc-minimap-line.en { background: var(--en-border); opacity: 0.6; }

/* 视口高亮框 */
.doc-minimap-viewport {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(193, 127, 58, 0.18);
  border: 1px solid var(--accent);
  border-radius: 2px;
  pointer-events: none;
  transition: top 0.1s, height 0.1s;
  min-height: 10px;
}

/* 小地图底部信息 */
.minimap-info {
  width: 72px;
  text-align: center;
  font-size: 10px;
  color: var(--text-hint);
  font-family: var(--font-mono);
  flex-shrink: 0;
  line-height: 1.4;
}

/* ---- PAGES SCROLL ---- */
.pages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 40px 60px;
  background: var(--bg);
  display: flex;
  justify-content: center;
}

#pagesWrapper {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ---- PAGE BLOCK ---- */
.editor-page {
  width: 100%;
  background: var(--bg-page);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 60px 72px 100px;
  min-height: 400px;
  position: relative;
  flex-shrink: 0;
}

/* 分页线已废弃，保留选择器以防遗留 */
.page-divider { display: none; }

.editor-content {
  outline: none;
  font-family: var(--font-zh);
  font-size: 16px;
  line-height: 1.9;
  color: var(--zh-color);
  caret-color: var(--accent);
}

.editor-content:empty:before {
  content: '开始写作…';
  color: var(--text-hint);
  pointer-events: none;
}

/* ---- PARAGRAPH BLOCKS ---- */
.para-block {
  margin: 0 0 4px 0;
  position: relative;
  list-style: none;
}

.zh-line {
  display: block;
  padding: 2px 0;
  font-family: var(--font-zh);
  font-size: 16px;
  line-height: 1.9;
  color: var(--zh-color);
  outline: none;
  min-height: 1.9em;
}

.en-line {
  display: block;
  font-family: var(--font-en);
  font-size: 14px;
  line-height: 1.7;
  color: var(--en-color);
  background: var(--en-bg);
  border-left: 3px solid var(--en-border);
  padding: 6px 12px;
  margin: 2px 0 8px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  position: relative;
  transition: all 0.2s;
}

.en-line.locked {
  background: var(--locked-bg);
  border-left-color: var(--locked-border);
  color: var(--locked-text);
}

.en-line-actions {
  position: absolute;
  top: 6px;
  right: 8px;
  display: none;
  gap: 4px;
}
.en-lines-container:hover .en-line-actions { display: flex; }

.en-action-btn {
  background: rgba(255,255,255,0.9);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  white-space: nowrap;
}
.en-action-btn:hover { background: white; color: var(--text-primary); }
.en-action-btn.lock-btn.is-locked { color: var(--locked-border); border-color: var(--locked-border); }

.en-editable {
  outline: none;
  cursor: text;
  flex: 1;
}

.translating-indicator {
  display: inline-block;
  font-style: italic;
  color: var(--text-hint);
  font-size: 12px;
}

/* ---- HEADINGS ---- */
.para-block[data-level="1"] .zh-line,
.para-block[data-level="1"] .zh-sent-row {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-primary);
  margin-top: 8px;
}
.para-block[data-level="2"] .zh-line,
.para-block[data-level="2"] .zh-sent-row {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--text-primary);
}
.para-block[data-level="3"] .zh-line,
.para-block[data-level="3"] .zh-sent-row {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.7;
  color: var(--text-primary);
}
.para-block[data-level="4"] .zh-line,
.para-block[data-level="4"] .zh-sent-row {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.9;
  color: var(--text-primary);
}

/* View modes */
body.view-chinese .en-sent-row,
body.view-chinese .para-actions { display: none !important; }
body.view-english .zh-line,
body.view-english .zh-sent-row,
body.view-english .para-actions { display: none !important; }
body.view-english .sentence-pairs-wrapper .zh-sent-row { display: none !important; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-tab {
  flex: 1;
  padding: 10px 0;
  font-size: 13px;
  font-family: var(--font-ui);
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.sidebar-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--bg-toolbar); }

.sidebar-panel { display: none; flex: 1; overflow-y: auto; padding: 12px; flex-direction: column; gap: 8px; }
.sidebar-panel.active { display: flex; }

.panel-section {
  background: var(--bg-toolbar);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hint-text {
  font-size: 11px;
  color: var(--text-hint);
  line-height: 1.5;
}

.small-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--font-ui);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.small-btn:hover { border-color: var(--accent); color: var(--accent); }
.small-btn.confirm-btn { background: var(--accent); color: white; border-color: var(--accent); }
.small-btn.confirm-btn:hover { background: var(--accent-hover); }
.small-btn.cancel-btn:hover { border-color: #cc5555; color: #cc5555; }

/* Glossary */
.term-input-wrap { display: flex; flex-direction: column; gap: 6px; }
.term-input {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
}
.term-input:focus { border-color: var(--accent); }
.term-input-actions { display: flex; gap: 6px; justify-content: flex-end; }

.glossary-list { display: flex; flex-direction: column; gap: 4px; max-height: 200px; overflow-y: auto; }
.glossary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  font-size: 12px;
  gap: 8px;
}
.glossary-item-text { flex: 1; }
.glossary-zh { font-weight: 500; color: var(--text-primary); }
.glossary-en { color: var(--en-color); font-family: var(--font-en); }
.glossary-delete { background: none; border: none; cursor: pointer; color: var(--text-hint); font-size: 14px; padding: 0 2px; }
.glossary-delete:hover { color: #cc5555; }

.candidate-list { display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow-y: auto; }
.candidate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  background: var(--accent-light);
  border-radius: var(--radius);
  border: 1px solid #e5d5b5;
  font-size: 12px;
}
.candidate-item button { padding: 2px 8px; font-size: 11px; }
.empty-hint { font-size: 12px; color: var(--text-hint); text-align: center; padding: 12px 0; }

.upload-glossary-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  justify-content: center;
  transition: all 0.15s;
}
.upload-glossary-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* Settings */
.settings-label { font-size: 12px; color: var(--text-secondary); display: block; }
.settings-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
}
.settings-input:focus { border-color: var(--accent); }
.api-key-wrap { display: flex; gap: 6px; align-items: center; }
.api-key-wrap .settings-input { flex: 1; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }

/* ---- CONTEXT MENU ---- */
.context-menu {
  position: fixed;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 280px;
  z-index: 1000;
  display: none;
  overflow: hidden;
}
.context-menu.visible { display: block; }
.context-menu-header {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-hint);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg);
}
.context-menu-loading {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
}
.context-menu-loading.visible { display: flex; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.context-menu-items { display: flex; flex-direction: column; padding: 4px; }
.context-suggestion {
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.context-suggestion:hover { background: var(--accent-light); }
.suggestion-en {
  font-family: var(--font-en);
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}
.suggestion-zh {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}


.editor-page {
  background: var(--bg-page);
  box-shadow: var(--shadow-md);
  border-radius: 2px;
  min-height: var(--page-h);
  padding: 60px 72px;
  margin-bottom: 32px;
  position: relative;
}


/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--bg-page);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 380px;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.modal-body { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.modal-btn.cancel { background: var(--bg); color: var(--text-secondary); }
.modal-btn.cancel:hover { border-color: var(--text-secondary); }
.modal-btn.confirm { background: var(--accent); color: white; border-color: var(--accent); }
.modal-btn.confirm:hover { background: var(--accent-hover); }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 3000;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-hint); }

/* ---- INDENT ---- */
.para-block[data-indent="1"] .zh-line,
.para-block[data-indent="1"] .zh-sent-row:first-child { text-indent: 2em; }

.en-lines-container {
  margin: 4px 0 10px 0;
  background: var(--en-bg);
  border-left: 3px solid var(--en-border);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 8px 12px;
  position: relative;
}
.en-lines-container.locked {
  background: var(--locked-bg);
  border-left-color: var(--locked-border);
}
.sentence-pair { margin-bottom: 4px; }
.zh-sentence { font-size: 12px; color: var(--text-hint); line-height: 1.6; font-family: var(--font-zh); }
.en-sentence { font-size: 14px; color: var(--en-color); line-height: 1.7; padding: 1px 0; outline: none; font-family: var(--font-en); }
.en-sentence:focus { background: rgba(193,127,58,0.06); border-radius: 3px; }
.en-lines-container.locked .en-sentence { color: var(--locked-text); }

/* ---- 逐句中英对照 ---- */
.sentence-pairs-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.zh-sent-row {
  display: block;
  font-family: var(--font-zh);
  font-size: 16px;
  line-height: 1.9;
  color: var(--zh-color);
  outline: none;
  padding: 1px 0;
  min-height: 1.9em;
}
.zh-sent-row:focus { background: rgba(193,127,58,0.04); border-radius: 3px; }

.en-sent-row {
  display: block;
  font-family: var(--font-en);
  font-size: 14px;
  line-height: 1.7;
  color: var(--en-color);
  background: var(--en-bg);
  border-left: 3px solid var(--en-border);
  padding: 4px 12px;
  margin-bottom: 2px;
  border-radius: 0 var(--radius) var(--radius) 0;
  outline: none;
}
.en-sent-row:focus { background: rgba(193,127,58,0.08); }
.en-sent-row.locked { background: var(--locked-bg); border-left-color: var(--locked-border); color: var(--locked-text); }

/* 段落之间加大间距，方便区分 */
.para-block {
  margin-bottom: 28px !important;
}

.para-actions {
  display: none;
  margin-top: 4px;
}
.sentence-pairs-wrapper:hover .para-actions { display: flex; }


/* ---- 悬停语句对高亮 ---- */
/* ---- 悬停语句对高亮（语句级别，按，；分句） ---- */
.zh-clause {
  border-radius: 2px;
  display: inline;
  transition: background 0.12s, font-weight 0.1s;
}
.zh-clause.sent-hover {
  background: rgba(193, 127, 58, 0.15);
  font-weight: 700;
}


.en-clause {
  display: inline;
  border-radius: 3px;
  transition: background 0.15s;
}
.en-clause.sent-hover {
  background: var(--highlight-clause, rgba(99, 149, 230, 0.18));
}