/* DriveBase — Swiss minimalist (light)
   Same design system as X-Cloud. */

:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --surface-2: #F5F5F5;
  --ink: #0A0A0A;
  --text: #171717;
  --text-2: #525252;
  --text-3: #A3A3A3;
  --line: #EAEAEA;
  --line-2: #D4D4D4;
  --accent: #0066FF;
  --accent-soft: rgba(0, 102, 255, 0.08);
  --ok: #16A34A;
  --warn: #D97706;
  --danger: #DC2626;
  --shadow-pop: 0 8px 32px rgba(10, 10, 10, 0.08);

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Code", Consolas, monospace;

  --sidebar-w: 240px;
  --topbar-h: 60px;

  --t-fast: 120ms;
  --t-base: 200ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
button:disabled, .btn:disabled { cursor: not-allowed; opacity: 0.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hidden, [hidden] { display: none !important; }

/* Role-based visibility — JS toggles body.is-content / body.is-system */
body:not(.is-content):not(.is-system) .manager-only { display: none !important; }
body:not(.is-system) .admin-nav { display: none !important; }

/* Workspace detail-hidden mode (user closed the right detail panel) */
.workspace.detail-hidden { grid-template-columns: 1fr; }
.workspace.detail-hidden .side-panel { display: none; }
.muted { color: var(--text-2); }
small.muted, .muted small { color: var(--text-3); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.3; }
h3 { font-size: 14px; line-height: 1.4; }
p { margin: 0; }

/* ============== Buttons ============== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink); }
.btn:active:not(:disabled) { transform: translateY(0.5px); background: var(--line); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: #222; border-color: #222; }
.btn.primary:active:not(:disabled) { background: #000; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--line-2); }
.btn.danger:hover:not(:disabled) { background: #FEF2F2; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }

.icon-btn {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  background: transparent;
  font-size: 14px;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active:not(:disabled) { transform: translateY(0.5px); background: var(--line); }
.icon-btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ============== Tags ============== */
.tag, .pill, .role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.tag.green { color: var(--ok); border-color: rgba(22, 163, 74, 0.3); background: rgba(22, 163, 74, 0.06); }
.tag.red { color: var(--danger); border-color: rgba(220, 38, 38, 0.3); background: rgba(220, 38, 38, 0.05); }
.tag.blue { color: var(--accent); border-color: rgba(0, 102, 255, 0.3); background: var(--accent-soft); }
.role-badge { font-family: var(--font); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ============== Brand ============== */
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 24px; height: 24px;
  background: var(--ink); color: #fff;
  border-radius: 4px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.brand-title { font-size: 14px; font-weight: 600; color: var(--ink); margin: 0; }
.brand-sub { font-size: 11px; color: var(--text-3); margin: 0; letter-spacing: 0.02em; }

/* ============== Login ============== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 64px;
  padding: 48px;
  overflow: auto;
}
.login-screen.hidden { display: none; }
.login-brand {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 0 1 540px;
  min-width: 0;
}
.login-panel {
  flex: 0 1 440px;
  min-width: 0;
  width: 100%;
}
.login-copy h1 {
  font-size: 36px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
}
.login-copy p { font-size: 14px; color: var(--text-2); line-height: 1.65; max-width: 420px; }
.login-metrics {
  display: flex;
  gap: 24px;
  padding-top: 20px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}
.login-metric { display: flex; flex-direction: column; gap: 2px; }
.login-metric strong { font-size: 12px; color: var(--ink); font-weight: 600; }
.login-metric span { font-size: 11px; color: var(--text-3); letter-spacing: 0.02em; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 28px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.form-title h2 { font-size: 16px; margin-bottom: 4px; }
.form-title p { font-size: 13px; color: var(--text-2); }
.entry-note { font-size: 12px; color: var(--text-3); line-height: 1.5; }

/* ============== Forms ============== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--text-2); letter-spacing: 0.01em; }
.field input,
.field select,
.field textarea,
input[type="search"],
input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  color: var(--ink);
  font-size: 13px;
  transition: border-color 0.12s;
}
.field textarea, textarea { min-height: 120px; padding: 10px 12px; line-height: 1.6; resize: vertical; height: auto; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--text-3); }
.field input::placeholder, textarea::placeholder { color: var(--text-3); }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--ink); cursor: pointer; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid .field.full { grid-column: 1 / -1; }

/* ============== App shell ============== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.nav button svg {
  width: 14px; height: 14px;
  stroke: currentColor; stroke-width: 1.6; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button.active { background: var(--surface-2); color: var(--ink); }
.nav button.active::before {
  content: "";
  position: absolute;
  left: -16px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--ink);
}

.project-switcher {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.project-switcher-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.project-switcher-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.project-switcher #projectSelect { display: none; }
.project-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow-y: auto; }
.project-select-mode .project-switcher #projectSelect { display: block; }
.project-select-mode .project-list { display: none; }
/* Compact project switcher mode — single-line minimal items */
.project-compact-mode .project-option {
  padding: 6px 8px;
  gap: 0;
  border-width: 0;
  border-radius: var(--r-sm);
  background: transparent;
}
.project-compact-mode .project-option:hover { background: var(--surface-2); border-width: 0; }
.project-compact-mode .project-option.active { background: var(--surface-2); border-width: 0; }
.project-compact-mode .project-option-top { gap: 6px; margin: 0; }
.project-compact-mode .project-option-top .tag { font-size: 10px; height: 18px; padding: 0 6px; }
.project-compact-mode .project-option-meta { display: none; }
.project-compact-mode .project-option-name { font-size: 12px; }
.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.tree-item:hover { background: var(--surface-2); color: var(--ink); }
.tree-item.active { background: var(--surface-2); color: var(--ink); font-weight: 500; }
#projectLink { font-size: 11px; color: var(--text-3); font-family: var(--mono); }

.storage {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.storage-head { display: flex; justify-content: space-between; align-items: baseline; }
.storage-head span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.storage-head strong {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
}
.bar { height: 2px; background: var(--line); border-radius: 1px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ink); border-radius: 1px; width: 46%; }
.bar > span.progress-72 { width: 72%; }
.bar > span.progress-100 { width: 100%; background: var(--ok); }
.storage-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 8px;
  color: var(--text-3);
}
.storage-stats div {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  gap: 4px;
}
.storage-stats strong {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}
.storage-stats span {
  font-size: 11px;
  color: var(--text-3);
}

/* ============== Main ============== */
.main { min-width: 0; display: flex; flex-direction: column; }
body.admin-dashboard-active {
  height: 100vh;
  overflow: hidden;
}
body.admin-dashboard-active .app {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}
body.admin-dashboard-active .main {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

:root { --topbar-h: 64px; }
/* Hide the dead settings-filter panel (no data-settings-group on cards) */
.config-nav-panel { display: none; }
/* Page max-width on ultrawide screens */
.content > .view { max-width: 1440px; margin: 0 auto; }
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(0, 360px) auto;
  gap: 20px;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.page-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.page-title p {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
  order: -1;
}
.page-title h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.search { position: relative; display: flex; align-items: center; }
.search svg {
  position: absolute;
  left: 12px;
  width: 14px; height: 14px;
  stroke: var(--text-3); stroke-width: 1.6; fill: none;
  pointer-events: none;
}
.search input {
  height: 36px;
  padding: 0 12px 0 36px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  width: 100%;
}
.search input:hover { background: #EEEEEE; }
.search input:focus { background: var(--surface); border-color: var(--ink); }

.top-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.top-actions .icon-btn { width: 32px; height: 32px; border: 1px solid var(--line-2); border-radius: var(--r-md); }
.top-actions .icon-btn:hover { background: var(--surface-2); border-color: var(--ink); }

/* ============== Content ============== */
.content { flex: 1; padding: 20px 24px 32px; min-width: 0; }
body.admin-dashboard-active .content {
  min-height: 0;
  overflow: hidden;
  padding-bottom: 16px;
}
body.admin-dashboard-active #admin.active {
  height: 100%;
  max-width: none;
}

.page-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r-md);
  font-size: 12px;
  margin-bottom: 16px;
}
.switch-notice {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r-md);
  font-size: 12px;
  margin-bottom: 16px;
}
.switch-notice.active { display: inline-flex; }

