/* Sticking Point app. Layout: a dark brand bar with tabs, then one readable column of report sections;
   diagnosis cards lead, tables and charts follow. Follows the system light/dark setting. */
:root {
  --bg: #F4F5F2;
  --surface: #FFFFFF;
  --fg: #15191D;
  --muted: #56606A;
  --line: #DCE0DC;
  --chip: #E9ECE8;
  --accent: #C8232A;
  --accent-soft: rgba(211, 38, 45, 0.10);
  --good-c: #1E7543;
  --good-soft: rgba(46, 155, 87, 0.13);
  --chart-line: #15191D;
  --chart-grid: #E3E6E2;
  --chart-best: #8C959D;
  --band: rgba(211, 38, 45, 0.08);
  --heat-1: #E6E9E5;
  --heat-2: #C7DCCD;
  --heat-3: #F3CFD0;
  --mark-bg: var(--iron);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1012; --surface: #16191C; --fg: #E9ECE9; --muted: #A2A9AF; --line: #2A2F34; --chip: #23272B;
    --accent: #FF5A5F; --accent-soft: rgba(255, 90, 95, 0.14); --good-c: #5CC98A; --good-soft: rgba(92, 201, 138, 0.14);
    --chart-line: #E9ECE9; --chart-grid: #262B30; --chart-best: #7D868E; --band: rgba(255, 90, 95, 0.10);
    --heat-1: #22262A; --heat-2: #1F4A30; --heat-3: #5A2427;
    color-scheme: dark;
  }
}

body { background: var(--bg); color: var(--fg); font-size: 16px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--iron); color: var(--chalk); padding-top: env(safe-area-inset-top, 0px); }
.topbar-inner { max-width: 1840px; margin: 0 auto; padding: 12px max(clamp(20px, 3.5vw, 96px), env(safe-area-inset-right, 0px)) 8px max(clamp(20px, 3.5vw, 96px), env(safe-area-inset-left, 0px)); display: flex; align-items: center; gap: 16px; }
.app-logo { font-size: 18px; color: var(--chalk); margin-right: auto; }
.unit-toggle { display: inline-flex; border: 1px solid var(--iron-line); border-radius: 4px; overflow: hidden; }
.unit-toggle button { background: transparent; border: 0; color: var(--on-iron-soft); font: 500 13px/1 var(--mono); padding: 8px 11px; cursor: pointer; }
.unit-toggle button[aria-pressed="true"] { background: var(--chalk); color: var(--iron); }
.btn-add { font-weight: 600; font-size: 14px; text-decoration: none; background: var(--red); color: #FFFFFF; padding: 9px 14px; border-radius: 4px; }
.btn-add:hover { background: var(--red-ink); }
.tabs { max-width: 1840px; margin: 0 auto; padding: 0 max(clamp(20px, 3.5vw, 96px), env(safe-area-inset-right, 0px)) 0 max(clamp(20px, 3.5vw, 96px), env(safe-area-inset-left, 0px)); display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 10px 12px 12px; font-size: 15px; text-decoration: none; color: var(--on-iron-soft); border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--chalk); }
.tabs a[aria-current="page"] { color: var(--chalk); border-bottom-color: var(--red); }
@media (max-width: 560px) { .btn-add { display: none; } }

.sample-banner { background: var(--accent-soft); border-bottom: 1px solid var(--line); }
.sample-banner { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 10px var(--gutter); font-size: 15px; }
.sample-banner[hidden] { display: none; }
.link-strong { color: var(--accent); font-weight: 600; }

