/* ── Tokens ─────────────────────────────────────────────────────────────────── */
:root {
  --bg:        #0a0008;
  --surface:   #130011;
  --surface2:  #1c0019;
  --border:    rgba(201,168,76,0.15);
  --gold:      #c9a84c;
  --gold-dim:  rgba(201,168,76,0.5);
  --gold-faint:rgba(201,168,76,0.08);
  --cream:     #f0e8d5;
  --cream-dim: rgba(240,232,213,0.65);
  --muted:     rgba(240,232,213,0.35);
  --dim:       rgba(240,232,213,0.18);
  --done-clr:  #7abf90;
  --prog-clr:  #c9a84c;
  --radius:    10px;
  --serif:     Georgia, 'Times New Roman', serif;
  --sans:      'Outfit', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --display:   'Playfair Display', Georgia, serif;
  /* View prefs — overridden by JS */
  --editor-max-width: 820px;
  --editor-font-size: 17px;
  --editor-line-height: 1.9;
  --editor-h-padding: 44px;
}

/* ── Light Mode ──────────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #faf7f2;
  --surface:   #f3ede3;
  --surface2:  #ece4d6;
  --border:    rgba(180,140,60,0.2);
  --gold:      #a07830;
  --gold-dim:  rgba(160,120,48,0.5);
  --gold-faint:rgba(160,120,48,0.08);
  --cream:     #2a1f0e;
  --cream-dim: rgba(42,31,14,0.7);
  --muted:     rgba(42,31,14,0.45);
  --dim:       rgba(42,31,14,0.25);
  --done-clr:  #3a8f56;
  --prog-clr:  #a07830;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--cream);
  height: 100vh;
  overflow: hidden;
}
button { cursor: pointer; border: none; font: inherit; color: inherit; background: none; }
input, textarea { font: inherit; color: inherit; }
code { font-family: 'Menlo', 'Courier New', monospace; font-size: 0.85em; color: var(--gold); }

/* ── App shell ──────────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
#hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 56px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#hdr-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }

#hdr-icon {
  font-size: 18px;
  color: var(--gold);
  flex-shrink: 0;
  opacity: 0.7;
}

#hdr-title {
  font-family: var(--display);
  font-style: italic;
  font-size: 15px;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#hdr-stats {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.dot { color: var(--dim); }

#hdr-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

#prog-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
#prog-bar { width: 100px; height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
#prog-fill { height: 100%; background: var(--gold); border-radius: 2px; transition: width 0.5s ease; width: 0%; }
#prog-pct { font-size: 10px; color: var(--muted); }

#btn-add {
  background: var(--gold);
  color: #0a0008;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 20px;
  letter-spacing: 0.02em;
  transition: opacity 0.18s;
}
#btn-add:hover { opacity: 0.85; }

#btn-theme {
  font-size: 14px;
  color: var(--muted);
  padding: 5px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: color 0.18s, border-color 0.18s;
  line-height: 1;
}
#btn-theme:hover { color: var(--gold); border-color: var(--gold-dim); }

#btn-undo {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: color 0.18s, border-color 0.18s, opacity 0.18s;
}
#btn-undo:hover:not(:disabled) { color: var(--cream); border-color: var(--gold-dim); }
#btn-undo:disabled { opacity: 0.3; cursor: not-allowed; }

#btn-export {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: color 0.18s, border-color 0.18s;
}
#btn-export:hover { color: var(--cream); border-color: var(--gold-dim); }

/* ── Body layout ────────────────────────────────────────────────────────────── */
#body { display: flex; flex: 1; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
#sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sb-tabs {
  display: flex;
  gap: 0;
  padding: 10px 8px 0;
  flex-shrink: 0;
}

.sb-tab {
  flex: 1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 6px 4px;
  border-radius: 6px 6px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  text-align: center;
}
.sb-tab:hover { color: var(--muted); }
.sb-tab.active {
  color: var(--gold);
  background: var(--surface2);
  border-color: var(--border);
}

#ch-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
}
#ch-list::-webkit-scrollbar { width: 3px; }
#ch-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.ch-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 1px;
  transition: background 0.15s;
  position: relative;
}
.ch-item:hover { background: var(--surface2); }
.ch-item.active { background: rgba(201,168,76,0.1); }
.ch-item.active .ch-name { color: var(--gold); }

.ch-icon { font-size: 10px; flex-shrink: 0; width: 12px; text-align: center; }
.ch-item.done       .ch-icon { color: var(--done-clr); }
.ch-item.in-progress .ch-icon { color: var(--prog-clr); }
.ch-item.not-started .ch-icon { color: var(--dim); }

.ch-num  { font-size: 10px; color: var(--dim); flex-shrink: 0; width: 28px; }
.ch-name { font-size: 12.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--cream-dim); }
.ch-wc   { font-size: 10px; color: var(--dim); flex-shrink: 0; }

.ch-del {
  display: none;
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 15px; color: var(--dim); padding: 2px 4px; border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.ch-item:hover .ch-del { display: block; }
.ch-item:hover .ch-wc  { display: none; }
.ch-del:hover { color: #e06060; background: rgba(224,96,96,0.1); }

.ch-item[draggable="true"] { cursor: grab; }
.ch-item[draggable="true"]:active { cursor: grabbing; }
.ch-item.dragging { opacity: 0.35; background: var(--surface2); }
.ch-item.drag-over-top    { border-top: 2px solid var(--gold); margin-top: -1px; }
.ch-item.drag-over-bottom { border-bottom: 2px solid var(--gold); margin-bottom: -1px; }

.ch-group-droppable { transition: color 0.15s, background 0.15s; border-radius: 4px; }
.ch-group-droppable.drag-over-group {
  color: var(--gold);
  background: var(--gold-faint);
  outline: 1px dashed var(--gold-dim);
}

.empty-hint { font-size: 12px; color: var(--dim); text-align: center; padding: 32px 16px; line-height: 1.9; }

.ch-group-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  padding: 14px 10px 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ch-group-label[data-group] {
  cursor: pointer;
}
.ch-group-label[data-group]:hover {
  color: var(--gold);
}
.ch-group-edit {
  opacity: 0;
  font-size: 10px;
  transition: opacity 0.15s;
  font-style: normal;
  letter-spacing: 0;
  text-transform: none;
}
.ch-group-label[data-group]:hover .ch-group-edit {
  opacity: 1;
}
.ch-group-input {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--gold-faint);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  outline: none;
  padding: 2px 6px;
  width: 100%;
  margin: 10px 4px 2px;
}

/* ── Editor wrap ────────────────────────────────────────────────────────────── */
#editor-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── View toolbar ───────────────────────────────────────────────────────────── */
#view-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px 0;
  justify-content: flex-end;
  flex-shrink: 0;
}
.vt-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.vt-label {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 2px;
}
.vt-btn {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--dim);
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  line-height: 1.6;
}
.vt-btn:hover { color: var(--cream-dim); border-color: var(--border); }
.vt-btn.active {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: var(--gold-faint);
}
.vt-sep {
  width: 1px;
  height: 14px;
  background: var(--border);
}
/* Font size custom input */
#vt-size-custom {
  width: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--cream-dim);
  font-size: 11px;
  font-family: var(--sans);
  padding: 2px 4px;
  text-align: center;
  outline: none;
}
#vt-size-custom:focus { border-color: var(--gold-dim); }

/* Empty state */
#empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  gap: 8px;
}
#empty-icon { font-size: 28px; color: var(--gold-dim); opacity: 0.4; }
#empty p { font-size: 13px; }
.empty-sub { font-size: 11px; color: var(--dim); }

/* Editor */
#editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px var(--editor-h-padding) 0;
  max-width: var(--editor-max-width);
  width: 100%;
  margin: 0 auto;
}

#ed-top {
  flex-shrink: 0;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Collapse toggle */
#ed-top-meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.25s ease;
  max-height: 120px;
  opacity: 1;
}
#ed-top-meta.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}
#ed-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#btn-collapse {
  font-size: 11px;
  color: var(--dim);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}
#btn-collapse:hover { color: var(--muted); border-color: var(--border); }

#ed-chnum {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

/* Shared input style */
#ed-part, #ed-title, #ed-subtitle, #ed-notes {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  outline: none;
  padding: 0 0 6px;
  transition: border-color 0.2s;
}
#ed-part {
  font-size: 13px;
  color: var(--muted);
}
#ed-part::placeholder { color: var(--dim); }
#ed-part:focus { border-bottom-color: var(--border); }

#ed-title {
  font-family: var(--display);
  font-size: 22px;
  font-style: italic;
  color: var(--gold);
  line-height: 1.25;
  padding-bottom: 6px;
}
#ed-title::placeholder { color: var(--dim); }
#ed-title:focus { border-bottom-color: var(--gold-dim); }