.view { display: none; }
.view.active { display: block; }

/* ============== Workspace ============== */
.workspace {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  align-items: start;
  min-height: calc(100vh - var(--topbar-h) - 60px);
}
#shares .workspace { grid-template-columns: 1fr 240px; }

.file-detail-drawer-mode #drive .workspace {
  grid-template-columns: 1fr;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  min-width: 0;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}
.panel-head-tools { display: flex; gap: 8px; align-items: center; }
.compact-head { margin-bottom: 8px; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-3);
  min-width: 0;
}
.crumbs strong { color: var(--ink); font-weight: 600; }
.crumbs span:not(strong) { color: var(--text-3); }
.crumb-link {
  padding: 0;
  background: transparent;
  font: inherit;
  color: var(--text-2);
  border: 0;
  cursor: pointer;
  transition: color 0.12s;
}
.crumb-link:hover { color: var(--ink); }
.crumb-sep { color: var(--text-3); padding: 0 4px; }

.file-toolbar-actions { display: flex; gap: 6px; }

.config-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.section-title h2 { font-size: 14px; font-weight: 600; margin: 0; }
.section-title .muted { font-size: 12px; }

/* ============== Bulkbar ============== */
.bulkbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--accent-soft);
  border-radius: var(--r-md);
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--accent);
  position: sticky;
  top: 0;
  z-index: 2;
}
.bulkbar.active { display: flex; }
.bulk-actions { display: flex; gap: 6px; }

/* ============== Segmented ============== */
.segmented {
  display: inline-flex;
  border-bottom: 1px solid var(--line);
}
.segmented button {
  padding: 8px 12px;
  background: transparent;
  font-size: 13px;
  color: var(--text-3);
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s;
}
.segmented button.active {
  color: var(--ink);
  font-weight: 500;
  border-bottom-color: var(--ink);
}

/* ============== Tables ============== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}
.table tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr { transition: background 0.1s; cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.selected,
.table tbody tr.active-row { background: var(--accent-soft); }
.table tbody tr.selected td:first-child,
.table tbody tr.active-row td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.table thead th input[type="checkbox"] { vertical-align: middle; }
.table tbody td input[type="checkbox"] { vertical-align: middle; }

.row-check { vertical-align: middle; }

.file-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
}
.file-icon {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-size: 10px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--text-2);
  flex-shrink: 0;
  text-transform: uppercase;
}
.file-icon.folder { background: var(--ink); color: #fff; }
.file-icon.folder svg { width: 14px; height: 14px; stroke: currentColor; }

.drive-grid { display: none; }
.drive-grid-mode .table { display: none; }
.drive-grid-mode .drive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

/* ============== Empty state ============== */
.empty-state { padding: 48px 24px; text-align: center; display: none; }
.empty-state.active { display: block; }
.empty-state.compact-empty { padding: 24px; }
.empty-state strong {
  display: block;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 4px;
}
.empty-state .muted { font-size: 13px; }
.empty-actions { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }

