/* App layout */

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text-1);
}

/* === NAV (52px) === */
.nav {
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  background: var(--nav-bg);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
}
.nav-brand svg { width: 26px; height: 26px; }

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-tab {
  height: 32px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  border-radius: var(--r-md);
  transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.nav-tab:hover { background: var(--surface-3); color: var(--text-2); }
.nav-tab.active { color: var(--blue); font-weight: 600; }
.nav-tab:active { transform: scale(0.97); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: var(--r-md);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.nav-link:hover { background: var(--surface-3); color: var(--text-2); }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #2563EB);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.02em;
}

/* === BODY (sidebar + main) === */
.body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* === SIDEBAR === */
.sidebar {
  width: 224px;
  background: var(--bg);
  border-right: 0.5px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sb-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sb-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 12px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sb-label .add-btn {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  color: var(--text-4);
  transition: background-color var(--t-fast), color var(--t-fast);
}
.sb-label .add-btn:hover { background: var(--surface-3); color: var(--text-2); }

.sb-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border-radius: var(--r-md);
  transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
  cursor: pointer;
}
.sb-item:hover { background: var(--surface-2); }
.sb-item.active {
  background: var(--blue-bg);
  color: var(--blue-text);
  font-weight: 600;
}
.sb-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 2px;
  background: var(--blue);
}
.sb-item:active { transform: scale(0.99); }
.sb-item .count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-4);
  font-feature-settings: 'tnum';
}
.sb-item.active .count { color: var(--blue-text); opacity: 0.7; }
.sb-item .dot {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.sb-item .icon { color: var(--text-3); }
.sb-item.active .icon { color: var(--blue); }

.sb-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 0.5px solid var(--border-sub);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sb-footer .sb-item {
  font-size: 12px;
  color: var(--text-4);
  height: 26px;
}

/* === MAIN === */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.main-inner {
  max-width: 920px;
  margin: 0 auto;
}
.main-inner.wide { max-width: 1200px; }

/* === PAGE HEADER === */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text-1);
  margin: 0;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-3);
  margin: 4px 0 0;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* === STATS === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: box-shadow var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.stat:hover { box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-num {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-1);
  font-feature-settings: 'tnum';
  line-height: 1.1;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* === MEDIA TABS === */
.media-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 14px;
  padding: 0 4px;
}
.media-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  transition: color var(--t-fast);
}
.media-tab:hover { color: var(--text-2); }
.media-tab.active { color: var(--blue); font-weight: 600; }
.media-tab.active::after {
  content: '';
  position: absolute;
  left: 12px; right: 12px;
  bottom: -0.5px;
  height: 2px;
  background: var(--blue);
  border-radius: 2px 2px 0 0;
}
.media-tab .badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--surface-3);
  color: var(--text-3);
  border-radius: 4px;
  padding: 1px 5px;
  font-feature-settings: 'tnum';
}
.media-tab.active .badge { background: var(--blue-bg); color: var(--blue-text); }

/* === LIST TOOLBAR === */
.list-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.list-toolbar .grow { flex: 1; }

/* === BOOKMARK LIST === */
.bookmark-list {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.bookmark-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--row-py) var(--row-px);
  border-bottom: 0.5px solid var(--border-sub);
  position: relative;
  cursor: pointer;
  transition: background-color var(--t-fast);
  animation: fadeUp var(--t-base) var(--ease) both;
}
.bookmark-row:last-child { border-bottom: none; }
.bookmark-row:hover { background: var(--surface-2); }
.bookmark-row:hover .b-title { color: var(--blue); }
.bookmark-row:hover .b-checkbox,
.bookmark-row:hover .b-actions { opacity: 1; }
.bookmark-row.selected { background: var(--select-bg); }
.bookmark-row.selected .b-checkbox { opacity: 1; }

.b-checkbox {
  width: 18px; height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--check-border);
  background: var(--surface);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--t-fast), background-color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.b-checkbox.checked {
  background: var(--blue);
  border-color: var(--blue);
  opacity: 1;
}
.b-checkbox.checked svg { width: 10px; height: 10px; stroke: white; stroke-width: 3; }
.b-checkbox:active { transform: scale(0.9); }

.b-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border-radius: var(--r-lg);
  background: var(--surface-3);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  font-family: 'DM Mono', monospace;
  letter-spacing: -0.02em;
  position: relative;
  overflow: hidden;
}