#ed-fb-step {
  font-size: 12px;
  color: var(--gold);
  background: var(--gold-faint);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  outline: none;
  padding: 4px 12px;
  width: 180px;
  transition: border-color 0.2s, width 0.2s;
}
#ed-fb-step::placeholder { color: var(--gold-dim); font-style: italic; }
#ed-fb-step:focus { border-color: var(--gold); width: 220px; }

/* Main textarea */
#ed-body {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
  font-family: var(--serif);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  color: var(--cream);
  padding: 4px 0 24px;
  transition: font-size 0.15s ease;
}
#ed-body::placeholder { color: var(--dim); font-style: italic; font-size: 15px; }
#ed-body::-webkit-scrollbar { width: 3px; }
#ed-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Footer */
#ed-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#ef-left { display: flex; align-items: center; gap: 10px; }

#btn-voice {
  font-size: 12px;
  color: var(--muted);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: color 0.18s, border-color 0.18s;
}
#btn-voice:hover { color: var(--gold); border-color: var(--gold-dim); }

#voice-tag { font-size: 11px; color: var(--gold-dim); }

#ef-mid { display: flex; align-items: center; gap: 10px; }
#ed-wc   { font-size: 11px; color: var(--muted); }
#ed-save { font-size: 11px; color: var(--dim); }

#ef-right { display: flex; gap: 4px; }

.sbtn {
  font-size: 11px;
  color: var(--dim);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: all 0.18s;
}
.sbtn:hover { color: var(--muted); border-color: var(--dim); }

.sbtn.active[data-s="done"]        { color: var(--done-clr); border-color: var(--done-clr); background: rgba(122,191,144,0.1); }
.sbtn.active[data-s="in-progress"] { color: var(--gold);     border-color: var(--gold-dim); background: var(--gold-faint); }
.sbtn.active[data-s="not-started"] { color: var(--muted);    border-color: var(--dim);      background: rgba(255,255,255,0.04); }

/* ── Modals ─────────────────────────────────────────────────────────────────── */
#voice-overlay,
#export-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(6px);
  padding: 20px;
}

#voice-modal,
#export-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 480px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  overflow: hidden;
}

#voice-modal h3 {
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: 18px;
  color: var(--gold);
  padding: 24px 24px 6px;
}

#voice-modal p {
  font-size: 13px;
  color: var(--muted);
  padding: 0 24px;
  line-height: 1.6;
  margin-bottom: 12px;
}

/* Export modal — new layout */
#export-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 22px 14px;
  border-bottom: 1px solid var(--border);
}
#export-hdr h3 {
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: 18px;
  color: var(--gold);
  margin: 0;
}
#export-close {
  font-size: 15px;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: color 0.18s, border-color 0.18s;
}
#export-close:hover { color: var(--cream); border-color: var(--border); }

#export-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 16px 8px;
}
.exp-opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-align: left;
  transition: border-color 0.18s, background 0.18s;
  cursor: pointer;
}
.exp-opt:hover {
  border-color: var(--gold-dim);
  background: rgba(212,175,55,0.04);
}
.exp-opt-icon { font-size: 22px; flex-shrink: 0; }
.exp-opt-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.exp-opt-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--cream);
  font-family: var(--sans);
}
.exp-opt-desc {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--sans);
}
.exp-opt-arr {
  font-size: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

#export-dev {
  margin: 8px 16px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
#export-dev summary {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 14px;
  cursor: pointer;
  font-family: var(--sans);
  list-style: none;
  user-select: none;
}
#export-dev summary::-webkit-details-marker { display: none; }
#export-dev summary:hover { color: var(--cream); }
#export-dev[open] summary { border-bottom: 1px solid var(--border); }
#export-dev-foot {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
#export-copy {
  font-size: 12px;
  font-weight: 600;
  background: var(--gold);
  color: #0a0008;
  padding: 7px 16px;
  border-radius: 7px;
  transition: opacity 0.18s;
}
#export-copy:hover { opacity: 0.85; }

#voice-ta,
#export-ta {
  flex: 1;
  margin: 0 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--cream);
  resize: none;
  outline: none;
  min-height: 200px;
  max-height: 360px;
  transition: border-color 0.2s;
}
#voice-ta:focus, #export-ta:focus { border-color: var(--gold-dim); }
#voice-ta::placeholder { color: var(--dim); }

#export-ta { font-family: 'Menlo', 'Courier New', monospace; font-size: 12px; }

#voice-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px 24px;
}

#voice-cancel {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: color 0.18s;
}
#voice-cancel:hover { color: var(--cream); }

#voice-save {
  font-size: 13px;
  font-weight: 600;
  background: var(--gold);
  color: #0a0008;
  padding: 8px 20px;
  border-radius: 8px;
  transition: opacity 0.18s;
}
#voice-save:hover { opacity: 0.85; }

/* ── Final Book button ───────────────────────────────────────────────────────── */
#btn-add-fb {
  font-size: 12px;
  color: var(--gold-dim);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid rgba(201,168,76,0.25);
  transition: color 0.18s, border-color 0.18s, background 0.18s;
  font-weight: 600;
}
#btn-add-fb:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: var(--gold-faint);
}
#btn-add-fb.in-fb {
  color: var(--done-clr);
  border-color: rgba(122,191,144,0.4);
  background: rgba(122,191,144,0.08);
}
#btn-add-fb.in-fb:hover {
  color: #e06060;
  border-color: rgba(224,96,96,0.4);
  background: rgba(224,96,96,0.06);
}

/* ── Scribe button ───────────────────────────────────────────────────────────── */
#btn-scribe {
  font-size: 12px;
  color: var(--gold-dim);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid rgba(201,168,76,0.25);
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
#btn-scribe:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: var(--gold-faint);
}

/* ── Scribe panel ────────────────────────────────────────────────────────────── */
#scribe-panel {
  position: fixed;
  right: -460px;
  top: 0;
  width: 440px;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
}
#scribe-panel.open { right: 0; }

#scribe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#scribe-title {
  font-family: var(--display);
  font-style: italic;
  font-size: 16px;
  color: var(--gold);
}
#scribe-close {
  font-size: 20px;
  color: var(--dim);
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
}
#scribe-close:hover { color: var(--cream); }

#scribe-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

#scribe-mode {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--cream-dim);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
#scribe-mode:focus { border-color: var(--gold-dim); }

#scribe-ctx-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
#scribe-ctx { accent-color: var(--gold); cursor: pointer; }

#scribe-input {
  flex-shrink: 0;
  margin: 0 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--cream);
  resize: none;
  outline: none;
  height: 90px;
  transition: border-color 0.2s;
}
#scribe-input:focus { border-color: var(--gold-dim); }
#scribe-input::placeholder { color: var(--dim); font-style: italic; }

#scribe-send {
  flex-shrink: 0;
  margin: 10px 16px 0;
  background: var(--gold);
  color: #0a0008;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  transition: opacity 0.18s;
  align-self: stretch;
}
#scribe-send:hover:not(:disabled) { opacity: 0.85; }
#scribe-send:disabled { opacity: 0.45; cursor: not-allowed; }

#scribe-output {
  flex: 1;
  overflow-y: auto;
  margin: 12px 16px 0;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--cream-dim);
  min-height: 80px;
  font-family: var(--serif);
}
#scribe-output::-webkit-scrollbar { width: 3px; }
#scribe-output::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.scribe-cursor {
  display: inline-block;
  color: var(--gold);
  animation: blink 0.8s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.scribe-error {
  color: #e06060;
  font-family: var(--sans);
  font-size: 12px;
  font-style: italic;
}

.scribe-setup {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}
.scribe-setup p { margin: 0 0 10px; }
.scribe-setup a { color: var(--gold); }
.scribe-setup input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.scribe-setup button {
  background: var(--gold);
  color: #1a1007;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}

#scribe-insert {
  flex-shrink: 0;
  margin: 10px 16px 0;
  background: none;
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 12px;
  padding: 7px 16px;
  border-radius: 20px;
  transition: background 0.18s;
}
#scribe-insert:hover { background: var(--gold-faint); }

#scribe-footer {
  display: flex;
  justify-content: flex-end;
  padding: 10px 16px 16px;
  flex-shrink: 0;
}
#scribe-clear-key {
  font-size: 10px;
  color: var(--dim);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
#scribe-clear-key:hover { color: var(--muted); border-color: var(--border); }

/* ── Mentor button ───────────────────────────────────────────────────────────── */
#btn-mentor {
  font-size: 12px;
  color: rgba(220,120,60,0.8);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid rgba(220,120,60,0.3);
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
#btn-mentor:hover {
  color: #e07840;
  border-color: rgba(220,120,60,0.6);
  background: rgba(220,120,60,0.06);
}

/* ── Mentor panel ────────────────────────────────────────────────────────────── */
#mentor-panel {
  position: fixed;
  left: -400px;
  top: 0;
  width: 380px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid rgba(220,120,60,0.2);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 8px 0 32px rgba(0,0,0,0.4);
}
#mentor-panel.open { left: 0; }