/* ============== Side panel ============== */
.side-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
}
.detail-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.detail-panel-head strong { font-size: 13px; color: var(--ink); font-weight: 600; }
.side-panel .preview {
  width: 56px; height: 56px;
  background: var(--ink); color: #fff;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.side-panel .preview.is-folder svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.detail-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.detail-list.compact-detail { border-top: 0; }
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.detail-row span { color: var(--text-3); font-size: 12px; }
.detail-row strong { color: var(--ink); font-weight: 500; text-align: right; max-width: 60%; word-break: break-all; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ============== KB / editor ============== */
.kb-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 220px;
  gap: 16px;
  align-items: start;
  min-height: calc(100vh - var(--topbar-h) - 60px);
}
.kb-layout-2col { grid-template-columns: 260px minmax(0, 1fr); }

/* ============== KB nav (left) ============== */
.doc-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.doc-filter-chips button {
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  border: 1px solid transparent;
}
.doc-filter-chips button:hover { background: var(--surface-2); color: var(--ink); }
.doc-filter-chips button.active { background: var(--ink); color: #fff; }

.kb-doc-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px !important;
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
}
.kb-doc-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kb-doc-title {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-doc-sub {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-doc-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.kb-doc-row:hover .kb-doc-actions,
.kb-doc-row.active .kb-doc-actions { opacity: 1; }
.kb-doc-actions .icon-btn.mini { width: 22px; height: 22px; font-size: 11px; border: 0; background: transparent; }
.kb-doc-actions .icon-btn.mini:hover { background: var(--surface); border: 1px solid var(--line-2); }
.doc-star { color: var(--text-3); }
.doc-star.active { color: var(--warn); }
.recent-section { margin-bottom: 8px; }
.recent-section .doc-tree-label { color: var(--accent); }

/* ============== KB editor (right of nav) ============== */
.kb-editor {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.kb-editor-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 16px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kb-editor-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.kb-editor-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.kb-editor-title .doc-page-icon { width: 32px; height: 32px; font-size: 12px; }
.kb-editor-title input {
  flex: 1;
  height: auto;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.kb-editor-title input:focus { outline: 0; border: 0; }
.kb-editor-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.kb-editor-actions .segmented { padding: 0; }
.kb-editor-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.kb-chip-meta { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.kb-chip-sep { width: 1px; height: 12px; background: var(--line); margin: 0 4px; }
.kb-chip-add {
  height: 22px;
  padding: 0 8px;
  border: 1px dashed var(--line-2);
  background: transparent;
  border-radius: var(--r-sm);
  font-size: 11px;
  color: var(--text-3);
}
.kb-chip-add:hover { border-color: var(--ink); color: var(--ink); }

.kb-editor-canvas {
  padding: 16px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
}
.kb-editor-canvas .editor-body {
  min-height: 520px;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 14px;
  line-height: 1.85;
}
.kb-editor-canvas .editor-body:focus { outline: 0; }
.kb-editor-canvas .preview-doc { padding: 0; }
.kb-editor-canvas .kb-insertbar { display: none; }

/* Notion-style slash menu */
.kb-slash-menu {
  position: absolute;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  z-index: 10;
  display: flex;
  flex-direction: column;
}
.kb-slash-menu[hidden] { display: none; }
.kb-slash-head {
  padding: 8px 10px 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.kb-slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}
.kb-slash-item:hover,
.kb-slash-item.focused { background: var(--surface-2); }
.kb-slash-item strong { display: block; color: var(--ink); font-weight: 500; font-size: 13px; }
.kb-slash-item .muted { display: block; font-size: 11px; color: var(--text-3); margin-top: 1px; }
.kb-slash-icon {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  flex-shrink: 0;
}
.kb-slash-icon svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; color: var(--text-2); }
.kb-slash-foot {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-3);
}
.kb-slash-foot kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: var(--r-sm);
  margin-right: 4px;
}
.kb-slash-foot span { margin-right: 12px; }

/* Floating outline FAB */
.kb-outline-fab {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
}
.kb-outline-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  box-shadow: var(--shadow-pop);
  color: var(--text-2);
}
.kb-outline-btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink); }
.kb-outline-btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.kb-outline-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  max-height: 60vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.kb-outline-fab.open .kb-outline-pop { display: flex; }
.kb-outline-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.kb-outline-head strong { font-size: 12px; }
.kb-outline-head .muted { font-size: 11px; font-family: var(--mono); }
.kb-outline-list {
  padding: 4px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.kb-outline-item {
  text-align: left;
  padding: 6px 10px;
  background: transparent;
  font-size: 13px;
  color: var(--text-2);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.kb-outline-item:hover { background: var(--surface-2); color: var(--ink); }
.kb-outline-item[data-outline-level="2"] { padding-left: 22px; font-size: 12px; }
.kb-outline-item[data-outline-level="3"] { padding-left: 34px; font-size: 12px; color: var(--text-3); }
.doc-tree {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  max-height: calc(100vh - var(--topbar-h) - 32px);
  overflow-y: auto;
}
.doc-tree-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.doc-tree-head > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-tree-head h3 {
  font-size: 13px;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.005em;
  text-transform: none;
}
.doc-tree-head .muted { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tree-head .btn { height: 28px; padding: 0 10px; font-size: 12px; flex-shrink: 0; }
.doc-tree-section { display: flex; flex-direction: column; gap: 1px; margin-bottom: 4px; }
.doc-tree-folder-body { display: flex; flex-direction: column; gap: 1px; }
.doc-tree-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 6px 4px 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.folder-toggle {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: transparent;
  color: var(--text-3);
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  border: 0;
}
.folder-toggle:hover { background: var(--surface-2); color: var(--ink); }
.folder-caret {
  width: 10px; height: 10px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.doc-tree-section:not(.collapsed) .folder-caret { transform: rotate(90deg); }
.folder-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  background: var(--surface-2);
  color: var(--text-3);
  padding: 1px 6px;
  border-radius: 999px;
}
.folder-menu-btn {
  width: 22px; height: 22px;
  font-size: 12px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  border-radius: var(--r-sm);
  opacity: 0;
  transition: opacity 0.12s;
}
.doc-tree-section:hover .folder-menu-btn { opacity: 1; }
.folder-menu-btn:hover { background: var(--surface-2); color: var(--ink); }
.doc-tree-section.collapsed .doc-tree-folder-body { display: none; }

/* Folder action popover */
.kb-folder-menu {
  position: fixed;
  z-index: 60;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.kb-folder-menu[hidden] { display: none; }
.kb-folder-menu button {
  text-align: left;
  padding: 8px 10px;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  border-radius: var(--r-sm);
}
.kb-folder-menu button:hover { background: var(--surface-2); color: var(--ink); }
.kb-folder-menu button.danger { color: var(--danger); }
.kb-folder-menu button.danger:hover { background: #FEF2F2; }
.kb-folder-menu-head {
  padding: 8px 10px 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Trash view */
.trash-tabs { margin-bottom: 16px; padding-bottom: 12px; gap: 24px; }
.trash-pane { display: none; flex-direction: column; gap: 8px; }
.trash-pane.active { display: flex; }
#trash .trash-note { margin-bottom: 12px; }
#trash .trash-item { padding: 12px 14px; cursor: pointer; transition: background 0.1s, border-color 0.1s; }
#trash .trash-item:hover { background: var(--surface-2); }
#trash .trash-item.selected { background: var(--accent-soft); border-color: rgba(0,102,255,0.3); box-shadow: inset 2px 0 0 var(--accent); }
.trash-detail-panel .preview { font-family: var(--mono); font-size: 16px; }
.trash-detail-panel .preview.trash-icon svg { width: 24px; height: 24px; stroke: currentColor; }
.trash-detail-panel .detail-actions { flex-direction: column; align-items: stretch; gap: 0; }

/* ============================================================
   Unified design rules (overrides for consistency)
   ============================================================ */

/* — 1. Project switcher card stable height — */
.project-option { box-sizing: border-box; }
.project-compact-mode .project-option { min-height: 30px; }

/* — 2. KB editor rhythm — */
.kb-editor-header { padding-bottom: 10px !important; }
.kb-editor-chips { gap: 8px; }
.kb-editor-canvas { padding-top: 14px !important; gap: 12px !important; }
.kb-outline-fab { top: 14px !important; right: 14px !important; }
.kb-outline-pop {
  display: flex !important;
  opacity: 0;
  transform: scale(0.96) translateY(-4px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.kb-outline-fab.open .kb-outline-pop {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* — 3. Drive table row operations stand out — */
.table tbody tr:hover td:last-child { background: var(--surface-2); }
.table tbody tr.active-row td:last-child { background: var(--accent-soft); }

/* — 4. Shares detail panel (use shared side-panel styling) — */

/* — 5. Trash tab visual consistent with admin-view-tabs — */
#trash .trash-tabs {
  gap: 32px !important;
  margin-bottom: 24px !important;
  padding-bottom: 16px !important;
}
#trash .trash-tabs button {
  font-size: 24px !important;
  padding: 0 !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em !important;
}
#trash .trash-tabs button.active::after { bottom: -17px !important; }

/* — 6. Page container max-width on ultra-wide — */
.content > .view { max-width: 1440px; }

/* — 7. Detail panels (drive / shares / trash) unified padding/gap — */
.side-panel { padding: 16px !important; gap: 12px !important; }

/* — 8. Form unified — */
.form-grid { gap: 16px !important; }
.field { gap: 6px !important; }
.field input, .field select { height: 32px !important; }

/* — 9. Cards unified — */
.config-card h3 { line-height: 1.4; }
.api-card { padding: 16px !important; gap: 8px !important; }
.settings-grid, .admin-config-grid { gap: 12px !important; }

/* — 10. Admin pagination control group — */
.pager { gap: 8px !important; }
.pager #adminProjectPage,
.pager #auditPageText { min-width: 120px; text-align: center; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm); height: 28px; line-height: 28px; font-family: var(--mono); }

/* — 11. Empty state icon size unified — */
.empty-state > div::before { font-size: 48px !important; }
.empty-state.compact-empty > div::before { font-size: 32px !important; }

/* — 12. Section title rhythm — */
.section-title { margin-bottom: 16px !important; }
.section-title h2 { font-size: 14px !important; }

/* — 13. Config accordion stack interior gap — */
.config-accordion-stack { gap: 8px !important; }

/* — 14. Admin alert + cards spacing in ops dashboard — */
.admin-stack { gap: 16px !important; }
.cards { gap: 12px !important; }

/* — 15. Mobile rules — */
@media (max-width: 640px) {
  .row-action-hover { display: none !important; }
  .table, .admin-table, .permission-table {
    position: relative;
  }
  .panel:has(> .table),
  .panel:has(> table) {
    background-image: linear-gradient(to right, transparent 80%, rgba(0, 0, 0, 0.04));
    background-position: right center;
    background-repeat: no-repeat;
    background-size: 24px 100%;
  }
  .topbar {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 10px 16px !important;
    height: auto !important;
  }
  .top-actions { justify-content: flex-start !important; flex-wrap: wrap; }
  .login-panel { max-width: 360px !important; }
}

/* — 16. Outline FAB scale animation already added at #2 — */

/* — 17. Config-card left accent stripe (visual hierarchy in accordions) — */
.config-accordion > .admin-config-grid .config-card,
.config-accordion > .settings-grid .config-card {
  position: relative;
  padding-left: 18px !important;
}
.config-accordion > .admin-config-grid .config-card::before,
.config-accordion > .settings-grid .config-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--line-2);
  border-radius: 0;
}
.config-accordion > .admin-config-grid .config-card:hover::before,
.config-accordion > .settings-grid .config-card:hover::before { background: var(--ink); }

/* — 18. KB editor chip hide secondary muted text on small chip rows — */
.kb-editor-chips .kb-chip-meta:not(#saveState) { display: none; }
.kb-editor-chips .kb-chip-sep { display: none; }

/* — 19. Sidebar config-center jump nav (anchor list, sticky inside .admin-stack) — */
.config-jump-nav {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  min-width: 0;
}
.config-jump-nav-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.config-jump-nav a {
  display: block;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 12px;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.config-jump-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.config-jump-nav a.active { background: var(--ink); color: #fff; }

/* — 20. Search placeholder visual — */
.search input::placeholder { font-style: normal; }

.doc-dot {
  width: 22px; height: 22px;
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}
.tree-item.active .doc-dot { background: var(--ink); color: #fff; }

.editor { display: flex; flex-direction: column; gap: 14px; }
.editor-title {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.editor-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.doc-title-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.doc-page-icon {
  width: 30px; height: 30px;
  background: var(--ink); color: #fff;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}
.editor-title-row input {
  flex: 1;
  height: auto;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.editor-title-row input:focus { outline: 0; border: 0; }
.editor-title-row input[readonly] {
  cursor: default;
}
.doc-actions { display: flex; gap: 6px; }
.doc-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.kb-insertbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}
.insertbar-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-right: 4px;
}
.kb-insertbar .btn { height: 26px; padding: 0 10px; font-size: 12px; }

.editor-body {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px;
  background: var(--surface);
}
.editor.previewing .editor-body { display: none; }
.editor.reading .editor-toolbar,
.editor.reading .kb-insertbar,
.editor.reading .editor-body { display: none; }
.editor.reading .preview-doc { display: block; }
.config-card.is-hidden, .is-hidden { display: none !important; }
.file-detail-drawer-mode .drive-detail-panel {
  display: none;
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 360px;
  z-index: 20;
  border-left: 1px solid var(--line);
  border-radius: 0;
  box-shadow: var(--shadow-pop);
  overflow-y: auto;
}
.file-detail-drawer-mode .drive-detail-panel.active { display: flex; }
.preview-doc { display: none; font-size: 14px; line-height: 1.75; color: var(--text); }
.preview-doc.active, .editor.previewing .preview-doc { display: block; }
.preview-doc h1 { font-size: 28px; margin: 24px 0 12px; }
.preview-doc h2 { font-size: 20px; margin: 24px 0 12px; }
.preview-doc h3 { font-size: 16px; margin: 20px 0 8px; }
.preview-doc p { margin: 12px 0; }
.preview-doc ul, .preview-doc ol { padding-left: 24px; margin: 12px 0; }

/* Doc more popover (kebab menu on the editor header) */
.doc-more-wrap { position: relative; display: inline-flex; }
.doc-more-btn { width: 32px; height: 32px; border: 1px solid var(--line-2); border-radius: var(--r-md); }
.doc-more-btn:hover { background: var(--surface-2); border-color: var(--ink); }
.doc-more-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  display: none;
  flex-direction: column;
  z-index: 50;
}
.doc-more-wrap.open .doc-more-popover { display: flex; }
.doc-more-popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  border-radius: var(--r-sm);
  text-align: left;
}
.doc-more-popover button:hover { background: var(--surface-2); color: var(--ink); }
.doc-more-popover button svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* KB side tabs */
.kb-side-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  gap: 0;
}
.kb-side-tabs button {
  flex: 1;
  padding: 8px 4px;
  background: transparent;
  font-size: 12px;
  color: var(--text-3);
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s;
}
.kb-side-tabs button:hover { color: var(--text-2); }
.kb-side-tabs button.active { color: var(--ink); font-weight: 500; border-bottom-color: var(--ink); }
.kb-side-panel { display: none; flex-direction: column; gap: 14px; }
.kb-side-panel.active { display: flex; }

/* KB side */
.outline.kb-side { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 0; }
.kb-side-section { display: flex; flex-direction: column; gap: 6px; }
.kb-side-section h3 {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}
.kb-side-section a {
  font-size: 13px;
  color: var(--text-2);
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.kb-side-section a:hover { color: var(--ink); text-decoration: none; }
.doc-info-box .detail-row { padding: 8px 0; }
.doc-info-box .detail-row:last-child { border-bottom: 0; }

.kb-asset-list { display: flex; flex-direction: column; gap: 6px; }
.kb-asset-list h3 {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}
.kb-asset {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.kb-asset:hover { border-color: var(--ink); background: var(--surface-2); }
.kb-asset > span:last-child { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12px; }
.kb-asset strong { font-size: 13px; color: var(--ink); font-weight: 500; }
.kb-asset .muted { font-size: 11px; color: var(--text-3); }
.kb-thumb {
  width: 32px; height: 32px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-2);
  flex-shrink: 0;
}

/* ============== Shares ============== */
.share-toolbar {
  display: grid;
  grid-template-columns: 1fr 160px 160px;
  gap: 8px;
  margin-bottom: 12px;
}
.share-list-head {
  display: grid;
  grid-template-columns: minmax(180px, 1.35fr) minmax(220px, 1.65fr) 120px 90px 116px;
  gap: 12px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}
.share-list { display: flex; flex-direction: column; }
.share-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.35fr) minmax(220px, 1.65fr) 120px 90px 116px;
  gap: 12px;
  padding: 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  align-items: center;
  font-size: 13px;
  cursor: pointer;
}
.share-row:hover { background: var(--surface-2); }
.share-row.active { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.share-row > span:first-child {
  display: flex; align-items: center; gap: 10px;
  font-weight: 500; color: var(--ink); min-width: 0;
}
.share-row .muted { font-family: var(--mono); font-size: 11px; }
.share-row-title,
.share-row-link {
  min-width: 0;
}
.share-row-title > div,
.share-row-link {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.share-row .tag {
  justify-self: start;
}
.share-row .config-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.share-detail-panel { gap: 12px; }
.share-detail-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
}
.share-code-highlight {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}
.share-detail-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }

/* ============== Admin ============== */
.admin-view-tabs {
  display: flex;
  gap: 32px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.admin-view-tabs button {
  padding: 0;
  background: transparent;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-3);
  transition: color 0.12s;
  position: relative;
  line-height: 1.2;
}
.admin-view-tabs button:hover { color: var(--text-2); }
.admin-view-tabs button.active { color: var(--ink); }
.admin-view-tabs button.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -17px;
  height: 2px;
  background: var(--ink);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
  height: clamp(480px, calc(100vh - var(--topbar-h) - 112px), 720px);
  min-height: 0;
  overflow: hidden;
}
body.admin-dashboard-active .admin-grid[data-admin-tab="ops"] {
  height: calc(100vh - var(--topbar-h) - 104px);
  max-height: calc(100vh - var(--topbar-h) - 104px);
}
.admin-stack {
  display: flex;
  min-width: 0;
  max-height: 100%;
  overflow-y: auto;
  flex-direction: column;
  gap: 16px;
}

.admin-grid[data-admin-tab="config"] {
  height: auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: visible;
}

.admin-grid[data-admin-tab="config"] .admin-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-grid[data-admin-tab="config"] .admin-stack > .panel {
  min-width: 0;
}

.admin-grid[data-admin-tab="config"] .admin-stack > .config-nav-panel {
  order: 2;
  position: static;
}

.config-nav-panel .settings-filter {
  flex-direction: row;
}

.config-nav-panel .settings-filter button {
  width: auto;
}

.admin-grid[data-admin-tab="config"] .config-project-panel { order: 1; }
.admin-grid[data-admin-tab="config"] .config-basic-panel { order: 3; }
.admin-grid[data-admin-tab="config"] .config-rules-panel { order: 4; }
.admin-grid[data-admin-tab="config"] .config-permission-panel { order: 5; }
.admin-grid[data-admin-tab="config"] .config-api-panel { order: 6; }

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.metric { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.metric .label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.metric .value {
  font-size: 48px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.04em;
  font-feature-settings: "tnum";
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.metric span:last-child { font-size: 11px; color: var(--text-3); line-height: 1.5; }

.admin-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(217, 119, 6, 0.3);
  background: rgba(217, 119, 6, 0.05);
  border-radius: var(--r-md);
  margin-top: 12px;
}
.admin-alert strong { color: var(--warn); font-size: 13px; font-weight: 600; }
.admin-alert .muted { font-size: 12px; }

.admin-toolbar {
  display: grid;
  grid-template-columns: 1fr 160px 160px;
  gap: 8px;
  margin-bottom: 12px;
}
.admin-table tbody td .btn { margin-right: 4px; height: 28px; padding: 0 10px; font-size: 12px; }

.pager {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-3);
}
.pager .btn { height: 28px; padding: 0 10px; font-size: 12px; }

/* Config cards (basic settings + rules) */
.settings-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.settings-filter button {
  height: 28px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.12s, color 0.12s;
}
.settings-filter button:hover { background: var(--surface-2); color: var(--ink); }
.settings-filter button.active { background: var(--ink); color: #fff; }

.settings-grid, .admin-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.config-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color 0.12s;
}
.config-card:hover { border-color: var(--line-2); }
.config-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 0;
}
.config-card header > div { min-width: 0; }
.config-card h3 { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.config-card .muted { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.config-card .btn { align-self: flex-start; }
.config-card .segmented { align-self: flex-start; }
/* Push actions to the bottom so cards in the same row align */
.config-card > .btn,
.config-card > .segmented,
.config-card > .config-actions { margin-top: auto; }
.config-card header { align-items: flex-start; }

/* Top search mode (Cmd+K button vs always-visible input) */
body.search-mode-input #cmdkBtn { display: none; }
body.search-mode-button .topbar .search { display: none; }
body.search-mode-button .topbar { grid-template-columns: minmax(200px, 1fr) auto; }
/* "both" keeps the default — search input + 🔍 button */

/* API reference cards */
.api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}
.api-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.api-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 0;
}
.api-module {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.api-card code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  background: var(--surface-2);
  padding: 6px 8px;
  border-radius: var(--r-sm);
  word-break: break-all;
}
.api-card p { font-size: 12px; line-height: 1.5; color: var(--text-2); }

/* Permission / reference tables — read-only (no row hover, no clickable feel) */
.permission-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.permission-table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--line);
}
.permission-table tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  font-size: 13px;
  cursor: default;
}
.permission-table tbody td:first-child { color: var(--ink); font-weight: 500; }
.permission-table tbody tr { cursor: default; }
.permission-table tbody tr:hover { background: transparent; }
.permission-table tbody tr:last-child td { border-bottom: 0; }

/* Launch list */
.launch-list { display: flex; flex-direction: column; gap: 8px; }
.launch-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.launch-item strong { font-size: 13px; font-weight: 600; color: var(--ink); grid-column: 1; }
.launch-item .muted { grid-column: 1; font-size: 12px; line-height: 1.5; }
.launch-item .tag { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

/* Audit (right column on admin) */
.audit {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  align-self: stretch;
}
.audit-fixed {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 10px;
}
.audit-filters { display: flex; flex-direction: column; gap: 6px; }
.audit-summary { border-top: 1px solid var(--line); }
.audit-summary .detail-row { padding: 8px 0; }
.audit-events {
  display: flex;
  flex: 1 1 0;
  min-height: 0;
  height: 0;
  overflow-y: auto;
  flex-direction: column;
  padding-right: 4px;
  overscroll-behavior: contain;
}
.audit-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.audit-item:last-child { border-bottom: 0; }
.audit-item strong { color: var(--ink); font-weight: 500; font-size: 13px; }
.audit-pager {
  flex: none;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* ============== Modals ============== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.4);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-pop);
  max-height: calc(100vh - 48px);
  overflow: hidden;
}
.modal.large { max-width: 720px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
}

