:root {
  color-scheme: dark;
  --bg: #0e0e0e;
  --surface: #161616;
  --raised: #1d1d1d;
  --line: #2b2b2b;
  --ink: #e8e8e8;
  --muted: #9a9a9a;
  --gold: #d8af68;
  --gold-hi: #e6c27f;
  --gold-soft: rgba(216, 175, 104, 0.14);
  --alert: #e39a7b;
  --ok: #9fc4a0;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 90px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-text-size-adjust: 100%;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 30; background: rgba(14, 14, 14, 0.94);
}
a { color: var(--gold); }
h2 { font: 400 1.5rem/1.2 var(--serif); margin: 0 0 14px; letter-spacing: -0.01em; }
p { margin: 0 0 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: min(720px, 100% - 28px); margin-inline: auto; }

/* Site header and footer: mirrors davidlask.com */
.shell { width: min(1180px, 100% - 40px); margin-inline: auto; }
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; color: #fff;
  background: rgba(14, 14, 14, 0.94); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12); font-family: Arial, Helvetica, sans-serif;
}
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 32px; min-height: 74px; }
.site-header .brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .02em; text-decoration: none; color: #fff; font-size: 17px; }
.brand-mark { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--gold); object-fit: cover; background: #000; }
.site-header nav { display: flex; align-items: center; gap: 30px; }
.site-header nav a { color: #e8e8e8; font-size: 15px; font-weight: 700; text-decoration: none; }
.site-header nav a:hover { color: var(--gold); }
.site-footer { background: #0a0a0a; color: #fff; padding-block: 52px 28px; margin-top: 24px; font-family: Arial, Helvetica, sans-serif; font-size: 17px; line-height: 1.65; }
.site-footer p { margin: 0; }
.footer-inner { display: flex; justify-content: space-between; gap: 32px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 26px; }
.footer-links a { color: #b6b6b6; text-decoration: none; }
.footer-links a:hover { color: var(--gold); }
.legal { color: #aaa092; border-top: 1px solid rgba(255, 255, 255, 0.12); margin-top: 36px; padding-top: 20px; font-size: 12px; }
.legal p { margin: 3px 0; }
@media (max-width: 560px) {
  .shell { width: min(100% - 28px, 1180px); }
  .header-inner { align-items: flex-start; min-height: auto; padding-block: 14px; }
  .site-header .brand > span:last-child { display: none; }
  .site-header nav { gap: 16px; padding-top: 8px; }
  .site-header nav a { font-size: 14px; }
  .footer-inner, .footer-links { flex-direction: column; }
  .footer-links { gap: 10px; }
}

/* App title bar (scrolls with the page, below the site header) */
.app-bar { border-bottom: 1px solid var(--line); }
.app-bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.app-name { display: inline-flex; align-items: center; gap: 10px; font: 400 1.35rem var(--serif); color: var(--ink); text-decoration: none; }
.app-name img { border-radius: 7px; }
.update-bar { background: var(--raised); border-bottom: 1px solid var(--gold); }
.update-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 50px; }

/* Support */
.support { padding: 8px 0 12px; }
.support p { color: var(--muted); max-width: 60ch; }

main { padding: 18px 0 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.panel-head h2 { margin: 0; }

/* Segmented controls */
.metric-switch, .range { display: flex; flex-wrap: wrap; gap: 6px; }
.metric-switch { margin-bottom: 20px; }
.seg {
  font: 600 0.9rem var(--sans); color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; min-height: 36px; cursor: pointer;
}
.seg.small { padding: 4px 11px; min-height: 30px; font-size: 0.82rem; }
.seg[aria-pressed="true"] { color: #171717; background: var(--gold); border-color: var(--gold); }

/* Readout: the big trend number */
.readout { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.readout-label { color: var(--muted); margin: 0; font-size: 0.92rem; }
.readout-value { font: 400 clamp(3.2rem, 14vw, 4.6rem)/1 var(--serif); letter-spacing: -0.03em; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.readout-unit { font-size: 0.36em; color: var(--muted); letter-spacing: 0; margin-left: 0.2em; }
.readout-sub { color: var(--muted); font-size: 0.9rem; margin: 0; }
.changes { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0 0 4px; font-size: 0.95rem; }
.changes dt { color: var(--muted); }
.changes dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.changes dd.muted { color: var(--muted); font-weight: 400; }
.status { margin: 18px 0 14px; padding: 12px 14px; border-left: 3px solid var(--gold); background: var(--raised); border-radius: 0 8px 8px 0; font-size: 0.96rem; }
.status[data-kind="high"], .status[data-kind="low"] { border-left-color: var(--alert); }
.status[data-kind="early"] { border-left-color: var(--line); color: var(--muted); }

/* Chart */
.chart-box { position: relative; }
#chart { display: block; width: 100%; height: auto; }
#chart.dim { opacity: 0.25; }
.chart-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); margin: 0; }
.chart-msg[hidden] { display: none; }
#chart .grid { stroke: var(--line); stroke-width: 1; }
#chart .axis { fill: var(--muted); font: 15px var(--sans); }
#chart .band { fill: var(--gold-soft); stroke: none; }
#chart .dot { fill: var(--bg); stroke: var(--muted); stroke-width: 1.4; }
#chart .dot.tagged { stroke: var(--alert); }
#chart .trendline { fill: none; stroke: var(--gold); stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
#chart .endpoint { fill: var(--gold); }
.chart-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.legend { color: var(--muted); font-size: 0.8rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.key { display: inline-block; margin-left: 6px; }
.key:first-child { margin-left: 0; }
.key-dot { width: 9px; height: 9px; border: 1.5px solid var(--muted); border-radius: 50%; }
.key-line { width: 16px; height: 3px; background: var(--gold); border-radius: 2px; }
.key-band { width: 16px; height: 10px; background: var(--gold-soft); }

.empty { padding: 8px 0 4px; color: var(--muted); }
.empty-title { font: 400 1.6rem/1.25 var(--serif); color: var(--ink); }

/* Form */
.hint { color: var(--muted); font-size: 0.88rem; }
.voice-text { font: italic 1.05rem var(--serif); color: var(--gold); margin: 6px 0 10px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0 16px; }
.field { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.field.inline { display: flex; align-items: center; gap: 10px; }
.field small { font-weight: 400; color: var(--muted); }
.field-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 8px; min-height: 30px; }
.unit-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.seg.tiny { border: 0; min-height: 26px; padding: 2px 10px; font-size: 0.8rem; }
.date-field { max-width: 220px; margin-top: 8px; }
input, select {
  font: 500 1.15rem var(--sans); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; min-height: 50px; width: 100%;
  font-variant-numeric: tabular-nums;
}
select { font-size: 1rem; width: auto; min-height: 44px; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
input.filled { border-color: var(--gold); background: #1a160e; }
input.bad { border-color: var(--alert); }
#f-note { font-size: 1rem; }
.tags { border: 0; padding: 0; margin: 0 0 16px; }
.tags legend { color: var(--muted); font-size: 0.9rem; padding: 0; margin-bottom: 8px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: 500 0.9rem var(--sans); color: var(--ink); background: transparent; cursor: pointer;
  border: 1px dashed var(--line); border-radius: 999px; padding: 7px 13px; min-height: 38px;
}
.chip[aria-pressed="true"] { border: 1px solid var(--alert); color: var(--alert); background: rgba(227, 154, 123, 0.1); }
.form-msg { min-height: 1.4em; color: var(--alert); font-size: 0.92rem; margin: 10px 0; }
#data-msg { color: var(--ok); }
.form-actions, .data-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Buttons */
.btn {
  font: 700 0.98rem var(--sans); color: var(--gold); background: transparent; cursor: pointer;
  border: 1px solid var(--gold); border-radius: 9px; padding: 11px 18px; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn:hover { background: var(--gold-soft); }
.btn.primary { background: var(--gold); color: #171717; }
.btn.primary:hover { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn.ghost { border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--muted); background: transparent; }
.btn.small { min-height: 38px; padding: 6px 13px; font-size: 0.88rem; }
.btn.tiny { min-height: 36px; padding: 4px 11px; font-size: 0.82rem; font-weight: 600; }
.btn.armed, .btn.danger { color: var(--alert); border-color: var(--alert); }
.btn:focus-visible, .seg:focus-visible, .chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.voice { border-radius: 999px; padding: 8px 16px; min-height: 44px; }
.btn.voice .ico { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.btn.voice.live { background: var(--gold); color: #171717; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; padding: 0; }
.file-btn:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }

/* History */
.history { list-style: none; margin: 0 0 12px; padding: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row-main { display: grid; gap: 2px; min-width: 0; }
.row-date { font-weight: 600; }
.row-vals { color: var(--ink); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.row-extra { color: var(--alert); font-size: 0.84rem; overflow-wrap: anywhere; }
.row-acts { display: flex; gap: 6px; flex-shrink: 0; }

.settings { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }


/* Toast + dialog */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); transform: translate(-50%, 20px);
  background: var(--raised); color: var(--ink); border: 1px solid var(--gold); border-radius: 10px;
  padding: 11px 16px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 40; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px; width: min(460px, 100% - 32px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); }

@media (max-width: 420px) {
  .panel { padding: 16px; }
  .fields { gap: 10px; }
  .changes { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
  html { scroll-behavior: auto; }
}
@media (min-width: 640px) {
  #chart .axis { font-size: 11px; }
}

/* Tag impact */
.impact { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.impact-h { font-size: 1.2rem; margin-bottom: 10px; }
.impact-list { list-style: none; margin: 0 0 8px; padding: 0; }
.impact-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "tag n" "val val"; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.impact-list li:first-child { border-top: 0; }
.impact-tag { grid-area: tag; font-weight: 600; }
.impact-val { grid-area: val; color: var(--gold); font-variant-numeric: tabular-nums; }
.impact-val.muted { color: var(--muted); }
.impact-n { grid-area: n; color: var(--muted); font-size: 0.85rem; }

/* Weekly table */
.table-wrap { overflow-x: auto; }
.weekly { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.weekly th:last-child, .weekly td:last-child { padding-right: 0; }
.weekly th { text-align: left; color: var(--muted); font-weight: 600; font-size: 0.82rem; padding: 0 8px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.weekly abbr { text-decoration: none; }
.weekly td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.weekly .num { text-align: right; }
.weekly .muted { color: var(--muted); }

.hint code { font-size: 0.9em; color: var(--ink); }

/* Since you started */
.since { display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 6px 0 0; }
.since dt, .since dd { padding: 11px 0; border-top: 1px solid var(--line); }
.since dt:first-of-type, .since dt:first-of-type + dd { border-top: 0; }
.since dt { color: var(--muted); }
.since dd { margin: 0; text-align: right; display: grid; gap: 1px; }
.since-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.since-sub { color: var(--muted); font-size: 0.8rem; }
.since-h3 { font: 400 1.2rem/1.2 var(--serif); margin: 22px 0 4px; }

/* Tape group */
.tape { border: 0; padding: 0; margin: 0 0 16px; }
.tape legend { color: var(--ink); font-weight: 600; font-size: 0.95rem; padding: 0; margin-bottom: 4px; }
.tape legend small { color: var(--muted); font-weight: 400; }
.tape .fields { margin-top: 8px; margin-bottom: 8px; }

/* Scale-change markers */
#chart .marker { stroke: var(--alert); stroke-width: 1.2; stroke-dasharray: 4 4; }
#chart .marker-label { fill: var(--alert); font: 11px var(--sans); }
.markers { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.marker-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 10px; align-items: end; }
@media (max-width: 520px) { .marker-form { grid-template-columns: 1fr; } .marker-form .btn { justify-self: start; } }

/* Scale change checkbox in the log form */
.scale-change { margin: 0 0 6px; display: grid; gap: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; color: var(--ink); font-size: 0.92rem; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 1px 0 0; padding: 0; accent-color: var(--gold); flex-shrink: 0; }
.check small { color: var(--muted); }
.row-marker { color: var(--alert); font-size: 0.8rem; font-weight: 600; }

#chart .marker.soft { stroke: var(--muted); opacity: 0.8; }
#chart .marker-label.soft { fill: var(--muted); }
.key-marker { width: 0; height: 12px; border-left: 2px dashed var(--alert); }
.marker-note { margin: 8px 0 0; font-size: 0.82rem; }
.key[hidden], #legend-marker-text[hidden] { display: none; }
.key-marker.soft { border-left-color: var(--muted); }

/* Chart reading details */
#chart { touch-action: pan-y; cursor: crosshair; }
#chart:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 4px; }
#chart .guide { stroke: var(--muted); stroke-width: 1; }
#chart .ring { fill: none; stroke: var(--gold); stroke-width: 2.5; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; display: grid; gap: 2px; max-width: 230px;
  background: var(--raised); border: 1px solid var(--gold); border-radius: 9px; padding: 8px 11px;
  font-size: 0.84rem; line-height: 1.35; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.chart-tip[hidden] { display: none; }
.chart-tip strong { font-weight: 700; }
.chart-tip .muted { color: var(--muted); }
.chart-tip .tip-tags, .chart-tip .tip-marker { color: var(--alert); }
.chart-help { margin: 8px 0 0; font-size: 0.8rem; }
