/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark:    #1a1920;
  --bg-darker:  #131218;
  --bg-panel:   #232130;
  --bg-toolbar: #1d1b27;
  --accent:     #E8A866;
  --accent-h:   #F0C179;
  --text:       #abb2bf;
  --text-light: #d7dae0;
  --border:     #3a3540;
  --bar-h:      42px;
  --toolbar-h:  38px;
  --tabs-h:     34px;
  --status-h:   24px;
  --resizer-w:  6px;
}

html, body {
  height: 100%;
  font-family: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
}

/* ── Top bar ── */
.topbar {
  height: var(--bar-h);
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 8px;
  flex-shrink: 0;
  user-select: none;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  user-select: none;
}
.logo-svg { height: 22px; width: auto; flex-shrink: 0; }
.logo-brand {
  background: linear-gradient(135deg, #E0955A 0%, #F0C179 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: 'Montserrat', 'Segoe UI', sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .03em;
}
.logo-sep {
  color: var(--border);
  -webkit-text-fill-color: var(--border);
  font-weight: 300;
  margin: 0 2px;
}
.logo-product {
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  font-size: 14px;
  font-weight: 400;
}

.topbar-right { display: flex; gap: 6px; align-items: center; }

.btn {
  background: var(--bg-panel);
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #323842; border-color: #5a6070; }
.btn-print { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-print:hover { background: var(--accent-h); border-color: var(--accent-h); }

/* ── Toolbar ── */
.toolbar {
  height: var(--toolbar-h);
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 2px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }

.tool {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  padding: 3px 8px;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.tool:hover { background: #2c313a; border-color: var(--border); color: var(--text-light); }
.tool-active { background: #2c313a !important; border-color: var(--accent) !important; color: var(--accent) !important; }

.tool-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 3px 8px;
}
.tool-toggle:hover { background: #2c313a; border-color: var(--border); }
.tool-toggle input { accent-color: var(--accent); cursor: pointer; }

.sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* ── Panes ── */
/* ── Tab bar ── */
.tab-bar {
  height: var(--tabs-h);
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  padding: 0 6px;
  gap: 2px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text);
  max-width: 180px;
  flex-shrink: 0;
  transition: background .12s, color .12s;
  user-select: none;
}
.tab:hover { background: #2c313a; color: var(--text-light); }
.tab.tab-active {
  background: var(--bg-dark);
  color: var(--text-light);
  border-top: 2px solid var(--accent);
  padding-top: 4px;
}

.tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}

.tab-close {
  background: none;
  border: none;
  color: #636d83;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 3px;
  flex-shrink: 0;
}
.tab-close:hover { color: var(--text-light); background: rgba(255,255,255,.1); }

.tab-new {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px 4px;
  margin-bottom: 2px;
  flex-shrink: 0;
  align-self: center;
}
.tab-new:hover { background: #2c313a; border-color: var(--border); color: var(--text-light); }

.panes {
  display: flex;
  flex-direction: row;
  height: calc(100vh - var(--bar-h) - var(--toolbar-h) - var(--tabs-h) - var(--status-h));
  overflow: hidden;
}

.pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.pane-header {
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #636d83;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Editor wrap + mirror */
.editor-wrap {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.editor-mirror {
  position: absolute;
  inset: 0;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 14.5px;
  line-height: 1.65;
  padding: 20px 24px;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg-dark);
  color: transparent;
  z-index: 0;
}
.editor-mirror mark {
  background: rgba(245, 166, 35, 0.3);
  color: transparent;
  border-radius: 2px;
}
.editor-mirror mark.mark-current {
  background: rgba(245, 166, 35, 0.7);
}

/* Editor textarea */
#editor {
  position: absolute;
  inset: 0;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-light);
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 14.5px;
  line-height: 1.65;
  padding: 20px 24px;
  tab-size: 2;
  caret-color: var(--accent);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  z-index: 1;
}
#editor::placeholder { color: #4a5060; }
#editor::-webkit-scrollbar { width: 6px; }
#editor::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Preview pane */
.pane-preview {
  border-left: 1px solid var(--border);
}

.preview-content {
  flex: 1;
  padding: 20px 28px;
  overflow-y: auto;
  background: #fff;
  color: #24292e;
  scrollbar-width: thin;
}
.preview-content::-webkit-scrollbar { width: 6px; }
.preview-content::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

/* github-markdown-css overrides */
.markdown-body { font-size: 15px; line-height: 1.7; max-width: none; }
.markdown-body pre { background: #f6f8fa; }

/* Preview dark theme */
.preview-content.preview-dark {
  background: #1e2127;
  color: #abb2bf;
}
.preview-content.preview-dark .markdown-body {
  color: #abb2bf;
}
.preview-content.preview-dark .markdown-body h1,
.preview-content.preview-dark .markdown-body h2,
.preview-content.preview-dark .markdown-body h3,
.preview-content.preview-dark .markdown-body h4,
.preview-content.preview-dark .markdown-body h5,
.preview-content.preview-dark .markdown-body h6 {
  color: #d7dae0;
  border-bottom-color: #3a3f4b;
}
.preview-content.preview-dark .markdown-body a { color: #528bff; }
.preview-content.preview-dark .markdown-body code {
  background: #282c34;
  color: #e06c75;
}
.preview-content.preview-dark .markdown-body pre {
  background: #282c34;
  border: 1px solid #3a3f4b;
}
.preview-content.preview-dark .markdown-body pre code { color: #abb2bf; }
.preview-content.preview-dark .markdown-body blockquote {
  color: #636d83;
  border-left-color: #528bff;
}
.preview-content.preview-dark .markdown-body table thead tr {
  background: #282c34;
}
.preview-content.preview-dark .markdown-body table tr {
  background: #1e2127;
  border-top-color: #3a3f4b;
}
.preview-content.preview-dark .markdown-body table tr:nth-child(2n) {
  background: #21252b;
}
.preview-content.preview-dark .markdown-body table td,
.preview-content.preview-dark .markdown-body table th {
  border-color: #3a3f4b;
}
.preview-content.preview-dark .markdown-body hr { border-color: #3a3f4b; }

/* Drag resizer */
.resizer {
  width: var(--resizer-w);
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background .15s;
}
.resizer:hover, .resizer.dragging { background: var(--accent); }

/* ── Status bar ── */
.statusbar {
  height: var(--status-h);
  background: var(--accent);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 16px;
  font-size: 11.5px;
  color: rgba(255,255,255,.9);
  flex-shrink: 0;
  user-select: none;
}
.status-right { margin-left: auto; }

.status-saved {
  font-size: 11px;
  opacity: 0;
  transition: opacity .4s;
  margin-left: auto;
}
.status-saved.visible { opacity: .8; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
  width: 420px;
  max-width: 95vw;
  color: var(--text-light);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal h2 { font-size: 18px; margin-bottom: 10px; color: #fff; }
.modal p  { font-size: 13px; color: var(--text); margin-bottom: 20px; line-height: 1.5; }

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.form-row label { font-size: 13px; flex-shrink: 0; }
.form-row select {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-light);
  padding: 4px 8px;
  font-size: 13px;
  flex: 1;
  cursor: pointer;
}
.checkbox-row { justify-content: flex-start; gap: 8px; }
.checkbox-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

/* ── Drag-and-drop overlay ── */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(82, 139, 255, 0.12);
  border: 2px dashed var(--accent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
.drop-overlay.active { opacity: 1; }

.drop-message {
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 16px 28px;
  font-size: 15px;
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}

/* ── Recent files dropdown ── */
.recent-wrap {
  position: relative;
}
.recent-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 260px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  z-index: 200;
  overflow: hidden;
}
.recent-dropdown[hidden] { display: none; }

.recent-list { max-height: 280px; overflow-y: auto; }

.recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background .1s;
  border-bottom: 1px solid var(--border);
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: #2c313a; color: var(--text-light); }
.recent-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item-time { font-size: 11px; color: #636d83; flex-shrink: 0; }

.recent-empty {
  padding: 14px 12px;
  font-size: 12px;
  color: #636d83;
  font-style: italic;
}

.recent-footer {
  padding: 6px 10px;
  border-top: 1px solid var(--border);
  text-align: right;
}
.recent-footer button {
  background: none;
  border: none;
  color: #636d83;
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 4px;
}
.recent-footer button:hover { color: var(--text-light); }

/* ── Document Outline (TOC) panel ── */
.toc-panel {
  width: 210px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
  overflow: hidden;
}
.toc-panel[hidden] { display: none; }

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.toc-list::-webkit-scrollbar { width: 4px; }
.toc-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.toc-item {
  display: block;
  padding: 4px 14px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 2px solid transparent;
  transition: background .1s, color .1s, border-color .1s;
  line-height: 1.5;
}
.toc-item:hover { background: #2c313a; color: var(--text-light); border-left-color: var(--accent); }
.toc-item.toc-active { color: var(--accent); border-left-color: var(--accent); }

.toc-h1 { padding-left: 14px; font-weight: 600; color: var(--text-light); }
.toc-h2 { padding-left: 22px; }
.toc-h3 { padding-left: 30px; font-size: 12px; }
.toc-h4 { padding-left: 38px; font-size: 11.5px; opacity: .8; }
.toc-h5 { padding-left: 46px; font-size: 11px;   opacity: .7; }
.toc-h6 { padding-left: 54px; font-size: 11px;   opacity: .6; }

.toc-empty {
  padding: 16px 14px;
  font-size: 12px;
  color: #636d83;
  font-style: italic;
}

/* ── Find & Replace bar ── */
.find-bar {
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}
.find-bar[hidden] { display: none; }

.find-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.find-row input[type="text"] {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-light);
  font-family: inherit;
  font-size: 13px;
  padding: 4px 8px;
  outline: none;
  width: 220px;
  flex-shrink: 0;
}
.find-row input[type="text"]:focus { border-color: var(--accent); }
.find-row input[type="text"].find-no-match { border-color: #e05c4a; background: rgba(224,92,74,.08); }

.find-count {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 52px;
  white-space: nowrap;
  flex-shrink: 0;
}

.find-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-size: 12px;
  padding: 3px 8px;
  cursor: pointer;
  line-height: 1;
  transition: background .1s, color .1s;
  flex-shrink: 0;
}
.find-btn:hover { background: #323842; color: var(--text-light); }
.find-btn-text { font-size: 11.5px; padding: 3px 10px; }

.find-opt {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}
.find-opt:hover { border-color: var(--border); color: var(--text-light); }
.find-opt input { accent-color: var(--accent); cursor: pointer; }

.find-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  margin-left: auto;
  border-radius: 3px;
  line-height: 1;
}
.find-close:hover { color: var(--text-light); background: rgba(255,255,255,.06); }

/* ── Progress bar ── */
.progress-wrap {
  position: relative;
  height: 4px;
  background: var(--bg-darker);
  flex-shrink: 0;
  overflow: visible;
}
.progress-wrap[hidden] { display: none; }

.progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width .3s ease, background .3s;
  max-width: 100%;
}
.progress-bar.goal-met { background: #3dba6f; }
.progress-bar.goal-over { background: #e05c4a; }

.progress-label {
  position: absolute;
  right: 8px;
  top: 6px;
  font-size: 10px;
  color: var(--text);
  opacity: .7;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Status bar clickable stat ── */
.status-clickable {
  cursor: pointer;
  border-bottom: 1px dotted rgba(255,255,255,.4);
  padding-bottom: 1px;
}
.status-clickable:hover { opacity: 1; border-bottom-style: solid; }

/* ── Word goal popover ── */
.goal-popover {
  position: fixed;
  bottom: 30px;
  left: 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 180px;
}
.goal-popover[hidden] { display: none; }
.goal-popover label { font-size: 11px; color: var(--text); letter-spacing: .06em; text-transform: uppercase; }
.goal-popover input {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-light);
  font-family: inherit;
  font-size: 13px;
  padding: 5px 8px;
  outline: none;
  width: 100%;
}
.goal-popover input:focus { border-color: var(--accent); }
.goal-actions { display: flex; gap: 6px; justify-content: flex-end; }
.goal-actions button {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}
.goal-set-btn { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.goal-actions button:hover { opacity: .85; }

/* ── Table editor ── */
.table-modal-inner {
  width: min(92vw, 700px);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.table-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.table-ctrl-group {
  display: flex;
  gap: 4px;
}

.btn-sm {
  padding: 3px 9px;
  font-size: 12px;
}

.table-editor-wrap {
  overflow: auto;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 4px;
}

.table-editor-grid {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

.table-editor-grid th,
.table-editor-grid td {
  border: 1px solid var(--border);
  padding: 0;
  position: relative;
}

.table-editor-grid th { background: #21252b; }
.table-editor-grid td { background: var(--bg-dark); }

.table-editor-grid input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-light);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  width: 120px;
  min-width: 60px;
}

.table-editor-grid th input { font-weight: 600; color: #fff; }
.table-editor-grid input:focus { background: rgba(82,139,255,.08); }

/* Alignment toggle row */
.table-editor-grid .align-row td {
  background: var(--bg-darker);
  text-align: center;
  padding: 2px 4px;
}

.align-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  color: #636d83;
  font-size: 11px;
  padding: 1px 5px;
  cursor: pointer;
  transition: all .1s;
}
.align-btn:hover,
.align-btn.active { background: var(--bg-panel); border-color: var(--accent); color: var(--accent); }

/* ── Focus / Presentation mode ── */
body.focus-mode .topbar,
body.focus-mode .toolbar,
body.focus-mode .find-bar,
body.focus-mode .tab-bar,
body.focus-mode .progress-wrap,
body.focus-mode .statusbar,
body.focus-mode .pane-preview,
body.focus-mode .resizer,
body.focus-mode .toc-panel,
body.focus-mode .pane-header { display: none !important; }

body.focus-mode .panes {
  height: 100vh;
  padding: 0;
}

body.focus-mode .pane-editor {
  width: 100%;
  max-width: 100%;
  flex: 1;
  background: var(--bg);
}

body.focus-mode .editor-wrap {
  display: flex;
  justify-content: center;
  background: var(--bg);
}

body.focus-mode #editor,
body.focus-mode #editor-mirror {
  max-width: 740px;
  width: 100%;
  padding: 60px 48px;
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: 0.01em;
  box-sizing: border-box;
}

body.focus-mode #editor {
  position: relative;
  background: transparent;
}

body.focus-mode #editor-mirror {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* Exit hint badge */
.focus-hint {
  position: fixed;
  top: 18px;
  right: 22px;
  background: rgba(255,255,255,.92);
  color: #333;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,.12);
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  pointer-events: none;
  z-index: 9999;
}

#tool-focus.active,
#tool-custom-css.active {
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
}

/* Custom CSS modal */
.custom-css-modal-inner {
  width: 560px;
  max-width: 96vw;
}
.modal-hint {
  font-size: 12px;
  color: #636d83;
  margin: -4px 0 12px;
  line-height: 1.5;
}
.modal-hint code {
  background: rgba(82,139,255,.12);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}
#custom-css-input {
  width: 100%;
  height: 240px;
  font-family: 'Consolas', 'Fira Mono', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  background: var(--bg-darker);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  box-sizing: border-box;
  tab-size: 2;
}

/* ── Help button ── */
.btn-help {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
}
.btn-help:hover { background: var(--bg-panel); border-color: var(--accent); color: var(--accent); }

/* ── Help modal ── */
.help-modal-inner {
  width: 720px;
  max-width: 96vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.help-header h2 {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 16px;
  font-weight: 800;
  background: linear-gradient(135deg, #E0955A 0%, #F0C179 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.help-close {
  background: none;
  border: none;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}
.help-close:hover { background: var(--bg-panel); color: var(--text-light); }
.help-body {
  overflow-y: auto;
  padding: 20px 24px 28px;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.help-section {
  margin-bottom: 28px;
}
.help-section:last-child { margin-bottom: 0; }
.help-section h3 {
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.help-section p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-light);
  margin-bottom: 8px;
}
.help-section p:last-child { margin-bottom: 0; }
.help-section ul {
  margin: 6px 0 0 18px;
  padding: 0;
}
.help-section ul li {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-light);
  margin-bottom: 4px;
}
.help-section pre {
  background: var(--bg-darker);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 14px;
  margin-top: 8px;
  overflow-x: auto;
}
.help-section pre code {
  font-family: 'Consolas', 'Fira Mono', monospace;
  font-size: 12px;
  color: var(--text-light);
  background: none;
  padding: 0;
}
.help-section code {
  font-family: 'Consolas', 'Fira Mono', monospace;
  font-size: 12px;
  background: rgba(232,168,102,.12);
  color: var(--accent-h);
  padding: 1px 5px;
  border-radius: 3px;
}
kbd {
  display: inline-block;
  font-family: 'Consolas', 'Fira Mono', monospace;
  font-size: 11px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 6px;
  color: var(--text-light);
  white-space: nowrap;
}
.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 6px;
}
.help-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-light);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-darker);
  font-size: 12px;
}
.help-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(58,53,64,.5);
  color: var(--text);
  vertical-align: middle;
}
.help-table tr:last-child td { border-bottom: none; }
.help-table tr:hover td { background: rgba(255,255,255,.03); }

/* ── Print styles ── */
@media print {
  /* Everything hidden except the hidden-print-root injected by JS */
  body > *:not(#print-root) { display: none !important; }
}