#mentor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(220,120,60,0.15);
  flex-shrink: 0;
}
#mentor-title {
  font-family: var(--display);
  font-style: italic;
  font-size: 16px;
  color: #e07840;
}
#mentor-close {
  font-size: 20px;
  color: var(--dim);
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s;
}
#mentor-close:hover { color: var(--cream); }

#mentor-ch-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mentor-ch-name {
  font-family: var(--display);
  font-style: italic;
  font-size: 14px;
  color: var(--gold);
  line-height: 1.4;
}
.mentor-ch-meta {
  font-size: 11px;
  color: var(--muted);
}
.mentor-dim { color: var(--dim); font-style: italic; }

#mentor-exercise {
  margin: 14px 16px 0;
  padding: 12px 14px;
  background: rgba(220,120,60,0.06);
  border: 1px solid rgba(220,120,60,0.15);
  border-radius: 8px;
  flex-shrink: 0;
}
.mentor-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(220,120,60,0.6);
  margin-bottom: 6px;
}
#mentor-exercise-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--cream-dim);
  font-style: italic;
}

#mentor-push {
  flex-shrink: 0;
  margin: 14px 16px 0;
  background: #e07840;
  color: #0a0008;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 20px;
  letter-spacing: 0.03em;
  transition: opacity 0.18s;
  align-self: stretch;
}
#mentor-push:hover:not(:disabled) { opacity: 0.85; }
#mentor-push:disabled { opacity: 0.45; cursor: not-allowed; }

#mentor-output {
  flex: 1;
  overflow-y: auto;
  margin: 12px 16px 16px;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid rgba(220,120,60,0.12);
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.8;
  color: var(--cream-dim);
  font-family: var(--serif);
}
#mentor-output::-webkit-scrollbar { width: 3px; }
#mentor-output::-webkit-scrollbar-thumb { background: rgba(220,120,60,0.2); border-radius: 2px; }

.mentor-cursor {
  display: inline-block;
  color: #e07840;
  animation: blink 0.8s step-end infinite;
}
.mentor-error {
  color: #e06060;
  font-family: var(--sans);
  font-size: 12px;
  font-style: italic;
}

/* Mentor output sections */
.mp-section { margin-bottom: 18px; }
.mp-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(220,120,60,0.55);
  margin-bottom: 7px;
}
.mp-needs {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--cream-dim);
  font-family: var(--serif);
}
.mp-prompt {
  font-size: 13px;
  line-height: 1.75;
  color: var(--cream);
  font-family: var(--serif);
  font-style: italic;
  padding: 12px 14px;
  background: rgba(220,120,60,0.07);
  border-left: 2px solid rgba(220,120,60,0.4);
  border-radius: 0 6px 6px 0;
}
.mp-reminder {
  font-size: 13px;
  font-weight: 600;
  color: #e07840;
  font-family: var(--serif);
  font-style: italic;
  text-align: center;
  padding: 10px 0 0;
  border-top: 1px solid rgba(220,120,60,0.15);
}

/* ── Mentor API key modal ────────────────────────────────────────────────────── */
#mentor-key-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(6px);
  padding: 20px;
}
#mentor-key-modal {
  background: var(--surface);
  border: 1px solid rgba(220,120,60,0.3);
  border-radius: 14px;
  width: 480px;
  max-width: 100%;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#mentor-key-modal h3 {
  font-family: var(--display);
  font-weight: 400;
  font-style: italic;
  font-size: 20px;
  color: #e07840;
}
#mentor-key-modal p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
.mentor-key-hint { font-size: 12px !important; }
.mentor-key-hint a { color: var(--gold); }
#mentor-key-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--cream);
  outline: none;
  transition: border-color 0.2s;
}
#mentor-key-input:focus { border-color: rgba(220,120,60,0.5); }
#mentor-key-error {
  font-size: 12px;
  color: #e06060;
  font-style: italic;
}
#mentor-key-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
#mentor-key-cancel {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
#mentor-key-save {
  font-size: 13px;
  font-weight: 600;
  background: #e07840;
  color: #0a0008;
  padding: 8px 20px;
  border-radius: 8px;
  transition: opacity 0.18s;
}
#mentor-key-save:hover:not(:disabled) { opacity: 0.85; }
#mentor-key-save:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Upgrade Note Panel ───────────────────────────────────────────────────────── */
#upgrade-note {
  margin: 0 0 14px 0;
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 10px;
  background: rgba(201,168,76,0.05);
  overflow: hidden;
}
#upgrade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(201,168,76,0.15);
}
#upgrade-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
#upgrade-toggle {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--gold-dim);
  background: var(--gold-faint);
  cursor: pointer;
  transition: opacity 0.15s;
}
#upgrade-toggle:hover { opacity: 0.75; }
#upgrade-body {
  padding: 12px 16px 14px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--cream-dim);
  font-style: italic;
  white-space: pre-wrap;
}
#upgrade-note.collapsed #upgrade-body { display: none; }
#upgrade-note.collapsed {
  border-bottom: 1px solid rgba(201,168,76,0.25);
}
#upgrade-note.collapsed #upgrade-header { border-bottom: none; }

/* ── Group collapse toggle ───────────────────────────────────────────────────── */
.ch-group-toggle {
  cursor: pointer;
  font-size: 9px;
  opacity: 0.6;
  margin-right: 4px;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.ch-group-toggle:hover { opacity: 1; }
.ch-group-name {
  flex: 1;
  cursor: pointer;
}
.ch-group-label {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ── Cover Editor ────────────────────────────────────────────────────────────── */
#cover-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 20px;
}

#cover-modal {
  width: 100%;
  max-width: 1100px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Toolbar */
#cover-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  flex-wrap: wrap;
}
.cv-group { display: flex; align-items: center; gap: 6px; }
.cv-label {
  font-family: var(--sans); font-size: 10px;
  color: var(--dim); text-transform: uppercase;
  letter-spacing: 0.06em; margin-right: 2px;
}
.cv-theme, .cv-btn, #cv-img-clear, #cv-print, #cover-close {
  font-family: var(--sans); font-size: 12px;
  border: 1px solid var(--border); border-radius: 5px;
  padding: 4px 10px; cursor: pointer;
  background: none; color: var(--cream-dim);
  transition: all 0.15s;
}
.cv-theme:hover, .cv-btn:hover, #cv-img-clear:hover { color: var(--cream); border-color: var(--gold-dim); }
.cv-theme.active { color: var(--gold); border-color: var(--gold); background: var(--gold-faint); }
#cv-print { color: var(--gold); border-color: var(--gold-dim); }
#cv-print:hover { background: var(--gold-faint); }
#cover-close {
  font-size: 18px; padding: 2px 10px;
  border-color: transparent; color: var(--dim);
}
#cover-close:hover { color: var(--cream); }
.cv-btn { cursor: pointer; }

/* Stage — back + spine + front */
#cover-stage {
  display: flex;
  gap: 0;
  justify-content: center;
  align-items: stretch;
  filter: drop-shadow(0 20px 60px rgba(0,0,0,0.7));
}

/* Cover panels */
.cover-panel {
  width: 320px;
  min-height: 480px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 32px 28px;
  transition: background 0.3s, color 0.3s;
}

/* Spine */
#cover-spine {
  width: 36px;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  transition: background 0.3s;
}
#cv-spine-title, #cv-spine-author {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--serif);
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 200px;
}
#cv-spine-title { font-size: 12px; font-style: italic; }
#cv-spine-author { font-size: 10px; transform: rotate(180deg); }

/* Front cover layout */
#cv-front-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  z-index: 0; opacity: 0.35;
  transition: opacity 0.3s;
}
#cv-front-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  height: 100%; justify-content: space-between;
}
.cv-title-block { margin-top: auto; padding-top: 60%; }

/* Back cover layout */
#cover-back { justify-content: space-between; }
.cv-back-content { flex: 1; display: flex; flex-direction: column; gap: 20px; padding-top: 40px; }
.cv-back-footer {
  font-family: var(--sans); font-size: 10px;
  opacity: 0.5; letter-spacing: 0.08em; text-transform: uppercase;
}

/* Editable fields */
.cv-editable {
  outline: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
  min-height: 1em;
  white-space: pre-wrap;
}
.cv-editable:focus { border-bottom-color: rgba(255,255,255,0.2); }
.cv-editable:empty:before {
  content: attr(data-placeholder);
  opacity: 0.3; font-style: italic; pointer-events: none;
}
.cv-main-title {
  font-family: var(--display); font-size: 32px; font-style: italic;
  line-height: 1.15; font-weight: 400; margin-bottom: 10px;
}
.cv-subtitle-cover {
  font-family: var(--sans); font-size: 13px;
  letter-spacing: 0.1em; text-transform: uppercase;
  opacity: 0.75; margin-bottom: auto;
}
.cv-author-name {
  font-family: var(--sans); font-size: 14px;
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-top: auto;
}
.cv-back-text {
  font-family: var(--serif); font-size: 14px;
  line-height: 1.75; flex: 1;
}
.cv-bio {
  font-family: var(--sans); font-size: 11px;
  line-height: 1.6; opacity: 0.7;
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 14px; margin-top: 10px;
}