.b-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.b-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.b-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--t-fast);
  letter-spacing: -0.01em;
}
.b-domain {
  font-size: 11px;
  color: var(--text-4);
  flex-shrink: 0;
}
.b-desc {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.b-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  flex-wrap: wrap;
}
.b-meta-sep { color: var(--text-4); font-size: 10px; }

.b-side {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.b-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.b-action {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  color: var(--text-4);
  transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.b-action:hover { background: var(--surface-3); color: var(--text-2); }
.b-action.danger:hover { background: var(--red-bg); color: var(--red-text); }
.b-action:active { transform: scale(0.92); }

.b-time {
  font-size: 11px;
  color: var(--text-4);
  font-feature-settings: 'tnum';
  margin-right: 4px;
}

/* === BULK BAR === */
.bulk-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1E293B;
  color: white;
  border-radius: 14px;
  padding: 8px 8px 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-bulk);
  z-index: 300;
  animation: slideUp var(--t-slow) var(--ease) both;
}
[data-theme="dark"] .bulk-bar { background: var(--blue); }
.bulk-bar .count {
  font-size: 13px;
  font-weight: 600;
}
.bulk-bar .vdiv { background: rgba(255,255,255,0.2); height: 20px; }
.bulk-bar .bk-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  background: rgba(255,255,255,0.15);
  color: white;
  transition: background-color var(--t-fast), transform var(--t-fast);
}
.bulk-bar .bk-btn:hover { background: rgba(255,255,255,0.25); }
.bulk-bar .bk-btn:active { transform: scale(0.95); }
.bulk-bar .bk-btn.danger { background: rgba(239,68,68,0.3); }
.bulk-bar .bk-btn.danger:hover { background: rgba(239,68,68,0.5); }

/* === EMPTY === */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: var(--surface-3);
  margin: 0 auto 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-4);
}
.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0 0 4px;
}
.empty-sub {
  font-size: 13px;
  color: var(--text-3);
  margin: 0 0 20px;
}

/* === MODAL === */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: fadeIn var(--t-base) var(--ease) both;
}
[data-theme="dark"] .modal-backdrop { background: rgba(0,0,0,0.6); }
.modal {
  width: 540px;
  max-width: calc(100% - 32px);
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md), 0 20px 60px rgba(0,0,0,0.15);
  overflow: hidden;
  animation: fadeUp var(--t-slow) var(--ease) both;
}
[data-theme="dark"] .modal { box-shadow: var(--shadow-md), 0 20px 60px rgba(0,0,0,0.5); }

/* === COMMAND PALETTE === */
.cmdk {
  width: 580px;
  max-width: calc(100% - 32px);
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md), 0 20px 60px rgba(0,0,0,0.15);
  overflow: hidden;
  animation: fadeUp var(--t-slow) var(--ease) both;
}
.cmdk-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--border-sub);
}
.cmdk-input-row .icon { color: var(--text-3); }
.cmdk-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text-1);
}
.cmdk-input-row input::placeholder { color: var(--text-4); }
.cmdk-list { max-height: 380px; overflow-y: auto; padding: 8px; }
.cmdk-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 12px 4px;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
  transition: background-color var(--t-fast);
  cursor: pointer;
}
.cmdk-item.active, .cmdk-item:hover { background: var(--surface-3); color: var(--text-1); }
.cmdk-item .icon { color: var(--text-3); }
.cmdk-item.active .icon { color: var(--blue); }
.cmdk-item-label { flex: 1; }
.cmdk-item-meta { font-size: 11px; color: var(--text-4); }

.cmdk-footer {
  border-top: 0.5px solid var(--border-sub);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-4);
}
.cmdk-footer .hints { display: flex; gap: 12px; align-items: center; }
.cmdk-footer .hint { display: inline-flex; align-items: center; gap: 4px; }

/* === Sidebar nesting === */
.sb-chevron {
  width: 14px; height: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; padding: 0; cursor: pointer;
  color: var(--text-4);
  border-radius: 3px;
  margin-right: 2px;
  flex-shrink: 0;
}
.sb-chevron:hover { background: var(--surface-3); color: var(--text-2); }
.sb-chevron-spacer { display: inline-block; width: 14px; flex-shrink: 0; margin-right: 2px; }
.sb-children {
  display: flex; flex-direction: column; gap: 1px;
  margin-left: 14px;
  border-left: 1px solid var(--border-sub);
  padding-left: 4px;
  margin-top: 1px;
  margin-bottom: 2px;
}
.sb-item.sb-child {
  font-size: 12px;
  padding: 5px 10px 5px 8px;
  color: var(--text-3);
}
.sb-item.sb-child .dot { width: 6px; height: 6px; }

