:root,
:root[data-theme="dark"] {
  --bg-0: #0d1117;
  --bg-1: #161b22;
  --bg-2: #21262d;
  --bg-3: #30363d;
  --fg-0: #f0f6fc;
  --fg-1: #c9d1d9;
  --fg-2: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --success: #2ea043;
  --warning: #f0883e;
  --danger: #f85149;
  --folder: #ff9500;
  --image: #00e676;
  --video: #ffea00;
  --audio: #00b0ff;
  --doc: #448aff;
  --archive: #ff5252;
  --other: #b0bec5;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --tooltip-bg: rgba(13,17,23,0.96);
  --legend-bg: rgba(13,17,23,0.85);
  --selected-bg: rgba(88,166,255,0.2);
  --toast-shadow: 0 8px 32px rgba(0,0,0,0.6);
  --list-row-border: rgba(48,54,61,0.4);
  --scrollbar: #30363d;
  --scrollbar-hover: #484f58;
  color-scheme: dark;
}

/* Light theme: flip neutrals, keep accents (they're tuned for both).
   Touches every CSS variable so the whole UI adapts without component edits. */
:root[data-theme="light"] {
  --bg-0: #ffffff;
  --bg-1: #f6f8fa;
  --bg-2: #eaeef2;
  --bg-3: #d0d7de;
  --fg-0: #1f2328;
  --fg-1: #424a53;
  --fg-2: #656d76;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --success: #1a7f37;
  --warning: #9a6700;
  --danger: #cf222e;
  --folder: #bf8700;
  --shadow: 0 4px 24px rgba(0,0,0,0.12);
  --tooltip-bg: rgba(255,255,255,0.97);
  --legend-bg: rgba(255,255,255,0.9);
  --selected-bg: rgba(9,105,218,0.12);
  --toast-shadow: 0 8px 32px rgba(0,0,0,0.12);
  --list-row-border: rgba(208,215,222,0.6);
  --scrollbar: #d0d7de;
  --scrollbar-hover: #afb8c1;
  color-scheme: light;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-0);
  color: var(--fg-1);
  height: 100vh;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.hidden { display: none !important; }

/* Header */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--bg-3);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 1.1rem; font-weight: 600; color: var(--fg-0); }
.logo { color: var(--accent); display: flex; align-items: center; }
.logo.large svg { width: 64px; height: 64px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* Buttons */
button { cursor: pointer; border: none; font-size: 0.85rem; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary {
  background: var(--success); color: #fff; padding: 7px 14px;
  border-radius: var(--radius); font-weight: 500;
}
.btn-primary:hover { filter: brightness(1.15); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }
.btn-secondary {
  background: var(--bg-2); color: var(--fg-1); padding: 7px 12px;
  border: 1px solid var(--bg-3); border-radius: var(--radius);
}
.btn-secondary:hover { background: var(--bg-3); }
.btn-ghost { background: transparent; color: var(--fg-2); padding: 6px 10px; }
.btn-ghost:hover { color: var(--fg-0); }
.btn-danger {
  background: var(--danger); color: #fff; padding: 7px 12px;
  border-radius: var(--radius); font-weight: 500;
}
.btn-danger:hover { filter: brightness(1.15); }
.btn-icon {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--bg-2); color: var(--fg-2);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--bg-3);
}
.btn-icon:hover { background: var(--bg-3); color: var(--fg-0); }
.btn-toggle {
  padding: 6px 12px; border-radius: 6px;
  background: transparent; color: var(--fg-2);
  border: 1px solid transparent;
  font-size: 0.82rem;
}
.btn-toggle.active { background: var(--bg-2); color: var(--fg-0); border-color: var(--bg-3); }
.full { width: 100%; justify-content: center; }

/* Toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 16px; background: var(--bg-1);
  border-bottom: 1px solid var(--bg-3);
}
.toolbar-group { display: flex; gap: 6px; align-items: center; }
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.search-wrap input {
  width: 100%; padding: 7px 28px 7px 12px;
  background: var(--bg-0); color: var(--fg-1);
  border: 1px solid var(--bg-3); border-radius: var(--radius);
  font-size: 0.85rem; outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap .btn-icon {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border: none; background: none; font-size: 1rem;
}

/* Progress */
#progress-area { padding: 0 16px 10px; background: var(--bg-1); }
.progress-track { width: 100%; height: 4px; background: var(--bg-2); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 2px; transition: width 0.25s ease; }
.status-text { font-size: 0.8rem; color: var(--fg-2); margin-top: 6px; }