/* Dropzone (upload) */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 20px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  text-align: center;
  background: var(--surface-2);
}
.dropzone strong { font-size: 13px; color: var(--ink); }
.dropzone .muted { font-size: 12px; max-width: 320px; }

.upload-queue { display: flex; flex-direction: column; gap: 8px; }
.upload-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.upload-item strong { font-size: 13px; color: var(--ink); font-weight: 500; }
.upload-item .muted { font-family: var(--mono); font-size: 11px; }
.upload-item .bar { grid-column: 1 / -1; margin-top: 2px; }

/* Trash */
.trash-note {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--r-md);
}
.trash-note strong { font-size: 13px; color: var(--ink); }
.trash-note .muted { font-size: 12px; }
.trash-list { display: flex; flex-direction: column; gap: 6px; }
.trash-list > * {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 13px;
}

/* ============== Drawer ============== */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  z-index: 60;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}
.drawer.active { transform: translateX(0); }
.drawer .modal-head { border-bottom: 1px solid var(--line); }
.drawer-body {
  flex: 1;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}
.drawer-body h3 { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.drawer-body .detail-row { font-size: 13px; padding: 8px 0; }
.drawer-body .field { gap: 4px; }
.drawer-body .field span { font-size: 12px; }

/* ============== Context menu ============== */
.context-menu {
  position: fixed;
  z-index: 40;
  display: none;
  flex-direction: column;
  min-width: 160px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
}
.context-menu.active { display: flex; }
.context-menu button {
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text);
  background: transparent;
}
.context-menu button:hover { background: var(--surface-2); color: var(--ink); }

