:root {
  --bg-primary: #f8f7f2;
  --bg-secondary: #ffffff;
  --bg-sidebar: #efede6;
  --border-color: #e2ddd3;
  --text-main: #232725;
  --text-muted: #6b726e;
  --accent-green: #1b4332;
  --accent-green-hover: #2d6a4f;
  --accent-gold: #c59b27;
  --accent-gold-soft: #fefae0;
  --danger: #d90429;
  --danger-soft: #ffe5e8;
  --sidebar-width: 270px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
  --font-mono: SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

[data-theme="dark"] {
  --bg-primary: #121413;
  --bg-secondary: #1a1d1b;
  --bg-sidebar: #151716;
  --border-color: #2b2f2d;
  --text-main: #e8eae9;
  --text-muted: #8d9692;
  --accent-green: #40916c;
  --accent-green-hover: #52b788;
  --accent-gold: #e9c46a;
  --accent-gold-soft: #232014;
  --danger: #ef233c;
  --danger-soft: #381216;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body, html { height: 100%; font-family: var(--font-sans); color: var(--text-main); background: var(--bg-primary); overflow: hidden; }

/* SVG Icon Base */
.svg-icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex-shrink: 0; }

.app-container { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* Sidebar Layout */
.sidebar {
  width: var(--sidebar-width); background: var(--bg-sidebar); border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column; padding: 1rem; gap: 0.85rem; flex-shrink: 0; transition: transform 0.25s ease;
  z-index: 100;
}
.sidebar-header { display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; align-items: center; gap: 0.6rem; font-size: 1.1rem; color: var(--accent-green); font-weight: 700; }
.brand .brand-icon { width: 22px; height: 22px; }

.search-container { position: relative; display: flex; align-items: center; }
.search-container .search-icon { position: absolute; left: 0.6rem; color: var(--text-muted); width: 16px; height: 16px; }
.search-container input {
  width: 100%; padding: 0.5rem 0.6rem 0.5rem 2.2rem; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); background: var(--bg-secondary); color: var(--text-main); font-size: 0.85rem; cursor: pointer;
}

.nav-links { display: flex; flex-direction: column; gap: 0.2rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.75rem; border: none;
  background: transparent; color: var(--text-main); border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; font-size: 0.9rem;
}
.nav-item:hover { background: rgba(0,0,0,0.04); }
.nav-item.active { background: var(--bg-secondary); color: var(--accent-green); font-weight: 600; box-shadow: var(--shadow-sm); }
.nav-item .svg-icon { color: var(--text-muted); }
.nav-item.active .svg-icon { color: var(--accent-green); }

.sidebar-actions { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.2rem; }
.recent-section { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.5rem; }
.section-title { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); letter-spacing: 0.05em; padding-left: 0.2rem; }
.recent-list { display: flex; flex-direction: column; gap: 0.1rem; }
.recent-item { font-size: 0.82rem; padding: 0.4rem 0.5rem; cursor: pointer; border-radius: var(--radius-sm); color: var(--text-muted); text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.recent-item:hover { background: var(--bg-secondary); color: var(--text-main); }

/* Main Workspace */
.main-workspace { flex: 1; display: flex; flex-direction: column; background: var(--bg-primary); overflow: hidden; min-width: 0; }
.top-bar {
  height: 52px; border-bottom: 1px solid var(--border-color); display: flex;
  align-items: center; justify-content: space-between; padding: 0 1.25rem; background: var(--bg-secondary); flex-shrink: 0;
}
.top-bar-left { display: flex; align-items: center; gap: 0.75rem; }
.breadcrumbs { font-weight: 700; color: var(--accent-green); font-size: 0.85rem; letter-spacing: 0.04em; }
.top-bar-actions { display: flex; align-items: center; gap: 1rem; }
.status-indicator { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }

.content-area { flex: 1; overflow-y: auto; padding: 1.25rem; }
.route-view { display: flex; flex-direction: column; gap: 1.25rem; height: 100%; }
.route-view.hidden { display: none !important; }

/* Dashboard UI */
.dashboard-header { display: flex; justify-content: space-between; align-items: flex-end; }
.dashboard-header h1 { font-size: 1.6rem; color: var(--accent-green); }
.subtitle { font-size: 0.85rem; color: var(--text-muted); }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }
.widget-card {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; box-shadow: var(--shadow-sm);
}
.widget-title { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Buttons & Segmented Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; font-weight: 600; font-size: 0.85rem; transition: all 0.15s ease;
}
.btn-primary { background: var(--accent-green); color: #fff; }
.btn-primary:hover { background: var(--accent-green-hover); }
.btn-secondary { background: var(--accent-gold-soft); color: var(--text-main); border-color: var(--accent-gold); }
.btn-outline { border-color: var(--border-color); background: transparent; color: var(--text-main); }
.btn-outline:hover { background: var(--bg-sidebar); }
.btn-danger-icon { background: transparent; border: 1px solid var(--border-color); color: var(--danger); padding: 0.4rem; border-radius: var(--radius-sm); cursor: pointer; }
.btn-danger-icon:hover { background: var(--danger-soft); }
.icon-btn { background: transparent; border: none; cursor: pointer; color: var(--text-main); padding: 0.3rem; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: rgba(0,0,0,0.05); }

/* Master-Detail Notes & Studies View */
.notes-master-detail { display: flex; height: 100%; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-secondary); overflow: hidden; }

