/* ---------- charts ---------- */
.chart-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 1000px) {
  .chart-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.small-multiples {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.chart {
  margin: 0;
  position: relative;
}
.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 6px;
}
.chart-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.chart-title h3 {
  margin: 0;
  font-size: 0.98rem;
}
.chart-unit {
  font-size: 0.78rem;
  color: var(--muted);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  width: 100%;
  font-size: 0.78rem;
  color: var(--text-2);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-key {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}
.legend-band {
  width: 14px;
  height: 10px;
  background: var(--band);
  border-top: 1px solid var(--band-edge);
  border-bottom: 1px solid var(--band-edge);
}
.legend-marker {
  width: 0;
  height: 12px;
  border-left: 1.5px dashed var(--series-7);
}
.legend-band-lab,
.legend-band-personal {
  background: none;
  border: 1.25px dashed var(--series-7);
}
.legend-band-personal {
  border-color: var(--series-1);
}
.legend-threshold {
  width: 14px;
  height: 0;
  border-top: 2px dashed var(--threshold);
}
.chart-plot {
  position: relative;
  width: 100%;
  touch-action: pan-y;
}
.chart-svg {
  display: block;
  overflow: visible;
}
.chart-svg:focus-visible {
  outline: 2px solid var(--focus);
  border-radius: 6px;
}
.chart-svg .grid {
  stroke: var(--grid);
  stroke-width: 1;
}
.chart-svg .axis {
  stroke: var(--axis);
  stroke-width: 1;
}
.chart-svg .tick {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.chart-svg .band {
  fill: var(--band);
}
.chart-svg .band-lab,
.chart-svg .band-personal {
  fill: none;
  stroke: var(--series-7);
  stroke-width: 1.25;
  stroke-dasharray: 4 3;
}
.chart-svg .band-personal {
  stroke: var(--series-1);
}
.chart-svg .regimen-span {
  fill: var(--accent-soft);
}
.chart-svg .regimen-span.alt {
  fill: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
}
.chart-svg .regimen-label {
  fill: var(--text-2);
  font-size: 10.5px;
  font-weight: 600;
  font-family: var(--font);
}
.chart-note {
  margin: 8px 0 0;
  font-size: 0.86rem;
  color: var(--text-2);
}
/* Chart summary: a row of small stat tiles instead of a sentence. */
.chart-summary {
  margin-top: 12px;
}
.chart-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  margin: 0;
}
.chart-stat {
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}
.chart-stat dt {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}
.chart-stat dd {
  margin: 0;
}
.chart-stat-value {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin-top: 2px !important;
  font-size: 1.12rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.chart-stat-sub {
  margin-top: 1px !important;
  font-size: 0.76rem;
  color: var(--muted);
}
.chart-delta {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.chart-svg .threshold {
  stroke: var(--threshold);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}
/* Breaks from HRT: a light shade behind the data. */
.chart-svg .break-span {
  fill: var(--muted);
  opacity: 0.12;
}
.legend-break {
  background: var(--muted);
  border: 0;
  opacity: 0.35;
}
.chart-svg .marker {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.7;
}
.chart-svg .marker-regimen {
  stroke: var(--series-7);
  opacity: 0.8;
}
.chart-svg .marker-label {
  fill: var(--muted);
  font-size: 10px;
  font-family: var(--font);
}
.chart-svg .line {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-svg .line-edge {
  fill: none;
  stroke-width: 5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-svg .dot {
  stroke: var(--surface-1);
  stroke-width: 2;
}
.chart-svg .dot-qualified {
  stroke-width: 2;
}
.chart-svg .focus-ring {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.5;
}
.chart-svg .hit {
  fill: transparent;
}
.chart-mini .chart-svg .tick {
  font-size: 10px;
}
.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 0.9rem;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
}
.chart-tip {
  position: absolute;
  z-index: 5;
  min-width: 140px;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 0.8rem;
  pointer-events: none;
}
.tip-date {
  color: var(--muted);
  margin-bottom: 2px;
}
.tip-row strong {
  font-size: 0.95rem;
}
.tip-key {
  display: inline-block;
  width: 12px;
  height: 3px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}
.tip-name {
  margin-left: 6px;
  color: var(--text-2);
}
.tip-detail {
  color: var(--text-2);
}
.chart-table {
  position: relative;
  margin-top: 10px;
  overflow-x: auto;
}
.chart-table-edit {
  width: 1%;
  padding-block: 2px;
  text-align: right;
}

/* ---------- tools ---------- */
.tool-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
/* Masonry grid: masonry() in ui.js sets each card's row span from its height
   (rows are 4px; the 12px below each card is part of its span). */
.masonry {
  display: grid;
  grid-auto-rows: 4px;
  column-gap: 12px;
}
.masonry > * {
  align-self: start;
}
.tool-grid .card > * + * {
  margin-top: 10px;
}
.result {
  font-size: 1rem;
  font-weight: 600;
}
.result .big-num {
  font-size: 1.8rem;
}
.formula {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--surface-2);
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre;
}
.conv-table .table td {
  padding: 4px 6px;
}

/* ---------- settings ---------- */
.settings-section > * + * {
  margin-top: 12px;
}
.section-danger {
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.toggle-list {
  display: grid;
  gap: 2px;
}
@media (min-width: 760px) {
  .toggle-list {
    grid-template-columns: 1fr 1fr;
    column-gap: 20px;
  }
}
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
}
.toggle-row label {
  display: flex;
  /* Top-aligned so the box sits beside the first line when the label wraps. */
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.toggle-row label input[type='checkbox'] {
  margin-top: 3px; /* centers the 18px box on the 24px first line */
}
.add-cat {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
  align-items: end;
}
@media (min-width: 700px) {
  .add-cat {
    grid-template-columns: 2fr 1fr 1fr auto;
  }
}
.backup-actions {
  display: grid;
  gap: 10px;
}
.link-list li {
  margin: 4px 0;
}
.biblio li {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

/* onboarding */
.onboarding {
  max-width: 560px;
  margin: 0 auto;
  padding-top: 24px;
  text-align: left;
}
.onboarding-logo {
  border-radius: 16px;
}
.lead {
  font-size: 1.1rem;
  color: var(--text-2);
}
.features {
  list-style: none;
  padding: 0;
}
.features li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 8px 0;
  color: var(--text-2);
}
.features .icon {
  color: var(--accent);
  margin-top: 2px;
}
.onboarding .card > * + * {
  margin-top: 14px;
}
.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.choice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: 0.9rem var(--font);
  text-align: left;
  cursor: pointer;
}
.choice span {
  color: var(--muted);
  font-size: 0.8rem;
}
.choice.on {
  border-color: var(--flag-blue);
  background: var(--flag-blue);
  color: var(--on-blue);
}
.choice.on span {
  color: inherit;
}

/* empty */
.empty {
  text-align: center;
  padding: 40px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-2);
}
.empty > .icon {
  box-sizing: content-box;
  padding: 14px;
  border-radius: 999px;
  background: var(--flag-pink);
  color: var(--on-pink);
  margin-bottom: 8px;
}
.empty p {
  max-width: 440px;
  margin: 0 auto 16px;
}

