:root {
  /* Obsidian-Inspired Minimalist Dark Theme (Default) */
  --bg-deep: #16161a;
  --bg-sidebar: #1a1a20;
  --bg-card: #202026;
  --bg-hover: #272730;
  --bg-input: #121215;
  --border-subtle: #292933;
  --border-bright: #373746;
  --text-primary: #e6e6eb;
  --text-secondary: #9898a8;
  --text-muted: #646473;
  --accent-primary: #7e7fb8;
  --accent-secondary: #51527a;
  --accent-emerald: #4d8f6f;
  --accent-cyan: #528392;
  --accent-purple: #7e7fb8;
  --accent-amber: #947d51;
  --accent-rose: #9a5762;
  --diff-add-bg: rgba(77, 143, 111, 0.12);
  --diff-add-border: #4d8f6f;
  --diff-del-bg: rgba(154, 87, 98, 0.12);
  --diff-del-border: #9a5762;
  --diff-mod-bg: rgba(126, 127, 184, 0.12);
  --diff-mod-border: #7e7fb8;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Custom themed slim scrollbars for all internal scrollable containers (excluding html & body) */
*:not(html):not(body) {
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) transparent;
}
*:not(html):not(body)::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*:not(html):not(body)::-webkit-scrollbar-track {
  background: transparent;
}
*:not(html):not(body)::-webkit-scrollbar-thumb {
  background: var(--border-bright);
  border-radius: 999px;
  transition: background 0.15s ease;
}
*:not(html):not(body)::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Sovereign Instant Splash & Budget Phone Loading System
   Hardware-accelerated CSS animations running on browser compositor thread
   ========================================================================== */
.sphene-loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: radial-gradient(circle at center, #101524 0%, #06080d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  user-select: none;
  -webkit-user-select: none;
}

.sphene-loading-screen.loading-fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 90vw;
  width: 320px;
}

.loading-gem-container {
  position: relative;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}

.loading-gem-pulse {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: spheneGemPulse 2.4s ease-in-out infinite;
  will-change: transform, filter;
}

.loading-gem-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(16, 185, 129, 0.45));
}

.loading-ring-spinner {
  position: absolute;
  inset: -6px;
  border: 2.5px solid transparent;
  border-top-color: #10b981;
  border-right-color: rgba(16, 185, 129, 0.3);
  border-radius: 50%;
  animation: spheneRingSpin 1.2s cubic-bezier(0.5, 0.1, 0.4, 0.9) infinite;
  will-change: transform;
}

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

@keyframes spheneGemPulse {
  0%, 100% {
    transform: scale(0.95);
    filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.35));
  }
  50% {
    transform: scale(1.05);
    filter: drop-shadow(0 0 24px rgba(16, 185, 129, 0.75));
  }
}

.loading-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.loading-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #f8fafc;
  margin: 0;
}

.loading-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
}

.loading-status-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.loading-progress-fill {
  height: 100%;
  width: 15%;
  background: linear-gradient(90deg, #10b981 0%, #06b6d4 100%);
  border-radius: 999px;
  transition: width 0.35s ease;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

.loading-status-text {
  font-size: 0.82rem;
  color: #94a3b8;
  font-weight: 500;
  letter-spacing: 0.02em;
  min-height: 1.2em;
  margin-bottom: 4px;
}

.loading-status-sub {
  font-size: 0.72rem;
  color: #64748b;
  letter-spacing: 0.03em;
  transition: color 0.3s ease;
}

/* Layout */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar */
.sidebar {
  width: 340px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

/* 3D Crystal Brand Header */
.brand-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(21, 26, 36, 0.4) 0%, transparent 100%);
  cursor: pointer;
  transition: background 0.15s ease;
}

.brand-header:hover {
  background: linear-gradient(180deg, rgba(28, 35, 49, 0.6) 0%, rgba(21, 26, 36, 0.2) 100%);
}

.brand-header-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-gem-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 700px;
}

.brand-gem {
  width: 38px;
  height: 38px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.08s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: floatGem 5s ease-in-out infinite;
}

@keyframes floatGem {
  0%, 100% { transform: translateY(0px) rotateZ(0deg); }
  50% { transform: translateY(-3px) rotateZ(1deg); }
}

@keyframes pulseGemGlow {
  0% { transform: translate(-50%, -50%) scale(0.92); opacity: 0.7; }
  100% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
}

.brand-gem img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 14px rgba(6, 182, 212, 0.5));
}

.gem-glare {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.75) 0%, transparent 60%);
  mix-blend-mode: overlay;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}

.brand-gem-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.45) 0%, rgba(168, 85, 247, 0.25) 40%, rgba(16, 185, 129, 0.2) 60%, transparent 75%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 1;
  animation: pulseGemGlow 4s ease-in-out infinite alternate;
}

.brand-details {
  display: flex;
  flex-direction: column;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-weight: 800;
  letter-spacing: 1.5px;
  font-size: 1.1rem;
  background: linear-gradient(135deg, #f8fafc 0%, #38bdf8 50%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.kernel-pill {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

/* Search Container */
.search-container {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.search-input-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  pointer-events: none;
}

.search-input-wrapper input {
  width: 100%;
  height: 36px;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0 28px 0 32px;
  color: var(--text-primary);
  font-size: 0.84rem;
  outline: none;
  transition: all 0.15s ease;
}

.search-input-wrapper input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

.search-kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-muted);
}

.sidebar-actions-row {
  display: flex;
  gap: 8px;
  width: 100%;
  align-items: center;
}

.sidebar-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.sidebar-actions-row #btn-new-note {
  flex: 1;
  width: 100%;
}

.sidebar-actions-row .plugin-sidebar-importer-slot {
  flex: 1;
  display: flex;
}

.sidebar-actions-row .plugin-sidebar-importer-slot:empty {
  display: none !important;
}

.sidebar-actions-row.has-importer #btn-new-note,
.sidebar-actions-row:has(#btn-open-importer) #btn-new-note {
  flex: 1.1;
}

/* ==========================================================================
   Primary Sidebar Plugin Slot: Below + Note / Import (Max 3 lines, then menu)
   ========================================================================== */
#plugin-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin-top: 6px;
  position: relative;
}

#plugin-sidebar-actions:empty {
  display: none !important;
}

#plugin-sidebar-actions button,
#plugin-sidebar-actions .btn {
  width: 100%;
  height: 36px;
  min-height: 36px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 12px;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

#plugin-sidebar-actions button:hover,
#plugin-sidebar-actions .btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#btn-sidebar-plugins-more {
  justify-content: space-between !important;
  border: 1px dashed var(--border-subtle) !important;
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--text-secondary) !important;
}

#btn-sidebar-plugins-more:hover {
  border-color: var(--accent-cyan) !important;
  color: var(--text-primary) !important;
}

.sidebar-plugins-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  padding: 4px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-plugins-dropdown-item {
  width: 100%;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 5px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  transition: all 0.12s ease;
}

.sidebar-plugins-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--accent-cyan);
}

/* ==========================================================================
   Bottom Sidebar Plugin Slot: Floating Action Buttons (Above User Profile)
   ========================================================================== */
#plugin-sidebar-bottom-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 16px 8px 16px;
  width: 100%;
  box-sizing: border-box;
}

#plugin-sidebar-bottom-actions:empty {
  display: none !important;
}

.btn-sidebar-fab {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  max-width: 34px !important;
  max-height: 34px !important;
  border-radius: 50% !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-secondary) !important;
  cursor: pointer !important;
  position: relative !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
  transition: all 0.15s ease !important;
  padding: 0 !important;
  margin: 0 !important;
  line-height: 1 !important;
}

.btn-sidebar-fab:hover {
  background: var(--bg-hover) !important;
  color: var(--accent-cyan) !important;
  border-color: var(--accent-cyan) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25) !important;
}

.btn-sidebar-fab .fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #ffffff;
  border-radius: 10px;
  font-size: 0.65rem;
  padding: 1px 5px;
  font-weight: 700;
  line-height: 1;
  min-width: 14px;
  text-align: center;
  border: 1px solid var(--bg-sidebar);
}

.sidebar-bottom-dropdown-menu {
  position: absolute;
  bottom: 100%;
  right: 16px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.45);
  padding: 6px;
  z-index: 1000;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-bottom-dropdown-item {
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 5px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  transition: all 0.12s ease;
}

.sidebar-bottom-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--accent-cyan);
}

.sidebar-actions-row .btn-new,
.sidebar-actions-row .btn-import,
#btn-new-note,
#btn-open-importer {
  height: 36px;
  min-height: 36px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

#btn-new-note {
  background: linear-gradient(135deg, var(--accent-emerald, #10b981) 0%, #059669 100%);
  color: #ffffff;
  border: none;
}

#btn-new-note:hover {
  filter: brightness(1.08);
  box-shadow: 0 3px 12px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

#btn-new-note:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

#btn-open-importer,
.sidebar-actions-row .btn-import {
  width: 100%;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

#btn-open-importer:hover,
.sidebar-actions-row .btn-import:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-bright);
}

/* Extra +Draw button (slimmer, 75% height of +Note) */
#btn-new-draw,
.btn-draw-new {
  height: 27px;
  min-height: 27px;
  width: 100%;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 5px;
  white-space: nowrap;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--accent-amber, #f59e0b);
  border: 1px solid rgba(245, 158, 11, 0.35);
  transition: all 0.15s ease;
}

#btn-new-draw:hover,
.btn-draw-new:hover {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--accent-amber, #f59e0b);
  color: #fbbf24;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

#btn-new-draw:active,
.btn-draw-new:active {
  transform: translateY(0);
}

#btn-new-draw .sphene-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-amber, #f59e0b);
}

/* Nav Pills */
.nav-pills {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 10px 10px;
}

.nav-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-pill:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-pill.active {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  font-weight: 600;
}

.badge-count {
  margin-left: auto;
  font-size: 0.7rem;
  background: var(--accent-purple);
  color: #fff;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* Partitions Card Section */
.partitions-section {
  padding: 10px 12px;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(11, 14, 20, 0.3);
}

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.filter-reset-link {
  color: var(--accent-cyan);
  cursor: pointer;
}

.partition-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.partition-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.partition-card:hover {
  border-color: var(--border-bright);
  background: var(--bg-hover);
}

.partition-card.active {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  box-shadow: 0 0 0 1px var(--accent-cyan), 0 2px 8px rgba(6, 182, 212, 0.2);
}

.partition-card[data-partition="Workspace"].active {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 0 1px var(--accent-emerald), 0 2px 8px rgba(16, 185, 129, 0.2);
}

.partition-card[data-partition="Reference"].active {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  box-shadow: 0 0 0 1px var(--accent-cyan), 0 2px 8px rgba(6, 182, 212, 0.2);
}

.partition-card[data-partition="Private"].active {
  border-color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.08);
  box-shadow: 0 0 0 1px var(--accent-purple), 0 2px 8px rgba(168, 85, 247, 0.2);
}

.partition-card[data-partition="Drawing"].active,
.partition-card[data-partition="drawing"].active {
  border-color: rgb(168, 85, 247) !important;
  background: rgba(168, 85, 247, 0.08);
  box-shadow: 0 0 0 1px rgb(168, 85, 247), 0 2px 8px rgba(168, 85, 247, 0.2);
}

.p-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}

.p-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.p-dot-all { background: var(--text-secondary); }
.p-dot-workspace { background: var(--accent-emerald); box-shadow: 0 0 5px var(--accent-emerald); }
.p-dot-reference { background: var(--accent-cyan); box-shadow: 0 0 5px var(--accent-cyan); }
.p-dot-private { background: var(--accent-purple); box-shadow: 0 0 5px var(--accent-purple); }
.p-dot-drawing { background: var(--accent-amber); box-shadow: 0 0 5px var(--accent-amber); }

.p-count {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.p-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.2;
}

/* Document List */
.doc-list-section {
  flex: 1 1 auto;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 12px 6px;
}

.doc-tree {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.doc-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: all 0.12s ease;
}

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

.doc-item.active {
  background: var(--bg-card);
  border-left-color: var(--accent-emerald);
}

.doc-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.doc-item-title-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  position: relative;
  white-space: nowrap;
}

.doc-item-title {
  display: inline-block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.4;
  vertical-align: middle;
}

.doc-item-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.doc-item-badge {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}

.doc-item-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  padding: 24px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* Sidebar Folder Hierarchy & Subactions */
.btn-sidebar-subaction {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.15s ease;
}

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

.doc-tree-folder {
  display: flex;
  flex-direction: column;
  margin-bottom: 2px;
}

.doc-folder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease;
  color: var(--text-primary);
}

.doc-folder-row:hover {
  background: var(--bg-hover);
}

.doc-folder-main {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.doc-folder-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.doc-tree-folder.collapsed .doc-folder-chevron {
  transform: rotate(0deg);
}

.doc-tree-folder.expanded .doc-folder-chevron {
  transform: rotate(90deg);
}

.doc-folder-icon {
  display: inline-flex;
  align-items: center;
  color: var(--accent-primary, #7e7fb8);
  flex-shrink: 0;
}

.doc-folder-name-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  position: relative;
  white-space: nowrap;
}

.doc-folder-name {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.4;
  vertical-align: middle;
  color: var(--text-primary);
}

.doc-folder-meta {
  display: flex;
  align-items: center;
  gap: 4px;
}

.doc-folder-count {
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.doc-folder-add-btn {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.75rem;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.doc-folder-row:hover .doc-folder-add-btn {
  opacity: 1;
}

.doc-folder-add-btn:hover {
  color: var(--accent-primary);
  background: var(--bg-card);
}

.doc-folder-action-evict {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--accent-primary, #818cf8);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.75rem;
  transition: opacity 0.15s ease, color 0.15s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.doc-folder-row:hover .doc-folder-action-evict {
  opacity: 0.85;
}

.doc-folder-action-evict:hover {
  opacity: 1 !important;
  color: #a5b4fc;
  background: var(--bg-card, rgba(255, 255, 255, 0.08));
  transform: scale(1.15);
}

.doc-folder-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 3px !important;
  border-left: 1px solid var(--border-subtle) !important;
  margin-left: 3px !important;
  margin-top: 2px;
  margin-bottom: 4px;
  list-style: none;
}

.doc-tree-folder.collapsed .doc-folder-children {
  display: none !important;
}

.doc-item.nested-child {
  padding: 4px 6px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(11, 14, 20, 0.5);
}

.telemetry-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}

.pulse-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1); }
}

.telemetry-label {
  font-weight: 600;
  color: var(--text-primary);
}

.telemetry-pill {
  margin-left: auto;
  font-size: 0.68rem;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.telemetry-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Main Viewport */
.main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  overflow: hidden;
}

.view-panel {
  display: none;
  flex-direction: column;
  height: 100%;
}
.view-panel.active { display: flex; }

/* Doc Header Bar */
.doc-header-bar {
  padding: 18px 32px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--bg-sidebar) 0%, transparent 100%);
}

.doc-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.doc-title-row h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f8fafc;
}