/* === View toggle === */
.view-toggle {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: 8px;
  padding: 2px;
  gap: 0;
}
.vt-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 0;
  font: inherit;
  font-size: 12px; font-weight: 600;
  color: var(--text-3);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.vt-btn:hover { color: var(--text-2); }
.vt-btn.active {
  background: var(--surface);
  color: var(--text-1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* === Bookmarks table === */
.bk-table-wrap {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.bk-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.bk-table thead {
  background: var(--surface-2);
}
.bk-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 9px 12px;
  border-bottom: 0.5px solid var(--border);
  white-space: nowrap;
}
.bk-th-check { width: 36px; padding: 9px 8px 9px 14px !important; }
.bk-th-title { min-width: 280px; }
.bk-th-type { width: 80px; }
.bk-th-coll { width: 160px; }
.bk-th-tags { width: 160px; }
.bk-th-status { width: 90px; }
.bk-th-date { width: 80px; }
.bk-th-actions { width: 90px; }

.bk-tr {
  cursor: pointer;
  animation: fadeUp var(--t-base) var(--ease) both;
  transition: background-color var(--t-fast) var(--ease);
}
.bk-tr:hover { background: var(--surface-2); }
.bk-tr:hover .bk-title-text { color: var(--blue); }
.bk-tr:hover .b-checkbox:not(.always-visible) { opacity: 1; }
.bk-tr:hover .bk-row-actions { opacity: 1; }
.bk-tr.selected { background: var(--select-bg); }
.bk-tr.selected .b-checkbox { opacity: 1; }
.bk-tr td {
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--border-sub);
  vertical-align: middle;
}
.bk-tr:last-child td { border-bottom: 0; }

.bk-td-check { padding: 8px 8px 8px 14px !important; }
.bk-td-check .b-checkbox { opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.bk-td-check .b-checkbox.always-visible { opacity: 1; }

.bk-title-cell {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.bk-table-thumb {
  width: 32px; height: 32px;
  border-radius: 7px;
  font-size: 11px;
  flex-shrink: 0;
}
.bk-title-stack {
  min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.bk-title-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
  transition: color var(--t-fast) var(--ease);
  letter-spacing: -0.005em;
}
.bk-domain-text {
  font-size: 11px;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.bk-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
}
.bk-type-chip .icon { color: var(--text-4); }

.bk-tag-row {
  display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden;
}
.bk-tag-row .tag {
  white-space: nowrap;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bk-tag-row .tag-more {
  background: var(--surface-3);
  color: var(--text-4);
}

.bk-td-date {
  font-size: 11px;
  color: var(--text-4);
  font-feature-settings: 'tnum';
  white-space: nowrap;
}

.bk-row-actions {
  display: flex; gap: 1px;
  opacity: 0;
  justify-content: flex-end;
  transition: opacity var(--t-fast) var(--ease);
}

/* checkbox indeterminate (select all) */
.b-checkbox .dash {
  display: block; width: 8px; height: 1.5px;
  background: var(--blue);
  border-radius: 1px;
}
.b-checkbox.indeterminate {
  border-color: var(--blue);
  background: var(--blue-bg);
}
.b-checkbox.always-visible { opacity: 1 !important; }

/* === Pagination === */
.bk-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 4px 4px;
  flex-wrap: wrap;
}
.bk-pagination-info {
  font-size: 12px;
  color: var(--text-3);
}
.bk-pagination-info strong {
  color: var(--text-2);
  font-weight: 600;
  font-feature-settings: 'tnum';
}
.bk-pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.pg-btn, .pg-num {
  background: transparent;
  border: 0.5px solid transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
  min-width: 30px;
  font-feature-settings: 'tnum';
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.pg-btn:hover:not(:disabled), .pg-num:hover {
  background: var(--surface-2);
  color: var(--text-1);
}
.pg-btn:disabled {
  opacity: 0.4; cursor: not-allowed;
}
.pg-num.active {
  background: var(--blue-bg);
  color: var(--blue-text);
  font-weight: 600;
}
.pg-ellipsis {
  font-size: 12px;
  color: var(--text-4);
  padding: 0 4px;
}

/* Compact density for table */
[data-density="compact"] .bk-tr td { padding: 5px 12px; }
[data-density="compact"] .bk-table-thumb { width: 26px; height: 26px; font-size: 9px; }
[data-density="compact"] .bk-domain-text { display: none; }

/* === Nested chips on collection cards === */
.nested-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-3);
  border: 0.5px solid transparent;
  border-radius: 5px;
  padding: 2px 6px 2px 5px;
  cursor: pointer;
  font-family: inherit;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.nested-chip:hover {
  background: var(--surface);
  border-color: var(--chip-color, var(--blue));
  color: var(--text-1);
}
.nested-chip .dot { width:7px; height:7px; border-radius:2px; }
.nested-chip-count {
  font-size: 9px;
  color: var(--text-4);
  font-weight: 600;
  font-feature-settings: 'tnum';
  margin-left: 1px;
}
.nested-chip-more {
  background: transparent;
  color: var(--text-4);
  cursor: default;
}

/* === Accordion view === */
.acc-row {
  border-bottom: 0.5px solid var(--border-sub);
}
.acc-row:last-child { border-bottom: 0; }

.acc-parent {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 8px;
  transition: background-color var(--t-fast) var(--ease);
}
.acc-parent:hover { background: var(--surface-2); }

.acc-chevron {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; padding: 0; cursor: pointer;
  color: var(--text-4);
  border-radius: 5px;
  flex-shrink: 0;
}
.acc-chevron:hover { background: var(--surface-3); color: var(--text-2); }

.acc-name-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  text-align: left;
  font: inherit;
  color: inherit;
}
.acc-name-btn.child {
  gap: 9px;
}
.acc-folder {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.acc-folder.small {
  width: 26px; height: 26px;
  border-radius: 7px;
}
.acc-name-stack {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0; flex: 1;
}
.acc-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.005em;
  transition: color var(--t-fast) var(--ease);
}
.acc-name.child-name { font-size: 12px; }
.acc-name-btn:hover .acc-name { color: var(--blue); }
.acc-meta {
  font-size: 11px;
  color: var(--text-4);
}
.acc-meta span { color: var(--text-3); }

.acc-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.acc-children-count {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface-3);
  border-radius: 5px;
  padding: 2px 6px;
  font-feature-settings: 'tnum';
}
.acc-bookmark-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  font-feature-settings: 'tnum';
  min-width: 28px;
  text-align: right;
  padding-right: 4px;
}

