/* ═══════════════════════════════════════════════════
   LucID — Bespoke 2026 Modern Design System & Layout
   Inspired by Matte Metallic Surfaces & Gold Accents
   ═══════════════════════════════════════════════════ */

/* ─── THEME DEFINITIONS ─────────────────────────── */

/* Theme 1: Dusk Ember / Steel & Gold (Dark) */
[data-theme="dusk-ember"] {
  --bg-base: #1c1f26;
  --bg-surface: #242832;
  --bg-elevated: #2d3340;
  --bg-hover: rgba(229, 169, 59, 0.12);
  --bg-active: rgba(229, 169, 59, 0.2);
  --accent: #e5a93b;
  --accent-hover: #d4972a;
  --accent-subtle: rgba(229, 169, 59, 0.15);
  --text-primary: #f2f4f8;
  --text-secondary: rgba(242, 244, 248, 0.72);
  --text-muted: rgba(242, 244, 248, 0.45);
  --border: rgba(242, 244, 248, 0.06);
  --border-hover: rgba(242, 244, 248, 0.15);
  --highlight: rgba(255, 255, 255, 0.05);
  --shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.35);
  --danger: #ff6b6b;
  --save-ok: #e5a93b;
  --scrollbar-track: #1c1f26;
  --scrollbar-thumb: #2d3340;
}

/* Theme 2: Warm Linen (Light) */
[data-theme="warm-linen"] {
  --bg-base: #fdf7e4;
  --bg-surface: #f5eed8;
  --bg-elevated: #faeed1;
  --bg-hover: rgba(187, 171, 140, 0.15);
  --bg-active: rgba(187, 171, 140, 0.22);
  --accent: #9e8a67;
  --accent-hover: #8a7756;
  --accent-subtle: rgba(158, 138, 103, 0.15);
  --text-primary: #2a251b;
  --text-secondary: rgba(42, 37, 27, 0.72);
  --text-muted: rgba(42, 37, 27, 0.45);
  --border: rgba(42, 37, 27, 0.06);
  --border-hover: rgba(42, 37, 27, 0.15);
  --highlight: rgba(255, 255, 255, 0.5);
  --shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.06);
  --danger: #c0392b;
  --save-ok: #9e8a67;
  --scrollbar-track: #fdf7e4;
  --scrollbar-thumb: #ded0b6;
}

/* Default Fallback */
:root {
  --bg-base: #1c1f26;
  --bg-surface: #242832;
  --bg-elevated: #2d3340;
  --bg-hover: rgba(229, 169, 59, 0.12);
  --bg-active: rgba(229, 169, 59, 0.2);
  --accent: #e5a93b;
  --accent-hover: #d4972a;
  --accent-subtle: rgba(229, 169, 59, 0.15);
  --text-primary: #f2f4f8;
  --text-secondary: rgba(242, 244, 248, 0.72);
  --text-muted: rgba(242, 244, 248, 0.45);
  --border: rgba(242, 244, 248, 0.06);
  --border-hover: rgba(242, 244, 248, 0.15);
  --highlight: rgba(255, 255, 255, 0.05);
  --shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.35);
  --danger: #ff6b6b;
  --save-ok: #e5a93b;
  --scrollbar-track: #1c1f26;
  --scrollbar-thumb: #2d3340;
}

/* ─── COLOR SCHEME & BROWSER ENGINE MODE ────────── */
html[data-theme="warm-linen"],
body[data-theme="warm-linen"] {
  color-scheme: light !important;
}

html[data-theme="dusk-ember"],
body[data-theme="dusk-ember"] {
  color-scheme: dark !important;
}

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

html {
  font-size: 16px;
  height: 100%;
  width: 100%;
}

body {
  height: 100%;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background 0.25s ease, color 0.25s ease;
}

.icon-svg {
  width: 1.125rem;
  height: 1.125rem;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

@keyframes iconSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.icon-spin {
  animation: iconSpin 1.1s linear infinite !important;
}

::selection {
  background: var(--accent-subtle);
  color: var(--text-primary);
}

/* ─── 100% PERFECT THEME-ADAPTIVE SCROLLBARS ─────── */
::-webkit-scrollbar {
  width: 0.375rem;
  height: 0.375rem;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 0.25rem;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ─── 3-PANE CONTAINER ──────────────────────────── */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg-base);
}

/* ─── SIDEBAR RESIZERS ──────────────────────────── */
.sidebar-resizer {
  width: 0.25rem;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  z-index: 10;
  transition: background 0.15s;
}
.sidebar-resizer:hover,
.sidebar-resizer.resizing {
  background: var(--accent);
}