.partition-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}
.badge-workspace { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-reference { background: rgba(6, 182, 212, 0.15); color: #38bdf8; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-private { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-drawing { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }

/* Interactive Partition Selector */
.partition-selector-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

button.partition-select-btn {
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  outline: none;
  transition: all 0.18s ease;
  user-select: none;
}

button.partition-select-btn:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

button.partition-select-btn:active {
  transform: translateY(0);
}

.partition-caret {
  font-size: 0.65rem;
  line-height: 1;
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.partition-selector-container.open .partition-caret {
  transform: rotate(180deg);
}

.partition-select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1050;
  min-width: 250px;
  background: var(--bg-surface, #1e222b);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  backdrop-filter: blur(12px);
  animation: dropdownFadeIn 0.15s ease-out;
}

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

.partition-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-primary, #f1f5f9);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s ease;
}

.partition-option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.partition-option.active {
  background: rgba(255, 255, 255, 0.12);
  font-weight: 600;
}

.p-option-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.p-dot-workspace { background: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.5); }
.p-dot-reference { background: #06b6d4; box-shadow: 0 0 6px rgba(6, 182, 212, 0.5); }
.p-dot-private { background: #a855f7; box-shadow: 0 0 6px rgba(168, 85, 247, 0.5); }
.p-dot-drawing { background: #f59e0b; box-shadow: 0 0 6px rgba(245, 158, 11, 0.5); }

.p-option-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.p-option-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
}

.p-option-desc {
  font-size: 0.68rem;
  color: var(--text-muted, #94a3b8);
}

.doc-details-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tags-container {
  display: flex;
  gap: 6px;
}

.tag-chip {
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 4px;
}

/* Notice Banner */
.partition-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 24px;
  font-size: 0.82rem;
  line-height: 1.4;
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}
.notice-workspace { background: rgba(16, 185, 129, 0.08); border: 1px solid rgba(16, 185, 129, 0.2); color: #a7f3d0; }
.notice-reference { background: rgba(6, 182, 212, 0.08); border: 1px solid rgba(6, 182, 212, 0.2); color: #bae6fd; }
.notice-private { background: rgba(168, 85, 247, 0.08); border: 1px solid rgba(168, 85, 247, 0.2); color: #e9d5ff; }
.notice-drawing { background: rgba(245, 158, 11, 0.08); border: 1px solid rgba(245, 158, 11, 0.2); color: #fde68a; }

/* Document Viewport */
.doc-scroll-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 28px 40px;
}

.markdown-article {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  line-height: 1.75;
  font-size: 1rem;
  color: #cbd5e1;
  box-sizing: border-box;
}

.markdown-article h1, .markdown-article h2, .markdown-article h3 {
  color: #f8fafc;
  margin: 1.4em 0 0.6em;
  font-weight: 700;
}
.markdown-article h1 { font-size: 1.8rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 0.3em; }
.markdown-article h2 { font-size: 1.35rem; }
.markdown-article h3 { font-size: 1.15rem; }

.markdown-article p { margin: 0.8em 0; }
.markdown-article ul, .markdown-article ol { margin: 0.8em 0; padding-left: 1.5em; }
.markdown-article li { margin: 0.3em 0; }

.markdown-article pre {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  overflow-x: auto;
  margin: 1.2em 0;
  color: #38bdf8;
}

.markdown-article code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.88em;
  color: #38bdf8;
}

.wikilink-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 1px 7px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.wikilink-badge:hover {
  background: rgba(6, 182, 212, 0.25);
  border-color: var(--accent-cyan);
}

.wikilink-badge.wikilink-broken {
  background: rgba(239, 68, 68, 0.12) !important;
  color: #ef4444 !important;
  border: 1px dashed rgba(239, 68, 68, 0.55) !important;
}
.wikilink-badge.wikilink-broken:hover {
  background: rgba(239, 68, 68, 0.24) !important;
  border-color: #ef4444 !important;
  text-decoration: underline;
}
.wikilink-broken-tag {
  font-size: 0.72em;
  opacity: 0.9;
  background: rgba(239, 68, 68, 0.22);
  padding: 1px 4px;
  border-radius: 3px;
  margin-left: 2px;
  font-style: italic;
}

.local-graph-node-link.broken-link {
  background: rgba(239, 68, 68, 0.08);
  border: 1px dashed rgba(239, 68, 68, 0.45);
}
.local-graph-node-link.broken-link:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: #ef4444;
}

.task-item-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.task-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--accent-emerald);
  cursor: pointer;
}

/* Editor Mode */
.editor-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  box-sizing: border-box;
}
.editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.editor-filename-wrapper {
  flex: 1;
  min-width: 0;
}

.editor-filename-input-box {
  display: flex;
  align-items: center;
  background: var(--bg-input, #161a22);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.15));
  border-radius: 6px;
  padding: 0 8px 0 0;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.editor-filename-input-box:focus-within {
  border-color: var(--accent-cyan, #06b6d4);
  box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

.editor-input-filename {
  flex: 1;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  padding: 8px 12px;
  color: var(--text-primary, #f1f5f9);
  font-size: 0.85rem;
  font-family: inherit;
  min-width: 0;
}

.editor-ext-badge {
  display: inline-flex;
  align-items: center;
  user-select: none;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted, #94a3b8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  letter-spacing: 0.5px;
}
.editor-code {
  width: 100%;
  height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px;
  color: #f1f5f9;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
.editor-code:focus {
  border-color: var(--accent-cyan);
}

/* Live Preview Mode (Obsidian-Style Dynamic Inline WYSIWYG) */
.live-preview-wrapper {
  width: 100%;
  min-height: 480px;
  max-height: 75vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px 20px;
  cursor: text;
  box-sizing: border-box;
}
.live-preview-wrapper:focus-within {
  border-color: var(--accent-cyan);
}
.live-preview-surface {
  min-height: 100%;
  outline: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.lp-block {
  position: relative;
  min-height: 26px;
  border-radius: 4px;
  padding: 2px 6px;
  box-sizing: border-box;
  transition: background 0.1s ease;
  cursor: text;
}
.lp-block:hover {
  background: rgba(255, 255, 255, 0.02);
}
.lp-block.active {
  background: rgba(56, 189, 248, 0.05);
  border-left: 2px solid var(--accent-cyan);
  padding-left: 8px;
}
.lp-rendered {
  width: 100%;
  pointer-events: auto;
}
.lp-rendered h1,
.lp-rendered h2,
.lp-rendered h3,
.lp-rendered h4,
.lp-rendered p,
.lp-rendered ul,
.lp-rendered ol,
.lp-rendered blockquote {
  margin: 0 !important;
}
.lp-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  line-height: 1.6;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  padding: 1px 0;
  margin: 0;
  resize: none;
  box-sizing: border-box;
  overflow-y: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  display: block;
}
.lp-empty-line {
  min-height: 1.4em;
}


/* AI Smart Auto-Complete & Ghost Wikilink Hints */
.editor-ai-hint {
  position: absolute;
  bottom: 14px;
  right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--accent-cyan);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.76rem;
  color: var(--accent-cyan);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
  pointer-events: none;
  animation: fadeInHint 0.15s ease;
}
.editor-ai-hint strong {
  background: rgba(56, 189, 248, 0.2);
  padding: 1px 5px;
  border-radius: 3px;
}
.editor-ai-hint code {
  color: var(--text-primary);
  font-family: var(--font-mono);
}

@keyframes fadeInHint {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Smart Inbox Taxonomy Router Banner & Confirmation */
.smart-inbox-banner {
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.35);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 0.82rem;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(10px);
}
.smart-inbox-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.smart-inbox-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}
.smart-inbox-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.smart-inbox-confirm-prompt {
  font-size: 0.74rem;
  color: var(--text-secondary);
}
.smart-inbox-diff-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.smart-inbox-diff-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.78rem;
}
.diff-label {
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 150px;
}
.diff-old {
  color: var(--text-muted);
  text-decoration: line-through;
}
.diff-arrow {
  color: var(--accent-primary, #7e7fb8);
  font-weight: bold;
}
.diff-new {
  color: var(--accent-cyan);
  font-weight: 700;
}
.diff-same {
  color: var(--text-muted);
}
.diff-chips-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.smart-inbox-chip {
  background: rgba(14, 165, 233, 0.2);
  color: var(--accent-cyan);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
}
.smart-inbox-chip-new {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.smart-inbox-chip-dim {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
}
.smart-inbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

/* Plugin Memory Footprint Badges & Meter */
.plugin-tag-mem {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.plugin-tag-perf {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.plugin-ram-pill,
.plugin-active-pill {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
}
.plugin-mem-notice {
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid #f59e0b;
  padding: 10px 14px;
  border-radius: 4px;
  margin: 12px 0;
  font-size: 0.8rem;
  color: var(--text-primary);
  display: flex;
  gap: 10px;
}

/* Conceptually Linked Notes (sphene-semantic-graph) */
.related-notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}
.related-note-card {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.related-note-card:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-hover);
}
.related-note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.related-note-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}
.related-note-sim {
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  font-weight: 600;
}
.related-note-concept {
  font-size: 0.75rem;
  color: var(--text-muted);
}


/* Buttons */
.btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--accent-primary, #7e7fb8); color: #ffffff; }
.btn-primary:hover { background: #9092cc; }
.btn-secondary { background: var(--bg-card); color: var(--text-secondary); border-color: var(--border-subtle); }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-bright); }
.btn-success { background: var(--accent-emerald); color: #ffffff; }
.btn-danger { background: var(--accent-rose); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }

.btn-icon {
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
  transition: filter 0.15s ease;
}

/* Default Theme: Monochrome/Muted Icons (keeps logo vibrant) */
html:not(.theme-cyber-velvet-rock) .btn-icon {
  filter: grayscale(1) opacity(0.75);
}

/* Cyber Velvet Rock: Colorful Icons */
html.theme-cyber-velvet-rock .btn-icon {
  filter: none;
}

/* Panel Header */
.panel-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-sidebar);
}
.panel-subtext {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.panel-scroll-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

/* Staged Cards (Differential Timeline - GitHub PR Comparison Style) */
.staged-flow {
  max-width: 1050px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.staged-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: border-color 0.15s ease;
}

.staged-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.staged-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 12px;
}

.staged-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.staged-card-title {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.staged-card-title svg {
  color: var(--text-secondary);
}

.staged-agent-pill {
  font-size: 0.72rem;
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.diff-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
}

.diff-stat-add {
  color: #3fb950;
  background: rgba(46, 160, 67, 0.15);
  padding: 1px 7px;
  border-radius: 4px;
}

.diff-stat-del {
  color: #f85149;
  background: rgba(248, 81, 73, 0.15);
  padding: 1px 7px;
  border-radius: 4px;
}

.diff-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.staged-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-accept {
  background: #238636;
  color: #ffffff;
  border: 1px solid rgba(240, 246, 252, 0.1);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-accept:hover {
  background: #2ea043;
  box-shadow: 0 0 10px rgba(46, 160, 67, 0.3);
}

.btn-veto {
  background: rgba(248, 81, 73, 0.08);
  color: #f85149;
  border: 1px solid rgba(248, 81, 73, 0.35);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-veto:hover {
  background: rgba(248, 81, 73, 0.18);
  border-color: #f85149;
}

/* GitHub PR-Style Diff Table */
.gh-diff-container {
  overflow-x: auto;
  background: #0d1117;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 20px;
}

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

.gh-diff-line {
  vertical-align: top;
}

.gh-line-num {
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  padding: 0 8px;
  text-align: right;
  color: #6e7681;
  user-select: none;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px;
}

.gh-line-marker {
  width: 24px;
  min-width: 24px;
  text-align: center;
  user-select: none;
  font-weight: 700;
}

.gh-line-content {
  padding: 0 10px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e6edf3;
}

/* Deleted Lines (GitHub Red) */
.gh-line-deleted {
  background-color: rgba(248, 81, 73, 0.15);
}
.gh-line-deleted .gh-line-num {
  color: rgba(248, 81, 73, 0.8);
  background-color: rgba(248, 81, 73, 0.12);
}
.gh-line-deleted .gh-line-marker {
  color: #f85149;
}
.gh-line-deleted .gh-line-content {
  color: #ff7b72;
}

/* Added Lines (GitHub Green) */
.gh-line-added {
  background-color: rgba(46, 160, 67, 0.15);
}
.gh-line-added .gh-line-num {
  color: rgba(46, 160, 67, 0.8);
  background-color: rgba(46, 160, 67, 0.12);
}
.gh-line-added .gh-line-marker {
  color: #3fb950;
}
.gh-line-added .gh-line-content {
  color: #7ee787;
}

/* Context / Unchanged Lines */
.gh-line-context {
  background-color: transparent;
}
.gh-line-context .gh-line-marker {
  color: #6e7681;
}

/* Toast Notifications */
#sphene-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  max-width: calc(100vw - 48px);
  box-sizing: border-box;
}

.sphene-toast {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
  animation: toastSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
  max-width: min(440px, calc(100vw - 48px));
  width: fit-content;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.toast-success {
  background: rgba(35, 134, 54, 0.96);
  color: #ffffff;
  border: 1px solid rgba(46, 160, 67, 0.4);
}

.toast-error {
  background: rgba(218, 54, 51, 0.96);
  color: #ffffff;
  border: 1px solid rgba(248, 81, 73, 0.4);
}

.toast-info {
  background: rgba(22, 27, 34, 0.96);
  color: #f0f6fc;
  border: 1px solid rgba(240, 246, 252, 0.15);
}

.fade-out {
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s ease;
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.diff-stream {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.diff-row {
  padding: 8px 12px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.5;
}

.diff-added { background: var(--diff-add-bg); border-left: 3px solid var(--diff-add-border); }
.diff-deleted { background: var(--diff-del-bg); border-left: 3px solid var(--diff-del-border); text-decoration: line-through; }
.diff-modified { background: var(--diff-mod-bg); border-left: 3px solid var(--diff-mod-border); }

/* Knowledge Graph */
.graph-canvas-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #101520 0%, #080a0f 100%);
  overflow: hidden;
}

#graph-canvas {
  width: 100%;
  height: 100%;
}

.graph-controls-dock {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  gap: 8px;
}

.graph-legend {
  display: flex;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Security Cards */
.security-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 900px;
}

.sec-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 20px;
}

.sec-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.badge-active {
  font-size: 0.7rem;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 700;
}

.sec-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.sec-metric {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}

.sec-val {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.sec-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.sec-key-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 14px;
  font-size: 0.75rem;
}

.sec-key-box code {
  display: block;
  font-family: var(--font-mono);
  color: var(--accent-purple);
  margin-top: 4px;
  word-break: break-all;
}

.empty-staged-box {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-staged-box .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-staged-box h3 { color: var(--text-primary); margin-bottom: 6px; }
.empty-staged-box p { font-size: 0.85rem; max-width: 480px; margin: 0 auto; }

/* ------------------------------------------------------------------ */
/* Welcome / Vault Overview Hero Screen                               */
/* ------------------------------------------------------------------ */
.welcome-container {
  height: 100%;
  overflow-y: auto;
  padding: 40px 24px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome-hero-content {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  text-align: center;
}

/* Large Interactive 3D Crystal Gemstone */
.hero-gem-container {
  position: relative;
  width: 130px;
  height: 130px;
  margin: 10px auto 28px;
  perspective: 900px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.hero-gem-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 170px;
  height: 170px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(56, 189, 248, 0.4) 0%, rgba(168, 85, 247, 0.28) 40%, rgba(16, 185, 129, 0.15) 60%, transparent 75%);
  filter: blur(26px);
  border-radius: 50%;
  pointer-events: none;
  animation: pulseGemGlow 4s ease-in-out infinite alternate;
  z-index: 1;
}

.hero-gem {
  position: relative;
  width: 110px;
  height: 110px;
  transform-style: preserve-3d;
  will-change: transform;
  z-index: 2;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.8)) drop-shadow(0 0 20px rgba(56, 189, 248, 0.5));
  animation: floatGem 5s ease-in-out infinite;
}

.hero-gem img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
}

.welcome-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #f8fafc 0%, #38bdf8 50%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.welcome-subtitle {
  font-size: 0.92rem;
  color: var(--text-secondary);
  max-width: 660px;
  margin: 0 auto 20px;
  line-height: 1.5;
}

.welcome-telemetry-pills {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.w-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.76rem;
  color: var(--text-secondary);
}

.w-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.w-dot.green { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.w-dot.cyan { background: var(--accent-cyan); box-shadow: 0 0 6px var(--accent-cyan); }
.w-dot.purple { background: var(--accent-purple); box-shadow: 0 0 6px var(--accent-purple); }

.welcome-partitions-header {
  margin-bottom: 16px;
  text-align: center;
}

.welcome-partitions-header h3 {
  font-size: 0.82rem;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.welcome-partitions-header p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.welcome-partition-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 30px;
  text-align: left;
}

.welcome-p-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

.welcome-p-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.welcome-p-card.card-workspace:hover {
  border-color: var(--accent-emerald);
}

.welcome-p-card.card-reference:hover {
  border-color: var(--accent-cyan);
}

.welcome-p-card.card-private:hover {
  border-color: var(--accent-purple);
}

.welcome-p-card.card-drawing:hover {
  border-color: var(--accent-amber);
}

.wp-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.wp-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.wp-badge {
  margin-left: auto;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.wp-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 14px;
  flex: 1;
}

.wp-cta {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-cyan);
  display: inline-flex;
  align-items: center;
}

.card-workspace .wp-cta { color: var(--accent-emerald); }
.card-reference .wp-cta { color: var(--accent-cyan); }
.card-private .wp-cta { color: var(--accent-purple); }
.card-drawing .wp-cta { color: var(--accent-amber); }

.welcome-actions-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

/* Document Active Container */
.doc-active-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* Markdown Rendering Enhancements: Tables, Alerts, Tasks             */
/* ------------------------------------------------------------------ */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 18px 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.markdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  text-align: left;
}

.markdown-table th,
.markdown-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.markdown-table th {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  border-bottom: 2px solid var(--border-bright);
}

.markdown-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.015);
}

.markdown-table tr:hover td {
  background: rgba(6, 182, 212, 0.05);
}

/* Callout Alerts */
.alert-box {
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.5;
  border-left: 4px solid;
}

.alert-title {
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.alert-note {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  color: #e0f2fe;
}
.alert-note .alert-title { color: var(--accent-cyan); }

.alert-caution, .alert-warning {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
  color: #fef3c7;
}
.alert-caution .alert-title, .alert-warning .alert-title { color: var(--accent-amber); }

.alert-tip {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  color: #d1fae5;
}
.alert-tip .alert-title { color: var(--accent-emerald); }

.alert-important {
  border-color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.08);
  color: #f3e8ff;
}
.alert-important .alert-title { color: var(--accent-purple); }

.markdown-article hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 22px 0;
}

.markdown-article p {
  margin-bottom: 12px;
  line-height: 1.6;
}

.markdown-article ul, .markdown-article ol {
  margin-left: 20px;
  margin-bottom: 12px;
  line-height: 1.6;
}

.markdown-article h1 { font-size: 1.6rem; margin: 20px 0 12px; font-weight: 700; }
.markdown-article h2 { font-size: 1.3rem; margin: 18px 0 10px; font-weight: 700; border-bottom: 1px solid var(--border-subtle); padding-bottom: 4px; }
.markdown-article h3 { font-size: 1.1rem; margin: 14px 0 8px; font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Plugins & Extensions Workspace Styles                              */
/* ------------------------------------------------------------------ */
.plugins-workspace-content {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.plugins-security-banner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 28px;
}

.sec-banner-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.sec-banner-body h4 {
  font-size: 0.95rem;
  color: var(--accent-cyan);
  margin-bottom: 4px;
  font-weight: 700;
}

.sec-banner-body p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.plugin-section-block {
  margin-bottom: 30px;
}

.plugin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.plugin-section-header h3 {
  font-size: 0.85rem;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 700;
}

.section-pill {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: 12px;
}

.section-pill-verified {
  font-size: 0.72rem;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
}

.section-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Installed Plugins Flow */
.installed-plugins-flow {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-plugins-box {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px dashed var(--border-subtle);
  border-radius: 8px;
}
.empty-plugins-box .empty-icon { font-size: 2.2rem; margin-bottom: 8px; }
.empty-plugins-box h4 { color: var(--text-primary); margin-bottom: 4px; font-size: 0.95rem; }
.empty-plugins-box p { font-size: 0.82rem; max-width: 480px; margin: 0 auto; }

.plugin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px 20px;
  transition: all 0.15s ease;
}

.plugin-card.disabled {
  opacity: 0.65;
  border-color: var(--border-subtle);
}

.plugin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.plugin-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.plugin-name {
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--text-primary);
}