/* ============== Preview body ============== */
.preview-body {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 24px;
  min-height: 240px;
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.preview-mock {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preview-mock.image-mock,
.preview-mock.generic-mock {
  aspect-ratio: 4 / 3;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: #fff;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.preview-mock.pdf-mock { aspect-ratio: 3 / 4; max-width: 260px; padding: 24px; }
.pdf-page { display: flex; flex-direction: column; gap: 8px; }
.pdf-line { height: 6px; background: var(--line); border-radius: 1px; }
.pdf-line.w-90 { width: 90%; }
.pdf-line.w-85 { width: 85%; }
.pdf-line.w-80 { width: 80%; }
.pdf-line.w-75 { width: 75%; }
.pdf-line.w-70 { width: 70%; }
.pdf-line.w-65 { width: 65%; }
.pdf-line.w-60 { width: 60%; }
.pdf-line.w-50 { width: 50%; }
.preview-mock.sheet-mock { padding: 0; max-width: 360px; overflow: hidden; }
.sheet-row { display: grid; grid-template-columns: repeat(4, 1fr); }
.sheet-row span { height: 28px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.sheet-row span:last-child { border-right: 0; }
.sheet-row.head span { background: var(--surface-2); }
.preview-mock.md-mock { gap: 10px; padding: 24px; }
.md-h1 { height: 16px; width: 60%; background: var(--ink); border-radius: 2px; }
.md-h2 { height: 12px; width: 40%; background: var(--text-2); border-radius: 2px; margin-top: 4px; }
.md-line { height: 6px; background: var(--line); border-radius: 1px; }
.md-line.w-90 { width: 90%; }
.md-line.w-85 { width: 85%; }
.md-line.w-70 { width: 70%; }
.md-line.w-60 { width: 60%; }
.preview-mock.folder-mock { gap: 10px; }
.preview-mock-bar { height: 14px; background: var(--line); border-radius: var(--r-sm); }
.preview-mock-bar.short { width: 40%; }
.preview-hint { font-size: 11px; color: var(--text-3); text-align: center; }

/* ============== Toast ============== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 24px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  box-shadow: var(--shadow-pop);
}
.toast.show,
.toast.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ============== Responsive ============== */
@media (max-width: 1240px) {
  .kb-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .outline.kb-side { display: none; }
}
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .side-panel, .doc-tree, .outline { position: static; max-height: none; }
  .audit {
    position: static;
    height: min(620px, calc(100vh - 96px));
    max-height: min(620px, calc(100vh - 96px));
    overflow: hidden;
  }
  .admin-grid {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .admin-stack {
    max-height: none;
    overflow: visible;
  }
  .cards { grid-template-columns: 1fr 1fr; }
}
/* Sidebar head (logo + collapse button) */
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-collapse {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  color: var(--text-3);
}
.sidebar-collapse:hover { background: var(--surface-2); color: var(--ink); }
.sidebar-collapse svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Desktop collapsed sidebar (icon-only rail) */
body.sidebar-collapsed:not(.sidebar-open) .app { grid-template-columns: 56px 1fr; }
body.sidebar-collapsed:not(.sidebar-open) .sidebar { padding: 16px 8px; gap: 16px; align-items: center; }
body.sidebar-collapsed:not(.sidebar-open) .sidebar .brand-text,
body.sidebar-collapsed:not(.sidebar-open) .sidebar .project-switcher,
body.sidebar-collapsed:not(.sidebar-open) .sidebar .storage { display: none; }
body.sidebar-collapsed:not(.sidebar-open) .sidebar .nav button {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  font-size: 0;
  gap: 0;
}
body.sidebar-collapsed:not(.sidebar-open) .sidebar .nav button svg { width: 16px; height: 16px; }
body.sidebar-collapsed:not(.sidebar-open) .sidebar .nav button.active::before { left: -8px; }
body.sidebar-collapsed:not(.sidebar-open) .sidebar-collapse svg { transform: rotate(180deg); }
body.sidebar-collapsed:not(.sidebar-open) .sidebar-head { justify-content: center; }
body.sidebar-collapsed:not(.sidebar-open) .sidebar-head .brand { display: none; }

/* Doc tree search */
.doc-tree-search {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}
.doc-tree-search svg {
  position: absolute;
  left: 10px;
  width: 12px;
  height: 12px;
  stroke: var(--text-3);
  stroke-width: 1.6;
  fill: none;
  pointer-events: none;
}
.doc-tree-search input {
  height: 30px;
  padding: 0 10px 0 30px;
  background: var(--surface-2);
  border: 1px solid transparent;
  font-size: 12px;
}
.doc-tree-search input:hover { background: #EEEEEE; }
.doc-tree-search input:focus { background: var(--surface); border-color: var(--ink); outline: 0; }

/* Sidebar toggle & scrim — hidden on desktop */
.sidebar-toggle { display: none; }
.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.4);
  z-index: 39;
}
body.sidebar-open .sidebar-scrim { display: block; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .login-screen { flex-direction: column; gap: 24px; padding: 24px 16px; align-items: stretch; }
  .login-brand, .login-panel { flex: 1 1 auto; max-width: 100%; }
  .login-copy h1 { font-size: 28px; }
  .sidebar-toggle {
    display: inline-grid;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-md);
    color: var(--ink);
  }
  .sidebar-toggle:hover { background: var(--surface-2); border-color: var(--ink); }
  .sidebar-toggle svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.6;
    fill: none;
    stroke-linecap: round;
  }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    height: 100vh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    flex-direction: column;
    border-right: 1px solid var(--line);
    padding: 20px 16px;
    gap: 24px;
    overflow-y: auto;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .nav { flex-direction: column; }
  .project-switcher, .storage { width: 100%; }
  .topbar {
    grid-template-columns: auto 1fr auto;
    height: auto;
    min-height: var(--topbar-h);
    padding: 12px 16px;
    gap: 12px;
  }
  .page-title h1 { font-size: 18px; }
  .search { display: none; }
  .top-actions { gap: 6px; }
  .top-actions .btn { padding: 0 10px; font-size: 12px; }
  .admin-view-tabs { gap: 20px; }
  .admin-view-tabs button { font-size: 18px; }
  .row-action-hover { display: none; }
  .content { padding: 16px; }
  .login-screen { padding: 24px 16px; }
  .login-copy h1 { font-size: 32px; }
  .kb-layout { grid-template-columns: 1fr; }
  .doc-tree { position: static; max-height: none; }
  .share-toolbar, .admin-toolbar { grid-template-columns: 1fr; }
  .share-list-head { display: none; }
  .share-row {
    grid-template-columns: 1fr;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    margin-bottom: 8px;
  }
  .share-row .config-actions {
    justify-content: flex-start;
  }
  .form-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .settings-grid, .admin-config-grid { grid-template-columns: 1fr; }
  .drive-grid-mode .drive-grid { grid-template-columns: 1fr; }
  .panel-head,
  .editor-title-row,
  .admin-alert,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }
  .panel-head-tools,
  .file-toolbar-actions,
  .doc-actions,
  .config-actions {
    flex-wrap: wrap;
  }
  .table,
  .admin-table,
  .permission-table {
    display: block;
    overflow-x: auto;
  }
  .table th,
  .table td,
  .admin-table th,
  .admin-table td,
  .permission-table th,
  .permission-table td {
    white-space: nowrap;
  }
}