/* ─── TOP BAR (3.25rem) ─────────────────────────── */
.brand-header,
.top-bar {
  height: 3.25rem;
  min-height: 3.25rem;
  max-height: 3.25rem;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.brand-header {
  border-right: 1px solid var(--border);
}

.brand-logo {
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -0.02rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.brand-logo-img {
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  object-fit: cover;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex: 1;
  min-width: 0;
}
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* DOCKED EXPAND SIDEBAR BUTTON IN TOP BAR */
.docked-expand-btn {
  margin-right: 0.25rem;
}
.docked-expand-btn.hidden { display: none !important; }

/* UN-CRAMPED VIEW MODE TABS (NO SUFFOCATING BORDERS) */
.view-tabs {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.375rem 0.5rem;
  gap: 0.625rem;
}
.view-tab {
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}
.view-tab:hover {
  color: var(--text-primary) !important;
  background: var(--bg-hover) !important;
}
.view-tab.active {
  background: var(--bg-elevated) !important;
  color: var(--accent) !important;
  border-color: transparent !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  font-weight: 600;
}

/* ICON BUTTONS (ANIMATES ICON ITSELF — NO HARSH HOVER BACKGROUND BOX) */
.icon-btn,
.theme-glow-btn {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer;
  padding: 0.375rem;
  border-radius: 0.375rem;
  font-size: 0.9375rem;
  opacity: 0.75;
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease, color 0.2s ease;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover,
.theme-glow-btn:hover {
  opacity: 1 !important;
  background: transparent !important;
  transform: translateY(-2px) scale(1.15);
  color: var(--accent) !important;
}
[data-theme="dusk-ember"] .theme-glow-btn {
  color: #e5a93b !important;
  filter: drop-shadow(0 0 8px rgba(229, 169, 59, 0.45));
}
[data-theme="warm-linen"] .theme-glow-btn {
  color: #9e8a67 !important;
  filter: drop-shadow(0 0 8px rgba(158, 138, 103, 0.45));
}

/* ─── SIDEBARS ──────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  transition: width 0.15s ease, opacity 0.2s ease;
  background: var(--bg-surface);
}

.left-pane {
  width: 18rem;
  min-width: 12rem;
  max-width: 30rem;
  flex-shrink: 0;
}

.right-pane {
  width: 16rem;
  min-width: 12rem;
  max-width: 25rem;
  flex-shrink: 0;
  padding: 1.25rem 1rem;
  overflow-y: auto;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  overflow: hidden;
  border: none;
  opacity: 0;
  pointer-events: none;
}

/* ─── LEFT SIDEBAR BODY & STREAMLINED EXPLORER TOOLBAR ─ */
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.875rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search-wrapper {
  position: relative;
  width: 100%;
}
.search-wrapper.hidden {
  display: none !important;
}

.search-input {
  width: 100%;
  font-size: 0.8125rem;
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  padding: 0.4375rem 0.75rem;
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* EXPLORER STREAMLINED TOOLBAR ROW (PREMIUM DESIGN ALIGNED WITH VIEW TABS) */
.tree-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0;
  gap: 0.5rem;
}

.explorer-mode-pill {
  display: flex;
  align-items: center;
  flex: 1;
  height: 2.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.25rem;
  gap: 0.25rem;
}

.explorer-pill-btn {
  flex: 1;
  height: 100%;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  transition: all 0.2s ease;
}
.explorer-pill-btn:hover {
  color: var(--text-primary) !important;
  background: var(--bg-hover) !important;
}
.explorer-pill-btn.active {
  background: var(--bg-elevated) !important;
  color: var(--accent) !important;
  border-color: transparent !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  font-weight: 600;
}

.explorer-actions-pill {
  display: flex;
  align-items: center;
  height: 2.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.25rem;
  gap: 0.125rem;
}

/* FIXED CONFINEMENT & ALIGNMENT FOR ACTION PILL BUTTONS */
.action-pill-btn {
  height: 100% !important;
  width: 1.875rem !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0.5rem !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  color: var(--text-secondary) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transform: none !important; /* PREVENT translateY(-2px) MISALIGNMENT */
  transition: background 0.15s ease, color 0.15s ease !important;
}
.action-pill-btn:hover {
  transform: none !important; /* KEEP OUTER HOVER BOX STRICTLY FLUSH AND ALIGNED */
  color: var(--accent) !important;
  background: var(--bg-hover) !important;
  opacity: 1 !important;
}
.action-pill-btn:hover .icon-svg {
  transform: scale(1.15); /* SCALE ICON ITSELF SMOOTHLY WITHOUT SHIFTING OUTER CONFINEMENT BOX */
  transition: transform 0.15s ease;
}

/* ─── FOLDER & NOTE TREE HIERARCHY INDENTATION & SPACING ──── */
.folder-tree, .tag-tree {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}
.folder-tree.hidden, .tag-tree.hidden {
  display: none !important;
}

.tree-folder-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.625rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.tree-folder-header:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.tree-folder-header.active {
  background: var(--bg-active);
  color: var(--accent);
}
.tree-folder-header .count-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  color: var(--text-muted);
  background: var(--bg-base);
  padding: 0.0625rem 0.4375rem;
  border-radius: 1rem;
}

/* GENEROUS PROPER SPACING BETWEEN HEADER AND FIRST NESTED NOTE UNDERNEATH */
.tree-notes {
  margin-left: 1.25rem;
  margin-top: 0.375rem;
  padding-left: 0.5rem;
  padding-top: 0.25rem;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.tree-notes.collapsed { max-height: 0 !important; margin-top: 0 !important; padding-top: 0 !important; }

.tree-note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
}
.tree-note:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.tree-note.active {
  background: var(--bg-active);
  color: var(--accent);
  font-weight: 600;
}

/* ─── RIGHT-CLICK TREE CONTEXT MENU ─────────────── */
.context-menu {
  position: fixed;
  z-index: 10000;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.375rem;
  min-width: 11rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.context-menu.hidden { display: none !important; }

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-primary);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 0.12s;
}
.context-menu-item:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.context-menu-item.danger:hover {
  background: rgba(255, 100, 100, 0.15);
  color: var(--danger);
}
.context-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* ─── SIDEBAR FOOTER, E2EE, SYNC BADGE & LOCK ACTION ─── */
.sidebar-footer {
  padding: 0.75rem;
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
}

.e2ee-card {
  padding: 0.625rem 0.75rem;
  border-radius: 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
.e2ee-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}
.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}
.status-dot.active {
  background: var(--save-ok);
  box-shadow: 0 0 0.375rem var(--save-ok);
}

