/* ============================================
   orOS Writer — style.css (FINAL v0.5-beta)
   All fixes: Background, Header, Footer, Settings Modal, Icons
   ============================================ */

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

/* ===== VARIABLES ===== */
:root {
  --font-primary: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg-dark: #1b1a18;
  --bg-surface: #1b1a18;
  --bg-toolbar: #141312;
  --bg-panel: #252320;
  --bg-input: #28262a;
  --bg-hover: rgba(255,255,255,0.06);
  --text-primary: #e8e6e3;
  --text-secondary: #a8a4a0;
  --text-muted: #6b6864;
  --accent-gold: #c8a96e;
  --accent-gold-light: #daba83;
  --accent-gold-dim: rgba(200,169,110,0.15);
  --border-color: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --danger: #e57373;
  --success: #81c784;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: 150ms ease;
}

/* ===== RESET ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-primary);
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== LANDING PAGE OVERRIDE ===== */
body.landing-page {
  height: auto !important;
  overflow-y: auto !important;
}

/* ===== HEADER COMPONENT ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  display: flex;
  align-items: center;
}

.header .header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-primary);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-gold);
}

.version-badge {
  background: var(--accent-gold-dim);
  color: var(--accent-gold-light);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  border: 1px solid var(--border-color);
}

.channel-badge.beta {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--accent-gold);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-family: var(--font-primary);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  min-width: 60px;
}

.lang-select:hover { border-color: var(--border-hover); }
.lang-select:focus { border-color: var(--accent-gold); }

.header-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: var(--transition);
  font-family: inherit;
}

.header-btn:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
  background: var(--accent-gold-dim);
}

/* ===== FOOTER COMPONENT ===== */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border-color);
  z-index: 1000;
  display: flex;
  align-items: center;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 20px;
  box-sizing: border-box;
  gap: 20px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.footer-version {
  font-weight: 600;
  color: var(--accent-gold);
}

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

.footer-center {
  text-align: center;
  flex: 1;
}

.footer-credits {
  font-size: 12px;
  color: var(--text-secondary);
}

.footer-link {
  color: var(--accent-gold);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

.footer-right {
  white-space: nowrap;
}

.footer-badge {
  font-size: 11px;
  color: var(--text-secondary);
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.footer-powered {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ===== BACK TO TOP BUTTON ===== */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--accent-gold);
  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.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(200,169,110,0.4); }

/* ===== EDITOR WRAPPER ===== */
#editor-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 112px);
  margin-top: 56px;
  background: var(--bg-dark);
}

#editor-wrapper h1, #editor-wrapper h2, #editor-wrapper h3,
#editor-wrapper button, #editor-wrapper input, #editor-wrapper select,
#editor-wrapper label, #editor-wrapper span, #editor-wrapper div {
  font-family: var(--font-primary);
}

/* ===== MAIN TOOLBAR ===== */
.main-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 998;
  gap: 8px;
  flex-shrink: 0;
}

.toolbar-group, .toolbar-left, .toolbar-center, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
}

/* ===== BUTTONS ===== */
.action-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition);
  font-size: 15px;
  flex-shrink: 0;
}

.action-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-gold-light);
}

.action-btn:active {
  background: var(--accent-gold-dim);
}

.fmt-text-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
}

.fmt-text-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-gold-light);
}

.fmt-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background var(--transition), color var(--transition);
}

.fmt-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-gold-light);
}

.mini-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: background var(--transition), color var(--transition);
  padding: 0 4px;
}

.mini-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-gold-light);
  border-color: var(--border-hover);
}

.tb-separator {
  width: 1px;
  height: 22px;
  background: var(--border-color);
  margin: 0 2px;
  flex-shrink: 0;
}

.action-btn .fa, .fmt-text-btn .fa, .fmt-btn .fa, .mini-btn .fa { font-size: inherit; line-height: 1; }

/* ===== DROPDOWN ===== */
.dropdown { position: relative; display: inline-flex; align-items: center; }
.dropdown-toggle { display: inline-flex; align-items: center; gap: 4px; }
.dropdown-arrow-icon { font-size: 11px !important; margin-left: 2px; opacity: 0.7; }
.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 999;
  overflow: hidden;
  margin-top: 4px;
}
.dropdown-content.visible { display: block; }
.dropdown-content button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-primary);
  font-size: 13px;
  transition: background var(--transition);
}
.dropdown-content button:hover { background: var(--bg-hover); color: var(--accent-gold-light); }

/* ===== GOAL BAR ===== */
.goal-bar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-color);
  z-index: 997;
  font-size: 13px;
  flex-shrink: 0;
}

.goal-bar select, .goal-bar input[type="number"] {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-family: var(--font-primary);
  font-size: 13px;
  outline: none;
}

