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

:root {
  --icon-color: #6e6e6e;
  --icon-stroke: 1.5;
  --icon-brand: #4F6EF7;
  --brand: #4F6EF7;
  --brand-dark: #3B56D4;
  --brand-light: #EEF1FB;
  --brand-tint: #DDE3F5;
  --brand-shadow: 79,110,247;
  --page-grad-from: #F8F8FB;
  --page-grad-to:   #dae1f2;
  --font-base: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --app-bg: #E8ECF7;
  --text: #111827;
  --text-muted: #6B7280;
  --text-faint: #9CA3AF;
  --border: #E5E7EB;
  --border-dark: #D1D5DB;
  --bg: #F9FAFB;
  --bg-white: #FFFFFF;
  --rail-w: 52px;
  --sidebar-w: 230px;
  --detail-w: 260px;
  --topbar-h: 48px;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --danger: #EF4444;
  --success: #22C55E;
  --warning: #F59E0B;
  font-size: 14px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; color: var(--text); background: var(--bg); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }

/* ── Auth Pages ───────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #EEF1FB 0%, #F9FAFB 100%); }
.auth-container { width: 100%; max-width: 400px; padding: 24px; }
.auth-card { background: var(--bg-white); border-radius: 14px; padding: 40px 36px; box-shadow: var(--shadow-md); }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-size: 18px; font-weight: 700; color: var(--text); }
.auth-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.auth-subtitle { color: var(--text-muted); margin-bottom: 28px; }
.auth-error { background: #FEF2F2; border: 1px solid #FCA5A5; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 18px; color: #B91C1C; font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-switch { text-align: center; margin-top: 22px; color: var(--text-muted); font-size: 13px; }
.auth-switch a { color: var(--brand); font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

/* ── Form controls ────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.form-group input, .form-control { background: #F7F8FA; border: 1px solid transparent; border-radius: 10px; padding: 11px 13px; color: var(--text); font-size: 14px; transition: background .12s, border-color .12s, box-shadow .12s; }
.form-group input::placeholder, .form-control::placeholder { color: var(--text-faint); }
.form-group input:hover, .form-control:hover { background: #F1F3F6; }
.form-group input:focus, .form-control:focus { outline: none; background: white; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,110,247,0.15); }
select.form-control { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'><path d='M3 4.5l3 3 3-3' stroke='%236e6e6e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer; }
.path-row { display: flex; align-items: center; gap: 6px; background: #F7F8FA; border-radius: 10px; padding: 4px; border: 1px solid transparent; transition: background .12s, border-color .12s, box-shadow .12s; }
.path-row:focus-within { background: white; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,110,247,0.15); }
.path-row .path-folder, .path-row .path-title { background: transparent; border: none; padding: 8px 10px; border-radius: 7px; box-shadow: none; }
.path-row .path-folder:hover, .path-row .path-title:hover { background: rgba(0,0,0,0.03); }
.path-row .path-folder:focus, .path-row .path-title:focus { background: transparent; border: none; box-shadow: none; }
.path-row .path-folder { flex: 0 1 auto; max-width: 55%; min-width: 0; color: var(--text-muted); }
.path-row .path-title { flex: 1 1 auto; min-width: 0; font-weight: 500; }
.path-row .path-sep { color: var(--text-faint); font-size: 16px; flex-shrink: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── Buttons ──────────────────────────────────────── */
.btn-primary { background: var(--brand); color: white; border-radius: 9px; padding: 10px 18px; font-weight: 600; font-size: 14px; transition: background .15s, transform .08s, box-shadow .15s; border: none; box-shadow: 0 1px 2px rgba(var(--brand-shadow),0.25); }
.btn-primary:hover { background: var(--brand-dark); box-shadow: 0 4px 12px rgba(var(--brand-shadow),0.3); }
.btn-primary:active { transform: scale(.98); }
.btn-secondary { background: transparent; color: var(--text-muted); border: none; border-radius: 9px; padding: 10px 16px; font-weight: 500; font-size: 14px; transition: background .12s, color .12s; }
.btn-secondary:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.btn-ghost-sm { background: none; color: var(--brand); font-size: 12px; padding: 4px 8px; border-radius: 5px; }
.btn-ghost-sm:hover { background: var(--brand-light); }
.btn-full { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { background: none; border: none; color: var(--text-muted); padding: 5px; border-radius: 6px; display: flex; align-items: center; transition: background .12s, color .12s; }
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.active { color: var(--brand); background: var(--brand-light); }
.btn-icon-info { padding: 5px 6px; }
.icon-btn { background: none; border: none; color: var(--text-faint); padding: 2px 4px; border-radius: 4px; transition: color .15s, background .15s; }
.icon-btn:hover { color: var(--brand); background: var(--brand-light); }

/* ── App Layout ───────────────────────────────────── */
.app-page { display: flex; min-height: 100vh; overflow: hidden; background: var(--app-bg); }
.app-layout { display: flex; width: 100%; height: 100vh; overflow: hidden; background: var(--app-bg); }

/* ── Panel 1: Icon Rail ───────────────────────────── */
.icon-rail {
  width: var(--rail-w);
  min-width: var(--rail-w);
  height: 100vh;
  background: linear-gradient(180deg, #E2E7F5 0%, #EAEEF8 40%, #F2F4FB 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0 10px;
  flex-shrink: 0;
  z-index: 90;
  gap: 0;
}
.rail-top { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 4px; }

.rail-workspace-avatar {
  width: 36px; height: 36px;
  background: #1F2937;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 16px;
  margin-bottom: 14px; flex-shrink: 0;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.rail-btn {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(30,40,80,0.55);
  background: transparent;
  transition: background .14s, color .14s, box-shadow .14s;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
}
.rail-btn:hover { background: rgba(255,255,255,0.7); color: var(--text); }
.rail-btn-active {
  background: #ffffff !important;
  color: var(--brand-dark) !important;
  box-shadow: 0 1px 2px rgba(30,40,80,0.08), 0 0 0 1px rgba(30,40,80,0.04);
}

.rail-user-avatar {
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(30,40,80,0.08);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-weight: 600; font-size: 13px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.rail-user-avatar:hover { background: #ffffff; color: var(--text); }

/* ── Panel 2: Sidebar ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: calc(100vh - 12px);
  margin-top: 12px;
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  border-top-left-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: visible;
  transition: width .22s ease, min-width .22s ease, transform .22s ease;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: -4px 0 14px rgba(30,40,80,0.05), -1px 0 2px rgba(30,40,80,0.04);
}
.sidebar.collapsed { width: 0; min-width: 0; box-shadow: none; }
/* When sidebar is collapsed, main-area takes over the floating-paper look */
.sidebar.collapsed + .main-area {
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
  box-shadow: -4px 0 14px rgba(30,40,80,0.05), -1px 0 2px rgba(30,40,80,0.04);
}
/* Dim layer behind the mobile slide-out drawer (only visible on small screens) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,18,28,0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 12px; flex-shrink: 0; gap: 8px;
}
.sidebar-workspace-btn {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  padding: 4px 6px; margin-left: -6px; border-radius: 6px;
  transition: background .12s; min-width: 0; flex: 1;
}
.sidebar-workspace-btn:hover { background: var(--bg); }
.sidebar-workspace-btn svg { color: var(--text-faint); flex-shrink: 0; }
.sidebar-workspace-name { font-weight: 700; font-size: 14.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-actions { display: flex; gap: 2px; flex-shrink: 0; align-items: center; }
.sidebar-toggle-btn { background: none; border: none; color: var(--text-muted); padding: 5px; border-radius: 6px; display: flex; align-items: center; }
.sidebar-toggle-btn:hover { background: var(--bg); color: var(--text); }
/* Still scrollable, but the scrollbar is hidden (Firefox, IE, and WebKit). */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 0 12px; scrollbar-width: none; -ms-overflow-style: none; }
.sidebar-nav::-webkit-scrollbar { width: 0; height: 0; display: none; }
.sidebar-section { margin-bottom: 6px; padding-top: 10px; }
.sidebar-section + .sidebar-section { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 14px; }
.sidebar-section-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
  text-transform: none; letter-spacing: 0;
}
.sidebar-section-label > .label-text { display: flex; align-items: center; gap: 8px; color: var(--text); }
.sidebar-section-label .label-icon { color: var(--text-faint); display: flex; align-items: center; }
.sidebar-section-label .label-icon.li-favorites { color: #F59E0B; }
.sidebar-section-label .label-icon.li-pages { color: var(--brand); }
.sidebar-section-label .label-icon.li-recent { color: #10B981; }
.sidebar-section-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px 4px; margin: 4px 6px 0;
  font-size: 12.5px; color: var(--text-muted);
  border-radius: 6px; cursor: pointer;
  transition: background .12s, color .12s;
}
.sidebar-section-footer:hover { background: var(--bg); color: var(--text); }
.sidebar-section-footer svg { color: var(--text-faint); }
.section-actions { display: flex; gap: 1px; opacity: 0; transition: opacity .15s; }
.sidebar-section:hover .section-actions { opacity: 1; }
.section-action-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-faint); padding: 3px 5px; border-radius: 5px;
  display: flex; align-items: center;
}
.section-action-btn:hover { background: var(--bg); color: var(--text); }
.sidebar-empty { padding: 14px; text-align: center; color: var(--text-muted); font-size: 12px; }
.sidebar-empty p { margin-bottom: 10px; }
.sidebar-page-link {
  position: relative;
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px; margin: 1px 6px; border-radius: 6px;
  font-size: 13px; color: var(--text-muted);
  transition: background .12s, color .12s; overflow: hidden;
}
.sidebar-page-link:hover { background: var(--bg); color: var(--text); }
.sidebar-page-link.active {
  background: var(--brand-light); color: var(--brand-dark); font-weight: 600;
}
.sidebar-page-link.active::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.sidebar-page-link.active .item-icon { color: var(--brand); }
.sidebar-page-link .item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* ── Tree ─────────────────────────────────────────── */
.tree-folder { position: relative; }
.tree-folder-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px 6px 8px; cursor: pointer;
  color: var(--text-muted); font-size: 13px;
  border-radius: 6px; margin: 0 6px;
  transition: background .12s, color .12s; position: relative; user-select: none;
}
.tree-folder-header:hover { background: var(--bg); color: var(--text); }
.tree-folder-header:hover .item-actions { opacity: 1; }
.folder-arrow { display: flex; align-items: center; flex-shrink: 0; transition: transform .18s; color: var(--text-faint); }
.tree-folder.open > .tree-folder-header .folder-arrow { transform: rotate(90deg); }
.folder-icon { flex-shrink: 0; }
.item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-actions { display: flex; gap: 1px; opacity: 0; transition: opacity .12s; flex-shrink: 0; }
.item-action-btn { font-size: 12px; padding: 2px 5px; border-radius: 4px; color: var(--text-faint); background: none; border: none; cursor: pointer; line-height: 1; }
.item-action-btn:hover { background: var(--border); color: var(--text); }
.item-action-btn.danger:hover { background: #FEE2E2; color: var(--danger); }
.tree-folder-children { padding-left: 0; position: relative; }
.tree-page {
  display: flex; align-items: center;
  margin: 1px 6px; border-radius: 6px;
  position: relative; transition: background .12s;
}
.tree-page:hover { background: var(--bg); }
.tree-page:has(.tree-page-link.active) { background: var(--brand-light); }
.tree-page:has(.tree-page-link.active):hover { background: var(--brand-light); }
.tree-page:has(.tree-page-link.active)::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.tree-page:hover .page-actions { opacity: 1; }
.tree-page-link {
  display: flex; align-items: center; gap: 8px;
  flex: 1; padding: 6px 8px;
  font-size: 13px; color: var(--text-muted);
  transition: color .12s; overflow: hidden; min-width: 0;
}
.tree-page-link:hover { color: var(--text); }
.tree-page-link.active { color: var(--brand-dark); font-weight: 600; }
.page-actions { display: flex; gap: 1px; opacity: 0; transition: opacity .12s; margin-right: 6px; flex-shrink: 0; }
.item-icon { flex-shrink: 0; color: var(--icon-color); }
.folder-icon { color: var(--icon-brand); }
.tabler-icon { stroke-width: var(--icon-stroke); fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.tree-page-link.active .item-icon { color: var(--brand); }

/* drag highlight */
.drag-over { background: var(--brand-light) !important; outline: 2px dashed var(--brand) !important; outline-offset: -2px; border-radius: 6px; }

/* ── Panel 3: Main Area ───────────────────────────── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; margin-top: 12px; height: calc(100vh - 12px); background: var(--bg-white); }

/* ── Topbar ──────────────────────────────────────────*/
.topbar { height: var(--topbar-h); background: var(--bg-white); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; gap: 12px; flex-shrink: 0; }
.topbar-collapse-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); flex-shrink: 0; margin-right: 4px;
  transition: background .12s, color .12s;
}
.topbar-collapse-btn:hover { background: var(--bg); color: var(--text); }
.topbar-collapse-btn .ico-expand { display: none; }
.app-layout:has(.sidebar.collapsed) .topbar-collapse-btn .ico-collapse { display: none; }
.app-layout:has(.sidebar.collapsed) .topbar-collapse-btn .ico-expand { display: block; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; overflow: hidden; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.topbar-title { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Breadcrumb ──────────────────────────────────────*/
.breadcrumb { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-muted); overflow: hidden; }
.bc-link { color: var(--brand); }
.bc-link:hover { text-decoration: underline; }
.bc-sep { color: var(--text-faint); }
.bc-folder { color: var(--text-muted); }
.bc-current { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Save indicator & badges ─────────────────────────*/
.save-indicator { font-size: 11px; color: var(--success); font-weight: 500; }
.save-indicator.unsaved { color: var(--warning); }
.page-meta { font-size: 11px; color: var(--text-faint); }
.status-badge { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 20px; text-transform: capitalize; }
.status-draft { background: #FEF3C7; color: #B45309; }
.status-published { background: #DCFCE7; color: #166534; }

/* ── Page menu ───────────────────────────────────────*/
.page-menu-wrap { position: relative; }
.page-menu { position: absolute; right: 0; top: calc(100% + 4px); background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); min-width: 190px; padding: 4px; z-index: 200; display: none; }
.page-menu.open { display: block; }
.menu-item { display: block; width: 100%; text-align: left; padding: 7px 12px; font-size: 13px; border-radius: 5px; color: var(--text); transition: background .12s; }
.menu-item:hover { background: var(--bg); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: #FEF2F2; }
.menu-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Content + Detail wrapper ─────────────────────── */
.content-with-detail { flex: 1; display: flex; overflow: hidden; }

/* ── Content area ─────────────────────────────────── */
.content-area { flex: 1; overflow-y: auto; min-width: 0; }

/* ── Panel 4: Detail Panel ────────────────────────── */
.detail-panel {
  width: var(--detail-w);
  min-width: var(--detail-w);
  height: calc(100vh - 12px);
  margin-top: 12px;
  background: var(--bg-white);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .22s ease, min-width .22s ease;
  flex-shrink: 0;
}
.detail-panel.collapsed { width: 0; min-width: 0; }

/* Pill-style tabs (matches reference) */
.dp-tabs {
  display: flex; align-items: center; gap: 2px;
  padding: 14px 14px 12px; flex-shrink: 0;
  background: var(--bg-white);
  position: relative;
}
.dp-tab {
  background: none; border: none; cursor: pointer;
  padding: 6px 14px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); border-radius: 6px;
  transition: color .12s, background .12s, box-shadow .12s;
}
.dp-tab:hover { color: var(--text); }
.dp-tab.active {
  background: white; color: var(--text); font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}
.dp-tabs {
  background: #F3F4F6;
  margin: 14px 14px 6px; padding: 4px;
  border-radius: 8px; border-bottom: none;
}
.dp-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-faint); padding: 5px; border-radius: 6px;
  display: flex; align-items: center; margin-left: auto;
  transition: background .12s, color .12s;
}
.dp-close:hover { background: white; color: var(--text); }

.dp-body { flex: 1; overflow-y: auto; padding: 16px 16px 22px; }
.dp-body::-webkit-scrollbar { width: 3px; }
.dp-body::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }

.dp-tab-panel { display: none; }
.dp-tab-panel.active { display: block; }

.dp-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 10px; margin-top: 4px;
}

