:root {
  --bg: #000000;
  --panel: #000000;
  --border: #1a1a1a;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --up: #3ddc97;
  --down: #f87171;
  /* Fallback until privacy.js measures .site-footer (wraps taller on narrow screens). */
  --footer-offset: 5.5rem;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg); color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}
body {
  /* Keep last content clear of the fixed footer on every page. */
  padding-bottom: calc(var(--footer-offset) + 0.85rem);
}
main { max-width: none; margin: 0; padding: 0.8rem; width: 100%; }

.wordmark {
  display: block;
  width: fit-content;
  margin: 0 0 0.55rem;
  color: var(--text);
  text-decoration: none;
  font-size: clamp(1.85rem, 3.6vw, 2.55rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.wordmark:hover,
.wordmark:focus-visible {
  color: var(--text);
  text-decoration: none;
}
.chart-panel {
  background: var(--panel); border: none; border-radius: 0;
  padding: 0;
  /* Chart + legend together take ~40% of the visible viewport. */
  display: flex;
  flex-direction: column;
  min-height: 40vh;
  min-height: 40dvh;
  min-height: 40svh;
}
#chart { position: relative; flex: 1 1 0; height: auto; min-height: 200px; width: 100%; overflow: hidden; }
.day-line {
  position: absolute;
  top: 0;
  width: 0;
  border-left: 1px dotted #ef4444;
  pointer-events: none;
  z-index: 3;
}
.compare-panel {
  margin-top: 0.45rem;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.35rem 0.5rem 0.45rem;
}
#compare-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
#compare-table th, #compare-table td {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
#compare-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
}
#compare-table th:first-child,
#compare-table td.window {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
}
#compare-table td.pct { text-align: left; white-space: nowrap; }
#compare-table td.pct-up { color: var(--up); }
#compare-table td.pct-down { color: var(--down); }
#compare-table td.pct-flat { color: var(--muted); }

.book-card {
  margin: 0 0 0.75rem;
  max-width: 42rem;
}
.card-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  table-layout: fixed;
}
.card-table th,
.card-table td {
  text-align: left;
  padding: 0.22rem 0.45rem 0.22rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-weight: 400;
}
.card-table th {
  width: 7.5rem;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  padding-right: 0.75rem;
}
.card-table td {
  color: var(--text);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}
.card-table tr:last-child th,
.card-table tr:last-child td {
  border-bottom: 0;
}
@media (max-width: 640px) {
  .book-card { max-width: 100%; margin-bottom: 1rem; }
  .card-table th { width: 6.5rem; }
}
.holdings-panel {
  margin-top: 0.5rem; background: var(--panel); border: 1px solid var(--border);
  border-radius: 0; padding: 0.6rem 0.7rem 0.75rem;
  width: 100%;
  overflow: hidden;
}
.day-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr) minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1rem 1.25rem;
  align-items: start;
  width: 100%;
}
.day-col {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
  position: relative;
}
.day-col > table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}
.section-label {
  color: var(--muted); font-size: 0.72rem; letter-spacing: 0.04em;
  text-transform: uppercase; margin-bottom: 0.3rem;
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
td { text-align: left; padding: 0.4rem 0.35rem; border-bottom: 1px solid var(--border); }
td.sym {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
td.weight {
  text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap;
}
td.range {
  text-align: left;
  font-variant-numeric: tabular-nums;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 0.85rem;
  line-height: 1.35;
}
.day-note {
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.5;
  min-height: 1.2em;
  max-width: 100%;
  width: 100%;
  position: static;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  overflow: hidden;
}
.day-note:empty::after { content: ''; }
/* Stack day cols only on phone; half-width stays 3-col */
@media (max-width: 640px) {
  main { padding: 0.55rem; }
  .holdings-panel, .compare-panel { padding-left: 0.55rem; padding-right: 0.55rem; }
  .site-footer { padding-left: 0.55rem; padding-right: 0.55rem; }
  .day-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
  }
  .day-col { padding-bottom: 0.15rem; overflow: hidden; }
  table { font-size: 0.95rem; }
  td { padding: 0.6rem 0.35rem; }
  .day-note { font-size: 0.92rem; line-height: 1.55; }
  #compare-table { font-size: 0.82rem; }
  #compare-table th, #compare-table td { padding: 0.4rem 0.3rem; }
}

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  margin: 0;
  padding: 0.55rem 0.8rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 0.22rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
}
.site-footer .footer-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.site-footer a {
  color: var(--muted);
  text-decoration: none;
}
.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--text);
  text-decoration: underline;
}

@media (max-width: 640px) {
  .site-footer { padding-left: 0.55rem; padding-right: 0.55rem; }
}

.chart-meta {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0 0 0.35rem;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem 0.7rem;
  flex: 1;
  min-width: 0;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.swatch {
  width: 0.7rem;
  height: 2px;
  display: inline-block;
  flex: 0 0 auto;
}
.swatch.bar { height: 0; border-top: 2px dashed currentColor; width: 0.85rem; background: none !important; }
.selected-day {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding-top: 0.05rem;
}
.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding-top: 0.05rem;
}
.back-link:hover, .back-link:focus-visible { color: var(--text); }
.books-panel { margin-top: 0.45rem; width: 100%; }
.table-scroll { width: 100%; overflow-x: auto; border: 1px solid var(--border); }
#books-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; min-width: 980px; }
#books-table th, #books-table td {
  padding: 0.38rem 0.45rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#books-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
