:root {
  --bg0: #0f1419;
  --bg1: #1a2332;
  --ink: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3d9b8f;
  --accent2: #c4a35a;
  --err: #e07070;
  --ok: #6bc48a;
  --line: rgba(232, 238, 246, 0.12);
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(61, 155, 143, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(196, 163, 90, 0.12), transparent 50%),
    linear-gradient(160deg, var(--bg0), var(--bg1));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.panel {
  width: min(420px, 100%);
  padding: 1.75rem 1.5rem 1.5rem;
  border: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.72);
  backdrop-filter: blur(8px);
}

.panel.wide { width: min(640px, 100%); }

h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font);
  font-weight: 600;
  font-size: 2rem;
  letter-spacing: 0.02em;
  color: var(--accent2);
}

.app-version-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.12rem 0.45rem;
  border: 1px solid var(--accent);
  border-radius: 3px;
  vertical-align: middle;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(61, 155, 143, 0.12);
}

.tabs {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 1.15rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.35rem;
}

.tab {
  margin: 0;
  padding: 0.45rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab:hover { color: var(--ink); filter: none; }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel { margin-top: 0.25rem; }

.library-status {
  margin: 0.5rem 0;
  color: var(--muted);
}

.library-status.err { color: var(--err); }

.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.85rem;
}

.library-toolbar .btn-secondary,
.library-toolbar .btn-danger { margin-top: 0; }

.btn-danger {
  display: inline-block;
  padding: 0.65rem 1.1rem;
  border: none;
  background: #a84848;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover { filter: brightness(1.08); }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.library-confirm {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--err);
  background: rgba(224, 112, 112, 0.08);
}

.library-confirm-text {
  margin: 0 0 0.75rem;
  color: var(--err);
}

.library-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.library-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.library-item:last-child { border-bottom: none; }

.library-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
}

.library-check-wrap {
  margin: 0.2rem 0 0;
  flex: 0 0 auto;
}