.dp-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 9px 0; min-height: 30px;
  border-bottom: 1px solid #F3F4F6;
}
.dp-row:last-child { border-bottom: none; }
.dp-label {
  font-size: 12.5px; color: var(--text-muted); flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
}
.dp-label svg { color: var(--text-faint); flex-shrink: 0; }
.dp-value {
  font-size: 12.5px; color: var(--text); text-align: right; flex: 1;
  word-break: break-word; font-weight: 500;
}
.dp-user { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.dp-user-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand); color: white;
  font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.dp-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0 16px; }

.dp-actions { display: flex; flex-direction: column; gap: 4px; }
.dp-action-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 500;
  color: var(--text-muted); transition: background .12s, color .12s; cursor: pointer;
  background: none; border: none; width: 100%; text-align: left;
}
.dp-action-btn:hover { background: var(--brand-light); color: var(--brand); }
.dp-action-btn svg { flex-shrink: 0; }

/* Activity tab */
.dp-activity-item {
  display: flex; gap: 11px; padding: 10px 0;
  border-bottom: 1px solid #F3F4F6;
}
.dp-activity-item:last-child { border-bottom: none; }
.dp-activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 6px; flex-shrink: 0;
}
.dp-activity-dot-create { background: var(--success); }
.dp-activity-dot-edit   { background: var(--brand); }
.dp-activity-content { flex: 1; min-width: 0; }
.dp-activity-text { font-size: 12.5px; color: var(--text); line-height: 1.4; }
.dp-activity-text strong { font-weight: 600; }
.dp-activity-time { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

/* What links here (backlinks) */
.dp-backlinks { display: flex; flex-direction: column; gap: 2px; }
.dp-backlink {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 500;
  color: var(--text-muted); transition: background .12s, color .12s;
}
.dp-backlink:hover { background: var(--brand-light); color: var(--brand); }
.dp-backlink svg { flex-shrink: 0; }
.dp-backlink-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dp-empty { font-size: 12px; color: var(--text-faint); padding: 2px 2px 4px; }

/* Link modal: Web URL / Wiki page tabs + page picker */
.link-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.link-tab {
  padding: 7px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--text-muted); background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.link-tab:hover { color: var(--text); }
.link-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.link-tab-panel { display: none; }
.link-tab-panel.active { display: block; }
.link-page-results { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.link-page-item {
  display: flex; flex-direction: column; gap: 2px;
  text-align: left; width: 100%; padding: 8px 11px; border-radius: 7px;
  color: var(--text); background: none; border: none; cursor: pointer;
}
.link-page-item:hover { background: var(--brand-light); }
.link-page-title {
  font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-page-item:hover .link-page-title { color: var(--brand); }
.link-page-path {
  font-size: 11px; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-page-empty { font-size: 12.5px; color: var(--text-faint); padding: 8px 4px; }

/* ── Editor ──────────────────────────────────────────*/
.editor-wrapper { max-width: 780px; margin: 0 auto; padding: 56px 36px 80px; }
.page-title-input { width: 100%; border: none; outline: none; font-size: 30px; font-weight: 700; color: var(--text); margin-bottom: 10px; background: transparent; }
.page-title-input::placeholder { color: var(--text-faint); }
.page-meta-bar { display: flex; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.meta-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-faint); }

.editor-toolbar {
  display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
  background: var(--bg-white); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 4px 7px;
  margin-bottom: 14px; position: sticky; top: 10px; z-index: 10;
  box-shadow: var(--shadow-sm);
}
.toolbar-group { display: flex; align-items: center; gap: 1px; }
.toolbar-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }
.toolbar-right { margin-left: auto; }
.toolbar-select { border: 1.5px solid var(--border); border-radius: 5px; padding: 3px 5px; font-size: 12px; background: transparent; color: var(--text); cursor: pointer; }
.toolbar-select:focus { outline: none; border-color: var(--brand); }
.tb-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 5px;
  color: var(--text-muted); font-size: 12px;
  transition: background .12s, color .12s; border: none; background: none; cursor: pointer;
}
.tb-btn:hover { background: var(--bg); color: var(--text); }
.tb-btn.active { background: var(--brand-light); color: var(--brand); }

.editor-body {
  min-height: 400px; outline: none;
  font-size: 15px; line-height: 1.75; color: var(--text);
  border: 1.5px solid transparent; border-radius: var(--radius);
  padding: 14px; transition: border-color .15s;
}
.editor-body:focus { border-color: var(--border); }
.editor-body h1 { font-size: 26px; font-weight: 700; margin: 22px 0 10px; }
.editor-body h2 { font-size: 20px; font-weight: 600; margin: 18px 0 9px; }
.editor-body h3 { font-size: 16px; font-weight: 600; margin: 14px 0 7px; }
.editor-body p { margin: 0 0 8px; }
.editor-body ul, .editor-body ol { padding-left: 24px; margin: 8px 0; }
.editor-body li { margin: 4px 0; }
.editor-body a { color: var(--brand); text-decoration: underline; }
.editor-body hr { border: none; border-top: 1.5px solid var(--border); margin: 20px 0; }
.editor-body img { max-width: 100%; height: auto; border-radius: 6px; cursor: pointer; }
/* Offset for sticky toolbar so TOC/bookmark links don't scroll headings
   under the toolbar. Toolbar height ≈ 16 + 26 + 20 = ~62px, plus a small gap. */
.editor-body h1, .editor-body h2, .editor-body h3,
.view-content h1, .view-content h2, .view-content h3 { scroll-margin-top: 80px; }
.editor-body img.selected { outline: 2px solid var(--brand); }

/* Back-to-top floating button — appears when the content area is scrolled */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease, background .15s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  z-index: 50;
}
.back-to-top:hover { background: var(--brand-dark); }
.back-to-top.show { opacity: 1; visibility: visible; transform: translateY(0); }