.goal-lock-label { display: inline-flex; align-items: center; gap: 4px; color: var(--text-secondary); font-size: 13px; cursor: pointer; }

/* ===== FIND & REPLACE BAR ===== */
.find-replace-bar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border-color);
  z-index: 997;
  font-size: 13px;
  flex-shrink: 0;
}

.find-replace-bar input[type="text"] {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-family: var(--font-primary);
  font-size: 13px;
  outline: none;
  min-width: 140px;
}

.find-replace-bar .mini-btn {
  min-width: 80px;
}

.fr-results { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* ===== QUICK FORMAT TOOLBAR ===== */
.quick-format-toolbar {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* ===== READING PROGRESS ===== */
.reading-progress-container {
  width: 100%;
  height: 3px;
  background: transparent;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.reading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-light));
  transition: width 100ms ease;
  border-radius: 0 2px 2px 0;
  position: absolute;
  left: 0;
  top: 0;
}

/* ===== RICH EDITOR AREA ===== */
.rich-wrapper { flex: 1; position: relative; overflow: hidden; min-height: 0; background: var(--bg-dark); }
.rich-editor {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 48px 64px 120px;
  outline: none;
  font-family: var(--font-primary);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-primary);
  background: var(--bg-dark);
  caret-color: var(--accent-gold);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
  font-style: italic;
}

.rich-editor h1 { font-size: 2em; font-weight: 700; margin: 0.8em 0 0.4em; color: var(--accent-gold-light); line-height: 1.3; }
.rich-editor h2 { font-size: 1.6em; font-weight: 600; margin: 0.7em 0 0.35em; color: var(--accent-gold-light); line-height: 1.3; }
.rich-editor h3 { font-size: 1.3em; font-weight: 600; margin: 0.6em 0 0.3em; color: var(--text-primary); line-height: 1.3; }
.rich-editor p { margin: 0.5em 0; }
.rich-editor ul, .rich-editor ol { margin: 0.5em 0; padding-left: 1.8em; }
.rich-editor li { margin: 0.2em 0; }
.rich-editor blockquote { border-left: 3px solid var(--accent-gold); padding: 0.3em 0 0.3em 1em; margin: 0.8em 0; color: var(--text-secondary); font-style: italic; }
.rich-editor strong { color: var(--text-primary); font-weight: 700; }
.rich-editor em { font-style: italic; }
.rich-editor u { text-decoration-color: var(--accent-gold); }
.rich-editor code { background: var(--bg-input); padding: 2px 6px; border-radius: var(--radius-sm); font-family: 'Courier New', monospace; font-size: 0.9em; }
.rich-editor pre { background: var(--bg-input); padding: 12px 16px; border-radius: var(--radius-md); overflow-x: auto; margin: 0.8em 0; }
.rich-editor a { color: var(--accent-gold-light); text-decoration: underline; text-decoration-color: var(--accent-gold-dim); }

/* ===== SAVE INDICATOR OVERLAY ===== */
.save-indicator-overlay {
  position: absolute;
  bottom: 12px;
  left: 24px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  pointer-events: none;
  font-family: var(--font-primary);
  letter-spacing: 0.3px;
  z-index: 10;
  transition: opacity var(--transition);
}

/* ===== STATS OVERLAY ===== */
.stats-overlay {
  position: absolute;
  bottom: 12px;
  right: 24px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: auto;
  font-family: var(--font-primary);
  letter-spacing: 0.3px;
  z-index: 10;
}

.stats-default { cursor: pointer; opacity: 0.7; transition: opacity var(--transition); user-select: none; }
.stats-default:hover { opacity: 1; color: var(--accent-gold-light); }
.stats-goal { color: var(--accent-gold); opacity: 0.8; }
.stats-detailed {
  display: none;
  flex-direction: column;
  gap: 4px;
  position: absolute;
  bottom: 100%;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 6px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  font-size: 12px;
}

.stat-row { display: flex; justify-content: space-between; gap: 12px; color: var(--text-secondary); }
.stat-row span:last-child { color: var(--text-primary); font-weight: 600; }

/* ===== SIDE PANELS ===== */
.side-panel {
  position: fixed;
  top: 112px;
  right: 0;
  width: 280px;
  max-height: calc(100vh - 172px);
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 24px rgba(0,0,0,0.3);
  z-index: 996;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.panel-title { font-size: 13px; font-weight: 600; color: var(--accent-gold-light); text-transform: uppercase; letter-spacing: 0.5px; }
.panel-close { flex-shrink: 0; }
.panel-body { padding: 12px 14px; overflow-y: auto; flex: 1; }

.outline-item { padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-secondary); font-size: 13px; transition: background var(--transition), color var(--transition); margin-bottom: 2px; }
.outline-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.outline-item-h1 { padding-left: 10px; font-weight: 600; }
.outline-item-h2 { padding-left: 24px; font-weight: 500; }
.outline-item-h3 { padding-left: 38px; font-size: 12px; }
.outline-empty { color: var(--text-muted); font-size: 12px; font-style: italic; padding: 8px; text-align: center; }

