/* mindex SPA — dark navigation L, light reader.
   Color schemes (coal/paper/carbon/inverse/cream) reassign --d-* and --r-*
   variables at runtime. Reader styles reassign --reader-* variables.
   Both pickers are CSS-variable swaps, no remount.

   Defaults (the `coal` scheme + `editorial` style) are written here so the
   page renders correctly before JS runs.
*/

:root {
  /* Reader (coal default) */
  --r-bg:        #ffffff;
  --r-bg-soft:   #f7f7f6;
  --r-text:      #1a1a1a;
  --r-text-soft: #5a5a5a;
  --r-text-mute: #999999;
  --r-border:    #e6e4e0;
  --r-code-bg:   #f3f1ed;

  /* Callout bar colors (5 GitHub-flavored types) */
  --r-callout-note-bar:      #5a8aaa;
  --r-callout-tip-bar:       #5a8a5a;
  --r-callout-important-bar: #9a6aa8;
  --r-callout-warning-bar:   #c08a3e;
  --r-callout-caution-bar:   #c0644e;

  /* Navigation L (coal default) */
  --d-bg:        #1a1a1a;
  --d-bg-elev:   #161616;
  --d-bg-hover:  #232323;
  --d-bg-active: #2a2a2a;
  --d-text:      #e8e6e1;
  --d-text-soft: #8e8a82;
  --d-text-mute: #5a5751;
  --d-border:    #2a2a2a;
  --d-rule:      #232323;
  --danger:      #d4685a;
  --warn:        #c08a3e;

  --sidebar-w:   272px;

  /* Reader style (editorial default) */
  --reader-display:        "Instrument Serif", Georgia, serif;
  --reader-display-style:  normal;
  --reader-body:           "Source Serif 4", Charter, Georgia, serif;
  --reader-mono:           "Geist Mono", ui-monospace, monospace;
  --reader-h1-size:        46px;
  --reader-h1-weight:      400;
  --reader-h2-size:        22px;
  --reader-h2-weight:      600;
  --reader-h3-size:        17px;
  --reader-h3-weight:      600;
  --reader-body-size:      18px;
  --reader-line-height:    1.65;
  --reader-letter-spacing: -0.005em;
}

* { box-sizing: border-box; }
html, body, #root, .root { height: 100%; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--r-text);
  background: var(--r-bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ─────────────────────  Auth / landing screens (preserved)  ───────────────────── */
.screen-center {
  height: 100vh;
  background: var(--r-bg);
  display: flex; align-items: center; justify-content: center;
}
.auth-block { width: 320px; }
.wordmark {
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: 26px;
  line-height: 1;
  color: var(--r-text);
  letter-spacing: -0.005em;
  user-select: none;
}
.tagline {
  font-size: 14px;
  font-weight: 400;
  color: var(--r-text-soft);
  margin-top: 8px;
}
.btn-primary, .btn-secondary {
  width: 100%; height: 40px;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0;
}
.btn-primary { background: #1a1a1a; color: #ffffff; }
.btn-primary:hover { background: #333333; }
.btn-primary:focus-visible { outline: 2px solid #1a1a1a; outline-offset: 2px; }
.btn-secondary {
  background: #ffffff;
  color: var(--r-text);
  border: 1px solid var(--r-border);
}
.btn-secondary:hover { background: #f5f5f5; }
.btn-secondary:focus-visible { outline: 2px solid #1a1a1a; outline-offset: 2px; }
.legal { font-size: 11px; color: var(--r-text-mute); text-align: center; line-height: 1.5; }
.legal-link { color: var(--r-text-mute); text-decoration: underline; text-decoration-color: var(--r-text-mute); }

.picker-heading { font-size: 16px; font-weight: 600; color: var(--r-text); }
.picker-sub { font-size: 13px; color: var(--r-text-soft); margin-top: 8px; }
.org-list { border: 1px solid var(--r-border); background: var(--r-bg); }
.org-row {
  display: block; width: 100%; text-align: left;
  height: 40px; padding: 0 12px;
  font-size: 14px; font-weight: 500;
  color: var(--r-text); background: var(--r-bg);
  border-bottom: 1px solid var(--r-border);
}
.org-row:last-child { border-bottom: none; }
.org-row:hover { background: var(--r-bg-soft); }

/* ─────────────────────  Workspace shell  ───────────────────── */
.workspace-shell { display: flex; flex-direction: column; height: 100vh; }

/* Topbar */
.topbar {
  height: 48px;
  background: var(--d-bg);
  border-bottom: 1px solid var(--d-border);
  display: flex; align-items: center;
  padding: 0 14px;
  gap: 10px;
  color: var(--d-text);
  flex-shrink: 0;
}
.topbar .wordmark {
  color: var(--d-text);
  margin-right: 4px;
  background: none; border: none; cursor: pointer;
  padding: 0;
}
.topbar .wordmark:hover { opacity: 0.8; }

.nav-arrows { display: flex; align-items: center; gap: 2px; }
.nav-btn {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  color: var(--d-text-soft);
  border-radius: 3px;
}
.nav-btn svg { width: 14px; height: 14px; }
.nav-btn:hover { color: var(--d-text); background: var(--d-bg-hover); }
.nav-btn[disabled] { color: var(--d-text-mute); cursor: default; background: none; }

.crumbs {
  display: flex; align-items: center;
  font-size: 13px;
  color: var(--d-text-soft);
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  margin-left: 4px;
}
.crumb { padding: 3px 6px; color: var(--d-text-soft); white-space: nowrap; border-radius: 3px; }
.crumb:hover { color: var(--d-text); background: var(--d-bg-hover); }
.crumb.is-current { color: var(--d-text); font-weight: 500; }
.crumb.is-current:hover { background: none; cursor: default; }
.crumb-sep { color: var(--d-text-mute); padding: 0 1px; user-select: none; flex-shrink: 0; }

.copy-btn {
  display: flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 9px 0 8px;
  color: var(--d-text-soft); font-size: 12px;
  border-radius: 3px; flex-shrink: 0; margin-left: 4px;
}
.copy-btn svg { width: 13px; height: 13px; }
.copy-btn:hover { color: var(--d-text); background: var(--d-bg-hover); }
.copy-btn.is-copied { color: var(--d-text); }

.spacer { flex: 1 1 auto; }

.palette-btn {
  display: grid; place-items: center;
  width: 26px; height: 26px;
  color: var(--d-text-soft);
  border-radius: 3px; flex-shrink: 0;
}
.palette-btn svg { width: 14px; height: 14px; }
.palette-btn:hover, .palette-btn.is-open { color: var(--d-text); background: var(--d-bg-hover); }

.style-btn {
  display: flex; align-items: center;
  height: 26px; padding: 0 8px;
  color: var(--d-text-soft);
  font-size: 13px;
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic; line-height: 1;
  border-radius: 3px; flex-shrink: 0;
  letter-spacing: 0.01em;
}
.style-btn:hover, .style-btn.is-open { color: var(--d-text); background: var(--d-bg-hover); }
.style-btn .Aa-big   { font-size: 17px; }
.style-btn .Aa-small { font-size: 13px; margin-left: 1px; }

/* Style + scheme popovers (anchored to topbar) */
.style-pop, .scheme-pop {
  position: fixed; top: 52px;
  background: var(--r-bg);
  border: 1px solid var(--r-border);
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.06);
  z-index: 800; overflow: hidden;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease;
  pointer-events: none;
}
.style-pop  { width: 320px; }
.scheme-pop { width: 280px; }
.style-pop.is-open, .scheme-pop.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.style-pop-head, .scheme-pop-head {
  padding: 12px 14px 8px;
  font-size: 11px; font-weight: 600;
  color: var(--r-text-mute);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-family: system-ui, sans-serif;
}
.style-list  { max-height: 70vh; overflow-y: auto; padding: 4px 0 8px; }
.scheme-list { padding: 4px 0 8px; }

.style-row {
  display: block; width: 100%; text-align: left;
  padding: 8px 14px 10px;
  border-top: 1px solid transparent;
  cursor: pointer; position: relative;
}
.style-row:hover { background: var(--r-bg-soft); }
.style-row + .style-row { border-top-color: var(--r-border); }
.style-row.is-current::before {
  content: ""; position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px; background: var(--r-text);
}
.style-name {
  font-size: 22px; line-height: 1.1;
  color: var(--r-text); margin-bottom: 4px;
  letter-spacing: -0.005em;
}
.style-sample { font-size: 13.5px; line-height: 1.5; color: var(--r-text-soft); }
.style-row.is-current .style-name::after {
  content: "✓"; margin-left: 8px;
  font-family: system-ui, sans-serif;
  font-size: 14px; color: var(--r-text-mute);
  vertical-align: 2px;
}

.scheme-row {
  display: flex; align-items: center;
  width: 100%; padding: 9px 14px;
  cursor: pointer; gap: 12px;
  text-align: left;
  border-top: 1px solid transparent;
  position: relative;
}
.scheme-row + .scheme-row { border-top-color: var(--r-border); }
.scheme-row:hover { background: var(--r-bg-soft); }
.scheme-row.is-current::before {
  content: ""; position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 2px; background: var(--r-text);
}
.scheme-swatch {
  width: 32px; height: 22px;
  border-radius: 3px;
  border: 1px solid var(--r-border);
  display: flex; overflow: hidden; flex-shrink: 0;
}
.scheme-swatch span { flex: 1; height: 100%; }
.scheme-meta { flex: 1; min-width: 0; }
.scheme-name {
  font-family: system-ui, sans-serif;
  font-size: 13px; font-weight: 600;
  color: var(--r-text);
}
.scheme-desc {
  font-family: system-ui, sans-serif;
  font-size: 11.5px;
  color: var(--r-text-soft);
  margin-top: 1px;
}
.scheme-row.is-current .scheme-name::after {
  content: "✓"; margin-left: 6px;
  font-size: 12px; color: var(--r-text-mute);
}

/* App grid */
.app-grid {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1; min-height: 0; overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: var(--d-bg);
  color: var(--d-text);
  display: grid;
  /* head | tab row | panes | foot */
  grid-template-rows: 38px 30px 1fr 38px;
  height: 100%;
  position: relative;
  border-right: 1px solid var(--d-border);
  min-width: 0;
  overflow: hidden;
}

.sidebar-head {
  display: flex; align-items: center;
  padding: 0 6px 0 8px;
  border-bottom: 1px solid var(--d-rule);
  position: relative;
  gap: 6px;
}
.sidebar-head .actions { display: flex; gap: 0; margin-left: auto; }
.sidebar-head .act {
  width: 22px; height: 22px;
  color: var(--d-text-mute);
  display: grid; place-items: center;
  border-radius: 3px;
}
.sidebar-head .act svg { width: 12px; height: 12px; }
.sidebar-head .act:hover { color: var(--d-text); background: var(--d-bg-hover); }

/* Workspace switcher */
.ws-switcher {
  display: flex; align-items: center;
  gap: 7px; height: 26px; padding: 0 8px 0 7px;
  color: var(--d-text-soft);
  font-size: 12px;
  font-family: "Geist Mono", ui-monospace, monospace;
  border-radius: 3px;
  flex: 0 1 auto; min-width: 0;
}
.ws-switcher:hover, .ws-switcher.is-open { color: var(--d-text); background: var(--d-bg-hover); }
.ws-switcher .ws-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: #5a8a5a;
  border-radius: 50%;
  flex-shrink: 0;
}
.ws-switcher .ws-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--d-text); font-weight: 500;
}
.ws-switcher .ws-caret {
  width: 10px; height: 10px;
  color: var(--d-text-mute);
  flex-shrink: 0;
  transition: transform .14s ease;
}
.ws-switcher.is-open .ws-caret { transform: rotate(180deg); color: var(--d-text-soft); }
.ws-counts {
  font-size: 10.5px;
  color: var(--d-text-mute);
  font-family: "Geist Mono", ui-monospace, monospace;
  flex-shrink: 0;
}

.ws-pop {
  position: absolute;
  left: 8px; right: 8px;
  top: calc(100% + 4px);
  background: var(--d-bg-elev);
  border: 1px solid var(--d-border);
  border-radius: 5px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.18);
  z-index: 100; overflow: hidden;
  opacity: 0; transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease;
  pointer-events: none;
}
.ws-pop.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.ws-pop-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 9px 11px 7px;
  font-size: 10px; font-weight: 600;
  color: var(--d-text-mute);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-family: system-ui, sans-serif;
  border-bottom: 1px solid var(--d-rule);
}
.ws-pop-list { max-height: 240px; overflow-y: auto; padding: 4px 0; }
.ws-pop-row {
  display: flex; align-items: center;
  width: 100%; padding: 7px 11px;
  color: var(--d-text-soft);
  font-size: 12.5px;
  font-family: "Geist Mono", ui-monospace, monospace;
  text-align: left; cursor: pointer;
  gap: 8px; position: relative;
}
.ws-pop-row:hover { background: var(--d-bg-hover); color: var(--d-text); }
.ws-pop-row .ws-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: #5a8a5a;
  border-radius: 50%;
  flex-shrink: 0;
}
.ws-pop-row.is-current { color: var(--d-text); }
.ws-pop-row.is-current::before {
  content: ""; position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px; background: var(--d-text);
}
.ws-pop-row .ws-pop-meta {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--d-text-mute);
  font-variant-numeric: tabular-nums;
}
.ws-pop-foot {
  display: block; padding: 8px 11px;
  border-top: 1px solid var(--d-rule);
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: var(--d-text-soft);
}
.ws-pop-foot:hover { color: var(--d-text); background: var(--d-bg-hover); }
.ws-pop-search-wrap { padding: 6px 8px; border-bottom: 1px solid var(--d-rule); }
.ws-pop-search { width: 100%; }
.ws-pop-empty { padding: 10px 12px; color: var(--d-text-mute); font-size: 12.5px; }
.ws-pop-row.is-highlight { background: var(--d-bg-hover); }