/* Image resize handles — overlay box positioned over the selected image */
.img-resize-box {
  position: absolute;
  pointer-events: none;
  z-index: 25;
  box-sizing: border-box;
}
.img-resize-handle {
  position: absolute;
  width: 12px; height: 12px;
  background: #fff;
  border: 2px solid var(--brand);
  border-radius: 50%;
  pointer-events: auto;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.img-resize-nw { top: -7px; left: -7px;  cursor: nwse-resize; }
.img-resize-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.img-resize-sw { bottom: -7px; left: -7px;  cursor: nesw-resize; }
.img-resize-se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.editor-body blockquote, .view-wrapper blockquote {
  border-left: 4px solid var(--brand);
  background: var(--brand-light);
  padding: 10px 16px;
  color: var(--text);
  margin: 14px 0;
  border-radius: 0 6px 6px 0;
}
.editor-body blockquote p, .view-wrapper blockquote p { margin: 4px 0; }

.editor-body pre, .view-wrapper pre {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 8px;
  margin: 14px 0;
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.editor-body pre code, .view-wrapper pre code {
  font-family: inherit;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}
.editor-body code, .view-wrapper code {
  font-family: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.92em;
}

.editor-body .toc-block, .view-wrapper .toc-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 16px 0;
  max-width: 360px;
}
.toc-block .toc-title { display: none; }
.toc-block ul { list-style: none; padding: 0; margin: 0; }
.toc-block li { margin: 3px 0; line-height: 1.45; }
.toc-block li.toc-h2 { padding-left: 14px; }
.toc-block li.toc-h3 { padding-left: 28px; }
.toc-block a { color: var(--text); text-decoration: none; font-size: 13.5px; }
.toc-block a:hover { color: var(--brand); text-decoration: underline; }
.toc-block .toc-empty { color: var(--text-muted); font-size: 13px; font-style: italic; }
.editor-body table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.editor-body td, .editor-body th { border: 1.5px solid var(--border-dark); padding: 7px 11px; min-width: 80px; vertical-align: top; }
.editor-body th { background: var(--bg); font-weight: 600; }
.table-context-menu { position: fixed; background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 4px; z-index: 300; min-width: 160px; }
.table-context-menu button { display: block; width: 100%; text-align: left; padding: 7px 12px; font-size: 13px; border-radius: 5px; color: var(--text); }
.table-context-menu button:hover { background: var(--bg); }
.table-context-menu button.danger { color: var(--danger); }
.table-context-menu button.danger:hover { background: #FEF2F2; }
.table-context-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ── View mode ───────────────────────────────────────*/
.view-wrapper { max-width: 780px; margin: 0 auto; padding: 56px 36px 80px; }
.view-title { font-size: 30px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.view-content { font-size: 15px; line-height: 1.75; color: var(--text); }
.view-content h1 { font-size: 26px; font-weight: 700; margin: 22px 0 10px; }
.view-content h2 { font-size: 20px; font-weight: 600; margin: 18px 0 9px; }
.view-content h3 { font-size: 16px; font-weight: 600; margin: 14px 0 7px; }
.view-content p { margin: 0 0 8px; }
.view-content ul, .view-content ol { padding-left: 24px; margin: 8px 0; }
.view-content li { margin: 4px 0; }
.view-content a { color: var(--brand); text-decoration: underline; }
.view-content hr { border: none; border-top: 1.5px solid var(--border); margin: 20px 0; }
.view-content img { max-width: 100%; height: auto; border-radius: 6px; }
.view-content table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.view-content td, .view-content th { border: 1.5px solid var(--border-dark); padding: 7px 11px; vertical-align: top; }
.view-content th { background: var(--bg); font-weight: 600; }
.empty-content { text-align: center; padding: 60px; color: var(--text-muted); }
.empty-content a { color: var(--brand); }

/* ── Dashboard home ──────────────────────────────────*/
.dashboard-home { max-width: 780px; margin: 0 auto; padding: 36px 36px 80px; }
.dashboard-welcome { margin-bottom: 44px; }
.dashboard-welcome h1 { font-size: 26px; font-weight: 700; margin-bottom: 10px; }
.dashboard-welcome p { color: var(--text-muted); line-height: 1.6; margin-bottom: 22px; }
.dashboard-actions { display: flex; gap: 10px; }
.dashboard-section h2 { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--text-muted); }
.page-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.page-card { display: flex; align-items: flex-start; gap: 11px; background: var(--bg-white); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; transition: box-shadow .15s, border-color .15s; }
.page-card:hover { box-shadow: var(--shadow-sm); border-color: var(--brand); }
.page-card-icon { flex-shrink: 0; }
.page-card-info { min-width: 0; }
.page-card-title { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-card-date { font-size: 11px; color: var(--text-faint); margin-top: 3px; }

/* ── Search page ─────────────────────────────────────*/
.search-results-wrap { max-width: 700px; margin: 0 auto; padding: 28px 24px 80px; }
.search-main-form { display: flex; gap: 10px; margin-bottom: 22px; }
.search-main-input { flex: 1; background: var(--bg-white); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 9px 13px; font-size: 14px; color: var(--text); }
.search-main-input:focus { outline: none; border-color: var(--brand); }
.search-count { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.search-results { display: flex; flex-direction: column; gap: 8px; }
.search-result { display: flex; align-items: center; gap: 13px; background: var(--bg-white); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; transition: box-shadow .15s, border-color .15s; }
.search-result:hover { box-shadow: var(--shadow-sm); border-color: var(--brand); }
.result-icon { flex-shrink: 0; }
.result-title { font-weight: 500; margin-bottom: 2px; }
.result-type { font-size: 11px; color: var(--text-faint); }
.empty-results { text-align: center; padding: 60px; color: var(--text-muted); }
.empty-results .hint { font-size: 13px; margin-top: 6px; }

/* ── Modals ──────────────────────────────────────────*/
.modal-overlay { position: fixed; inset: 0; background: rgba(15,18,28,.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); z-index: 1000; display: none; align-items: center; justify-content: center; animation: modalFade .15s ease-out; }
.modal-overlay.open { display: flex; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop  { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal { background: white; border-radius: 16px; width: 560px; max-width: calc(100vw - 32px); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 24px 64px -16px rgba(15,18,28,.25); animation: modalPop .18s cubic-bezier(.2,.8,.2,1); }
.modal-wide { width: 680px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px 6px; border-bottom: none; }
.modal-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
.modal-close { color: var(--text-faint); font-size: 18px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 8px; transition: background .12s, color .12s; }
.modal-close:hover { background: rgba(0,0,0,.05); color: var(--text); }
.modal-body { padding: 18px 26px 8px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 26px 22px; border-top: none; }

.upload-area { border: 2px dashed var(--border-dark); border-radius: var(--radius); padding: 28px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; color: var(--text-muted); font-size: 13px; }
.upload-area:hover, .upload-area.drag-over { border-color: var(--brand); background: var(--brand-light); }
.upload-area svg { margin-bottom: 10px; }
.upload-area p { margin: 0; }

/* ── Version history ─────────────────────────────────*/
.version-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); }
.version-item:last-child { border-bottom: none; }
.version-date { font-size: 12px; color: var(--text-muted); }
.version-restore { font-size: 12px; color: var(--brand); cursor: pointer; }
.version-restore:hover { text-decoration: underline; }

/* ────────────────────────────────────────────────────
   WikiBase Redesign — overrides (loaded last, win specificity ties)
   ──────────────────────────────────────────────────── */

:root {
  --sidebar-w: 248px;
  --app-bg: #F4F5F8;
  --card-radius: 12px;
  --topbar-h: 56px;
}

body, .app-page, .app-layout { background: var(--app-bg); }

/* Sidebar: flush left, white, no shadow, no top margin */
.sidebar {
  margin-top: 0;
  height: 100vh;
  border-top-left-radius: 0;
  border-right: 1px solid #E8EAF0;
  box-shadow: none;
  background: #FFFFFF;
}
.sidebar.collapsed + .main-area { border-radius: 0; box-shadow: none; }

/* Brand row */
.sidebar-brand { padding: 16px 18px 14px; flex-shrink: 0; }
.brand-link { display: flex; align-items: center; gap: 10px; }
.brand-icon { display: flex; align-items: center; }
.brand-name { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }

/* Sidebar bottom bar (fixed at the bottom of the sidebar) */
.sidebar-bottom-bar {
  flex-shrink: 0;
  display: flex; gap: 4px;
  padding: 10px 14px 14px;
  background: transparent;
  container-type: inline-size;
}
/* When the sidebar is dragged narrow, drop the button labels and show
   icons only so they keep fitting on one row. */
@container (max-width: 210px) {
  .sidebar-bottom-bar .bb-btn span { display: none; }
  .sidebar-bottom-bar .bb-btn { gap: 0; padding: 0; }
}
.bb-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 8px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  background: transparent; border: none; cursor: pointer; border-radius: 6px;
  transition: background .12s, color .12s;
}
.bb-btn:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.bb-btn .tabler-icon { flex-shrink: 0; color: var(--icon-color); }
.bb-btn:hover .tabler-icon { color: var(--text); }

/* Search modal */
.search-modal-backdrop {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(20, 24, 40, 0.35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  animation: smfade .14s ease-out;
}
.search-modal-backdrop[hidden] { display: none; }
@keyframes smfade { from { opacity: 0; } to { opacity: 1; } }
.search-modal {
  width: 100%; max-width: 640px;
  background: #FFFFFF; border-radius: 12px;
  box-shadow: 0 24px 60px rgba(20,24,40,0.25), 0 2px 6px rgba(20,24,40,0.08);
  overflow: hidden;
  animation: smpop .16s ease-out;
}
@keyframes smpop { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.search-modal-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid #ECEEF3;
}
.search-modal-input-row .tabler-icon { color: var(--text-faint); flex-shrink: 0; }
.search-modal-input-row input {
  flex: 1; border: none; outline: none;
  font-family: inherit; font-size: 16px; color: var(--text);
  background: transparent;
}
.search-modal-input-row kbd {
  font-family: inherit; font-size: 11px; color: var(--text-faint);
  background: #F4F5F8; border: 1px solid #E5E7EB; border-radius: 4px;
  padding: 2px 6px; font-weight: 500;
}
.search-modal-results { max-height: 60vh; overflow-y: auto; padding: 6px; }
.search-modal-empty {
  padding: 32px 18px; text-align: center;
  color: var(--text-faint); font-size: 13px;
}
.search-result {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none;
  cursor: pointer;
}
.search-result:hover, .search-result.active { background: var(--brand-light); color: var(--brand-dark); }
.search-result .tabler-icon { color: var(--text-faint); flex-shrink: 0; }
.search-result.active .tabler-icon { color: var(--brand); }
.search-result-title { flex: 1; font-size: 14px; font-weight: 500; }
.search-result-type { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }

/* Legacy: kept for any unrelated reference */
.sidebar-search { padding: 0 14px 10px; flex-shrink: 0; }
.search-input-fake {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px; border-radius: 8px;
  background: #F6F7F9; border: 1px solid #E8EAF0;
  color: var(--text-faint); font-size: 13px;
  transition: border-color .12s, background .12s;
}
.search-input-fake:hover { border-color: #D7DAE3; }
.search-input-fake svg { color: var(--text-faint); flex-shrink: 0; }
.search-input-fake span { flex: 1; }
.search-input-fake kbd {
  font-family: inherit; font-size: 11px; color: var(--text-faint);
  background: #FFFFFF; border: 1px solid #E5E7EB; border-radius: 4px;
  padding: 1px 5px; font-weight: 500;
}

/* + New button */
.sidebar-new { display: flex; gap: 0; padding: 0 14px 16px; flex-shrink: 0; }
.btn-new {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px;
  background: var(--brand); color: white;
  font-size: 14px; font-weight: 600;
  border: none; border-radius: 8px 0 0 8px;
  cursor: pointer; transition: background .12s;
  box-shadow: 0 1px 2px rgba(79,110,247,0.25);
}
.btn-new:hover { background: var(--brand-dark); }
.btn-new-plus { font-size: 16px; font-weight: 500; line-height: 1; }
.btn-new-caret {
  width: 32px; height: 38px;
  background: var(--brand); color: white;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0 8px 8px 0;
  border-left: 1px solid rgba(255,255,255,0.18);
  cursor: pointer; transition: background .12s;
  box-shadow: 0 1px 2px rgba(79,110,247,0.25);
}
.btn-new-caret:hover { background: var(--brand-dark); }

/* Section labels — softer, no dividers */
.sidebar-section + .sidebar-section { border-top: none; margin-top: 0; padding-top: 10px; }
.sidebar-section { padding-top: 8px; margin-bottom: 2px; }
.sidebar-section-label { padding: 6px 18px 6px 14px; font-size: 13px; font-weight: 600; color: var(--text); }
.sidebar-section-label > .label-text { gap: 6px; }
.sidebar-section-label .label-icon svg { width: 20px; height: 20px; }

/* Active page item: blue DOT on left + light blue bg + blue text */
.sidebar-page-link { padding: 6px 10px 6px 22px; }
.tree-page-link { padding: 5px 10px 5px 10px; }
.sidebar-page-link { margin: 1px 10px; }
.sidebar-page-link.active::before,
.tree-page:has(.tree-page-link.active)::before { display: none; }
.sidebar-page-link.active,
.tree-page:has(.tree-page-link.active) { background: var(--brand-light); border-radius: 6px; }
.sidebar-page-link.active { color: var(--brand); }
.tree-page-link.active { color: var(--brand); }

.sidebar-page-link.active .item-icon,
.tree-page-link.active .item-icon { color: var(--brand); }

/* Active page: stronger blue text/background, no dot indicator */
.sidebar-page-link::after,
.tree-page-link::after { display: none !important; }
.tree-page:has(.tree-page-link.active),
.sidebar-page-link.active {
  background: var(--brand-tint) !important;
}
.tree-page-link.active,
.sidebar-page-link.active { color: var(--brand-dark, #2C46C9) !important; font-weight: 600; }

/* Tree-view vertical guide lines under each open folder — dotted */
.tree-folder-children { position: relative; }
.tree-folder.open > .tree-folder-children::before {
  content: "";
  position: absolute;
  top: 2px; bottom: 4px;
  left: var(--line-left, 14px);
  width: 0; height: auto;
  border-left: 1px dotted #B5BAC4;
  pointer-events: none;
}

/* Folder open/closed icon swap; hide chevron arrow entirely */
.folder-arrow { display: none !important; }
.folder-icon-open { display: none; }
.tree-folder.open > .tree-folder-header > .folder-icon-closed { display: none; }
.tree-folder.open > .tree-folder-header > .folder-icon-open { display: inline-block; }

/* Tree page row (resets old left-bar) */
.tree-page-link { padding: 5px 10px 5px 10px; }

/* Section footer (View all recent pages) */
.sidebar-section-footer {
  padding: 10px 16px; margin: 6px 10px 8px;
  color: var(--text-muted); font-size: 12.5px; font-weight: 500;
}

/* ── Main area: light grey bg, content card ───────── */
.main-area { background: var(--app-bg); margin-top: 0; height: 100vh; }
.topbar {
  background: var(--app-bg); border-bottom: none;
  height: var(--topbar-h); padding: 0 24px;
}
.topbar-left { gap: 12px; }
.topbar-right { gap: 10px; }

/* Hide topbar collapse btn — sidebar always visible in this design */
.topbar-collapse-btn { display: none; }

/* Breadcrumb: muted grey, current page in blue */
.breadcrumb { font-size: 13.5px; color: var(--text-muted); gap: 6px; }
.bc-link { color: var(--text-muted); }
.bc-link:hover { color: var(--text); text-decoration: none; }
.bc-sep { color: var(--text-faint); }
.bc-folder { color: var(--text-muted); }
.bc-current { color: var(--brand); font-weight: 600; }

/* (old save-indicator rules removed — see .page-float-group .save-indicator) */

/* Share / Edit / Done ghost buttons */
.btn-share {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px;
  background: transparent; border: none; border-radius: 7px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .12s, color .12s;
}
.btn-share:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.btn-share svg { color: currentColor; }

/* Topbar icon button (… menu, info) */
.btn-tb-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 7px;
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer; transition: background .12s, color .12s;
}
.btn-tb-icon:hover { background: rgba(0,0,0,0.05); color: var(--text); }

/* Topbar avatar circle */
.topbar-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: white;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em;
  margin-left: 4px;
  transition: background .12s;
}
.topbar-avatar:hover { background: var(--brand-dark); }
button.topbar-avatar { border: 0; cursor: pointer; padding: 0; font-family: inherit; }
button.topbar-avatar.topbar-avatar-icon {
  background: transparent;
  color: var(--text-muted);
}
button.topbar-avatar.topbar-avatar-icon:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text);
}

/* ── User menu dropdown ── */
.user-menu-wrap { position: relative; margin-left: 4px; }
.user-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 296px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.04);
  padding: 10px;
  z-index: 200;
  animation: umPop .14s ease-out;
}
.user-menu[hidden] { display: none; }
@keyframes umPop {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.user-menu-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.um-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--brand); color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
}
.um-meta { min-width: 0; }
.um-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.um-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.user-menu-section-label {
  font-size: 10.5px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 6px 10px 4px;
}

