:root {
  --bg: #f4efe6;
  --bg-strong: #e8dfd0;
  --surface: rgba(255, 252, 247, 0.82);
  --surface-strong: #fffaf2;
  --text: #1b1611;
  --muted: #6b6258;
  --line: rgba(58, 44, 28, 0.12);
  --line-strong: rgba(58, 44, 28, 0.22);
  --accent: #d95d39;
  --accent-deep: #b14424;
  --accent-soft: #ffe4d7;
  --success: #1f8f63;
  --shadow: 0 24px 80px rgba(69, 44, 16, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --content-width: 1180px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top left, rgba(217, 93, 57, 0.14), transparent 32%),
    radial-gradient(circle at top right, rgba(31, 143, 99, 0.14), transparent 28%),
    linear-gradient(180deg, #fbf7ef 0%, #efe5d5 100%);
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

video {
  max-width: 100%;
}

.page-shell {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: #fff9f3;
  font-size: 1.25rem;
  background: linear-gradient(135deg, var(--accent) 0%, #ef8f52 100%);
  box-shadow: 0 16px 36px rgba(217, 93, 57, 0.28);
}

.brand-copy strong,
.brand-copy span {
  display: block;
}

.brand-copy strong {
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-copy span {
  color: var(--muted);
  font-size: 0.95rem;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.nav-link,
.button,
button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background-color 160ms ease;
}

.nav-link {
  color: var(--text);
  background: rgba(255, 250, 242, 0.74);
  border: 1px solid var(--line);
}

.button,
button,
.button-primary {
  color: #fffaf4;
  background: linear-gradient(135deg, var(--accent) 0%, #ea7b48 100%);
  box-shadow: 0 16px 28px rgba(217, 93, 57, 0.24);
}

.button-secondary {
  color: var(--text);
  background: rgba(255, 250, 242, 0.88);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.button-success {
  background: linear-gradient(135deg, #1f8f63 0%, #29a571 100%);
  box-shadow: 0 16px 28px rgba(31, 143, 99, 0.22);
}

.nav-link:hover,
.button:hover,
button:hover {
  transform: translateY(-1px);
}

.flash {
  margin-bottom: 20px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(177, 68, 36, 0.16);
  color: #6f2916;
  background: rgba(255, 228, 215, 0.92);
}

.hero,
.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero {
  padding: 32px;
}

.hero::after,
.panel::after {
  content: "";
  position: absolute;
  inset: auto -60px -60px auto;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 93, 57, 0.14), transparent 68%);
  pointer-events: none;
}

.panel {
  padding: 24px;
}

.stack {
  display: grid;
  gap: 20px;
}

.grid-2,
.grid-3,
.metric-grid,
.auth-grid {
  display: grid;
  gap: 20px;
}

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

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

.section-title {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.02;
}

.section-copy,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent-deep);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  border: 1px solid rgba(177, 68, 36, 0.12);
}

.metric {
  padding: 20px;
  border-radius: var(--radius-md);
  background: rgba(255, 250, 242, 0.8);
  border: 1px solid var(--line);
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.hero .grid-2 {
  grid-template-columns: minmax(0, 1.5fr) minmax(420px, 0.9fr);
  gap: 24px;
}

.hero .metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-self: stretch;
}

.hero .metric:last-child {
  grid-column: 1 / -1;
}

.exercise-card,
.day-link,
.leader-row {
  display: block;
  padding: 20px;
  text-decoration: none;
  border-radius: var(--radius-md);
  background: rgba(255, 250, 242, 0.74);
  border: 1px solid var(--line);
}

.exercise-card h3,
.leader-row strong,
.day-link strong {
  margin: 0;
}

.exercise-card p,
.day-link span {
  margin: 8px 0 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.action-row > * {
  flex: 1 1 180px;
  text-align: center;
}

.list {
  display: grid;
  gap: 12px;
}

.day-link,
.leader-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.video-shell {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--radius-lg) - 4px);
  border: 1px solid var(--line);
  background: #1c1815;
  aspect-ratio: 4 / 3;
  min-height: 280px;
}

.video-shell img {
  display: block;
  width: 100%;
}

.camera-feed,
.camera-preview {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #1c1815;
}

.camera-capture-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  opacity: 0.001;
  pointer-events: none;
}

.camera-preview,
.camera-placeholder {
  position: absolute;
  inset: 0;
}

.camera-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #f8efe3;
  background:
    linear-gradient(180deg, rgba(28, 24, 21, 0.74), rgba(28, 24, 21, 0.9)),
    radial-gradient(circle at top, rgba(217, 93, 57, 0.24), transparent 36%);
  z-index: 2;
}

.camera-placeholder strong {
  font-size: 1.1rem;
}

.camera-placeholder span {
  color: rgba(248, 239, 227, 0.82);
}

.camera-preview-hidden {
  display: none;
}

.camera-preview {
  z-index: 3;
}

.camera-hidden {
  display: none;
}

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

.stats-table th,
.stats-table td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.stats-table th {
  color: var(--muted);
  font-weight: normal;
}

.auth-layout {
  min-height: calc(100vh - 68px);
  display: grid;
  place-items: center;
}

.auth-grid {
  max-width: 980px;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.9fr);
  align-items: stretch;
}

.auth-hero {
  padding: 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-card {
  max-width: 420px;
  margin: 0 auto;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text);
  font: inherit;
  background: rgba(255, 252, 247, 0.94);
}