/* Tree */
.sidebar-tree { overflow-y: auto; overflow-x: hidden; padding: 6px 0 8px; min-width: 0; }
.sidebar-tree::-webkit-scrollbar { width: 8px; }
.sidebar-tree::-webkit-scrollbar-track { background: transparent; }
.sidebar-tree::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 4px; border: 2px solid var(--d-bg); }

/* ── Sidebar tab row (B8) ────────────────────────────────────────── */
.sidebar-tabs {
  display: flex;
  align-items: stretch;
  height: 30px;
  padding: 0 8px;
  border-bottom: 1px solid var(--d-rule);
  gap: 0;
}
.sb-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 0 10px;
  height: 30px;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--d-text-mute);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sb-tab:hover { color: var(--d-text-soft); }
.sb-tab.is-on { color: var(--d-text); border-bottom-color: var(--d-text); }
.sb-tab.is-softened {
  color: var(--d-text-soft);
  border-bottom-color: var(--d-text-soft);
}
.sb-tab-trash { margin-left: auto; }
.sb-tab-badge {
  display: inline-block;
  min-width: 14px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 14px;
  text-align: center;
  color: var(--d-text-mute);
  font-variant-numeric: tabular-nums;
}
.sb-tab.is-on .sb-tab-badge { color: var(--d-text); }