.library-check {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.library-body { min-width: 0; flex: 1; }

.library-name {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
}

.library-name:hover { text-decoration: underline; }

.library-meta {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.lede { margin: 0 0 1.25rem; color: var(--muted); line-height: 1.45; }
.top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.who { margin: 0; color: var(--muted); font-size: 0.9rem; }
.who a { color: var(--accent); }

.profile-menu {
  position: relative;
  flex: 0 0 auto;
  align-self: flex-start;
}
.profile-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.25rem 0.55rem 0.25rem 0.25rem;
  border: 1px solid rgba(139, 155, 176, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
}
.profile-trigger:hover,
.profile-trigger[aria-expanded="true"] {
  border-color: var(--accent);
  background: rgba(61, 155, 143, 0.12);
}
.profile-avatar {
  display: inline-flex;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 32px;
}
.profile-avatar img,
.profile-avatar svg {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: cover;
}
.profile-name { color: var(--ink); }
.profile-chevron {
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: -0.1rem;
}
.profile-dropdown {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 10.5rem;
  padding: 0.35rem 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121a28;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 40;
}
.profile-dropdown[hidden] { display: none; }
.profile-dropdown-item {
  display: block;
  padding: 0.55rem 0.85rem;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.88rem;
}
.profile-dropdown-item:hover {
  background: rgba(61, 155, 143, 0.15);
  color: var(--accent2);
}
.profile-dropdown-logout {
  border-top: 1px solid var(--line);
  margin-top: 0.25rem;
  padding-top: 0.65rem;
  color: var(--muted);
}

.account-panel { max-width: 720px; }
.account-home-link {
  color: var(--ink);
  text-decoration: none;
}
.account-home-link:hover { color: var(--accent2); }
.account-card h2 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  color: var(--accent2);
}
.account-card h2:first-child { margin-top: 0; }
.account-card p { margin: 0.65rem 0; line-height: 1.45; }
.account-sub code {
  font-size: 0.78rem;
  word-break: break-all;
}
.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}
.btn-account {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.btn-account.primary {
  background: rgba(61, 155, 143, 0.2);
  border-color: var(--accent);
  color: var(--accent2);
}
.btn-account.secondary {
  background: rgba(0, 0, 0, 0.25);
  color: var(--muted);
}
.btn-account:hover { border-color: var(--accent); color: var(--accent2); }
.account-soon { font-size: 0.85rem; margin-top: 1rem; }
.plain-list { margin: 0.35rem 0 0; padding-left: 1.15rem; }
.plain-list li { margin: 0.25rem 0; }

.hub-body a:link { color: var(--accent); }
.hub-body a:visited { color: #7eb8ae; }
.hub-body a:hover { color: var(--accent2); }

label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input[type="email"],
input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font: inherit;
}

button,
.file-btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.65rem 1.1rem;
  border: none;
  background: var(--accent);
  color: #06120f;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:hover,
.file-btn:hover { filter: brightness(1.08); }

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.btn-primary { background: var(--accent); color: #06120f; }
.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  margin-left: 0.5rem;
}

.drop {
  border: 2px dashed rgba(61, 155, 143, 0.45);
  padding: 2.5rem 1.25rem;
  text-align: center;
  background: rgba(61, 155, 143, 0.06);
  outline: none;
}

.drop.drag { border-color: var(--accent2); background: rgba(196, 163, 90, 0.1); }
.drop.disabled { opacity: 0.55; pointer-events: none; }
.drop-title { margin: 0 0 0.35rem; font-size: 1.1rem; }
.drop-sub { margin: 0.35rem 0; color: var(--muted); font-size: 0.9rem; }

.selected {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

.selected-name {
  margin: 0 0 0.25rem;
  font-weight: 600;
  word-break: break-all;
}

.selected-size {
  margin: 0 0 0.85rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.actions .btn-primary,
.actions .btn-secondary { margin-top: 0; }

.status { margin-top: 1.25rem; }
.status-text { margin: 0 0 0.65rem; font-weight: 600; }
.status-pct {
  margin: 0.45rem 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent2);
}
.status-meta { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.85rem; }

.bar {
  height: 14px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border-radius: 2px;
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    #5ec4b6 40%,
    var(--accent2) 70%,
    var(--accent) 100%
  );
  background-size: 200% 100%;
  transition: width 0.2s ease-out;
}

.bar-fill.active {
  animation: solana-bar-shine 1.2s linear infinite;
}

.bar-fill.done {
  animation: none;
  background: var(--ok);
  background-size: 100% 100%;
}

@keyframes solana-bar-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.msg { margin-top: 1rem; padding: 0.65rem 0.75rem; border: 1px solid var(--line); }
.msg.err { border-color: var(--err); color: var(--err); word-break: break-word; }
.msg.ok { border-color: var(--ok); color: var(--ok); }
.msg-link {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.msg-link:hover { filter: brightness(1.15); }

code { font-size: 0.9em; color: var(--accent2); }

/* Research hub (v0.7) */
html { height: 100%; }
.hub-body {
  align-items: stretch;
  justify-content: flex-start;
  padding: 1rem;
  min-height: 100vh;
  height: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.hub-body *,
.hub-body {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}
.hub-body::-webkit-scrollbar,
.hub-body *::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.hub-body::-webkit-scrollbar-track,
.hub-body *::-webkit-scrollbar-track {
  background: transparent;
}
.hub-body::-webkit-scrollbar-thumb,
.hub-body *::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}
.hub-body::-webkit-scrollbar-thumb:hover,
.hub-body *::-webkit-scrollbar-thumb:hover {
  background: #5ec4b6;
}

.hub-panel {
  width: min(1400px, 100%);
  max-width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 2rem);
  padding: 1.25rem 1.35rem 1.1rem;
}
.hub-top { margin-bottom: 0.5rem; flex: 0 0 auto; }
.hub-top h1 { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.hub-top .lede { margin-bottom: 0.35rem; }
.btn-hard-refresh {
  margin: 0;
  margin-left: 0.15rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(139, 155, 176, 0.45);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  vertical-align: middle;
}
.btn-hard-refresh:hover {
  color: var(--ink);
  border-color: var(--accent);
  background: rgba(61, 155, 143, 0.15);
  filter: none;
}
.hub-tabs { flex-wrap: wrap; gap: 0.15rem; flex: 0 0 auto; }
.hub-tabs .tab-muted { font-size: 0.85rem; opacity: 0.85; }
.hub-panel-section {
  margin-top: 0.5rem;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.hub-panel-section.active { display: flex; }
.hub-panel-section[hidden] { display: none !important; }

.stat-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; }
.stat { flex: 1; min-width: 120px; padding: 0.65rem 0.75rem; border: 1px solid var(--line); background: rgba(0,0,0,0.2); }
.stat-label { font-size: 0.75rem; color: var(--muted); }
.stat-val { font-size: 1.35rem; font-weight: 600; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 1000px) { .grid3 { grid-template-columns: 1fr; } }

.card { border: 1px solid var(--line); background: rgba(15, 20, 25, 0.55); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card h2 { margin: 0 0 0.65rem; font-size: 0.95rem; color: var(--accent2); }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td { padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); text-align: left; }
.data-table th { color: var(--muted); font-weight: 500; font-size: 0.78rem; }

.plain-list { list-style: none; padding: 0; margin: 0; line-height: 1.6; }
.muted { color: var(--muted); }
.banner-warn { padding: 0.5rem 0.75rem; margin-bottom: 1rem; border: 1px solid var(--warn, #e0a060); background: rgba(224, 160, 96, 0.12); font-size: 0.88rem; }

.tag { display: inline-block; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.72rem; font-weight: 600; }
.tag.good, .tag.ok { background: rgba(107, 196, 138, 0.15); color: var(--ok); }
.tag.ugly { background: rgba(224, 112, 112, 0.12); color: var(--err); }
.tag.warn, .tag.pending { background: rgba(224, 160, 96, 0.12); color: #e0a060; }
.tag.err, .tag.failed { background: rgba(224, 112, 112, 0.12); color: var(--err); }

.datasets-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
}
@media (max-width: 900px) { .datasets-layout { grid-template-columns: 1fr; } }
.datasets-rail { border-right: 1px solid var(--line); overflow: auto; min-height: 0; }
.datasets-rail-list { padding: 0.25rem 0; }
.datasets-rail-item { display: block; width: 100%; text-align: left; padding: 0.55rem 0.75rem; border: none; border-left: 3px solid transparent; background: transparent; color: var(--ink); cursor: pointer; font: inherit; }
.datasets-rail-item:hover { background: rgba(61, 155, 143, 0.08); }
.datasets-rail-item.sel { border-left-color: var(--accent); background: rgba(61, 155, 143, 0.12); }
.datasets-rail-name { font-weight: 600; font-size: 0.88rem; margin-bottom: 0.15rem; }
.datasets-rail-prov { font-size: 0.78rem; margin-bottom: 0.25rem; }
.datasets-rail-meta { font-size: 0.72rem; }
.datasets-main { padding: 0.75rem 1rem; overflow: auto; min-height: 0; }
.datasets-detail-header { margin-bottom: 0.75rem; }
.datasets-coins-card { margin-top: 0; }
.datasets-raw-card { margin-bottom: 0.75rem; padding: 0.75rem 1rem; }
.datasets-raw-list { list-style: none; margin: 0.35rem 0 0; padding: 0; font-size: 0.82rem; }
.datasets-raw-list li { padding: 0.15rem 0; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.datasets-raw-list code { color: var(--ink); }
.datasets-stub-reason { font-size: 0.85rem; margin: 0.35rem 0 0.25rem; }
.tag.catalog { background: rgba(120, 140, 160, 0.15); color: #a8b4c0; }
.sentinel { height: 1px; margin: 0.5rem 0; }

.import-progress {
  margin: 0.65rem 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
}
.import-progress-phase {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent2);
  margin-bottom: 0.4rem;
}
.import-progress-bar {
  height: 8px;
  background: rgba(232, 238, 246, 0.08);
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.import-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}
.import-progress-meta { font-size: 0.82rem; margin-bottom: 0.25rem; }
.import-mint, .import-msg { font-size: 0.78rem; margin-top: 0.2rem; word-break: break-all; }

.workbench {
  display: grid;
  grid-template-columns: 220px 1fr 240px;
  gap: 0;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
}
@media (max-width: 900px) { .workbench { grid-template-columns: 1fr; } }
.workbench-col { border-right: 1px solid var(--line); overflow: auto; min-height: 0; }
.workbench-center { padding: 0.75rem 1rem; overflow: auto; min-height: 0; display: flex; flex-direction: column; }
.col-head { padding: 0.5rem 0.75rem; font-size: 0.72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--line); background: rgba(0,0,0,0.2); }
.wb-select {
  width: 100%;
  padding: 0.4rem 0.55rem;
  margin: 0.5rem 0.75rem;
  max-width: calc(100% - 1.5rem);
  background: #0b1016;
  border: 1px solid var(--line);
  color: var(--ink);
  color-scheme: dark;
}
.wb-select option,
.wb-select optgroup {
  background: #0b1016;
  color: var(--ink);
}
#bib-summarise-model.wb-select,
.bib-summarise-model {
  margin: 0;
  max-width: 16rem;
  background: #0b1016;
  color: var(--ink);
}
#bib-summarise-model option {
  background: #0b1016;
  color: #e8eef4;
}
.coin-tree { list-style: none; padding: 0; margin: 0; }
.coin-tree-item { padding: 0.4rem 0.75rem; cursor: pointer; border-left: 3px solid transparent; }
.coin-tree-item:hover { background: rgba(61, 155, 143, 0.08); }
.coin-tree-item.sel { border-left-color: var(--accent); background: rgba(61, 155, 143, 0.12); }
.coin-tree-pkg { font-weight: 600; font-size: 0.82rem; }
.coin-tree-mint { font-size: 0.78rem; color: var(--muted); }
.coin-title { font-family: var(--font); font-size: 1.1rem; color: var(--accent2); margin: 0 0 0.25rem; }
.coin-meta { font-size: 0.82rem; margin-bottom: 0.35rem; }
.coin-links { font-size: 0.8rem; margin: 0 0 0.65rem; }
.coin-links a { color: var(--accent); margin-right: 0.75rem; }

.analysis-charts { margin-bottom: 0.75rem; }
.chart-panel { margin-bottom: 0.65rem; }
.chart-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.25rem; }
.chart-box { height: 160px; border: 1px solid var(--line); background: rgba(0,0,0,0.25); position: relative; }
.chart-box-sm { height: 110px; }
.chart-svg { width: 100%; height: 100%; display: block; }
.chart-empty { padding: 1rem; text-align: center; }
.chart-note { font-size: 0.8rem; margin: 0.25rem 0 0; }
.chart-axis { font-size: 10px; fill: var(--muted); }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.4rem; margin-bottom: 0.75rem; }
.feat { padding: 0.4rem 0.5rem; border: 1px solid var(--line); font-size: 0.78rem; }
.feat-k { color: var(--muted); font-size: 0.68rem; line-height: 1.2; }
.feat-v { font-weight: 600; word-break: break-all; }

.series-table-wrap {
  flex: 1;
  min-height: 160px;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  margin-top: 0.25rem;
}
.series-table { font-size: 0.78rem; }
.series-table th { position: sticky; top: 0; background: rgba(15, 20, 25, 0.95); z-index: 1; }
.series-table td { font-variant-numeric: tabular-nums; white-space: nowrap; }

.note-block { padding: 0.65rem 0.75rem; margin: 0.5rem 0.75rem; border: 1px solid var(--line); background: rgba(0,0,0,0.2); font-size: 0.82rem; }
.note-block h3 { margin: 0 0 0.35rem; font-size: 0.78rem; color: var(--accent2); }
.strategy-block .strategy-body { font-size: 0.9rem; line-height: 1.5; color: var(--muted); }
.strategy-body h1, .strategy-body h2, .strategy-body h3 { color: var(--accent2); font-family: var(--font); }
.strategy-accordions { display: flex; flex-direction: column; gap: 0.65rem; }
.strategy-accordion { margin: 0; padding: 0; }
.strategy-accordion.card { padding: 0; overflow: hidden; }
.strategy-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.strategy-summary::-webkit-details-marker { display: none; }
.strategy-summary::before {
  content: '▸';
  color: var(--accent2);
  font-size: 0.85rem;
  margin-right: 0.35rem;
  transition: transform 0.15s ease;
}
.strategy-accordion[open] > .strategy-summary::before { transform: rotate(90deg); }
.strategy-summary-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent2);
  font-family: var(--font);
}
.strategy-summary .strategy-edit-btn { flex: 0 0 auto; margin: 0; }
.strategy-summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  flex: 0 0 auto;
}
.strategy-history-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.28rem 0.6rem;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1.2;
}
.strategy-history-btn:hover { color: var(--ink); border-color: var(--accent2); }
.strategy-history-btn[hidden] { display: none !important; }
.strategy-history-btn:disabled { opacity: 0.6; cursor: default; }
.strategy-edit-btn {
  background: rgba(61, 155, 143, 0.18);
  border: 1px solid var(--accent);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  border-radius: 4px;
  line-height: 1.2;
}
.strategy-edit-btn:hover { background: rgba(61, 155, 143, 0.32); }
.strategy-edit-btn.strategy-edit-btn-exit {
  background: rgba(224, 160, 96, 0.15);
  border-color: #e0a060;
  color: #e8c89a;
}
.strategy-edit-btn.strategy-edit-btn-exit:hover { background: rgba(224, 160, 96, 0.28); }
.strategy-edit-btn[hidden] { display: none !important; }
.strategy-accordion.is-editing.card {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(61, 155, 143, 0.35);
}
.strategy-accordion.is-editing .strategy-accordion-inner {
  background: rgba(61, 155, 143, 0.06);
  border-radius: 0 0 4px 4px;
}
.strategy-accordion-inner { padding: 0 0.85rem 0.85rem; }
.strategy-edit-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}
.strategy-edit-bar[hidden],
.strategy-accordion:not(.is-editing) .strategy-edit-bar {
  display: none !important;
}
.strategy-editing-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.15rem 0.45rem;
  border: 1px solid rgba(61, 155, 143, 0.45);
  border-radius: 3px;
  background: rgba(61, 155, 143, 0.12);
}
.strategy-toolbar { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.strategy-cmd {
  background: rgba(61, 155, 143, 0.12);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  border-radius: 3px;
}
.strategy-cmd:hover { background: rgba(61, 155, 143, 0.22); }
.strategy-toolbar-markers { margin-top: 0.15rem; }
.strategy-marker {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(61, 155, 143, 0.08);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 0.76rem;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
  border-radius: 4px;
}
.strategy-marker:hover { background: rgba(61, 155, 143, 0.18); }
.strategy-swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex: 0 0 auto;
}
.strategy-link-prompt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.78rem;
}
.strategy-link-prompt[hidden] { display: none !important; }
.strategy-link-label { color: var(--muted); }
.strategy-link-input {
  flex: 1 1 12rem;
  min-width: 8rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.45rem;
  border-radius: 3px;
}
.strategy-link-apply {
  background: rgba(61, 155, 143, 0.22);
  border: 1px solid var(--accent);
  color: var(--ink);
  font: inherit;
  font-size: 0.76rem;
  padding: 0.22rem 0.5rem;
  cursor: pointer;
  border-radius: 3px;
}
.strategy-edit-actions { display: flex; gap: 0.5rem; align-items: center; }
.strategy-save-btn {
  background: var(--accent);
  border: none;
  color: #0f1419;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  border-radius: 3px;
}
.strategy-save-btn:disabled { opacity: 0.6; cursor: default; }
.strategy-body.strategy-editing[contenteditable="true"],
.strategy-body.strategy-editing[contenteditable="true"]:focus {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
  outline: none;
  min-height: 2rem;
  border: 1px solid rgba(61, 155, 143, 0.45);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  background: rgba(0, 0, 0, 0.15);
}
.strategy-body.strategy-editing[contenteditable="true"] h1,
.strategy-body.strategy-editing[contenteditable="true"] h2,
.strategy-body.strategy-editing[contenteditable="true"] h3 {
  color: var(--accent2);
  font-family: var(--font);
}
.strategy-msg { margin: 0; font-size: 0.82rem; }
.strategy-exit-challenge {
  flex: 1 1 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(224, 160, 96, 0.45);
  border-radius: 4px;
  background: rgba(224, 160, 96, 0.08);
}
.strategy-exit-challenge[hidden] { display: none !important; }
.strategy-exit-challenge-text {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  color: #e0a060;
}
.strategy-exit-challenge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  align-items: center;
}
.strategy-challenge-save {
  background: var(--accent);
  border: none;
  color: #0f1419;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  border-radius: 3px;
}
.strategy-challenge-save:disabled { opacity: 0.6; cursor: default; }
.strategy-meta {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
}
.strategy-meta[hidden] { display: none !important; }
.strategy-suggestion {
  color: var(--accent2);
  background: color-mix(in srgb, var(--accent2) 12%, transparent);
  padding: 0 0.12em;
  border-radius: 2px;
}
.strategy-comment {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  padding: 0 0.12em;
  border-radius: 2px;
}
.strategy-txt-ink { color: var(--ink); background: none; padding: 0; }
.strategy-txt-muted { color: var(--muted); background: none; padding: 0; }
.strategy-history-panel {
  margin-top: 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  font-size: 0.8rem;
}
.strategy-history-panel[hidden] { display: none !important; }
.strategy-history-heading {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent2);
}
.strategy-revision-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.strategy-revision-item {
  display: grid;
  grid-template-columns: auto auto auto 1fr auto;
  gap: 0.35rem 0.5rem;
  align-items: baseline;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}