.notes-sidebar-panel {
  width: 290px; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; background: var(--bg-primary); flex-shrink: 0;
}
.notes-panel-header { padding: 0.75rem; border-bottom: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 0.5rem; }
.notes-search-box { width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 0.85rem; background: var(--bg-secondary); color: var(--text-main); }
.notes-filter-tabs { display: flex; gap: 0.25rem; background: var(--bg-sidebar); padding: 0.2rem; border-radius: var(--radius-sm); }
.filter-btn { flex: 1; padding: 0.3rem; border: none; background: transparent; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); cursor: pointer; border-radius: 4px; }
.filter-btn.active { background: var(--bg-secondary); color: var(--accent-green); box-shadow: var(--shadow-sm); }

.notes-list-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.note-card-item { padding: 0.75rem; border-bottom: 1px solid var(--border-color); cursor: pointer; display: flex; flex-direction: column; gap: 0.25rem; transition: background 0.15s ease; }
.note-card-item:hover { background: var(--bg-sidebar); }
.note-card-item.active { background: var(--bg-secondary); border-left: 4px solid var(--accent-green); }
.note-card-title { font-weight: 600; font-size: 0.9rem; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-card-snippet { font-size: 0.78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Editor Panel */
.notes-editor-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg-secondary); min-width: 0; }
.editor-header-bar { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border-color); gap: 0.75rem; }
.note-title-field { flex: 1; font-size: 1.3rem; font-weight: 700; border: none; outline: none; background: transparent; color: var(--text-main); font-family: var(--font-serif); }
.editor-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.timestamp { font-size: 0.75rem; color: var(--text-muted); }

.segmented-control { display: flex; background: var(--bg-primary); padding: 0.2rem; border-radius: var(--radius-sm); border: 1px solid var(--border-color); }
.seg-btn { padding: 0.3rem 0.6rem; border: none; background: transparent; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); cursor: pointer; border-radius: 4px; }
.seg-btn.active { background: var(--accent-green); color: #ffffff; }

.editor-relative-container { position: relative; flex: 1; display: flex; flex-direction: column; }
.markdown-editor, .markdown-preview {
  flex: 1; width: 100%; height: 100%; border: none; outline: none; background: var(--bg-secondary);
  padding: 1.25rem; font-size: 0.95rem; line-height: 1.7; color: var(--text-main); overflow-y: auto;
}
.markdown-editor { font-family: var(--font-mono); resize: none; }
.markdown-preview { font-family: var(--font-serif); }
.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 { margin-bottom: 0.5rem; color: var(--accent-green); }
.markdown-preview blockquote { border-left: 4px solid var(--accent-gold); background: var(--accent-gold-soft); padding: 0.5rem 1rem; font-style: italic; margin: 0.75rem 0; }

/* Slash Menu */
.slash-menu {
  position: absolute; top: 1rem; left: 1.25rem; background: var(--bg-secondary); border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md); border-radius: var(--radius-md); width: 280px; z-index: 50; display: flex; flex-direction: column; overflow: hidden;
}
.slash-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.85rem; cursor: pointer; transition: background 0.15s ease; }
.slash-item:hover { background: var(--bg-primary); }
.slash-item .svg-icon { color: var(--accent-green); }
.slash-item strong { display: block; font-size: 0.85rem; color: var(--text-main); }
.slash-desc { font-size: 0.75rem; color: var(--text-muted); }

/* Bible Navigator */
.bible-nav-container { display: flex; flex-direction: column; gap: 1.5rem; }
.testament-section h2 { font-size: 1.1rem; color: var(--accent-green); margin-bottom: 0.75rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3rem; }
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 0.5rem; }
.book-card {
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  padding: 0.5rem 0.25rem; border-radius: var(--radius-sm); text-align: center; cursor: pointer; font-weight: 600; font-size: 0.82rem; color: var(--text-main);
  transition: all 0.15s ease;
}
.book-card:hover { border-color: var(--accent-green); color: var(--accent-green); transform: translateY(-1px); }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem; }
.modal.hidden { display: none !important; }
.modal-content { background: var(--bg-secondary); border-radius: var(--radius-md); width: 100%; max-width: 500px; padding: 1.25rem; box-shadow: var(--shadow-md); border: 1px solid var(--border-color); }
.search-modal-header { display: flex; align-items: center; gap: 0.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
.search-modal-header input { flex: 1; border: none; outline: none; font-size: 1rem; background: transparent; color: var(--text-main); }
.search-results-list { max-height: 300px; overflow-y: auto; margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }

.mobile-only { display: none; }
.mobile-only-inline { display: none; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 90; }

/* Responsive Media Queries */
@media (max-width: 850px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .mobile-only { display: inline-flex; }

  .notes-master-detail { border: none; border-radius: 0; }
  .notes-sidebar-panel { width: 100%; display: flex; }
  .notes-editor-panel { width: 100%; display: none; }

  .notes-master-detail.show-editor .notes-sidebar-panel { display: none; }
  .notes-master-detail.show-editor .notes-editor-panel { display: flex; }
  .mobile-only-inline { display: inline-flex; }
  
  .note-title-field { font-size: 1.1rem; }
  .timestamp { display: none; }
}

/* Quiz Grid & Layout Styles */
.quiz-dashboard-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.quiz-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.quiz-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.quiz-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.quiz-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-green);
}

.quiz-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.quiz-card-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Modal Form Controls */
.form-modal {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Slash Menu Floating Overlay Fix */
.editor-container {
  position: relative; /* Container scope for relative menu positioning */
}

.slash-menu {
  position: absolute;
  top: 60px;
  left: 20px;
  z-index: 100;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0.5rem;
  width: 260px;
  max-height: 300px;
  overflow-y: auto;
}

.slash-menu.hidden {
  display: none !important;
}

.slash-item {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.slash-item:hover {
  background: var(--bg-sidebar);
}