.footer-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.sync-status-badge {
  font-size: 0.75rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--text-secondary);
}
.sync-status-badge.saving {
  color: var(--accent);
}
.sync-status-badge.error {
  color: var(--danger);
}

.lock-action-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem !important;
  border-radius: 0.375rem !important;
  border: 1px solid var(--border) !important;
  background: var(--bg-base) !important;
  color: var(--text-secondary) !important;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lock-action-btn:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

/* ─── CENTER PANE & 100% AUTO-FIT EDITOR ─────────── */
.center-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
}

/* 100% AUTO-FIT EDITOR/PREVIEW CONTAINER */
.editor-split {
  flex: 1 1 100%;
  height: calc(100% - 3.25rem);
  width: 100%;
  display: flex;
  overflow: hidden;
  min-height: 0;
  background: var(--bg-base);
}

/* MODE 1: EDITOR ONLY */
.editor-split.mode-editor .editor-pane {
  flex: 1 1 100% !important;
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
}
.editor-split.mode-editor .preview-pane,
.editor-split.mode-editor .split-handle {
  display: none !important;
}

/* MODE 2: PREVIEW ONLY */
.editor-split.mode-preview .preview-pane {
  flex: 1 1 100% !important;
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
}
.editor-split.mode-preview .editor-pane,
.editor-split.mode-preview .split-handle {
  display: none !important;
}

/* MODE 3A: SPLIT VIEW (Vertical / Top-Bottom) */
.editor-split.mode-split-vertical {
  flex-direction: column !important;
}
.editor-split.mode-split-vertical .editor-pane {
  flex: 1 1 50%;
  width: 100%;
  height: 50%;
  min-height: 0;
  display: flex !important;
}
.editor-split.mode-split-vertical .preview-pane {
  flex: 1 1 50%;
  width: 100%;
  height: 50%;
  min-height: 0;
  display: flex !important;
}
.editor-split.mode-split-vertical .split-handle {
  height: 0.375rem;
  width: 100%;
  cursor: row-resize;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-left: none;
  border-right: none;
  flex-shrink: 0;
}
.editor-split.mode-split-vertical .handle-line {
  width: 2.5rem;
  height: 0.1875rem;
  border-radius: 0.125rem;
  background: var(--border-hover);
}

/* MODE 3B: SPLIT VIEW (Horizontal / Side-by-Side Left-Right) */
.editor-split.mode-split-horizontal {
  flex-direction: row !important;
}
.editor-split.mode-split-horizontal .editor-pane {
  flex: 1 1 50%;
  width: 50%;
  height: 100%;
  min-width: 0;
  display: flex !important;
}
.editor-split.mode-split-horizontal .preview-pane {
  flex: 1 1 50%;
  width: 50%;
  height: 100%;
  min-width: 0;
  display: flex !important;
}
.editor-split.mode-split-horizontal .split-handle {
  width: 0.375rem;
  height: 100%;
  cursor: col-resize;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-top: none;
  border-bottom: none;
  flex-shrink: 0;
}
.editor-split.mode-split-horizontal .handle-line {
  height: 2.5rem;
  width: 0.1875rem;
  border-radius: 0.125rem;
  background: var(--border-hover);
}