.strategy-revision-item:last-child { border-bottom: none; }
.strategy-revision-when { font-variant-numeric: tabular-nums; color: var(--ink); }
.strategy-revision-by { color: var(--muted); font-size: 0.76rem; }
.strategy-revision-kind {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  border: 1px solid var(--line);
}
.strategy-revision-kind-edit { color: var(--accent); border-color: rgba(61, 155, 143, 0.45); }
.strategy-revision-kind-restore { color: var(--accent2); border-color: rgba(196, 163, 90, 0.45); }
.strategy-revision-snippet {
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.strategy-revision-actions { display: flex; gap: 0.5rem; }
.strategy-revision-preview {
  margin-top: 0.5rem;
  padding: 0.5rem;
  border: 1px dashed var(--line);
  border-radius: 4px;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
}
.strategy-revision-preview[hidden] { display: none !important; }
.strategy-restore-challenge {
  margin-top: 0.5rem;
  padding: 0.45rem;
  background: rgba(196, 163, 90, 0.08);
  border: 1px solid rgba(196, 163, 90, 0.35);
  border-radius: 4px;
}
.strategy-restore-challenge[hidden] { display: none !important; }
.strategy-restore-challenge-text { margin: 0 0 0.35rem; font-size: 0.8rem; }
.strategy-restore-challenge-actions { display: flex; gap: 0.5rem; align-items: center; }
.strategy-restore-confirm {
  background: rgba(61, 155, 143, 0.22);
  border: 1px solid var(--accent);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  border-radius: 3px;
}
.inner-tabs { margin-top: 0; }
.inner-panel[hidden] { display: none !important; }
.linkish { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.bib-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  min-height: 0;
  flex: 1;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.15);
}
@media (max-width: 900px) { .bib-layout { grid-template-columns: 1fr; } }
.bib-rail {
  border-right: 1px solid var(--line);
  overflow: auto;
  padding-bottom: 1rem;
}
.bib-main {
  padding: 0.75rem 1rem;
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.bib-main-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.bib-main h2 { margin: 0; font-size: 1.1rem; color: var(--accent2); }
.bib-list-toggle {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}
.bib-list-panel { margin-bottom: 0.75rem; overflow: auto; max-height: 42vh; }
.bib-list-panel.is-collapsed {
  max-height: 0;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.bib-reader { margin-top: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bib-pdf-frame {
  width: 100%;
  min-height: 480px;
  flex: 1;
  border: 1px solid var(--line);
  background: #111;
}
.bib-pdf-frame.bib-html-frame {
  background: #f7f5f0;
}
.bib-filter-group { padding: 0.5rem 0.75rem; }
.bib-filter-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 0.35rem; }
.bib-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.bib-chip {
  font: inherit;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.35);
  color: var(--muted);
  cursor: pointer;
}
.bib-chip.active, .bib-chip:hover {
  color: var(--ink);
  border-color: var(--accent);
  background: rgba(61, 155, 143, 0.15);
}
#bib-table-body tr { cursor: pointer; }
#bib-table-body tr:hover, #bib-table-body tr.bib-row-sel { background: rgba(61, 155, 143, 0.12); }
.bib-reader-head h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.bib-reader-actions { margin: 0.35rem 0; display: flex; flex-wrap: wrap; gap: 0.75rem; }
.bib-text-pane {
  max-height: 480px;
  overflow: auto;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.35);
  color: var(--ink);
  font-size: 0.85rem;
  white-space: pre-wrap;
  margin: 0;
  flex: 1;
}
.bib-reader-tools {
  margin: 0.5rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}
