/* orOS Designer Theme — Nunito OFL — Pure CSS */

@font-face { font-family:'Nunito'; src:url('../fonts/nunito-regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'Nunito'; src:url('../fonts/nunito-medium.woff2') format('woff2'); font-weight:500; font-style:normal; font-display:swap; }
@font-face { font-family:'Nunito'; src:url('../fonts/nunito-semibold.woff2') format('woff2'); font-weight:600; font-style:normal; font-display:swap; }
@font-face { font-family:'Nunito'; src:url('../fonts/nunito-bold.woff2') format('woff2'); font-weight:700; font-style:normal; font-display:swap; }
@font-face { font-family:'Nunito'; src:url('../fonts/nunito-extrabold.woff2') format('woff2'); font-weight:800; font-style:normal; font-display:swap; }

:root {
  --bg-primary: #ffffff; --bg-secondary: #f6f5f1;
  --text-primary: #2b2723; --text-secondary: #756f68;
  --accent: #c8a96e; --accent-hover: #a08254;
  --border: #e2ded7; --shadow: rgba(40,30,15,0.07);
  --shadow-lg: 0 8px 30px rgba(40,30,15,0.12);
  --radius: 12px; --radius-sm: 6px;
  --header-h: 55px;
  --font-main: 'Nunito', system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, monospace;
}

[data-theme="dark"] {
  --bg-primary: #1b1a18; --bg-secondary: #252320;
  --text-primary: #e7e3dd; --text-secondary: #948e86;
  --accent: #daba83; --accent-hover: #c8a96e;
  --border: #393631; --shadow: rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s, color 0.3s;
}

body.landing-page {
  height: auto !important;
  min-height: 100vh;
  overflow-y: auto !important;
}

.container { max-width: 900px; margin: 0 auto; padding: 0 1.5rem; width: 100%; }

/* ---------- Header ---------- */
.header {
  background-color: color-mix(in srgb, var(--bg-secondary) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 0;
  position: sticky; top: 0; z-index: 100; flex-shrink: 0;
}
.header-content { max-width: 100%; margin: 0 auto; padding: 0 2rem; display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; font-family: var(--font-mono); font-size: 1.25rem; }
.logo-icon { width: 24px; height: 24px; flex-shrink: 0; }
.logo-text b { font-weight: 800; color: var(--text-primary); }
.logo-text i { font-style: normal; color: var(--accent); font-weight: 800; }
.version-badge { font-family: var(--font-mono); font-size: 0.65rem; font-weight: 600; color: var(--text-secondary); background: var(--bg-secondary); border: 1px solid var(--border); padding: 0.1rem 0.35rem; border-radius: 4px; margin-left: 0.25rem; vertical-align: middle; }
.header-controls { display: flex; gap: 0.4rem; align-items: center; }
.btn-control { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); padding: 0.45rem 0.75rem; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.85rem; font-family: var(--font-main); font-weight: 600; transition: all 0.2s; }
.btn-control:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon { width: 2rem; height: 2rem; padding: 0; display: flex; align-items: center; justify-content: center; font-size: 1.05rem; }
.lang-select { padding: 0.4rem 0.6rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background-color: var(--bg-primary); color: var(--text-primary); font-size: 0.85rem; font-family: var(--font-main); font-weight: 600; cursor: pointer; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 4rem 0; background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary)); }
.hero-logo { width: 72px; height: 72px; margin-bottom: 1rem; opacity: 0.85; }
.hero h1 { font-family: var(--font-mono); font-size: 3.5rem; margin-bottom: 0.5rem; letter-spacing: -0.03em; line-height: 1; }
.hero h1 b { font-weight: 800; }
.hero h1 i { font-style: normal; color: var(--accent); font-weight: 800; }
.hero p { color: var(--text-secondary); font-size: 1.125rem; max-width: 600px; margin: 0 auto; font-weight: 500; }

/* ---------- Tools Grid ---------- */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1.5rem; padding: 2rem 0; justify-items: center; }
.tool-card { background-color: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; text-decoration: none; color: var(--text-primary); transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 220px; max-width: 300px; }
.tool-card:hover { transform: translateY(-4px); box-shadow: 0 10px 30px var(--shadow); border-color: var(--accent); }
.tool-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.tool-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.3rem; }
.tool-desc { font-size: 0.85rem; color: var(--text-secondary); }