#markdown-textarea {
  flex: 1 1 100% !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  padding: 1.5rem 2rem !important;
  background: var(--bg-base) !important;
  color: var(--text-primary) !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  resize: none !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 0.9375rem !important;
  line-height: 1.6 !important;
  box-sizing: border-box !important;
  overflow-y: auto !important;
  margin: 0 !important;
}

.preview-content {
  flex: 1 1 100%;
  width: 100%;
  height: 100%;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  box-sizing: border-box;
}

/* ─── RIGHT INSPECTOR PANE & METRICS FORMATTING ─── */
.right-pane section {
  margin-bottom: 1.5rem;
}
.tags-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.right-pane h6 {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.btn-tag-add {
  font-size: 0.875rem;
  font-weight: 600;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.btn-tag-add:hover {
  background: var(--accent);
  color: var(--bg-base);
}

.toc-container {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.toc-item {
  font-size: 0.8125rem;
  padding: 0.3125rem 0.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.12s;
}
.toc-item:hover {
  color: var(--accent);
  background: var(--bg-hover);
}
.toc-item.toc-h2 { padding-left: 1rem; }
.toc-item.toc-h3 { padding-left: 1.5rem; font-size: 0.75rem; }

.empty-state {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.tag-chip {
  font-size: 0.75rem;
  background: var(--accent-subtle);
  color: var(--accent);
  padding: 0.25rem 0.5rem;
  border-radius: 1rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.tag-del-btn {
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.7;
}
.tag-del-btn:hover { opacity: 1; color: var(--danger); }

/* METRICS GRID SPACING */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}
.metric {
  padding: 0.625rem 0.375rem;
  border-radius: 0.5rem;
  text-align: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.metric strong {
  display: block;
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1.2;
}
.metric small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05rem;
}

/* ─── IN-APP MODALS ──────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}
.modal-backdrop.hidden { display: none; }

.modal-card {
  width: min(90vw, 22rem);
  padding: 1.75rem 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.modal-icon {
  margin-bottom: 0.75rem;
  color: var(--accent);
  display: flex;
  justify-content: center;
}
.modal-warning-svg, .modal-prompt-svg {
  width: 2.75rem;
  height: 2.75rem;
}

.modal-card h3 {
  font-size: 1.125rem;
  margin-bottom: 0.375rem;
  color: var(--text-primary);
}
.modal-card p {
  font-size: 0.84375rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

.modal-input {
  width: 100%;
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  outline: none;
  margin-bottom: 1.25rem;
}
.modal-input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 0.625rem;
}

.btn-modal-secondary,
.btn-modal-primary,
.btn-modal-danger {
  flex: 1;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-modal-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-modal-secondary:hover {
  background: var(--bg-hover);
}

.btn-modal-primary {
  background: var(--accent);
  color: var(--bg-base);
  border: none;
}
.btn-modal-primary:hover {
  opacity: 0.9;
}

.btn-modal-danger {
  background: var(--danger);
  color: #ffffff;
  border: none;
}
.btn-modal-danger:hover {
  opacity: 0.9;
}

/* ─── MANDATORY E2EE LOCK SCREEN ────────────────── */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}
.lock-screen.hidden { display: none; }

.lock-card {
  width: min(90vw, 26rem);
  padding: 2.5rem 2rem;
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.4);
}
.lock-icon {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}
.lock-logo-img {
  width: 9rem;
  height: 9rem;
  border-radius: 0.75rem;
  object-fit: cover;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.4);
}
.lock-card h2 {
  font-size: 1.75rem;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}
.lock-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}
.lock-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.lock-input {
  width: 100%;
  display: block;
  padding: 0.625rem 0.875rem;
  font-size: 1rem;
  background: var(--bg-base);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  outline: none;
  margin-bottom: 0.75rem;
  text-align: center;
  letter-spacing: 0.15rem;
}
.lock-input:focus { border-color: var(--accent); }
.lock-error {
  font-size: 0.8125rem;
  color: var(--danger);
  margin-bottom: 0.75rem;
  font-weight: 500;
}
.lock-btn {
  width: 100%;
  display: block;
  padding: 0.625rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--bg-base);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  margin-bottom: 1.25rem;
  transition: opacity 0.15s;
}
.lock-btn:hover { opacity: 0.9; }
.lock-footer {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── RESPONSIVE BREAKPOINTS ─────────────────────── */
@media (max-width: 60rem) {
  .right-pane { display: none; }
  .sidebar-resizer { display: none; }
}
@media (max-width: 40rem) {
  .left-pane { width: 0; min-width: 0; overflow: hidden; border: none; }
}