.theme-picker { display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }
.theme-option {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  background: transparent; border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-family: inherit; text-align: left;
  transition: background .12s, border-color .12s;
}
.theme-option:hover { background: var(--bg); }
.theme-option.active {
  background: var(--brand-light);
  border-color: var(--brand-tint);
}
.theme-preview {
  display: inline-flex; align-items: center;
  width: 56px; height: 22px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.tp-swatch { display: block; height: 100%; }
.tp-swatch.tp-bg    { flex: 1.4; background: var(--p2); }
.tp-swatch.tp-brand { flex: 1;   background: var(--p1); }
.tp-swatch.tp-light { flex: 0.8; background: var(--p3); }
.theme-name { flex: 1; font-size: 13px; font-weight: 500; color: var(--text); }
.theme-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  color: var(--brand);
  opacity: 0;
  transition: opacity .12s;
}
.theme-option.active .theme-check { opacity: 1; }

/* Font picker rows — share .theme-check */
.font-picker { display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }
.font-option {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: transparent; border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-family: inherit; text-align: left;
  transition: background .12s, border-color .12s;
}
.font-option:hover { background: var(--bg); }
.font-option.active {
  background: var(--brand-light);
  border-color: var(--brand-tint);
}
.font-sample {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 22px;
  font-size: 14px; font-weight: 600; color: var(--text);
  flex-shrink: 0;
}
.font-name { flex: 1; font-size: 13px; font-weight: 500; color: var(--text); }
.font-option.active .theme-check { opacity: 1; }

