/* =============================================================================
   Trust Fund — 162 Strategies
   Aesthetic: serious / governmental / actuarial. Navy + ivory + brass.
   ============================================================================= */
:root {
  /* 162 Strategies brand: blue + orange + gray */
  --navy:        #114a82;   /* deep brand blue */
  --navy-2:      #1a5b9c;   /* brand blue */
  --navy-3:      #2f6cb0;   /* lighter blue */
  --brass:       #d9772a;   /* brand orange (accent) */
  --brass-soft:  #ea8f3f;   /* brand orange, lighter */
  --ivory:       #f4f6f9;   /* cool paper to suit blue */
  --paper:       #ffffff;
  --ink:         #1f2a33;
  --ink-soft:    #565a5e;   /* brand gray */
  --rule:        #dfe5ec;

  --green:       #11703f;
  --green-bg:    #d6efdf;
  --green-edge:  #2f9e62;

  --red:         #9b2a26;
  --red-bg:      #f8dedc;   /* light red = "bad / still insolvent" */
  --red-edge:    #d98b86;

  --shadow:      0 1px 2px rgba(11,37,69,.06), 0 8px 24px rgba(11,37,69,.08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --tracker-h: 92px;
  --bar-h: 128px;   /* two-row action bar on phones */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(19,49,92,.06), transparent 60%),
    var(--ivory);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================ Sticky tracker ============================== */
.tracker {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(11,37,69,.28);
  border-bottom: 3px solid var(--brass);
  padding: max(10px, env(safe-area-inset-top)) 16px 12px;
  transition: background .45s ease, border-color .45s ease;
}
.tracker.is-solvent {
  background: linear-gradient(180deg, #0f5c34 0%, #14753f 100%);
  border-bottom-color: var(--brass-soft);
}
.tracker-inner {
  max-width: 860px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 14px;
}
.tracker-emblem {
  display: grid; place-items: center;
  width: 50px; height: 50px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  color: var(--brass-soft);
  border: 1px solid rgba(255,255,255,.14);
}
.tracker.is-solvent .tracker-emblem { color: #eafff1; }
.tracker-readout { min-width: 86px; }
.tracker-label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,.72); font-weight: 600;
}
.tracker-figure {
  font-family: var(--serif);
  font-size: 38px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tracker-figure .pct-sign { font-size: 22px; opacity: .8; margin-left: 1px; }
.tracker-meter-wrap { min-width: 0; }
.tracker-meter {
  position: relative;
  height: 18px;
  background: rgba(255,255,255,.16);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.16);
}
.tracker-fill {
  position: absolute; inset: 0 100% 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red-edge), #e7b3af);
  transition: width .5s cubic-bezier(.22,.61,.36,1), background .45s ease;
}
.tracker-fill.is-solvent {
  background: linear-gradient(90deg, var(--green-edge), #7ed6a3);
}
.tracker-goal-line {
  position: absolute; top: -3px; bottom: -3px; left: 100%;
  width: 0; border-left: 2px dashed rgba(255,255,255,.55);
}
.tracker-statusline {
  margin-top: 6px;
  font-size: 12.5px; font-weight: 600;
  color: rgba(255,255,255,.85);
}

/* ================================ Page ==================================== */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 18px calc(var(--bar-h) + env(safe-area-inset-bottom) + 28px);
}

/* ---- hero ---- */
.hero { text-align: center; padding: 14px 4px 8px; }
.hero-brand { display: inline-block; margin-bottom: 18px; }
.hero-brand img { width: 132px; height: auto; display: block; }
.hero-title {
  font-family: var(--serif);
  font-size: clamp(28px, 7vw, 42px);
  line-height: 1.08; margin: 0 0 8px;
  color: var(--navy); font-weight: 700;
}
.hero-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(16px, 4.4vw, 20px);
  color: var(--navy-3); margin: 0 0 18px;
}
.hero-intro {
  text-align: left;
  font-size: 15.5px; color: var(--ink-soft);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--brass);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 auto;
  box-shadow: var(--shadow);
}
.hero-intro strong { color: var(--navy); }
.hero-note {
  text-align: left;
  font-size: 13px; color: var(--ink-soft);
  margin: 12px 4px 0; padding-left: 2px;
}

/* ---- option groups ---- */
.options-root { margin-top: 26px; }
.group-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px;
  margin: 26px 2px 12px;
}
.group-head h2 {
  font-family: var(--serif);
  font-size: 19px; color: var(--navy); margin: 0; font-weight: 700;
  white-space: nowrap;
}
.group-head .group-tag {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  font-weight: 700; padding: 3px 9px; border-radius: 999px;
  white-space: nowrap;
}
.group-tag.tag-enhance { color: var(--red); background: var(--red-bg); }
.group-tag.tag-solvency { color: var(--green); background: var(--green-bg); }
.group-sub {
  margin: -4px 2px 14px; font-size: 13px; color: var(--ink-soft);
}

