:root {
  --memory: 240px;
  --sources: 400px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 14px/1.45 system-ui, sans-serif;
}
button, input, textarea, select { font: 13px/1.35 system-ui, sans-serif; color: var(--ink); }
button { background: transparent; border: 0; padding: 0; cursor: pointer; }
.kicker { margin: 0 0 8px; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.terminal-name { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 650; letter-spacing: 0.01em; }
.progress .pace { margin: 4px 0 10px; color: var(--accent); }
.meta { color: var(--muted); font-size: 12px; line-height: 1.4; }
.error { color: var(--danger); font-size: 13px; }

.terminal { display: flex; height: 100vh; min-width: 960px; background: var(--paper); }
.memory, .workspace, .sources { position: relative; }
.memory { width: var(--memory); flex: none; border-right: 1px solid var(--line); overflow: auto; transition: width 220ms ease; background: var(--paper); }
.terminal.collapsed .memory { width: 52px; }
.terminal.collapsed .memory-body { display: none; }
.terminal.collapsed .resizer[data-panel="memory"] { display: none; }
.resizer { flex: none; width: 7px; margin: 0 -3px; position: relative; z-index: 2; cursor: col-resize; touch-action: none; }
.resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; background: transparent; transition: background 120ms ease; }
.resizer:hover::after, .terminal.resizing .resizer.active::after { background: var(--accent); }
.terminal.resizing { cursor: col-resize; user-select: none; }
.terminal.resizing .memory, .terminal.resizing .sources { transition: none; }
.terminal.resizing iframe, .terminal.resizing canvas { pointer-events: none; }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: #061821; }
.workspace-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; overflow: hidden; padding: 16px 20px 8px; }
.sources { width: var(--sources); flex: none; border-left: 1px solid var(--line); overflow: auto; background: var(--panel); transition: width 220ms ease; }
.terminal.inspecting { --sources: min(50vw, 760px); }

.liquid::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 20%, rgba(0, 237, 100, 0.22) 50%, transparent 80%);
  transform: translateX(-120%);
  animation: sweep 460ms ease;
}
@keyframes sweep { to { transform: translateX(120%); } }