/* Reading-width picker (settings page) */
.reading-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.reading-option {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  width: 100%;
  background: transparent; border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-family: inherit; text-align: left;
  transition: background .12s, border-color .12s;
}
.reading-option:hover { background: var(--bg); }
.reading-option.active { background: var(--brand-light); border-color: var(--brand-tint); }
.reading-preview {
  grid-row: 1 / 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  width: 36px; height: 32px;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg-white);
  padding: 5px 9px;
}
.reading-preview.reading-preview-full { padding: 5px 4px; }
.reading-preview .rp-bar { width: 100%; height: 3px; border-radius: 2px; background: var(--text-faint); }
.reading-preview .rp-bar.short { width: 60%; align-self: flex-start; }
.reading-name { grid-column: 2; grid-row: 1; font-size: 13.5px; font-weight: 600; color: var(--text); }
.reading-sub  { grid-column: 2; grid-row: 2; font-size: 12px; color: var(--text-muted); }
.reading-option .theme-check { grid-column: 3; grid-row: 1 / 3; opacity: 0; transition: opacity .12s; color: var(--brand); }
.reading-option.active .theme-check { opacity: 1; }

/* Live preview of the selected reading width */
.reading-demo { margin-top: 18px; }
.reading-demo-label {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 8px;
}
.reading-demo-page {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 26px;
  box-shadow: inset 0 1px 2px rgba(15,23,42,0.03);
}
.reading-demo-col {
  margin: 0 auto;
  max-width: 100%;
  transition: max-width .28s ease;
}
.rd-title { height: 12px; width: 52%; border-radius: 4px; background: var(--text-faint); margin-bottom: 14px; }
.rd-line  { height: 7px; border-radius: 4px; background: var(--border); margin-bottom: 9px; }
.rd-line.short { width: 42%; margin-bottom: 0; }
/* Narrow caps the demo column; full lets it fill the mock page. The 920px:780px
   real-world ratio is approximated here so the difference reads clearly. */
html[data-reading-width="narrow"] .reading-demo-col { max-width: 62%; }
html[data-reading-width="full"]   .reading-demo-col { max-width: 100%; }

/* Cloudy preview swatch for the Aurora theme */
.theme-preview-cloud { position: relative; }
.theme-preview-cloud .tp-cloud {
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 80% at 20% 30%, rgba(255,196,214,1) 0%, rgba(255,196,214,0) 70%),
    radial-gradient(60% 80% at 80% 30%, rgba(186,206,255,1) 0%, rgba(186,206,255,0) 70%),
    radial-gradient(70% 90% at 55% 90%, rgba(206,189,255,1) 0%, rgba(206,189,255,0) 70%),
    #F6F3FF;
}
.theme-preview-cloud .tp-cloud.tp-cloud-mist {
  background:
    radial-gradient(60% 80% at 18% 30%, rgba(255,221,189,1) 0%, rgba(255,221,189,0) 70%),
    radial-gradient(60% 80% at 82% 25%, rgba(196,234,214,1) 0%, rgba(196,234,214,0) 70%),
    radial-gradient(70% 90% at 55% 90%, rgba(252,238,178,1) 0%, rgba(252,238,178,0) 70%),
    #FAF8F3;
}
.theme-preview-cloud .tp-cloud.tp-cloud-lagoon {
  background:
    radial-gradient(60% 80% at 18% 30%, rgba(173,232,236,1) 0%, rgba(173,232,236,0) 70%),
    radial-gradient(60% 80% at 82% 28%, rgba(186,222,255,1) 0%, rgba(186,222,255,0) 70%),
    radial-gradient(70% 90% at 55% 90%, rgba(190,240,224,1) 0%, rgba(190,240,224,0) 70%),
    #EFF8F9;
}
.theme-preview-cloud .tp-cloud.tp-cloud-coral {
  background:
    radial-gradient(60% 80% at 18% 30%, rgba(255,200,205,1) 0%, rgba(255,200,205,0) 70%),
    radial-gradient(60% 80% at 82% 25%, rgba(255,215,186,1) 0%, rgba(255,215,186,0) 70%),
    radial-gradient(70% 90% at 55% 90%, rgba(255,190,214,1) 0%, rgba(255,190,214,0) 70%),
    #FFF5F4;
}

.user-menu-divider {
  border: 0; border-top: 1px solid var(--border);
  margin: 8px 0 6px;
}
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  transition: background .12s;
}
.user-menu-item:hover { background: var(--bg); }
.user-menu-item svg { color: var(--text-muted); flex-shrink: 0; }

/* ── Content card: white rounded card sitting on grey bg ── */
.content-with-detail { padding: 0 24px 24px; gap: 16px; }
.content-with-detail:has(.detail-panel.collapsed) { gap: 0; }
.content-area {
  background: white; border-radius: var(--card-radius);
  box-shadow: 0 1px 3px rgba(15,23,42,0.04), 0 1px 2px rgba(15,23,42,0.03);
  border: 1px solid #EDEFF3;
  overflow-y: auto;
}

/* Inner content padding sits inside the card */
.editor-wrapper, .view-wrapper { padding: 64px 56px 80px; max-width: none; }
.dashboard-home { padding: 44px 56px 80px; max-width: none; }

/* Comfortable reading width: cap the article text column so lines stay easy
   to scan. The page card keeps its full size; the text is centred with extra
   side padding. Toggleable in Settings → Reading (default on). */
html[data-reading-width="narrow"] .editor-wrapper,
html[data-reading-width="narrow"] .view-wrapper {
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}
.view-title, .page-title-input { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }

/* Reading-width toggle in the topbar: reuses the Settings → Reading bar
   previews (compacted) and shows the preview for the action available in the
   current state (full when comfortable, comfortable when full width). */
#readingWidthToggle[aria-pressed="true"] {
  background: var(--brand-light);
  color: var(--brand);
}

/* ── On this page: page layout + sticky outline ───────────────────
   The page card lays its article and the heading outline side by side.
   The outline is a slim ~280px column that sticks in place while the
   card scrolls, styled to read as part of the page (no off-page chrome). */
.page-layout { display: flex; align-items: flex-start; }
.page-layout > .editor-wrapper,
.page-layout > .view-wrapper { flex: 1 1 auto; min-width: 0; }

.page-outline {
  flex: 0 0 280px;
  width: 280px;
  align-self: flex-start;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 64px 30px 48px 6px;
  box-sizing: border-box;
}
.page-outline .po-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 10px;
  padding-left: 14px;
}
.po-nav { display: flex; flex-direction: column; border-left: 2px solid var(--border); }
.po-nav a {
  display: block;
  margin-left: -2px;
  padding: 5px 8px 5px 14px;
  border-left: 2px solid transparent;
  border-radius: 0 5px 5px 0;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .12s, border-color .12s, background .12s;
}
.po-nav a:hover { color: var(--text); background: var(--bg); }
.po-nav a.po-h2 { padding-left: 26px; }
.po-nav a.po-h3 { padding-left: 38px; font-size: 12.5px; }
.po-nav a.active {
  color: var(--brand);
  border-left-color: var(--brand);
  font-weight: 600;
}

/* Hidden when toggled off or when the page has no headings */
.page-layout.outline-collapsed .page-outline,
.page-outline.is-empty { display: none; }

#outlineToggleBtn.active { color: var(--brand); background: var(--brand-light); }

/* On narrow viewports the slim outline would crowd the article — hide it so
   the page card keeps its full width. */
@media (max-width: 1100px) {
  .page-outline { display: none; }
  #outlineToggleBtn { display: none; }
}

/* Page meta row under title */
.page-meta-bar { gap: 14px; margin-bottom: 26px; align-items: center; }
.meta-item { font-size: 13px; color: var(--text-muted); }