/* ---- "choose one" set: light grouping for either/or options ---- */
.opt-set {
  position: relative;
  border: 1px solid rgba(17,74,130,.30);
  border-left: 4px solid var(--navy-2);
  border-radius: 16px;
  background: rgba(17,74,130,.085);
  padding: 13px 13px 3px;
  margin: 18px 0;
  box-shadow: 0 2px 10px rgba(11,37,69,.08);
}
.opt-set-head {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 800; color: #fff;
  background: var(--navy-2);
  padding: 4px 12px 4px 10px; border-radius: 999px;
  margin: 0 0 11px 0;
  box-shadow: 0 1px 3px rgba(11,37,69,.2);
}
.opt-set-head::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  border: 2px solid #fff;
}
.opt-set .opt { box-shadow: none; }

/* ---- option card ---- */
.opt {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 13px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s ease, border-color .2s ease, background .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.opt-hit {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.opt-hit:active { transform: scale(.997); }
/* per-option citation link (separate from the toggle area so it navigates) */
.opt-ref {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 11px; padding-top: 9px;
  border-top: 1px dashed var(--rule);
  width: 100%;
  font-size: 12px; font-weight: 600; text-decoration: none;
  color: var(--navy-3);
}
.opt-ref svg { flex: 0 0 auto; opacity: .85; }
.opt-ref.ref-bill { color: var(--navy-2); }
.opt-ref.ref-source { color: var(--ink-soft); font-weight: 500; }
.opt-ref:hover span { text-decoration: underline; }
.opt.checked { border-color: var(--navy-3); }
.opt.checked.g-enhance { background: var(--red-bg); border-color: var(--red-edge); }
.opt.checked.g-solvency { background: var(--green-bg); border-color: var(--green-edge); }

/* policy-type tag chip (simple glyph + a word or two) */
.opt-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em;
  padding: 4px 10px 4px 8px; border-radius: 999px;
  border: 1px solid transparent;
  margin-bottom: 7px;
}
.opt-tag svg { width: 15px; height: 15px; flex: 0 0 auto; }
.opt-tag.tag-cost { color: var(--red);   background: var(--red-bg);   border-color: var(--red-edge); }
.opt-tag.tag-gain { color: var(--green); background: var(--green-bg); border-color: var(--green-edge); }

.opt-body { min-width: 0; }
.opt-label {
  display: block;
  font-size: 15.5px; font-weight: 600; color: var(--ink);
  line-height: 1.3;
}
.opt-detail {
  font-size: 12.5px; color: var(--ink-soft); margin-top: 3px;
  display: none; /* revealed on larger screens / expand */
}

.opt-right { display: flex; align-items: center; gap: 12px; }
.opt-pct {
  font-family: var(--serif);
  font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums;
  min-width: 54px; text-align: right;
}
.opt-pct.pos { color: var(--green); }
.opt-pct.neg { color: var(--red); }

/* custom checkbox */
.opt-check {
  appearance: none; -webkit-appearance: none;
  width: 26px; height: 26px; flex: 0 0 26px;
  border: 2px solid var(--navy-3); border-radius: 7px;
  background: #fff; cursor: pointer; position: relative;
  transition: background .15s ease, border-color .15s ease;
}
.opt-check:checked { background: var(--navy-2); border-color: var(--navy-2); }
.opt.checked.g-solvency .opt-check:checked { background: var(--green); border-color: var(--green); }
.opt.checked.g-enhance .opt-check:checked { background: var(--red); border-color: var(--red); }
.opt-check:checked::after {
  content: ""; position: absolute; left: 8px; top: 3px;
  width: 6px; height: 12px; border: solid #fff;
  border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.opt-check:focus-visible { outline: 3px solid var(--brass-soft); outline-offset: 2px; }

/* ---- alignment callout ---- */
.alignment {
  margin: 22px 0 4px;
  border: 1px solid rgba(17,74,130,.28);
  border-left: 4px solid var(--navy-2);
  background: rgba(17,74,130,.06);
  border-radius: 14px;
  padding: 15px 17px;
  box-shadow: var(--shadow);
}
.align-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--navy-2); margin-bottom: 8px;
}
.align-head svg { color: var(--green); flex: 0 0 auto; }
.align-lead { margin: 0 0 6px; font-size: 14.5px; font-weight: 600; color: var(--ink); }
.align-list { margin: 0; padding: 0; list-style: none; }
.align-list li { font-size: 14px; line-height: 1.5; color: var(--ink); margin: 7px 0; }
.align-list a { color: var(--navy-2); font-weight: 700; text-decoration: none; }
.align-list a:hover { text-decoration: underline; }
.align-sub { color: var(--ink-soft); }