.brand { padding: 16px 12px 8px; }
#collapse-memory { font: 15px/1 system-ui, sans-serif; font-weight: 650; letter-spacing: 0.04em; color: var(--accent); }
.memory-body { padding: 0 12px 24px; }
#memory-search, .source-search, input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #001821;
  color: var(--ink);
  padding: 7px 8px;
  border-radius: 2px;
}
input:focus, textarea:focus, select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
#memory-search { margin-bottom: 12px; }
nav ul, #recent, #scope-options { list-style: none; margin: 0; padding: 0; }
.folder, .recent-item, .source-row, #scope-options button, #scope-button, #filter-button, .inspector-bar button, .sheet-actions button {
  position: relative;
  overflow: hidden;
}
.folder { display: flex; gap: 6px; width: 100%; text-align: left; padding: 5px 6px; border-radius: 2px; color: var(--ink); }
.folder:hover, .source-row:hover, .recent-item:hover, #scope-options button:hover { background: var(--raised); }
.folder[aria-current="true"] { background: var(--hit); color: var(--accent); }
.folder .mark { width: 12px; color: var(--muted); }
.folder-row { display: flex; align-items: center; gap: 2px; }
.folder-row .folder, .folder-row .point { flex: 1; min-width: 0; }
.model-row .folder { font-weight: 600; }
.model-row > .meta { flex: none; font-size: 11.5px; }
.model-link { flex: none; padding: 1px 8px; border: 1px solid var(--line); border-radius: 10px; font-size: 11.5px; color: var(--accent); text-decoration: none; }
.model-link:hover { border-color: var(--accent); }
.action-menu textarea { width: 100%; min-width: 220px; }
.more { flex: none; width: 22px; height: 24px; border-radius: 2px; color: var(--muted); opacity: 0; }
.folder-row:hover .more, .source-item:hover .more, .inspector-bar .more, .more:focus-visible, :has(+ .action-menu) .more { opacity: 1; }
.more:hover { background: var(--raised); color: var(--ink); }
.action-menu { margin: 2px 0 6px 18px; padding: 8px; border: 1px solid var(--line); background: #112733; display: grid; gap: 8px; }
.action-menu form { display: grid; gap: 8px; }
.action-menu .meta, .action-menu .error { margin: 0; }
button.danger { color: var(--danger); text-align: left; padding: 4px 6px; }
.action-menu form button.danger { border: 1px solid var(--danger); padding: 6px 8px; }
.action-menu > button { text-align: left; padding: 4px 6px; }
.source-item { display: flex; align-items: flex-start; border-top: 1px solid var(--line); }
.source-item .source-row { flex: 1; min-width: 0; border-top: 0; }
.source-item .more { margin: 8px 8px 0 0; }
.unread { flex: none; align-self: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: #ff4d4f; color: #fff; font-size: 10px; font-weight: 650; line-height: 16px; text-align: center; }
.folder .unread { margin-left: auto; }
.folder .unread + .badge { margin-left: 4px; }
.point .unread:empty { min-width: 7px; width: 7px; height: 7px; padding: 0; margin-top: 5px; align-self: flex-start; }
.folder .badge { margin-left: auto; flex: none; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 0 4px; border-radius: 2px; }
.listing { margin: 12px 0 0; padding: 10px; border: 1px solid var(--line); background: var(--panel); display: grid; gap: 8px; }
.listing .meta { margin: 0; }
.listing button { padding: 6px 8px; }
.listing button:not(.primary) { border: 1px solid var(--line); background: var(--raised); color: var(--ink); }
.point { display: flex; gap: 6px; width: 100%; text-align: left; padding: 4px 6px; border-radius: 2px; color: var(--muted); font-size: 12px; line-height: 1.35; position: relative; overflow: hidden; }
.point:hover { background: var(--raised); color: var(--ink); }
.point[aria-current="true"] { background: var(--hit); color: var(--accent); }
.point .mark { width: 12px; flex: none; color: var(--accent); }
.point .meta { flex: none; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.point-text { margin: 10px 12px 4px; font-size: 14px; line-height: 1.45; }
.inspector .also { margin-top: 0; }
.paper-stage { flex: 1; padding: 12px 12px 16px; overflow: auto; border-top: 1px solid var(--line); }
.paper { display: block; width: 100%; max-width: 816px; margin: 0 auto; background: white; color: #111; box-shadow: 0 0 0 1px var(--line); }
.paper.plain { padding: 40px 48px; counter-reset: line; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; }
.paper.plain p { margin: 0; min-height: 1.6em; white-space: pre-wrap; overflow-wrap: anywhere; position: relative; counter-increment: line; }
.paper.plain p::before { content: counter(line); position: absolute; left: -40px; width: 30px; text-align: right; color: #9aa5ab; font-variant-numeric: tabular-nums; user-select: none; }
.doc-frame { border: 0; min-height: 480px; }
.paper-stage mark { background: rgba(0, 237, 100, 0.38); color: inherit; border-radius: 1px; }
.paper-stage .docx-wrapper { background: transparent; padding: 0; }
.paper-stage .docx-wrapper > section.docx { margin-bottom: 16px; box-shadow: 0 0 0 1px var(--line); }
.recent-item { display: block; width: 100%; text-align: left; padding: 5px 6px; border-radius: 2px; color: var(--ink); }
.children { margin-left: 14px; }

.drop { flex: none; display: flex; align-items: baseline; gap: 16px; border: 1px dashed var(--line); padding: 12px 16px; text-align: left; background: var(--panel); }
.drop .kicker { margin: 0; }
.drop p:last-child { margin: 0; color: var(--ink); }
.drop.dragging { border-color: var(--accent); background: var(--hit); }
.ask { flex: none; margin: 0; padding: 12px 20px 14px; border-top: 1px solid var(--line); background: var(--paper); }
.composer {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #001821;
  padding: 8px 8px 6px 12px;
}
.composer textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  max-height: 140px;
  margin: 0;
  padding: 4px 4px 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  resize: none;
}
.composer textarea:focus { outline: none; }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.composer-bar .scope-picker { margin-left: auto; }
.composer #scope-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  min-width: 84px;
  max-width: 200px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--raised);
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.composer #scope-button:hover { border-color: var(--accent); color: var(--ink); }
.composer #scope-button.chosen { color: var(--accent); border-color: var(--accent); background: var(--hit); }
.composer #scope-button[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.scope-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-caret { font-size: 10px; opacity: 0.8; transition: transform 0.15s; }
#scope-button[aria-expanded="true"] .scope-caret { transform: rotate(180deg); }
.composer button.primary, .composer #stop-answer { height: 28px; padding: 0 12px; border-radius: 999px; }
.effort { --thumb: 16px; display: flex; align-items: center; gap: 8px; margin: 0; }
.effort-name { color: #d7e4d6; font-size: 12px; }
.effort-track {
  position: relative;
  width: 128px;
  height: 14px;
  border-radius: 999px;
  background: rgba(232, 220, 196, 0.1);
}
.effort-flow {
  position: absolute;
  z-index: 1;
  left: 0;
  top: 0;
  bottom: 0;
  width: max(0px, calc(100% * var(--effort-ratio, 0) - var(--thumb) / 2 + 6px));
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  box-shadow: inset 0 0 8px rgba(255, 244, 214, 0.28);
  transition: width 420ms cubic-bezier(0.22, 0.8, 0.24, 1);
}
.effort-body {
  position: absolute;
  inset: -40% 0;
  animation: effort-bob 1.5s ease-in-out infinite;
}
.effort-waves {
  position: absolute;
  left: 0;
  top: 0;
  width: 200%;
  height: 100%;
  animation: effort-drift 1.15s linear infinite;
}
.wave-back { fill: #8fc9aa; }
.wave-front { fill: #e4d6ae; opacity: 0.9; }
.effort-sheen {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255, 250, 236, 0.72), transparent);
  animation: effort-sheen 1.7s ease-in-out infinite;
}
@keyframes effort-drift {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@keyframes effort-bob {
  0%, 100% { transform: translateY(1px); }
  50% { transform: translateY(-2px); }
}
@keyframes effort-sheen {
  0% { transform: translateX(0); }
  100% { transform: translateX(320%); }
}
.effort input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  z-index: 2;
  left: 0;
  top: 50%;
  width: 100%;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  transform: translateY(-50%);
  cursor: pointer;
}
.effort input[type="range"]:focus { outline: none; }
.effort input[type="range"]::-webkit-slider-runnable-track { height: 14px; background: transparent; border: 0; }
.effort input[type="range"]::-moz-range-track { height: 14px; background: transparent; border: 0; }
.effort input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #f7f3e8;
  border: 2px solid #d7eadc;
  box-shadow: 0 0 0 2px rgba(12, 28, 24, 0.35);
}
.effort input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #d7eadc;
  border-radius: 50%;
  background: #f7f3e8;
  box-shadow: 0 0 0 2px rgba(12, 28, 24, 0.35);
}
#stop-answer { border: 1px solid var(--line); background: var(--raised); padding: 8px 12px; }
.scope-picker { position: relative; }
#scope-button { min-width: 88px; max-width: 180px; height: 36px; border: 1px solid var(--line); background: var(--panel); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#scope-button[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
#scope-menu { position: absolute; right: 0; bottom: calc(100% + 4px); z-index: 3; display: flex; flex-direction: column; width: 300px; background: #112733; border: 1px solid var(--line); }
#scope-menu[hidden] { display: none; }
#scope-search { width: auto; margin: 8px; flex: none; }
#scope-options { max-height: 300px; overflow: auto; }
#scope-options li { display: flex; }
#scope-options button[role="option"] { display: grid; grid-template-columns: 16px 1fr; column-gap: 6px; flex: 1; min-width: 0; padding: 8px 12px 8px calc(12px + var(--depth, 0) * 14px); text-align: left; color: var(--ink); }
#scope-options .scope-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#scope-options .scope-expand { flex: none; width: 32px; color: var(--muted); }
#scope-options .scope-expand:hover { color: var(--accent); }
#scope-options button[aria-selected="true"] { color: var(--accent); background: var(--hit); }
#scope-options .mark { grid-row: 1 / span 2; align-self: center; color: var(--accent); }
#scope-options .meta { display: block; grid-column: 2; }
#scope-options > .meta { padding: 8px 12px; }
.work { flex: none; max-height: 34%; margin: 0; overflow: auto; }
.work:empty { display: none; }
.chat-log { flex: 1; min-height: 0; overflow: auto; overflow-anchor: none; padding: 8px 4px 12px; }
.chat-log:empty::before { content: "Answers are written here. Upload status stays above."; color: var(--muted); font-size: 13px; }
.answer { max-width: 720px; }
.answer-question { margin: 4px 0 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 650; line-height: 1.4; }
.answer-section { margin: 0 0 18px; padding-left: 14px; border-left: 2px solid var(--line); }
.answer-section h3 { margin: 0 0 6px; color: var(--muted); font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.answer-section p { margin: 0 0 8px; font-size: 15px; line-height: 1.55; }
.answer-confidence { margin: 4px 0 0; }
.answer-sources { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.answer-source { justify-self: start; text-align: left; color: var(--muted); font-size: 12px; line-height: 1.4; }
.answer-source:hover { color: var(--accent); }
button.cite { display: inline; margin: 0 1px; padding: 0 1px; color: var(--accent); font-size: 11px; line-height: 1; vertical-align: super; position: relative; }
ol { margin: 8px 0 16px; padding-left: 18px; font-size: 12px; line-height: 1.45; color: var(--muted); }

.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 14px 12px 8px; }
.panel-head h2 { margin: 0; font: 13px/1.2 system-ui, sans-serif; font-weight: 600; }
.source-tools { display: flex; gap: 8px; padding: 0 12px 8px; position: relative; }
.source-search { flex: 1; }
#filter-button { border: 1px solid var(--line); padding: 7px 8px; background: var(--panel); color: var(--ink); }
.filter-popover { position: absolute; right: 12px; top: 40px; z-index: 3; width: 200px; padding: 10px; background: #112733; border: 1px solid var(--line); }
.filter-popover label { display: block; margin-top: 8px; color: var(--muted); }
.source-row { display: block; width: 100%; text-align: left; padding: 8px 12px; border-top: 1px solid var(--line); color: var(--ink); }
.source-row strong { display: block; font-weight: 600; font-size: 13px; }
.empty { padding: 12px; }
.sources .kicker { padding: 14px 12px 4px; }

.inspector { min-height: 100%; display: flex; flex-direction: column; }
.inspector-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.inspector-bar button, .sheet-actions button:not(.primary) { border: 1px solid var(--line); padding: 6px 8px; background: var(--raised); color: var(--ink); }
.inspector h3 { margin: 12px 12px 4px; font-size: 16px; font-weight: 600; }
.inspector .meta, .inspector .error, .inspector blockquote, .inspector article { margin-left: 12px; margin-right: 12px; }
.pdf { display: flex; flex-direction: column; flex: 1; border-top: 1px solid var(--line); }
.pdf-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.pdf-bar button { border: 1px solid var(--line); background: var(--raised); color: var(--ink); width: 28px; height: 26px; }
.pdf-bar button:disabled { opacity: 0.35; cursor: default; }
.pdf-stage { padding: 0 12px 16px; overflow: auto; }
.sources:has(.pdf-stage:hover), .sources:has(.paper-stage:hover) { overflow: visible; z-index: 5; }
.sources .pdf-stage:hover, .sources .paper-stage:hover { overflow: visible; }
.sources .pdf-page, .sources .paper, .sources .docx-wrapper, .sources .doc-frame { transform-origin: top right; transition: transform 180ms ease; }
.sources .pdf-stage:hover .pdf-page,
.sources .paper-stage:hover .paper,
.sources .paper-stage:hover .docx-wrapper,
.sources .paper-stage:hover .doc-frame { transform: scale(1.65); z-index: 6; }
.pdf-page { position: relative; margin: 0 auto; background: white; box-shadow: 0 0 0 1px var(--line); }
.pdf-page canvas { display: block; }
.pdf-page .textLayer { position: absolute; inset: 0; overflow: clip; line-height: 1; text-align: initial; opacity: 1; z-index: 1; --scale-round-x: 1px; --scale-round-y: 1px; --min-font-size: 1; --min-font-size-inv: calc(1 / var(--min-font-size)); --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); }
.pdf-page .textLayer :is(span, br) { position: absolute; color: transparent; white-space: pre; cursor: text; transform-origin: 0 0; --font-height: 0; --scale-x: 1; --rotate: 0deg; font-size: calc(var(--text-scale-factor) * var(--font-height)); transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.pdf-page .textLayer .markedContent { display: contents; }
.pdf-page .textLayer span::selection { background: rgba(0, 120, 215, 0.3); }
.pdf-page .textLayer br::selection { background: transparent; }
.pdf-hit { position: absolute; background: rgba(0, 237, 100, 0.38); mix-blend-mode: multiply; border-radius: 1px; pointer-events: none; }
.inspector pre { white-space: pre-wrap; font: 13px/1.45 system-ui, sans-serif; margin: 0 12px 16px; }
blockquote { margin: 8px 0; padding-left: 10px; border-left: 2px solid var(--accent); }
.hit { background: var(--hit); }
article { border-top: 1px solid var(--line); padding-top: 8px; }
article h3 { font-size: 15px; margin: 0 0 4px; }

dialog { border: 1px solid var(--line); padding: 16px; width: min(440px, calc(100vw - 32px)); background: #112733; color: var(--ink); }
dialog::backdrop { background: rgba(0, 14, 20, 0.72); }
dialog label { display: block; margin-top: 10px; color: var(--muted); }
dialog { max-height: calc(100vh - 32px); overflow: auto; }
dialog textarea { resize: vertical; }
dialog input:disabled { opacity: 0.55; }
dialog .coverage { margin: 12px 0 0; padding: 8px 10px 10px; border: 1px solid var(--line); }
dialog .coverage legend { padding: 0 4px; color: var(--muted); }
dialog label.choice { display: flex; align-items: center; gap: 8px; margin-top: 6px; color: var(--ink); }
dialog label.choice input { width: auto; margin: 0; accent-color: var(--accent); }
dialog label.model-choice { color: var(--accent); }
.model-folders { max-height: 220px; overflow: auto; margin-top: 6px; border: 1px solid var(--line); }
.model-folders .meta { margin: 8px 10px; }
.model-folders label.choice { margin: 0; padding: 7px 10px; }
.model-folders label.choice:has(input:checked) { background: var(--hit); color: var(--accent); }
.sector-choice .tickers { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 2px 0 6px 22px; }
.sector-choice .tickers[hidden] { display: none; }
.define-inline { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
#add-ticker, #add-tag { border: 1px solid var(--line); background: var(--raised); padding: 0 10px; }
.define-inline:has(#tag-search) { grid-template-columns: 1fr auto; margin-top: 2px; padding-top: 0; border-top: 0; }
.tag-choices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-height: 120px; overflow: auto; }
.tag-choices .meta { margin: 0; }
dialog label.tag-chip { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); cursor: pointer; }
dialog label.tag-chip:has(input:checked) { border-color: var(--accent); color: var(--accent); }
dialog label.tag-chip input { width: auto; margin: 0; accent-color: var(--accent); }
#add-note { margin: 6px 0 0; }
#define-ticker { margin: 0 0 12px; }
#define-ticker .meta, #define-ticker .error { margin: 0; }
#context-error { margin: 12px 0 0; }

dialog.annotate { width: calc(100vw - 32px); height: calc(100vh - 32px); max-width: none; max-height: none; padding: 0; overflow: hidden; }
dialog.annotate[open] { display: flex; flex-direction: column; }
.annotate-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.annotate-head .kicker { margin: 0; }
.annotate-head strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.annotate-head button { padding: 6px 14px; }
.annotate-body { flex: 1; min-height: 0; display: flex; }
.annotate-doc { flex: 1; min-width: 0; overflow: auto; background: #0b1c25; display: flex; flex-direction: column; }
.annotate-doc .meta, .annotate-doc .error { margin: 8px 16px; }
.annotate-doc .paper-stage, .annotate-doc .pdf { border-top: 0; overflow: visible; }
.annotate-doc .pdf-stage { overflow: visible; }
.annotate-doc ::selection { background: rgba(0, 120, 215, 0.3); }
.annotate-bar { flex: none; width: 380px; overflow: auto; padding: 14px 16px; border-left: 1px solid var(--line); }
.annotate-bar .kicker { margin-top: 0; }
.annotate-bar blockquote { max-height: 180px; overflow: auto; font-size: 13px; }
.annotate-bar #path-picker .coverage:first-child { margin-top: 12px; }
.layer-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.layer-list li { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.layer-list button, #add-layer { border: 1px solid var(--line); background: var(--raised); padding: 0 10px; }
.path-picks { display: flex; flex-wrap: wrap; gap: 6px; max-height: 140px; overflow: auto; }
.path-picks button { border: 1px solid var(--line); background: transparent; color: var(--ink); padding: 2px 8px; border-radius: 999px; text-align: left; }
#annotate-layers .define-inline { grid-template-columns: 1fr auto; }
#path-preview { margin: 8px 0 0; }

.devbar { flex: none; border-top: 1px solid var(--line); background: var(--panel); }
#devlog-toggle { display: flex; gap: 6px; align-items: baseline; padding: 7px 14px; color: var(--muted); font-size: 12px; }
#devlog-toggle[aria-pressed="true"] { color: var(--accent); }
.devlog-head { display: flex; align-items: baseline; gap: 12px; padding: 8px 14px 4px; }
.devlog-head .kicker { margin: 0; color: var(--accent); }
.devlog-head .meta { flex: 1; }
#devlog-clear { border: 1px solid var(--line); padding: 3px 8px; background: var(--raised); font-size: 12px; }
#devlog-lines { list-style: none; margin: 0; padding: 0 14px 8px; height: 32vh; overflow: auto; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); }
#devlog-lines li { display: grid; grid-template-columns: 22ch 12ch 14ch 1fr; gap: 10px; padding: 2px 0; border-bottom: 1px solid rgba(61, 79, 88, 0.45); }
#devlog-lines li.error { color: var(--danger); }
#devlog-lines code { color: var(--muted); user-select: all; }
#devlog-lines time { color: var(--muted); }
#devlog-lines strong { font-weight: 600; color: var(--accent); }
#devlog-lines li.error strong { color: var(--danger); }
#devlog-lines details { grid-column: 4; }
#devlog-lines summary { color: var(--muted); cursor: pointer; }
#devlog-lines pre { margin: 4px 0; white-space: pre-wrap; color: var(--muted); }

.progress { padding: 14px 16px; border: 1px solid var(--line); background: var(--panel); }
.progress-title { margin: 0 0 10px; font-weight: 600; }
.stages { list-style: none; margin: 0; padding: 0; color: var(--ink); font-size: 13px; }
.stages li { display: grid; grid-template-columns: 18px auto 1fr; column-gap: 10px; align-items: center; padding: 6px 0; animation: rise 260ms ease; }
.stages li[data-status="done"] { color: var(--muted); }
.stages li[data-status="error"] .stage-label { color: var(--danger); }
.stage-mark { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); }
[data-status="active"] > .stage-mark { border-color: var(--accent); border-right-color: transparent; animation: spin 800ms linear infinite; }
[data-status="done"] > .stage-mark { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 3px var(--panel); }
[data-status="error"] > .stage-mark { border-color: var(--danger); background: var(--danger); box-shadow: inset 0 0 0 3px var(--panel); }
[data-status="active"] > .stage-label {
  background: linear-gradient(90deg, var(--ink) 35%, var(--accent) 50%, var(--ink) 65%) 0 0 / 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.6s linear infinite;
}
.stage-count { justify-self: end; font-variant-numeric: tabular-nums; }
.stage-message { grid-column: 2 / 4; margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-status="done"] > .stage-message { display: none; }
.stage-bar { grid-column: 2 / 4; height: 3px; margin-top: 6px; background: var(--line); overflow: hidden; }
.stage-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 400ms ease; }
[data-status="done"] > .stage-bar { display: none; }
.outcome { margin: 10px 0 0; animation: rise 260ms ease; }
.choice-board { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.choice-board p { margin: 0 0 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
button.busy::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
  vertical-align: -1px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
button.primary { background: var(--accent); color: #001e2b; border: 0; padding: 8px 12px; font-weight: 650; }
button.primary:hover { filter: brightness(1.08); }

.account { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); }
.account #account-email { flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account button, .account a, .signin .link { color: var(--muted); font-size: 12px; text-decoration: none; }
.account button:hover, .account a:hover, .signin .link:hover { color: var(--accent); }
#signin-start[hidden] { display: none; }
body[data-role="viewer"] #drop, body[data-role="viewer"] #define-ticker, body[data-role="viewer"] .more { display: none; }

/* Boot cover: the landing page's flat, matte dark-green sheet while the terminal loads underneath. */
.boot {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: stretch;
  background-color: #0d2a24;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    linear-gradient(180deg, #12332b 0%, #0d2a24 55%, #0a221d 100%);
  color: #ffffff;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}
.boot[hidden] { display: none; }
.boot.boot-out { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-stage {
  display: grid;
  align-items: end;
  width: min(1120px, calc(100% - 72px));
  margin: 0 auto;
  min-height: 100%;
  padding: 0 0 12vh;
}
.boot-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  max-width: 44rem;
}
.boot-title {
  margin: 0;
  font-size: clamp(40px, 6vw, 76px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.98;
  color: #ffffff;
}
.boot-line {
  margin: 0;
  font-size: clamp(16px, 1.6vw, 20px);
  font-weight: 500;
  line-height: 1.45;
  color: #5cc28f;
}
.boot-wait {
  display: flex;
  gap: 8px;
  align-items: center;
  height: 12px;
}
.boot-wait span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5cc28f;
  opacity: 0.22;
  animation: boot-dot 1.05s ease-in-out infinite;
}
.boot-wait span:nth-child(2) { animation-delay: 0.15s; }
.boot-wait span:nth-child(3) { animation-delay: 0.3s; }
.boot-error {
  margin: 4px 0 0;
  max-width: 36ch;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.4;
}
#boot-retry {
  margin-top: 4px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 550;
}
#boot-retry:hover { background: var(--accent); color: var(--accent-ink); }
body.booting .terminal,
body.booting.admin-page > :not(#boot) {
  visibility: hidden;
}
@keyframes boot-dot {
  0%, 80%, 100% { opacity: 0.2; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
@media (max-width: 820px) {
  .boot-stage {
    width: min(100% - 40px, 560px);
    padding-bottom: 10vh;
  }
}

.signin { position: fixed; inset: 0; z-index: 20; display: grid; overflow: auto; padding: 16px 0; background: var(--paper); }
.signin-card { margin: auto; }
.signin[hidden] { display: none; }
.signin-card { width: min(360px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; padding: 28px 24px; border: 1px solid var(--line); background: var(--panel); }
.signin-logo { width: 44px; height: 44px; object-fit: contain; }
.signin-card .terminal-name { margin: 0; font-size: 15px; }
.signin-card .meta { margin: 0; }
.signin-or { text-align: center; margin: 4px 0 0; }
.signin-form { display: flex; flex-direction: column; gap: 8px; }
.signin-form[hidden] { display: none; }
.signin-form button:not(.primary):not(.link) { border: 1px solid var(--line); background: var(--raised); padding: 8px 12px; }
.signin .link { align-self: flex-start; }

.admin-page { min-height: 100vh; background: var(--paper); padding: 0 24px 40px; }
.admin-bar { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.admin-bar a { color: var(--accent); text-decoration: none; font-weight: 650; }
.admin-bar #who { margin-left: auto; }
.admin-tabs { display: flex; gap: 8px; margin: 16px 0; }
.admin-tabs button { padding: 6px 10px; color: var(--muted); border-bottom: 1px solid transparent; }
.admin-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.admin-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.admin-row input, .admin-row select { width: auto; }
.grants { display: block; margin: 8px 0 12px; border: 0; padding: 0; color: var(--muted); }
.grants legend { padding: 0; }
#member { width: min(720px, calc(100vw - 32px)); }
.member-password { margin: 18px 0 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.member-password .meta { margin: 0 0 8px; }
.member-password input { width: 100%; }
.member-password .sheet-actions { justify-content: flex-start; margin-top: 8px; }
.folder-picks { max-height: 320px; overflow: auto; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--deep); }
.folder-tree { list-style: none; margin: 0; padding: 0; }
.folder-tree li { display: flex; }
.folder-tree button[role="option"] { display: grid; grid-template-columns: 16px 1fr; column-gap: 6px; flex: 1; min-width: 0; padding: 7px 10px 7px calc(10px + var(--depth, 0) * 16px); text-align: left; color: var(--ink); background: transparent; }
.folder-tree button[role="option"]:hover { background: var(--raised); }
.folder-tree button[aria-selected="true"] { color: var(--accent); background: var(--hit); }
.folder-tree .mark { grid-row: 1 / span 2; align-self: center; color: var(--accent); }
.folder-tree .scope-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-tree .meta { display: block; grid-column: 2; }
.folder-tree .scope-expand { flex: none; width: 32px; color: var(--muted); background: transparent; }
.folder-tree .scope-expand:hover { color: var(--accent); }
.grant-summary { margin: 6px 0 0; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table td.grants-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.admin-table tbody tr { cursor: pointer; }
.admin-table tbody tr:hover { background: var(--raised); }
.admin-table tr.removed td { color: var(--muted); }
.admin-list { list-style: none; margin: 0; padding: 0; }
.admin-list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.admin-list li form { margin: 0; }
.settings-group { margin: 12px 0 0; font-size: 1rem; }
.plan-rejections { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: 640px; margin: 12px 0 20px; }
.plan-rejections fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.plan-rejections legend { padding: 0 4px; font-weight: 600; }
.plan-rejections label { display: flex; align-items: flex-start; gap: 8px; margin-top: 6px; }
.plan-rejections input { width: auto; margin: 2px 0 0; accent-color: var(--accent); }
.mail-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 12px; padding: 8px 10px; border: 1px solid var(--danger); font-size: 12px; }
.mail-status.ok { border-color: var(--line); color: var(--muted); }
.connect-can { margin: 0; padding-left: 18px; color: var(--ink); font-size: 13px; }

.legal-page { max-width: 720px; margin: 0 auto; padding: 40px 24px 80px; }
.legal-page nav { display: flex; gap: 16px; margin-bottom: 28px; }
.legal-page nav a, .legal-page a { color: var(--accent); }
.legal-page h1 { font-size: 22px; font-weight: 650; }
.legal-page h2 { font-size: 15px; margin: 28px 0 8px; }
.legal-page p, .legal-page li { color: var(--ink); font-size: 14px; line-height: 1.55; }

/* Admin: a member's latest Quant Factor runs. */
.quant-runs { margin: 6px 0 0; padding-left: 18px; max-height: 150px; overflow: auto; }