/* view */
.view { max-width: 1840px; margin: 0 auto; padding: 36px max(clamp(20px, 3.5vw, 96px), env(safe-area-inset-right, 0px)) calc(80px + env(safe-area-inset-bottom, 0px)) max(clamp(20px, 3.5vw, 96px), env(safe-area-inset-left, 0px)); outline: none; display: grid; gap: 28px; }
.view > * { min-width: 0; }
.loading { color: var(--muted); }
.report-head h1 { font-family: var(--display); font-stretch: 112%; font-weight: 750; font-size: clamp(30px, 4.4vw, 46px); line-height: 1.04; letter-spacing: -0.02em; }
.report-head .sub { margin-top: 10px; color: var(--muted); max-width: 70ch; }
.block-sec { display: grid; gap: 16px; }
.block-sec h2, .two-col h2 { font-family: var(--display); font-stretch: 108%; font-weight: 700; font-size: 22px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 3vw, 64px); }
.two-col > div { display: grid; gap: 10px; align-content: start; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.muted { color: var(--muted); }
.note { font-size: 14px; color: var(--muted); }
.calm { font-size: 18px; max-width: 60ch; }
.back a { color: var(--muted); font-size: 15px; }
.back a::before { content: "← "; }
.plain-list { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 4px; border: 1.5px solid transparent; font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; }
.btn-red { background: var(--red); color: #FFFFFF; }
.btn-red:hover { background: var(--red-ink); }
.btn-line { background: transparent; color: var(--fg); border-color: var(--line); }
.btn-line:hover { border-color: var(--fg); }
.btn:disabled { opacity: 0.6; cursor: progress; }

/* pills */
.pill { display: inline-block; font-family: var(--mono); font-size: 12px; line-height: 1.5; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill-red { background: var(--accent-soft); color: var(--accent); }
.pill-good { background: var(--good-soft); color: var(--good-c); }
.pill-quiet { background: var(--chip); color: var(--muted); }
.pill-ink { background: var(--fg); color: var(--bg); }

/* empty */
.empty { display: grid; gap: 14px; padding: 56px 0; max-width: 60ch; }
.empty h1 { font-family: var(--display); font-stretch: 112%; font-weight: 750; font-size: clamp(28px, 4vw, 40px); line-height: 1.05; }
.empty p { color: var(--muted); }
.empty-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* diagnosis cards */
.dx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: clamp(18px, 1.4vw, 28px); }
.dx { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.dx-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.dx-head h3 { font-family: var(--display); font-weight: 700; font-size: 21px; }
.dx-head h3 a { color: inherit; text-decoration: none; }
.dx-head h3 a:hover { text-decoration: underline; }
.dx-why, .dx-try { font-size: 15.5px; }
.dx-conf { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.dx-also { font-size: 14.5px; color: var(--muted); display: grid; gap: 4px; }
.dx-also ul { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; }
.dx-table summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.dx-table table { margin-top: 10px; font-size: 14px; }

/* charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.c-grid { stroke: var(--chart-grid); stroke-width: 1; }
.c-tick { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.c-band { fill: var(--band); }
.c-best { fill: none; stroke: var(--chart-best); stroke-width: 1.25; stroke-dasharray: 4 3; }
.c-line { fill: none; stroke: var(--chart-line); stroke-width: 1.6; stroke-linejoin: round; opacity: 0.55; }
.c-dot { fill: var(--chart-line); }
.c-dot.pr { fill: var(--chart-line); stroke: var(--surface); stroke-width: 1.5; }
.c-dot.light { fill: none; stroke: var(--chart-best); stroke-width: 1.2; }
.c-stuck { fill: var(--red); stroke: var(--surface); stroke-width: 2; }
.spark { width: 120px; height: 32px; }
.spark path { fill: none; stroke: var(--fg); stroke-width: 1.5; stroke-linejoin: round; }
.spark circle { fill: var(--accent); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-block; vertical-align: middle; margin-right: -8px; }
.lg-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--chart-line); }
.lg-pr { width: 9px; height: 9px; border-radius: 50%; background: var(--chart-line); box-shadow: 0 0 0 2px var(--surface) inset; }
.lg-step { width: 18px; border-top: 1.5px dashed var(--chart-best); }
.lg-band { width: 14px; height: 10px; background: var(--band); border: 1px solid var(--accent-soft); }

/* lift cards */
.lift-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: clamp(14px, 1.2vw, 24px); }
.lift-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; text-decoration: none; color: inherit; transition: border-color .15s ease; }
.lift-card:hover { border-color: var(--fg); }
.lift-name { font-weight: 600; }
.lift-val { grid-column: 1 / -1; font-size: 26px; font-weight: 500; }
.lift-sub { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.lift-card .spark { grid-column: 1 / -1; width: 100%; height: 36px; }

/* panels and stats */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-width: 0; }
.panel-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; font-family: var(--body); }
.stats { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stats dt { font-size: 13px; color: var(--muted); }
.stats dd { margin: 4px 0 0; font-size: 22px; font-weight: 500; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th { font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
tbody th { font-weight: 600; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
td a { color: inherit; font-weight: 600; }
.raw { display: block; font-size: 12.5px; color: var(--muted); }
.lifts-table td .spark { width: 110px; }
.dx-table table th, .dx-table table td { padding: 6px 10px; }

/* blocks */
.timeline { position: relative; height: 44px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tl-seg { position: absolute; top: 6px; bottom: 6px; background: var(--chip); border-left: 3px solid var(--accent); border-radius: 2px 4px 4px 2px; color: var(--fg); overflow: hidden; }
.tl-seg.alt { border-left-color: var(--plate-blue); }
.tl-seg i { font-style: normal; font-size: 12.5px; font-weight: 600; padding: 0 8px; line-height: 32px; white-space: nowrap; display: block; overflow: hidden; text-overflow: ellipsis; }
.blocks-table th[scope="row"] { white-space: nowrap; }
.rate { display: grid; grid-template-columns: minmax(60px, 1fr) auto; gap: 8px; align-items: center; min-width: 150px; }
.rate-bar { height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; }
.rate-bar i { display: block; height: 100%; background: var(--muted); border-radius: 4px; }
.rate.best .rate-bar i { background: var(--red); }
.rate.best .num { color: var(--accent); font-weight: 600; }
.rate.neg .rate-bar i { background: var(--chart-grid); }
.rate .num { font-size: 13.5px; white-space: nowrap; }

/* volume */
.vol { display: grid; gap: 10px; position: relative; }
.vol-row, .vol-axis { display: grid; grid-template-columns: 110px minmax(0, 1fr) 52px; align-items: center; gap: 0 12px; font-size: 15px; }
.vol-track { position: relative; height: 16px; background: linear-gradient(90deg, transparent var(--band-l), var(--good-soft) var(--band-l), var(--good-soft) calc(var(--band-l) + var(--band-w)), transparent calc(var(--band-l) + var(--band-w))); border-radius: 2px; }
.vol-track i { position: absolute; left: 0; top: 2px; bottom: 2px; background: var(--fg); border-radius: 0 3px 3px 0; }
.vol-row.low .vol-track i { background: var(--red); }
.vol-row.high .vol-track i { background: var(--plate-blue); }
.vol-row b { text-align: right; font-weight: 500; }
.vol-scale { position: relative; height: 18px; font: 12px/1 var(--mono); color: var(--muted); }
.vol-scale span { position: absolute; top: 4px; transform: translateX(-50%); }
.vol-scale span:first-child { transform: none; }
.heat td { font-size: 13.5px; min-width: 56px; }
.heat .h0 { color: var(--muted); }
.heat .h1 { background: var(--heat-1); }
.heat .h2 { background: var(--heat-2); }
.heat .h3 { background: var(--heat-3); }
.heat thead th { font-size: 12px; }
@media (max-width: 560px) { .vol-row, .vol-axis { grid-template-columns: 84px minmax(0, 1fr) 40px; font-size: 14px; } }

/* recap */
.year-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.year-pick button { font: 500 14px/1 var(--mono); padding: 8px 12px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; }
.year-pick button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.recap-wrap { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
.recap-side { display: grid; gap: 10px; max-width: 320px; }
.wrapped { width: 320px; max-width: 100%; aspect-ratio: 9 / 16; border-radius: 18px; background: radial-gradient(90% 50% at 85% 10%, rgba(211, 38, 45, 0.35), rgba(211, 38, 45, 0) 70%), var(--iron); color: var(--chalk); padding: 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6); --mark-bg: var(--iron); }
.stripe { display: grid; grid-template-columns: 5fr 4fr 3fr 2fr; height: 6px; border-radius: 3px; overflow: hidden; flex: none; }
.stripe i:nth-child(1) { background: var(--red); }
.stripe i:nth-child(2) { background: var(--plate-blue); }
.stripe i:nth-child(3) { background: var(--plate-yellow); }
.stripe i:nth-child(4) { background: var(--plate-green); }
.wr-title { font-family: var(--display); font-stretch: 125%; font-weight: 800; font-size: 29px; line-height: 1; letter-spacing: -0.02em; }
.wr-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wr-stats b { display: block; font-weight: 500; font-size: 22px; }
.wr-stats span { font-size: 12.5px; color: var(--on-iron-soft); }
.wr-block { border-top: 1px solid var(--iron-line); padding-top: 10px; display: grid; gap: 2px; }
.wr-block .k { font-size: 12.5px; color: var(--on-iron-soft); }
.wr-block .v { font-family: var(--display); font-weight: 700; font-size: 15.5px; line-height: 1.32; }
.wr-block em { font-style: normal; color: var(--plate-yellow); }
.wr-block strong { color: var(--red-bright); }
.wr-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--on-iron-soft); }
.wr-foot svg { width: 18px; height: 18px; color: var(--chalk); }

/* import */
.drop { position: relative; display: grid; gap: 6px; place-items: center; text-align: center; padding: 48px 20px; border: 2px dashed var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 3px; }
.drop-title { font-family: var(--display); font-weight: 700; font-size: 20px; }
.drop-sub { color: var(--muted); font-size: 15px; max-width: 52ch; }
.units { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.units legend { padding: 0; margin-bottom: 8px; font-size: 15px; width: 100%; }
.units label { display: inline-flex; gap: 6px; align-items: center; font-size: 15px; }
.error { color: var(--accent); font-weight: 500; }
.danger { display: grid; gap: 10px; justify-items: start; }
.danger-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; background: var(--iron); color: var(--chalk); padding: 12px 16px; border-radius: 8px; font-size: 14.5px; max-width: min(92vw, 560px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); transition: opacity .2s ease, transform .2s ease; pointer-events: none; z-index: 40; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 24px; }

/* wide screens: the lift detail puts its stats beside the chart */
@media (min-width: 1500px) {
  .report-head .sub { max-width: 90ch; }
  .recap-wrap { gap: 56px; }
}

.app-foot { max-width: 1840px; margin: 0 auto; padding: 20px max(clamp(20px, 3.5vw, 96px), env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(clamp(20px, 3.5vw, 96px), env(safe-area-inset-left, 0px)); display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); }
.app-foot nav { display: flex; gap: 18px; }
.app-foot a { color: var(--muted); }
.app-foot a:hover { color: var(--fg); }
