:root {
  color-scheme: light;
  --bg: #eef1ee;
  --panel: #ffffff;
  --ink: #18201b;
  --muted: #67706a;
  --line: #d8ded8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d9efeb;
  --warn: #b42318;
  --gold: #8a6116;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 10px 28px rgba(24, 32, 27, 0.06);
}

.auth {
  display: grid;
  gap: 20px;
  width: min(420px, 100%);
  margin: 12vh auto 0;
}

.topbar,
.sectionTitle,
.entryRow,
.summaryRow,
.formActions,
.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.05;
}

h2 {
  font-size: 20px;
}

.topbar {
  margin-bottom: 18px;
}

.eyebrow,
.muted,
.entryMeta,
.summaryRow span,
.metric span,
#authText {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  min-height: 92px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}

.logger {
  margin-bottom: 14px;
}

.trendPanel {
  margin-bottom: 14px;
}

.trendPanel .filters {
  min-width: min(100%, 390px);
}

.trendStats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.trendStats div {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.trendStats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.trendStats strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.trendStats .positive {
  color: var(--accent-dark);
}

.trendStats .negative {
  color: var(--warn);
}

.trendChart {
  min-height: 220px;
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfcfb 0%, #f3f6f3 100%);
}

.trendChart svg {
  display: block;
  width: 100%;
  height: auto;
}

.trendBars rect {
  fill: var(--accent);
  rx: 4px;
}

.trendGrid {
  stroke: var(--line);
  stroke-width: 1;
}

.trendAverage {
  stroke: var(--gold);
  stroke-dasharray: 6 6;
  stroke-width: 2;
}

.trendLabels text {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.trendCaption {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.4;
}

.entryForm {
  display: grid;
  grid-template-columns: 150px minmax(220px, 1fr) 120px;
  gap: 12px;
  margin-top: 16px;
}

.sets {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.wide,
.formActions {
  grid-column: span 2;
}

.formActions {
  justify-content: end;
}

form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 15px;
  color: #fff;
  background: var(--accent);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.ghost {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

.ghost:hover {
  background: #edf1eb;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}

.entries,
.summary {
  margin-top: 14px;
}

.entryRow,
.summaryRow {
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.entryRow:first-child,
.summaryRow:first-child {
  border-top: 0;
}

.entryMain {
  min-width: 0;
}

.entryTitle {
  font-weight: 800;
}

.entryTitle span {
  color: var(--gold);
  font-weight: 750;
}

.entryMeta {
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.35;
}

.entryActions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.entryActions button,
#logout,
#resetEntry,
.summaryRow button,
.exerciseForm button {
  width: 42px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.exerciseForm {
  display: grid;
  grid-template-columns: 1fr 42px;
  margin-top: 14px;
}

.summaryRow strong,
.summaryRow span {
  display: block;
}

.summaryRow strong {
  font-size: 15px;
}

.summaryRow span {
  margin-top: 3px;
  font-size: 13px;
}

.error {
  margin-top: 10px;
  color: var(--warn);
  font-weight: 750;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 20px, 1120px);
    margin: 14px auto;
  }

  .metrics,
  .trendStats,
  .grid,
  .entryForm,
  .sets {
    grid-template-columns: 1fr;
  }

  .wide,
  .formActions {
    grid-column: auto;
  }

  .topbar {
    align-items: flex-start;
  }

  .sectionTitle {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters {
    width: 100%;
  }

  .entryRow {
    align-items: flex-start;
  }
}

/* Per-session chart: readable values on touch screens and a text alternative. */
.trendChart { overflow-x: auto; min-height: 0; }
.trendChart svg { min-width: 660px; }
.trendValue { fill: var(--ink, #20352b); font-size: 11px; font-weight: 700; }
.trendStats small { display: block; margin-top: 5px; color: var(--muted); }
#trendSessions summary { cursor: pointer; padding: 10px 0; font-weight: 700; }
.sessionValues { list-style: none; padding: 0; margin: 0; }
.sessionValues li { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