@keyframes outline-flash-anim { 0%, 100% { background: transparent; } 50% { background: var(--accent-gold-dim); } }
.rich-editor h1.outline-flash, .rich-editor h2.outline-flash, .rich-editor h3.outline-flash { animation: outline-flash-anim 1.2s ease; }

.meta-field { margin-bottom: 12px; }
.meta-field label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.meta-field input[type="text"] { width: 100%; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 6px 10px; color: var(--text-primary); font-family: var(--font-primary); font-size: 13px; outline: none; transition: border-color var(--transition); }
.meta-field input[type="text"]:focus { border-color: var(--accent-gold); }
.meta-dates { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border-color); }
.meta-date-row { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }

.wordfreq-summary { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); }
.wordfreq-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.wf-word { min-width: 80px; font-size: 12px; color: var(--text-primary); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.wordfreq-bar { flex: 1; height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.wordfreq-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-light)); border-radius: 3px; transition: width 300ms ease; }
.wordfreq-count { min-width: 24px; text-align: right; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.wordfreq-item.overused .wf-word { color: var(--accent-gold-light); }
.wordfreq-empty { color: var(--text-muted); font-size: 12px; font-style: italic; padding: 8px; text-align: center; }

/* ===== FOCUS MODE SPOTLIGHT ===== */
.focus-spotlight { position: absolute; border: 2px solid var(--accent-gold); border-radius: 2px; box-shadow: 0 0 0 9999px rgba(0,0,0,0.4); pointer-events: none; z-index: 5; transition: all 100ms ease; }

/* ===== CONTEXT MENU ===== */
.context-menu { position: fixed; background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 10000; min-width: 160px; overflow: hidden; padding: 4px 0; }
.cm-item { display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer; color: var(--text-secondary); font-size: 13px; transition: background var(--transition), color var(--transition); }
.cm-item:hover { background: var(--bg-hover); color: var(--accent-gold-light); }
.cm-icon { width: 16px; text-align: center; font-size: 12px; }
.cm-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* ===== TOAST ===== */
.zentool-toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--bg-panel); border: 1px solid var(--border-color); color: var(--text-primary); padding: 10px 20px; border-radius: var(--radius-md); font-family: var(--font-primary); font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,0.4); z-index: 10001; opacity: 0; transition: opacity var(--transition), transform var(--transition); pointer-events: none; }
.zentool-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== ZEN MODE ===== */
[data-zen="true"] .header,
[data-zen="true"] #oros-footer,
[data-zen="true"] .main-toolbar,
[data-zen="true"] .quick-format-toolbar,
[data-zen="true"] .reading-progress-container {
  display: none !important;
}

[data-zen="true"] #editor-wrapper { height: 100vh; }
[data-zen="true"] .rich-editor { padding-top: 15vh; padding-bottom: 30vh; max-width: 720px; margin: 0 auto; }
[data-zen="true"] .save-indicator-overlay, [data-zen="true"] .stats-overlay { display: none; }
[data-zen="true"] .side-panel { display: none; }