/* footer */
.page-foot { margin-top: 34px; border-top: 1px solid var(--rule); padding-top: 16px; }
.page-foot .src { font-size: 12.5px; color: var(--navy-3); font-weight: 600; margin: 0 0 12px; }
.page-foot .src a { color: var(--navy-3); }
.report-cta { margin: 0 0 14px; }
.report-cta a {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; text-decoration: none;
  color: #fff; background: linear-gradient(180deg, var(--navy-2), var(--navy));
  padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow);
}
.report-cta a:hover { filter: brightness(1.06); }
.report-cta svg { flex: 0 0 auto; }
.page-foot .disclaimer { font-size: 11.5px; color: var(--ink-soft); margin: 0; line-height: 1.55; }

/* ============================ Action bar ================================== */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,253,248,.92);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-top: 1px solid var(--rule);
}
/* phones: descriptive Save on its own row; Reset (icon) + the two share
   options on the row below */
#btn-save  { order: 1; flex: 1 1 100%; }
#btn-reset { order: 2; flex: 0 0 auto; }
#btn-share { order: 3; flex: 1 1 auto; }
#btn-qr    { order: 4; flex: 1 1 auto; }
#btn-reset .act-label { display: none; }   /* icon-only on phones to save room */
.act {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 46px; border-radius: 12px; font-size: 14.5px; font-weight: 600;
  font-family: var(--sans); cursor: pointer; border: 1px solid var(--rule);
  background: var(--paper); color: var(--navy);
  transition: transform .1s ease, box-shadow .2s ease, background .2s ease;
}
.act:active { transform: translateY(1px); }
.act-ghost { flex: 0 0 auto; padding: 0 16px; }
.act-primary {
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  color: #fff; border-color: var(--navy);
  box-shadow: 0 6px 16px rgba(11,37,69,.25);
}
.act svg { flex: 0 0 auto; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 18px);
  transform: translate(-50%, 16px); z-index: 60;
  background: var(--navy); color: #fff;
  padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(11,37,69,.35);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================ QR modal ==================================== */
.qr-modal {
  position: fixed; inset: 0; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(11,37,69,.55);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.qr-modal[hidden] { display: none; }
.qr-card {
  position: relative;
  width: 100%; max-width: 340px; text-align: center;
  background: #fff; border-radius: 20px;
  padding: 26px 24px 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
}
.qr-close {
  position: absolute; top: 6px; right: 12px;
  border: none; background: none; font-size: 30px; line-height: 1;
  color: var(--ink-soft); cursor: pointer; padding: 4px 8px;
}
.qr-title { font-family: var(--serif); font-size: 20px; color: var(--navy); margin: 2px 0 16px; font-weight: 700; }
.qr-holder { width: 240px; max-width: 78%; margin: 0 auto 14px; }
.qr-holder svg { display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 8px; }
.qr-url { font-size: 12px; color: var(--navy-3); word-break: break-all; margin: 0 0 10px; }
.qr-note { font-size: 12.5px; color: var(--ink-soft); margin: 0; }

/* ============================ Responsive ================================== */
@media (min-width: 620px) {
  .opt-detail { display: block; }
  :root { --bar-h: 66px; }
  /* roomy screens: single row again */
  .actionbar { flex-wrap: nowrap; }
  #btn-save  { order: 0; flex: 0 0 auto; }
  #btn-reset { order: 0; flex: 0 0 auto; }
  #btn-share { order: 0; flex: 1; }
  #btn-qr    { order: 0; flex: 0 0 auto; }
  #btn-reset .act-label { display: inline; }
}
@media (min-width: 900px) {
  .page { max-width: 820px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ============================ PIN gate ==================================== */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
}
.gate.show { display: flex; }
body.locked { overflow: hidden; }
.gate-card {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--paper); border-radius: 20px;
  padding: 30px 26px 26px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.gate-card img { width: 116px; height: auto; margin: 0 auto 18px; display: block; }
.gate-title { font-family: var(--serif); font-size: 22px; color: var(--navy); margin: 0 0 4px; font-weight: 700; }
.gate-sub { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 20px; }
.gate-input {
  width: 100%; text-align: center; font-size: 30px; font-weight: 700;
  letter-spacing: .5em; font-variant-numeric: tabular-nums;
  padding: 14px 10px 14px 18px; border: 2px solid var(--rule); border-radius: 12px;
  color: var(--navy); background: var(--ivory); outline: none;
  -webkit-appearance: none; appearance: none;
}
.gate-input:focus { border-color: var(--navy-2); background: #fff; }
.gate-input.err { border-color: var(--red); animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
.gate-btn {
  width: 100%; margin-top: 14px; height: 50px; border: none; border-radius: 12px;
  font-size: 16px; font-weight: 700; color: #fff; cursor: pointer;
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  font-family: var(--sans);
}
.gate-note { margin-top: 16px; font-size: 11.5px; color: var(--ink-soft); }