/* ── Cover themes ─────────────────────────────────────────────────────────────── */
[data-cover-theme="dark"] .cover-panel,
[data-cover-theme="dark"] #cover-spine {
  background: #0a0008; color: #f0e8d5;
}
[data-cover-theme="dark"] #cover-front { border-left: 3px solid #c9a84c; }
[data-cover-theme="dark"] #cover-back  { border-right: 3px solid #c9a84c; }
[data-cover-theme="dark"] .cv-main-title { color: #c9a84c; }

[data-cover-theme="gold"] .cover-panel,
[data-cover-theme="gold"] #cover-spine {
  background: #c9a84c; color: #1a0e00;
}
[data-cover-theme="gold"] .cv-main-title { color: #1a0e00; }

[data-cover-theme="cream"] .cover-panel,
[data-cover-theme="cream"] #cover-spine {
  background: #f5efe2; color: #2a1a0e;
}
[data-cover-theme="cream"] .cv-main-title { color: #8b5e2a; }

[data-cover-theme="black"] .cover-panel,
[data-cover-theme="black"] #cover-spine {
  background: #000; color: #fff;
}
[data-cover-theme="black"] .cv-main-title { color: #fff; }
[data-cover-theme="black"] #cv-front-bg { opacity: 0.5; }

[data-cover-theme="wine"] .cover-panel,
[data-cover-theme="wine"] #cover-spine {
  background: #3d0c1f; color: #f5ebe0;
}
[data-cover-theme="wine"] .cv-main-title { color: #e8b88a; }
[data-cover-theme="wine"] #cover-front { border-left: 2px solid #e8b88a; }

/* Print */
@media print {
  body > *:not(#cover-overlay) { display: none !important; }
  #cover-overlay {
    position: static !important; background: none !important;
    padding: 0 !important;
  }
  #cover-toolbar { display: none !important; }
  #cover-stage { justify-content: center; }
}

/* ── Backup & Cover buttons ─────────────────────────────────────────────────── */
#btn-backup {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: color 0.18s, border-color 0.18s;
}
#btn-backup:hover { color: var(--cream); border-color: var(--gold-dim); }

#btn-cover {
  font-size: 12px;
  color: var(--gold-dim);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid rgba(201,168,76,0.25);
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
#btn-cover:hover {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: var(--gold-faint);
}

/* ── Focus mode button ──────────────────────────────────────────────────────── */
#btn-focus.active {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: var(--gold-faint);
}

/* ── Focus exit button ──────────────────────────────────────────────────────── */
#focus-exit {
  position: fixed;
  bottom: 28px;
  right: 28px;
  font-size: 12px;
  color: var(--dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 18px;
  z-index: 400;
  display: none;
  letter-spacing: 0.05em;
  transition: color 0.18s, border-color 0.18s;
}
#focus-exit:hover { color: var(--muted); border-color: var(--dim); }

/* ── Focus mode layout ──────────────────────────────────────────────────────── */
.focus-mode #focus-exit { display: block; }

.focus-mode #sidebar {
  width: 0 !important;
  min-width: 0 !important;
  overflow: hidden;
  padding: 0;
  border: none;
}
.focus-mode #view-toolbar { display: none; }
.focus-mode #btn-add, .focus-mode #btn-backup, .focus-mode #btn-export,
.focus-mode #btn-cover, .focus-mode #btn-undo, .focus-mode #btn-theme,
.focus-mode #prog-wrap { display: none; }
.focus-mode #ed-foot {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.focus-mode #ed-foot:hover {
  opacity: 1;
  pointer-events: all;
}
.focus-mode #ed-top-row { display: none; }
.focus-mode #ed-top-meta { display: none !important; }
.focus-mode #upgrade-note { display: none !important; }
.focus-mode #writing-prompts { display: none !important; }
.focus-mode #hdr-stats { display: none; }
.focus-mode #hdr { border-bottom-color: transparent; background: var(--bg); }
.focus-mode #ed-title { font-size: 26px; margin-bottom: 20px; }
.focus-mode #ed-body { font-size: calc(var(--editor-font-size) + 1px); }

/* ── Writing prompts ────────────────────────────────────────────────────────── */
#writing-prompts {
  padding: 14px 0 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s;
}
#writing-prompts.hidden { display: none; }
.wp-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 10px;
  display: block;
}
#wp-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wp-prompt {
  font-size: 13px;
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  font-family: var(--serif);
  font-style: italic;
  line-height: 1.5;
  width: 100%;
}
.wp-prompt:hover {
  color: var(--cream-dim);
  border-color: var(--gold-dim);
  background: var(--gold-faint);
}

/* ── Cloud save indicator ───────────────────────────────────────────────────── */
#ed-save { transition: color 0.3s; }
#ed-save.syncing { color: var(--gold-dim); }
#ed-save.synced  { color: var(--done-clr); }

/* ── Premium Paywall ────────────────────────────────────────────────────────── */
.paywall-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.paywall-inner {
  width: 540px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
}
.paywall-icon  { font-size: 30px; color: var(--gold); opacity: 0.7; }
.paywall-title {
  font-family: var(--display);
  font-weight: 700;
  font-style: italic;
  font-size: 40px;
  color: var(--cream);
  line-height: 1.1;
}
.paywall-tagline {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-top: -12px;
}
.paywall-desc {
  font-size: 16px;
  color: var(--muted);
  line-height: 1.75;
  max-width: 420px;
  font-family: var(--serif);
  font-style: italic;
}
.paywall-plans {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 6px;
}
.paywall-plan {
  padding: 14px 32px;
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--serif);
  cursor: pointer;
  transition: opacity 0.18s, transform 0.15s;
  border: none;
}
.paywall-plan:hover { opacity: 0.85; transform: translateY(-1px); }
.paywall-plan.primary {
  background: var(--gold);
  color: #0a0008;
  font-weight: 600;
}
.paywall-plan.secondary {
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  background: var(--gold-faint);
}
.paywall-footer { font-size: 13px; color: var(--dim); }
.paywall-footer a { color: var(--gold-dim); transition: color 0.15s; }
.paywall-footer a:hover { color: var(--gold); }

/* ── Onboarding Wizard ──────────────────────────────────────────────────────── */
#onboarding-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
#onboarding-overlay.visible { display: flex; }

#onboarding-modal {
  width: 580px;
  max-width: 100%;
}
.ob-step {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
  animation: ob-in 0.3s ease;
}
.ob-step.active { display: flex; }
@keyframes ob-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ob-symbol { font-size: 26px; color: var(--gold); opacity: 0.65; }
.ob-headline {
  font-family: var(--display);
  font-weight: 700;
  font-style: italic;
  font-size: 36px;
  color: var(--cream);
  line-height: 1.15;
}
.ob-sub {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.65;
  margin-top: -8px;
  max-width: 420px;
}
.ob-fields {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ob-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 15px 20px;
  font-size: 17px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--cream);
  outline: none;
  text-align: center;
  transition: border-color 0.2s;
}
.ob-input::placeholder { color: var(--dim); }
.ob-input:focus { border-color: var(--gold-dim); }

.ob-btn-primary {
  background: var(--gold);
  color: #0a0008;
  font-size: 15px;
  font-weight: 600;
  padding: 13px 40px;
  border-radius: 30px;
  letter-spacing: 0.04em;
  transition: opacity 0.18s, transform 0.15s;
}
.ob-btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.ob-btn-primary:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.ob-btn-ghost {
  background: none;
  color: var(--muted);
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: color 0.18s, border-color 0.18s;
}
.ob-btn-ghost:hover { color: var(--cream); border-color: var(--dim); }

.ob-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
}

/* Book type grid */
.ob-types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}
.ob-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 18px 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
}
.ob-type-btn:hover {
  border-color: var(--gold-dim);
  background: var(--surface2);
}
.ob-type-btn.selected {
  border-color: var(--gold);
  background: var(--gold-faint);
}
.ob-type-icon { font-size: 22px; line-height: 1; }
.ob-type-name { font-size: 13px; font-weight: 600; color: var(--cream-dim); }
.ob-type-desc { font-size: 11px; color: var(--dim); line-height: 1.4; }