/* Stats */
.stats-bar {
  display: flex; gap: 8px; padding: 8px 16px;
  background: var(--bg-1); border-bottom: 1px solid var(--bg-3);
  overflow-x: auto;
}
.stat-chip {
  font-size: 0.8rem; color: var(--fg-2);
  background: var(--bg-2); padding: 3px 10px;
  border-radius: 12px; white-space: nowrap;
}
.size-highlight { color: var(--accent); font-weight: 600; }

/* Content */
.content {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
#main { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* Breadcrumbs */
.breadcrumbs {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--bg-0);
  border-bottom: 1px solid var(--bg-3);
  font-size: 0.85rem; flex-shrink: 0;
}
.crumbs { display: flex; align-items: center; gap: 4px; overflow: hidden; }
.crumbs .crumb {
  color: var(--accent); cursor: pointer; padding: 2px 6px; border-radius: 4px;
  white-space: nowrap;
}
.crumbs .crumb:hover { background: var(--bg-2); text-decoration: underline; }
.crumbs .crumb:last-child { color: var(--fg-0); cursor: default; text-decoration: none; }
.crumbs .crumb:last-child:hover { background: transparent; }
.crumbs .sep { color: var(--fg-2); font-size: 0.75rem; }

/* Main pane: vertical stack (list on top, divider, treemap on bottom) */
.main-pane {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}
.main-pane.treemap-hidden #view-treemap,
.main-pane.treemap-hidden #pane-divider { display: none; }
.main-pane.treemap-hidden #view-list { flex: 1 1 auto; }

/* List pane (top) — now split horizontally: tree (2/3) + details sidebar (1/3) */
#view-list {
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--bg-0);
  min-height: 80px;
  flex: 0 0 auto;
  height: 45%;
}
.list-pane-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: row;
  overflow: hidden;
}
.list-main {
  flex: 2 1 0; min-width: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.list-sidebar {
  flex: 1 1 0; min-width: 240px; max-width: 420px;
  display: flex; flex-direction: column;
  background: var(--bg-1);
  border-left: 1px solid var(--bg-3);
  overflow: hidden;
}

/* Draggable divider */
.pane-divider {
  flex: 0 0 6px;
  background: var(--bg-1);
  border-top: 1px solid var(--bg-3);
  border-bottom: 1px solid var(--bg-3);
  cursor: row-resize;
  position: relative;
  user-select: none;
  transition: background 0.15s ease;
}
.pane-divider:hover, .pane-divider.dragging { background: var(--accent); }
.pane-divider-grip {
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 32px; height: 2px;
  background: var(--fg-2);
  border-radius: 1px;
  opacity: 0.5;
  pointer-events: none;
}
.pane-divider:hover .pane-divider-grip,
.pane-divider.dragging .pane-divider-grip { background: #fff; opacity: 1; }

/* Treemap pane (bottom) */
#view-treemap {
  flex: 1 1 auto;
  min-height: 80px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.treemap-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--bg-3);
  flex-shrink: 0;
}
.treemap-title { font-size: 0.82rem; color: var(--fg-2); font-weight: 500; }
.treemap-hint { color: var(--fg-2); opacity: 0.6; font-weight: 400; margin-left: 6px; font-size: 0.72rem; }

/* Treemap body: single area now (sidebar moved to the list pane above) */
.treemap-body {
  flex: 1; min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg-1);
}
#treemap { display: block; width: 100%; height: 100%; cursor: crosshair; }

/* Tooltip (hover) */
.tooltip {
  position: absolute; pointer-events: none;
  background: var(--tooltip-bg); border: 1px solid var(--bg-3);
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 0.8rem; color: var(--fg-1); display: none; z-index: 20;
  max-width: 340px; box-shadow: var(--toast-shadow);
  line-height: 1.5;
  backdrop-filter: blur(6px);
}
.tooltip .tt-title { font-weight: 700; color: var(--fg-0); margin-bottom: 6px; word-break: break-word; font-size: 0.92rem; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 24px; color: var(--fg-2); margin-top: 3px; }
.tooltip .tt-size { color: var(--accent-hover); font-weight: 700; }

