/* Wealth in 3 layers (/wealth). Linked after /assets/base.css, which holds the tokens, fonts, nav,
   buttons, badge and reveal motion. Same look as /portfolio: light page, white cards with a hairline
   border and a 4px radius, Geist through assets/shell.css, dark buttons.
   The class names come from wealth/wealth.js, which writes most of the page. */

.wealth {
  /* Ink and surfaces, under the names wealth.js uses in its SVG and inline styles */
  --ink: var(--text);
  --ink2: var(--text-2);
  --mute: var(--muted-text);
  --page: #fff;
  --line: var(--hairline);
  --line2: var(--hairline-strong);
  --sunk: #0000000a;
  --sunk2: #0000000f;
  --track: #0000000f;
  --hm-mid: #f2f2f4;
  --f-body: var(--font-ui);
  --pad: 26px;

  --ok-ink: #157a46;
  --bad-ink: #c23439;
  --warn-ink: #8f6200;
  --ok-soft: #1f9d551a;
  --bad-soft: #e5484d17;
  --warn-soft: #c98a001f;

  /* The 3 layers, plus debts */
  --l1: #12a594;
  --l2: #5b5bd6;
  --l3: #d6409f;
  --l4: #e5484d;
  --l1-bg: #12a5940d;
  --l2-bg: #5b5bd60d;
  --l3-bg: #d6409f0b;

  /* Asset classes in the fat layer, income moons */
  --cs: #0a84ff;
  --cb: #7c5cff;
  --cc: #30a46c;
  --cx: #e8890c;
  --ac: #0a84ff;

  /* Fragility */
  --fF: #8e8e93;
  --fR: #0a84ff;
  --fA: #e8890c;

  /* Seasons of the square */
  --ib: #e0a300;
  --ix: #e5484d;
  --db: #30a46c;
  --dx: #6e7dab;

  /* Correlation: together, apart */
  --hot: #e5484d;
  --cool: #0a84ff;

  overflow-x: clip;
}

[hidden] { display: none !important; }
[tabindex="-1"]:focus { outline: none; }

.wealth input,
.wealth select,
.wealth textarea {
  font: inherit;
  letter-spacing: inherit;
  color: var(--text);
}

.ok { color: var(--ok-ink); }
.warn { color: var(--warn-ink); }
.bad { color: var(--bad-ink); }
.mute { color: var(--muted-text); }
.sm { font-size: 12.5px; }
.up { color: var(--ok-ink); }
.down { color: var(--bad-ink); }
.c1 { --lc: var(--l1); }
.c2 { --lc: var(--l2); }
.c3 { --lc: var(--l3); }
.c4 { --lc: var(--l4); }

/* ---------- Page frame ---------- */

.page {
  width: min(var(--content-w), 100% - 2 * var(--gutter));
  margin: 0 auto;
  padding-bottom: 40px;
  display: grid;
  gap: 20px;
  --content-w: 1240px;
  --reveal-base: 80ms;
}

.w-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  padding: 40px 0 4px;
}

.w-title {
  font-size: clamp(38px, 5.4vw, 68px);
  letter-spacing: -0.07em;
  line-height: .98;
  padding-bottom: .04em;
  text-wrap: balance;
}

.live-word { color: var(--accent); }

.w-intro {
  max-width: 640px;
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.022em;
  color: var(--text-2);
  text-wrap: pretty;
}

/* The 3 layers, defined */
.defs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.def {
  position: relative;
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 20px 22px 20px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
}

.def-n {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--lc);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.def-t {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: -0.055em;
}

.def p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-2);
}

/* ---------- Cards ---------- */

.card {
  scroll-margin-top: calc(var(--nav-h) + 16px);
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
  padding: var(--pad);
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
}

.ch {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.ch h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: -0.06em;
  text-wrap: balance;
}

.ch .eyebrow { margin-bottom: 6px; }
.ch .rt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-2);
}