/* ===== SCROLLBAR ===== */
.rich-editor::-webkit-scrollbar, .panel-body::-webkit-scrollbar, .wordfreq-list::-webkit-scrollbar { width: 6px; }
.rich-editor::-webkit-scrollbar-track, .panel-body::-webkit-scrollbar-track, .wordfreq-list::-webkit-scrollbar-track { background: transparent; }
.rich-editor::-webkit-scrollbar-thumb, .panel-body::-webkit-scrollbar-thumb, .wordfreq-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.rich-editor::-webkit-scrollbar-thumb:hover, .panel-body::-webkit-scrollbar-thumb:hover, .wordfreq-list::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ===== PRINT STYLES ===== */
@media print {
  body * { visibility: hidden; }
  .rich-editor, .rich-editor * { visibility: visible; }
  .rich-editor { position: absolute; left: 0; top: 0; width: 100%; height: auto; overflow: visible; padding: 0; color: #000; background: #fff; }
  .save-indicator-overlay, .stats-overlay, .main-toolbar, .quick-format-toolbar, .reading-progress-container, .side-panel, .context-menu { display: none !important; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .main-toolbar { flex-wrap: wrap; gap: 4px; padding: 6px 8px; }
  .toolbar-group { padding: 0 2px; gap: 2px; }
  .action-btn { width: 30px; height: 30px; font-size: 14px; }
  .fmt-text-btn { min-width: 26px; height: 26px; font-size: 13px; }
  .rich-editor { padding: 24px 20px 100px; font-size: 15px; }
  .save-indicator-overlay { bottom: 8px; left: 12px; font-size: 10px; }
  .stats-overlay { bottom: 8px; right: 12px; font-size: 10px; }
  .side-panel { width: 100%; max-width: 280px; }
  .header { height: 48px; }
  .version-badge { display: none; }
  .footer { height: 48px; }
}

@media (max-width: 480px) {
  .toolbar-center { order: 3; width: 100%; justify-content: center; margin-top: 4px; }
  .goal-bar, .find-replace-bar { padding: 6px 8px; font-size: 12px; }
  .find-replace-bar input[type="text"] { min-width: 100px; font-size: 12px; }
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --bg-dark: #faf9f7;
  --bg-surface: #f0efed;
  --bg-toolbar: #e8e6e3;
  --bg-panel: #ffffff;
  --bg-input: #f0efed;
  --bg-hover: rgba(0,0,0,0.04);
  --text-primary: #2a2825;
  --text-secondary: #6a6660;
  --text-muted: #a09c98;
  --border-color: rgba(0,0,0,0.08);
  --border-hover: rgba(0,0,0,0.15);
}

[data-theme="light"] .rich-editor { background: transparent; caret-color: var(--accent-gold); }
[data-theme="light"] .focus-spotlight { box-shadow: 0 0 0 9999px rgba(0,0,0,0.15); }

@media print { [data-theme="light"] .rich-editor { background: #fff; color: #000; } }

/* ===== LANDING PAGE HERO & TOOLS GRID ===== */
.hero {
  text-align: center;
  padding: 4rem 0;
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-dark));
}

.hero-logo {
  width: 72px;
  height: 72px;
  margin-bottom: 1rem;
  opacity: 0.85;
}

.hero h1 {
  font-family: var(--font-primary);
  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-gold); font-weight: 800; }
.hero p { color: var(--text-secondary); font-size: 1.125rem; max-width: 600px; margin: 0 auto; font-weight: 500; }

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

.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-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  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 rgba(0,0,0,0.12);
  border-color: var(--accent-gold);
}

.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); }

/* ===== SETTINGS MODAL ===== */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  font-family: var(--font-primary);
  transition: opacity 0.2s ease;
}

.settings-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.settings-modal-content {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 520px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.settings-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.settings-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.settings-close:hover {
  color: var(--danger);
  background: rgba(224, 108, 90, 0.1);
}

.settings-nav {
  display: flex;
  gap: 4px;
  padding: 12px 20px 0;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

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

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

.settings-body {
  padding: 20px;
}

.toggles-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.toggle-label {
  font-size: 14px;
  color: var(--text-primary);
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

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

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

.slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: var(--transition);
}

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

.switch input:checked + .slider::before {
  transform: translateX(18px);
  background: #fff;
}

.settings-divider,
.settings-subdivider {
  height: 1px;
  background: var(--border-color);
  margin: 12px 0;
}

.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.shortcut-table th {
  text-align: left;
  color: var(--text-secondary);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.shortcut-table td {
  padding: 6px 8px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.shortcut-table kbd {
  background: var(--bg-dark);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  font-family: monospace;
  color: var(--accent-gold);
}

.settings-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg-dark);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.install-section {
  margin-top: 16px;
  text-align: center;
}

.btn-install {
  background: var(--accent-gold);
  color: #1b1a18;
  border: none;
  border-radius: var(--radius);
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

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

.btn-install:disabled {
  opacity: 0.5;
  cursor: default;
}

.beta-section {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-dark);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.beta-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-gold);
  margin-bottom: 6px;
}

.beta-warning {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0 0 8px 0;
}

.beta-links {
  display: flex;
  gap: 8px;
}

.beta-btn {
  display: inline-block;
  font-size: 12px;
  color: var(--accent-gold);
  text-decoration: none;
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 4px;
}

.beta-btn:hover {
  background: var(--accent-gold-dim);
}

/* Fix: settings modal content not filling width */
.settings-modal-content .settings-body,
.settings-modal-content .tab-panel,
.settings-modal-content .toggles-container {
  width: 100%;
  box-sizing: border-box;
}

/* Fix: toggle label crowding the switch */
.toggle-row {
  gap: 16px;
}
.toggle-label {
  flex: 1;
  min-width: 0;
}

/* Fix: tool icon sizing for Fork Awesome on index */
.tool-icon .fa {
  font-size: 2rem;
}