/* ============== Dynamically generated by app.js ============== */

/* Project switcher cards */
.project-option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.project-option:hover { border-color: var(--line); background: var(--surface-2); }
.project-option.active {
  background: var(--surface-2);
  border-color: var(--line);
}
.project-option-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.project-option-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-option-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
}

/* Drive card (grid mode) */
.drive-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.12s;
  position: relative;
}
.drive-card.selected,
.drive-card.active { background: var(--surface-2); }
.drive-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.drive-card-title-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.drive-card-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.drive-card-type {
  font-size: 10px;
  color: var(--text-3);
  font-family: var(--mono);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.drive-card-meta {
  display: none;
}
.drive-card-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: auto;
}
.drive-card-actions > .muted { display: none; }
.drive-card .icon-btn.mini[data-toast="已打开更多操作"] { display: none; }
.drive-card .btn { height: 26px; padding: 0 10px; font-size: 11px; }
.drive-card .icon-btn.mini { width: 22px; height: 22px; font-size: 11px; }

/* Row actions inline — hover-only secondary actions */
.row-actions {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  min-width: 144px;
}
.table td:last-child { text-align: right; }
.row-action-hover {
  opacity: 0;
  transform: translateX(4px);
  transition: opacity 0.12s, transform 0.12s, background 0.12s, color 0.12s, border-color 0.12s;
  pointer-events: none;
  border: 1px solid var(--line);
  background: var(--surface);
}
.table tbody tr:hover .row-action-hover,
.table tbody tr.active-row .row-action-hover,
.drive-card:hover .row-action-hover,
.drive-card.active .row-action-hover {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.row-action-hover:hover { border-color: var(--ink); background: var(--surface-2); color: var(--ink); }
.row-action-hover[title="删除"]:hover { color: var(--danger); background: #FEF2F2; border-color: rgba(220, 38, 38, 0.3); }

/* Config accordion */
.config-accordion-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.config-accordion {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.config-accordion > summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
  transition: background 0.12s;
  position: relative;
  user-select: none;
}
.config-accordion > summary::-webkit-details-marker,
.config-accordion > summary::marker { display: none; }
.config-accordion > summary::after {
  content: "+";
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 400;
  color: var(--text-3);
  width: 16px;
  text-align: center;
  transition: transform 0.18s ease;
  line-height: 1;
}
.config-accordion[open] > summary::after { content: "−"; }
.config-accordion > summary:hover { background: var(--surface-2); }
.config-accordion-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.config-accordion-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  margin-left: auto;
  margin-right: 8px;
}
.config-accordion[open] > .admin-config-grid,
.config-accordion[open] > .settings-grid {
  padding: 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.config-accordion[open] > .admin-config-grid .config-card,
.config-accordion[open] > .settings-grid .config-card { background: var(--surface); }

/* Mini icon-btn */
.icon-btn.mini { width: 24px; height: 24px; font-size: 12px; }

/* Trash list */
.trash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 13px;
}
.trash-item .file-icon { flex-shrink: 0; }
.trash-item > strong { color: var(--ink); font-weight: 500; flex: 1; min-width: 0; word-break: break-all; }
.trash-item .muted { font-size: 11px; color: var(--text-3); font-family: var(--mono); }
.trash-actions { display: flex; gap: 6px; margin-left: auto; flex-shrink: 0; }

/* Drawer internal layout */
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.drawer-section:last-child { border-bottom: 0; padding-bottom: 0; }
.drawer-section h3 {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}
.drawer-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.drawer-action-grid .btn { width: 100%; }

/* Drawer tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.drawer-tab {
  padding: 8px 12px;
  background: transparent;
  font-size: 13px;
  color: var(--text-3);
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s;
}
.drawer-tab:hover { color: var(--text-2); }
.drawer-tab.active {
  color: var(--ink);
  font-weight: 500;
  border-bottom-color: var(--ink);
}
.drawer-tab-panel { display: none; flex-direction: column; gap: 12px; }
.drawer-tab-panel.active { display: flex; }

/* Mini list (admins, simple lists in drawer) */
.mini-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.mini-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-2);
}
.mini-list li strong { color: var(--ink); font-weight: 500; font-size: 13px; }