#books-table td.name, #books-table th.name,
#books-table td.bar, #books-table th.bar,
#books-table td.thesis, #books-table th.thesis {
  text-align: left;
}
#books-table td.thesis {
  white-space: normal;
  min-width: 16rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#books-table a.book-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
#books-table a.book-link:hover, #books-table a.book-link:focus-visible { text-decoration: underline; }
#books-table .bar-line,
#books-table .vs-line {
  display: block;
  line-height: 1.35;
}
#books-table td.vs { text-align: left; }
#books-table td.pct-up, #books-table .pct-up { color: var(--up); }
#books-table td.pct-down, #books-table .pct-down { color: var(--down); }
#books-table td.pct-flat, #books-table .pct-flat { color: var(--muted); }
@media (max-width: 640px) {
  .chart-meta { flex-wrap: wrap; }
}

.site-footer .footer-copy,
.site-footer .footer-sep { white-space: nowrap; }
.site-footer .footer-sep { color: var(--muted); }
.site-footer .footer-sep.footer-sep--wrap-edge {
  /* After measure-with-shown: hide edge seps without reflow (avoids post-hide leading |). */
  visibility: hidden;
}
.site-footer button.privacy-choices {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: inherit;
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.site-footer button.privacy-choices svg {
  height: 14px;
  width: auto;
  display: block;
  flex: 0 0 auto;
}
.site-footer button.privacy-choices:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 2px;
}
.privacy-page { max-width: 42rem; padding-bottom: 0.5rem; }
.privacy-page h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 0.4rem;
}
.privacy-page .asof { color: var(--muted); font-size: 0.8rem; margin: 0 0 1.1rem; }
.privacy-page h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.25rem 0 0.35rem;
}
.privacy-page p, .privacy-page li {
  max-width: 42rem;
  line-height: 1.55;
}
.privacy-page p { margin: 0 0 0.65rem; }
.privacy-page ul { margin: 0 0 0.65rem; padding-left: 1.15rem; }
.privacy-page a { color: var(--text); }

.privacy-dialog[hidden] { display: none; }
.privacy-dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.privacy-card {
  position: relative;
  width: min(32rem, 100%);
  background: #fff;
  color: #161616;
  border-radius: 12px;
  padding: 1.15rem 1.2rem 1rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  font-size: 0.92rem;
  line-height: 1.45;
}
.privacy-card h2 { margin: 0 1.8rem 0.45rem 0; font-size: 1.2rem; font-weight: 650; }
.privacy-card p { margin: 0.35rem 0 0; color: #333; }
.privacy-card a { color: #0550ae; }
.privacy-x {
  position: absolute;
  top: 0.7rem;
  right: 0.75rem;
  border: 0;
  background: transparent;
  color: #161616;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
}
.privacy-allow, .privacy-confirm {
  appearance: none;
  border: 0;
  background: #0561f2;
  color: #fff;
  border-radius: 6px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.privacy-allow { display: block; width: 100%; margin: 0.85rem 0 0.35rem; }
.privacy-cat { border-top: 1px solid #e6e6e6; padding: 0.75rem 0 0.15rem; margin-top: 0.75rem; }
.privacy-cat-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.privacy-always { color: #3d7a1a; font-size: 0.8rem; font-weight: 650; }
.privacy-switch {
  width: 2.6rem;
  height: 1.45rem;
  border-radius: 999px;
  border: 0;
  background: #c5c5c5;
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 0;
}
.privacy-switch::after {
  content: "";
  position: absolute;
  top: 0.16rem;
  left: 0.16rem;
  width: 1.12rem;
  height: 1.12rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.privacy-switch[aria-checked="true"] { background: #0561f2; }
.privacy-switch[aria-checked="true"]::after { transform: translateX(1.15rem); }
.privacy-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.9rem; }
.privacy-reject {
  appearance: none;
  background: #fff;
  color: #161616;
  border: 1px solid #cfcfcf;
  border-radius: 6px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.not-advice[hidden] { display: none; }
.not-advice {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.not-advice-card {
  width: min(32rem, 100%);
  background: #fff;
  color: #161616;
  border-radius: 12px;
  padding: 1.15rem 1.2rem 1rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  font-size: 0.92rem;
  line-height: 1.45;
}
.not-advice-card h2 { margin: 0 0 0.45rem; font-size: 1.2rem; font-weight: 650; }
.not-advice-card p { margin: 0.35rem 0 0; color: #333; }
.not-advice-card button {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 0.85rem;
  border: 0;
  background: #0561f2;
  color: #fff;
  border-radius: 6px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* All dashboard tables: left-aligned cells and headings */
table th, table td { text-align: left !important; }

/* Sortable table headers */
table th .sort-btn {
  appearance: none;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-align: left;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  max-width: 100%;
}
table th .sort-btn:hover,
table th .sort-btn:focus-visible {
  color: var(--text);
}
table th .sort-btn:focus-visible {
  outline: 1px solid var(--accent, #5b8def);
  outline-offset: 2px;
}
table th .sort-ind {
  display: inline-block;
  min-width: 0.7em;
  font-size: 0.75em;
  opacity: 0.55;
  line-height: 1;
}
table th[aria-sort="none"] .sort-ind,
table th:not([aria-sort]) .sort-ind:empty {
  opacity: 0;
}
#holdings-table th,
#changes-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.28rem 0.35rem 0.35rem;
  border-bottom: 1px solid var(--border);
}