/* ---------- App Main Wrapper ---------- */
.editor-wrapper {
  background-color: var(--bg-secondary);
  flex: 1;
  width: 100%;
  overflow: hidden;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

#rich-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ---------- Rich Text Editor (both class AND id selectors) ---------- */
.rich-editor,
#rich-editor {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 2rem 3rem;
  font-family: var(--font-main);
  font-size: 1.05rem;
  line-height: 1.85;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  overflow-y: auto;
  position: relative;
  z-index: 1;
}

.rich-editor:empty::before,
#rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-secondary);
  opacity: 0.6;
  pointer-events: none;
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-style: normal;
}

.rich-editor h1, #rich-editor h1 { font-size: 1.8rem; font-weight: 800; margin: 1rem 0; }
.rich-editor h2, #rich-editor h2 { font-size: 1.4rem; font-weight: 700; margin: 0.8rem 0; }
.rich-editor h3, #rich-editor h3 { font-size: 1.15rem; font-weight: 700; margin: 0.6rem 0; }
.rich-editor blockquote, #rich-editor blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; margin: 0.5rem 0; color: var(--text-secondary); font-style: italic; }
.rich-editor code, #rich-editor code { font-family: var(--font-mono); background: var(--bg-primary); padding: 0.15rem 0.35rem; border-radius: 4px; font-size: 0.9em; }
.rich-editor u, #rich-editor u { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.rich-editor s, #rich-editor s { text-decoration: line-through; }

/* ========== FOCUS MODE (SPOTLIGHT) ========== */
.focus-spotlight {
  position: absolute;
  background: transparent;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 999;
  border-radius: 4px;
  border: 1px solid var(--accent);
  transition: top 0.1s ease, left 0.1s ease, width 0.1s ease, height 0.1s ease;
}

/* ========== SIDE PANELS (Metadata, Outline, WordFreq) ========== */
.side-panel,
.metadata-panel,
.outline-panel,
.wordfreq-panel {
  position: absolute;
  top: 1rem;
  width: 260px;
  max-height: 60%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.left-panel { left: 1rem; }
.right-panel { right: 1rem; }

.panel-header,
.metadata-header,
.outline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.panel-close-btn,
.close-metadata-btn,
.close-outline-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0;
}

.panel-close-btn:hover,
.close-metadata-btn:hover,
.close-outline-btn:hover { color: var(--accent); }

/* Metadata Panel Body */
.metadata-fields,
.metadata-body {
  overflow-y: auto;
  padding: 0.75rem;
  flex: 1;
}

.form-group { margin-bottom: 0.8rem; }
.form-group:last-of-type { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  margin-top: 0.6rem;
}

.form-label:first-child { margin-top: 0; }

.form-control,
.form-small,
.meta-field-input,
.meta-field-label,
meta-field-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus,
.form-small:focus { border-color: var(--accent); }