.eyebrow.c1::before,
.eyebrow.c2::before,
.eyebrow.c3::before,
.eyebrow.c4::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lc);
}

.sub {
  max-width: 72ch;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
}

.note {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted-text);
}

.note b { color: inherit; }
.note b.ok { color: var(--ok-ink); }
.note b.warn { color: var(--warn-ink); }
.note b.bad { color: var(--bad-ink); }

/* ---------- Buttons and controls ---------- */

.wealth .btn {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--hairline-strong);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.wealth .btn:hover { border-color: #00000038; transform: translateY(-1px); }

.wealth .btn.sm {
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-nav-btn);
  font-size: 13px;
}

.wealth .btn.pri {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

.wealth .btn.pri:hover {
  background: #000;
  border-color: #000;
  box-shadow: 0 6px 16px -8px #0000004d;
}

.wealth .btn.pri:hover .btn-glyph { transform: translateX(2px); }

.wealth .btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}

.wealth .btn.ghost:hover { color: var(--text); background: var(--sunk); transform: none; }

.wealth .btn.arm,
.wealth .btn.arm:hover {
  border-color: transparent;
  background: var(--bad-soft);
  color: var(--bad-ink);
}

.field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.field select,
.field input,
.lsel,
.rb-src input,
.slider input[type=number],
.pop input[type=number],
.pop input[type=text],
.pop select,
.backup textarea {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--hairline-strong);
  border-radius: 10px;
  background: var(--panel);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.field select:focus,
.field input:focus,
.lsel:focus,
.rb-src input:focus,
.slider input:focus,
.pop input:focus,
.pop select:focus,
.backup textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Segmented control: Map or Edit, colour by */
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--sunk2);
}

.seg button {
  height: 32px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

.seg button:hover { color: var(--text); }

.seg button.on {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 3px #0000001f, 0 0 0 1px #0000000a;
}

.seg.sm button { height: 28px; padding: 0 12px; font-size: 12.5px; }

/* Small pill toggle, as the builder's filter chips */
.tbtn {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  background: var(--panel);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}

.tbtn:hover { border-color: #00000033; }
.tbtn.on { background: var(--text); border-color: var(--text); color: #fff; }

input[type=range] {
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

input[type=range]:focus { outline: none; }
input[type=range]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--track); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--track); }

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px #0000001f, 0 2px 6px -1px #00000033;
  transition: transform var(--dur-fast) var(--ease-out);
}

input[type=range]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px #0000001f, 0 2px 6px -1px #00000033;
}

input[type=range]:active::-webkit-slider-thumb { transform: scale(1.12); }

/* Example data notice */
.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 14px;
  padding: 10px 12px 10px 20px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  font-size: 13.5px;
  color: var(--text-2);
  text-align: center;
}

.notice b { color: var(--text); font-weight: 600; }

/* Status chips */
.st {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--sunk);
  color: var(--text-2);
}

.st::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.st.ok { background: var(--ok-soft); color: var(--ok-ink); }
.st.warn { background: var(--warn-soft); color: var(--warn-ink); }
.st.warn::before { border-radius: 1px; transform: rotate(45deg); }
.st.bad { background: var(--bad-soft); color: var(--bad-ink); }
.st.bad::before { border-radius: 1px; }
.st.mute::before { background: transparent; border: 1.5px solid currentColor; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-2);
  background: color-mix(in srgb, var(--lc, var(--accent)) 12%, transparent);
}

.simtag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--link);
  background: var(--accent-soft);
}

/* ---------- Summary ---------- */

.sum {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px 32px;
  padding: 22px var(--pad);
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
}

.nw .lbl { display: block; font-size: 12.5px; color: var(--muted-text); }

.nw b {
  display: block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.05em;
  white-space: nowrap;
}

.nw .delta { display: block; min-height: 1.2em; font-size: 12.5px; color: var(--muted-text); }

.mix { display: grid; gap: 9px; min-width: 0; }
.mbar { display: flex; gap: 3px; height: 10px; }