/* Structure cards */
.ob-structure-opts { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.ob-struct-btn {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 4px 14px;
  padding: 18px 22px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
  width: 100%;
}
.ob-struct-btn:hover { border-color: var(--gold-dim); background: var(--surface2); }
.ob-struct-btn.active { border-color: var(--gold); background: var(--gold-faint); }
.ob-struct-icon {
  grid-row: 1 / 3;
  font-size: 20px;
  color: var(--dim);
  text-align: center;
}
.ob-struct-btn.active .ob-struct-icon { color: var(--gold); }
.ob-struct-btn strong { font-size: 14px; font-weight: 600; color: var(--cream-dim); }
.ob-struct-btn > span { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ── Mobile responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  #btn-backup, #btn-cover, #btn-undo { display: none; }
  #prog-wrap { display: none; }
}

@media (max-width: 700px) {
  #hdr { padding: 0 14px; height: 52px; gap: 10px; }
  #hdr-stats { display: none; }
  #sidebar { width: 200px; }
  #view-toolbar { flex-wrap: wrap; gap: 8px; padding: 6px 10px; }
  .vt-sep { display: none; }
  #btn-export { display: none; }
}

@media (max-width: 540px) {
  #sidebar {
    position: fixed;
    left: -100%;
    width: 80vw;
    top: 52px;
    height: calc(100vh - 52px);
    z-index: 200;
    transition: left 0.28s ease;
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  #sidebar.mobile-open { left: 0; }
  #editor-wrap { width: 100%; }
  #view-toolbar { display: none; }
  #ed-foot { flex-wrap: wrap; gap: 10px; }
  #ef-right { order: -1; width: 100%; justify-content: flex-start; }
  .ob-types { grid-template-columns: repeat(2, 1fr); }
  .paywall-title { font-size: 30px; }
  .ob-headline { font-size: 28px; }
  .paywall-plans { flex-direction: column; align-items: stretch; }
}

/* ── Book Profile button (sidebar) ──────────────────────────────────────────── */
#btn-book-profile {
  flex-shrink: 0;
  width: 100%;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-dim);
  padding: 10px 14px;
  border-radius: 8px;
  text-align: left;
  transition: color 0.18s, background 0.18s;
  background: none;
}
#btn-book-profile:hover { color: var(--gold); background: var(--gold-faint); }
#btn-book-profile.has-profile::after {
  content: ' ●';
  color: var(--done-clr);
  font-size: 8px;
  vertical-align: middle;
}

/* ── Book Profile modal ─────────────────────────────────────────────────────── */
#book-profile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 600;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(8px);
}
#book-profile-overlay.visible { display: flex; }

#book-profile-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 680px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}
#book-profile-modal::-webkit-scrollbar { width: 3px; }
#book-profile-modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

#bp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 16px;
  flex-shrink: 0;
}
#bp-header > div { display: flex; align-items: center; gap: 12px; }
.bp-symbol { font-size: 18px; color: var(--gold); opacity: 0.7; }
.bp-title {
  font-family: var(--display);
  font-weight: 700;
  font-style: italic;
  font-size: 22px;
  color: var(--gold);
}
#bp-close {
  font-size: 22px;
  color: var(--dim);
  padding: 2px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s;
}
#bp-close:hover { color: var(--cream); }

.bp-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
  padding: 0 28px 20px;
  border-bottom: 1px solid var(--border);
}

.bp-fields {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 0;
}
.bp-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
}
.bp-field:last-child { border-bottom: none; }

.bp-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--cream-dim);
  line-height: 1.4;
}
.bp-hint {
  font-size: 12px;
  color: var(--dim);
  font-style: italic;
  line-height: 1.5;
}
.bp-input {
  margin-top: 6px;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  font-family: var(--serif);
  color: var(--cream);
  resize: vertical;
  outline: none;
  line-height: 1.65;
  transition: border-color 0.2s;
}
.bp-input::placeholder { color: var(--dim); font-style: italic; font-size: 13px; }
.bp-input:focus { border-color: var(--gold-dim); }

#bp-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 28px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#bp-cancel {
  font-size: 13px;
  color: var(--muted);
  padding: 9px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: color 0.18s;
}
#bp-cancel:hover { color: var(--cream); }
#bp-save {
  font-size: 13px;
  font-weight: 600;
  background: var(--gold);
  color: #0a0008;
  padding: 9px 24px;
  border-radius: 8px;
  transition: opacity 0.18s;
}
#bp-save:hover { opacity: 0.85; }

/* ── Language picker ──────────────────────────────────────────────────────────── */
#lang-picker {
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 6px;
  cursor: pointer;
  font-family: var(--sans);
  transition: color 0.18s, border-color 0.18s;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
}
#lang-picker:hover { color: var(--gold); border-color: var(--gold-dim); }
#lang-picker option { background: var(--bg); color: var(--text); }
.focus-mode #lang-picker { display: none; }

/* ── Sidebar bottom (Book Profile + Feedback) ────────────────────────────────── */
#sb-bottom {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Writing mode toggle ─────────────────────────────────────────────────────── */
#btn-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 9px 14px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--sans);
  letter-spacing: 0.02em;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
  cursor: pointer;
}
#btn-mode-toggle:hover { color: var(--cream); border-color: var(--gold-dim); }

/* In clean mode the button glows gold to show it's active */
.clean-mode #btn-mode-toggle {
  color: var(--gold);
  border-color: var(--gold-dim);
  background: var(--gold-faint);
}

/* Elements hidden in clean mode */
.clean-mode #writing-prompts,
.clean-mode #btn-scribe,
.clean-mode #btn-mentor,
.clean-mode #btn-voice,
.clean-mode #voice-tag {
  display: none !important;
}

#btn-feedback {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 9px 14px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--sans);
  transition: color 0.18s, border-color 0.18s;
  letter-spacing: 0.01em;
}
#btn-feedback:hover { color: var(--gold); border-color: var(--gold-dim); border-style: solid; }

/* ── Feedback modal ──────────────────────────────────────────────────────────── */
#feedback-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#feedback-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: min(520px, 92vw);
  box-shadow: 0 24px 64px rgba(0,0,0,0.45);
  animation: ob-in 0.28s cubic-bezier(.22,.61,.36,1);
}
#fb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
#fb-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
#fb-close {
  color: var(--muted);
  font-size: 20px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}
#fb-close:hover { color: var(--text); }
#fb-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 18px;
}
#fb-ta {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.7;
  padding: 14px 16px;
  resize: vertical;
  min-height: 110px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.18s;
}
#fb-ta:focus { border-color: var(--gold-dim); }
#fb-ta::placeholder { color: var(--muted); opacity: 0.6; }
#fb-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
#fb-cancel {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 8px;
  transition: color 0.15s;
}
#fb-cancel:hover { color: var(--text); }
#fb-send {
  font-size: 13px;
  font-weight: 600;
  color: var(--bg);
  background: var(--gold);
  padding: 9px 22px;
  border-radius: 8px;
  letter-spacing: 0.02em;
  transition: opacity 0.18s;
}
#fb-send:hover { opacity: 0.85; }
#fb-send:disabled { opacity: 0.5; cursor: default; }

/* ── Notification toast ──────────────────────────────────────────────────────── */
#notif-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: 380px;
  width: calc(100vw - 56px);
  background: var(--surface);
  border: 1px solid var(--gold-dim);
  border-radius: 14px;
  padding: 18px 18px 18px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(212,175,55,0.12);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.32s ease, transform 0.32s cubic-bezier(.22,.61,.36,1);
  pointer-events: none;
}
#notif-toast.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#notif-icon {
  font-size: 18px;
  color: var(--gold);
  flex-shrink: 0;
  margin-top: 2px;
  line-height: 1;
}
#notif-body {
  flex: 1;
  min-width: 0;
}
#notif-msg {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.55;
  margin: 0 0 12px;
  font-family: var(--sans);
}
#notif-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
#notif-dismiss {
  font-size: 12px;
  font-weight: 600;
  color: var(--bg);
  background: var(--gold);
  padding: 6px 16px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  transition: opacity 0.15s;
  line-height: 1;
}
#notif-dismiss:hover { opacity: 0.85; }
#notif-counter {
  font-size: 11px;
  color: var(--muted);
}
#notif-close {
  color: var(--muted);
  font-size: 18px;
  padding: 2px 6px;
  flex-shrink: 0;
  transition: color 0.15s;
  line-height: 1;
  margin-top: -2px;
}
#notif-close:hover { color: var(--text); }
.focus-mode #notif-toast { display: none !important; }

/* ── Admin panel ─────────────────────────────────────────────────────────────── */
#btn-admin {
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--muted);
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: color 0.18s, border-color 0.18s;
}
#btn-admin:hover { color: var(--gold); border-color: var(--gold-dim); }

#admin-overlay {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
#admin-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: min(680px, 95vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  animation: ob-in 0.28s cubic-bezier(.22,.61,.36,1);
  overflow: hidden;
}
#admin-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#admin-hdr-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
#admin-icon { font-size: 18px; color: var(--gold); }
#admin-hdr h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  font-family: var(--sans);
}
#admin-close {
  color: var(--muted);
  font-size: 22px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}