.meta-info,
.meta-dates {
  margin-top: 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meta-info p,
.meta-dates span {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Outline Panel Body */
.outline-list,
.outline-body {
  overflow-y: auto;
  padding: 0.4rem 0;
  flex: 1;
}

.outline-list::-webkit-scrollbar,
.outline-body::-webkit-scrollbar { width: 5px; }
.outline-list::-webkit-scrollbar-track,
.outline-body::-webkit-scrollbar-track { background: transparent; }
.outline-list::-webkit-scrollbar-thumb,
.outline-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.outline-item {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.outline-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.outline-item-h1 { padding-left: 0.75rem; font-weight: 700; color: var(--text-primary); }
.outline-item-h2 { padding-left: 1.5rem; font-weight: 600; }
.outline-item-h3 { padding-left: 2.25rem; font-size: 0.78rem; }

.outline-empty {
  padding: 1rem 0.75rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Word Frequency Panel Body */
.wordfreq-summary {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-secondary);
}
.wordfreq-summary .stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}
.wordfreq-summary .stat-row span:last-child {
  color: var(--accent);
  font-weight: 600;
}
.wordfreq-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.4rem 1rem;
}
.wordfreq-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.8rem;
}
.wordfreq-item .wf-word {
  min-width: 5rem;
  max-width: 8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.wordfreq-item.overused .wf-word {
  color: var(--accent);
}
.wordfreq-bar {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.wordfreq-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.wordfreq-item.overused .wordfreq-bar-fill {
  background: linear-gradient(90deg, var(--accent), #e8b87a);
}
.wordfreq-count {
  font-weight: 700;
  color: var(--text-primary);
  min-width: 1.8rem;
  text-align: right;
  font-size: 0.75rem;
}
.wordfreq-empty {
  padding: 1rem 0.75rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ========== READING PROGRESS BAR ========== */
.reading-progress,
.reading-progress-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background-color: var(--accent);
  z-index: 60;
  transition: width 0.08s ease-out;
  pointer-events: none;
}

/* ========== GOAL BAR ========== */
.goal-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.goal-unit {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-main);
  font-weight: 600;
  cursor: pointer;
}

.goal-target-input,
.goal-input {
  width: 80px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
}

.goal-target-input:focus,
.goal-input:focus { border-color: var(--accent); }

.goal-lock-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.goal-lock-label input { cursor: pointer; }

.goal-action-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.goal-action-btn:hover { background: var(--accent-hover); }

/* ========== STATS OVERLAY ========== */
.stats-overlay {
  position: absolute;
  bottom: 0.75rem;
  right: 1.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 10;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.editor-wrapper:hover .stats-overlay { opacity: 0.85; }

.stats-toggle {
  cursor: pointer;
  user-select: none;
  transition: opacity 0.2s ease;
}

.stats-toggle:hover {
  opacity: 0.85;
}

.stats-goal {
  font-size: 0.68rem;
  margin-top: 0.2rem;
}

.stats-detailed {
  position: absolute;
  bottom: calc(100% + 4px);
  left: auto;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  z-index: 200;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  pointer-events: auto;
  min-width: 200px;
}

.stats-detailed .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-detailed .stat-row span:last-child {
  color: var(--text-primary);
  font-weight: 600;
}

/* ========== FIND & REPLACE BAR ========== */
.find-replace-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.fr-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.fr-input {
  flex: 1;
  min-width: 120px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  outline: none;
}

.fr-input:focus { border-color: var(--accent); }

.fr-separator {
  align-self: center;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.fr-buttons {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.fr-button {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.fr-button:hover { background: var(--accent); color: white; border-color: var(--accent); }
.fr-button-secondary { opacity: 0.7; }
.fr-button-secondary:hover { opacity: 1; }

.fr-results {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-left: auto;
  align-self: center;
}

.close-button,
.close-fr-btn {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0;
  align-self: flex-start;
}

.close-button:hover,
.close-fr-btn:hover { color: var(--accent); }

/* ========== ACTIONS CONTAINER (Save/Open/Clear/Export) ========== */
.actions-container {
  display: flex;
  justify-content: center;
  padding: 1rem 2rem;
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.buttons-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.primary-btn {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.primary-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.warning-btn {
  color: #d9534f;
}

.warning-btn:hover {
  border-color: #d9534f;
  color: #d9534f;
}

.icon {
  font-size: 1.1rem;
}

.dropdown-container {
  position: relative;
}

.dropdown-trigger {
  min-width: 80px;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 120px;
  z-index: 200;
  overflow: hidden;
  display: none;
}

.dropdown-menu.visible { display: block; }

.dropdown-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.dropdown-menu button:hover {
  background: var(--accent);
  color: white;
}

/* ========== SECONDARY TOOLS GROUP (Goal/Outline/Metadata/Find/WordFreq) ========== */
.secondary-tools-group {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========== QUICK FORMAT TOOLBAR ========== */
.quick-format-toolbar {
  display: flex;
  gap: 0.25rem;
  margin: 0 auto;
  align-self: center;
  flex-wrap: wrap;
  padding: 0.75rem 2rem;
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fmt-btn {
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 0.3rem;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fmt-btn:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.fmt-btn:active { transform: scale(0.95); }

.fmt-divider {
  width: 1px;
  height: 1.4rem;
  background: var(--border);
  margin: 0 0.15rem;
  align-self: center;
  flex-shrink: 0;
}

/* ========== BACK TO TOP ========== */
.back-to-top-btn,
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  width: 3rem;
  height: 3rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  z-index: 99;
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-to-top-btn.visible,
.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top-btn:hover,
.back-to-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(200,169,110,0.4);
}

/* ========== FOOTER ========== */
.footer {
  background-color: var(--bg-primary);
  border-top: 1px solid var(--border);
  padding: 1rem 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.footer-inner {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.footer-link:hover { color: var(--accent); }

.footer-text { color: var(--text-secondary); }

.footer-credits {
  font-size: 0.8rem;
}

.footer-credits a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.footer-credits a:hover { text-decoration: underline; }

/* ========== ZEN MODE ========== */
[data-zen="true"] .header,
[data-zen="true"] .footer,
[data-zen="true"] .back-to-top-btn,
[data-zen="true"] .back-to-top,
[data-zen="true"] .toolbar,
[data-zen="true"] .stats-overlay,
[data-zen="true"] .find-replace-bar,
[data-zen="true"] .reading-progress,
[data-zen="true"] .reading-progress-bar,
[data-zen="true"] .goal-bar,
[data-zen="true"] .outline-panel,
[data-zen="true"] .metadata-panel,
[data-zen="true"] .wordfreq-panel,
[data-zen="true"] .quick-format-toolbar,
[data-zen="true"] .actions-container,
[data-zen="true"] .secondary-tools-group,
[data-zen="true"] .focus-spotlight {
  display: none !important;
}

[data-zen="true"] .editor-wrapper {
  min-height: 100vh !important;
  height: 100vh !important;
  border-radius: 0 !important;
  width: 100vw;
  max-width: 100vw;
}

[data-zen="true"] #rich-editor,
[data-zen="true"] .rich-editor {
  min-height: 100vh !important;
  height: 100vh !important;
}

/* ========== TOAST ========== */
.zentool-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background-color: var(--accent);
  color: white;
  padding: 1rem 2rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: all 0.3s ease;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.zentool-toast.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ========== CONTEXT MENU ========== */
.context-menu {
  position: fixed;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  min-width: 180px;
  overflow: hidden;
  animation: ctxFade 0.15s ease;
}

@keyframes ctxFade {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.cm-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: background 0.15s;
}

.cm-item:hover {
  background: var(--accent);
  color: white;
}

.cm-icon {
  font-family: var(--font-mono);
  font-weight: 800;
  min-width: 1.5rem;
  text-align: center;
}

.cm-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* ========== SETTINGS MODAL ========== */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
  padding: 0;
}

.close-btn:hover { color: var(--accent); }

.modal-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}

.tab-btn {
  padding: 0.75rem 0;
  margin-right: 1.5rem;
  background: none;
  border: none;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  padding: 1.25rem 1.5rem;
}

.shortcut-table {
  width: 100%;
  border-collapse: collapse;
}

.shortcut-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.shortcut-table td {
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.shortcut-table td:last-child {
  text-align: right;
}

kbd {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Toggles */
.toggles-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.toggle-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background-color: var(--border);
  border-radius: 12px;
  transition: 0.3s;
  cursor: pointer;
}

.slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.switch input:checked + .slider {
  background-color: var(--accent);
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

/* Install section */
.install-section {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
}

.btn-install {
  width: 100%;
  padding: 0.7rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-install:hover {
  background: var(--accent-hover);
}

.btn-install:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Settings divider */
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

/* ========== BETA SECTION IN SETTINGS ========== */
.beta-section {
  margin-top: 0.6rem;
  padding: 0.7rem;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: rgba(200, 169, 110, 0.06);
}

.beta-header {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.beta-warning {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 0.5rem;
  line-height: 1.35;
}

.beta-links {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.beta-btn {
  font-size: 0.72rem !important;
  padding: 0.35rem 0.6rem !important;
  border: 1px solid var(--accent) !important;
  color: var(--accent) !important;
  background: transparent !important;
  text-decoration: none !important;
  border-radius: 6px !important;
  transition: all 0.2s ease;
}

.beta-btn:hover {
  background: rgba(200, 169, 110, 0.12) !important;
}

/* ========== SCROLLBAR STYLING ========== */
#rich-editor::-webkit-scrollbar,
.rich-editor::-webkit-scrollbar {
  width: 8px;
}

#rich-editor::-webkit-scrollbar-track,
.rich-editor::-webkit-scrollbar-track {
  background: transparent;
}

#rich-editor::-webkit-scrollbar-thumb,
.rich-editor::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

#rich-editor::-webkit-scrollbar-thumb:hover,
.rich-editor::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* ========== HEADING FLASH ANIMATION ========== */
#rich-editor h1.outline-flash,
#rich-editor h2.outline-flash,
#rich-editor h3.outline-flash,
.rich-editor h1.outline-flash,
.rich-editor h2.outline-flash,
.rich-editor h3.outline-flash {
  animation: outlineFlash 1.2s ease;
}

@keyframes outlineFlash {
  0% { background-color: var(--accent); color: white; }
  100% { background-color: transparent; }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .header-content { padding: 0 1rem; }
  .quick-format-toolbar { gap: 0.15rem; padding: 0.5rem 1rem; }
  .fmt-btn { min-width: 1.9rem; height: 1.9rem; font-size: 0.8rem; }
  #rich-editor, .rich-editor { padding: 1.5rem 1.25rem; font-size: 1rem; }
  .hero h1 { font-size: 2.5rem; }
  .version-badge { display: none; }
  .footer-inner { padding: 0 1rem; }
  .find-replace-bar { padding: 0.5rem 0.75rem; }
  .goal-bar { padding: 0.5rem 0.75rem; }
  .stats-overlay { font-size: 0.65rem; bottom: 0.5rem; right: 0.75rem; }
  .fmt-divider { height: 1.2rem; }
  .side-panel, .outline-panel, .metadata-panel, .wordfreq-panel { width: 200px; right: 0.5rem; top: 0.5rem; max-height: 50%; }
  .left-panel { left: 0.5rem; }
  .outline-item { font-size: 0.78rem; }
  .meta-field-input, .form-control, .form-small { font-size: 0.78rem; }
  .actions-container { padding: 0.75rem 1rem; }
  .action-btn { padding: 0.5rem 0.75rem; font-size: 0.8rem; }
  .secondary-tools-group { padding: 0.4rem 0.75rem; }
  .tool-btn { width: 2rem; height: 2rem; font-size: 1rem; }
}

@media (max-width: 480px) {
  .lang-select { font-size: 0.75rem; padding: 0.3rem 0.4rem; }
  .btn-control { padding: 0.35rem 0.5rem; font-size: 0.75rem; }
  .btn-icon { width: 1.75rem; height: 1.75rem; }
  .fmt-btn { min-width: 1.7rem; height: 1.7rem; font-size: 0.75rem; }
  .modal-content { width: 95%; max-height: 90vh; }
  .tab-btn { font-size: 0.8rem; margin-right: 1rem; }
  .side-panel, .outline-panel, .metadata-panel, .wordfreq-panel { width: 180px; }
  .outline-item-h2 { padding-left: 1rem; }
  .outline-item-h3 { padding-left: 1.5rem; }
  .goal-unit { font-size: 0.75rem; padding: 0.3rem 0.4rem; }
  .goal-target-input, .goal-input { width: 60px; font-size: 0.75rem; }
  .goal-lock-label { font-size: 0.7rem; }
  .back-to-top-btn, .back-to-top { bottom: 1.5rem; right: 1.5rem; width: 2.5rem; height: 2.5rem; font-size: 1rem; }
}

/* ========== PRINT-FRIENDLY STYLING ========== */
@media print {
  body * {
    visibility: hidden !important;
  }
  #rich-editor,
  #rich-editor *,
  .rich-editor,
  .rich-editor * {
    visibility: visible !important;
  }
  #rich-editor,
  .rich-editor {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    font-size: 12pt !important;
    line-height: 1.6 !important;
  }
  #rich-editor h1, .rich-editor h1 { font-size: 22pt !important; page-break-after: avoid; }
  #rich-editor h2, .rich-editor h2 { font-size: 16pt !important; page-break-after: avoid; }
  #rich-editor h3, .rich-editor h3 { font-size: 14pt !important; page-break-after: avoid; }
  #rich-editor p, #rich-editor li,
  .rich-editor p, .rich-editor li {
    orphans: 3;
    widows: 3;
  }
  #rich-editor blockquote, .rich-editor blockquote {
    border-left: 3px solid #999 !important;
    color: #444 !important;
  }
  #rich-editor a, .rich-editor a {
    color: black !important;
    text-decoration: underline !important;
  }
  @page {
    margin: 2cm;
    size: A4;
  }
}