.plugin-version {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.plugin-tag-verified {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 2px 8px;
  border-radius: 10px;
}

.plugin-tag-sideload {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 2px 8px;
  border-radius: 10px;
}

.plugin-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.plugin-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.meta-chip {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
}

.plugin-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 12px;
}

.plugin-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
}
.plugin-status-indicator.active { color: var(--accent-emerald); }
.plugin-status-indicator.inactive { color: var(--text-muted); }

.plugin-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-toggle-plugin {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid;
}
.btn-toggle-plugin.btn-disable {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.3);
}
.btn-toggle-plugin.btn-enable {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.3);
}

.btn-remove-plugin {
  font-size: 0.76rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-remove-plugin:hover {
  color: var(--accent-rose);
  border-color: var(--accent-rose);
}

/* Catalog Grid */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.catalog-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.15s ease;
}

.catalog-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.cat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cat-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.cat-size {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.cat-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 12px;
  flex: 1;
}

.cat-badges-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.btn-install-plugin {
  width: 100%;
}

.btn-installed {
  background: rgba(16, 185, 129, 0.12) !important;
  color: var(--accent-emerald) !important;
  border: 1px solid rgba(16, 185, 129, 0.3) !important;
  cursor: default !important;
  width: 100%;
}

/* ==============================================================================
   User Account Bar (Sidebar Bottom)
   ============================================================================== */
.user-account-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  margin: 8px 12px;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.15s ease;
}

.user-account-bar:hover {
  border-color: var(--border-bright);
}

.user-account-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.user-avatar-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(6, 182, 212, 0.2) 100%);
  border: 1px solid rgba(16, 185, 129, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.user-meta-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name-display {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-display {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--accent-emerald);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  transform: scale(1.08);
}

/* User Account Popup Dropdown Menu */
.user-profile-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 4px;
  width: 220px;
  background: var(--bg-surface, #161b22);
  border: 1px solid var(--border-bright, rgba(255, 255, 255, 0.15));
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 1px rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 6px;
  z-index: 100001 !important;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: fadeInPopup 0.15s ease-out;
}

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

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
}

.user-menu-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.user-menu-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-menu-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-menu-role {
  font-size: 0.68rem;
  color: var(--accent-emerald, #34d399);
  text-transform: uppercase;
  font-weight: 600;
}

.user-menu-divider {
  height: 1px;
  background: var(--border-subtle, rgba(255, 255, 255, 0.08));
  margin: 3px 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  text-align: left;
}

.user-menu-item:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.08));
  color: var(--text-primary);
}

.user-menu-danger {
  color: #ef4444;
}

.user-menu-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* ==============================================================================
   Authentication Screens & Modals
   ============================================================================== */
.auth-overlay,
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(8, 10, 15, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeInAuth 0.25s ease-out forwards;
}