.mbar i {
  display: block;
  min-width: 4px;
  flex-basis: 0;
  border-radius: 999px;
  transition: flex-grow 700ms var(--ease-out);
}

.mbar i:nth-child(1) { background: var(--l1); }
.mbar i:nth-child(2) { background: var(--l2); }
.mbar i:nth-child(3) { background: var(--l3); }

.mleg { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 13px; color: var(--text-2); }

.mleg span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--lc);
  vertical-align: 1px;
}

.mleg b { color: var(--text); font-weight: 600; }

.dline {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted-text);
}

.dbar { height: 5px; overflow: hidden; border-radius: 999px; background: var(--track); }
.dbar i { display: block; width: 0; height: 100%; border-radius: 999px; background: var(--l4); transition: width 700ms var(--ease-out); }
.iline { font-size: 12.5px; color: var(--muted-text); }
.iline b { color: var(--ok-ink); font-weight: 600; }
.ctl { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }

/* ---------- Simulation bar ---------- */

.scen {
  display: grid;
  gap: 14px;
  padding: 18px var(--pad);
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: var(--radius-card);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: reveal 450ms var(--ease-out) both;
}

.scen .sh { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.scen .sh b { font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: -0.05em; }
.scen .sh .sp { flex: 1; }

.pulse {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent);
  animation: dot-pulse 2.4s var(--ease-out) infinite;
}

.deltas { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.dl { display: grid; gap: 1px; min-width: 0; padding: 10px 14px; border-radius: 14px; background: var(--bg); }
.dl span { font-size: 12px; color: var(--muted-text); }
.dl b { overflow: hidden; font-size: 15px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.dl i { font-size: 12px; font-style: normal; }
.moves { display: flex; flex-wrap: wrap; gap: 6px; }

.moves li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 6px 5px 13px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 12.5px;
  color: var(--text-2);
}

.moves li span { min-width: 0; }
.moves li em { font-style: normal; font-weight: 600; color: var(--text); }

.moves li button {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text-2);
  line-height: 1;
}

.moves li button:hover { background: var(--bad-soft); color: var(--bad-ink); }

/* ---------- Stage: map and inspector ---------- */

.stage { display: grid; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 20px; }
.stage.solo { grid-template-columns: minmax(0, 1fr); }
.mapcard { padding: 14px; gap: 12px; }
.mhead { display: grid; gap: 6px; padding: 6px 8px 0; }
.mrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.mctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mleg2 { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; margin-right: 6px; }
.mleg2 span { color: var(--text-2); }

.mleg2 span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--lc);
}

.crumbs { display: flex; align-items: center; gap: 4px; }

.crumbs button {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-2);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.crumbs button:hover { color: var(--text); background: var(--sunk); }

.crumbs .here {
  padding: 0 4px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.055em;
  color: var(--text);
}

.crumbs .sep { color: var(--faint); }
.mhint { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12.5px; color: var(--muted-text); }

.map {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: var(--bg);
  touch-action: pan-y;
}

.map svg { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }

.dhint {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 2;
  max-width: calc(100% - 24px);
  overflow: hidden;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  pointer-events: none;
  transform: translateX(-50%);
  box-shadow: 0 10px 30px -12px #00000066;
}