/* ── Sidebar panes (B8) ──────────────────────────────────────────── */
.sidebar-panes {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sidebar-pane {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sidebar-pane[hidden] { display: none; }
.sidebar-pane > .sidebar-tree { flex: 1 1 auto; min-height: 0; }

/* ── Sidebar: Recent tab pane (B8) ───────────────────────────────── */
.sb-recent {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 0 8px;
  font-family: "Geist Mono", ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
}
.sb-recent-empty {
  padding: 16px 12px;
  color: var(--d-text-mute);
  font-size: 12px;
}
.sb-recent-section {
  padding: 10px 12px 4px;
  font-family: system-ui, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--d-text-mute);
}
.sb-recent-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 12px;
  color: var(--d-text-soft);
  text-decoration: none;
  min-width: 0;
}
.sb-recent-row:hover { background: var(--d-bg-hover); color: var(--d-text); }
.sb-recent-row.is-active { color: var(--d-text); background: var(--d-bg-hover); }
.sb-recent-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}
.sb-recent-file {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-recent-path {
  font-size: 10.5px;
  color: var(--d-text-mute);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-recent-when {
  flex-shrink: 0;
  font-size: 10.5px;
  color: var(--d-text-mute);
  font-variant-numeric: tabular-nums;
}

.tree {
  font-family: "Geist Mono", ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.95;
}
.tree-row {
  display: flex; align-items: center;
  padding-right: 10px;
  cursor: pointer; user-select: none;
  /* Suppress the iOS long-press link callout so press-and-hold opens our
     context menu instead of the native preview. */
  -webkit-touch-callout: none;
  color: var(--d-text-soft);
  position: relative; min-width: 0; gap: 6px;
}
.tree-row:hover { color: var(--d-text); background: var(--d-bg-hover); }

.chev {
  width: 10px; height: 10px;
  flex-shrink: 0;
  color: var(--d-text-mute);
  display: grid; place-items: center;
  transition: transform .12s ease;
}
.chev svg { width: 9px; height: 9px; }
.chev.is-spacer { visibility: hidden; }
.chev.is-open { transform: rotate(90deg); color: var(--d-text-soft); }

.tree-children { animation: tree-expand .14s ease-out; }
@keyframes tree-expand {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .tree-children { animation: none; }
  .chev { transition: none; }
}

.ic { width: 14px; height: 14px; flex-shrink: 0; display: grid; place-items: center; }
.ic svg { width: 14px; height: 14px; display: block; }
.tree-folder .ic { color: var(--d-text); }
.tree-file .ic   { color: var(--d-text-mute); }

.tree-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.tree-folder .tree-label { color: var(--d-text); font-weight: 500; }
.tree-file .tree-label   { color: var(--d-text-soft); font-weight: 400; }

.tree-row.is-active { background: var(--d-bg-active); color: var(--d-text); }
.tree-row.is-active .tree-label { color: var(--d-text); font-weight: 500; }
.tree-row.is-active .ic         { color: var(--d-text); }
.tree-row.is-active::before {
  content: ""; position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px; background: var(--d-text);
}

.tree-row.is-focused {
  background: var(--d-bg-active);
  box-shadow: inset 0 0 0 1px var(--d-border);
}
.tree-row.is-focused .tree-label { color: var(--d-text); }
.tree-row:focus { outline: none; }
.tree-row:focus-visible { outline: none; }

/* M4: multi-select highlight. Sits below .is-focused (the box-shadow ring)
   so a single focused row in a multi-selection still reads as the focal
   row. No animation, no radius — One-Gray palette discipline. */
.tree-row.is-selected { background: var(--d-bg-active); }
.tree-row.is-selected .tree-label { color: var(--d-text); }

/* M4: HTML5 drag-and-drop visual states. */
.tree-row.is-drop-target {
  background: var(--d-bg-active);
  box-shadow: inset 0 0 0 1px var(--d-text);
}
.tree.is-drop-target {
  box-shadow: inset 0 0 0 1px var(--d-text);
}
.tree-row.is-dragging { opacity: 0.5; }

/* Tree search bar — sits inside .sidebar-tree at the top.
   Visible whenever the workspace has at least one file. */
.tree-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 10px;
  border-bottom: 1px solid var(--d-border);
}

.tree-search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid var(--d-border);
  color: var(--d-text);
  font-family: "Geist Mono", ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  padding: 4px 6px;
  outline: none;
}
.tree-search-input::placeholder { color: var(--d-text-mute); }
.tree-search-input:focus { border-color: var(--d-text-soft); }

.tree-search-count {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--d-text-mute);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.search-hit {
  font-weight: 700;
  color: var(--d-text);
}

.tree-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--d-text-mute);
  font-family: "Geist Mono", ui-monospace, monospace;
}

/* Resize handle */
.resize {
  position: absolute; top: 0; right: -3px;
  width: 6px; height: 100%;
  cursor: col-resize; z-index: 20;
}
.resize::before {
  content: ""; position: absolute;
  top: 0; bottom: 0; left: 3px;
  width: 1px; background: transparent;
}
.resize:hover::before, .resize.is-dragging::before { background: #3a3a3a; }
body.is-resizing { cursor: col-resize; user-select: none; }
body.is-resizing * { cursor: col-resize !important; }

/* Sidebar foot — org switcher | user menu */
.sidebar-foot {
  border-top: 1px solid var(--d-rule);
  padding: 0 6px 0 8px;
  display: flex; align-items: center; justify-content: space-between;
  position: relative;
  gap: 6px;
}

.org-switcher {
  display: flex; align-items: center;
  gap: 7px; height: 26px; padding: 0 8px 0 7px;
  color: var(--d-text-soft);
  font-size: 12px;
  font-family: "Geist Mono", ui-monospace, monospace;
  border-radius: 3px;
  flex: 0 1 auto; min-width: 0;
}
.org-switcher:hover, .org-switcher.is-open { color: var(--d-text); background: var(--d-bg-hover); }
.org-switcher .org-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--d-text);
}
.org-switcher .org-caret {
  width: 10px; height: 10px;
  color: var(--d-text-mute);
  flex-shrink: 0;
  transition: transform .14s ease;
}
.org-switcher.is-open .org-caret { transform: rotate(180deg); color: var(--d-text-soft); }

.org-pop {
  position: absolute;
  left: 8px;
  bottom: calc(100% + 4px);
  min-width: 230px;
  max-width: calc(100% - 16px);
  background: var(--d-bg-elev);
  border: 1px solid var(--d-border);
  border-radius: 5px;
  box-shadow: 0 -10px 32px rgba(0,0,0,0.4), 0 -2px 6px rgba(0,0,0,0.18);
  z-index: 100; overflow: hidden;
  opacity: 0; transform: translateY(4px);
  transition: opacity .14s ease, transform .14s ease;
  pointer-events: none;
}
.org-pop.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.org-pop-head {
  padding: 9px 12px 7px;
  font-size: 10px; font-weight: 600;
  color: var(--d-text-mute);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-family: system-ui, sans-serif;
  border-bottom: 1px solid var(--d-rule);
}
.org-pop-list { max-height: 240px; overflow-y: auto; padding: 4px 0; }
.org-pop-row {
  display: flex; align-items: baseline;
  width: 100%; padding: 9px 12px;
  color: var(--d-text-soft);
  text-align: left; cursor: pointer;
  gap: 10px; position: relative;
}
.org-pop-row:hover { background: var(--d-bg-hover); color: var(--d-text); }
.org-pop-row.is-current { color: var(--d-text); }
.org-pop-row.is-current::before {
  content: ""; position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 2px; background: var(--d-text);
}
.org-pop-row .org-pop-name {
  font-family: system-ui, sans-serif;
  font-size: 13px; font-weight: 500;
  color: var(--d-text);
}
.org-pop-row .org-pop-handle {
  margin-left: auto;
  font-family: "Geist Mono", monospace;
  font-size: 10.5px;
  color: var(--d-text-mute);
}
.org-pop-foot {
  display: block; padding: 8px 12px;
  border-top: 1px solid var(--d-rule);
  font-family: system-ui, sans-serif;
  font-size: 12px;
  color: var(--d-text-soft);
}
.org-pop-foot:hover { color: var(--d-text); background: var(--d-bg-hover); }

/* User menu (sidebar foot) */
.user-btn {
  display: flex; align-items: center;
  gap: 4px; height: 26px; padding: 0 4px;
  border-radius: 3px; flex-shrink: 0;
}
.user-btn:hover, .user-btn.is-open { background: var(--d-bg-hover); }
.user-btn .user-chip {
  width: 22px; height: 22px;
  background: var(--d-bg-active); color: var(--d-text);
  font-size: 10.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--d-border);
  font-family: system-ui, sans-serif;
}
.user-btn .user-caret {
  width: 10px; height: 10px;
  color: var(--d-text-mute);
  transition: transform .14s ease;
}
.user-btn.is-open .user-caret { transform: rotate(180deg); color: var(--d-text-soft); }