@keyframes fadeInAuth {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* Google Picker API Dialog Overlays (Ensure dialog renders above .auth-overlay z-index 9999) */
.picker-dialog {
  z-index: 200000 !important;
}
.picker-dialog-bg {
  z-index: 199999 !important;
}

.modal-content,
.modal-card {
  position: relative;
  background: var(--bg-card, #1c1f26);
  border: 1px solid var(--border-bright, #373746);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 50px rgba(0, 0, 0, 0.4);
  color: var(--text-primary, #ffffff);
  max-width: 560px;
  width: 92vw;
  box-sizing: border-box;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle, #292933);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted, #9898a8);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s ease;
  line-height: 1;
}

.modal-close:hover {
  background: var(--bg-hover, #272730);
  color: var(--text-primary, #ffffff);
}

.modal-body {
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle, #292933);
}

.auth-card {
  position: relative;
  width: 440px;
  max-width: 92vw;
  background: linear-gradient(180deg, #131822 0%, #0d1117 100%);
  border: 1px solid rgba(45, 55, 72, 0.85);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 50px rgba(16, 185, 129, 0.08);
  overflow: hidden;
}

.onboarding-card {
  width: 500px;
}

.profile-card {
  width: 460px;
}

.auth-card-glow {
  position: absolute;
  top: -50px;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  height: 120px;
  background: radial-gradient(ellipse, rgba(16, 185, 129, 0.3) 0%, transparent 70%);
  pointer-events: none;
}

.auth-header {
  text-align: center;
  margin-bottom: 24px;
}

.auth-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.auth-gem-container {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-gem-img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 16px rgba(16, 185, 129, 0.5));
}

.auth-icon-badge {
  font-size: 2.2rem;
  margin-bottom: 8px;
}

.auth-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.auth-header-row h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.auth-sub {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.45;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.auth-input {
  background: #07090e;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: all 0.15s ease;
}

.auth-input:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
  background: #090c12;
}

.auth-submit-btn {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.form-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.auth-footer {
  text-align: center;
  margin-top: 22px;
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.auth-alert-error {
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid var(--accent-rose);
  color: #fecdd3;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.4;
}

.auth-alert-status {
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid var(--accent-emerald);
  color: #a7f3d0;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.4;
}

/* ==============================================================================
   Mobile Responsiveness, Burger Menu & Collapsible Sidebar Drawer
   ============================================================================== */

/* Responsive Mobile Navigation Topbar (Hidden on Desktop >=1025px) */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 14px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  width: 100%;
}

.btn-desktop-back,
#btn-desktop-back {
  display: none !important;
}

.mobile-bar-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.mobile-back-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  padding: 6px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 38px;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.mobile-back-btn:active {
  background: var(--bg-hover);
  transform: scale(0.96);
}

.mobile-doc-header-title {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  margin-left: 10px;
  padding: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.mobile-menu-btn:active {
  background: var(--bg-hover);
  transform: scale(0.96);
}

/* Mobile Document Options Sheet */
.mobile-doc-sheet {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.mobile-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.mobile-sheet-content {
  position: relative;
  z-index: 2001;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-bright);
  border-radius: 18px 18px 0 0;
  padding: 22px 20px 32px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.8);
  animation: slideUpSheet 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpSheet {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.mobile-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-sheet-title-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  padding-right: 12px;
}

.mobile-sheet-title-col h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
}

.mobile-sheet-actions {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  margin-bottom: 18px !important;
  width: 100% !important;
}

.mobile-sheet-actions .btn {
  width: 100% !important;
  flex: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  min-height: 44px !important;
  padding: 10px 16px !important;
  font-size: 0.9rem !important;
  border-radius: 8px !important;
  box-sizing: border-box !important;
  text-align: left !important;
}

.mobile-sheet-meta-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.8rem;
}

.sheet-meta-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet-meta-item .meta-label {
  font-weight: 600;
  color: var(--text-muted);
  width: 48px;
  flex-shrink: 0;
}

.sheet-meta-item .meta-val {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  word-break: break-all;
}

.sheet-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Welcome Partition Documents Dynamic List */
.welcome-partition-docs {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  padding: 20px 22px;
  margin: 18px 0 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: fadeInDocs 0.25s ease-out forwards;
}

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

.wp-docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.wp-docs-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wp-docs-title-row h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.wp-docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.p-doc-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.15s ease;
}

.p-doc-card:hover, .p-doc-card:active {
  border-color: var(--accent-cyan);
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.p-doc-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.35;
}

.p-doc-card-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.p-doc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.p-doc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.p-doc-tag {
  font-size: 0.68rem;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
}

.p-doc-cta {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.burger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  cursor: pointer;
  padding: 8px;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.burger-btn:hover, .burger-btn:active {
  background: var(--bg-hover);
  border-color: var(--border-bright);
}

.burger-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.burger-btn.active .burger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.burger-btn.active .burger-bar:nth-child(2) {
  opacity: 0;
}
.burger-btn.active .burger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.mobile-gem-wrapper {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-gem-img {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 8px rgba(6, 182, 212, 0.4));
}

.mobile-brand-title {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #f8fafc 0%, #38bdf8 50%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mobile-kernel-pill {
  font-size: 0.62rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 1px 5px;
  border-radius: 6px;
}

.mobile-action-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-action-btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

/* Close button inside sidebar header */
.btn-close-sidebar {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 1.15rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-close-sidebar:hover, .btn-close-sidebar:active {
  color: var(--text-primary);
  background: var(--bg-hover);
  border-color: var(--border-bright);
}

/* Sidebar Backdrop Blur Overlay */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 99999 !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ------------------------------------------------------------------ */
/* Responsive Media Queries                                           */
/* ------------------------------------------------------------------ */

/* Tablets and Mobile (<= 1024px) */
@media (max-width: 1024px) {
  .app-layout {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    position: relative;
  }

  .mobile-topbar {
    display: flex;
    height: 52px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
  }

  /* Keep document header bar visible with responsive collapsed toolbar */
  .doc-header-bar {
    display: flex !important;
    padding: 6px 12px !important;
  }

  .partition-notice {
    display: none !important;
  }

  .btn-close-sidebar {
    display: flex;
  }

  .sidebar-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(340px, 86vw);
    max-width: 360px;
    z-index: 100000 !important;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.75);
  }

  /* Mobile Doc Header: Hide desktop close button and desktop toolbar actions above document */
  #btn-close-doc {
    display: none !important;
  }
  .doc-toolbar-actions {
    display: none !important;
  }

  /* Mobile Toast: centered horizontally, 92px above bottom floating action bubbles */
  #sphene-toast-container {
    bottom: 92px !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    align-items: center !important;
    max-width: calc(100vw - 32px) !important;
    width: max-content !important;
  }
  .sphene-toast {
    text-align: center !important;
  }

  /* Mobile Modals: clearance above bottom floating bubbles */
  .modal-content,
  .modal-card {
    margin-bottom: 72px !important;
  }

  .main-viewport {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .view-panel {
    flex: 1;
    min-height: 0;
    height: calc(100% - 52px);
    overflow: hidden;
  }

  .doc-active-container {
    height: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .doc-scroll-viewport {
    padding: 16px 18px 40px;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    height: auto;
  }

  .markdown-article {
    max-width: 100%;
    font-size: 0.96rem;
  }

  .markdown-article h1:first-child {
    margin-top: 4px;
    font-size: 1.4rem;
  }

  .welcome-container {
    padding: 24px 18px;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    height: 100%;
  }

  .catalog-grid {
    grid-template-columns: 1fr;
  }
}

/* Small Tablets and Large Phones (<= 768px) */
@media (max-width: 768px) {
  .doc-header-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
  }

  .doc-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .doc-title-row h1 {
    font-size: 1.35rem;
    word-break: break-word;
    line-height: 1.3;
  }

  .doc-details-row {
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.76rem;
  }

  .doc-toolbar-actions {
    display: none !important;
  }

  .doc-scroll-viewport {
    padding: 16px 16px 40px;
  }

  .markdown-article {
    font-size: 0.95rem;
    max-width: 100%;
  }

  .markdown-article h1 { font-size: 1.45rem; margin-top: 16px; }
  .markdown-article h2 { font-size: 1.2rem; margin-top: 14px; }
  .markdown-article h3 { font-size: 1.05rem; margin-top: 12px; }

  /* Ensure wide tables and pre blocks are smooth scrollable on touch */
  .table-wrapper {
    margin: 14px 0;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .markdown-article pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
    font-size: 0.82rem;
  }

  /* Welcome Screen Responsiveness */
  .welcome-container {
    padding: 24px 16px;
  }

  .welcome-hero-content {
    max-width: 100%;
  }

  .hero-gem-container {
    width: 70px;
    height: 70px;
    margin-bottom: 12px;
  }

  .welcome-title {
    font-size: 1.55rem;
    letter-spacing: 1px;
  }

  .welcome-subtitle {
    font-size: 0.88rem;
    margin-bottom: 16px;
  }

  .welcome-telemetry-pills {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 24px;
  }

  .w-pill {
    font-size: 0.72rem;
    padding: 4px 9px;
  }

  .welcome-partition-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .welcome-actions-row {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .welcome-actions-row .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  /* Panels & Controls */
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
  }

  .panel-header h2 {
    font-size: 1.2rem;
  }

  .graph-legend {
    flex-wrap: wrap;
    gap: 10px;
  }

  .graph-controls-dock {
    bottom: 16px;
    right: 16px;
    flex-direction: column;
    gap: 8px;
  }

  .editor-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .editor-actions {
    display: flex;
    gap: 8px;
  }

  .editor-actions .btn {
    flex: 1;
    min-height: 42px;
    justify-content: center;
  }

  /* Modals */
  .auth-card {
    padding: 24px 20px;
    max-width: 92vw;
  }

  .onboarding-card, .profile-card {
    width: 92vw;
  }

  /* ==========================================================================
     Settings & User Management Responsive Styles (<= 768px)
     ========================================================================== */
  #tab-settings .panel-header {
    padding: 14px 14px;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
  }

  .settings-nav-tabs {
    width: 100%;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .settings-tab-btn {
    flex: 1 1 50%;
    white-space: nowrap;
    text-align: center;
    justify-content: center;
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  #tab-settings .panel-scroll-viewport {
    padding: 12px 10px 40px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .settings-section-container {
    padding: 0 !important;
    gap: 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .settings-card {
    border-radius: 8px;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .settings-card-header {
    padding: 12px 14px !important;
    gap: 10px !important;
    box-sizing: border-box !important;
  }

  .settings-card-header h3 {
    font-size: 0.95rem !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  .settings-card-header p {
    font-size: 0.8rem !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  .settings-card-body {
    padding: 14px 12px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  /* Grid adjustments for mobile settings */
  .settings-card-body div[style*="grid-template-columns"],
  #tailscale-connected-container div[style*="grid-template-columns"],
  #tailscale-setup-container div[style*="grid-template-columns"],
  #cloud-sync-connect-options,
  #cloud-sync-active-details > div,
  .settings-user-form > div[style*="grid-template-columns"],
  .tailscale-metrics-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Grid items and cards */
  .settings-card-body div[style*="grid-template-columns"] > div,
  #tailscale-connected-container div[style*="grid-template-columns"] > div,
  #cloud-sync-connect-options .pwa-step-card,
  #tailscale-setup-container .pwa-step-card,
  .tailscale-metric-box {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  /* Connected Daemon Endpoint card */
  #settings-card-daemon-endpoint .settings-card-body > div:first-child {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
    padding: 10px 12px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  #settings-card-daemon-endpoint .settings-card-body > div:first-child > div:first-child {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  #active-daemon-url-display {
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  #input-daemon-url {
    min-width: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
    flex: 1 1 100% !important;
  }

  .settings-card-body div:has(#input-daemon-url),
  .settings-card-body div:has(#btn-save-daemon-url) {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  #btn-test-daemon-url,
  #btn-save-daemon-url,
  #btn-reset-daemon-url {
    flex: 1 1 auto !important;
    min-height: 38px !important;
    justify-content: center !important;
  }

  /* Tailscale containers */
  #tailscale-connected-container,
  #tailscale-setup-container {
    padding: 12px 10px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  #tailscale-status-title,
  #tailscale-status-desc {
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  #tailscale-magicdns-display,
  #tailscale-https-display,
  #tailscale-ip-display,
  #tailnet-name-display {
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  #tailscale-tls-box {
    padding: 10px 12px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  #tailscale-tls-box strong,
  #tailscale-tls-heading {
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  #tailscale-tls-guide code {
    word-break: break-all !important;
    overflow-wrap: anywhere !important;
    white-space: normal !important;
    display: inline !important;
    max-width: 100% !important;
  }

  #tailscale-tls-guide ol {
    padding-left: 18px !important;
  }

  #tailscale-qr-wrapper {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Master Cipher Key row */
  .settings-row div[style*="min-width:240px"],
  .settings-row div[style*="min-width: 240px"],
  .master-cipher-input-wrapper {
    min-width: 0 !important;
    width: 100% !important;
    flex: 1 1 100% !important;
    box-sizing: border-box !important;
  }

  #btn-generate-cipher-key {
    width: 100% !important;
    justify-content: center !important;
    min-height: 38px !important;
  }

  .sovereign-decrypt-callout {
    padding: 12px 10px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .code-snippet-box {
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .code-snippet-box code {
    word-break: break-all !important;
    white-space: pre-wrap !important;
  }

  .callout-humor {
    word-break: break-word !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* User profiles responsive cards */
  .settings-user-form > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  #btn-update-profile-submit,
  #btn-create-user-submit {
    width: 100% !important;
    height: 42px !important;
  }

  .users-table-wrapper {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .users-table-wrapper table {
    display: block !important;
    width: 100% !important;
  }

  .users-table-wrapper thead {
    display: none !important;
  }

  .users-table-wrapper tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .users-table-wrapper tr {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    padding: 12px !important;
    background: var(--bg-surface, #161b22) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 8px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .users-table-wrapper td {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 3px 0 !important;
    border-bottom: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
    font-size: 0.82rem !important;
    word-break: break-all !important;
  }

  .users-table-wrapper td:last-child {
    margin-top: 6px !important;
    padding-top: 8px !important;
    border-top: 1px solid var(--border-subtle) !important;
    justify-content: flex-end !important;
  }

  .users-table-wrapper td .btn-delete-user {
    width: 100% !important;
    justify-content: center !important;
    min-height: 36px !important;
  }

  /* Save action bar */
  .settings-action-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .settings-action-bar .btn {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
  }
}

/* Compact Mobile Phones (<= 480px) */
@media (max-width: 480px) {
  .mobile-brand-title {
    font-size: 0.95rem;
  }


  .partition-cards {
    gap: 8px;
  }

  .search-container {
    padding: 10px 14px;
  }

  .nav-pills {
    padding: 10px 12px;
  }

  .doc-list-section {
    padding: 12px 14px;
  }
}

/* ==========================================================================
   Obsidian-Grade Real Plugin Suite & Documentation Styles
   ========================================================================== */

/* Plugin Filter Toolbar & Search */
.plugin-filter-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.plugin-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.plugin-search-wrap .search-icon {
  position: absolute;
  left: 14px;
  font-size: 0.95rem;
  color: var(--text-muted);
  pointer-events: none;
}

.plugin-search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-input, #13171d);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  border-radius: 8px;
  color: var(--text-primary, #e6edf3);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.plugin-search-input:focus {
  outline: none;
  border-color: var(--accent-primary, #2dd4bf);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.plugin-category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-pill {
  background: var(--bg-card, #161b22);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  color: var(--text-muted, #8b949e);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cat-pill:hover {
  background: var(--bg-card-hover, #1f242c);
  color: var(--text-primary, #e6edf3);
  border-color: rgba(255,255,255,0.2);
}

.cat-pill.active {
  background: var(--accent-primary, #2dd4bf);
  color: #0b0f14;
  border-color: var(--accent-primary, #2dd4bf);
  font-weight: 600;
}

/* Obsidian-Style Plugin Detail Modal */
.plugin-detail-dialog {
  background: var(--bg-surface, #0d1117);
  border: 1px solid var(--border-default, rgba(255,255,255,0.12));
  border-radius: 12px;
  width: 90%;
  max-width: 860px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.p-detail-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  background: linear-gradient(180deg, var(--bg-card, #161b22) 0%, var(--bg-surface, #0d1117) 100%);
}

.p-detail-hero {
  display: flex;
  align-items: center;
  gap: 18px;
}

.p-detail-icon-box {
  width: 58px;
  height: 58px;
  border-radius: 14px;
  background: var(--bg-input, #13171d);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.p-detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.p-detail-title-row h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary, #e6edf3);
  margin: 0;
}

.p-version-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  color: var(--text-muted);
}

.p-verified-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: rgba(45, 212, 191, 0.12);
  color: var(--accent-primary, #2dd4bf);
  border: 1px solid rgba(45, 212, 191, 0.25);
  border-radius: 6px;
  font-weight: 600;
}

.p-detail-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted, #8b949e);
}

.p-cat-tag {
  color: var(--accent-primary, #2dd4bf);
  font-weight: 500;
}

.p-detail-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.p-action-controls {
  display: flex;
  gap: 10px;
}

/* Tabs */
.p-detail-tabs {
  display: flex;
  background: var(--bg-card, #161b22);
  padding: 0 24px;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
}

.p-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted, #8b949e);
  padding: 12px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.p-tab-btn:hover {
  color: var(--text-primary, #e6edf3);
}

.p-tab-btn.active {
  color: var(--accent-primary, #2dd4bf);
  border-bottom-color: var(--accent-primary, #2dd4bf);
  font-weight: 600;
}

/* Body */
.p-detail-body {
  padding: 28px;
  overflow-y: auto;
  flex: 1;
}

.p-lead-desc {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-primary, #e6edf3);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}

.p-markdown-body {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary, #c9d1d9);
  white-space: pre-wrap;
}

.p-markdown-body h3, .p-markdown-body h4 {
  color: var(--text-primary, #e6edf3);
  margin: 18px 0 8px;
}

.p-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.p-action-card {
  background: var(--bg-card, #161b22);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.08));
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s ease;
}

.p-action-card:hover {
  border-color: rgba(45, 212, 191, 0.3);
  transform: translateY(-2px);
}

.p-action-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary, #e6edf3);
}

.p-action-card-desc {
  font-size: 0.85rem;
  color: var(--text-muted, #8b949e);
  line-height: 1.5;
}

.p-action-output {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-input, #13171d);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.1));
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--accent-primary, #2dd4bf);
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}

.p-security-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.p-sec-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  background: var(--bg-card, #161b22);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
  border-radius: 8px;
}

.p-sec-icon {
  font-size: 1.2rem;
}

.p-sec-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.p-sec-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Themes
   ========================================================================== */
/* 1. Minimalist Dark (Kindle OLED True Black) */
html.theme-minimalist-dark {
  --bg-deep: #000000 !important;
  --bg-sidebar: #050505 !important;
  --bg-card: #0a0a0a !important;
  --bg-hover: #141414 !important;
  --bg-input: #000000 !important;
  --border-subtle: #1c1917 !important;
  --border-bright: #292524 !important;
  --text-primary: #f5f5f4 !important;
  --text-secondary: #a8a29e !important;
  --text-muted: #78716c !important;
  --accent-emerald: #10b981 !important;
  --accent-cyan: #06b6d4 !important;
  --accent-purple: #a855f7 !important;
  --accent-amber: #f59e0b !important;
}

html.theme-minimalist-dark body,
html.theme-minimalist-dark .app-layout,
html.theme-minimalist-dark .main-content,
html.theme-minimalist-dark .view-panel,
html.theme-minimalist-dark .doc-scroll-viewport,
html.theme-minimalist-dark .doc-viewer-card,
html.theme-minimalist-dark .editor-pane {
  background: #000000 !important;
  color: #f5f5f4 !important;
}

html.theme-minimalist-dark .sidebar {
  background: #050505 !important;
  border-right: 1px solid #1c1917 !important;
}

html.theme-minimalist-dark .doc-header-bar,
html.theme-minimalist-dark .panel-header,
html.theme-minimalist-dark .header-bar {
  background: #080808 !important;
  border-bottom: 1px solid #1c1917 !important;
}

html.theme-minimalist-dark .catalog-card,
html.theme-minimalist-dark .plugin-card,
html.theme-minimalist-dark .auth-card,
html.theme-minimalist-dark .modal-content,
html.theme-minimalist-dark .modal-card,
html.theme-minimalist-dark .plugin-detail-dialog {
  background: #0a0a0a !important;
  border-color: #262626 !important;
}

/* 2. Minimalist White (Paper Editorial) */
html.theme-minimalist-white {
  --bg-deep: #ffffff !important;
  --bg-sidebar: #f8fafc !important;
  --bg-card: #ffffff !important;
  --bg-hover: #f1f5f9 !important;
  --bg-input: #ffffff !important;
  --border-subtle: #e2e8f0 !important;
  --border-bright: #cbd5e1 !important;
  --text-primary: #0f172a !important;
  --text-secondary: #475569 !important;
  --text-muted: #64748b !important;
  --accent-emerald: #0f766e !important;
  --accent-cyan: #0284c7 !important;
  --accent-purple: #7c3aed !important;
  --accent-amber: #b45309 !important;
}

html.theme-minimalist-white body,
html.theme-minimalist-white .app-layout,
html.theme-minimalist-white .main-content,
html.theme-minimalist-white .view-panel,
html.theme-minimalist-white .doc-scroll-viewport,
html.theme-minimalist-white .doc-viewer-card,
html.theme-minimalist-white .editor-pane,
html.theme-minimalist-white .editor-code {
  background: #ffffff !important;
  color: #0f172a !important;
}

html.theme-minimalist-white .sidebar {
  background: #f8fafc !important;
  border-right: 1px solid #e2e8f0 !important;
}

html.theme-minimalist-white .doc-header-bar,
html.theme-minimalist-white .panel-header,
html.theme-minimalist-white .header-bar {
  background: #f1f5f9 !important;
  border-bottom: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}

html.theme-minimalist-white .markdown-article {
  color: #1e293b !important;
}

html.theme-minimalist-white .markdown-article h1,
html.theme-minimalist-white .markdown-article h2,
html.theme-minimalist-white .markdown-article h3,
html.theme-minimalist-white .markdown-article h4,
html.theme-minimalist-white .markdown-article strong {
  color: #0f172a !important;
}

html.theme-minimalist-white .markdown-article p,
html.theme-minimalist-white .markdown-article li {
  color: #334155 !important;
}

html.theme-minimalist-white .markdown-article hr {
  border-top: 1px solid #e2e8f0 !important;
}

html.theme-minimalist-white .doc-item {
  color: #1e293b !important;
}

html.theme-minimalist-white .doc-item:hover {
  background: #e2e8f0 !important;
}

html.theme-minimalist-white .doc-item.active {
  background: #e0f2fe !important;
  color: #0284c7 !important;
}

html.theme-minimalist-white .doc-item-snippet {
  color: #64748b !important;
}

html.theme-minimalist-white .catalog-card,
html.theme-minimalist-white .plugin-card,
html.theme-minimalist-white .auth-card,
html.theme-minimalist-white .modal-content,
html.theme-minimalist-white .modal-card,
html.theme-minimalist-white .plugin-detail-dialog {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06) !important;
}

html.theme-minimalist-white .p-detail-header,
html.theme-minimalist-white .p-detail-tabs {
  background: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

html.theme-minimalist-white .btn-secondary {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}

html.theme-minimalist-white .btn-secondary:hover {
  background: #e2e8f0 !important;
}

html.theme-minimalist-white .cat-pill {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #475569 !important;
}

html.theme-minimalist-white .cat-pill.active {
  background: #0f766e !important;
  color: #ffffff !important;
}

html.theme-minimalist-white .partition-select-dropdown {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05) !important;
}
html.theme-minimalist-white .partition-option:hover {
  background: #f1f5f9 !important;
}
html.theme-minimalist-white .partition-option.active {
  background: #e2e8f0 !important;
}
html.theme-minimalist-white .p-option-name {
  color: #0f172a !important;
}
html.theme-minimalist-white .p-option-desc {
  color: #64748b !important;
}
html.theme-minimalist-white .editor-filename-input-box {
  background: #ffffff !important;
  border-color: #cbd5e1 !important;
}
html.theme-minimalist-white .editor-filename-input-box:focus-within {
  border-color: #0284c7 !important;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15) !important;
}
html.theme-minimalist-white .editor-input-filename {
  color: #0f172a !important;
}
html.theme-minimalist-white .editor-ext-badge {
  background: #f1f5f9 !important;
  color: #64748b !important;
  border-color: #cbd5e1 !important;
}
html.theme-minimalist-white .badge-workspace { background: rgba(16, 185, 129, 0.12) !important; color: #047857 !important; border-color: rgba(16, 185, 129, 0.3) !important; }
html.theme-minimalist-white .badge-reference { background: rgba(6, 182, 212, 0.12) !important; color: #0369a1 !important; border-color: rgba(6, 182, 212, 0.3) !important; }
html.theme-minimalist-white .badge-private { background: rgba(168, 85, 247, 0.12) !important; color: #6b21a8 !important; border-color: rgba(168, 85, 247, 0.3) !important; }
html.theme-minimalist-white .badge-drawing { background: rgba(245, 158, 11, 0.12) !important; color: #b45309 !important; border-color: rgba(245, 158, 11, 0.3) !important; }
html.theme-minimalist-white .notice-workspace { color: #065f46 !important; }
html.theme-minimalist-white .notice-reference { color: #075985 !important; }
html.theme-minimalist-white .notice-private { color: #5b21b6 !important; }
html.theme-minimalist-white .notice-drawing { color: #92400e !important; }

/* 3. Google Material Design 3 */
html.theme-material {
  --bg-deep: #141218 !important;
  --bg-sidebar: #1d192b !important;
  --bg-card: #211f26 !important;
  --bg-hover: #2b2930 !important;
  --bg-input: #1d1b20 !important;
  --border-subtle: rgba(208, 188, 255, 0.12) !important;
  --border-bright: rgba(208, 188, 255, 0.24) !important;
  --text-primary: #e6e0e9 !important;
  --text-secondary: #cac4d0 !important;
  --text-muted: #938f99 !important;
  --accent-emerald: #6dd58c !important;
  --accent-cyan: #7cacf8 !important;
  --accent-purple: #d0bcff !important;
  --accent-amber: #ffb951 !important;
}

html.theme-material body,
html.theme-material .app-layout,
html.theme-material .main-content,
html.theme-material .view-panel,
html.theme-material .doc-scroll-viewport {
  background: #141218 !important;
  color: #e6e0e9 !important;
}

html.theme-material .sidebar {
  background: #1d192b !important;
  border-right: 1px solid rgba(208, 188, 255, 0.12) !important;
}

html.theme-material .btn,
html.theme-material .nav-pill,
html.theme-material .cat-pill,
html.theme-material .tag-chip {
  border-radius: 20px !important;
}

/* 4. Cyber Velvet Rock (Glam Amethyst Multi-Color) */
html.theme-cyber-velvet-rock {
  --bg-deep: #080a0f !important;
  --bg-sidebar: #0f131a !important;
  --bg-card: #151a24 !important;
  --bg-hover: #1c2331 !important;
  --bg-input: #0b0e14 !important;
  --border-subtle: #1f2736 !important;
  --border-bright: #2d3748 !important;
  --text-primary: #f1f5f9 !important;
  --text-secondary: #94a3b8 !important;
  --text-muted: #64748b !important;
  --accent-primary: #a855f7 !important;
  --accent-secondary: #06b6d4 !important;
  --accent-emerald: #10b981 !important;
  --accent-cyan: #06b6d4 !important;
  --accent-purple: #a855f7 !important;
  --accent-amber: #f59e0b !important;
  --accent-rose: #f43f5e !important;
  --diff-add-bg: rgba(16, 185, 129, 0.15) !important;
  --diff-add-border: #10b981 !important;
  --diff-del-bg: rgba(244, 63, 94, 0.15) !important;
  --diff-del-border: #f43f5e !important;
  --diff-mod-bg: rgba(168, 85, 247, 0.15) !important;
  --diff-mod-border: #a855f7 !important;
}

html.theme-cyber-velvet-rock body,
html.theme-cyber-velvet-rock .app-layout,
html.theme-cyber-velvet-rock .main-content,
html.theme-cyber-velvet-rock .view-panel,
html.theme-cyber-velvet-rock .doc-scroll-viewport {
  background: #080a0f !important;
  color: #f1f5f9 !important;
}

html.theme-cyber-velvet-rock .sidebar {
  background: #0f131a !important;
  border-right: 1px solid #1f2736 !important;
}

/* 5. Antracite (Monochrome Dark Grey — Soft Charcoal & Pure White Accents) */
html.theme-antracite {
  --bg-deep: #212429 !important;
  --bg-sidebar: #1b1d21 !important;
  --bg-card: #282c32 !important;
  --bg-hover: #32373f !important;
  --bg-input: #1b1d21 !important;
  --border-subtle: #363b44 !important;
  --border-bright: #4b525e !important;
  --text-primary: #ffffff !important;
  --text-secondary: #c4cad4 !important;
  --text-muted: #828a96 !important;
  --accent-primary: #ffffff !important;
  --accent-secondary: #d1d5db !important;
  --accent-emerald: #ffffff !important;
  --accent-cyan: #ffffff !important;
  --accent-purple: #e5e7eb !important;
  --accent-amber: #e5e7eb !important;
  --accent-rose: #9ca3af !important;
  --diff-add-bg: rgba(255, 255, 255, 0.08) !important;
  --diff-add-border: #9ca3af !important;
  --diff-del-bg: rgba(0, 0, 0, 0.25) !important;
  --diff-del-border: #4b5563 !important;
  --diff-mod-bg: rgba(255, 255, 255, 0.05) !important;
  --diff-mod-border: #6b7280 !important;
}

html.theme-antracite body,
html.theme-antracite .app-layout,
html.theme-antracite .main-content,
html.theme-antracite .view-panel,
html.theme-antracite .doc-scroll-viewport,
html.theme-antracite .doc-viewer-card,
html.theme-antracite .editor-pane {
  background: #212429 !important;
  color: #c4cad4 !important;
}

html.theme-antracite .sidebar {
  background: #1b1d21 !important;
  border-right: 1px solid #363b44 !important;
}

html.theme-antracite .doc-header-bar,
html.theme-antracite .panel-header,
html.theme-antracite .header-bar,
html.theme-antracite .mobile-header-bar {
  background: #1b1d21 !important;
  border-bottom: 1px solid #363b44 !important;
}

html.theme-antracite .catalog-card,
html.theme-antracite .plugin-card,
html.theme-antracite .auth-card,
html.theme-antracite .plugin-detail-dialog,
html.theme-antracite .modal-card,
html.theme-antracite .modal-content,
html.theme-antracite .version-history-card,
html.theme-antracite .tools-dropdown-menu,
html.theme-antracite .partition-select-dropdown,
html.theme-antracite .mobile-sheet-content {
  background: #282c32 !important;
  border-color: #3e444e !important;
  color: #c4cad4 !important;
}

html.theme-antracite .partition-option:hover {
  background: #363b44 !important;
}
html.theme-antracite .partition-option.active {
  background: #3e444e !important;
}
html.theme-antracite .p-option-name {
  color: #ffffff !important;
}
html.theme-antracite .p-option-desc {
  color: #9aa2ae !important;
}

html.theme-antracite .btn-primary {
  background: #ffffff !important;
  color: #1b1d21 !important;
  border: 1px solid #ffffff !important;
  font-weight: 600 !important;
}

html.theme-antracite .btn-primary:hover {
  background: #e5e7eb !important;
  color: #111315 !important;
  border-color: #e5e7eb !important;
}

html.theme-antracite .btn-secondary {
  background: #282c32 !important;
  border-color: #3e444e !important;
  color: #c4cad4 !important;
}

html.theme-antracite .btn-secondary:hover {
  background: #32373f !important;
  border-color: #ffffff !important;
  color: #ffffff !important;
}

html.theme-antracite .nav-pill.active,
html.theme-antracite .cat-pill.active {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: #ffffff !important;
  color: #ffffff !important;
}

html.theme-antracite .doc-item:hover {
  background: #282c32 !important;
}

html.theme-antracite .doc-item.active {
  background: #2b3038 !important;
  border-left: 3px solid #ffffff !important;
}

html.theme-antracite .doc-item-title {
  color: #e5e7eb !important;
}

html.theme-antracite .doc-item.active .doc-item-title {
  color: #ffffff !important;
}

html.theme-antracite .search-input-wrapper,
html.theme-antracite .auth-input,
html.theme-antracite .editor-code,
html.theme-antracite .editor-filename-input-box,
html.theme-antracite .editor-input-filename {
  background: #1b1d21 !important;
  border-color: #363b44 !important;
  color: #ffffff !important;
}

html.theme-antracite .editor-filename-input-box:focus-within {
  border-color: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2) !important;
}

html.theme-antracite .editor-ext-badge {
  background: #262930 !important;
  border-color: #404752 !important;
  color: #9aa2ae !important;
}

html.theme-antracite .tag-chip {
  background: #2a2e35 !important;
  border-color: #404752 !important;
  color: #c4cad4 !important;
}

html.theme-antracite .tag-chip:hover {
  border-color: #ffffff !important;
  color: #ffffff !important;
  background: #363b44 !important;
}

html.theme-antracite .brand-gem img,
html.theme-antracite .mobile-gem-img,
html.theme-antracite .hero-gem img {
  filter: grayscale(1) brightness(1.25) contrast(1.15);
}

/* ==========================================================================
   Themes: New Note (+ Note), Importer & Mobile Action Button Overrides
   ========================================================================== */

/* 1. Minimalist Dark */
html.theme-minimalist-dark #btn-new-note,
html.theme-minimalist-dark .mobile-action-btn {
  background: #f59e0b !important;
  color: #000000 !important;
  border: none !important;
  box-shadow: none !important;
}
html.theme-minimalist-dark #btn-new-note:hover,
html.theme-minimalist-dark .mobile-action-btn:hover {
  background: #d97706 !important;
}
html.theme-minimalist-dark #btn-open-importer {
  background: #0a0a0a !important;
  border-color: #262626 !important;
  color: #a8a29e !important;
}
html.theme-minimalist-dark #btn-open-importer:hover {
  background: #141414 !important;
  color: #f5f5f4 !important;
}

/* 2. Minimalist White */
html.theme-minimalist-white #btn-new-note,
html.theme-minimalist-white .mobile-action-btn {
  background: #0f766e !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: none !important;
}
html.theme-minimalist-white #btn-new-note:hover,
html.theme-minimalist-white .mobile-action-btn:hover {
  background: #115e59 !important;
}
html.theme-minimalist-white #btn-open-importer {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #1e293b !important;
}
html.theme-minimalist-white #btn-open-importer:hover {
  background: #e2e8f0 !important;
}

/* 3. Material */
html.theme-material #btn-new-note,
html.theme-material .mobile-action-btn {
  background: #d0bcff !important;
  color: #381e72 !important;
  border-radius: 20px !important;
  border: none !important;
}
html.theme-material #btn-new-note:hover,
html.theme-material .mobile-action-btn:hover {
  background: #e8def8 !important;
}
html.theme-material #btn-open-importer {
  border-radius: 20px !important;
  background: #2b2930 !important;
  border-color: rgba(208, 188, 255, 0.24) !important;
  color: #cac4d0 !important;
}
html.theme-material #btn-open-importer:hover {
  background: #36343b !important;
  color: #e6e0e9 !important;
}
html.theme-material .search-input-wrapper input {
  border-radius: 20px !important;
}

/* 4. Cyber Velvet Rock */
html.theme-cyber-velvet-rock #btn-new-note,
html.theme-cyber-velvet-rock .mobile-action-btn {
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 3px 12px rgba(16, 185, 129, 0.4) !important;
}
html.theme-cyber-velvet-rock #btn-new-note:hover,
html.theme-cyber-velvet-rock .mobile-action-btn:hover {
  box-shadow: 0 4px 18px rgba(6, 182, 212, 0.5) !important;
}
html.theme-cyber-velvet-rock #btn-open-importer {
  background: #151a24 !important;
  border-color: #1f2736 !important;
  color: #94a3b8 !important;
}
html.theme-cyber-velvet-rock #btn-open-importer:hover {
  background: #1c2331 !important;
  border-color: #06b6d4 !important;
  color: #f1f5f9 !important;
}

/* 5. Antracite */
html.theme-antracite #btn-new-note,
html.theme-antracite .mobile-action-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3) !important;
}
html.theme-antracite #btn-new-note:hover,
html.theme-antracite .mobile-action-btn:hover {
  filter: brightness(1.08) !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45) !important;
}
html.theme-antracite #btn-open-importer {
  background: #282c32 !important;
  border-color: #363b44 !important;
  color: #c4cad4 !important;
}
html.theme-antracite #btn-open-importer:hover {
  background: #32373f !important;
  border-color: #4b525e !important;
  color: #ffffff !important;
}


/* ==========================================================================
   Read Mode (Compaction Layout)
   ========================================================================== */
body.read-mode-active .doc-header-bar {
  padding: 4px 16px !important;
  min-height: 38px !important;
  background: var(--bg-sidebar) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

body.read-mode-active .partition-notice {
  display: none !important;
}

body.read-mode-active .doc-scroll-viewport {
  padding: 4px 16px !important;
}

body.read-mode-active .markdown-article {
  max-width: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 2px 8px !important;
  line-height: 1.24 !important;
  font-size: 0.92rem !important;
}

body.read-mode-active .markdown-article h1 {
  font-size: 1.35rem !important;
  margin: 6px 0 2px !important;
  padding-bottom: 2px !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

body.read-mode-active .markdown-article h2 {
  font-size: 1.18rem !important;
  margin: 5px 0 2px !important;
  padding-bottom: 2px !important;
  border-bottom: 1px solid var(--border-subtle) !important;
}

body.read-mode-active .markdown-article h3 {
  font-size: 1.05rem !important;
  margin: 4px 0 2px !important;
}

body.read-mode-active .markdown-article h4,
body.read-mode-active .markdown-article h5 {
  font-size: 0.95rem !important;
  margin: 3px 0 1px !important;
}

body.read-mode-active .markdown-article p {
  margin: 2px 0 3px !important;
  line-height: 1.25 !important;
}

body.read-mode-active .markdown-article ul,
body.read-mode-active .markdown-article ol {
  margin: 2px 0 3px !important;
  padding-left: 1.2em !important;
}

body.read-mode-active .markdown-article li {
  margin: 0 0 1px !important;
  line-height: 1.22 !important;
}

body.read-mode-active .markdown-article hr {
  margin: 3px 0 !important;
  border: none !important;
  border-top: 1px solid var(--border-subtle) !important;
  opacity: 0.4 !important;
}

body.read-mode-active .markdown-article blockquote,
body.read-mode-active .markdown-article .alert-block {
  margin: 3px 0 !important;
  padding: 4px 10px !important;
  font-size: 0.88rem !important;
  line-height: 1.25 !important;
}

body.read-mode-active .markdown-article table {
  margin: 4px 0 !important;
}

body.read-mode-active .markdown-article th,
body.read-mode-active .markdown-article td {
  padding: 2px 6px !important;
  font-size: 0.85rem !important;
  line-height: 1.2 !important;
}

body.read-mode-active .markdown-article pre {
  margin: 4px 0 !important;
  padding: 6px 10px !important;
  font-size: 0.86rem !important;
  line-height: 1.2 !important;
}

/* Read Mode Density Presets */
body.read-mode-active.density-ultra .markdown-article {
  line-height: 1.18 !important;
  font-size: 0.90rem !important;
}
body.read-mode-active.density-ultra .markdown-article p {
  margin: 1px 0 2px !important;
  line-height: 1.18 !important;
}
body.read-mode-active.density-ultra .markdown-article li {
  line-height: 1.16 !important;
  margin: 0 !important;
}

body.read-mode-active.density-compact .markdown-article {
  line-height: 1.32 !important;
  font-size: 0.94rem !important;
}
body.read-mode-active.density-compact .markdown-article p {
  margin: 3px 0 4px !important;
  line-height: 1.32 !important;
}

body.read-mode-active.density-standard .markdown-article {
  line-height: 1.48 !important;
  font-size: 0.98rem !important;
}
body.read-mode-active.density-standard .markdown-article p {
  margin: 5px 0 7px !important;
  line-height: 1.48 !important;
}

/* Interactive Importer Browser & Picker Components */
.auth-card.importer-card {
  max-width: 780px !important;
  width: 92% !important;
}

.importer-browser-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.importer-browser-header {
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.importer-file-row {
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s ease;
  cursor: pointer;
}

.importer-file-row:hover {
  background: var(--bg-hover);
}

.importer-file-row.selected {
  background: rgba(56, 189, 248, 0.08);
}

.importer-file-row td {
  padding: 10px 12px;
  font-size: 0.85rem;
}

.importer-notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px;
}

.importer-note-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.importer-note-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-1px);
}

.importer-note-card.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  box-shadow: 0 0 0 1px #38bdf8;
}

.importer-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-secondary);
  color: var(--text-muted);
}

/* ==========================================================================
   Gallery Lightbox Modal
   ========================================================================== */
.gallery-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}

.gallery-lightbox-container {
  width: 95%;
  max-width: 1200px;
  height: 90vh;
  display: flex;
  flex-direction: column;
}

.gallery-lightbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  color: #fff;
}

.gallery-counter {
  font-size: 0.85rem;
  color: #888;
}

.gallery-lightbox-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.gallery-nav-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 2.5rem;
  width: 50px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  z-index: 10;
}

.gallery-nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.gallery-image-viewport {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.gallery-image-viewport img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.gallery-thumbs-strip {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0;
  overflow-x: auto;
}

.gallery-thumb {
  height: 50px;
  width: 50px;
  border-radius: 6px;
  object-fit: cover;
  opacity: 0.4;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s ease;
}

.gallery-thumb.active, .gallery-thumb:hover {
  opacity: 1;
  border-color: var(--accent-primary, #2dd4bf);
}

/* ==========================================================================
   Obsidian-Style Callouts
   ========================================================================== */
.callout-box {
  margin: 16px 0;
  padding: 14px 18px;
  border-radius: 8px;
  border-left: 4px solid #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

.callout-box.callout-tip {
  border-left-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.callout-box.callout-warning {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
}

.callout-box.callout-caution {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.callout-content {
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ==========================================================================
   Split Layout & Local Knowledge Graph (Obsidian-Style Side Pane)
   ========================================================================== */
.doc-split-layout {
  display: flex;
  flex: 1;
  width: 100%;
  min-height: 100%;
  gap: 16px;
  position: relative;
}

.doc-main-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.doc-mobile-bottom-spacer {
  display: none;
  width: 100%;
  height: 0;
  pointer-events: none;
}

.doc-side-pane {
  width: 380px;
  min-width: 320px;
  max-width: 460px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  height: fit-content;
  max-height: calc(100vh - 140px);
  position: sticky;
  top: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 10;
  overflow: hidden;
}

.side-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-card-hover);
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.side-pane-content {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.local-graph-canvas {
  width: 100%;
  height: 280px;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  display: block;
}

.local-graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 4px 0;
}

.local-graph-node-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-input);
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.15s ease;
}

.local-graph-node-link:hover {
  background: var(--border-subtle);
}

/* ==========================================================================
   Plugin Settings & Configuration Panels
   ========================================================================== */
.p-settings-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px 0;
}

.p-setting-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.p-setting-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.p-setting-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.p-setting-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.p-setting-field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==========================================================================
   Importer Live Reader Mode Preview Box
   ========================================================================== */
.importer-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.importer-meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.importer-preview-box {
  margin-top: 10px;
  padding: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.86rem;
  line-height: 1.6;
}

/* ==========================================================================
   Settings & User Management Hub Styles
   ========================================================================== */
.settings-nav-tabs {
  display: flex;
  gap: 8px;
}

.settings-tab-btn {
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.settings-tab-btn.active {
  background: rgba(6, 182, 212, 0.12);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  font-weight: 600;
}

.settings-section-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  max-width: 960px;
  width: 100%;
  box-sizing: border-box;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.settings-card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.015);
  box-sizing: border-box;
}

.settings-icon {
  font-size: 1.5rem;
}

.settings-card-header h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.settings-card-header p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  word-break: break-word;
}

.settings-card-body {
  padding: 20px;
  box-sizing: border-box;
  max-width: 100%;
}

#active-daemon-url-display,
#tailscale-magicdns-display,
#tailscale-https-display,
#tailscale-ip-display,
#tailnet-name-display,
#cloud-account-email-display,
.settings-card-body code,
.settings-card-body pre {
  word-break: break-all;
  overflow-wrap: anywhere;
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-control input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  background-color: var(--border-subtle);
  border-radius: 24px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.toggle-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: all 0.2s ease;
}

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

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

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

.settings-action-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.settings-toast {
  color: #10b981;
  font-size: 0.86rem;
  font-weight: 500;
}

/* User management table */
.users-table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.users-table-wrapper th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-weight: 600;
}

.users-table-wrapper td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.users-table-wrapper tr:last-child td {
  border-bottom: none;
}

.user-badge-encrypted {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 12px;
  color: #10b981;
  font-size: 0.76rem;
  font-weight: 600;
}

.badge-2fa-enabled {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 12px;
  color: #10b981;
  font-size: 0.74rem;
  font-weight: 600;
}

.badge-2fa-disabled {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
  border-radius: 12px;
  color: var(--text-muted, #94a3b8);
  font-size: 0.74rem;
  font-weight: 500;
}

/* Graph mode selector */
.graph-header-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
}

.graph-mode-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 3px;
  gap: 4px;
}

.graph-mode-toggle .btn {
  padding: 4px 12px;
  font-size: 0.78rem;
  border-radius: 4px;
}

.graph-mode-toggle .btn.active {
  background: var(--accent-cyan);
  color: #000000;
  font-weight: 600;
}

/* Version History Modal */
/* Version History & Side-by-Side Diff Modal */
.version-history-card {
  padding: 20px 24px;
  max-width: 1240px !important;
  width: 96% !important;
  height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.versions-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
  flex-shrink: 0;
  min-width: 0;
}

.versions-header-title-box {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.versions-modal-heading,
.version-history-card h3 {
  font-size: clamp(0.92rem, 3vw, 1.25rem);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0 0 2px 0;
}

.versions-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#btn-close-versions {
  flex-shrink: 0 !important;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: all 0.15s ease;
}

#btn-close-versions:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

@media (max-width: 680px) {
  #version-history-doc-title {
    display: none !important;
  }
  
  .versions-header-actions {
    gap: 6px;
  }
  
  #btn-revert-current-version .btn-text {
    display: none;
  }
  
  #btn-revert-current-version {
    padding: 5px 8px;
  }
}

.versions-modal-layout {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  flex: 1;
  overflow: hidden;
}

.versions-history-list {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 8px;
  border-right: 1px solid var(--border-subtle);
}

.versions-history-list.hidden {
  display: none !important;
}

.version-item-card {
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.version-item-card:hover {
  border-color: var(--accent-cyan);
  background: var(--bg-hover);
}

.version-item-card.active {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

.version-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.version-num-pill {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.version-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.version-stats {
  display: flex;
  gap: 8px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  margin-bottom: 4px;
}

.diff-stat-add { color: #10b981; }
.diff-stat-del { color: #ef4444; }

.version-summary {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.versions-diff-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

/* Side-by-Side Diff Panels */
.sbs-diff-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sbs-diff-headers {
  display: grid;
  grid-template-columns: 1fr 44px 1fr;
  background: #161b22;
  border-bottom: 1px solid var(--border-subtle);
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.sbs-diff-body {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
}

.sbs-diff-row {
  display: grid;
  grid-template-columns: 1fr 44px 1fr;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  min-height: 24px;
}

.sbs-pane-left, .sbs-pane-right {
  display: flex;
  align-items: flex-start;
  padding: 2px 8px;
  overflow: hidden; /* No individual line scrollbars! */
}

.sbs-line-num {
  width: 32px;
  color: var(--text-muted);
  user-select: none;
  text-align: right;
  padding-right: 8px;
  font-size: 0.72rem;
  flex-shrink: 0;
}

.sbs-line-code {
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
}

.sbs-editable-code {
  outline: none;
  cursor: text;
  border-radius: 3px;
  padding: 0 4px;
  transition: all 0.12s ease;
}

.sbs-editable-code:hover, .sbs-editable-code:focus {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 1px var(--border-bright);
}

.sbs-pane-mid {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
}

.btn-diff-copy-line {
  background: rgba(126, 127, 184, 0.15);
  border: 1px solid rgba(126, 127, 184, 0.4);
  color: var(--accent-primary);
  border-radius: 4px;
  font-size: 0.72rem;
  padding: 0 5px;
  cursor: pointer;
  line-height: 1.4;
  transition: all 0.12s ease;
}

.btn-diff-copy-line:hover {
  background: var(--accent-primary);
  color: #fff;
  font-weight: 700;
}

.sbs-del {
  background: var(--diff-del-bg);
  color: #e098a1;
}

.sbs-add {
  background: var(--diff-add-bg);
  color: #7ece9d;
}

.sbs-empty {
  background: rgba(0, 0, 0, 0.18);
}

/* Side-by-Side Split Editor Mode (Left Diff, Right Textarea) */
.sbs-split-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  overflow: hidden;
}

.sbs-split-left-pane {
  overflow-y: auto;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
}

.sbs-diff-row-split {
  display: grid;
  grid-template-columns: 1fr 34px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  min-height: 24px;
}

.sbs-split-right-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-deep);
}

.sbs-split-textarea {
  flex: 1;
  width: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  border: none;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  resize: none;
  outline: none;
}

/* Right Pane Full Raw Editor Mode */
.sbs-editor-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sbs-editor-textarea {
  flex: 1;
  width: 100%;
  background: var(--bg-deep);
  color: var(--text-primary);
  border: none;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  resize: none;
  outline: none;
}

/* Mobile & Tablet Layout (Clean Unified Diff without duplicate lines) */
@media (max-width: 900px) {
  .version-history-card {
    height: 96vh !important;
    padding: 12px !important;
  }
  
  .versions-modal-layout {
    flex-direction: column;
    gap: 10px;
  }

  .versions-history-list {
    width: 100%;
    max-height: 100px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 4px;
    gap: 4px;
  }

  .version-item-card {
    padding: 4px 8px !important;
  }

  .sbs-diff-headers {
    padding: 6px 10px;
  }

  .sbs-mobile-unified-body {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.5;
  }

  .sbs-u-line {
    display: flex;
    align-items: flex-start;
    padding: 3px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    min-height: 22px;
  }

  .sbs-u-num {
    width: 34px;
    font-size: 0.7rem;
    color: var(--text-muted);
    user-select: none;
    flex-shrink: 0;
    padding-right: 6px;
    text-align: right;
  }

  .sbs-u-code {
    flex: 1;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .sbs-u-del {
    background: var(--diff-del-bg);
    color: #e098a1;
  }

  .sbs-u-add {
    background: var(--diff-add-bg);
    color: #7ece9d;
  }

  .sbs-u-same {
    color: var(--text-secondary);
  }
}

.diff-line {
  white-space: pre-wrap;
  word-break: break-all;
  padding: 1px 6px;
}

.diff-line-added {
  background: rgba(46, 160, 67, 0.2);
  color: #56d364;
}

.diff-line-deleted {
  background: rgba(248, 81, 73, 0.2);
  color: #ff7b72;
}

.diff-line-context {
  color: #c9d1d9;
}

.empty-diff-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.86rem;
  text-align: center;
  padding: 20px;
}



/* ==========================================================================
   Sidebar Navigation & Tools Dropdown Menu
   ========================================================================== */
.sidebar-nav-container {
  padding: 4px 12px 8px;
}

.nav-pills-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nav-pills-row > .nav-pill {
  flex: 1;
}

.tools-dropdown-wrapper {
  position: relative;
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 3px;
}

.btn-tools-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-tools-toggle:hover, .btn-tools-toggle.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

.tools-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 210px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 6px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tools-dropdown-menu .dropdown-item {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tools-dropdown-menu .dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tools-dropdown-menu .dropdown-item.active {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
}

/* ==========================================================================
   Compact Partition Cards (Pills)
   ========================================================================== */
.partition-cards.compact-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.compact-card {
  display: flex !important;
  align-items: center;
  gap: 6px;
  padding: 6px 8px !important;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.15s ease;
}

.compact-card .p-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-card .p-count {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ==========================================================================
   Sidebar Active Tag Filter Banner
   ========================================================================== */
.active-tag-filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  margin-bottom: 8px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 6px;
  font-size: 0.76rem;
  color: #93c5fd;
}

.btn-tag-clear {
  background: transparent;
  border: none;
  color: #93c5fd;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 4px;
  border-radius: 4px;
}

.btn-tag-clear:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ==========================================================================
   Document Header Bar: Clean 3-Row Layout
   ========================================================================== */
.doc-header-bar {
  padding: 14px 28px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  background: linear-gradient(180deg, var(--bg-sidebar) 0%, transparent 100%);
  border-bottom: 1px solid var(--border-subtle);
}

.doc-header-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.doc-header-back-col {
  display: flex;
  align-items: center;
}

#btn-desktop-back {
  display: none !important; /* Duplicate back button permanently hidden */
}

/* ==========================================================================
   Document Action Toolbar: Strict Core Geometry & Theme Control
   ========================================================================== */
.doc-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.plugin-doc-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Strict uniform geometry for direct toolbar buttons (core + direct plugins + overflow trigger) */
.doc-toolbar-actions > button,
.doc-toolbar-actions > .btn,
.plugin-doc-toolbar > button,
.plugin-doc-toolbar > .btn,
.doc-toolbar-overflow-container > button,
.editor-toolbar-overflow-container > button,
.btn-icon-only:not(.toolbar-overflow-item) {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  width: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  padding: 0 !important;
  border-radius: 6px !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
  font-size: 0.95rem !important;
  cursor: pointer !important;
  border: 1px solid var(--border-subtle) !important;
  background: var(--bg-card) !important;
  color: var(--text-secondary) !important;
  transition: all 0.15s ease !important;
  user-select: none !important;
  flex-shrink: 0 !important;
  overflow: hidden !important;
}

.doc-toolbar-actions > button:hover,
.doc-toolbar-actions > .btn:hover,
.plugin-doc-toolbar > button:hover,
.plugin-doc-toolbar > .btn:hover,
.doc-toolbar-overflow-container > button:hover,
.editor-toolbar-overflow-container > button:hover,
.btn-icon-only:not(.toolbar-overflow-item):hover {
  background: var(--bg-hover) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent-cyan) !important;
}

.doc-toolbar-actions > button.active,
.doc-toolbar-actions > .btn.active,
.plugin-doc-toolbar > button.active,
.plugin-doc-toolbar > .btn.active,
.doc-toolbar-overflow-container > button.active,
.editor-toolbar-overflow-container > button.active,
.btn-icon-only:not(.toolbar-overflow-item).active {
  background: rgba(6, 182, 212, 0.15) !important;
  color: var(--accent-cyan) !important;
  border-color: var(--accent-cyan) !important;
}

.doc-toolbar-actions > button .btn-icon,
.plugin-doc-toolbar > button .btn-icon,
.doc-toolbar-overflow-container > button .btn-icon,
.editor-toolbar-overflow-container > button .btn-icon,
.btn-icon-only:not(.toolbar-overflow-item) .btn-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1rem !important;
  line-height: 1 !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Floating Action Button (FAB) for Mobile Document Actions */
.floating-doc-actions-fab {
  display: none;
}

/* ==========================================================================
   Responsive Toolbar Overflow Dropdowns (Doc View & Editor View)
   ========================================================================== */
.doc-toolbar-overflow-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.doc-toolbar-overflow-menu,
.editor-toolbar-overflow-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 6px;
  min-width: 220px;
  max-width: 300px;
  width: max-content;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  gap: 3px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-sizing: border-box;
}

.doc-toolbar-overflow-menu button.toolbar-overflow-item,
.editor-toolbar-overflow-menu button.toolbar-overflow-item,
.toolbar-overflow-item {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  padding: 0 12px !important;
  margin: 0 !important;
  font-size: 0.84rem !important;
  font-weight: 500 !important;
  color: var(--text-primary) !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  text-align: left !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  box-sizing: border-box !important;
  user-select: none !important;
  box-shadow: none !important;
  line-height: normal !important;
  transition: background 0.12s ease, color 0.12s ease !important;
}

.doc-toolbar-overflow-menu button.toolbar-overflow-item:hover,
.editor-toolbar-overflow-menu button.toolbar-overflow-item:hover,
.toolbar-overflow-item:hover {
  background: var(--bg-hover) !important;
  color: var(--accent-cyan) !important;
}

.toolbar-overflow-item .toolbar-item-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 18px !important;
  min-width: 18px !important;
  max-width: 18px !important;
  height: 18px !important;
  flex-shrink: 0 !important;
  font-size: 1rem !important;
  line-height: 1 !important;
  color: var(--accent-cyan) !important;
}

.toolbar-overflow-item .toolbar-item-icon svg {
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor !important;
  display: block !important;
}

.toolbar-overflow-item .toolbar-item-icon .sphene-icon,
.toolbar-overflow-item .toolbar-item-icon .btn-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1rem !important;
  line-height: 1 !important;
}

.toolbar-overflow-item .toolbar-item-label {
  flex: 1 1 auto !important;
  text-align: left !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  color: inherit !important;
  font-size: 0.84rem !important;
  font-weight: 500 !important;
}


@media (max-width: 1024px) {
  #btn-desktop-back {
    display: none !important;
  }

  .doc-toolbar-actions {
    display: none !important;
  }

  .doc-split-layout {
    flex-direction: column !important;
  }

  /* Knowledge Graph on Mobile: Docked to bottom of screen (never covers article) */
  .doc-side-pane {
    position: fixed !important;
    bottom: 0 !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    height: 380px !important;
    max-height: 48vh !important;
    border-radius: 16px 16px 0 0 !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    border-top: 1px solid var(--border-bright) !important;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5) !important;
    z-index: 80 !important;
    margin: 0 !important;
    background: var(--bg-card) !important;
  }

  .side-pane-header {
    border-radius: 16px 16px 0 0 !important;
    padding: 10px 16px !important;
  }

  .side-pane-content {
    padding: 8px 14px 20px 14px !important;
  }

  .local-graph-canvas {
    height: 220px !important;
  }

  body.side-pane-open .doc-scroll-viewport {
    padding-bottom: 390px !important;
  }

  /* Mobile Bottom Action Bar & Document Quick Action Buttons (<1024px) */
  .mobile-doc-action-bar {
    display: none; /* Controlled dynamically via JS when viewing document */
    position: fixed;
    bottom: 20px;
    right: 16px;
    align-items: center;
    gap: 8px;
    z-index: 100 !important; /* Stays strictly on top of document & bottom knowledge graph */
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 5px 8px;
    border-radius: 32px;
    border: 1px solid var(--border-bright, rgba(255, 255, 255, 0.15));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.2);
  }

  .mobile-doc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card, #1e293b);
    color: var(--text-primary, #f1f5f9);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    font-size: 1.15rem;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    margin: 0;
  }

  .mobile-doc-btn .sphene-icon {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-doc-btn:hover,
  .mobile-doc-btn:focus {
    transform: scale(1.08);
    border-color: var(--accent-primary, #7e7fb8);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  }

  .mobile-doc-btn:active {
    transform: scale(0.92);
  }

  /* Dedicated Edit Button: Vibrant Accent */
  .mobile-doc-btn.btn-mobile-edit {
    background: var(--accent-primary, #7e7fb8);
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 16px rgba(126, 127, 184, 0.45);
  }

  .mobile-doc-btn.btn-mobile-edit:hover,
  .mobile-doc-btn.btn-mobile-edit:focus {
    background: var(--accent-cyan, #06b6d4);
    color: #000000;
    border-color: #ffffff;
    box-shadow: 0 6px 22px rgba(6, 182, 212, 0.6);
  }

  /* Outline Popup on Mobile: Sits directly ABOVE the action buttons (never covers them) */
  .floating-doc-toc {
    bottom: 84px !important;
    right: 16px !important;
    left: auto !important;
    width: 320px !important;
    max-width: calc(100vw - 32px) !important;
    max-height: calc(100vh - 180px) !important;
    z-index: 95 !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7), 0 0 1px rgba(255, 255, 255, 0.2) !important;
  }

  /* Floating Bottom Left Back Button (<1024px) */
  .floating-mobile-back-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text-primary, #f1f5f9);
    border: 1px solid var(--border-bright, rgba(255, 255, 255, 0.15));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.2);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 100 !important;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .floating-mobile-back-btn:hover,
  .floating-mobile-back-btn:focus {
    transform: scale(1.08);
    border-color: var(--accent-primary, #7e7fb8);
    color: #ffffff;
  }

  .floating-mobile-back-btn:active {
    transform: scale(0.92);
  }

  .floating-mobile-cancel-btn {
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #fca5a5 !important;
  }

  .floating-mobile-cancel-btn:hover {
    background: rgba(239, 68, 68, 0.25) !important;
    color: #ffffff !important;
  }

  /* Mobile Floating Edit Action Bar (<1024px) */
  .mobile-edit-action-bar {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 16px;
    align-items: center;
    gap: 8px;
    z-index: 100 !important;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 5px 8px;
    border-radius: 32px;
    border: 1px solid var(--border-bright, rgba(255, 255, 255, 0.15));
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  }

  .btn-mobile-save-fab {
    background: var(--accent-primary, #6366f1) !important;
    border: 1.5px solid rgba(255, 255, 255, 0.35) !important;
    color: #ffffff !important;
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.45) !important;
  }

  .btn-mobile-save-fab:hover {
    background: #4f46e5 !important;
  }

  /* Mobile Content Padding so Floating Action Buttons Never Obscure Document:
     Provides generous clearance (~180px - 220px, equivalent to 4-5 cm) below the last line
     so the user can scroll past the bottom line and view it comfortably above the floating action buttons */
  .doc-mobile-bottom-spacer {
    display: block !important;
    height: 180px !important;
    min-height: 180px !important;
    width: 100% !important;
    flex-shrink: 0 !important;
  }

  .doc-scroll-viewport {
    padding-bottom: 220px !important;
  }

  .markdown-article,
  #doc-view-article {
    padding-bottom: 60px !important;
    margin-bottom: 40px !important;
  }

  .concept-links-card,
  #doc-concept-links-card {
    margin-bottom: 60px !important;
  }

  .editor-pane,
  #editor-container,
  #live-preview-surface,
  .live-preview-surface {
    padding-bottom: 200px !important;
  }

  #editor-textarea-wrapper,
  #editor-textarea {
    padding-bottom: 160px !important;
    margin-bottom: 60px !important;
  }

  /* Hide desktop top editor actions on mobile */
  .editor-bar .editor-actions {
    display: none !important;
  }
  .editor-filename-wrapper,
  .editor-filename-input-box {
    width: 100% !important;
  }
}

/* 3D Knowledge Graph: Capture Touch Events & Pinch-to-Zoom */
#graph-canvas {
  touch-action: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

.graph-canvas-wrapper {
  touch-action: none !important;
  overscroll-behavior: none !important;
  overflow: hidden !important;
}

/* Standalone App Mode & Mobile Minimalist Clutter Reduction */
body.is-standalone-app .welcome-subtitle,
body.is-standalone-app .welcome-telemetry-pills,
body.is-standalone-app .btn-pwa-install,
body.is-standalone-app #btn-tools-install-pwa,
body.is-standalone-app #btn-install-pwa-header,
body.is-standalone-app .pwa-first-time-popup,
body.is-standalone-app #pwa-first-time-popup,
body.is-standalone-app .panel-subtext {
  display: none !important;
}

@media (max-width: 768px) {
  .welcome-subtitle,
  .welcome-telemetry-pills,
  .panel-subtext {
    display: none !important;
  }
}

.doc-header-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.path-crumb {
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  min-width: 0;
}

.doc-header-tags-row {
  display: flex;
  align-items: center;
}

.tag-chip {
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.tag-chip:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: #60a5fa;
  transform: translateY(-1px);
}

/* ==========================================================================
   Sovereign Decrypt Standalone Callout
   ========================================================================== */
.sovereign-decrypt-callout {
  background: rgba(168, 85, 247, 0.08);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.callout-humor {
  font-size: 0.82rem;
  color: #e9d5ff;
  line-height: 1.5;
  margin-bottom: 10px;
}

.code-snippet-box {
  background: #0d1117;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #38bdf8;
  overflow-x: auto;
  line-height: 1.45;
}

/* ==========================================================================
   Outline TOC Floating Widget
   ========================================================================== */
.floating-doc-toc {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 320px;
  max-height: 480px;
  background: var(--bg-card, rgba(15, 23, 42, 0.95));
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.floating-toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  flex-shrink: 0;
}

.floating-toc-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.floating-toc-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
}

.floating-toc-close:hover {
  color: var(--text-primary);
}

.floating-toc-body {
  padding: 8px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-height: 0;
}

.floating-toc-item {
  display: block;
  flex-shrink: 0; /* Never allow flexbox to compress item height into half-lines */
  min-height: 28px;
  line-height: 1.45;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-decoration: none;
  padding: 5px 8px;
  border-radius: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

.floating-toc-item:hover {
  background: var(--bg-hover);
  color: var(--accent-cyan);
}

.floating-toc-item.h1 {
  font-weight: 600;
  color: var(--text-primary);
  padding-left: 8px;
}

.floating-toc-item.h2 {
  padding-left: 18px;
  font-size: 0.78rem;
}

.floating-toc-item.h3 {
  padding-left: 28px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   3D Knowledge Graph Interactive Tooltip
   ========================================================================== */
.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent-cyan);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 100;
  max-width: 260px;
  line-height: 1.4;
  backdrop-filter: blur(8px);
}

/* ==========================================================================
   Fluid Responsive Typography: Scaled Titles Across The App
   ========================================================================== */
.welcome-title {
  font-size: clamp(1.2rem, 4vw, 1.85rem) !important;
}

.panel-header h2 {
  font-size: clamp(1.05rem, 3vw, 1.45rem) !important;
}

.auth-card h2 {
  font-size: clamp(1.1rem, 3vw, 1.45rem) !important;
}

.auth-card h3 {
  font-size: clamp(0.95rem, 2.5vw, 1.25rem) !important;
}

.markdown-article h1 {
  font-size: clamp(1.3rem, 4vw, 1.85rem) !important;
}

.markdown-article h2 {
  font-size: clamp(1.1rem, 3vw, 1.4rem) !important;
}

.markdown-article h3 {
  font-size: clamp(0.95rem, 2.5vw, 1.18rem) !important;
}

/* ==========================================================================
   Sphene Unified SVG Icon System
   ========================================================================== */
.sphene-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
}

.sphene-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

/* Material theme icons: uses fill="currentColor" */
html.theme-material .sphene-icon svg {
  fill: currentColor;
}

/* Cyber velvet rock: emoji sizing */
html.theme-cyber-velvet-rock .sphene-icon {
  font-size: 1rem;
  line-height: 1;
}

/* Minimalist Dark / Kindle OLED: warm amber accents for icons */
html.theme-minimalist-dark .sphene-icon svg {
  stroke: var(--accent-amber, #d97706);
}

/* Minimalist White / Swiss Editorial: sharp dark slate lines */
html.theme-minimalist-white .sphene-icon svg {
  stroke: #0f172a;
}

/* Antracite: pure white crisp line symbols */
html.theme-antracite .sphene-icon svg {
  stroke: #ffffff;
}

html.theme-antracite .sphene-icon svg[fill="currentColor"] {
  fill: #ffffff;
}

/* ==========================================================================
   STRICT THEME SANDBOX CONSTRAINTS
   Themes can customize:
   - Colors, accents, backgrounds, border colors, shadows, glassmorphism, fonts
   Themes CANNOT ALTER:
   - Sizing, alignment, layout, positions of buttons, forms, lists, menus,
     dropdowns, sticky menus, diff views, floating action buttons.
   ========================================================================== */
html[class*="theme-"] .doc-toolbar-actions > button,
html[class*="theme-"] .plugin-doc-toolbar > button,
html[class*="theme-"] .doc-toolbar-overflow-container > button,
html[class*="theme-"] .editor-toolbar-overflow-container > button,
html[class*="theme-"] .btn-icon-only:not(.toolbar-overflow-item) {
  width: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

html[class*="theme-"] .mobile-sheet-actions {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  width: 100% !important;
}

html[class*="theme-"] .mobile-sheet-actions .btn {
  width: 100% !important;
  min-height: 44px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  box-sizing: border-box !important;
  text-align: left !important;
}

html[class*="theme-"] .tools-dropdown-menu {
  position: absolute !important;
  z-index: 120 !important;
}

html[class*="theme-"] .mobile-doc-btn {
  width: 44px !important;
  height: 44px !important;
  border-radius: 50% !important;
}

html[class*="theme-antracite"] .mobile-doc-action-bar {
  background: rgba(27, 29, 33, 0.92) !important;
  border-color: #3e4249 !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8) !important;
}

html[class*="theme-antracite"] .mobile-doc-btn {
  background: #212429 !important;
  color: #ffffff !important;
  border-color: #3e4249 !important;
}

html[class*="theme-antracite"] .mobile-doc-btn.btn-mobile-edit {
  background: #282c32 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

html[class*="theme-"] .diff-pane {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
}

/* -------------------------------------------------------------
   Drawing Studio Mode (Interactive Canvas & Diagram Studio)
   ------------------------------------------------------------- */
body.drawing-studio-active {
  overflow: hidden !important;
  touch-action: none !important;
  overscroll-behavior: none !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
  height: 100dvh !important;
}

body.drawing-studio-active .main-content,
body.drawing-studio-active .doc-active-container {
  overflow: hidden !important;
  height: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.drawing-studio-active #doc-header-bar,
body.drawing-studio-active #app-sidebar,
body.drawing-studio-active .sidebar,
body.drawing-studio-active .sidebar-backdrop,
body.drawing-studio-active .mobile-doc-action-bar,
body.drawing-studio-active .mobile-edit-action-bar,
body.drawing-studio-active .btn-floating-mobile-back,
body.drawing-studio-active .btn-floating-doc-actions,
body.drawing-studio-active #pwa-install-banner,
body.drawing-studio-active #pwa-first-time-popup,
body.drawing-studio-active #pwa-install-modal,
body.drawing-studio-active .pwa-install-banner {
  display: none !important;
}

.drawing-studio-pane {
  display: none !important;
}

body.drawing-studio-active .drawing-studio-pane {
  display: flex !important;
  flex-direction: column;
  height: calc(100vh - 140px);
  min-height: 480px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

.drawing-studio-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 15;
}

.drawing-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.btn-drawing-back {
  flex-shrink: 0;
}

.drawing-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.drawing-studio-workspace {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-primary);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  min-height: 0;
}

.drawing-tool-palette {
  width: 58px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  gap: 6px;
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
  flex-shrink: 0;
}

.tool-section-label {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 4px;
  margin-bottom: 2px;
  font-weight: 700;
  text-align: center;
}

.tool-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.tool-btn.active {
  background: rgba(245, 158, 11, 0.18);
  border-color: #f59e0b;
  color: #fbbf24;
}

.tool-divider {
  width: 32px;
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 0;
}

.color-palette-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
}

.drawing-canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-size: 20px 20px;
  background-image: radial-gradient(var(--border-subtle) 1px, transparent 1px);
  cursor: crosshair;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
  overscroll-behavior: none !important;
  min-height: 0;
  width: 100%;
  height: 100%;
}

.drawing-canvas-container canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
}

/* Floating Zoom & Pan HUD */
.drawing-zoom-hud {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 3px 8px;
  z-index: 25;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-select: none;
}

.drawing-zoom-hud .zoom-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
}

.drawing-zoom-hud .zoom-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.drawing-zoom-hud .zoom-level-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.drawing-zoom-hud .zoom-level-text:hover {
  background: rgba(255, 255, 255, 0.08);
}

.drawing-zoom-hud .zoom-btn-reset {
  font-size: 12px;
  color: var(--accent-primary, #00f0ff);
  margin-left: 2px;
}

.drawing-text-editor-input {
  position: absolute;
  background: var(--bg-card);
  border: 1.5px solid #f59e0b;
  color: var(--text-primary);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.88rem;
  font-family: inherit;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  outline: none;
}

/* Responsive adjustments for Drawing Studio on Mobile Screens */
@media (max-width: 768px) {
  body.drawing-studio-active .app-header {
    display: none !important;
  }

  body.drawing-studio-active .drawing-studio-pane {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100dvh !important;
    height: 100vh !important;
    min-height: 0 !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 1000 !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--bg-primary) !important;
  }

  .drawing-studio-bar {
    padding: 6px 10px !important;
    height: 46px !important;
    min-height: 46px !important;
    gap: 6px !important;
    background: var(--bg-card) !important;
  }

  .drawing-title-group {
    gap: 6px !important;
    flex: 1;
    min-width: 0;
  }

  .drawing-title-group input {
    font-size: 0.82rem !important;
    padding: 4px 6px !important;
    height: 30px !important;
  }

  .drawing-actions {
    gap: 4px !important;
    flex-shrink: 0;
  }

  .drawing-actions .btn-drawing-cancel {
    display: none !important;
  }

  .drawing-actions .btn {
    padding: 4px 8px !important;
    font-size: 0.78rem !important;
    height: 30px !important;
  }

  .drawing-actions #btn-drawing-view-code .btn-label-text {
    display: none !important;
  }

  .drawing-studio-workspace {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column-reverse !important;
    min-height: 0 !important;
    overflow: hidden !important;
    touch-action: none !important;
    position: relative !important;
  }

  .drawing-tool-palette {
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    flex-direction: row !important;
    border-right: none !important;
    border-top: 1px solid var(--border-subtle) !important;
    padding: 2px 6px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    justify-content: flex-start !important;
    gap: 4px !important;
    flex-shrink: 0 !important;
    z-index: 30 !important;
    background: var(--bg-secondary) !important;
  }

  .drawing-tool-palette .tool-btn {
    width: 34px !important;
    height: 34px !important;
    flex-shrink: 0 !important;
  }

  .drawing-tool-palette .color-swatch {
    width: 18px !important;
    height: 18px !important;
  }

  .tool-divider, .tool-section-label {
    display: none !important;
  }

  .color-palette-picker {
    flex-direction: row !important;
    gap: 4px !important;
    margin: 0 4px !important;
  }

  .drawing-canvas-container {
    flex: 1 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    touch-action: none !important;
    position: relative !important;
  }

  .drawing-canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    touch-action: none !important;
  }

  .drawing-zoom-hud {
    bottom: 8px !important;
    right: 8px !important;
    padding: 2px 6px !important;
  }

  .drawing-zoom-hud .zoom-btn {
    width: 22px !important;
    height: 22px !important;
    font-size: 13px !important;
  }

  .drawing-zoom-hud .zoom-level-text {
    font-size: 10px !important;
    min-width: 32px !important;
  }
}

/* ========================================================================== */
/* PWA Standalone App & Installation Styles                                  */
/* ========================================================================== */
.btn-pwa-install {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  margin-top: 8px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.25);
  border-radius: 6px;
  color: var(--accent-cyan, #00f0ff);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-pwa-install:hover {
  background: rgba(0, 240, 255, 0.16);
  border-color: var(--accent-cyan, #00f0ff);
  transform: translateY(-1px);
}

.pwa-direct-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.28);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 16px;
}

.pwa-os-nav {
  display: flex;
  gap: 6px;
  background: var(--bg-card, #121620);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  margin-bottom: 16px;
  overflow-x: auto;
}

.pwa-tab-btn {
  flex: 1;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted, #94a3b8);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.pwa-tab-btn.active {
  background: var(--bg-hover, #1e2433);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pwa-step-card {
  display: flex;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg-card, #121620);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  margin-bottom: 10px;
}

.pwa-step-card p {
  margin: 4px 0 0 0;
  font-size: 0.85rem;
  color: var(--text-muted, #94a3b8);
  line-height: 1.4;
}

.pwa-step-card strong {
  font-size: 0.9rem;
  color: var(--text-main, #f8fafc);
}

.pwa-step-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan, #00f0ff);
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.pwa-step-card kbd {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.8rem;
  font-family: inherit;
}

/* PWA Modal Responsive Scroller & Direct Workflow Cards */
.pwa-modal-overlay {
  overflow-y: auto !important;
  padding: 16px 10px !important;
  box-sizing: border-box !important;
  align-items: center !important;
}

.pwa-modal-card {
  max-height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

.pwa-modal-body {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  max-height: calc(90vh - 130px) !important;
  padding-right: 6px;
}

.pwa-workflow-step {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface, #161b22);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 10px;
  margin-bottom: 12px;
}

.pwa-workflow-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan, #38bdf8);
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pwa-workflow-content {
  flex: 1;
  min-width: 0;
}

.pwa-workflow-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--text-main, #f8fafc);
}

.pwa-workflow-sub {
  margin: 3px 0 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.4;
}

/* Micro-AI Intelligence Suite: Smart Compose, Entities, & Concept Links */
.smart-compose-ghost {
  color: var(--text-muted, #71717a);
  opacity: 0.6;
  font-style: italic;
  pointer-events: none;
  display: inline-block;
  margin-left: 2px;
}

.smart-compose-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(126, 127, 184, 0.15);
  border: 1px solid rgba(126, 127, 184, 0.3);
  color: var(--accent-primary, #7e7fb8);
  border-radius: 4px;
  font-size: 0.72rem;
  padding: 1px 6px;
  cursor: pointer;
  margin-left: 6px;
}

.smart-compose-pill kbd {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  padding: 0 4px;
  font-size: 0.68rem;
}

.entity-ghost-link {
  border-bottom: 1.5px dashed var(--accent-cyan, #38bdf8);
  color: inherit;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.entity-ghost-link:hover {
  background: rgba(56, 189, 248, 0.15);
  border-radius: 3px;
}

.entity-ghost-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-cyan, #38bdf8);
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 10px;
  cursor: pointer;
  margin-left: 4px;
}

.concept-links-card {
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.concept-links-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  min-width: 0;
  max-width: 100%;
}

.concept-links-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(14, 165, 233, 0.15);
  color: var(--accent-cyan);
  flex-shrink: 0;
  white-space: nowrap;
}

.concept-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 10px;
  max-width: 100%;
  box-sizing: border-box;
}

.concept-link-item {
  background: var(--bg-surface, #161b22);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.concept-link-item:hover {
  background: var(--bg-hover, #1f242c);
  border-color: var(--accent-cyan, #38bdf8);
  transform: translateY(-1px);
}

.concept-link-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.concept-link-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

.concept-link-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  width: 100%;
  display: block;
  box-sizing: border-box;
}

.concept-link-snippet {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* First-Time PWA App Install Suggestion Popup */
.pwa-first-time-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 360px;
  max-width: calc(100vw - 48px);
  background: var(--bg-card, #161b22);
  border: 1px solid var(--accent-cyan, #38bdf8);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 16px rgba(56, 189, 248, 0.15);
  padding: 16px;
  z-index: 950 !important;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: pwaPopupSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  backdrop-filter: blur(12px);
  box-sizing: border-box;
}

@keyframes pwaPopupSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.pwa-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pwa-popup-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pwa-popup-logo {
  border-radius: 7px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
}

.pwa-popup-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pwa-popup-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary, #f0f6fc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-popup-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted, #8b949e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pwa-popup-close {
  background: none;
  border: none;
  color: var(--text-muted, #8b949e);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.pwa-popup-close:hover {
  color: var(--text-primary, #f0f6fc);
  background: var(--bg-hover, rgba(255, 255, 255, 0.08));
}

.pwa-popup-body {
  font-size: 0.8rem;
  color: var(--text-secondary, #c9d1d9);
  line-height: 1.45;
}

.pwa-popup-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pwa-popup-actions .btn-sm {
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
}

/* ==========================================================================
   Floating Markdown Semantics Cheat Sheet
   ========================================================================== */
.markdown-cheat-sheet {
  position: sticky;
  bottom: 0;
  margin-top: 14px;
  background: var(--bg-card, rgba(15, 23, 42, 0.96));
  border: 1px solid var(--border-subtle);
  border-top: 2px solid var(--accent-primary, #7e7fb8);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.55), 0 -1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.72rem;
  transition: all 0.2s ease;
  z-index: 95;
  max-height: 250px;
  overflow-y: auto;
}

.cheat-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.cheat-sheet-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cheat-sheet-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cheat-sheet-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.cheat-sheet-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.cheat-sheet-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.cheat-sheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.cheat-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cheat-col-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.cheat-token-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cheat-token {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.70rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.cheat-token:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary, #7e7fb8);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.cheat-token code {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #93c5fd;
  background: transparent;
  padding: 0;
}

.cheat-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-left: 4px;
}

.editor-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.plugin-editor-bottom-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.plugin-editor-bottom-actions .btn,
.plugin-editor-bottom-actions button {
  height: 28px !important;
  min-height: 28px !important;
  font-size: 0.76rem !important;
  padding: 0 10px !important;
  border-radius: 12px !important;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-secondary) !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.plugin-editor-bottom-actions .btn:hover,
.plugin-editor-bottom-actions button:hover {
  border-color: var(--accent-cyan) !important;
  color: var(--accent-cyan) !important;
  background: var(--bg-hover) !important;
}

.editor-cheatsheet-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 3px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.editor-cheatsheet-pill:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ==========================================================================
   Micro-AI Assistant Upgrades: Summarizer & Conversational Q&A
   ========================================================================== */
.ai-assistant-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#ai-summary-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-secondary);
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-summary-tldr {
  background: rgba(126, 127, 184, 0.08);
  border-left: 3px solid var(--accent-primary, #7e7fb8);
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
  font-size: 0.78rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.ai-summary-bullet {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.ai-summary-bullet-dot {
  color: var(--accent-cyan, #528392);
  font-weight: bold;
  flex-shrink: 0;
}

.ai-topics-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.ai-topic-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

#ai-chat-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 250px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 2px;
  margin-bottom: 8px;
}

.ai-chat-bubble {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 92%;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  line-height: 1.5;
  animation: aiFadeIn 0.2s ease;
}

@keyframes aiFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-chat-bubble-user {
  align-self: flex-end;
  background: rgba(126, 127, 184, 0.2);
  border: 1px solid rgba(126, 127, 184, 0.35);
  color: var(--text-primary);
}

.ai-chat-bubble-assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ai-chat-citation {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--accent-cyan, #528392);
  background: rgba(6, 182, 212, 0.08);
  border-radius: 4px;
  padding: 1px 6px;
  width: fit-content;
  margin-top: 4px;
  font-family: var(--font-mono);
}

.ai-chat-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-subtle);
}

.ai-chat-citation-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--accent-primary, #00f0ff);
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-mono);
  text-align: left;
}

.ai-chat-citation-btn:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--accent-primary, #00f0ff);
  color: #fff;
  transform: translateY(-1px);
}

.ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent-emerald, #10b981);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-action-btn:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald, #10b981);
  color: #fff;
  transform: translateY(-1px);
}

@keyframes headingPulseGlow {
  0% {
    background-color: rgba(0, 240, 255, 0.35);
    box-shadow: 0 0 16px rgba(0, 240, 255, 0.5);
    border-left: 4px solid var(--accent-primary, #00f0ff);
    padding-left: 8px;
  }
  35% {
    background-color: rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 24px rgba(0, 240, 255, 0.35);
    border-left: 4px solid var(--accent-primary, #00f0ff);
    padding-left: 8px;
  }
  100% {
    background-color: transparent;
    box-shadow: none;
    border-left: 4px solid transparent;
    padding-left: 0px;
  }
}

.heading-pulse-highlight {
  animation: headingPulseGlow 2.5s ease-out forwards;
  border-radius: 4px;
  transition: padding-left 0.2s ease, border-left 0.2s ease;
}

.ai-chat-context-list {
  margin-top: 6px;
  padding-left: 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ai-suggested-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.ai-suggested-chip {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-subtle);
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-suggested-chip:hover {
  border-color: var(--accent-primary, #7e7fb8);
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ==========================================================================
   Document Deletion UI & Non-Intrusive Quick Actions
   ========================================================================== */
.btn-danger-hover:hover {
  color: var(--danger, #ef4444) !important;
  border-color: rgba(239, 68, 68, 0.45) !important;
  background: rgba(239, 68, 68, 0.12) !important;
}

.doc-item-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.doc-item-action-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.doc-item:hover .doc-item-action-delete {
  opacity: 0.65;
  pointer-events: auto;
}

.doc-item-action-delete:hover {
  opacity: 1 !important;
  color: var(--danger, #ef4444) !important;
  background: rgba(239, 68, 68, 0.15) !important;
}

.doc-item-sub span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  display: block;
}

/* ==========================================================================
   Delete Document Modal Containment & Path Truncation
   ========================================================================== */
.delete-doc-card {
  max-width: 460px;
  width: 92%;
  box-sizing: border-box;
  overflow: hidden;
  word-break: break-word;
}

.delete-doc-prompt {
  font-size: 0.88rem;
  color: var(--text-primary);
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

#delete-doc-modal-title {
  color: var(--text-primary);
  word-break: break-word;
  overflow-wrap: anywhere;
  display: inline;
}

.delete-doc-path-pill {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  min-width: 0;
}

#delete-doc-modal-path {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  min-width: 0;
  flex: 1 1 auto;
  box-sizing: border-box;
}

.delete-doc-warning {
  font-size: 0.8rem;
  color: var(--danger, #ef4444);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 6px;
  padding: 8px 12px;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.delete-doc-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* ==========================================================================
   Local-First Offline PWA & Tailscale Sync Indicators
   ========================================================================== */
.mobile-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.mobile-sync-pill.offline {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.mobile-sync-pill.syncing {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  animation: pulseSync 1.5s infinite;
}

@keyframes pulseSync {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.pwa-tailscale-promo-card {
  transition: all 0.2s ease;
}

.pwa-tailscale-promo-card:hover {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.08);
}

/* ==========================================================================
   Drafting & Edit Contextual Toolbar and Unsaved Changes Modal
   ========================================================================== */
body.editing-active .doc-toolbar-actions .btn-view-only,
body.editing-active #btn-doc-versions,
body.editing-active #btn-toggle-edit,
body.editing-active #btn-view-raw,
body.editing-active #btn-delete-doc,
body.editing-active #btn-export-pdf,
body.editing-active #btn-open-local-graph,
body.editing-active #btn-semantic-related,
body.editing-active #btn-ai-assistant,
body.editing-active #btn-toggle-read-mode {
  display: none !important;
}

.unsaved-changes-card {
  border-top: 3px solid var(--accent-amber, #f59e0b) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 24px rgba(245, 158, 11, 0.12) !important;
}

.unsaved-prompt {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.unsaved-path-pill {
  transition: all 0.2s ease;
}

/* ==========================================================================
   Sovereign Trash Bin & Safe Restore Modal Styling
   ========================================================================== */
.trash-modal-card {
  border-top: 3px solid var(--accent-primary, #00f0ff) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(0, 240, 255, 0.1) !important;
}

.btn-sidebar-trash {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-subtle) !important;
  color: var(--text-secondary) !important;
  font-size: 0.85rem !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  transition: all 0.2s ease !important;
}

.btn-sidebar-trash:hover {
  background: var(--bg-card-hover) !important;
  border-color: var(--accent-primary) !important;
  color: var(--text-primary) !important;
}

.trash-item-row {
  transition: all 0.15s ease;
}

.trash-item-row:hover {
  background: var(--bg-card-hover) !important;
  border-color: var(--border-bright) !important;
  transform: translateY(-1px);
}

.btn-restore-trash {
  background: transparent !important;
  border: 1px solid var(--accent-primary) !important;
  color: var(--accent-primary) !important;
  font-weight: 500 !important;
  padding: 4px 10px !important;
  font-size: 0.78rem !important;
  border-radius: 6px !important;
  transition: all 0.2s ease !important;
}

.btn-restore-trash:hover {
  background: rgba(0, 240, 255, 0.12) !important;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2) !important;
}

.btn-delete-trash-forever {
  background: transparent !important;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  color: var(--danger, #ef4444) !important;
  padding: 4px 8px !important;
  font-size: 0.78rem !important;
  border-radius: 6px !important;
  transition: all 0.2s ease !important;
}

.btn-delete-trash-forever:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: var(--danger, #ef4444) !important;
}

@media (max-width: 640px) {
  .trash-item-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }
  .trash-item-actions {
    width: 100% !important;
    justify-content: flex-end !important;
  }
}

/* ==========================================================================
   User Profile-Linked Theme Switcher & Appearance Controls
   ========================================================================== */
.themes-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 10px;
  margin-bottom: 16px;
}

.theme-setting-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface, #161b22);
  border: 1px solid var(--border-subtle, #30363d);
  border-radius: 10px;
  padding: 14px 16px;
  transition: all 0.2s ease;
  position: relative;
}

.theme-setting-card:hover {
  border-color: var(--border-hover, #58a6ff);
  transform: translateY(-1px);
}

.theme-setting-card.active {
  border-color: var(--accent, #58a6ff);
  background: rgba(88, 166, 255, 0.05);
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.15);
}

.theme-card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.theme-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-icon-badge {
  font-size: 1.25rem;
  line-height: 1;
}

.theme-name-text {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.theme-swatches-container {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  border: 1px solid var(--border-subtle, #30363d);
}

.theme-swatch-pill {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: inline-block;
  flex-shrink: 0;
}

.theme-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 12px;
  flex: 1 1 auto;
}

.theme-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle, #30363d);
  margin-top: auto;
}

.theme-active-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.theme-active-tag span {
  font-size: 0.7rem;
}

.uninstalled-themes-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  background: var(--bg-surface-elevated, #1c2128);
  border: 1px dashed var(--accent, #58a6ff);
  border-radius: 10px;
  margin-top: 14px;
}

.uninstalled-callout-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
  flex: 1 1 300px;
}

.uninstalled-callout-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.uninstalled-callout-info strong {
  display: block;
  font-size: 0.92rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.uninstalled-callout-info p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.plugin-card.theme-card-user-active {
  border-color: rgba(16, 185, 129, 0.5) !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.12) !important;
}

/* Desktop Auto-Collapsing Sidebar Proximity Peek (Taskbar-Style) */
@media (min-width: 1025px) {
  .app-layout {
    overflow: hidden !important;
    position: relative !important;
    width: 100vw !important;
    max-width: 100vw !important;
  }

  .sidebar {
    position: relative !important;
    transition: margin-left 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.32s ease !important;
  }

  body.desktop-autocollapse-active .sidebar {
    margin-left: -340px !important;
    transform: translateX(0) !important;
    box-shadow: none !important;
    z-index: 1000 !important;
  }

  body.desktop-autocollapse-active .sidebar.sidebar-peek-open {
    transform: translateX(340px) !important;
    box-shadow: 14px 0 45px rgba(0, 0, 0, 0.7) !important;
  }

  body.desktop-autocollapse-active .main-viewport {
    flex: 1 !important;
    min-width: 0 !important;
  }
}

/* =========================================================================
   Phase 2: Ghost Notes & On-Demand Lazy Hydration
   ========================================================================= */
.ghost-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--accent-primary, #6366f1);
  margin-left: 6px;
  opacity: 0.85;
  transition: transform 0.2s ease, opacity 0.2s ease;
  vertical-align: middle;
}

.ghost-indicator:hover {
  transform: scale(1.15);
  opacity: 1;
}

.doc-item.is-ghost .doc-item-title {
  color: var(--text-secondary, #94a3b8);
}

.ghost-streaming-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin: 12px 0;
  border-radius: 8px;
  background: var(--bg-input, rgba(99, 102, 241, 0.08));
  border: 1px dashed var(--accent-primary-dim, rgba(99, 102, 241, 0.3));
  color: var(--accent-primary, #6366f1);
  font-size: 0.85rem;
  animation: pulse 1.8s infinite ease-in-out;
}

.ghost-fetch-error-card,
.ghost-evicted-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px 24px;
  margin: 28px auto;
  max-width: 600px;
  background: var(--bg-surface, #161b22);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.25s ease-out;
}

.ghost-fetch-error-card .ghost-error-badge,
.ghost-evicted-container .ghost-evicted-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.ghost-error-badge {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger, #ef4444);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.ghost-evicted-badge {
  background: var(--accent-primary-dim, rgba(99, 102, 241, 0.15));
  color: var(--accent-primary, #6366f1);
  border: 1px solid var(--accent-primary-dim, rgba(99, 102, 241, 0.3));
}

.ghost-error-title,
.ghost-evicted-container h2 {
  font-size: 1.22rem;
  font-weight: 700;
  color: var(--text-main, #f1f5f9);
  margin: 0 0 10px 0;
}

.ghost-error-desc,
.ghost-evicted-desc {
  font-size: 0.9rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.5;
  margin: 0 0 18px 0;
}

.ghost-error-details {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-input, #0d1117);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: var(--font-mono, monospace);
  color: var(--danger, #f87171);
  margin-bottom: 20px;
  word-break: break-all;
}

.ghost-error-actions,
.ghost-evicted-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.doc-item-action-evict {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.8rem;
  border-radius: 4px;
  opacity: 0.65;
  transition: opacity 0.15s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-primary, #6366f1);
}

.doc-item-action-evict:hover {
  opacity: 1;
  transform: scale(1.18);
}

#btn-evict-doc {
  color: var(--accent-primary, #6366f1) !important;
  border-color: rgba(99, 102, 241, 0.35) !important;
}

#btn-evict-doc[style*="display: none"],
#btn-evict-doc[style*="display:none"],
#btn-evict-doc.hidden,
#btn-evict-doc[hidden] {
  display: none !important;
}

#btn-evict-doc:hover {
  background: var(--accent-primary-dim, rgba(99, 102, 241, 0.15)) !important;
  border-color: var(--accent-primary, #6366f1) !important;
  color: #a5b4fc !important;
  transform: translateY(-1px);
}

#doc-storage-pill:hover {
  filter: brightness(1.15);
}

/* Phase 3: Quick Reconnect Button */
.btn-quick-reconnect {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  font-weight: 600 !important;
}

.btn-quick-reconnect:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

/* Phase 3: iOS WebKit Offline Reassurance Notice */
.ios-offline-banner {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.18));
  border-bottom: 1px solid rgba(99, 102, 241, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 8px 16px;
  position: relative;
  z-index: 999;
  width: 100%;
  box-sizing: border-box;
}

.ios-banner-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
  font-size: 0.82rem;
  color: var(--text-primary, #f8fafc);
  line-height: 1.4;
  text-align: center;
}

.ios-banner-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.ios-banner-text {
  flex: 1;
}

.ios-banner-dismiss {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.85rem;
  border-radius: 4px;
  transition: color 0.15s ease;
  flex-shrink: 0;
}

.ios-banner-dismiss:hover {
  color: var(--text-primary, #ffffff);
}

/* Phase 3 Extension: 3-State Cloud Badges & Storage Indicators */
.cloud-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  font-size: 0.8rem;
  vertical-align: middle;
  line-height: 1;
}

.cloud-badge-contour {
  color: #818cf8;
  opacity: 0.85;
}

.cloud-badge-filled {
  color: #4ade80;
  opacity: 0.9;
}

.cloud-badge-crossed {
  color: #fbbf24;
  opacity: 0.85;
}

.badge-local-only-storage {
  background: rgba(234, 179, 8, 0.12) !important;
  color: #eab308 !important;
  border: 1px solid rgba(234, 179, 8, 0.3) !important;
}

.badge-local-only-storage:hover {
  filter: brightness(1.15);
}

/* Shared Partition Badges & Dots */
.p-dot-shared { background: #38bdf8 !important; box-shadow: 0 0 6px rgba(56, 189, 248, 0.4); }
.badge-shared { background: rgba(56, 189, 248, 0.15) !important; color: #38bdf8 !important; border: 1px solid rgba(56, 189, 248, 0.3) !important; }

/* Partition Tree Header in All View */
.doc-tree-partition-group {
  list-style: none;
  margin-bottom: 8px;
}

.partition-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  margin-bottom: 3px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.partition-tree-header:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.partition-tree-main {
  display: flex;
  align-items: center;
  gap: 6px;
}

.partition-tree-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.partition-tree-count {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.partition-tree-add-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.partition-tree-add-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.partition-tree-children {
  list-style: none;
  padding-left: 3px !important;
  border-left: 1px solid var(--border-subtle) !important;
  margin-left: 3px !important;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Drag and Drop Visual Emphasis */
.doc-item.is-dragging {
  opacity: 0.45 !important;
  transform: scale(0.98);
  box-shadow: 0 0 0 2px var(--accent-primary, #6366f1) !important;
}

.doc-folder-row.drag-over,
.partition-card.drag-over,
.partition-tree-header.drag-over {
  background: rgba(99, 102, 241, 0.2) !important;
  border-color: #6366f1 !important;
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.4) !important;
}

/* Unified Sidebar Cloud Action / Status */
.doc-item-action-cloud {
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: default;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  line-height: 1;
  border-radius: 4px;
  color: var(--text-muted);
  transition: transform 0.15s ease, color 0.15s ease, background 0.15s ease;
}

button.doc-item-action-cloud.doc-item-action-evict {
  cursor: pointer;
  color: #4ade80;
}

button.doc-item-action-cloud.doc-item-action-evict:hover {
  color: #86efac;
  background: rgba(34, 197, 94, 0.15);
  transform: scale(1.15);
}

/* Context Menu */
.sphene-context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 220px;
  max-width: 320px;
  background: var(--bg-card, #131722);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.14));
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 6px;
  backdrop-filter: blur(16px);
  animation: menuFadeIn 0.12s ease-out;
}

@keyframes menuFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.context-menu-header {
  padding: 8px 10px 6px;
}

.context-menu-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.35;
}

.context-menu-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
  font-family: var(--font-mono);
}

.context-menu-divider {
  height: 1px;
  background: var(--border-subtle, rgba(255, 255, 255, 0.08));
  margin: 4px 0;
}

.context-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: none;
  border: none;
  border-radius: 5px;
  color: var(--text-primary);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease;
}

.context-menu-item:hover {
  background: var(--accent-primary-dim, rgba(99, 102, 241, 0.15));
  color: #a5b4fc;
}

.context-menu-item.text-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.context-menu-item.disabled,
.context-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.context-menu-item.disabled:hover,
.context-menu-item:disabled:hover {
  background: none;
  color: var(--text-muted);
}

/* ========================================================================== */
/* Sovereign Install Gateway (Frosted Glass Overlay on Web Visits)            */
/* ========================================================================== */
.sphene-install-gateway {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(6, 8, 14, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
  animation: gatewayFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

@keyframes gatewayFadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
}

.gateway-card {
  position: relative;
  max-width: 540px;
  width: 100%;
  background: linear-gradient(180deg, rgba(18, 24, 38, 0.96) 0%, rgba(10, 13, 20, 0.98) 100%);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 18px;
  padding: 34px 30px;
  box-sizing: border-box;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 50px rgba(56, 189, 248, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: gatewayScaleUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes gatewayScaleUp {
  from {
    transform: scale(0.94);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.gateway-gem-wrapper {
  position: relative;
  width: 76px;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.gateway-gem-glow {
  position: absolute;
  inset: -12px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.4) 0%, rgba(168, 85, 247, 0.2) 50%, transparent 75%);
  filter: blur(14px);
  border-radius: 50%;
  pointer-events: none;
}

.gateway-gem-img {
  width: 60px;
  height: 60px;
  filter: drop-shadow(0 4px 12px rgba(56, 189, 248, 0.5));
  z-index: 1;
}

.gateway-brand {
  margin-bottom: 20px;
}

.gateway-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #f8fafc;
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.gateway-ver {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent, #38bdf8);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
}

.gateway-subtitle {
  font-size: 0.88rem;
  color: #94a3b8;
  margin: 0;
  line-height: 1.4;
}

.gateway-security-banner {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 24px;
  display: flex;
  gap: 14px;
  text-align: left;
  box-sizing: border-box;
  width: 100%;
}

.gateway-sec-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
  padding-top: 2px;
}

.gateway-sec-content {
  flex: 1;
}

.gateway-sec-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 4px;
}

.gateway-sec-desc {
  font-size: 0.8rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.gateway-sec-desc strong {
  color: #f1f5f9;
}

.gateway-install-container {
  width: 100%;
  margin-bottom: 20px;
}

.btn-gateway-primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #ffffff;
  padding: 14px 20px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.4), 0 0 20px rgba(56, 189, 248, 0.2);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.btn-gateway-primary:hover {
  background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(2, 132, 199, 0.5), 0 0 30px rgba(56, 189, 248, 0.3);
}

.btn-gateway-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.btn-gateway-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.btn-gateway-main {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.btn-gateway-sub {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 500;
}

.gateway-hint {
  font-size: 0.76rem;
  color: #64748b;
  margin-top: 10px;
}

.gateway-ios-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.gateway-ios-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.84rem;
  color: #e2e8f0;
}

.gateway-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  font-weight: 700;
  font-size: 0.74rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ios-highlight {
  color: #38bdf8;
}

.gateway-generic-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
}

.gateway-generic-tip {
  font-size: 0.82rem;
  color: #94a3b8;
  line-height: 1.5;
}

.gateway-generic-tip code {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

.gateway-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  width: 100%;
}

.btn-gateway-link {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.btn-gateway-link:hover {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.btn-gateway-link .arrow {
  transition: transform 0.15s ease;
}

.btn-gateway-link:hover .arrow {
  transform: translateX(3px);
}

.gateway-subhint {
  font-size: 0.72rem;
  color: #64748b;
}