.dhint.idle { background: var(--panel); color: var(--text-2); box-shadow: 0 0 0 1px var(--hairline-strong), 0 10px 30px -14px #0000004d; }

.insp { position: sticky; top: calc(var(--nav-h) + 16px); }

/* The map's own marks */
.band .bl { font-size: 12px; }
.band .bl .nm { font-family: var(--font-display); font-size: 15px; font-weight: 800; letter-spacing: -0.03em; }
.band .bl .tot { font-size: 15px; font-weight: 600; fill: var(--text); }
.band .bl .sh { font-size: 12px; fill: var(--muted-text); }
.band.drop rect.bg { stroke: var(--accent) !important; stroke-opacity: 1 !important; stroke-width: 1.6px; }
.band .hint { font-size: 14px; font-weight: 600; fill: var(--accent); text-anchor: middle; pointer-events: none; }
.chip rect { fill: #0000000a; }
.chip text { font-size: 12px; fill: var(--text-2); text-anchor: middle; pointer-events: none; }
.chip.act { cursor: pointer; }
.chip.act rect { fill: var(--panel); stroke: var(--hairline-strong); }
.chip.act text { fill: var(--text); font-weight: 600; }
.chip.act:hover rect,
.chip.act:focus-visible rect { fill: var(--text); stroke: var(--text); }
.chip.act:hover text,
.chip.act:focus-visible text { fill: #fff; }
.chip.bad text { fill: var(--bad-ink); }
.chip.debt text { fill: var(--bad-ink); }
.node { cursor: pointer; outline: none; }
.node.dr { cursor: grab; touch-action: none; }
.node.dragging { cursor: grabbing; }
.node .inner { transform-box: fill-box; transform-origin: center; transition: transform 350ms var(--ease-out); }
.node:hover .inner,
.node:focus-visible .inner { transform: scale(1.035); }
.node.dragging .inner { transform: scale(1.07); }
.node .body { stroke-width: 1.5px; }
.node .halo { fill: none; stroke: var(--text); stroke-width: 2px; opacity: 0; transition: opacity 200ms; }
.node.sel .halo,
.node:focus-visible .halo { opacity: 1; }
.node.tgt .halo { opacity: 1; stroke: var(--ok); stroke-dasharray: 4 4; }
.node .ring { fill: none; stroke: var(--text); stroke-opacity: .55; stroke-width: 1.2px; stroke-dasharray: 3 4; pointer-events: none; }
.node .ghost { fill: none; stroke: var(--text); stroke-opacity: .45; stroke-width: 1.2px; stroke-dasharray: 1.5 4.5; }
.node .debt { stroke: var(--l4); stroke-opacity: .7; stroke-width: 1px; pointer-events: none; }

.node text {
  fill: var(--text);
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: #ffffffc7;
  stroke-width: 3px;
  stroke-linejoin: round;
}

.node .t1 { font-size: 12.5px; font-weight: 600; }
.node .t2 { font-size: 12px; fill: var(--text-2); }
.node .t3 { font-size: 11px; fill: var(--muted-text); }
.node .cv { font-size: 12px; font-weight: 700; }
.node .inc rect { fill: var(--accent); }
.node .inc text { fill: #fff; stroke: none; font-size: 10.5px; font-weight: 700; }
.node.ph .body { fill: transparent !important; stroke: var(--faint) !important; stroke-dasharray: 4 4; }
.node.ph .t1 { fill: var(--link); }
.fx circle { pointer-events: none; }
.node .moon { stroke: var(--accent); stroke-width: 1.2px; pointer-events: none; }
.node.zero .body { fill: transparent !important; stroke: var(--faint) !important; stroke-dasharray: 3 4; }
.node.zero .t1 { fill: var(--text-2); }
.node.zero .t2 { fill: var(--muted-text); }

.fchip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
  background: color-mix(in srgb, var(--fc) 14%, transparent);
}

.fchip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--fc); }

/* ---------- Inspector ---------- */

.ih { display: grid; gap: 4px; }
.ih h3 { font-family: var(--font-display); font-weight: 800; font-size: 26px; line-height: 1.08; letter-spacing: -0.055em; }
.ih .big { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted-text); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.acts { display: grid; gap: 8px; }
.acts .btn { width: 100%; justify-content: center; }
.tips { display: grid; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--bg); font-size: 12.5px; color: var(--text-2); }
.tips b { color: var(--text); }
.slider { display: grid; gap: 6px; }
.slider label { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.slider b { color: var(--text); }
.slider input[type=number] { width: 100%; }
.mini-h { margin-bottom: 6px; font-size: 12.5px; color: var(--muted-text); }
.sch { display: flex; flex-wrap: wrap; gap: 6px; }
.sch span { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--text); background: color-mix(in srgb, var(--sc) 16%, transparent); }
.cl { display: grid; gap: 6px; font-size: 13px; }
.cl div { display: flex; justify-content: space-between; gap: 10px; }
.cl i { font-style: normal; }
.minichk { display: grid; gap: 6px; }
.minichk div { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }

/* The fat layer to Portfolio construction */
.to-pf-box { display: grid; gap: 8px; }
.wealth .btn.to-pf { width: 100%; height: 46px; justify-content: center; font-size: 14px; }
/* The fat layer view: the builder in a frame, its height sent by the frame (pci-embed-height). */
.pf-embed { min-width: 0; }
.pf-frame { display: block; width: 100%; height: 1400px; border: 0; background: var(--panel); }

/* ---------- Popover: set the amount, then simulate ---------- */

.pop {
  position: fixed;
  top: 30%;
  left: 50%;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 24px));
  padding: 18px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  background: var(--panel);
  box-shadow: 0 30px 60px -24px #00000040, 0 2px 8px -2px #0000001a;
  animation: reveal 280ms var(--ease-out) both;
}

.pop h4 { font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1.1; letter-spacing: -0.05em; }
.pop .lead { font-size: 13px; color: var(--text-2); }
.pop label { margin-bottom: -4px; font-size: 12px; color: var(--muted-text); }
.pop .amt { display: grid; grid-template-columns: 1fr 118px; align-items: center; gap: 10px; }
.pop input[type=number],
.pop input[type=text],
.pop select { width: 100%; }
.pop .out { padding: 10px 12px; border-radius: 12px; background: var(--bg); font-size: 13px; color: var(--text-2); }
.pop .out b { color: var(--text); }
.pop .out b.bad, .pop .out .bad { color: var(--bad-ink); }
.pop .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 2px; }

/* ---------- Readings ---------- */

.read { display: grid; gap: 20px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.recs { display: grid; margin: 0 calc(-1 * var(--pad)); }

.rec {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px var(--pad);
  border-top: 1px solid var(--hairline);
}

.rec:last-child { padding-bottom: 2px; }
.rec p { font-size: 14px; color: var(--text-2); }
.rec p b { color: var(--text); font-weight: 600; }
.rec .ra { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.rec > .st { justify-self: start; }

.checks { display: grid; margin: 0 calc(-1 * var(--pad)); }

.chk {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px var(--pad);
  border-top: 1px solid var(--hairline);
}

.chk b { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.chk .t { font-size: 13px; color: var(--text-2); }
.score { display: flex; align-items: baseline; gap: 6px; }
.score .n { font-family: var(--font-display); font-weight: 800; font-size: 36px; letter-spacing: -0.05em; line-height: 1; }
.score .n small { font-family: var(--font-ui); font-weight: 500; font-size: 15px; letter-spacing: 0; color: var(--muted-text); }

.tw { overflow-x: auto; }
.wealth table { width: 100%; border-collapse: collapse; }

.wealth th {
  padding: 8px 10px;
  border-top: 1px solid var(--hairline);
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted-text);
  white-space: nowrap;
}

.wealth td { padding: 3px 6px; border-top: 1px solid var(--hairline); vertical-align: middle; font-variant-numeric: tabular-nums; }
.lines td, .lines th, .ladder td, .ladder th { padding: 10px; font-size: 13px; white-space: nowrap; }
.lines .r, .ladder .r { text-align: right; }
.ladder .mcell { width: 28%; min-width: 80px; }
.ladder tr.sh th { padding-top: 18px; font-size: 13px; font-weight: 600; color: var(--text); }
.freq { font-size: 11.5px; color: var(--muted-text); white-space: normal; }
.meter { position: relative; min-width: 60px; height: 8px; overflow: hidden; border-radius: 999px; background: var(--track); }
.meter i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--mc, var(--accent)); }
.lsel { max-width: 210px; height: 32px; padding: 0 8px; font-size: 12.5px; }
.loss b { font-weight: 600; }