/* Details sidebar (now on list pane) */
.list-sidebar .info-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--bg-3);
  flex-shrink: 0;
  min-height: 40px;
}
.list-sidebar .info-card-header h3 {
  font-size: 0.88rem; font-weight: 600; color: var(--fg-0);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-sidebar .info-card-body {
  padding: 12px 14px; overflow-y: auto;
  font-size: 0.82rem; flex: 1;
}
.list-sidebar .info-card-body .detail-group { margin-bottom: 12px; }
.list-sidebar .info-card-body .detail-group:last-child { margin-bottom: 0; }
.list-sidebar .detail-label {
  font-size: 0.68rem; color: var(--fg-2);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.list-sidebar .detail-value {
  color: var(--fg-0); word-break: break-word; line-height: 1.4;
}
.list-sidebar .detail-value.size {
  font-size: 1.15rem; font-weight: 700; color: var(--accent);
}
.list-sidebar .detail-value.type {
  color: var(--fg-1); display: flex; align-items: center;
}
.list-sidebar .detail-pct { font-size: 0.74rem; color: var(--fg-2); margin-top: 2px; }
.list-sidebar .detail-id {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.7rem; color: var(--fg-2);
  word-break: break-all;
}
.list-sidebar .info-card-actions {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px; border-top: 1px solid var(--bg-3);
  flex-shrink: 0;
}
.list-sidebar .info-card-actions .btn-secondary,
.list-sidebar .info-card-actions .btn-danger {
  width: 100%; justify-content: center; padding: 7px 12px; font-size: 0.82rem;
}
.info-card-empty {
  color: var(--fg-2); font-style: italic; text-align: center;
  padding: 24px 8px; line-height: 1.5;
}
.type-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.detail-preview {
  width: 100%; aspect-ratio: 16 / 10;
  background: var(--bg-0) center / contain no-repeat;
  border: 1px solid var(--bg-3); border-radius: 6px;
  margin-bottom: 10px;
}
.folder-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: var(--folder); color: #000; font-size: 0.68rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  margin-left: 6px;
}

/* Legend */
.legend {
  position: absolute; bottom: 10px; left: 10px;
  display: flex; flex-wrap: wrap; gap: 10px;
  background: var(--legend-bg); padding: 6px 10px;
  border-radius: 6px; border: 1px solid var(--bg-3);
  font-size: 0.72rem; color: var(--fg-2);
  z-index: 5; pointer-events: none;
  max-width: calc(100% - 20px);
  backdrop-filter: blur(6px);
}
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* List */
.view { display: flex; flex-direction: column; overflow: hidden; }

.list-header, .list-row {
  display: grid;
  grid-template-columns: 1fr 96px 140px 140px 140px;
  gap: 10px; padding: 6px 16px; align-items: center;
  font-size: 0.82rem; border-bottom: 1px solid var(--bg-3);
}
.list-header .sortable { cursor: pointer; user-select: none; }
.list-header .sortable:hover { color: var(--fg-0); }
.list-header .sortable.asc::after { content: " ↑"; color: var(--accent); }
.list-header .sortable.desc::after { content: " ↓"; color: var(--accent); }
.list-header {
  background: var(--bg-1); color: var(--fg-2); font-weight: 600;
  position: sticky; top: 0; z-index: 2;
  flex-shrink: 0;
}
.list-body {
  overflow-y: auto; flex: 1; contain: strict;
  /* subtle fade at bottom so half-clipped rows read as "scroll more" */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 16px), transparent 100%);
}
.list-body::after {
  /* tiny spacer so the last row is never half-clipped */
  content: ''; display: block; height: 8px; flex-shrink: 0;
}

.list-row { color: var(--fg-1); cursor: pointer; border-bottom: 1px solid var(--list-row-border); }
.list-row:hover { background: var(--bg-2); }
.list-row.selected { background: var(--selected-bg); }
.list-row.folder .col-name { color: var(--fg-0); font-weight: 500; }

.list-row .col-name {
  display: flex; align-items: center; gap: 6px;
  overflow: hidden; min-width: 0;
}
/* Tree expand/collapse control */
.tree-indent { display: inline-block; flex-shrink: 0; }
.tree-toggle {
  width: 16px; height: 16px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--bg-3); border-radius: 3px;
  background: var(--bg-2); color: var(--fg-1);
  font-size: 0.78rem; font-weight: 700; line-height: 1;
  cursor: pointer; user-select: none;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}
.tree-toggle:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.tree-toggle.placeholder {
  border: none; background: none; cursor: default; visibility: hidden;
}
.list-row .name-dot {
  width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}