/* Share row title (when JS renders multi-line cells) */
.share-row-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.share-row-link {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  word-break: break-all;
}

/* Markdown image placeholder */
.doc-image-placeholder {
  background: var(--surface-2);
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  padding: 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  margin: 12px 0;
}

/* ============== Polish pass ============== */

/* 1. Empty state visual anchor — large mono numeral as Swiss anchor */
.empty-state > div { position: relative; padding-top: 64px; }
.empty-state > div::before {
  content: "00";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 48px;
  font-weight: 500;
  letter-spacing: -0.04em;
  color: var(--line-2);
  line-height: 1;
}
.empty-state.compact-empty > div { padding-top: 48px; }
.empty-state.compact-empty > div::before { font-size: 32px; }

/* 2. Tabular numerals — align numbers across rows */
.metric .value,
.storage-head strong,
.tag, .pill, .role-badge,
.file-icon,
.kb-thumb,
.doc-page-icon,
.doc-dot,
.share-code-highlight,
.upload-item .muted,
.share-row .muted,
.audit-item .muted,
.audit-summary .detail-row strong,
.detail-row strong,
#projectLink,
.project-option-meta {
  font-variant-numeric: tabular-nums;
}
.table tbody td { font-variant-numeric: tabular-nums; }

/* 3. Indicator bar on hoverable list items */
.tree-item,
.kb-asset,
.config-card,
.launch-item,
.trash-item,
.upload-item,
.audit-item,
.share-row,
.drive-card,
.project-option {
  position: relative;
}
.tree-item::before,
.kb-asset::before,
.config-card::before,
.launch-item::before,
.trash-item::before,
.upload-item::before,
.share-row::before,
.drive-card::before,
.project-option::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: transparent;
  border-radius: 1px;
  transition: background 0.12s;
  pointer-events: none;
}
.tree-item:hover::before,
.kb-asset:hover::before,
.config-card:hover::before,
.launch-item:hover::before,
.trash-item:hover::before,
.upload-item:hover::before,
.share-row:hover::before,
.drive-card:hover::before,
.project-option:hover::before {
  background: var(--ink);
}
.tree-item.active::before,
.config-card.active::before,
.project-option.active::before {
  background: var(--ink);
}
/* Share row uses accent box-shadow indicator — suppress the black bar */
.share-row.active::before { display: none; }
/* Drive card selected — keep left indicator visible */
.drive-card.selected::before,
.drive-card.active::before { background: var(--ink); }

/* ============== Top-bar icon cluster ============== */
.icon-cluster {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 0;
}
.icon-cluster .icon-btn {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
}
.icon-cluster .icon-btn:hover { background: var(--surface); }
.top-actions .icon-cluster + .icon-btn,
.top-actions .icon-cluster .icon-btn { border: 0; }