.acc-children {
  background: var(--surface-2);
  padding: 2px 0;
  animation: fadeUp 160ms var(--ease) both;
}
.acc-child {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 8px 50px;
  position: relative;
  transition: background-color var(--t-fast) var(--ease);
}
.acc-child:hover { background: var(--surface-3); }
.acc-child-rail {
  position: absolute;
  left: 21px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

/* =====================================================
   MOBILE HAMBURGER + DRAWER
   ===================================================== */

.nav-hamburger {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  color: var(--text-2);
  flex-shrink: 0;
  transition: background-color var(--t-fast);
}
.nav-hamburger:hover { background: var(--surface-3); }

/* Drawer overlay */
.mob-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
}
.mob-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* Drawer panel */
.mob-panel {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: min(320px, 88vw);
  background: var(--bg);
  border-left: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  animation: mob-slide-in 0.2s var(--ease);
}
@keyframes mob-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* Drawer header */
.mob-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 52px;
  border-bottom: 0.5px solid var(--border);
  flex-shrink: 0;
}
.mob-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}

/* Tab switcher */
.mob-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 12px 12px 4px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  flex-shrink: 0;
}
.mob-tab {
  flex: 1;
  padding: 6px;
  border-radius: calc(var(--r-md) - 2px);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  text-align: center;
  transition: background-color var(--t-fast), color var(--t-fast);
  cursor: pointer;
}
.mob-tab.active {
  background: var(--bg);
  color: var(--text-1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Drawer scrollable body */
.mob-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

/* Section */
.mob-section { margin-bottom: 16px; }
.mob-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 12px 4px;
}
.mob-divider {
  height: 0.5px;
  background: var(--border-sub);
  margin: 0 0 12px;
}

/* Nav items inside drawer */
.mob-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  transition: background-color var(--t-fast), color var(--t-fast);
}
.mob-nav-item:hover { background: var(--surface-2); }
.mob-nav-item.active {
  background: var(--blue-bg);
  color: var(--blue-text);
  font-weight: 600;
}
.mob-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  flex-shrink: 0;
}
.mob-nav-item.active .mob-nav-icon { background: var(--blue-bg); }
.mob-soon {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-4);
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Drawer footer */
.mob-footer {
  border-top: 0.5px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.mob-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-top: 2px;
}
.mob-profile-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}