.list-row .name-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.col-size { text-align: right; font-variant-numeric: tabular-nums; color: var(--fg-0); }
.col-pct { display: flex; align-items: center; gap: 6px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.pct-bar {
  flex: 1; height: 6px; background: var(--bg-2); border-radius: 3px;
  overflow: hidden; min-width: 30px;
}
.pct-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.pct-num { font-size: 0.72rem; min-width: 38px; text-align: right; }

.col-type, .col-date { color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Intro */
.intro {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  min-height: 0;
}
.intro-card {
  text-align: center; max-width: 420px;
  background: var(--bg-1); padding: 40px 32px;
  border-radius: var(--radius); border: 1px solid var(--bg-3);
}
.intro-card h2 { margin: 16px 0 8px; font-size: 1.4rem; color: var(--fg-0); }
.intro-card p { color: var(--fg-2); line-height: 1.5; margin-bottom: 8px; }
.intro-card .sub { font-size: 0.8rem; color: var(--fg-2); opacity: 0.7; }

/* ==========================================================================
   Demo mode strip — shown above the main view when synthetic data is loaded
   ========================================================================== */
.demo-strip {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 18%, var(--bg-1)), var(--bg-1));
  border-bottom: 1px solid var(--bg-3);
  font-size: 0.85rem; color: var(--fg-1);
  flex-shrink: 0;
  padding-left: calc(16px + env(safe-area-inset-left, 0px));
  padding-right: calc(16px + env(safe-area-inset-right, 0px));
}
.demo-strip.hidden { display: none; }
.demo-strip .demo-text { flex: 1; line-height: 1.4; }
.demo-strip .demo-text strong { color: var(--fg-0); letter-spacing: 0.01em; }
.demo-strip .demo-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
  animation: demoPulse 2s ease-in-out infinite;
}
.demo-strip .btn-demo-cta { flex-shrink: 0; }
.demo-strip .demo-dismiss {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--fg-2);
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 1.1rem; line-height: 1; cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.demo-strip .demo-dismiss:hover {
  background: var(--bg-2); color: var(--fg-0); border-color: var(--bg-3);
}
.demo-strip .demo-dismiss:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
@keyframes demoPulse {
  0%, 100% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 10%, transparent); }
}
@media (max-width: 640px) {
  .demo-strip { flex-wrap: wrap; padding: 10px 12px; }
  .demo-strip .demo-text { font-size: 0.8rem; flex-basis: 100%; }
  .demo-strip .btn-demo-cta { width: 100%; }
}

/* Toast */
.toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-1); color: var(--fg-1);
  border: 1px solid var(--bg-3); border-radius: var(--radius);
  padding: 10px 16px; font-size: 0.85rem;
  box-shadow: var(--shadow); pointer-events: auto;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 320px; word-break: break-word;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* While dragging the divider, prevent text selection everywhere */