#admin-close:hover { color: var(--text); }

#admin-stats {
  display: flex;
  gap: 14px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.admin-stat {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  font-family: var(--sans);
  letter-spacing: 0.02em;
}
.pending-stat {
  background: rgba(212,175,55,0.12);
  color: var(--gold);
  border: 1px solid var(--gold-dim);
}
.done-stat {
  background: rgba(78,205,120,0.1);
  color: var(--done-clr);
  border: 1px solid rgba(78,205,120,0.2);
}

#admin-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-loading, .admin-empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 32px 0;
  font-family: var(--sans);
}

.admin-fb-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  transition: border-color 0.18s;
}
.admin-fb-item.pending { border-color: var(--gold-dim); }
.admin-fb-item.implemented { opacity: 0.55; }
.admin-fb-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.admin-fb-email {
  font-size: 12px;
  color: var(--gold-dim);
  font-family: var(--sans);
  font-weight: 500;
}
.admin-fb-date {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--sans);
}
.admin-fb-msg {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin: 0 0 12px;
  font-family: var(--serif);
  white-space: pre-wrap;
}
.admin-fb-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-status-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--sans);
}
.status-pending {
  background: rgba(212,175,55,0.1);
  color: var(--gold);
  border: 1px solid var(--gold-dim);
}
.status-implemented {
  background: rgba(78,205,120,0.1);
  color: var(--done-clr);
  border: 1px solid rgba(78,205,120,0.2);
}
.admin-mark-live {
  font-size: 12px;
  font-weight: 700;
  color: var(--bg);
  background: var(--gold);
  padding: 7px 16px;
  border-radius: 8px;
  letter-spacing: 0.03em;
  transition: opacity 0.15s;
  font-family: var(--sans);
}
.admin-mark-live:hover { opacity: 0.85; }
.admin-mark-live:disabled { opacity: 0.5; cursor: default; }

#admin-announce-section {
  border-top: 1px solid var(--border);
  padding: 20px 28px 24px;
  flex-shrink: 0;
}
.admin-announce-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  font-family: var(--sans);
}
#admin-announce-ta {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 14px;
  resize: none;
  height: 72px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.18s;
  margin-bottom: 10px;
  display: block;
}
#admin-announce-ta:focus { border-color: var(--gold-dim); }
#admin-announce-ta::placeholder { color: var(--muted); opacity: 0.5; }
#admin-announce-send {
  font-size: 12px;
  font-weight: 700;
  color: var(--bg);
  background: var(--gold);
  padding: 8px 20px;
  border-radius: 8px;
  letter-spacing: 0.03em;
  transition: opacity 0.18s;
  font-family: var(--sans);
}
#admin-announce-send:hover { opacity: 0.85; }
#admin-announce-send:disabled { opacity: 0.5; cursor: default; }

/* ── Preferences panel ───────────────────────────────────────────────────────── */
#btn-prefs {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 9px 14px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--sans);
  letter-spacing: 0.02em;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
  cursor: pointer;
}
#btn-prefs:hover { color: var(--cream); border-color: var(--gold-dim); }
#btn-prefs.open { color: var(--gold); border-color: var(--gold-dim); background: var(--gold-faint); }

#prefs-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: ob-in 0.2s cubic-bezier(.22,.61,.36,1);
}
.prefs-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--sans);
  margin-bottom: 2px;
}
.pref-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 3px 0;
}
.pref-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.pref-row input[type="checkbox"]:checked {
  background: var(--gold);
  border-color: var(--gold);
}
.pref-row input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #0a0008;
  font-weight: 700;
  line-height: 1;
}
.pref-row span {
  font-size: 12.5px;
  color: var(--cream-dim);
  font-family: var(--sans);
  user-select: none;
}
.pref-row:hover span { color: var(--cream); }

.prefs-presets {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.prefs-presets button {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 0;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--sans);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.prefs-presets button:hover { color: var(--cream); border-color: var(--gold-dim); background: var(--gold-faint); }

/* ── Publish upsell modal ────────────────────────────────────────────────────── */
#publish-overlay {
  position: fixed; inset: 0; z-index: 1300;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
#publish-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  width: min(580px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 44px 40px 36px;
  text-align: center;
  position: relative;
  box-shadow: 0 40px 100px rgba(0,0,0,0.6);
  animation: ob-in 0.32s cubic-bezier(.22,.61,.36,1);
}
#publish-close {
  position: absolute;
  top: 18px; right: 22px;
  font-size: 22px;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}
#publish-close:hover { color: var(--cream); }
#publish-icon {
  font-size: 28px;
  color: var(--gold);
  margin-bottom: 18px;
}
#publish-title {
  font-family: var(--display);
  font-size: 26px;
  font-style: italic;
  color: var(--cream);
  margin-bottom: 14px;
  line-height: 1.3;
}
#publish-sub {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--cream-dim);
  line-height: 1.7;
  margin-bottom: 32px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
#publish-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  margin-bottom: 32px;
}
.pub-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  transition: border-color 0.18s;
}
.pub-option:hover { border-color: var(--gold-dim); }
.pub-opt-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}
.pub-opt-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pub-opt-body strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--cream);
  font-family: var(--sans);
}
.pub-opt-body span {
  font-size: 12.5px;
  color: var(--muted);
  font-family: var(--sans);
  line-height: 1.5;
}
#publish-cta {
  display: block;
  width: 100%;
  background: var(--gold);
  color: #0a0008;
  font-size: 14px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 12px;
  letter-spacing: 0.03em;
  font-family: var(--sans);
  transition: opacity 0.18s;
  margin-bottom: 12px;
}
#publish-cta:hover { opacity: 0.88; }
#publish-later {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--sans);
  padding: 8px;
  transition: color 0.15s;
}
#publish-later:hover { color: var(--cream); }

/* ── Admin tabs ──────────────────────────────────────────────────────────────── */
#admin-tabs {
  display: flex;
  gap: 6px;
  padding: 0 28px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.admin-tab {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--sans);
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.02em;
}
.admin-tab:hover { color: var(--cream-dim); }
.admin-tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.admin-tab-pane { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* ── Publish tab ─────────────────────────────────────────────────────────────── */
#admin-tab-publish {
  overflow-y: auto;
  padding: 20px 28px 28px;
  gap: 20px;
}

#admin-publish-leads {
  margin-bottom: 4px;
}
.pub-leads-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--sans);
  margin-bottom: 10px;
}
.pub-lead-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}
.pub-lead-email {
  font-size: 12.5px;
  color: var(--cream-dim);
  font-family: var(--sans);
}
.pub-lead-date {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--sans);
}
.pub-leads-empty {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--sans);
  font-style: italic;
  margin-bottom: 20px;
}