/* === PAGE SECTION CHIP === */
.page-section-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
  padding: 3px 8px;
  border-radius: 6px;
}
.page-section-chip.chip-primary {
  color: var(--blue);
  background: var(--blue-bg);
}
.page-section-chip.chip-muted {
  color: var(--text-4);
  background: var(--surface-3);
}

/* =====================================================
   RESPONSIVE BREAKPOINTS
   ===================================================== */

@media (max-width: 768px) {
  /* Hide desktop nav tabs and sidebar */
  .nav-tabs { display: none; }
  .sidebar  { display: none; }

  /* Hide non-essential nav-right items */
  .nav-link          { display: none !important; }
  .troveai-trigger   { display: none; }
  .vdiv              { display: none; }

  /* Show hamburger */
  .nav-hamburger { display: flex; }

  /* Tighten nav padding on small screens */
  .nav { padding: 0 12px; }

  /* Main content takes full width and gets sensible padding */
  .main { padding: 16px; }

  /* ── PAGE HEADER: title first, actions below ── */
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-actions { flex-wrap: wrap; }

  /* Fix view dropdown to open rightward on mobile instead of going off-screen */
  .view-dropdown-menu { right: auto; left: 0; }
  .hide-mobile    { display: none !important; }

  /* ── STATS CARDS: 2-column, icon top-left, text expands ── */
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }
  .stat {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
  }
  .stat-icon {
    width: 24px !important;
    height: 24px !important;
    border-radius: 6px !important;
  }
  .stat-icon svg,
  .stat-icon .icon { width: 13px !important; height: 13px !important; }
  .stat-num { font-size: 20px; }
  .stat-label { font-size: 10px; }

  /* ── CATCHUP MEDIA TABS: horizontal scroll ── */
  .catchup-tabs-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .catchup-tabs-bar::-webkit-scrollbar { display: none; }
  .catchup-tabs-bar > button { flex-shrink: 0; }

  /* ── LIST TOOLBAR: hide spacer and select-all ── */
  .list-toolbar .grow    { display: none; }
  .list-select-all       { display: none; }
  .list-toolbar .search  { max-width: none; flex: 1; }

  /* ── BOOKMARK ROWS: mobile-friendly layout ── */
  .b-checkbox { display: none; }
  .b-actions  { display: none; }
  .b-title    { white-space: normal; line-height: 1.35; }
  .b-desc {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .b-side {
    align-self: flex-start;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
  }
  .b-time { margin-right: 0; }

  /* ── COLLECTIONS GRID: single column ── */
  .collections-grid { grid-template-columns: 1fr !important; }

  /* ── COMMUNITY PAGE: horizontal carousel ── */
  .community-grid {
    display: flex !important;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 12px !important;
    padding-bottom: 24px !important;
    /* bleed to right edge so last card isn't clipped */
    padding-right: 16px;
    margin-right: -16px;
  }
  .community-grid::-webkit-scrollbar { display: none; }
  .community-grid > .card {
    flex: 0 0 260px;
    scroll-snap-align: start;
  }

  /* ── COMMUNITY CATEGORY PILLS: horizontal scroll ── */
  .community-cat-pills {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px !important;
  }
  .community-cat-pills::-webkit-scrollbar { display: none; }
  .community-cat-pills > button { flex-shrink: 0; }

  /* === Insights (knowledge map) === */
  .km-canvas { position: relative; }
  /* Reduce SVG height on mobile so the legend/detail aren't crammed */
  .km-svg { height: 420px !important; }

  /* Toolbar: stack rows so the long info chip and Work/Personal toggle don't overflow */
  .km-toolbar {
    top: 10px !important;
    left: 10px !important;
    right: 10px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    pointer-events: none;
  }
  .km-toolbar > * { pointer-events: auto; max-width: 100%; }
  .km-toolbar > div:first-child {
    font-size: 10px !important;
    white-space: normal;
  }

  /* Move the zoom buttons to the bottom-right so they don't fight the toolbar */
  .km-zoom {
    top: auto !important;
    bottom: 10px !important;
    right: 10px !important;
  }

  /* Hide the legend on small screens — too noisy for the available space */
  .km-legend { display: none !important; }

  /* Detail panel: full-width sheet anchored to the bottom of the canvas */
  .km-detail {
    width: auto !important;
    left: 10px !important;
    right: 10px !important;
    bottom: 56px !important;
  }

  /* AI insights cards: 1 column on mobile */
  .km-insights-grid {
    grid-template-columns: 1fr !important;
  }
}
.acc-child .acc-name-btn { flex: 1; }