/* Rebalance */
.rb-src { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rb-src input { width: 150px; height: 30px; border-radius: 999px; }
.rb-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.rb-opt {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: var(--bg);
}

.rb-opt.best { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-soft); }
.rb-h { display: grid; gap: 6px; }
.rb-h b { font-size: 14px; font-weight: 600; }
.rb-h .tag { justify-self: start; color: var(--link); background: var(--accent-soft); }
.rb-list { display: grid; gap: 6px; font-size: 13px; }
.rb-list li { display: flex; justify-content: space-between; gap: 10px; }
.rb-list .buy { color: var(--ok-ink); white-space: nowrap; }
.rb-list .sell { color: var(--warn-ink); white-space: nowrap; }
.rb-out { font-size: 12.5px; color: var(--text-2); }
.rb-out.mute { color: var(--muted-text); }
.rb-opt .btn { justify-self: start; }

/* Gave's square, fragility, risk and danger */
.sqs { display: grid; margin: 0 calc(-1 * var(--pad)); }
.sqrow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 10px var(--pad); border-top: 1px solid var(--hairline); }
.sqrow b { font-size: 13.5px; font-weight: 600; }
.sqrow .w { display: block; font-size: 12px; color: var(--text-2); }
.sqleg { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted-text); }
.fmix { display: flex; gap: 3px; height: 10px; }
.fmix i { display: block; min-width: 4px; border-radius: 999px; background: var(--fc); }
.fleg { display: grid; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.fleg div { display: flex; align-items: baseline; gap: 10px; }
.fleg b { min-width: 42px; text-align: right; font-weight: 600; color: var(--text); }
.fax svg, .sc svg { display: block; width: 100%; height: auto; }
.sc text, .fax text { font-family: var(--font-ui); }

/* Correlation map */
.mx { overflow-x: auto; }
.mx table { width: auto; border-collapse: separate; border-spacing: 3px; }
.mx th { padding: 4px 6px; border: 0; font-size: 11.5px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.mx th.rot { height: 110px; vertical-align: bottom; }
.mx th.rot span { display: inline-block; max-height: 106px; overflow: hidden; writing-mode: vertical-rl; transform: rotate(180deg); }
.mx td { width: 44px; height: 34px; padding: 0; border: 0; border-radius: 8px; text-align: center; font-size: 12px; color: var(--text); }
.mx td.real { font-weight: 700; }
.mx td.diag { background: var(--bg); color: var(--faint); }

/* ---------- Edit mode: your real numbers ---------- */

.grp { display: grid; min-width: 0; overflow: hidden; border: 1px solid var(--hairline); border-radius: 16px; }
.grp + .grp { margin-top: 12px; }
.gh { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: var(--bg); }

.gh h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.05em;
}

.gh h3::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--lc); }
.gh .tot { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.gh .rule { max-width: 80ch; margin-top: 3px; font-size: 12.5px; color: var(--muted-text); }
.gset { display: flex; flex-wrap: wrap; gap: 10px 20px; padding: 0 16px 14px; background: var(--bg); }
.gset .field input { width: 120px; }
.gset .field input.sm { width: 64px; }
.grp th:first-child, .grp td:first-child { padding-left: 12px; }

.grp td input,
.grp td select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  transition: background-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.grp td input:hover,
.grp td select:hover { background: var(--sunk); }
.grp td input:focus,
.grp td select:focus { outline: none; background: var(--panel); box-shadow: 0 0 0 1.5px var(--accent); }
.grp td input::placeholder { color: var(--faint); }
.grp td input.num { text-align: right; }
td.x { width: 36px; text-align: center; }
td.x button { width: 28px; height: 28px; border-radius: 50%; font-size: 17px; line-height: 1; color: var(--faint); }
td.x button:hover { background: var(--bad-soft); color: var(--bad-ink); }
td.ro { padding-right: 12px; text-align: right; font-size: 12px; color: var(--muted-text); white-space: nowrap; }
.add { display: flex; padding: 8px 10px 10px; border-top: 1px solid var(--hairline); }
.add button { height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; color: var(--text-2); transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.add button:hover { color: var(--text); background: var(--sunk); }
.empty { padding: 12px 16px; border-top: 1px solid var(--hairline); font-size: 13px; color: var(--muted-text); }
.backup { display: grid; gap: 8px; }
.backup textarea { width: 100%; height: auto; min-height: 100px; padding: 10px 12px; font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.move-note { padding: 10px 14px; border-radius: 12px; background: var(--bg); color: var(--text-2); }

/* ---------- Footer, toast ---------- */

.page-foot { display: grid; gap: 4px; padding: 8px var(--gutter) 40px; text-align: center; }
.foot-dates { color: var(--muted-text); }
.noscript { padding: 24px; text-align: center; color: var(--text-2); }

.toast {
  position: fixed;
  top: calc(var(--nav-h) + 12px);
  left: 50%;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 13.5px;
  white-space: nowrap;
  box-shadow: 0 10px 30px -10px #00000066;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -8px) scale(.98);
  transition: opacity 260ms var(--ease-out), transform 360ms var(--ease-out);
}

.toast::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.toast.on { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ---------- Narrower screens ---------- */

@media (max-width: 1000px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .insp { position: static; }
}

@media (max-width: 900px) {
  .two { grid-template-columns: minmax(0, 1fr); }
  .rb-opts { grid-template-columns: minmax(0, 1fr); }
  .defs { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .sum { grid-template-columns: minmax(0, 1fr) auto; }
  .mix { grid-column: 1 / -1; order: 3; }
}

@media (max-width: 640px) {
  .wealth { --pad: 18px; }
  .page { gap: 14px; }
  .w-head { padding-top: 28px; gap: 14px; }
  .w-title { font-size: clamp(34px, 10.4vw, 46px); }
  .w-intro { font-size: 15.5px; }
  .def { grid-template-columns: 24px minmax(0, 1fr); gap: 2px 12px; padding: 14px 16px; }
  .def-n { grid-row: 1 / span 2; margin: 0; }
  .def-t { font-size: 19px; }
  .def p { font-size: 13.5px; }
  .ch h2 { font-size: 23px; }
  .sum { grid-template-columns: minmax(0, 1fr); padding: 18px; }
  .ctl { justify-content: space-between; }
  .nw b { font-size: 32px; }
  .notice { border-radius: 16px; padding: 12px 16px; }
  .mapcard { padding: 10px; }
  .rec { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .rec .ra { justify-content: space-between; }
  .chk { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .toast { top: auto; bottom: max(20px, env(safe-area-inset-bottom, 0px)); }
  .pop { top: auto !important; right: 12px; bottom: max(12px, env(safe-area-inset-bottom, 0px)); left: 12px !important; width: auto; }

  .ladder thead { display: none; }
  .ladder, .ladder tbody { display: block; }
  .ladder tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 14px 2px; border-top: 1px solid var(--hairline); }
  .ladder tr.sh { display: block; padding-bottom: 0; border-top: 0; }
  .ladder td { padding: 0; border: 0; white-space: normal; }
  .ladder td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .ladder td:nth-child(6) { grid-column: 2; grid-row: 1; justify-self: end; }
  .ladder td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .ladder td:nth-child(3) { grid-column: 1; grid-row: 3; text-align: left; font-size: 18px; font-weight: 600; }
  .ladder td:nth-child(5) { grid-column: 2; grid-row: 3; }
  .ladder td:nth-child(4) { grid-column: 1 / -1; grid-row: 4; width: auto; }
  .ladder .lsel { width: 100%; max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .wealth .btn:hover { transform: none; }
  .pulse::after { animation: none !important; }
}