/* ── Publish tier cards ──────────────────────────────────────────────────────── */
.pub-tier {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 12px;
}
.pub-tier-premium {
  border-color: var(--gold-dim);
  background: var(--gold-faint);
}
.pub-tier-hdr {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.pub-tier-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--cream);
  font-family: var(--sans);
}
.pub-tier-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  font-family: var(--sans);
}
.pub-tier-margin {
  font-size: 11px;
  color: var(--done-clr);
  font-family: var(--sans);
  margin-left: auto;
  font-weight: 600;
}
.pub-tier-items {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pub-tier-items li {
  font-size: 12.5px;
  color: var(--cream-dim);
  font-family: var(--sans);
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
}
.pub-tier-items li::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: var(--gold-dim);
}
.pub-tier-costs {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--sans);
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* ── Publish offer cards (writer-facing modal) ───────────────────────────────── */
#publish-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-bottom: 20px;
}
.pub-offer {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px 14px;
  position: relative;
  transition: border-color 0.18s;
}
.pub-offer:hover { border-color: var(--gold-dim); }
.pub-offer-premium {
  border-color: var(--gold-dim);
  background: var(--gold-faint);
}
.pub-offer-badge {
  position: absolute;
  top: -10px; right: 16px;
  background: var(--gold);
  color: #0a0008;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--sans);
}
.pub-offer-hdr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.pub-offer-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--cream);
  font-family: var(--sans);
}
.pub-offer-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  font-family: var(--sans);
}
.pub-offer-items {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pub-offer-items li {
  font-size: 12px;
  color: var(--cream-dim);
  font-family: var(--sans);
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
}
.pub-offer-items li::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: var(--gold-dim);
}
.pub-offer-cta {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 9px;
  border-radius: 9px;
  font-family: var(--sans);
  letter-spacing: 0.03em;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.pub-offer-cta:hover { color: var(--cream); border-color: var(--gold-dim); background: var(--gold-faint); }
.pub-offer-cta-gold {
  background: var(--gold);
  border-color: var(--gold);
  color: #0a0008;
}
.pub-offer-cta-gold:hover { opacity: 0.88; background: var(--gold); color: #0a0008; }
.pub-lead-tier {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  font-family: var(--sans);
  background: var(--gold-faint);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 2px 8px;
  margin-left: auto;
  margin-right: 10px;
  text-transform: capitalize;
}

/* ── Admin books tab ─────────────────────────────────────────────────────────── */
#admin-tab-books {
  overflow-y: auto;
  padding: 16px 28px 24px;
  gap: 16px;
}
#admin-books-list { display: flex; flex-direction: column; gap: 8px; }

.admin-book-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.admin-book-cover {
  width: 36px;
  height: 52px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface2);
  flex-shrink: 0;
}
.admin-book-cover-ph {
  width: 36px;
  height: 52px;
  border-radius: 4px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--dim);
  flex-shrink: 0;
}
.admin-book-info { flex: 1; min-width: 0; }
.admin-book-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--cream);
  font-family: var(--sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-book-author {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--sans);
  margin-top: 2px;
}
.admin-book-source {
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  background: var(--gold-faint);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 2px 8px;
  font-family: var(--sans);
  flex-shrink: 0;
}
.admin-book-del {
  font-size: 16px;
  color: var(--dim);
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.admin-book-del:hover { color: #e06060; background: rgba(224,96,96,0.1); }

#admin-books-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}
.ab-row {
  display: flex;
  gap: 8px;
}
.ab-input, .ab-ta, .ab-select {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--cream);
  font-family: var(--sans);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
}
.ab-input:focus, .ab-ta:focus, .ab-select:focus { border-color: var(--gold-dim); }
.ab-input::placeholder, .ab-ta::placeholder { color: var(--muted); opacity: 0.6; }
.ab-ta { resize: none; height: 60px; }
.ab-select { cursor: pointer; }
.ab-row-foot { align-items: center; }
#ab-submit {
  font-size: 12px;
  font-weight: 700;
  color: var(--bg);
  background: var(--gold);
  padding: 9px 18px;
  border-radius: 8px;
  font-family: var(--sans);
  white-space: nowrap;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
#ab-submit:hover { opacity: 0.85; }
#ab-submit:disabled { opacity: 0.5; cursor: default; }
.admin-books-empty {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--sans);
  font-style: italic;
  padding: 12px 0;
}

/* ── Writing streak chip ────────────────────────────────────────────────────── */
#streak-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-family: var(--sans);
  color: var(--gold);
  letter-spacing: 0.02em;
}
#streak-chip .streak-n {
  font-weight: 700;
}
#streak-chip .streak-label {
  color: var(--muted);
  font-weight: 400;
}

/* ── Celebration overlay ────────────────────────────────────────────────────── */
#celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 4, 14, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.5s ease;
}
#celebration-overlay.cel-in {
  opacity: 1;
}
.cel-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  padding: 48px 40px;
  max-width: 480px;
  transform: scale(0.92) translateY(12px);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
#celebration-overlay.cel-in .cel-inner {
  transform: scale(1) translateY(0);
}
.cel-icon {
  font-size: 36px;
  color: var(--gold);
  animation: cel-pulse 2.4s ease infinite;
}
@keyframes cel-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(1.08); }
}
.cel-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 32px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0;
}
[data-theme="light"] .cel-title { color: #1a1028; }
.cel-sub {
  font-family: var(--sans);
  font-size: 16px;
  color: var(--muted);
  margin: 0;
  letter-spacing: 0.02em;
}
.cel-close {
  margin-top: 8px;
  padding: 10px 28px;
  border-radius: 4px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  background: transparent;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.cel-close:hover {
  background: rgba(212, 175, 55, 0.1);
  border-color: var(--gold);
}

/* ── XP Chip ───────────────────────────────────────────────────────────────── */
#xp-chip {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.03em;
  cursor: pointer;
}
.xp-dot { color: var(--muted); }

/* ── Badges Modal ──────────────────────────────────────────────────────────── */
#badges-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#badges-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 640px;
  max-height: 90vh; overflow-y: auto;
  padding: 28px; box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
#badges-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
#badges-title {
  font-family: var(--display); font-size: 22px; font-style: italic;
  color: var(--cream);
}
#badges-close {
  background: none; border: none; color: var(--muted); font-size: 22px;
  cursor: pointer; padding: 4px 8px;
}
#badges-xp-bar {
  background: var(--surface2); border-radius: 10px;
  padding: 14px 18px; margin-bottom: 22px;
}
#bxp-info { display: flex; justify-content: space-between; margin-bottom: 8px; }
#bxp-level-name { font-family: var(--display); font-style: italic; color: var(--gold); font-size: 14px; }
#bxp-points { font-size: 13px; color: var(--cream); }
#bxp-track {
  height: 6px; background: var(--border); border-radius: 3px;
  overflow: hidden; margin-bottom: 6px;
}
#bxp-fill { height: 100%; background: var(--gold); border-radius: 3px; transition: width 0.5s ease; }
#bxp-next { font-size: 11px; color: var(--muted); }
#badges-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px;
}
.badge-item {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 12px; text-align: center;
  position: relative; transition: transform 0.15s ease;
}
.badge-earned { border-color: rgba(201,168,76,0.4); }
.badge-earned:hover { transform: translateY(-2px); }
.badge-locked { opacity: 0.35; }
.badge-icon { font-size: 26px; margin-bottom: 6px; }
.badge-name { font-family: var(--display); font-size: 12px; color: var(--cream); font-style: italic; margin-bottom: 4px; }
.badge-desc { font-size: 10px; color: var(--muted); line-height: 1.4; }
.badge-check {
  position: absolute; top: 6px; right: 8px;
  font-size: 10px; color: var(--done-clr); font-weight: 700;
}

/* ── Progress Map View ─────────────────────────────────────────────────────── */
#map-view {
  flex: 1; overflow-y: auto; padding: 16px 12px;
}
.map-path {
  display: flex; flex-direction: column; gap: 0;
}
.map-node {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px; cursor: pointer; border-radius: 8px;
  transition: background 0.1s;
}
.map-node:hover { background: var(--gold-faint); }
.map-node-active { background: var(--gold-faint); }
.map-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--muted); flex-shrink: 0;
  transition: all 0.2s;
}
.map-label { flex: 1; font-size: 12px; color: var(--cream); }
.map-status-tag { font-size: 11px; flex-shrink: 0; }
.map-connector {
  width: 2px; height: 16px; background: var(--border);
  margin-left: 10px; flex-shrink: 0;
}
.map-legend {
  display: flex; gap: 12px; margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--border); flex-wrap: wrap;
}
.map-leg-item { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--muted); }
.map-leg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.map-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 24px 0; }

/* ── Readiness Score ───────────────────────────────────────────────────────── */
#readiness-section {
  background: var(--surface2); border-radius: 12px;
  padding: 16px 18px; margin-bottom: 12px;
}
#readiness-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
#readiness-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
#readiness-pct { font-family: var(--display); font-size: 22px; color: var(--gold); font-style: italic; }
#readiness-bar-wrap {
  height: 5px; background: var(--border); border-radius: 3px;
  overflow: hidden; margin-bottom: 14px;
}
#readiness-bar { height: 100%; background: var(--gold); border-radius: 3px; transition: width 0.5s ease; }
.rd-row {
  display: grid; grid-template-columns: 16px 1fr 110px 80px 40px;
  align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px;
}
.rd-ok { color: var(--done-clr); }
.rd-label { color: var(--cream-dim); }
.rd-detail { font-size: 11px; text-align: right; }
.rd-bar-wrap { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.rd-bar { height: 100%; background: var(--gold); border-radius: 2px; }
.rd-score { font-size: 11px; color: var(--muted); text-align: right; }

/* ── Query Letter Modal ────────────────────────────────────────────────────── */
#query-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#query-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 640px;
  max-height: 90vh; overflow-y: auto;
  padding: 28px; box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
#query-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
#query-title {
  font-family: var(--display); font-size: 20px; font-style: italic; color: var(--cream);
}
#query-close {
  background: none; border: none; color: var(--muted); font-size: 22px;
  cursor: pointer; padding: 4px 8px;
}
#query-desc { font-size: 13px; color: var(--cream-dim); margin-bottom: 18px; line-height: 1.6; }
#query-generate {
  background: var(--gold); color: #1a0e00; border: none;
  padding: 12px 24px; border-radius: 50px; font-size: 13px;
  font-weight: 700; cursor: pointer; margin-bottom: 20px;
}
#query-generate:disabled { opacity: 0.5; cursor: not-allowed; }
#query-ta {
  width: 100%; min-height: 320px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 10px;
  color: var(--cream); font-family: var(--serif); font-size: 14px;
  line-height: 1.7; padding: 16px; resize: vertical; box-sizing: border-box;
}
#query-foot { margin-top: 12px; text-align: right; }
#query-copy {
  background: none; border: 1px solid var(--border); color: var(--cream-dim);
  padding: 8px 16px; border-radius: 20px; font-size: 12px; cursor: pointer;
}

