/* The Asset Quilt — shared look of the Money apps. */
:root {
  --paper: #f4f1e8; --card: #fbf9f3; --ink: #1d2420; --ink-2: #4c5650;
  --ink-3: #87908a; --rule: rgba(29,36,32,.18); --rule-soft: rgba(29,36,32,.09);
  --accent: #2f5d46;
  --accent-2: #b0662a;
  --serif: "Fraunces", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --side-w: 330px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-padding-top: calc(var(--appnav-h, 0px) + 20px); }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
}
.side {
  position: sticky;
  top: var(--appnav-h, 0px);
  height: calc(100vh - var(--appnav-h, 0px));
  height: calc(100dvh - var(--appnav-h, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-right: 1px solid var(--rule-soft);
}
.side-inner { padding: 1.2rem 1.15rem 1.5rem 1.3rem; }
.main {
  position: relative;
  height: calc(100vh - var(--appnav-h, 0px));
  height: calc(100dvh - var(--appnav-h, 0px));
  min-height: 520px;
  padding: 0.9rem 1rem 0.8rem;
}
.chart-box {
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}
#chart { display: block; }

/* ---------- sidebar ---------- */
.kicker {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.title {
  margin-top: 0.25rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2.3rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.title em { font-style: italic; color: var(--accent); }
.lede { margin-top: 0.7rem; color: var(--ink-2); }
.side-h {
  margin: 1.25rem 0 0.5rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.seg {
  display: flex;
  margin-top: 1rem;
  border: 1px solid var(--rule);
  border-radius: 7px;
  overflow: hidden;
  background: var(--card);
}
.seg button {
  flex: 1;
  padding: 0.45rem 0.4rem;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--ink-2);
}
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 6px; }
.legend button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.25rem 0.4rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  text-align: left;
  font-size: 0.86rem;
  line-height: 1.2;
}
.legend button:hover { background: var(--card); border-color: var(--rule-soft); }
.legend button[aria-pressed="true"] { background: var(--card); border-color: var(--ink); }
.legend .sw {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
}
.legend .tk { display: block; font-family: var(--mono); font-size: 0.66rem; color: var(--ink-3); }
.legend .all { grid-column: 1 / -1; justify-content: center; color: var(--ink-2); }

.lessons { list-style: none; }
.lessons li { margin-bottom: 0.55rem; padding-left: 0.9rem; position: relative; color: var(--ink-2); }
.lessons li::before {
  content: ""; position: absolute; left: 0; top: 0.6em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.lessons b { color: var(--ink); font-weight: 600; }

.stats-wrap { overflow-x: auto; }
.stats { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.stats th, .stats td { padding: 0.28rem 0.3rem; text-align: right; white-space: nowrap; }
.stats th:first-child, .stats td:first-child { text-align: left; white-space: normal; }
.stats thead th {
  font-family: var(--mono); font-size: 0.62rem; font-weight: 500;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--rule);
}
.stats td { font-family: var(--mono); font-size: 0.74rem; border-bottom: 1px solid var(--rule-soft); }
.stats td:first-child { font-family: var(--sans); font-size: 0.8rem; }
.stats td .yr { color: var(--ink-3); font-size: 0.66rem; }
.stats tr.on td { background: var(--card); font-weight: 600; }
.stats .sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.side-foot { margin-top: 1rem; font-size: 0.85rem; color: var(--ink-3); }

/* ---------- chart ---------- */
.tile rect { transition: opacity 0.2s; }
.tile text { pointer-events: none; }
.t-lab { font-family: var(--sans); font-size: 11px; font-weight: 600; }
.t-val { font-family: var(--mono); font-size: 11px; }
.yr-lab { font-family: var(--mono); font-size: 12px; fill: var(--ink-2); }
.axis-lab { font-family: var(--mono); font-size: 10.5px; fill: var(--ink-3); }
.grid line { stroke: var(--rule-soft); }
.path-line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.dim .tile:not(.on) rect { opacity: 0.2; }
.dim .tile:not(.on) text { fill: var(--ink-2); opacity: 0.75; }
.tile.on rect { stroke: var(--ink); stroke-width: 2; }
.g-line { fill: none; stroke-width: 1.6; transition: opacity 0.2s; }
.g-line.on { stroke-width: 3; }
.dim .g-line:not(.on) { opacity: 0.18; }
.g-end { font-family: var(--sans); font-size: 11px; fill: var(--ink-2); }
.cross { stroke: var(--ink-3); stroke-dasharray: 3 3; }

.tip {
  position: absolute;
  z-index: 5;
  min-width: 170px;
  max-width: 260px;
  padding: 0.5rem 0.65rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 7px;
  box-shadow: 0 4px 14px rgba(29,36,32,.12);
  font-size: 0.85rem;
  pointer-events: none;
}
.tip .h { font-weight: 600; }
.tip .m { font-family: var(--mono); font-size: 0.78rem; color: var(--ink-2); }
.tip table { border-collapse: collapse; margin-top: 0.2rem; }
.tip td { padding: 0 0.5rem 0 0; font-size: 0.78rem; }
.tip td.n { font-family: var(--mono); text-align: right; }
.tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }

/* ---------- sources ---------- */
.sources {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.5rem 1.3rem 4rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
}
.sources h2 { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; color: var(--ink); margin: 1.6rem 0 0.6rem; }
.sources h2:first-child { margin-top: 0; }
.sources h3 { font-size: 1rem; color: var(--ink); margin: 1.2rem 0 0.4rem; }
.sources p { margin-bottom: 0.7rem; }
.sources ul { padding-left: 1.2rem; }
.sources li { margin-bottom: 0.45rem; }
.sources .advice { font-weight: 600; color: var(--ink); }
.check-wrap { overflow-x: auto; margin-bottom: 0.8rem; }
.check { border-collapse: collapse; font-size: 0.82rem; }
.check th, .check td { padding: 0.25rem 0.6rem; border-bottom: 1px solid var(--rule-soft); text-align: left; }
.check th { font-family: var(--mono); font-size: 0.66rem; font-weight: 500; color: var(--ink-3); text-transform: uppercase; }
.check td.n { font-family: var(--mono); }
.changelog { list-style: none; padding-left: 0 !important; }
.changelog time { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-3); margin-right: 0.6rem; }

/* ---------- narrow ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--rule-soft); }
  .main { height: 600px; min-height: 0; padding: 0.6rem 0.5rem; }
  .title { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