.user-menu {
  position: absolute;
  right: 8px;
  bottom: calc(100% + 4px);
  width: 230px;
  background: var(--d-bg-elev);
  border: 1px solid var(--d-border);
  border-radius: 5px;
  box-shadow: 0 -10px 32px rgba(0,0,0,0.4), 0 -2px 6px rgba(0,0,0,0.18);
  z-index: 100; overflow: hidden;
  opacity: 0; transform: translateY(4px);
  transition: opacity .14s ease, transform .14s ease;
  pointer-events: none;
}
.user-menu.is-open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.user-menu-id {
  padding: 11px 13px 10px;
  border-bottom: 1px solid var(--d-rule);
  font-family: system-ui, sans-serif;
}
.user-menu-name { font-size: 13px; font-weight: 600; color: var(--d-text); }
.user-menu-email {
  font-size: 11.5px;
  color: var(--d-text-mute);
  margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-section { padding: 4px 0; }
.user-menu-row {
  display: flex; align-items: center;
  width: 100%; padding: 7px 13px;
  color: var(--d-text-soft);
  font-size: 12.5px;
  font-family: system-ui, sans-serif;
  text-align: left; cursor: pointer;
  gap: 8px;
}
.user-menu-row:hover { background: var(--d-bg-hover); color: var(--d-text); }
.user-menu-divider { height: 1px; background: var(--d-rule); }
.user-menu-row.is-danger { color: var(--danger); }
.user-menu-row.is-danger:hover { color: var(--danger); background: rgba(212, 104, 90, 0.08); }

/* Reader pane */
/* Flex column so the doc-header takes its natural height and .doc-scroll
   fills the *remaining* space. (Plain `height: 100%` on .doc-scroll made it a
   full viewport tall stacked below the header, overflowing .content-col and
   clipping the bottom of the scroll area below the window.) */
.content-col {
  background: var(--r-bg); height: 100%; overflow: hidden; min-width: 0;
  display: flex; flex-direction: column;
}

/* Reader tab strip — flat pills above the scroll area. */
.tab-strip {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 4px;
  padding: 5px 8px;
  background: var(--r-bg);
  border-bottom: 1px solid var(--r-border, #e5e2dc);
  overflow-x: auto; scrollbar-width: none;
}
.tab-strip::-webkit-scrollbar { display: none; }
.tab-pill {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 200px; padding: 4px 6px 4px 10px;
  border-radius: 7px; font-size: 13px;
  color: var(--r-text-mute, #8a857c);
  cursor: pointer; white-space: nowrap; user-select: none;
}
.tab-pill:hover { background: rgba(0,0,0,0.04); }
.tab-pill--active { background: rgba(0,0,0,0.07); color: var(--r-text); }
.tab-pill__name { overflow: hidden; text-overflow: ellipsis; }
.tab-pill__close {
  flex-shrink: 0; border: 0; background: transparent; cursor: pointer;
  font-size: 14px; line-height: 1; color: inherit;
  opacity: 0; padding: 0 3px; border-radius: 3px;
}
.tab-pill:hover .tab-pill__close,
.tab-pill--active .tab-pill__close { opacity: 0.55; }
.tab-pill__close:hover { opacity: 1; background: rgba(0,0,0,0.1); }
.tab-strip__new {
  flex-shrink: 0; border: 0; background: transparent; cursor: pointer;
  font-size: 17px; line-height: 1; color: var(--r-text-mute, #8a857c);
  padding: 2px 8px; border-radius: 5px;
}
.tab-strip__new:hover { background: rgba(0,0,0,0.06); color: var(--r-text); }

.doc-empty-state {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--r-text-mute, #8a857c); font-size: 14px;
}

/* Mobile tabs — filename header + swipe indicator (the strip is desktop-only). */
.mobile-tab-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
/* Swipe carousel: one full-width cell per tab laid out in a flex row; the track
   translates by -activeIndex * 100% to show the active cell and slide neighbours
   in. The viewport clips horizontally only, so each cell's .doc-scroll keeps its
   own vertical scroll. Only active ±1 cells hold a live DocPane (see JS). */
.carousel-viewport { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.carousel-track { display: flex; width: 100%; height: 100%; will-change: transform; }
.carousel-cell { flex: 0 0 100%; min-width: 0; display: flex; flex-direction: column; }
.mobile-tab-title {
  flex-shrink: 0; display: flex; align-items: center; gap: 10px;
  padding: 6px 16px 5px; font-size: 13px;
  color: var(--r-text-mute, #8a857c);
  border-bottom: 1px solid var(--r-border, #e5e2dc);
  background: var(--r-bg);
}
.mtt-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mtt-ind { flex-shrink: 0; display: flex; align-items: center; gap: 5px; }
.tpi-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(0,0,0,0.22); }
.tpi-dot.is-on { background: var(--r-text, #333); }
.tpi-text { font-variant-numeric: tabular-nums; font-size: 12px; }
/* Desktop keep-alive stack: every mounted tab is an absolutely-positioned pane
   filling the content area; only the active one shows. Inactive panes are
   content-hidden (skips render cost but PRESERVES rendering state, including the
   inner .doc-scroll position — unlike display:none) and inert, so switching back
   is an instant reveal with scroll intact and no refetch. */
.doc-stack { flex: 1; min-height: 0; position: relative; }
.doc-stack__pane {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; min-width: 0;
}
.doc-stack__pane.is-active { z-index: 1; }
.doc-stack__pane.is-inert { content-visibility: hidden; pointer-events: none; }

.doc-scroll {
  flex: 1; min-height: 0; overflow-y: auto; background: var(--r-bg);
}
.doc-scroll::-webkit-scrollbar { width: 10px; }
.doc-scroll::-webkit-scrollbar-thumb { background: #d8d6d2; border-radius: 5px; border: 2px solid var(--r-bg); }
/* Generous bottom padding gives the reader scrollable whitespace past the last
   line, so content never feels jammed against the window's bottom edge. */
.doc-card { background: var(--r-bg); padding: 64px 56px 33vh; min-height: 100%; }

.doc-content {
  max-width: 680px; margin: 0;
  font-family: var(--reader-body);
  font-size: var(--reader-body-size);
  line-height: var(--reader-line-height);
  color: var(--r-text);
  font-feature-settings: "kern", "liga", "calt";
  font-optical-sizing: auto;
}
.doc-content h1 {
  font-family: var(--reader-display);
  font-style: var(--reader-display-style);
  font-weight: var(--reader-h1-weight);
  font-size: var(--reader-h1-size);
  line-height: 1.1;
  margin: 0 0 20px;
  letter-spacing: var(--reader-letter-spacing);
  color: var(--r-text);
}
.doc-content h2 {
  font-family: var(--reader-body);
  font-weight: var(--reader-h2-weight);
  font-size: var(--reader-h2-size);
  margin: 40px 0 12px;
  letter-spacing: -0.005em;
  color: var(--r-text);
}
.doc-content h3 {
  font-family: var(--reader-body);
  font-weight: var(--reader-h3-weight);
  font-size: var(--reader-h3-size);
  margin: 28px 0 8px;
  color: var(--r-text);
}
.doc-content p { margin: 0 0 1.1em 0; }
.doc-content ul, .doc-content ol { padding-left: 1.5rem; margin: 0 0 1.2em 0; }
.doc-content li { margin-bottom: 0.4em; }
.doc-content li::marker { color: var(--r-text-mute); }
.doc-content blockquote {
  background: var(--r-bg-soft);
  border-left: 3px solid var(--r-border);
  padding: 12px 18px;
  margin: 1.5rem 0;
  color: var(--r-text-soft);
  font-style: italic;
}
.doc-content blockquote p { margin: 0; }
.doc-content code {
  font-family: var(--reader-mono);
  font-size: 0.85em;
  background: var(--r-code-bg);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--r-text);
}
.doc-content pre code {
  font-size: inherit;
  background: none;
  padding: 0;
  border-radius: 0;
  color: inherit;
}
.doc-content pre {
  background: var(--r-code-bg);
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--reader-mono);
  font-size: 13.5px;
  line-height: 1.55;
  border-radius: 4px;
  margin: 1.5em 0;
}
.doc-content hr { border: none; border-top: 1px solid var(--r-border); margin: 2.5rem 0; }
.doc-content a {
  color: var(--r-text);
  text-decoration: underline;
  text-decoration-color: var(--r-text-mute);
  text-underline-offset: 3px;
}
.doc-content a:hover { text-decoration-color: var(--r-text); }

/* Tables */
.doc-content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9em;
  line-height: 1.5;
  margin: 1.5em 0;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.doc-content th, .doc-content td {
  border: 1px solid var(--r-border);
  padding: 8px 12px;
  text-align: left;
}
.doc-content th {
  font-weight: 600;
  background: var(--r-bg-soft);
  font-size: 0.85em;
  letter-spacing: 0.01em;
}
.doc-content tr:hover { background: var(--r-bg-soft); }
.doc-content thead tr:hover { background: transparent; }

/* Dark reader schemes (carbon/inverse): --r-border (#2a2a2a) sits ~8% off
   --r-bg (#1c1c1c), so the cell grid effectively disappears. Bump to a
   palette that actually reads on the dark surface — kept scoped to tables
   so the rest of the chrome (rules, dividers) keeps its quieter line. */
[data-r-mode="dark"] .doc-content th,
[data-r-mode="dark"] .doc-content td {
  border-color: #3a3a3a;
}
[data-r-mode="dark"] .doc-content th {
  background: #262626;
}
[data-r-mode="dark"] .doc-content tr:hover { background: #242424; }

.doc-empty {
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding-top: 30vh;
  color: var(--r-text-mute);
  font-family: "Instrument Serif", Georgia, serif;
  font-style: italic;
  font-size: 22px;
  letter-spacing: -0.005em;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: #1a1a1a; color: #e8e6e1;
  padding: 9px 16px; font-size: 13px;
  font-family: system-ui, sans-serif;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none; z-index: 1000;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast svg { width: 14px; height: 14px; color: #8ec98e; }

/* Doc header (Share button row, preserved from current SPA) */
.doc-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0.75rem 1rem 14px;
  margin: 0 1rem 24px;
  border-bottom: 1px solid var(--r-border);
}
.doc-path-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--reader-mono);
}
.doc-path {
  font-size: 11.5px;
  color: var(--r-text-mute);
  letter-spacing: 0.02em;
}
.doc-meta-button {
  margin-left: auto;
  font-family: var(--reader-mono);
  font-size: 11px;
  color: var(--r-text-mute);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
}
.doc-meta-button:hover { color: var(--r-text); }

.doc-toolbar { display: flex; align-items: center; gap: 6px; }

.doc-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  font: 12.5px system-ui, -apple-system, sans-serif;
  color: var(--r-text);
  background: var(--r-bg);
  border: 1px solid var(--r-border);
  border-radius: 0;
  cursor: pointer;
}
.doc-btn:hover { background: var(--r-bg-soft); }
.doc-btn.is-on { background: var(--r-bg-soft); }
.doc-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.doc-btn kbd {
  font-family: var(--reader-mono);
  font-size: 10.5px;
  color: var(--r-text-mute);
  padding: 1px 4px;
  border: 1px solid var(--r-border);
  background: var(--r-bg-soft);
}
.doc-btn-primary {
  background: var(--r-text);
  color: #ffffff;
  border-color: var(--r-text);
}
.doc-btn-primary:hover:not(:disabled) { background: #333333; }
.doc-btn-primary kbd { background: #2a2a2a; color: #c8c5be; border-color: #444444; }
.doc-btn-ghost { color: var(--r-text-soft); border-color: transparent; }
.doc-btn-ghost:hover { background: var(--r-bg-soft); border-color: var(--r-border); }

/* ─────────────────────  Modals (preserved)  ───────────────────── */
.share-backdrop, .invite-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.share-modal, .invite-modal {
  background: var(--r-bg);
  color: var(--r-text);
  border: 1px solid var(--r-border);
  border-radius: 6px;
  padding: 1.25rem 1.5rem 1rem;
  max-width: 520px; width: calc(100% - 2rem);
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  font-size: 0.92rem;
}
.share-title, .invite-modal-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.15rem; }
.share-sub, .invite-modal-sub {
  font-size: 0.82rem;
  color: var(--r-text-mute);
  margin-bottom: 1rem;
  word-break: break-all;
}
.share-field { display: block; margin-bottom: 0.85rem; }
.share-field > span {
  display: block;
  font-size: 0.82rem;
  color: var(--r-text-soft);
  margin-bottom: 0.2rem;
}
.share-field input,
.share-field select,
.invite-modal-input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.92rem;
  border: 1px solid var(--r-border);
  border-radius: 4px;
  background: var(--r-bg);
  color: var(--r-text);
}
.share-actions, .invite-modal-actions {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  margin-top: 1rem;
  align-items: center;
}
.share-manage {
  margin-right: auto;
  font-size: 0.85rem;
  color: var(--r-text-soft);
  text-decoration: none;
}
.share-manage:hover { text-decoration: underline; }
.share-warning {
  background: var(--r-bg-soft);
  border: 1px solid var(--r-border);
  color: var(--r-text-soft);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  margin: 0.25rem 0 0.85rem;
}
.share-url {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.85rem;
  background: var(--r-code-bg);
  border: 1px solid var(--r-border);
  border-radius: 4px;
  color: var(--r-text);
}
.share-meta { font-size: 0.78rem; color: var(--r-text-mute); margin-top: 0.4rem; }
.share-error, .invite-modal-error { color: #c00; font-size: 0.85rem; margin: 0.5rem 0; }

.invite-modal-label {
  display: block;
  font-size: 13px;
  color: var(--r-text-soft);
  margin: 8px 0 0;
}
.copy-link-row {
  display: flex; gap: 8px; align-items: stretch; margin: 8px 0;
}
.copy-link-row .invite-modal-input { flex: 1; margin-top: 0; }
.allowlist-hint {
  background: var(--r-bg-soft);
  border-left: 3px solid var(--r-border);
  padding: 10px 14px;
  color: var(--r-text-soft);
  font-size: 12px;
  margin: 12px 0 0;
}

/* Members panel (preserved) */
.members-panel {
  width: 100%; max-width: 680px;
  padding: 48px 32px 64px;
  color: var(--r-text);
  font-size: 14px;
}
.members-title { font-size: 20px; font-weight: 600; margin: 0 0 8px; }
.members-subtitle {
  font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  margin: 32px 0 8px;
  color: var(--r-text-soft);
}
.members-note {
  background: var(--r-bg-soft);
  border-left: 3px solid var(--r-border);
  padding: 12px 16px;
  color: var(--r-text-soft);
  font-size: 13px;
  margin: 16px 0 24px;
}
.members-section { border-top: 1px solid var(--r-border); }
.member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--r-border);
  font-size: 14px;
}
.member-name { flex: 0 0 auto; font-weight: 500; color: var(--r-text); }
.member-meta { font-weight: 400; color: var(--r-text-soft); font-size: 13px; }
.member-email {
  flex: 1; color: var(--r-text-soft); font-size: 13px;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.role-pill {
  flex: 0 0 auto;
  padding: 2px 10px;
  font-size: 11px; font-weight: 500;
  background: var(--r-code-bg);
  color: var(--r-text-soft);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.btn-revoke {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--r-border);
  color: var(--r-text-soft);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}
.btn-revoke:hover { color: #c00; border-color: #c00; }
.members-actions { margin: 32px 0 0; }
.members-empty {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  color: var(--r-text-mute);
  font-size: 14px;
}

/* Route notice (preserved) */
.route-notice {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  background: var(--r-code-bg);
  border-bottom: 1px solid var(--r-border);
  font-size: 13px;
  color: var(--r-text-soft);
}
.route-notice > span { flex: 1; }
.route-notice-close {
  background: none; border: none; cursor: pointer;
  font-size: 16px; line-height: 1;
  padding: 2px 6px;
  color: var(--r-text-mute);
}
.route-notice-close:hover { color: var(--r-text-soft); }

/* ── Mobile components (rendered only on mobile via useIsMobile) ── */

/* Mobile topbar */
.mobile-topbar {
  height: 52px;
  padding: 0 8px;
  gap: 4px;
}
.hamburger {
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; gap: 4px;
  width: 44px; height: 44px;
  background: none; border: none; cursor: pointer;
  padding: 0; flex-shrink: 0;
}
.hamburger span {
  display: block; width: 18px; height: 2px;
  background: #cccccc;
}
.mobile-title {
  flex: 1;
  font-size: 14px; font-weight: 500;
  color: #cccccc;
  text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.mobile-share-btn {
  height: 44px; padding: 0 12px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; color: #999999;
  flex-shrink: 0;
}
.mobile-share-btn:active { color: #cccccc; }

.more-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: #999999;
  flex-shrink: 0; letter-spacing: 2px;
}
.more-btn:active { color: #cccccc; }

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
  will-change: opacity;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.drawer {
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(80vw, 320px);
  background: var(--d-bg); color: var(--d-text);
  z-index: 250;
  transform: translateX(-100%);
  transition: transform .15s cubic-bezier(.4, 0, .2, 1);
  will-change: transform;
}
.drawer.is-open { transform: translateX(0); }

/* Drawer "Open tabs" list — the mobile direct-jump affordance (swipe + the
   N/total pill cover sequential moves; this jumps to any tab and closes it). */
.drawer-tabs {
  flex-shrink: 0;
  border-bottom: 1px solid var(--d-border);
  padding: 6px 6px 8px;
  max-height: 35vh; overflow-y: auto;
}
.drawer-tabs__label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--d-text-mute); padding: 6px 8px 2px;
}
.drawer-tab {
  display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 6px 0 10px;
  border-radius: 7px; font-size: 14px;
  color: var(--d-text-soft); cursor: pointer; user-select: none;
}
.drawer-tab:hover { background: var(--d-bg-hover); color: var(--d-text); }
.drawer-tab.is-active { background: var(--d-bg-active); color: var(--d-text); }
.drawer-tab__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-tab__close {
  flex-shrink: 0; border: 0; background: transparent; cursor: pointer;
  font-size: 18px; line-height: 1; color: inherit; opacity: 0.5;
  width: 36px; height: 36px; border-radius: 5px;
}
.drawer-tab__close:hover { opacity: 1; background: var(--d-bg-hover); }

.drawer .sidebar-tree {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 6px 0 8px;
}
.drawer .tree-row { height: 44px; }

/* Drawer touch target overrides — 44px minimum */
.drawer .sidebar-head { height: 52px; padding: 0 12px; }
.drawer .ws-switcher { min-height: 44px; padding: 0 8px; }
.drawer .sidebar-head .act { width: 44px; height: 44px; }
.drawer .sidebar-head .act svg { width: 14px; height: 14px; }
.drawer .ws-pop-row { min-height: 44px; padding: 8px 14px; }
.drawer .ws-pop-foot { min-height: 44px; padding: 8px 14px; }
.drawer .tree-search-input { height: 36px; font-size: 15px; }

.drawer-foot {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; padding: 0 12px;
  border-top: 1px solid var(--d-border);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.drawer .org-switcher { min-height: 44px; padding: 4px 8px; }
.drawer .user-btn { min-height: 44px; padding: 4px 8px; }

/* Mobile bottom sheet */
.mobile-sheet-backdrop {
  position: fixed; inset: 0; z-index: 350;
  background: rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none;
  transition: opacity .15s ease;
  will-change: opacity;
}
.mobile-sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

.mobile-sheet {
  display: flex; flex-direction: column;
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 400;
  background: #1a1a1a;
  border-top: 1px solid #2a2a2a;
  max-height: 70vh; overflow-y: auto;
  transform: translateY(100%);
  transition: transform .15s cubic-bezier(.4, 0, .2, 1);
  will-change: transform;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-sheet.is-open { transform: translateY(0); }

.mobile-sheet-handle {
  width: 32px; height: 4px; background: #444444;
  margin: 12px auto 0; border-radius: 2px;
}
.mobile-sheet-section {
  padding: 8px 0;
  border-bottom: 1px solid #2a2a2a;
}
.mobile-sheet-section:last-child { border-bottom: none; }
.mobile-sheet-label {
  padding: 4px 16px 6px;
  font-size: 11px; font-weight: 600; color: #555555;
  text-transform: uppercase; letter-spacing: 0.07em;
  font-family: system-ui, sans-serif;
}
.mobile-sheet-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; height: 44px; padding: 0 16px;
  background: none; border: none; cursor: pointer;
  text-align: left;
}
.mobile-sheet-row:active { background: #2a2a2a; }
.mobile-sheet-row.is-current { background: #222222; }
.mobile-sheet-row.is-current .mobile-sheet-row-label { color: #ffffff; font-weight: 600; }
.mobile-sheet-row-label {
  font-size: 14px; color: #cccccc; font-weight: 400;
  font-family: system-ui, sans-serif;
}
.mobile-sheet-toggle {
  margin-left: auto;
  font-size: 13px; color: #888888;
  font-family: system-ui, sans-serif;
}
.mobile-sheet-row .scheme-swatch {
  width: 28px; height: 18px; border-radius: 3px;
  border: 1px solid #333333;
  display: flex; overflow: hidden; flex-shrink: 0;
}
.mobile-sheet-row .scheme-swatch span { flex: 1; height: 100%; }
.mobile-sheet-email {
  padding: 0 16px 8px;
  font-size: 13px; color: #666666;
  font-family: system-ui, sans-serif;
}
.mobile-sheet-danger { color: #cc0000; }

/* Mobile content area */
.mobile-content {
  flex: 1; min-height: 0; overflow: hidden;
}
.mobile-content .btn-share { display: none; }
.mobile-content .doc-card {
  padding-left: 20px; padding-right: 20px;
}
.mobile-content .doc-content {
  max-width: none;
  font-size: 17px; line-height: 1.72;
}
.mobile-content .doc-header { padding-top: 32px; }


/* ──────────────────────────────────────────────────────────────────── */
/*  M6 — File-history side sheet                                         */
/*  Lifted from docs/mockups/2026-05-22-editability/style.css            */
/* ──────────────────────────────────────────────────────────────────── */
.history-sheet {
  position: fixed;
  top: 48px; right: 0; bottom: 0;
  width: 380px;
  background: var(--r-bg);
  border-left: 1px solid var(--r-border);
  display: flex; flex-direction: column;
  z-index: 40;
  box-shadow: -12px 0 32px rgba(0,0,0,0.06);
  animation: sheet-in .22s ease-out;
}
@keyframes sheet-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.history-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--r-border);
}
.history-title-row {
  display: flex; align-items: baseline;
  margin-bottom: 6px;
}
.history-title {
  font-family: var(--reader-display);
  font-style: italic;
  font-weight: 400;
  font-size: 26px;
  line-height: 1;
  margin: 0;
  color: var(--r-text);
}
.history-close {
  margin-left: auto;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  color: var(--r-text-mute);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
}
.history-close:hover { color: var(--r-text); background: var(--r-bg-soft); }
.history-path {
  font-family: var(--reader-mono);
  font-size: 11.5px;
  color: var(--r-text-mute);
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  word-break: break-all;
}
.history-meta {
  font-family: var(--reader-mono);
  font-size: 10.5px;
  color: var(--r-text-soft);
  display: flex; gap: 6px;
  flex-wrap: wrap;
}
.history-meta strong { color: var(--r-text); font-weight: 600; }
.meta-sep { color: var(--r-text-mute); }

.history-filters {
  display: flex; gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--r-border);
  background: var(--r-bg-soft);
}
.hf-pill {
  font-family: system-ui, sans-serif;
  font-size: 11.5px;
  height: 22px;
  padding: 0 10px;
  color: var(--r-text-soft);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
}
.hf-pill:hover { color: var(--r-text); background: var(--r-bg); border-color: var(--r-border); }
.hf-pill.is-on { color: var(--r-text); background: var(--r-bg); border-color: var(--r-text); font-weight: 500; }

.history-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.history-list::-webkit-scrollbar { width: 8px; }
.history-list::-webkit-scrollbar-thumb { background: #d8d6d2; border: 2px solid var(--r-bg); }

.hv-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  padding: 10px 20px 12px;
  border-left: 2px solid transparent;
  position: relative;
  cursor: default;
}
.hv-row:hover { background: var(--r-bg-soft); }
.hv-row.is-current { border-left-color: var(--r-text); }
.hv-row.is-current .hv-time { color: var(--r-text); font-weight: 600; }
.hv-row.is-delete { background: rgba(212,104,90,0.05); }
.hv-row.is-delete .hv-snippet { color: var(--danger); font-style: italic; }

.hv-time {
  grid-row: 1; grid-column: 1;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--r-text);
}
.hv-ago {
  grid-row: 1; grid-column: 2;
  font-family: var(--reader-mono);
  font-size: 10.5px;
  color: var(--r-text-mute);
  align-self: center;
}
.hv-author {
  grid-row: 2; grid-column: 1 / span 2;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--reader-mono);
  font-size: 10.5px;
  color: var(--r-text-soft);
}
.hv-author-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.hv-author-dot.is-user  { background: #5a8aaa; }
.hv-author-dot.is-agent { background: #9a6aa8; }
.hv-author-dot.is-system { background: var(--r-text-mute); }
.hv-delta {
  grid-row: 1; grid-column: 3;
  font-family: var(--reader-mono);
  font-size: 11px;
  color: var(--r-text-soft);
  align-self: center;
  font-variant-numeric: tabular-nums;
}
.hv-delta .add { color: var(--ok, #4a8a5a); }
.hv-delta .rm  { color: var(--danger); }
.hv-no-diff { color: var(--r-text-mute); }
.hv-snippet {
  grid-row: 3; grid-column: 1 / span 3;
  font-family: var(--reader-mono);
  font-size: 11.5px;
  color: var(--r-text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.hv-actions {
  grid-row: 2; grid-column: 3;
  display: none;
  gap: 4px;
  justify-content: flex-end;
}
.hv-row:hover .hv-actions { display: flex; }
.hv-row:hover .hv-author { grid-column: 1 / span 2; }
.hv-act {
  font-family: system-ui, sans-serif;
  font-size: 11px;
  padding: 1px 7px;
  color: var(--r-text-soft);
  border: 1px solid var(--r-border);
  background: var(--r-bg);
  cursor: pointer;
}
.hv-act:hover { color: var(--r-text); background: var(--r-bg-soft); }
.hv-act.is-primary { color: var(--r-text); border-color: var(--r-text); font-weight: 500; }
.hv-act.is-primary:hover { background: var(--r-text); color: #fff; }
.hv-row.is-current .hv-act-restore { display: none; }
.hv-badge {
  display: inline-block;
  font-family: var(--reader-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  background: var(--r-text);
  color: #fff;
  margin-left: 6px;
  vertical-align: 1px;
}
.hv-sha {
  font-family: var(--reader-mono);
  font-size: 10px;
  color: var(--r-text-mute);
  margin-left: auto;
}

.history-footer {
  border-top: 1px solid var(--r-border);
  padding: 8px 20px;
  font-family: var(--reader-mono);
  font-size: 10.5px;
  color: var(--r-text-mute);
  background: var(--r-bg-soft);
}

body.is-history-open .doc-scroll { margin-right: 380px; }

/* Preview-mode banner — sits above the doc-header when viewing
   a historical version. Dark palette marks "you are in temporary mode". */
.preview-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--d-bg, #2a2a2a);
  color: var(--d-text, #f0f0f0);
  font-family: var(--reader-mono);
  font-size: 12px;
}
.preview-banner-actions { display: flex; gap: 8px; }
.preview-banner-actions button {
  font-family: system-ui, sans-serif;
  font-size: 11.5px;
  padding: 2px 8px;
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  cursor: pointer;
}
.preview-banner-actions button.is-primary {
  background: var(--d-text, #f0f0f0);
  color: var(--d-bg, #2a2a2a);
}
.hv-empty {
  font-family: var(--reader-mono);
  font-size: 11.5px;
  color: var(--r-text-mute);
  padding: 16px 20px;
}
.hv-row.is-previewing .hv-time { font-style: italic; text-decoration: underline; }

/* Mobile takeover (T9) — full-screen sheet under 768px. */
@media (max-width: 768px) {
  .history-sheet {
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    box-shadow: none;
    animation: sheet-up .25s ease-out;
  }
  @keyframes sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  body.is-history-open .doc-scroll { margin-right: 0; }
}

/* ─── Edit mode (M2) ─── */

.doc-header.is-editing {
  background: var(--r-bg-soft);
  border-bottom-color: var(--r-text-mute);
}
/* Optional reader-light card tint marks edit mode beyond the header (spec OQ1, default on). */
.doc-card.is-editing { background: #fcfbf8; }

.cm-host {
  display: block;
  min-height: 60vh;
  width: 100%;
}
.cm-host .cm-editor { height: 100%; }

.dirty-dot {
  font-family: var(--reader-mono);
  font-size: 14px;
  color: var(--r-text-mute);
  width: 20px; text-align: center;
  user-select: none;
}
.dirty-dot.is-dirty { color: var(--warn); font-weight: 700; }

.edit-statusbar {
  display: flex; align-items: center; gap: 18px;
  margin-top: 24px; padding-top: 10px;
  border-top: 1px solid var(--r-border);
  font-family: var(--reader-mono);
  font-size: 10.5px;
  color: var(--r-text-mute);
}
.esb-spacer { flex: 1; }
.esb-hash { color: var(--r-text-soft); }
.conflict-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.conflict-modal {
  background: var(--r-bg, #fff);
  color: var(--r-text, #1a1a1a);
  padding: 24px;
  max-width: 480px;
  font: inherit;
}
.conflict-modal h2 { margin-top: 0; font-size: 18px; }
.conflict-actions { display: flex; gap: 8px; margin-top: 16px; }
.conflict-actions button {
  background: transparent;
  border: 1px solid var(--d-border);
  color: var(--d-text);
  padding: 6px 14px;
  font: inherit;
  cursor: pointer;
}
.conflict-actions button:hover { background: var(--d-bg-hover); }

.edit-on-desktop {
  color: var(--d-text-mute, #888);
  font-size: 12px;
  padding: 4px 10px;
}

.toast .toast-action {
  margin-left: 4px;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.toast .toast-action:hover { opacity: 0.75; }

/* ---------- Tree context menu ---------- */
.tree-ctx-menu {
  z-index: 1000;
  min-width: 220px;
  background: var(--d-bg-elev);
  color: var(--d-text);
  border: 1px solid var(--d-border);
  padding: 4px 0;
  font: 13px/1.4 system-ui, -apple-system, sans-serif;
}
.tree-ctx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 12px;
  background: none;
  border: none;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.tree-ctx-item:hover:not(.is-disabled) { background: var(--d-bg-hover); }
.tree-ctx-item.is-danger { color: var(--danger); }
.tree-ctx-item.is-disabled { opacity: 0.4; cursor: default; }
.tree-ctx-shortcut { opacity: 0.6; font-size: 12px; padding-left: 16px; }
.tree-ctx-sep { height: 1px; background: var(--d-rule); margin: 4px 0; }
.tree-ctx-section {
  padding: 6px 12px 2px;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--d-text-mute);
}

/* ---------- Rename input ---------- */
.tree-rename-wrap { display: inline-flex; align-items: center; gap: 8px; }
.tree-rename-input {
  font: inherit;
  border: 1px solid var(--d-border);
  padding: 1px 4px;
  background: var(--d-bg-elev);
  color: var(--d-text);
  width: 200px;
}
.tree-rename-input.is-invalid { border-color: var(--danger); }
.tree-rename-err { color: var(--danger); font-size: 11px; }
.tree-row.is-pending { opacity: 0.5; }

/* ---------- Confirm modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 1100;
  display: flex; align-items: center; justify-content: center;
}
.modal-confirm {
  background: var(--r-bg);
  color: var(--r-text);
  border: 1px solid var(--r-border);
  padding: 18px 20px;
  min-width: 360px;
  max-width: 480px;
  font: 13px/1.5 system-ui, -apple-system, sans-serif;
}
.modal-title { font-weight: 600; margin-bottom: 8px; }
.modal-body { margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-confirm .btn { padding: 4px 12px; font: inherit; border: 1px solid var(--r-border); background: var(--r-bg); color: var(--r-text); cursor: pointer; }
.modal-confirm .btn:hover { background: var(--r-bg-soft); }
.modal-confirm .btn-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.modal-confirm .btn-danger:hover { filter: brightness(0.95); }
.modal-confirm .btn-primary { color: #fff; background: #1a1a1a; border-color: #1a1a1a; }
.modal-confirm .btn-primary:hover { background: #333333; border-color: #333333; }

/* ──────────────────────────────────────────────────────────────────── */
/*  Trash takeover view (B7b)                                            */
/*                                                                       */
/*  Lifted from docs/mockups/2026-05-22-editability/style.css:1106-1407. */
/*  Mockup's `body.is-trash-open .doc-card { display: none }` is omitted */
/*  — Workspace's contentPane gates on `trashOpen` in React, so the      */
/*  takeover replaces DocPane/MembersPanel/WorkspaceLanding at the JSX   */
/*  level. Sidebar tab-highlighting is owned by B8 (sidebar-tabs spec).  */
/* ──────────────────────────────────────────────────────────────────── */
.trash-view {
  min-height: 100%;
  background: var(--r-bg);
  display: flex;
  flex-direction: column;
}

.trash-header {
  padding: 36px 56px 18px;
  border-bottom: 1px solid var(--r-border);
}
.trash-title-row {
  display: flex; align-items: baseline; gap: 14px;
}
.trash-title {
  font-family: var(--reader-display);
  font-style: italic;
  font-weight: 400;
  font-size: 38px;
  line-height: 1;
  margin: 0;
  color: var(--r-text);
}
.trash-count {
  font-family: var(--reader-mono);
  font-size: 12px;
  color: var(--r-text-mute);
  font-variant-numeric: tabular-nums;
}
.trash-close {
  margin-left: auto;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--r-text-mute);
  background: transparent;
  border: none;
  cursor: pointer;
}
.trash-close:hover { color: var(--r-text); background: var(--r-bg-soft); }
.trash-close svg { width: 16px; height: 16px; }
.trash-sub {
  margin: 10px 0 18px;
  max-width: 720px;
  font-family: var(--reader-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--r-text-soft);
}
.trash-sub strong { color: var(--r-text); font-weight: 600; }

.trash-filters {
  display: flex; align-items: flex-end; gap: 14px;
  flex-wrap: wrap;
}
.trash-filter {
  display: flex; flex-direction: column;
  gap: 4px;
}
.trash-filter > span {
  font-family: var(--reader-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--r-text-mute);
}
.trash-filter select,
.trash-filter input {
  font-family: var(--reader-mono);
  font-size: 12px;
  color: var(--r-text);
  background: var(--r-bg);
  border: 1px solid var(--r-border);
  padding: 5px 8px;
  outline: none;
  min-width: 180px;
}
.trash-filter select:focus,
.trash-filter input:focus { border-color: var(--r-text); }
.trash-filter-search { flex: 1; max-width: 320px; }
.trash-filter-search input { width: 100%; }
.trash-filter-spacer { flex: 1; }
.trash-view-toggle {
  display: flex; align-items: center;
  border: 1px solid var(--r-border);
}
.tvt-btn {
  font-family: var(--reader-mono);
  font-size: 11px;
  height: 27px;
  padding: 0 12px;
  color: var(--r-text-soft);
  border-right: 1px solid var(--r-border);
  background: transparent;
  border-top: none;
  border-bottom: none;
  border-left: none;
  cursor: pointer;
}
.tvt-btn:last-child { border-right: none; }
.tvt-btn:hover { background: var(--r-bg-soft); color: var(--r-text); }
.tvt-btn.is-on { background: var(--r-text); color: #fff; }

.trash-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 56px 96px;
}
.trash-list::-webkit-scrollbar { width: 10px; }
.trash-list::-webkit-scrollbar-thumb { background: #d8d6d2; border: 2px solid var(--r-bg); }

.tg-folder { margin: 16px 0 0; }
.tg-folder-head {
  display: flex; align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 6px;
  border-bottom: 1px solid var(--r-border);
  cursor: pointer;
  user-select: none;
}
.tg-folder-head:hover { background: var(--r-bg-soft); }
.tg-folder-head .tg-chev {
  width: 12px; height: 12px;
  display: grid; place-items: center;
  color: var(--r-text-mute);
  transition: transform .12s ease;
  flex-shrink: 0;
}
.tg-folder-head .tg-chev svg { width: 10px; height: 10px; }
.tg-folder.is-collapsed .tg-chev { transform: rotate(-90deg); }
.tg-folder-head .tg-folder-icon {
  width: 14px; height: 14px;
  color: var(--r-text-soft);
}
.tg-folder-head .tg-folder-icon svg { width: 14px; height: 14px; }
.tg-folder-name {
  font-family: var(--reader-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--r-text);
}
.tg-folder-name em {
  color: var(--r-text-mute);
  font-style: normal;
}
.tg-folder-meta {
  margin-left: auto;
  font-family: var(--reader-mono);
  font-size: 10.5px;
  color: var(--r-text-mute);
  font-variant-numeric: tabular-nums;
}
.tg-folder-check { margin-right: 2px; }

.tg-folder.is-collapsed .tg-items { display: none; }

.tg-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 8px 12px 8px 32px;
  border-bottom: 1px solid var(--r-border);
  position: relative;
  font-family: var(--reader-mono);
  font-size: 12.5px;
}
.tg-item:hover { background: var(--r-bg-soft); }
.tg-item.is-selected { background: #f0eee9; }
.tg-item.is-selected::before {
  content: ""; position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px; background: var(--r-text);
}
.tg-item-name {
  color: var(--r-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tg-item-name em {
  color: var(--r-text-mute);
  font-style: normal;
}
.tg-item-deleted-by {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px;
  color: var(--r-text-soft);
  font-family: var(--reader-mono);
}
.tg-item-when {
  color: var(--r-text-mute);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.tg-item-size {
  color: var(--r-text-mute);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.tg-item-remaining {
  color: var(--warn);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.tg-item-remaining.is-urgent { color: var(--danger); font-weight: 600; }

/* Checkboxes — flat, mindex-aesthetic */
input[type="checkbox"].tg-check {
  appearance: none;
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border: 1px solid var(--r-border);
  background: var(--r-bg);
  cursor: pointer;
  display: inline-grid; place-items: center;
  margin: 0;
  flex-shrink: 0;
  border-radius: 0;
}
input[type="checkbox"].tg-check:hover { border-color: var(--r-text); }
input[type="checkbox"].tg-check:checked {
  background: var(--r-text);
  border-color: var(--r-text);
}
input[type="checkbox"].tg-check:checked::after {
  content: "";
  width: 7px; height: 4px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}
input[type="checkbox"].tg-check.is-mixed {
  background: var(--r-text);
  border-color: var(--r-text);
}
input[type="checkbox"].tg-check.is-mixed::after {
  content: "";
  width: 7px; height: 0;
  border-bottom: 1.5px solid #fff;
  transform: none;
}

/* Sticky bulk-action bar.
   Visibility decision per spec §5.6: display:none when hidden, display:flex
   when visible (NOT transform:translateY(110%) which broke in the mockup). */
.trash-bulk-bar {
  position: sticky;
  bottom: 0;
  background: var(--r-bg);
  border-top: 1px solid var(--r-border);
  padding: 14px 56px;
  align-items: center; gap: 14px;
  box-shadow: 0 -10px 24px rgba(0,0,0,0.04);
  z-index: 5;
  margin-top: auto;
  display: none;
}
.trash-bulk-bar.is-visible { display: flex; }
.tbb-count {
  font-family: var(--reader-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--r-text);
}
.tbb-bytes {
  font-family: var(--reader-mono);
  font-size: 11px;
  color: var(--r-text-mute);
  font-variant-numeric: tabular-nums;
}
.tbb-spacer { flex: 1; }
.trash-bulk-bar .btn-primary svg { width: 13px; height: 13px; margin-right: 4px; vertical-align: -2px; }

/* Empty state */
.trash-empty {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 60px;
}
.trash-empty-inner {
  text-align: center;
  max-width: 440px;
  color: var(--r-text-soft);
}
.trash-empty-inner svg {
  width: 64px; height: 64px;
  color: var(--r-border);
  margin: 0 auto 20px;
  display: block;
}
.trash-empty-inner h2 {
  font-family: var(--reader-display);
  font-style: italic;
  font-weight: 400;
  font-size: 28px;
  margin: 0 0 12px;
  color: var(--r-text);
}
.trash-empty-inner p {
  font-family: var(--reader-body);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0 0 12px;
}
.trash-empty-hint {
  font-size: 12.5px;
  color: var(--r-text-mute);
}