/* ── Publisher Wizard ──────────────────────────────────────────────────────── */
#publisher-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow-y: auto;
}
#publisher-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 920px;
  padding: 32px; box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
#publisher-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
#publisher-title {
  font-family: var(--display); font-size: 24px; font-style: italic; color: var(--cream);
}
#publisher-close {
  background: none; border: none; color: var(--muted); font-size: 24px;
  cursor: pointer; padding: 4px 8px;
}
#publisher-intro { font-size: 13px; color: var(--cream-dim); margin-bottom: 28px; }
#publisher-paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.pub-path {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; position: relative;
}
.pub-path-spotlight {
  border-color: rgba(201,168,76,0.5);
  background: linear-gradient(135deg, var(--surface2), rgba(201,168,76,0.06));
}
.pub-path-badge {
  position: absolute; top: -10px; left: 20px;
  background: var(--gold); color: #1a0e00;
  font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.pub-path-icon { font-size: 28px; margin-bottom: 8px; }
.pub-path-name { font-family: var(--display); font-size: 16px; font-style: italic; color: var(--cream); margin: 0 0 8px; }
.pub-path-desc { font-size: 12px; color: var(--cream-dim); margin-bottom: 12px; line-height: 1.5; }
.pub-path-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.pub-path-tag {
  font-size: 10px; padding: 3px 8px; border-radius: 20px;
  border: 1px solid var(--border); color: var(--muted);
}
.pub-path-steps { font-size: 12px; color: var(--cream-dim); line-height: 1.7; padding-left: 16px; margin-bottom: 16px; }
.pub-path-cta {
  display: block; width: 100%; padding: 10px 16px; border-radius: 50px;
  border: 1px solid var(--border); background: none; color: var(--cream);
  font-size: 12px; font-weight: 600; cursor: pointer; text-align: center;
  transition: all 0.2s;
}
.pub-path-cta:hover { border-color: var(--gold); color: var(--gold); }
.pub-path-cta-gold {
  background: var(--gold); color: #1a0e00; border-color: var(--gold);
}
.pub-path-cta-gold:hover { background: var(--gold-hi, #f5d840); }

/* ── Leaderboard ───────────────────────────────────────────────────────────── */
#leaderboard-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
#leaderboard-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 480px;
  max-height: 85vh; overflow-y: auto;
  padding: 28px; box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
#lb-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
#lb-title { font-family: var(--display); font-size: 20px; font-style: italic; color: var(--cream); }
#lb-close {
  background: none; border: none; color: var(--muted); font-size: 22px;
  cursor: pointer; padding: 4px 8px;
}
#lb-desc { font-size: 12px; color: var(--muted); margin-bottom: 18px; line-height: 1.5; }
#lb-optin {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface2); border-radius: 10px;
  margin-bottom: 20px;
}
#lb-optin-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--cream-dim); cursor: pointer; }
#lb-name {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  color: var(--cream); padding: 8px 12px; border-radius: 8px; font-size: 12px;
  min-width: 160px;
}
#lb-save {
  background: var(--gold); color: #1a0e00; border: none;
  padding: 8px 16px; border-radius: 20px; font-size: 12px;
  font-weight: 700; cursor: pointer;
}
.lb-table { width: 100%; }
.lb-th {
  display: grid; grid-template-columns: 30px 1fr 100px;
  font-size: 10px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em; padding: 0 8px 8px; border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.lb-row {
  display: grid; grid-template-columns: 30px 1fr 100px;
  align-items: center; padding: 8px; border-radius: 8px;
  margin-bottom: 4px; font-size: 13px;
}
.lb-me { background: var(--gold-faint); }
.lb-rank { font-family: var(--display); font-size: 15px; color: var(--gold); }
.lb-name { color: var(--cream); }
.lb-words { color: var(--gold); text-align: right; font-size: 12px; }
.lb-empty { font-size: 13px; color: var(--muted); text-align: center; padding: 20px 0; }
.lb-note { font-size: 11px; color: var(--dim); text-align: center; margin-top: 16px; }

/* ── Map tab button ────────────────────────────────────────────────────────── */
.sb-tab[data-mode="map"] { font-size: 14px; padding: 6px 10px; }

/* ── Admin Email Sequences tab ─────────────────────────────────────────────── */
.es-filter {
  font-size: 12px; padding: 5px 12px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  cursor: pointer; transition: all 0.15s;
}
.es-filter:hover { border-color: var(--accent); color: var(--accent); }
.es-filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#email-seq-table-wrap { overflow-x: auto; }
#email-seq-table th { white-space: nowrap; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
#email-seq-table tr:last-child { border-bottom: none; }

/* ── Quill Picker ──────────────────────────────────────────────────────────── */
#quill-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000; backdrop-filter: blur(6px);
}
#quill-modal {
  background: var(--bg); border-radius: 20px; padding: 32px 28px;
  max-width: 680px; width: 95%; max-height: 90vh; overflow-y: auto;
  border: 1px solid var(--border); box-shadow: 0 32px 80px rgba(0,0,0,0.45);
}
#quill-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
#quill-title { font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--fg); }
#quill-close { background: none; border: none; font-size: 24px; color: var(--muted); cursor: pointer; line-height: 1; }
#quill-subtitle { font-size: 14px; color: var(--muted); margin: 0 0 24px; font-style: italic; }
#quill-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px;
  margin-bottom: 20px;
}
.quill-card {
  border: 2px solid var(--border); border-radius: 14px; padding: 18px 14px;
  cursor: pointer; transition: all 0.2s; text-align: center; position: relative;
  background: var(--bg);
}
.quill-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.15); }
.quill-card.selected { border-color: var(--accent); background: var(--accent-faint, rgba(155,125,240,0.08)); }
.quill-card.selected::after {
  content: '✓'; position: absolute; top: 8px; right: 10px;
  color: var(--accent); font-size: 12px; font-weight: 700;
}
@keyframes quill-float {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%       { transform: translateY(-9px) rotate(-2deg); }
}
@keyframes pen-float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%       { transform: translateY(-8px) rotate(-1deg); }
}
@keyframes photo-breathe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.05); }
}
.quill-icon {
  height: 145px;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 14px;
  position: relative;
  background: #0a0510;
}
.pen-photo {
  width: 100%;
  height: 145px;
  object-fit: cover;
  object-position: center 25%;
  transition: transform 0.45s ease, filter 0.45s ease;
  filter: brightness(0.88) contrast(1.12) saturate(1.1);
  display: block;
}
.pen-photo.feather-type { animation: photo-breathe 4.2s ease-in-out infinite; }
.pen-photo.pen-type     { animation: photo-breathe 3.6s ease-in-out infinite; }
.quill-card:hover .pen-photo {
  animation: none;
  transform: scale(1.1);
  filter: brightness(1.05) contrast(1.12) saturate(1.25);
}
.quill-card.selected .pen-photo {
  animation: none;
  transform: scale(1.08);
  filter: brightness(1.1) contrast(1.1) saturate(1.3);
}
.pen-photo.golden-filter {
  filter: brightness(0.9) contrast(1.1) sepia(0.7) saturate(3.5) hue-rotate(-8deg);
}
.quill-card:hover .pen-photo.golden-filter {
  filter: brightness(1.1) sepia(0.6) saturate(4) hue-rotate(-8deg);
}
.quill-card.selected .pen-photo.golden-filter {
  filter: brightness(1.15) sepia(0.55) saturate(4.5) hue-rotate(-8deg);
}
/* Keep SVG styles for fallback */
.pen-svg { height: 115px; width: auto; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.4)); transition: transform 0.22s, filter 0.22s; }
.pen-svg.feather-type { animation: quill-float 3.4s ease-in-out infinite; }
.pen-svg.pen-type     { animation: pen-float 3s ease-in-out infinite; }
.quill-card:hover .pen-svg { animation: none; transform: translateY(-7px) rotate(-6deg) scale(1.1); filter: drop-shadow(0 12px 22px rgba(0,0,0,0.55)); }
.quill-card.selected .pen-svg { animation: none; transform: translateY(-8px) scale(1.12); filter: drop-shadow(0 12px 24px rgba(0,0,0,0.55)); }
.quill-name { font-family: var(--display); font-size: 14px; font-weight: 700; color: var(--fg); margin-bottom: 8px; }
.quill-desc { font-size: 12px; color: var(--muted); line-height: 1.55; margin-bottom: 10px; }
.quill-archetype {
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
  font-weight: 700;
}
#quill-chosen {
  display: none; align-items: center; gap: 12px; padding: 16px;
  background: var(--accent-faint, rgba(155,125,240,0.1)); border-radius: 12px;
  font-size: 14px; color: var(--fg); animation: fadeIn 0.3s;
}
#quill-chosen-inner em { color: var(--accent); font-style: normal; }
