:root {
  /* Without this the browser renders native controls -- select buttons, their
     popup menus, checkboxes, range tracks, scrollbars -- in light mode. A
     <select> then paints its own light chrome over the background set below,
     and because the option text inherits --text the popup is white on white:
     the picker looks like a blank white button with an invisible menu. */
  color-scheme: dark;

  --bg: #0f1216;
  --panel: #161b22;
  --panel-2: #1c2129;
  --line: #262d38;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #6aa9ff;
  --ok: #7ee787;
  --warn: #f2a65a;
  --person: #6aa9ff;
  --organization: #f2a65a;
  --project: #7ee787;
  --topic: #c792ea;
  --role: #ffd166;
  --date: #9aa7b6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body { display: flex; flex-direction: row; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 15px; margin: 0; letter-spacing: .2px; }
.sub { margin: 0; font-size: 11.5px; color: var(--muted); }
.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 12px var(--ok);
}
select, input[type="search"], input[type="text"], input[type="password"] {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit;
}
/* `appearance: none` is what actually makes a <select> honour the background
   above: left on `auto` the browser paints its own light control chrome on top,
   which turned every picker into a blank white button. The arrow is a data-URI
   chevron because the native one goes away with the native chrome, and this UI
   has to work with no network. */
select {
  font-size: 12.5px;
  appearance: none; -webkit-appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b98a9' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
select:focus-visible, input:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
/* The popup is drawn by the OS; without these the options inherit --text and
   land as near-white on a near-white menu. */
select option { background: var(--panel-2); color: var(--text); }
.counts { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.counts b { color: var(--text); font-weight: 600; }

.shell { display: flex; height: 100%; width: 100%; }

.sidebar {
  flex: 0 0 240px; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto;
}
.sidebar .brand { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.switchers { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.switchers select { width: 100%; margin-bottom: 8px; }
.switchers .counts { flex-wrap: wrap; margin-top: 4px; }

.sidenav { display: flex; flex-direction: column; padding: 4px 8px 8px; gap: 2px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group + .nav-group { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
  padding: 8px 12px 2px;
}
/* second-level items indent under their group label */
.nav-group .nav-item { padding-left: 24px; }
.nav-item {
  text-align: left; background: none; border: none; color: var(--muted);
  padding: 9px 12px; border-radius: 6px; font: inherit; font-size: 13px; cursor: pointer;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active {
  background: var(--panel-2); color: var(--text); font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

/* Account: sidebar footer + the account section */
.account { margin-top: auto; padding: 10px 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.account-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-who b { font-size: 13px; }
.account-who small { font-size: 11px; }

#section-account .row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
#section-account .row span:first-child { flex: 1; }
#section-account .arg-row { display: flex; gap: 8px; align-items: flex-end; }
#section-account .arg-row input, #section-account .arg-row select { width: auto; flex: 1; }
#section-account .new-key { word-break: break-all; padding: 8px 10px; background: var(--panel-2); border-radius: 6px; margin: 8px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.content-section { overflow-y: auto; min-width: 0; padding: 18px 22px; grid-column: 1 / -1; }
main:not(.data-mode) .content-section { display: none; }

/* The right panel's width lives in a custom property so the collapse toggle can
   anchor to the panel edge without JS measuring anything. */
main {
  flex: 1; min-width: 0; min-height: 0; position: relative;
  --right-w: 380px;
  display: grid; grid-template-columns: 268px minmax(0, 1fr) var(--right-w);
}
main.right-collapsed { --right-w: 0px; }
main.right-collapsed aside.right { display: none; }
main.data-mode { grid-template-columns: minmax(0, 1fr); }
main.data-mode > aside, main.data-mode > .center, main.data-mode > #right-toggle { display: none; }

aside.left { border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel); }
aside.right {
  border-left: 1px solid var(--line); overflow-y: auto; background: var(--panel);
  display: flex; flex-direction: column; min-width: 0;
}
#right-toggle {
  position: absolute; top: 10px; right: var(--right-w); width: 24px; height: 46px;
  border: 1px solid var(--line); border-right: none; border-radius: 6px 0 0 6px;
  background: var(--panel-2); color: var(--muted); cursor: pointer;
  font-size: 13px; line-height: 1; padding: 0; z-index: 6;
}
#right-toggle:hover { color: var(--text); border-color: var(--accent); }
.center { position: relative; min-width: 0; }

.panel { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 8px; }
input[type="search"] { width: 100%; }

.results { margin-top: 8px; max-height: 220px; overflow-y: auto; }
.result {
  padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex;
  align-items: center; gap: 8px; font-size: 12.5px;
}
.result:hover { background: var(--panel-2); }
.result .tag { font-size: 10px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
  font-size: 11.5px; cursor: pointer; user-select: none; background: var(--panel-2);
  display: flex; align-items: center; gap: 6px;
}
.chip.off { opacity: .35; }
.chip .swatch { width: 8px; height: 8px; border-radius: 50%; }
.chips.small .chip { font-size: 11px; padding: 2px 8px; }
.slider { display: block; margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.slider input { width: 100%; }

.legend div.row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 4px; }

.canvas-wrap { position: absolute; inset: 0; }
canvas { display: block; width: 100%; height: 100%; cursor: grab; }
canvas.dragging { cursor: grabbing; }
.canvas-hint {
  position: absolute; left: 14px; bottom: 12px; font-size: 11px; color: var(--muted);
  pointer-events: none;
}
.ghost-btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.ghost-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ghost-btn:disabled { opacity: .55; cursor: wait; }
.danger-btn { color: #ff7b72; border-color: #6e3030; }
.danger-btn:hover:not(:disabled) { background: #321f22; border-color: #a64141; }
#refit { position: absolute; right: 14px; bottom: 12px; }
.zoom-controls { position: absolute; right: 14px; bottom: 44px; display: flex; flex-direction: column; gap: 6px; }
.zoom-controls .ghost-btn { width: 30px; height: 30px; padding: 0; font-size: 16px; line-height: 1; text-align: center; }
.primary {
  background: var(--accent); color: #08111d; border: 0; border-radius: 6px;
  padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; margin-top: 10px;
}
.primary:disabled { opacity: .5; cursor: default; }

.tooltip {
  position: absolute; pointer-events: none; background: rgba(12,16,22,.96);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px;
  max-width: 280px; box-shadow: 0 8px 28px rgba(0,0,0,.45); z-index: 5;
}
.hidden { display: none !important; }

.tabs { display: flex; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.tab {
  flex: 1; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 10px 4px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { padding: 14px; overflow-y: auto; }

h2.entity-name { margin: 0 0 2px; font-size: 17px; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 3px 10px; font-size: 12.5px; margin: 10px 0; }
.kv div:nth-child(odd) { color: var(--muted); }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
  margin: 16px 0 6px; border-top: 1px solid var(--line); padding-top: 10px;
}
.rel {
  display: flex; justify-content: space-between; gap: 8px; padding: 5px 6px;
  border-radius: 6px; font-size: 12.5px; cursor: pointer;
}
.rel:hover { background: var(--panel-2); }
.rel .pred { color: var(--muted); font-size: 11px; }
.rel .w { color: var(--muted); font-size: 11px; }
.doc { padding: 6px; border-radius: 6px; font-size: 12.5px; border-bottom: 1px solid var(--line); }
.doc .meta { color: var(--muted); font-size: 11px; display: flex; gap: 8px; }
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 10.5px;
  border: 1px solid var(--line); color: var(--muted);
}
.badge.header { color: var(--ok); border-color: #204a2b; }
.badge.llm { color: var(--accent); border-color: #1e3556; }
.muted { color: var(--muted); font-size: 12.5px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
th, td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
tr.clickable:hover { background: var(--panel-2); cursor: pointer; }

.arg-row { margin: 8px 0; }
.arg-row label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.arg-row input, .arg-row select { width: 100%; }
.arg-row #drop-folder { margin-top: 6px; }
.arg-row #drop-folder-hint { margin: 6px 0 0; font-size: 11.5px; }

.dropzone {
  border: 2px dashed var(--line); border-radius: 10px; padding: 28px 14px; text-align: center;
  display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 12.5px;
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); background: rgba(106,169,255,.07); }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; }
.job {
  margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel-2); font-size: 12.5px;
}
.job .status { font-weight: 600; }
.job .status.done { color: var(--ok); }
.job .status.error { color: #ff7b72; }
.bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.obs { border-left: 2px solid var(--accent); padding-left: 10px; margin: 8px 0; font-size: 12.5px; }

/* --- view switch + the three-tier data workspace ------------------------- */

.viewswitch { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.view {
  background: var(--panel-2); border: 0; color: var(--muted); font: inherit; font-size: 12px;
  padding: 6px 14px; cursor: pointer;
}
.view.active { background: var(--accent); color: #08111d; font-weight: 600; }

.data-view { overflow-y: auto; min-width: 0; }
.tabs.wide .dtab {
  flex: 0 0 auto; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 11px 18px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.tabs.wide .dtab.active { color: var(--text); border-bottom-color: var(--accent); }
.dtab-body { padding: 16px 20px 40px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }

.card {
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px;
  background: var(--panel); margin-bottom: 9px;
}
.card.selected { border-color: var(--accent); }
.card .title { font-weight: 600; display: flex; justify-content: space-between; gap: 10px; }
.card .row { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 11.5px; margin-top: 4px; }
/* A layer can own hundreds of source files. Give the line the full width, let it
   shrink (min-width: 0 -- otherwise a flex child refuses to go below its content
   width and the truncation never happens) and cut it with an ellipsis; the whole
   list stays one hover (title) or one click (the documents toggle) away. */
.card .row .src-line {
  flex: 1 1 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.drop-form .drop-who { margin: 2px 0 10px; }
.card .actions { display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap; }

.crumbs { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; margin-bottom: 9px; }
.crumbs a { color: var(--accent); cursor: pointer; text-decoration: none; }
.crumbs span { color: var(--muted); }

.filerow {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 6px;
  font-size: 12.5px; cursor: pointer; border-bottom: 1px solid var(--line);
}
.filerow:hover { background: var(--panel-2); }
.filerow .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filerow .size { color: var(--muted); font-size: 11px; white-space: nowrap; }
.filerow .icon { color: var(--muted); width: 15px; text-align: center; }

.sources {
  max-height: 230px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 9px; background: var(--panel-2);
}
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 5px 0; cursor: pointer; }
.check input { margin: 0; }
.check .count { color: var(--muted); font-size: 11px; }

pre.md {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; font-size: 12px; line-height: 1.55; white-space: pre-wrap;
  word-break: break-word; max-height: 62vh; overflow-y: auto; margin: 0;
}
.prov {
  font-size: 11.5px; color: var(--muted); border-left: 2px solid var(--ok);
  padding: 4px 0 4px 10px; margin: 8px 0;
}
.prov code { word-break: break-all; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 10.5px;
  border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: #204a2b; }
.pill.bad { color: var(--warn); border-color: #55391c; }
.pill.running { color: var(--accent); border-color: #1e5a8a; }
.pill.stopped { color: #ffb86b; border-color: #6a4824; }
.drop-form { margin-bottom: 12px; }
.log { font-size: 11px; color: var(--muted); max-height: 130px; overflow-y: auto; margin-top: 7px; }
.log div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; }
.filter-bar input[type="search"] { flex: 1; }
.filter-bar select { flex: 0 0 160px; }

.cart-tray {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 12px;
  margin-top: 16px; padding: 10px 14px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px;
}
.cart-tray select { flex: 1; max-width: 320px; }
.cart-check { margin-right: 8px; }

/* --- global task centre + toasts ------------------------------------------ */

/* The sidebar's utility row -- language on the left, tasks on the right --
   under a divider that separates it from the menu above. */
.sidebar-utility {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 8px 12px 6px; padding-top: 10px; border-top: 1px solid var(--line);
}

.tasks-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; background: none; border: 0; border-radius: 999px;
  color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer;
}
.tasks-btn:hover { background: var(--panel-2); color: var(--text); }
.tasks-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tasks-btn .tasks-icon { flex: none; opacity: .85; }
.tasks-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #08111d; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.tasks-badge.busy { animation: tasks-pulse 1.4s ease-in-out infinite; }
@keyframes tasks-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.tasks-panel {
  position: fixed; top: 12px; right: 12px; width: 380px;
  max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow-y: auto;
  z-index: 40; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); padding: 12px;
}
.tasks-panel h2 {
  font-size: 13px; margin: 0 0 10px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--muted);
}
.task {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 8px; background: var(--panel-2); font-size: 12.5px;
}
.task .task-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task .task-name { font-weight: 600; }
.task .task-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.task .status { font-weight: 600; }
.task .status.done { color: var(--ok); }
.task .status.error { color: #ff7b72; }
.task .status.stopped { color: #ffb86b; }
.task .task-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.toasts {
  position: fixed; bottom: 16px; right: 16px; z-index: 50;
  display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); font-size: 13px; line-height: 1.4;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: #ff7b72; }
.toast .toast-msg { flex: 1; min-width: 0; }
.toast .toast-close {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 2px;
}
.toast .toast-close:hover { color: var(--text); }
.toast .toast-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- modal (replaces native confirm()/prompt()) ---------------------------- */

.modal-root {
  position: fixed; inset: 0; z-index: 60; background: rgba(4,6,9,.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  width: 100%; max-width: 460px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.6);
  display: flex; flex-direction: column; max-height: calc(100vh - 40px);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.modal-title { margin: 0; font-size: 15px; }
.modal-x {
  background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.modal-x:hover { color: var(--text); background: var(--panel-2); }
.modal-x:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.modal-body { padding: 16px; overflow-y: auto; font-size: 13px; line-height: 1.55; white-space: pre-line; }
.modal-body .lbl { display: block; }
.modal-body input[type="text"] { width: 100%; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.modal-foot .primary { margin-top: 0; }

/* --- accessibility & readability pass ------------------------------------- */

/* Keyboard users need a visible focus ring on every operable control. */
.nav-item:focus-visible, .chip:focus-visible, .primary:focus-visible,
.tab:focus-visible, .view:focus-visible, .dtab:focus-visible,
.result:focus-visible, .rel:focus-visible, .filerow:focus-visible,
.crumbs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Lift sub-12px text that is read as body copy, and widen touch targets. */
.lbl { font-size: 12px; }
th { font-size: 12px; }
.log { font-size: 12px; }
.canvas-hint { font-size: 12px; }
.sub { font-size: 12px; }
.arg-row label { font-size: 12px; }
.chip { font-size: 12px; padding: 5px 10px; }
.chips.small .chip { font-size: 12px; padding: 4px 9px; }
.badge, .pill { font-size: 11px; }
.ghost-btn { padding: 6px 12px; min-height: 26px; }
#right-toggle { width: 28px; }
.modal-x { min-width: 28px; min-height: 28px; }

/* Lock/unlock glyphs are inline SVG, not emoji. */
.pill svg { vertical-align: -1px; margin-right: 4px; }

/* First-run empty state on the graph canvas. */
.graph-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center;
  padding: 24px;
}
.graph-empty strong { font-size: 16px; }
.graph-empty .graph-empty-actions { display: flex; gap: 8px; margin-top: 8px; }
.graph-empty .graph-empty-actions .primary { margin-top: 0; }

/* --- layer document list + picker ----------------------------------------- */

.modal-card.wide { max-width: 720px; }

.docs { margin-top: 8px; }
.docs-toggle { font-size: 12px; }
.docs-body {
  margin-top: 6px; border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 6px;
}
/* The action bar sits above the list and outside its scroll box, so "add
   documents" stays reachable however long the cart is. */
.docs-bar { display: flex; align-items: center; gap: 8px; padding: 2px 2px 6px; }
.doc-list { max-height: 220px; overflow-y: auto; }
.doc-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px;
  font-size: 12px; border-bottom: 1px solid var(--line);
}
.doc-row:last-child { border-bottom: none; }
.doc-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Drop history: one compact line per drop. File names are long tokens, so they
   break anywhere rather than stretching the table, and they sit behind a toggle
   instead of in the operator's face. */
.drop-detail { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; padding: 2px 0 6px; color: var(--muted); font-size: 11.5px; }
.drop-detail .drop-note { color: var(--text); }
.file-names { flex: 1 1 100%; max-height: 150px; overflow-y: auto; overflow-wrap: anywhere; line-height: 1.55; }

.doc-picker input[type="search"] { width: 100%; margin-bottom: 8px; }
.doc-picker-list { max-height: 42vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; padding: 2px; }
.doc-picker-row { border-radius: 6px; }

/* Bulk selection: a corpus of hundreds of files cannot be picked one by one.
   `select all` always means "all rows the filters currently show". */
.picker-tools { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.picker-tools .grow { flex: 1 1 180px; min-width: 140px; }
.picker-tools select { max-width: 220px; }
.picker-tools button { white-space: nowrap; }
.picker-summary { margin-bottom: 6px; }
.picker-group {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; margin-top: 4px;
  border-radius: 6px; background: var(--panel-2); font-size: 12px; color: var(--muted);
}
.picker-group .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-group .size { white-space: nowrap; }

/* --- layer wizard ---------------------------------------------------------- */

.wizard-steps { display: flex; gap: 8px; margin-bottom: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.wizard-step { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); }
.wizard-step.active { background: var(--accent); color: #08111d; border-color: var(--accent); font-weight: 600; }
.wizard-step.done { color: var(--ok); border-color: #204a2b; }
.wizard .lbl { display: block; }
.wizard input[type="text"], .wizard select { width: 100%; margin-bottom: 10px; }
.wizard .doc-picker-list { max-height: 38vh; }

/* --- section page header + layers layout ----------------------------------- */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 14px; flex-wrap: wrap;
}
.page-head-text { flex: 1; min-width: 0; }
.page-head-text h2 { margin: 0 0 4px; font-size: 17px; }
.page-head-text .muted { margin: 0; }
.page-head .primary { margin-top: 2px; flex-shrink: 0; }

#nl-status { margin-bottom: 12px; }
#nl-status .job { margin-top: 0; border-left: 3px solid var(--accent); }

.empty-card {
  border: 1px dashed var(--line); border-radius: 10px; padding: 32px 20px;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-card strong { font-size: 15px; }
.empty-card .primary { margin-top: 4px; }

/* Skeleton loading states (cards + rows). */
.sk-line {
  height: 12px; border-radius: 6px; background: var(--panel-2);
  animation: sk-pulse 1.2s ease-in-out infinite;
}
.sk-line.w20 { width: 20%; }
.sk-line.w25 { width: 25%; }
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; }
.sk-line.w70 { width: 70%; }
.sk-card .sk-line { margin: 6px 0; }
.sk-row {
  display: flex; align-items: center; gap: 12px; padding: 8px;
  border-bottom: 1px solid var(--line);
}
.sk-row .sk-line { height: 10px; }
@keyframes sk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  .sk-line { animation: none; }
}

/* Files page: master-detail layout. */
.files-summary { margin-top: 10px; font-size: 11.5px; }
.file-detail-body {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; min-height: 220px; overflow-y: auto;
  max-height: calc(100vh - 210px);
}
.detail-tier .section-title { margin-top: 14px; }

/* --- graph: keyboard focus + list view ------------------------------------ */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
#graph:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.graph-viewswitch { position: absolute; top: 12px; left: 12px; z-index: 4; }

.graph-list {
  position: absolute; inset: 0; overflow-y: auto; background: var(--bg);
  padding: 50px 14px 16px;
}
.graph-list .list-meta { margin-bottom: 8px; font-size: 12px; color: var(--muted); }

.canvas-wrap.list-mode #graph,
.canvas-wrap.list-mode #tooltip,
.canvas-wrap.list-mode .canvas-hint,
.canvas-wrap.list-mode #graph-empty,
.canvas-wrap.list-mode #refit,
.canvas-wrap.list-mode .zoom-controls { display: none; }
.canvas-wrap:not(.list-mode) #graph-list { display: none; }

/* --- language switch ------------------------------------------------------- */

/* A utility toggle, not a primary action: a small pill that hugs its content,
   with the active side tinted rather than filled solid. */
.lang-switch {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
}
.lang-btn {
  background: none; border: 0; border-radius: 999px; color: var(--muted);
  font: inherit; font-size: 11.5px; line-height: 1; padding: 4px 10px; cursor: pointer;
}
.lang-btn:hover { color: var(--text); }
.lang-btn.active { background: rgba(106,169,255,.16); color: var(--accent); font-weight: 600; }
.lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }


/* --- global load indicator -------------------------------------------------- */

/* One thin bar at the top of the viewport, so a slow section never reads as a
   freeze. progressStart() holds it back for ~180ms: a local request that answers
   faster than that must not flash a bar, and the 3s task poll opts out. */
#global-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 200;
  pointer-events: none; opacity: 0; transition: opacity .18s linear;
}
#global-progress > i {
  display: block; height: 100%; width: 0;
  background: var(--accent); box-shadow: 0 0 8px rgba(106,169,255,.6);
}
body.is-loading #global-progress { opacity: 1; }
body.is-loading #global-progress > i {
  width: 85%; transition: width 9s cubic-bezier(.1, .55, .25, 1);
}
body.is-loaded #global-progress { opacity: 1; }
body.is-loaded #global-progress > i { width: 100%; transition: width .18s ease-out; }
@media (prefers-reduced-motion: reduce) {
  body.is-loading #global-progress > i { width: 100%; transition: none; }
}