input:focus,
select:focus {
  outline: 2px solid rgba(217, 93, 57, 0.18);
  border-color: rgba(217, 93, 57, 0.44);
}

.form-stack {
  display: grid;
  gap: 14px;
}

.inline-stat {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.inline-stat:first-of-type {
  padding-top: 0;
}

.inline-stat:last-of-type {
  border-bottom: 0;
}

.counter-value {
  font-size: 3.4rem;
  line-height: 1;
}

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

.compact-stack {
  gap: 14px;
}

.user-link {
  text-decoration: none;
  color: var(--accent-deep);
}

.race-list {
  display: grid;
  gap: 14px;
}

.race-row {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.78);
}

.race-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.race-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
}

.race-track {
  position: relative;
  height: 22px;
  border-radius: 999px;
  overflow: hidden;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(27, 22, 17, 0.06) 0,
      rgba(27, 22, 17, 0.06) 24px,
      transparent 24px,
      transparent 48px
    ),
    linear-gradient(90deg, rgba(58, 44, 28, 0.08), rgba(58, 44, 28, 0.03));
}

.race-car {
  position: relative;
  min-width: 40px;
  height: 100%;
  border-radius: 999px;
}

.race-car span {
  position: absolute;
  right: -8px;
  top: 3px;
  width: 18px;
  height: 16px;
  border-radius: 5px 8px 8px 5px;
  background: inherit;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.race-car-orange {
  background: linear-gradient(90deg, #df6b42, #f19a57);
}

.race-car-green {
  background: linear-gradient(90deg, #319764, #57c78b);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.calendar-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.calendar-dot-active {
  background: #2aa56f;
}

.calendar-dot-missed {
  background: #d95d39;
}

.calendar-dot-pending {
  background: #f0b34a;
}

.calendar-dot-penalty {
  background: #7c3aed;
}

.calendar-months {
  display: grid;
  gap: 18px;
}

.calendar-month {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 250, 242, 0.68);
}

.calendar-month h3 {
  margin: 0 0 14px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.calendar-cell {
  min-height: 62px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  background: rgba(255, 252, 247, 0.72);
}

.calendar-outside,
.calendar-future {
  opacity: 0.34;
}

.calendar-active {
  background: rgba(31, 143, 99, 0.16);
  border-color: rgba(31, 143, 99, 0.32);
}

.calendar-missed {
  background: rgba(217, 93, 57, 0.15);
  border-color: rgba(217, 93, 57, 0.28);
}

.calendar-pending {
  background: rgba(240, 179, 74, 0.18);
  border-color: rgba(240, 179, 74, 0.36);
}

.calendar-penalty {
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(124, 58, 237, 0.3);
}

.calendar-today {
  background: rgba(27, 22, 17, 0.08);
  border-color: var(--line-strong);
}

.report-card {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.76);
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.report-pill {
  text-transform: capitalize;
}

.report-pending {
  background: rgba(240, 179, 74, 0.18);
  color: #8a5c02;
}

.report-approved {
  background: rgba(124, 58, 237, 0.16);
  color: #5b2ab2;
}

.report-missed {
  background: rgba(217, 93, 57, 0.14);
  color: #9a3d25;
}

.habit-proof-card {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.76);
}

.habit-sections {
  display: grid;
  gap: 14px;
}

.section-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 6px;
  margin-bottom: 18px;
  border-top: 1px solid var(--line);
}

.section-divider:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.habit-proof-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.status-ok {
  color: var(--success);
}

.status-pending {
  color: var(--accent-deep);
}

.kv-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.compact-metric {
  padding: 14px;
}

.compact-metric strong {
  margin-top: 8px;
  font-size: 1.2rem;
  line-height: 1.1;
}

@media (max-width: 980px) {
  .grid-2,
  .grid-3,
  .metric-grid,
  .auth-grid {
    grid-template-columns: 1fr;
  }

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

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

  .hero .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero .metric:last-child {
    grid-column: auto;
  }

  .auth-layout {
    min-height: auto;
  }

  .calendar-cell {
    min-height: 48px;
    padding: 8px;
  }

  .video-shell {
    min-height: 240px;
  }

  .habit-proof-head {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .brand {
    width: 100%;
    align-items: flex-start;
  }

  .brand-copy {
    min-width: 0;
  }

  .brand-copy strong,
  .brand-copy span {
    overflow-wrap: anywhere;
  }

  .nav {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .nav-link,
  .button,
  button {
    width: 100%;
    text-align: center;
  }

  .metric-grid,
  .grid-3 {
    grid-template-columns: 1fr;
  }

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

  .calendar-month {
    padding: 12px;
    overflow-x: auto;
  }

  .calendar-weekdays,
  .calendar-grid {
    min-width: 420px;
    gap: 6px;
  }

  .calendar-weekdays {
    font-size: 0.72rem;
  }

  .calendar-cell {
    min-height: 40px;
    font-size: 0.88rem;
  }

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

  .page-shell {
    overflow-x: hidden;
  }

  .video-shell {
    min-height: 220px;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 18px 14px 28px;
  }

  .hero,
  .panel,
  .auth-hero {
    padding: 22px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .section-title {
    font-size: 2rem;
  }

  .counter-value {
    font-size: 2.6rem;
  }
}