.bib-summarise-model-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.bib-summarise-model { min-width: 12rem; }
.bib-summarise-status { margin: 0.35rem 0 0; font-size: 0.85rem; }
.bib-summarise-out { margin: 0.5rem 0 0; }
.bib-sum-section { margin: 0 0 0.85rem; }
.bib-sum-section h4 { margin: 0 0 0.35rem; font-size: 0.9rem; color: var(--accent2); }
.bib-sum-section ul { margin: 0; padding-left: 1.2rem; }
.bib-sum-section p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.bib-sum-meta { font-size: 0.75rem; color: var(--muted); margin: 0 0 0.5rem; }
.bib-epub-status { margin: 0.35rem 0; }
.bib-summarise-out { margin: 0.35rem 0 0; font-size: 0.85rem; }
.bib-web-panel {
  flex: 1;
  min-height: 160px;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.25);
}
.bib-web-note { margin: 0 0 1rem; color: var(--muted); line-height: 1.45; font-size: 0.9rem; }
.bib-web-actions { margin: 0; }
.bib-web-actions .btn-primary { display: inline-block; text-decoration: none; }

.feat-k[title],
.chart-label[title],
.series-table th[title],
.tag[title],
.glossary-list dt {
  cursor: help;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.glossary-card { margin-top: 0; }
.glossary-lede { margin: 0 0 0.75rem; font-size: 0.85rem; }
.glossary-list { margin: 0; }
.glossary-item { margin: 0 0 0.85rem; padding-bottom: 0.65rem; border-bottom: 1px solid var(--line); }
.glossary-item:last-child { border-bottom: none; margin-bottom: 0; }
.glossary-list dt { font-weight: 600; color: var(--accent2); margin: 0 0 0.25rem; }
.glossary-exp { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.glossary-list dd { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.knowledge-subtabs, .strategy-subtabs { margin: 0 0 1rem; }
.glossary-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 0.85rem;
  align-items: center;
  margin: 0 0 1rem;
}
.glossary-search-field {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  align-items: center;
  flex: 0 1 18rem;
  max-width: 22rem;
  min-width: 12rem;
}
.glossary-q {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 18rem;
  height: 2rem;
  box-sizing: border-box;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  line-height: 1.2;
}
.glossary-q:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 155, 143, 0.25);
}
.glossary-toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: center;
  min-height: 2rem;
}
.btn-search-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}
.glossary-q-clear {
  display: inline-flex;
  align-items: center;
  height: 1.75rem;
  line-height: 1;
  font-size: 0.9rem;
}
.glossary-sort-label {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  height: 1.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}
.glossary-sort-label select {
  height: 1.75rem;
  box-sizing: border-box;
}
.glossary-count {
  display: inline-flex;
  align-items: center;
  height: 1.75rem;
  font-size: 0.85rem;
  line-height: 1;
}
.strategy-plans-layout { min-height: 28rem; }
.strategy-plan-header {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}
.strategy-plan-title-display { margin: 0; color: var(--accent2); }
.strategy-plan-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.strategy-plan-meta { font-size: 0.85rem; margin: 0; }
.strategy-plan-body { line-height: 1.5; font-size: 0.95rem; }
.strategy-plan-body h2, .strategy-plan-body h3 { margin: 1rem 0 0.4rem; }
.strategy-plan-body ul, .strategy-plan-body ol { margin: 0.35rem 0 0.75rem; padding-left: 1.25rem; }
.strategy-plan-title-input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 1.05rem;
}
.strategy-plan-title-input[hidden] { display: none !important; }
.knowledge-glossary-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.knowledge-glossary-head h2 { margin: 0; }
.glossary-add-btn { flex-shrink: 0; }
.glossary-item-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  justify-content: space-between;
}
.glossary-edit-btn {
  font-size: 0.8rem;
  padding: 0.15rem 0.45rem;
}
.glossary-term-dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  max-width: min(32rem, 94vw);
  width: 100%;
}
.glossary-term-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.glossary-term-dialog-inner {
  padding: 1.1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.glossary-term-dialog h3 { margin: 0; }
.glossary-term-dialog label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
}
.glossary-term-dialog input,
.glossary-term-dialog textarea {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
.glossary-term-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.25rem;
}
.glossary-term-dialog-actions .spacer { flex: 1; }
.search-help-pop {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 20;
  min-width: 16rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
}
.search-help-pop ul { margin: 0.35rem 0 0; padding-left: 1.1rem; }
.hold-horizon-table td, .hold-horizon-table th { font-size: 0.85rem; }
.trading-actions { margin: 0.75rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.trading-progress { font-size: 0.85rem; }

.upload-kind-fieldset {
  border: 1px solid var(--line);
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
}
.upload-kind-legend { font-size: 0.75rem; color: var(--muted); padding: 0 0.35rem; }
.upload-kind-opt { display: inline-flex; align-items: center; gap: 0.35rem; margin-right: 1rem; color: var(--ink); cursor: pointer; }
.upload-kind-hint { margin: 0 0 0.75rem; font-size: 0.85rem; }
.text-link-panel { margin-top: 1rem; }
.text-link-title { margin: 0 0 0.5rem; font-size: 1rem; color: var(--accent2); }
.text-link-label { display: block; margin: 0.75rem 0; }
.text-link-mode {
  border: none;
  margin: 0.75rem 0;
  padding: 0;
}
.text-link-hint { margin: 0.35rem 0 0.5rem; font-size: 0.85rem; }
.text-link-label .wb-select { width: 100%; max-width: 36rem; margin: 0.25rem 0 0; }
.upload-shell {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
}
#panel-upload.upload-shell,
#panel-upload .upload-shell {
  max-width: 44rem;
}
.upload-rename-label {
  display: block;
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.upload-filename.wb-select {
  margin: 0.25rem 0 0;
  max-width: 100%;
}
.upload-detect-note { margin: 0.35rem 0 0.75rem; font-size: 0.85rem; }
.text-link-stored { margin: 0.25rem 0 0.5rem; font-size: 0.8rem; }