body.dragging-divider { user-select: none; cursor: row-resize !important; }
body.dragging-divider * { cursor: row-resize !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* Responsive: narrow viewports — app-like mobile layout */
@media (max-width: 720px) {
  :root { --radius: 10px; }

  body { -webkit-tap-highlight-color: transparent; }

  /* Header: trim padding, shrink brand on very small screens */
  .app-header {
    padding: 0 12px;
    padding-top: env(safe-area-inset-top, 0);
    height: calc(52px + env(safe-area-inset-top, 0px));
  }
  .brand h1 { font-size: 1rem; }

  /* Toolbar: single stacked row, search below, bigger tap targets */
  .toolbar {
    padding: 8px 10px; gap: 6px;
  }
  .toolbar-group { flex-wrap: wrap; }
  .search-wrap { flex: 1 1 100%; max-width: none; order: 10; }
  .btn-primary, .btn-secondary, .btn-toggle {
    padding: 9px 12px; font-size: 0.85rem;
  }
  /* Hide the desktop treemap toggle — mobile uses the tab bar instead */
  #btn-toggle-treemap { display: none; }

  /* Stats: scrollable chip row */
  .stats-bar { padding: 6px 10px; gap: 6px; }
  .stat-chip { font-size: 0.75rem; padding: 4px 10px; }

  /* Breadcrumbs: single line, horizontally scrollable */
  .breadcrumbs { padding: 6px 10px; font-size: 0.8rem; }
  .crumbs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .crumbs::-webkit-scrollbar { display: none; }

  /* Main pane: single stage driven by data-mobile-view (NOT column split) */
  .main-pane {
    flex: 1; min-height: 0;
    display: block;
    position: relative;
  }
  .pane-divider { display: none; }

  /* Each view is a full-stage absolute panel; only the active one shows */
  #view-list, #view-treemap {
    position: absolute; inset: 0;
    height: auto !important;
    flex: none;
    display: flex;
  }
  .main-pane[data-mobile-view="list"] #view-treemap { display: none; }
  .main-pane[data-mobile-view="treemap"] #view-list { display: none; }
  /* Treemap is always "visible" in mobile mode — tab bar controls it, not the desktop toggle */
  .main-pane.treemap-hidden #view-treemap { display: none; }
  .main-pane.treemap-hidden[data-mobile-view="treemap"] #view-list { display: flex; }

  /* List pane: full bleed, no side sidebar */
  .list-pane-body { flex-direction: column; }
  .list-main { flex: 1 1 auto; }
  .list-header, .list-row {
    grid-template-columns: 1fr 90px 56px;
    gap: 8px; padding: 10px 12px;
    font-size: 0.88rem;
  }
  .col-type, .col-date { display: none; }
  /* Simplify the percent column to a compact number */
  .col-pct .pct-bar { display: none; }
  .col-pct { justify-content: flex-end; }
  .col-pct .pct-num { min-width: 0; font-size: 0.78rem; }

  /* Bigger tree toggle on mobile — easier thumb target */
  .tree-toggle { width: 22px; height: 22px; font-size: 0.9rem; }

  /* Details: slide-up sheet from the bottom, not a side column */
  .list-sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: auto;
    max-width: none; min-width: 0;
    flex: none; height: auto;
    max-height: 80vh;
    border-left: none;
    border-top: 1px solid var(--bg-3);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    background: var(--bg-1);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.6);
    transform: translateY(100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .list-sidebar.sheet-open { transform: translateY(0); }
  /* Grab handle at the top of the sheet */
  .list-sidebar::before {
    content: ''; display: block;
    width: 40px; height: 4px;
    background: var(--bg-3); border-radius: 2px;
    margin: 8px auto 0;
  }
  .list-sidebar .info-card-header { padding: 10px 16px; }
  .list-sidebar .info-card-header h3 { font-size: 1rem; }
  .btn-close-details { display: inline-flex !important; }
  .list-sidebar .info-card-body { padding: 14px 16px; font-size: 0.88rem; }
  .list-sidebar .info-card-actions {
    flex-direction: row; padding: 12px 16px 16px;
  }
  .list-sidebar .info-card-actions .btn-secondary,
  .list-sidebar .info-card-actions .btn-danger {
    padding: 11px 12px; font-size: 0.88rem;
  }

  /* Treemap pane: hide header + legend on mobile (tab bar already labels it) */
  .treemap-header { display: none; }
  .legend { display: none; }

  /* Mobile tab bar */
  .mobile-tabs {
    display: flex;
    position: sticky; bottom: 0;
    background: var(--bg-1);
    border-top: 1px solid var(--bg-3);
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom, 0);
    flex-shrink: 0;
  }
  .mobile-tab {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 2px;
    padding: 8px 4px;
    background: transparent;
    color: var(--fg-2);
    font-size: 0.7rem; font-weight: 500;
    border: none; border-top: 2px solid transparent;
    min-height: 52px;
  }
  .mobile-tab.active { color: var(--accent); border-top-color: var(--accent); }
  .mobile-tab svg { stroke-width: 2; }

  /* Intro card: full bleed */
  .intro { padding: 16px; }
  .intro-card { padding: 32px 20px; }
}

/* By default the close-details button is only visible in the mobile sheet */
.btn-close-details { display: none; }

/* Desktop fallback for 720 < viewport <= 960: keep column stack for list/sidebar */
@media (min-width: 721px) and (max-width: 960px) {
  .list-header, .list-row { grid-template-columns: 1fr 80px 100px; }
  .col-type, .col-date { display: none; }
  .list-pane-body { flex-direction: column; }
  .list-sidebar {
    flex: 0 0 200px; min-width: 0; max-width: none;
    border-left: none; border-top: 1px solid var(--bg-3);
  }
  .list-sidebar .info-card-actions { flex-direction: row; }
  .legend { display: none; }
}

/* ==========================================================================
   Theme toggle button
   ========================================================================== */
