:root {
  --bg: #0a0b10;
  --sidebar: #0f1118;
  --surface: #151823;
  --border: #232838;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --cyan: #38bdf8;
  --success: #10b981;
  --warn: #f59e0b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); display: flex; height: 100vh; overflow: hidden; }
body.hub-mode aside { display: none; }
main, .content-scroll { position: relative; z-index: 1; }
body:not(.hub-mode) #tsparticles { display: none !important; }
.lock-screen { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 999; }
.lock-card { background: var(--sidebar); border: 1px solid var(--border); padding: 32px; border-radius: 12px; width: 360px; text-align: center; }
.lock-card h2 { margin: 0 0 8px; }
.lock-card p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }
.lock-card input { width: 100%; margin-bottom: 12px; text-align: center; font-size: 15px; padding: 10px; }
aside { width: 315px; min-width: 240px; max-width: 650px; flex-shrink: 0; position: relative; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
aside + * { flex: 1; min-width: 0; }
.sidebar-resizer { position: absolute; top: 0; right: -3px; width: 6px; height: 100%; cursor: col-resize; z-index: 50; transition: background 0.15s; }
.sidebar-resizer:hover, .sidebar-resizer.resizing { background: rgba(56, 189, 248, 0.55); }
.btn-trash-red { background: rgba(239, 68, 68, 0.14) !important; color: #f87171 !important; border: 1px solid rgba(239, 68, 68, 0.35) !important; }
.btn-trash-red:hover { background: rgba(239, 68, 68, 0.28) !important; color: #fecaca !important; }
.brand { padding: 12px 14px; font-weight: 800; font-size: 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tree-scroll { flex: 1; overflow-y: auto; padding: 12px; }
.sidebar-proj-nav { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.sidebar-proj-tools { display: flex; gap: 6px; }
.sidebar-proj-tools button { flex: 1; padding: 6px 8px; font-size: 12px; }

.subfolder-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 7px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12.5px;
  color: #93c5fd;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  margin-top: 4px;
  gap: 6px;
}
.subfolder-header:hover { background: rgba(147, 197, 253, 0.11); }
.subfolder-header.active-map { outline: 1px solid var(--accent); background: rgba(59, 130, 246, 0.16); }

.collapse-caret { display: inline-block; width: 16px; text-align: center; color: var(--muted); font-size: 11px; flex-shrink: 0; }
.collapse-caret:hover { color: #fff; }

.folder-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.subpage-item:hover .folder-actions,
.subpage-item:focus-within .folder-actions,
.subpage-item.menu-open .folder-actions,
.subfolder-header:hover .folder-actions,
.subfolder-header:focus-within .folder-actions,
.subfolder-header.menu-open .folder-actions {
  opacity: 1;
  pointer-events: auto;
}
.folder-actions button {
  padding: 2px 5px;
  font-size: 11px;
  line-height: 1.2;
  background: var(--bg);
  border-color: var(--border);
}
.folder-actions button:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.tree-context-menu {
  position: fixed;
  z-index: 10020;
  min-width: 185px;
  background: #0d1018;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tree-context-menu button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 6px 9px;
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tree-context-menu button:hover {
  background: var(--surface);
  border: none;
}
.tree-context-menu button.danger {
  color: #f87171;
  border: none;
}
.tree-context-menu button.danger:hover {
  background: rgba(248, 113, 113, 0.14);
}
.tree-context-sep {
  height: 1px;
  background: var(--border);
  margin: 3px 4px;
}

.subpage-item.multi-selected { background: rgba(56, 189, 248, 0.2); box-shadow: inset 0 0 0 1px #38bdf8; }

.selection-bar {
  display: none;
  position: fixed;
  width: 240px;
  z-index: 10015;
  flex-direction: column;
  gap: 7px;
  padding: 10px;
  background: rgba(13, 16, 24, 0.96);
  backdrop-filter: blur(8px);
  border: 1px solid #38bdf8;
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.85);
  font-size: 12.5px;
}
.selection-bar.open { display: flex; }
.selection-bar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.selection-bar-top button { padding: 2px 7px; font-size: 11px; line-height: 1.2; }
.selection-bar select { width: 100%; padding: 6px 8px; font-size: 12px; }
.selection-bar button.danger { padding: 6px 8px; font-size: 12px; }

.subpages-list { margin-left: 8px; padding-left: 6px; border-left: 1px solid var(--border); margin-top: 3px; display: flex; flex-direction: column; gap: 2px; }
.nested-subpages { margin-left: 8px; padding-left: 6px; border-left: 1px dashed var(--border); display: flex; flex-direction: column; gap: 2px; margin-top: 2px; margin-bottom: 3px; }
.subpage-item {
  position: relative;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  color: var(--text);
  user-select: none;
}
.subpage-item:hover { background: var(--surface); }
.subpage-item.active { background: rgba(59, 130, 246, 0.22); color: #fff; font-weight: 600; }
.subpage-item.is-child { font-size: 12.5px; padding: 4px 7px; color: var(--muted); }
.subpage-item.is-child.active { color: #fff; }
.order-btns button { padding: 1px 5px; font-size: 10px; opacity: 0.7; }
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 58px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--sidebar); display: flex; align-items: center; gap: 10px; }
.breadcrumb { font-size: 13px; color: var(--muted); }
.breadcrumb strong { color: var(--text); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
button, select, input, textarea { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 7px 12px; font-size: 13px; font-family: inherit; }
button { cursor: pointer; font-weight: 600; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button.danger { color: #f87171; border-color: rgba(248, 113, 113, 0.3); }
#saveBtn { position: relative; }
#saveBtn.has-changes::after {
  content: "";
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  background: #ef4444;
  border: 2px solid var(--sidebar);
  border-radius: 50%;
  box-shadow: 0 0 8px #ef4444;
}
.confetti-piece {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 9999;
  animation: confettiFly 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes confettiFly {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(0.4); opacity: 0; }
}
.content-scroll { flex: 1; overflow-y: auto; padding: 36px 48px; }
.page-sheet { max-width: 1040px; margin: 0 auto; padding-bottom: 60px; }

@page { margin: 0; }

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  aside, .topbar, .page-nav-footer, .lock-screen, .glossary-tooltip, .emoji-popover, .meta-pills { display: none !important; }

  body {
    background: var(--bg, #0b0f19) !important;
    color: var(--text, #e2e8f0) !important;
    height: auto !important;
    overflow: visible !important;
  }

  .content-scroll {
    padding: 0 !important;
    overflow: visible !important;
  }

  .sidebar,
  .topbar,
  .add-palette,
  .edit-controls,
  .toolbar,
  #editModeBtn,
  #deletePageBtn,
  #presetControls {
    display: none !important;
  }

  .page-sheet {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 16px !important;
    box-shadow: none !important;
  }
}