/* Status pill: "• Draft" in light blue (matching reference) */
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 20px;
}
.status-draft { background: #EEF1FB; color: var(--brand); }
.status-draft::before { content: "•"; font-size: 14px; line-height: 1; }
.status-published { background: #DCFCE7; color: #166534; }
.status-published::before { content: "•"; font-size: 14px; line-height: 1; }

/* Detail panel: floats on grey bg, transparent border */
.detail-panel { margin-top: 0; height: auto; background: white; border: 1px solid #EDEFF3; border-radius: var(--card-radius); border-left: 1px solid #EDEFF3; }

/* Editor toolbar — pill style */
.editor-toolbar {
  border-radius: 10px; padding: 5px 8px;
  box-shadow: 0 2px 8px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
  border: 1px solid #EDEFF3;
}

/* Reset old rail-related layout in case it lingers */
.icon-rail { display: none !important; }

/* ────────────────────────────────────────────────────
   v2 — Soft gradient + floating sidebar + paper card
   ──────────────────────────────────────────────────── */

body, body.app-page {
  font-family: var(--font-base);
  background: linear-gradient(90deg, var(--page-grad-from) 0%, var(--page-grad-to) 100%) !important;
  background-attachment: fixed !important;
}

/* Stop the rubber-band overscroll "bounce" from exposing the bare backdrop
   (which flashes as a loss of the page's gradient colour) when scrolling fast.
   Disable bounce/chaining on the document, and tint the html backdrop to match
   the gradient's edge so any residual overscroll stays on-theme, not white. */
html { background: var(--page-grad-from); }
html, body { overscroll-behavior: none; }

/* ─── Font families ─── */
html[data-font="inter"]   { --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
html[data-font="open"]    { --font-base: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
html[data-font="source"]  { --font-base: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
html[data-font="manrope"] { --font-base: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
html[data-font="system"]  { --font-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* ─── Theme palettes ─── */
html[data-theme="forest"] {
  --brand: #2F8F5C; --brand-dark: #1F6E45; --brand-light: #E6F2EC; --brand-tint: #CFE6D9;
  --icon-brand: #2F8F5C; --brand-shadow: 47,143,92;
  --page-grad-from: #F4F9F5; --page-grad-to: #d4e4d0;
}
html[data-theme="sunset"] {
  --brand: #E07A3B; --brand-dark: #B95F22; --brand-light: #FBEEE3; --brand-tint: #F4D6BD;
  --icon-brand: #E07A3B; --brand-shadow: 224,122,59;
  --page-grad-from: #FBF6F2; --page-grad-to: #f3d9c2;
}
html[data-theme="slate"] {
  --brand: #475569; --brand-dark: #334155; --brand-light: #ECEEF2; --brand-tint: #D6DAE2;
  --icon-brand: #475569; --brand-shadow: 71,85,105;
  --page-grad-from: #F6F7F9; --page-grad-to: #d4d8e0;
}
html[data-theme="plum"] {
  --brand: #8B5CB8; --brand-dark: #6E429A; --brand-light: #F1E9F7; --brand-tint: #E0CCEC;
  --icon-brand: #8B5CB8; --brand-shadow: 139,92,184;
  --page-grad-from: #F9F4FB; --page-grad-to: #e0d2ea;
}
html[data-theme="dream"] {
  --brand: #7C6BE8; --brand-dark: #5B4BC9; --brand-light: #EFECFC; --brand-tint: #DCD5F6;
  --icon-brand: #7C6BE8; --brand-shadow: 124,107,232;
}
html[data-theme="dream"] .folder-icon { color: #808080 !important; }

html[data-theme="mist"] {
  --brand: #1F2937; --brand-dark: #0F172A; --brand-light: #EEF0F4; --brand-tint: #D6DBE3;
  --icon-brand: #111827; --brand-shadow: 31,41,55;
}
html[data-theme="mist"] .folder-icon { color: #000 !important; }
html[data-theme="mist"] body,
html[data-theme="mist"] body.app-page {
  background:
    radial-gradient(60% 55% at 15% 25%, rgba(255,221,189,0.85) 0%, rgba(255,221,189,0) 65%),
    radial-gradient(55% 50% at 85% 20%, rgba(196,234,214,0.85) 0%, rgba(196,234,214,0) 65%),
    radial-gradient(65% 60% at 55% 90%, rgba(252,238,178,0.80) 0%, rgba(252,238,178,0) 65%),
    #FAF8F3 !important;
}
html[data-theme="dream"] body,
html[data-theme="dream"] body.app-page {
  background:
    radial-gradient(60% 55% at 18% 22%, rgba(255,196,214,0.85) 0%, rgba(255,196,214,0) 65%),
    radial-gradient(55% 50% at 82% 28%, rgba(186,206,255,0.85) 0%, rgba(186,206,255,0) 65%),
    radial-gradient(65% 60% at 55% 88%, rgba(206,189,255,0.85) 0%, rgba(206,189,255,0) 65%),
    #F6F3FF !important;
}

html[data-theme="lagoon"] {
  --brand: #0E9AA6; --brand-dark: #0B7A84; --brand-light: #E4F4F5; --brand-tint: #C7E8EB;
  --icon-brand: #0E9AA6; --brand-shadow: 14,154,166;
}
html[data-theme="lagoon"] .folder-icon { color: #5A7D80 !important; }
html[data-theme="lagoon"] body,
html[data-theme="lagoon"] body.app-page {
  background:
    radial-gradient(60% 55% at 16% 24%, rgba(173,232,236,0.85) 0%, rgba(173,232,236,0) 65%),
    radial-gradient(55% 50% at 84% 22%, rgba(186,222,255,0.85) 0%, rgba(186,222,255,0) 65%),
    radial-gradient(65% 60% at 55% 90%, rgba(190,240,224,0.80) 0%, rgba(190,240,224,0) 65%),
    #EFF8F9 !important;
}

html[data-theme="coral"] {
  --brand: #E25C72; --brand-dark: #C73E55; --brand-light: #FCE9EC; --brand-tint: #F6CDD5;
  --icon-brand: #E25C72; --brand-shadow: 226,92,114;
}
html[data-theme="coral"] .folder-icon { color: #9A7077 !important; }
html[data-theme="coral"] body,
html[data-theme="coral"] body.app-page {
  background:
    radial-gradient(60% 55% at 17% 23%, rgba(255,200,205,0.85) 0%, rgba(255,200,205,0) 65%),
    radial-gradient(55% 50% at 83% 24%, rgba(255,215,186,0.85) 0%, rgba(255,215,186,0) 65%),
    radial-gradient(65% 60% at 55% 88%, rgba(255,190,214,0.80) 0%, rgba(255,190,214,0) 65%),
    #FFF5F4 !important;
}

/* For the gradient themes the subtle --brand-tint disappears on the colourful
   background, so use a more opaque white-ish highlight for the selected
   sidebar page instead. */
html[data-theme="dream"]  .tree-page:has(.tree-page-link.active),
html[data-theme="dream"]  .sidebar-page-link.active,
html[data-theme="mist"]   .tree-page:has(.tree-page-link.active),
html[data-theme="mist"]   .sidebar-page-link.active,
html[data-theme="lagoon"] .tree-page:has(.tree-page-link.active),
html[data-theme="lagoon"] .sidebar-page-link.active,
html[data-theme="coral"]  .tree-page:has(.tree-page-link.active),
html[data-theme="coral"]  .sidebar-page-link.active {
  background: rgba(255,255,255,0.85) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.app-layout, .main-area { background: transparent !important; }

/* Sidebar — transparent, floats on gradient */
.sidebar {
  background: transparent !important;
  border-right: none !important;
  box-shadow: none !important;
  width: var(--sidebar-w) !important;
  min-width: var(--sidebar-w) !important;
  max-width: var(--sidebar-w) !important;
  flex: 0 0 var(--sidebar-w) !important;
}

/* Brand sits in its natural place at top of sidebar */
.sidebar-brand { padding: 18px 18px 18px 20px; }

/* Sidebar default width override (a bit wider for longer titles) */
:root { --sidebar-w: 260px; }

/* Small draggable resize handle at 50% height on right edge of sidebar */
.sidebar { position: relative; }
.sidebar-resizer {
  position: absolute;
  top: 50%; right: -14px;
  transform: translateY(-50%);
  width: 22px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  cursor: col-resize;
  z-index: 50;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #6B7280;
  opacity: 1;
  transition: color 0.15s;
}
.sidebar-resizer { color: #B5BAC4; }
.sidebar-resizer::before {
  content: "";
  width: 9px; height: 17px;
  background-image:
    radial-gradient(circle at center, currentColor 1.3px, transparent 1.7px),
    radial-gradient(circle at center, currentColor 1.3px, transparent 1.7px);
  background-size: 5px 6px;
  background-position: 0 50%, 5px 50%;
  background-repeat: repeat-y;
}
.sidebar-resizer:hover,
.sidebar-resizer.dragging { color: #4F6EF7; }
body.col-resizing,
body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

/* (old save-indicator rules removed — see .page-float-group .save-indicator) */

/* Breadcrumb home icon */
.bc-home { display: inline-flex; align-items: center; padding: 2px 4px; }
.bc-home svg { display: block; }

/* Page-info (i) button + save indicator — top-right inside the white paper card */
.content-with-detail { position: relative; }
.page-float-group {
  position: absolute;
  top: 20px; right: 32px;
  z-index: 30;
  display: inline-flex; align-items: center; gap: 0;
}
.page-info-float {
  position: static !important;
  background: transparent;
  border: 0;
  color: var(--text-muted);
}
.page-info-float:hover { background: rgba(79,110,247,0.10); color: var(--brand); }

/* Save indicator: icon(s) + transient label
   States (via JS):
     .unsaved     → amber clock icon + "Saving…" text
     .show-saved  → green tick icon  + "Saved" text
     .show-tick   → green tick icon only (final resting state)
*/
.page-float-group .save-indicator {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500; color: var(--text-muted);
  padding: 0; overflow: hidden;
}
.page-float-group .save-text {
  display: inline-block;
  max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap;
  transition: max-width .3s ease, opacity .2s ease;
}
.page-float-group .save-indicator.unsaved .save-text,
.page-float-group .save-indicator.show-saved .save-text {
  max-width: 90px; opacity: 1;
}
.page-float-group .save-icon-dirty,
.page-float-group .save-icon-saved,
.page-float-group .save-icon-saving {
  display: inline-flex; align-items: center; justify-content: center;
  width: 0; height: 20px; opacity: 0; overflow: hidden;
  background: transparent;
  transition: width .3s ease, opacity .2s ease;
}
.page-float-group .save-icon-dirty svg,
.page-float-group .save-icon-saved svg,
.page-float-group .save-icon-saving svg { flex-shrink: 0; }
.page-float-group .save-indicator.dirty .save-icon-dirty {
  width: 20px; opacity: 1; color: #B45309;
}
.page-float-group .save-indicator.unsaved {
  color: #B45309;
}
.page-float-group .save-indicator.unsaved .save-icon-saving {
  width: 20px; opacity: 1; color: #B45309;
}
.page-float-group .save-indicator.show-saved,
.page-float-group .save-indicator.show-tick {
  color: #15803D;
}
.page-float-group .save-indicator.show-saved .save-icon-saved,
.page-float-group .save-indicator.show-tick  .save-icon-saved {
  width: 20px; opacity: 1; color: #15803D;
}

/* Search — slightly translucent so gradient peeks through */
.search-input-fake {
  background: rgba(255,255,255,0.70);
  border: 1px solid rgba(180,190,220,0.45);
  backdrop-filter: blur(4px);
}
.search-input-fake:hover { background: rgba(255,255,255,0.90); }

/* +New button stays solid blue */

/* Section labels & items: no white panel, just text on gradient */
.sidebar-page-link:hover,
.tree-folder-header:hover,
.tree-page:hover { background: rgba(255,255,255,0.55); }
.sidebar-page-link.active,
.tree-page:has(.tree-page-link.active) { background: var(--brand-light); }

/* Topbar — transparent (sits on gradient), no border */
.topbar {
  background: transparent !important;
  border-bottom: none !important;
  padding: 14px 28px 12px;
  height: auto; min-height: 56px;
}

/* Topbar buttons are fully ghosted — no white bg override */

/* Floating bubble toolbar (appears on text selection) */
.bubble-toolbar {
  position: fixed;
  z-index: 1000;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.08);
  font-family: 'Open Sans', -apple-system, sans-serif;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.bubble-toolbar.visible {
  display: inline-flex;
  opacity: 1;
  transform: translateY(0);
}
.bubble-toolbar .bb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #1F2937;
  font-size: 14px;
  cursor: pointer;
}
.bubble-toolbar .bb-btn:hover { background: #F3F4F6; }
.bubble-toolbar .bb-btn.active { background: #EEF2FF; color: #4F6EF7; }
.bubble-toolbar .bb-sep {
  width: 1px;
  height: 18px;
  background: #E5E7EB;
  margin: 0 4px;
}
.bubble-toolbar .bb-format {
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
}
.bb-format-wrap { position: relative; display: inline-flex; }
.bb-format-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  padding: 4px;
  min-width: 170px;
  z-index: 1001;
}
.bb-format-menu.open { display: block; }
.bb-format-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  font-family: 'Open Sans', -apple-system, sans-serif;
  color: #1F2937;
  cursor: pointer;
  line-height: 1.25;
}
.bb-format-menu button:hover { background: #F3F4F6; }
/* Preview each option at its actual rendered size so the dropdown reads
   like a real style picker (Normal regular, H1 largest, etc.) */
.bb-format-menu button.fmt-p     { font-size: 14px; font-weight: 400; }
.bb-format-menu button.fmt-small { font-size: 11px; font-weight: 400; color: #6B7280; }
.bb-format-menu button.fmt-h3    { font-size: 15px; font-weight: 600; }
.bb-format-menu button.fmt-h2    { font-size: 18px; font-weight: 600; }
.bb-format-menu button.fmt-h1    { font-size: 22px; font-weight: 700; }

/* Inline "small text" / fine-print styling inside the editor and view.
   Use absolute units + normal weight so it stays small even when the user
   applies it inside a heading or other bold/large block. */
.editor-body small,
.view-content small {
  font-size: 11px !important;
  font-weight: 400 !important;
  color: #6B7280 !important;
  line-height: 1.4;
  letter-spacing: 0.01em;
}

/* Paper card — only top corners rounded, close to top, large + tall.
   Top padding sets the gap between the topbar and the card (previously a
   14px pad offset by a -9px margin hack on .content-area; collapsed to a
   single 5px pad here). */
.content-with-detail {
  padding: 5px 24px 0 24px;
  gap: 0;
  flex: 1; min-height: 0;
}
.content-with-detail:has(.detail-panel.collapsed) { gap: 0; }

.content-area {
  background: #fbfbfb;
  border-radius: 14px 14px 0 0 !important;
  box-shadow: 0 -1px 4px var(--brand-tint), 0 -1px 2px var(--brand-tint);
  border: 2px solid white;
  border-bottom: none;
  overflow-y: auto;
  /* Keep this scroller from rubber-banding (which would reveal its own near-
     white background in the gap) and from chaining its scroll to the page. */
  overscroll-behavior: none;
}
/* The tinted content-area shadow reads as muddy against the gradient theme
   backgrounds — drop it for those themes so the card sits cleanly. */
html[data-theme="dream"] .content-area,
html[data-theme="mist"] .content-area,
html[data-theme="lagoon"] .content-area,
html[data-theme="coral"] .content-area {
  box-shadow: none;
}

/* Slightly tighter inner padding (25% less L/R) */
.editor-wrapper, .view-wrapper { padding: 56px 42px 80px; }
.dashboard-home { padding: 40px 42px 80px; }

/* Sticky toolbar — pinned to the top of the editor scroll area, full-width
   white background so content scrolls beneath it cleanly. */
.editor-wrapper { position: relative; }
.editor-toolbar {
  position: sticky !important;
  top: 0 !important;
  left: 0;
  right: 0;
  /* margin-bottom gives clearance between the toolbar and the title/content;
     extra padding-bottom extends the white sticky band so content scrolling
     behind it always stays at least 10px clear of the buttons */
  margin: 0 0 14px !important;
  background: #fbfbfb !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  /* top padding pushes the button row down to align with the floating
     (i) info + save indicator on the right; bottom padding keeps content
     scrolling underneath at least 10px clear of the buttons */
  padding: 16px 0 20px !important;
  z-index: 20;
  flex-wrap: nowrap !important;
}
/* No extra wrapper padding-top — toolbar provides its own top space via
   padding so its button row centres with the (i) + save indicator on the right */
.editor-wrapper { padding-top: 0 !important; }

/* Editable area — no border in any state */
.editor-body,
.editor-body:focus {
  border: none !important;
  padding: 14px 0 !important;
}

/* List styling — apply to both edit and view modes */
.editor-body ul, .editor-body ol,
.view-content ul, .view-content ol {
  margin: 16px 0 !important;
  padding-left: 36px !important;
}
.editor-body li, .view-content li {
  margin: 2px 0 !important;
  line-height: 1.45 !important;
}
.editor-body li > p, .view-content li > p { margin: 0 !important; }

/* ── Detail panel: proper right-edge drawer, flush to the side ── */
.detail-panel {
  position: fixed !important;
  top: 0; right: 0; bottom: 0;
  width: 320px; min-width: 320px;
  height: auto !important;
  margin-top: 0 !important;
  background: white;
  border: none !important;
  border-left: 1px solid var(--border) !important;
  border-radius: 0 !important;
  box-shadow: -8px 0 24px rgba(30,40,80,0.06);
  z-index: 400;
  transform: translateX(0);
  transition: transform .25s ease;
  overflow-y: auto;
}
.detail-panel.collapsed {
  transform: translateX(100%);
  pointer-events: none;
  width: 320px !important; min-width: 320px !important;
}

/* Mobile tweaks */
@media (max-width: 768px) {
  .content-with-detail { padding: 0 10px; }
  .detail-panel { width: 86vw !important; min-width: 0 !important; }
}

/* ── Mobile ──────────────────────────────────────────*/
@media (max-width: 768px) {
  .icon-rail { display: none; }
  .detail-panel { display: none; }

  /* Tree becomes a slide-out drawer: hidden off-canvas by default (no JS needed,
     so there is no flash of an overlapping sidebar on first paint).
     The themed desktop sidebar is transparent + fixed-width via !important, so the
     drawer overrides those with !important to be an opaque, full-height panel that
     actually covers the page content underneath it. */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    height: 100vh !important; margin-top: 0 !important;
    z-index: 1000;
    width: min(86vw, 320px) !important;
    min-width: 0 !important; max-width: none !important; flex: none !important;
    transform: translateX(-100%);
    background: var(--bg-white) !important;
    border-right: 1px solid var(--border) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
  }
  /* Neutralise the desktop collapse rule so it can't fight the drawer state. */
  .sidebar.collapsed { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 4px 0 28px rgba(15,23,42,0.28) !important; }

  .sidebar-backdrop { display: block; z-index: 999; }
  body.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  body.sidebar-open { overflow: hidden; }

  /* The drag-to-resize handle is meaningless on touch. */
  .sidebar-resizer { display: none; }

  /* The drawer toggle is hidden in the desktop design; on mobile it's the only
     way to open the slide-out tree, so show it with a bigger tap target. */
  .topbar-collapse-btn { display: flex !important; width: 40px; height: 40px; }
  /* Show a "menu/open" chevron pointing right (drawer opens from the left). */
  .topbar-collapse-btn .ico-collapse { display: none; }
  .topbar-collapse-btn .ico-expand { display: block; }
  body.sidebar-open .topbar-collapse-btn .ico-collapse { display: block; }
  body.sidebar-open .topbar-collapse-btn .ico-expand { display: none; }

  /* Read-only on mobile: hide every create / edit / manage affordance. */
  .section-actions,
  .item-actions,
  .sidebar-empty .btn-ghost-sm,
  #newFolderBtn, #newPageBtn,
  #dashCreateFolder, #dashCreatePage,
  .btn-share,
  .page-menu-wrap,
  .user-menu .user-menu-item[href="/settings"],
  .user-menu .user-menu-item[href="/settings#members"],
  .user-menu .user-menu-item[href="/trash"],
  .empty-content a[href*="mode=edit"] { display: none !important; }

  .editor-wrapper, .view-wrapper, .dashboard-home { padding: 22px 20px 60px; }
  .page-title-input, .view-title { font-size: 24px; }
  .topbar { padding: 0 14px; }
  .content-with-detail { padding: 0 12px 12px; }
}

/* ── Settings page ─────────────────────────────────── */
body.settings-page {
  display: block;
  overflow-y: auto;
}
.settings-shell {
  min-height: 100vh;
  display: block;
  width: 100%;
}
.settings-topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  max-width: 820px;
  margin: 0 auto;
}
.settings-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none;
  font-size: 13px; font-weight: 500;
  padding: 6px 10px; border-radius: 8px;
  transition: background .12s, color .12s;
}
.settings-back:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.settings-topbar-spacer { flex: 1; }

/* Single white card containing both nav + pane */
.settings-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  background: white;
  border: 1px solid rgba(220,225,240,0.7);
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.04);
  width: 820px;
  margin: 8px auto 48px;
  min-height: 540px;
  overflow: hidden;
}

.settings-nav-pane {
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  background: #FBFBFD;
}
.settings-card-title {
  font-size: 17px; font-weight: 700; color: var(--text);
  padding: 4px 10px 16px;
}
.settings-nav-group-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 14px 10px 6px;
}
.settings-nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px; font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.settings-nav-item:hover { background: rgba(0,0,0,0.04); color: var(--text); }
.settings-nav-item.active {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 600;
}
.settings-nav-item svg { flex-shrink: 0; }

.settings-pane { padding: 26px 30px 32px; }
.settings-panel { display: none; }
.settings-panel.active { display: block; }
.settings-pane-header { margin-bottom: 18px; }
.settings-pane-title {
  font-size: 18px; font-weight: 600; color: var(--text);
  margin: 0 0 4px;
}
.settings-pane-help {
  font-size: 13px; color: var(--text-muted);
  margin: 0;
}

/* Grid layouts for pickers on settings page */
.theme-picker-grid,
.font-picker-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}
/* Section headers inside the theme grid — span all columns */
.theme-group-label {
  grid-column: 1 / -1;
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-faint);
  padding: 4px 2px 2px;
  margin-top: 4px;
}
.theme-group-label:first-child { margin-top: 0; }


.btn-secondary {
  display: inline-flex; align-items: center;
  white-space: nowrap;
  padding: 9px 16px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.btn-secondary:hover { background: var(--brand-light); border-color: var(--brand-tint); color: var(--brand-dark); }

/* Settings forms */
.settings-form { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.settings-field-label {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.settings-input {
  padding: 10px 12px;
  font-family: inherit; font-size: 14px;
  color: var(--text);
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .12s, box-shadow .12s;
}
.settings-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-shadow), 0.15);
}
.settings-form-row { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 18px;
  background: var(--brand); color: white;
  border: none; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .12s, opacity .12s;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.settings-form-status { font-size: 13px; color: var(--text-muted); }
.settings-form-status.ok { color: #2F8F5C; }
.settings-form-status.err { color: #C0392B; }

/* Storage usage panel */
.storage-card {
  border: 1px solid var(--border);
  border-radius: var(--card-radius, 12px);
  padding: 22px;
  background: var(--bg-white);
}
.storage-stat-row {
  display: flex;
  gap: 36px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.storage-stat { display: flex; flex-direction: column; gap: 3px; }
.storage-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.storage-stat-label { font-size: 12.5px; color: var(--text-muted); }
.storage-bar {
  height: 12px;
  background: var(--brand-light);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.storage-bar-fill {
  height: 100%;
  min-width: 2px;
  background: var(--brand);
  border-radius: 999px;
  transition: width .35s ease;
}
.storage-bar-fill.warn { background: var(--warning); }
.storage-bar-fill.danger { background: var(--danger); }
.storage-foot { margin-top: 12px; font-size: 13px; color: var(--text-muted); }

/* ── Find / Replace bar (edit mode) ─────────────────────────────────────────
   Floating panel pinned top-right, like a browser's native find. Highlights
   are drawn with the CSS Custom Highlight API so the editor DOM is never
   mutated for matches (only real replacements change content). */
.find-bar {
  position: fixed;
  top: 68px; right: 34px;
  z-index: 500;
  display: flex; flex-direction: column; gap: 6px;
  width: 340px;
  padding: 8px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(15,23,42,0.14), 0 2px 6px rgba(15,23,42,0.08);
}
.find-bar[hidden] { display: none; }
.find-row { display: flex; align-items: center; gap: 6px; }
.find-input {
  flex: 1; min-width: 0;
  height: 30px; padding: 0 10px;
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
}
.find-input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-shadow), 0.15);
}
.find-count {
  font-size: 12px; color: var(--text-muted);
  min-width: 46px; text-align: center; white-space: nowrap;
}
.find-nav, .find-opt, .find-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0;
  background: transparent; color: var(--text-muted);
  border: 1px solid transparent; border-radius: 6px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.find-nav:hover, .find-opt:hover, .find-close:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.find-opt {
  font-size: 12px; font-weight: 700; width: auto; padding: 0 8px;
}
.find-opt[aria-pressed="true"] {
  background: var(--brand-light); color: var(--brand); border-color: var(--brand-tint);
}
.find-btn {
  height: 30px; padding: 0 12px;
  font-family: inherit; font-size: 13px; font-weight: 500; white-space: nowrap;
  color: var(--text); background: var(--bg-white);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.find-btn:hover { background: var(--bg); border-color: var(--brand); }
.find-btn:disabled, .find-nav:disabled { opacity: .45; cursor: default; }
.find-btn:disabled:hover { background: var(--bg-white); border-color: var(--border); }

::highlight(find-match)   { background: #fff1a8; color: inherit; }
::highlight(find-current) { background: #ff9f43; color: #1a1a1a; }

/* ── Members panel ───────────────────────────────────────────────────────── */
.members-subhead {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin: 22px 0 10px;
}
.members-invite { margin-bottom: 8px; }
.invite-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.invite-email { flex: 1; min-width: 220px; }
.invite-role { min-width: 130px; }
.invite-status { font-size: 13px; color: var(--text-muted); margin-top: 8px; min-height: 18px; }
.invite-status.ok { color: #2F8F5C; }
.invite-status.err { color: #C0392B; }
.invite-link-box {
  margin-top: 10px; padding: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
.invite-link-label { font-size: 12px; color: var(--text-muted); margin: 0 0 8px; }
.invite-link-row { display: flex; gap: 8px; }
.invite-link-row .settings-input { flex: 1; font-size: 12px; }

.members-list { display: flex; flex-direction: column; gap: 8px; }
.member-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px;
  background: var(--bg-white); border: 1px solid var(--border); border-radius: 10px;
}
.member-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.member-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--brand-light); color: var(--brand-dark);
  font-size: 13px; font-weight: 700;
}
.member-avatar.invite-avatar { background: var(--bg); color: var(--text-muted); }
.member-meta { min-width: 0; }
.member-name { font-size: 14px; font-weight: 600; color: var(--text); }
.member-you { font-weight: 400; color: var(--text-faint); font-size: 12px; }
.member-email { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.member-role-select { padding: 7px 10px; font-size: 13px; }
.member-role-static { font-size: 13px; color: var(--text-muted); font-weight: 500; padding-right: 6px; }
.member-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: transparent; color: var(--text-faint);
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  transition: background .12s, color .12s;
}
.member-remove:hover { background: rgba(192,57,43,0.08); color: #C0392B; }

/* ── Trash ───────────────────────────────────────────────────────────────── */
.trash-shell { max-width: 720px; margin: 0 auto; padding: 24px 0 60px; }
.trash-list { display: flex; flex-direction: column; gap: 8px; }
.trash-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-white); border: 1px solid var(--border); border-radius: 10px;
}
.trash-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.trash-identity .item-icon { color: var(--text-muted); flex-shrink: 0; }
.trash-meta { min-width: 0; }
.trash-name { font-size: 14px; font-weight: 600; color: var(--text); }
.trash-sub { font-size: 12px; color: var(--text-faint); }
.trash-empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 60px 20px; color: var(--text-faint); text-align: center;
}

/* ── Role badge in user menu ─────────────────────────────────────────────── */
.um-role-badge {
  margin: 8px 14px 4px;
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--brand-dark); background: var(--brand-light);
  border-radius: 6px;
}

.um-ws-switcher { padding: 4px 0; }
.um-section-label {
  margin: 6px 14px 2px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
}
.um-ws-item {
  width: 100%;
  background: none; border: none; cursor: pointer;
  text-align: left; font: inherit;
}
.um-ws-item .um-ws-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.um-ws-item .um-ws-role {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); flex-shrink: 0;
}
.um-ws-item.is-active { font-weight: 600; color: var(--brand-dark); }
.um-ws-item.is-active svg { color: var(--brand-dark); }
.um-ws-item:disabled { opacity: 0.6; cursor: default; }

/* ── Tags ──────────────────────────────────────────────────────────────────── */
.tag-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 2px 0 14px;
}
.tag-row-edit { margin-top: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--brand-light); color: var(--brand-dark);
  border: 1px solid var(--brand-tint);
  font-size: 12px; font-weight: 500; line-height: 1;
  padding: 5px 9px; border-radius: 999px; white-space: nowrap;
}
a.tag-chip-link { transition: background .12s, border-color .12s; }
a.tag-chip-link:hover { background: var(--brand-tint); border-color: var(--brand); }
.tag-chip-sm { font-size: 11px; padding: 3px 7px; }
.tag-chip-lg { font-size: 15px; padding: 6px 13px; vertical-align: middle; }
.tag-chip-x {
  background: none; border: none; cursor: pointer; padding: 0;
  color: var(--brand); font-size: 14px; line-height: 1;
  display: flex; align-items: center; opacity: 0.6; transition: opacity .12s;
}
.tag-chip-x:hover { opacity: 1; }
.tag-add-btn {
  background: none; border: 1px dashed var(--border-dark); cursor: pointer;
  color: var(--text-muted); font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: 999px; transition: color .12s, border-color .12s, background .12s;
}
.tag-add-btn:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-light); }
.tag-input-wrap { position: relative; display: inline-flex; }
.tag-input {
  border: 1px solid var(--brand); border-radius: 999px;
  padding: 4px 11px; font-size: 12px; min-width: 120px;
  background: white; outline: none; box-shadow: 0 0 0 3px rgba(var(--brand-shadow), 0.15);
}
.tag-ac-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50;
  background: white; border: 1px solid var(--border); border-radius: 9px;
  box-shadow: var(--shadow-md); padding: 4px; min-width: 160px;
  display: flex; flex-direction: column; gap: 1px;
}
.tag-ac-menu[hidden] { display: none; }
.tag-ac-item {
  background: none; border: none; text-align: left; cursor: pointer;
  padding: 6px 9px; border-radius: 6px; font-size: 13px; color: var(--text);
}
.tag-ac-item:hover, .tag-ac-item.active { background: var(--brand-light); color: var(--brand-dark); }

/* Sidebar tags */
.sidebar-tags { display: flex; flex-direction: column; gap: 1px; }
.sidebar-tag {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 8px; border-radius: 6px; font-size: 13px; color: var(--text-muted);
  transition: background .12s, color .12s;
}
.sidebar-tag:hover { background: var(--brand-light); color: var(--brand-dark); }
.sidebar-tag.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.sidebar-tag-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-tag-name::before { content: "#"; color: var(--text-faint); margin-right: 2px; }
.sidebar-tag-count {
  flex-shrink: 0; font-size: 11px; color: var(--text-faint);
  background: var(--border); border-radius: 999px; padding: 1px 7px; min-width: 18px; text-align: center;
}
.sidebar-tag.active .sidebar-tag-count { background: var(--brand-tint); color: var(--brand-dark); }
.sidebar-tag.tag-hidden { display: none; }
.sidebar-tag-more {
  background: none; border: none; cursor: pointer; text-align: left;
  color: var(--brand); font-size: 12px; font-weight: 500; padding: 6px 8px; border-radius: 6px;
}
.sidebar-tag-more:hover { background: var(--brand-light); }

/* Tag results view */
.tag-results-head { margin-bottom: 22px; }
.tag-results-back {
  display: inline-block; color: var(--text-muted); font-size: 13px; margin-bottom: 12px;
}
.tag-results-back:hover { color: var(--brand); }
.tag-results-head h1 { font-size: 26px; font-weight: 700; }
.tag-results-count { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* Search result tags */
.search-result-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 8px; vertical-align: middle; }