/* ============== Role chip with dropdown ============== */
.role-menu { position: relative; }
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 8px 0 4px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.role-chip:hover { background: var(--surface); border-color: var(--line-2); }
.role-chip-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.role-chip-text { letter-spacing: 0.01em; }
.role-chip-caret { width: 12px; height: 12px; stroke: var(--text-3); stroke-width: 2; fill: none; transition: transform 0.12s; }
.role-menu.open .role-chip-caret { transform: rotate(180deg); }
.role-chip[data-role="content"] .role-chip-avatar { background: var(--accent); }
.role-chip[data-role="system"] .role-chip-avatar { background: var(--ink); }
.role-chip[data-role="guest"] .role-chip-avatar { background: var(--text-3); }

.role-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  padding: 4px;
  display: none;
  flex-direction: column;
  z-index: 50;
}
.role-menu.open .role-popover { display: flex; }
.role-popover button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  border-radius: var(--r-sm);
  text-align: left;
}
.role-popover button:hover { background: var(--surface-2); color: var(--ink); }
.role-popover button svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Notification dot */
.icon-btn { position: relative; }
.icon-btn-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 6px; height: 6px;
  background: var(--danger);
  border-radius: 50%;
  pointer-events: none;
}

/* ============== Cmd+K palette ============== */
.cmdk-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.4);
  z-index: 80;
  display: none;
  justify-content: center;
  padding-top: 12vh;
}
.cmdk-backdrop.active { display: flex; }
.cmdk {
  width: 100%;
  max-width: 560px;
  height: fit-content;
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.cmdk-input-wrap svg { width: 16px; height: 16px; stroke: var(--text-3); stroke-width: 1.6; fill: none; flex-shrink: 0; }
.cmdk-input-wrap input {
  flex: 1;
  height: 28px;
  padding: 0;
  background: transparent;
  border: 0;
  font-size: 15px;
  outline: none;
}
.cmdk-input-wrap kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}
.cmdk-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.cmdk-group { margin-bottom: 8px; }
.cmdk-group-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 6px 10px;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
}
.cmdk-item:hover { background: var(--surface-2); }
.cmdk-item .cmdk-item-text { flex: 1; color: var(--ink); min-width: 0; }
.cmdk-item .muted { font-size: 11px; font-family: var(--mono); }
.cmdk-key {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
}
.cmdk-foot {
  display: flex;
  gap: 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--text-3);
}
.cmdk-foot kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: var(--r-sm);
  margin-right: 2px;
}

/* ============== Notification & Help drawer ============== */
.notif-drawer, .help-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  z-index: 60;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}
.notif-drawer.active, .help-drawer.active { transform: translateX(0); }
.notif-body, .help-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
}
.notif-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  position: relative;
  cursor: pointer;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item strong { font-size: 13px; color: var(--ink); font-weight: 500; }
.notif-item .muted { font-size: 11px; margin-top: 2px; }
.notif-item.unread::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 8px;
  flex-shrink: 0;
}
.notif-item:not(.unread) { padding-left: 22px; }

.help-section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.help-section:last-child { border-bottom: 0; }
.help-section h3 {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}
.help-keys { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.help-keys li { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.help-keys li span { margin-left: 8px; }
.help-keys kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-2);
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: var(--r-sm);
  min-width: 20px;
  text-align: center;
}
.help-section a {
  display: block;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.help-section a:last-child { border-bottom: 0; }
.help-section a:hover { color: var(--accent); }

/* ============== Version history modal ============== */
.versions-list {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-left: 16px;
}
.versions-list::before {
  content: "";
  position: absolute;
  left: 3px; top: 12px; bottom: 12px;
  width: 1px;
  background: var(--line);
}
.versions-list .version-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  position: relative;
}
.version-mark {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line-2);
  margin-left: -16px;
  flex-shrink: 0;
  z-index: 1;
}
.version-item.current .version-mark { background: var(--ink); border-color: var(--ink); width: 9px; height: 9px; margin-left: -17px; }
.version-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.version-meta strong { font-size: 13px; color: var(--ink); font-weight: 500; }
.version-meta .muted { font-size: 12px; }
.version-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.12s; }
.versions-list .version-item:hover .version-actions { opacity: 1; }
.version-tip { font-size: 11px; padding-top: 8px; border-top: 1px solid var(--line); margin-top: 8px; }

/* ============== Backup grid ============== */
.backup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.backup-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.backup-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.backup-card-head .muted { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.backup-card-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.backup-card .muted { font-size: 12px; color: var(--text-3); }

/* ============== 1280px mid-screen breakpoint ============== */
@media (max-width: 1280px) {
  .workspace { grid-template-columns: 1fr; }
  .drive-detail-panel { display: none; }
  .file-detail-drawer-mode .drive-detail-panel.active { display: flex; }
  .backup-grid { grid-template-columns: 1fr; }
}

/* ============== Dark mode ============== */
html[data-theme="dark"] {
  --bg: #0A0A0A;
  --surface: #141414;
  --surface-2: #1F1F1F;
  --ink: #FAFAFA;
  --text: #E5E5E5;
  --text-2: #A3A3A3;
  --text-3: #737373;
  --line: #262626;
  --line-2: #404040;
  --accent: #3B82F6;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --shadow-pop: 0 8px 32px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"] body { color: var(--text); }
html[data-theme="dark"] .btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
html[data-theme="dark"] .btn.primary:hover { background: #E5E5E5; border-color: #E5E5E5; }
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .side-panel,
html[data-theme="dark"] .config-card,
html[data-theme="dark"] .cmdk,
html[data-theme="dark"] .notif-drawer,
html[data-theme="dark"] .help-drawer,
html[data-theme="dark"] .drawer { background: var(--surface); }
html[data-theme="dark"] .search input,
html[data-theme="dark"] .doc-tree-search input,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] select,
html[data-theme="dark"] textarea { background: var(--surface-2); color: var(--text); }
html[data-theme="dark"] .file-icon { background: var(--surface-2); }
html[data-theme="dark"] .file-icon.folder { background: var(--accent); color: #fff; }
html[data-theme="dark"] .nav button.active::before { background: var(--accent); }
html[data-theme="dark"] .preview-mock.image-mock,
html[data-theme="dark"] .preview-mock.generic-mock { background: var(--accent); }
html[data-theme="dark"] .login-screen { background: var(--bg); }

/* Drag-over highlight on dropzone */
.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.dropzone.is-dragover strong { color: var(--accent); }

/* Real image preview */
.preview-mock.image-real {
  aspect-ratio: 4 / 3;
  padding: 0;
  background: var(--surface-2);
  overflow: hidden;
  align-items: stretch;
}
.preview-mock.image-real img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Project switch fade */
.main.switching { opacity: 0.4; transition: opacity 0.16s ease; }
.main { transition: opacity 0.18s ease; }

/* Row leaving animation (after move) */
.row-leaving {
  transition: opacity 0.24s ease, transform 0.24s ease;
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
}

/* Audit metric cards */
.audit-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.audit-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.audit-metric .label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.audit-metric strong {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.audit-metric .muted { font-size: 10px; color: var(--text-3); line-height: 1.3; }
/* Audit-item: no left indicator (read-only feed), but lift typography */
.audit-item strong { transition: color 0.12s; }
.audit-item:hover strong { color: var(--accent); }
