:root {
  --bg: #f4efe4;
  --paper: rgba(255, 249, 239, 0.9);
  --paper-strong: #fffaf1;
  --ink: #1d1a16;
  --muted: #6b6257;
  --line: rgba(84, 64, 42, 0.12);
  --shadow: 0 18px 38px rgba(72, 50, 28, 0.08);
  --accent: #b55f31;
  --teal: #236974;
  --olive: #6b8645;
  --plum: #6d516f;
  --gold: #a77a1e;
  --red: #b9554f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  background:
    radial-gradient(circle at top left, rgba(181, 95, 49, 0.14), transparent 25%),
    radial-gradient(circle at top right, rgba(35, 105, 116, 0.14), transparent 22%),
    linear-gradient(180deg, #f8f4ec 0%, #ede3d5 100%);
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(84, 64, 42, 0.08);
  background: rgba(248, 244, 236, 0.84);
  backdrop-filter: blur(16px);
}

.site-header-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  text-decoration: none;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  font-size: 1.5rem;
  letter-spacing: 0.01em;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.site-nav a {
  padding: 9px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  transition: background 140ms ease, color 140ms ease;
}

.site-nav a:hover,
.site-nav a.active {
  background: rgba(181, 95, 49, 0.11);
  color: var(--ink);
}

.page {
  max-width: 1220px;
  margin: 0 auto;
  padding: 36px 20px 72px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 22px;
}

.hero-copy,
.hero-panel,
.summary-card,
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-copy,
.hero-panel {
  border-radius: 28px;
  padding: 24px;
}

.hero-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.hero-panel-label,
.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

.hero-panel-value {
  margin: 4px 0 8px;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  font-size: 2rem;
  line-height: 1;
  color: var(--ink);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
}

h1 {
  font-size: clamp(2.7rem, 6vw, 5.1rem);
  line-height: 0.92;
  margin-bottom: 14px;
}

h2 {
  font-size: 2rem;
  line-height: 1;
}

h3 {
  font-size: 1.35rem;
  line-height: 1.05;
}

.lede,
p,
li,
th,
td {
  color: var(--muted);
  line-height: 1.55;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.summary-card {
  border-radius: 22px;
  padding: 18px;
}

.summary-label {
  margin: 0 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-value {
  margin: 0;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  font-size: 2rem;
  line-height: 0.95;
  color: var(--ink);
}

.summary-delta {
  margin: 12px 0 0;
  font-size: 0.95rem;
}

.tone-body .summary-label,
.tone-bodyfat .summary-label {
  color: var(--accent);
}

.tone-steps .summary-label,
.tone-recovery .summary-label {
  color: var(--teal);
}

.tone-sleep .summary-label {
  color: var(--plum);
}

.tone-workout .summary-label {
  color: var(--olive);
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 30px 0 14px;
}

.trend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.utility-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.single-column {
  grid-template-columns: 1fr;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 22px;
}

.range-filter,
.toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
  text-decoration: none;
  color: var(--muted);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.filter-chip:hover,
.filter-chip.active {
  background: rgba(181, 95, 49, 0.11);
  border-color: rgba(181, 95, 49, 0.22);
  color: var(--ink);
}

.toolbar-note {
  margin: 0;
  font-size: 0.92rem;
}

.card {
  border-radius: 24px;
  padding: 22px;
}

.trend-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 280px;
}

.trend-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.trend-card-subtitle,
.detail-caption,
.detail-footer {
  margin: 6px 0 0;
  font-size: 0.95rem;
}

.trend-card-value {
  margin: 0;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  font-size: 2rem;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}

.link-card {
  display: block;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 42px rgba(72, 50, 28, 0.11);
  border-color: rgba(181, 95, 49, 0.22);
}

.tone-link-body {
  color: var(--accent);
}

.tone-link-fitbit {
  color: var(--teal);
}

.tone-link-workout {
  color: var(--olive);
}

.tone-link-insights {
  color: var(--plum);
}

.chart-shell {
  display: flex;
  align-items: center;
  min-height: 180px;
  margin-top: auto;
}

.chart-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-gridline {
  stroke: rgba(84, 64, 42, 0.14);
  stroke-width: 1;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  letter-spacing: 0.03em;
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-empty {
  width: 100%;
  padding: 24px 0;
  color: var(--muted);
  font-style: italic;
}

.card-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.table-shell {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.95rem;
}

th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--teal);
}

tbody tr:last-child td {
  border-bottom: none;
}

.workout-stack {
  display: grid;
  gap: 12px;
}

.workout-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.workout-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.workout-title {
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
}

.workout-meta,
.workout-totals p {
  margin: 4px 0 0;
  font-size: 0.92rem;
}

.workout-totals {
  text-align: right;
  white-space: nowrap;
}

.sleep-stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sleep-stage {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
}

.sleep-stage span {
  display: block;
  color: var(--plum);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sleep-stage strong {
  display: block;
  margin-top: 8px;
  font-family: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  font-size: 1.45rem;
  color: var(--ink);
}

.metric-list {
  margin: 0;
  padding-left: 18px;
}

.metric-list.compact li {
  font-size: 0.95rem;
}

.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.92rem;
}

.connected {
  background: rgba(35, 105, 116, 0.12);
  color: var(--teal);
}

.pending {
  background: rgba(181, 95, 49, 0.12);
  color: var(--accent);
}

.button {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font: inherit;
}

.button.secondary {
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
  border: 1px solid var(--line);
}

.empty-state {
  margin: auto 0 0;
  font-style: italic;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
  color: var(--ink);
}

.banner {
  margin-bottom: 20px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--paper);
}

.banner-success {
  border-color: rgba(35, 105, 116, 0.18);
  background: rgba(236, 246, 246, 0.82);
}

.banner-error {
  border-color: rgba(185, 85, 79, 0.2);
  background: rgba(252, 239, 236, 0.92);
}

.upload-form {
  display: grid;
  gap: 12px;
}

.file-field {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.file-field span {
  color: var(--ink);
}

.file-field input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed rgba(84, 64, 42, 0.24);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.52);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.insight-card:last-child {
  grid-column: 1 / -1;
}

.card-divider {
  margin: 18px 0;
  border: none;
  border-top: 1px solid var(--line);
}

pre {
  margin: 12px 0 0;
  padding: 14px;
  border-radius: 16px;
  overflow-x: auto;
  background: #1f1a17;
  color: #fdf7f0;
}

code {
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 0.92rem;
}

@media (max-width: 1120px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .trend-grid,
  .detail-grid,
  .utility-grid,
  .link-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page {
    padding: 20px 14px 44px;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-header-inner {
    align-items: start;
    flex-direction: column;
  }

  .trend-card-top,
  .card-heading,
  .workout-row,
  .toolbar {
    flex-direction: column;
    align-items: start;
  }

  .workout-totals {
    text-align: left;
  }

  .sleep-stage-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .site-nav {
    width: 100%;
  }

  .sleep-stage-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 2.9rem;
  }
}