.btn-theme { width: 32px; height: 32px; }
.btn-theme .icon-theme-dark,
.btn-theme .icon-theme-light { display: none; }
:root[data-theme="dark"] .btn-theme .icon-theme-light { display: inline-block; }
:root[data-theme="light"] .btn-theme .icon-theme-dark { display: inline-block; }

/* ==========================================================================
   Intro features list
   ========================================================================== */
.intro-features {
  list-style: none; padding: 0; margin: 16px 0 0;
  text-align: left; display: flex; flex-direction: column; gap: 6px;
}
.intro-features li {
  color: var(--fg-1); font-size: 0.85rem; line-height: 1.45;
  padding-left: 22px; position: relative;
}
.intro-features li::before {
  content: '✓'; position: absolute; left: 4px; top: 0;
  color: var(--success); font-weight: 700;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-1);
  border-top: 1px solid var(--bg-3);
  font-size: 0.78rem; color: var(--fg-2);
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}
.app-footer a { color: var(--fg-2); text-decoration: none; }
.app-footer a:hover { color: var(--accent); text-decoration: underline; }
.app-footer .footer-sep { opacity: 0.5; }

@media (max-width: 720px) {
  .app-footer { display: none; } /* mobile uses tab bar; legal links stay in intro */
}

/* ==========================================================================
   Cookie / storage notice (bottom banner)
   ========================================================================== */
.cookie-notice {
  position: fixed;
  left: 16px; right: 16px; bottom: 16px;
  z-index: 9999;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  background: var(--bg-1);
  border: 1px solid var(--bg-3);
  border-radius: var(--radius);
  box-shadow: var(--toast-shadow);
  color: var(--fg-1);
  font-size: 0.85rem;
  line-height: 1.45;
  max-width: 820px;
  margin: 0 auto;
  animation: cookieSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.cookie-notice-body { flex: 1; min-width: 0; }
.cookie-notice-body strong { color: var(--fg-0); display: block; margin-bottom: 2px; font-weight: 600; }
.cookie-notice-body a { color: var(--accent); text-decoration: none; margin-left: 4px; }
.cookie-notice-body a:hover { text-decoration: underline; }
.cookie-notice .btn-primary { flex-shrink: 0; padding: 8px 16px; }
@keyframes cookieSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  .cookie-notice {
    left: 8px; right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px) + 60px); /* above tab bar */
    flex-direction: column; align-items: stretch;
    gap: 10px; padding: 12px 14px;
  }
  .cookie-notice .btn-primary { width: 100%; justify-content: center; }
}

/* ==========================================================================
   Static legal pages (privacy, terms) — shared layout
   ========================================================================== */
body.legal-page {
  height: auto; overflow: auto; min-height: 100vh;
  background: var(--bg-0); color: var(--fg-1);
}
body.legal-page #app { height: auto; min-height: 100vh; }
.legal-container {
  max-width: 780px; margin: 0 auto;
  padding: 32px 24px 80px;
}
.legal-container h1 {
  font-size: 1.8rem; color: var(--fg-0); margin-bottom: 6px; font-weight: 600;
}
.legal-container .legal-updated {
  color: var(--fg-2); font-size: 0.85rem; margin-bottom: 28px;
}
.legal-container h2 {
  color: var(--fg-0); font-size: 1.2rem; font-weight: 600;
  margin: 28px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--bg-3);
}
.legal-container h3 {
  color: var(--fg-0); font-size: 1rem; font-weight: 600;
  margin: 20px 0 8px;
}
.legal-container p, .legal-container li {
  color: var(--fg-1); line-height: 1.65; margin-bottom: 10px;
  font-size: 0.95rem;
}
.legal-container ul { padding-left: 22px; margin-bottom: 12px; }
.legal-container a { color: var(--accent); text-decoration: none; }
.legal-container a:hover { text-decoration: underline; }
.legal-container code {
  background: var(--bg-2); color: var(--fg-0);
  padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.88em;
}
.legal-container .legal-back {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--fg-2); margin-bottom: 16px;
  font-size: 0.88rem;
}
.legal-container .legal-back:hover { color: var(--accent); }
.legal-container .legal-toc {
  background: var(--bg-1); border: 1px solid var(--bg-3);
  border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 24px;
}
.legal-container .legal-toc h3 {
  margin: 0 0 8px; font-size: 0.9rem; color: var(--fg-2);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.legal-container .legal-toc ul { padding-left: 18px; margin: 0; }
.legal-container .legal-toc li { margin-bottom: 2px; font-size: 0.88rem; }
