/* Dark, high-contrast interface sized for one-handed use at the gym:
   large touch targets, generous type, no hover-only affordances. */

:root {
  --bg: #1b1a18;
  --bg-raised: #262522;
  --bg-sunken: #161513;
  --border: #38362f;
  --text: #f0eee6;
  --text-muted: #9c988c;
  --accent: #d97757;
  --accent-strong: #c96442;
  --accent-ink: #1b1a18;
  --success: #8fa882;
  --warning: #d9a441;
  --danger: #c0604c;
  --idle: #4a4842;
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-height: 68px;
}

[x-cloak] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

p {
  margin: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ------------------------------------------------------------------ boot */

.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 100dvh;
  color: var(--text-muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ----------------------------------------------------------------- shell */

.shell {
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom, 0px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 14px;
  background: linear-gradient(180deg, #232220 0%, var(--bg) 100%);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__eyebrow {
  color: var(--text-muted);
  font-size: 13px;
  text-transform: capitalize;
}

.topbar__title {
  font-size: 23px;
  font-weight: 650;
}

.topbar__badge {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.content {
  padding: 4px 16px 24px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 16px 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: #33211c;
  border: 1px solid #6b3327;
  color: #e9b6a6;
  font-size: 14px;
}

.alert__close {
  background: none;
  border: 0;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.hint {
  color: var(--text-muted);
  font-size: 13px;
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card--row {
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card__title {
  font-size: 17px;
  font-weight: 620;
}

.card--rest,
.card--empty {
  align-items: flex-start;
  gap: 14px;
}

.rest-summary {
  display: flex;
  gap: 28px;
}

.rest-summary strong {
  display: block;
  font-size: 26px;
}

.rest-summary span {
  color: var(--text-muted);
  font-size: 13px;
}

/* -------------------------------------------------------------- progress */

.progress-card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-card--done {
  border-color: var(--success);
}

.progress-card__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  color: var(--text-muted);
}

.progress-card__head strong {
  font-size: 20px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-sunken);
  overflow: hidden;
}

.bar--lg {
  height: 12px;
}

.bar__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width 0.3s ease;
}

/* ---------------------------------------------------------------- blocks */

.block--done {
  border-color: rgba(143, 168, 130, 0.5);
}

.block__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.block__head h2 {
  font-size: 19px;
  font-weight: 640;
  margin-top: 4px;
}

.block__meta {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--idle);
  color: var(--text);
}

.tag--cardio {
  background: rgba(217, 119, 87, 0.16);
  color: #e09375;
}

.tag--calisthenics {
  background: rgba(217, 164, 65, 0.16);
  color: #d9b06a;
}

.tag--strength {
  background: rgba(143, 168, 130, 0.18);
  color: #a8bd9c;
}

/* ------------------------------------------------------------- exercises */

.exercises {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.exercise {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
}

.exercise__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.exercise__body strong {
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exercise__body span {
  color: var(--text-muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.exercise--done .exercise__body strong {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* --------------------------------------------------------------- buttons */

.check {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--bg-sunken);
  color: transparent;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.check--sm {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 20px;
}

.check--on {
  background: var(--success);
  border-color: var(--success);
  color: var(--accent-ink);
}

.btn {
  padding: 13px 18px;
  border-radius: 12px;
  border: 1px solid var(--accent-strong);
  background: var(--accent-strong);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 640;
  cursor: pointer;
}

.btn--full {
  width: 100%;
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.icon-btn {
  min-width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
}

.icon-btn--lg {
  min-width: 54px;
  height: 54px;
  font-size: 26px;
}

.icon-btn--danger {
  color: var(--danger);
  border-color: rgba(192, 96, 76, 0.4);
}

/* ------------------------------------------------------------------ week */

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
}

.metric strong {
  display: block;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.metric span {
  color: var(--text-muted);
  font-size: 12px;
}

.weekgrid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.weekday {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.weekday--today {
  border-color: var(--accent);
}

.weekday__label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.weekday__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--idle);
}

.weekday--complete .weekday__dot {
  background: var(--success);
}

.weekday--partial .weekday__dot {
  background: var(--warning);
}

.weekday--missed .weekday__dot {
  background: var(--danger);
}

.weekday--upcoming .weekday__dot,
.weekday--empty .weekday__dot {
  background: var(--idle);
}

.weekday__count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--idle);
  display: inline-block;
  flex: 0 0 auto;
}

.dot--complete {
  background: var(--success);
}

.dot--partial {
  background: var(--warning);
}

.dot--missed {
  background: var(--danger);
}

.dot--upcoming,
.dot--empty {
  background: var(--idle);
}

/* -------------------------------------------------------------- timeline */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.timeline__arrow {
  font-size: 13px;
  color: var(--idle);
  margin-top: 3px;
}

.timeline__arrow--up {
  color: var(--success);
}

.timeline__arrow--down {
  color: var(--danger);
}

.timeline li div {
  display: flex;
  flex-direction: column;
}

.timeline__detail {
  color: var(--text-muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.timeline__date {
  color: var(--text-muted);
  font-size: 12px;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
}

.history li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history__state {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 13px;
}

/* ----------------------------------------------------------- plan editor */

.subtabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 14px;
  scrollbar-width: none;
}

.subtabs::-webkit-scrollbar {
  display: none;
}

.subtabs button {
  flex: 0 0 auto;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
}

.subtabs button.is-active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-ink);
  font-weight: 620;
}

.planlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.planlist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  font-size: 15px;
}

.planlist__item--missing {
  color: var(--danger);
}

.planlist__actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.select,
select,
input[type='text'],
input[type='number'] {
  width: 100%;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 16px; /* 16px keeps Android from zooming on focus */
  font-family: inherit;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.field > span {
  color: var(--text-muted);
}

.field small {
  color: var(--text-muted);
  font-size: 12px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
}

.switch input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

/* ---------------------------------------------------------------- tabbar */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(22, 21, 19, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 11px 4px 13px;
  background: none;
  border: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}

.tabbar button span {
  font-size: 19px;
  line-height: 1;
}

.tabbar button.is-active {
  color: var(--accent);
}

/* -------------------------------------------------------------- overlays */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 14, 13, 0.8);
  backdrop-filter: blur(3px);
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.sheet {
  width: 100%;
  max-width: 460px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet h2 {
  font-size: 19px;
}

.sheet__subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 4px;
}

.sheet__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.weightpicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.weightpicker > div {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.weightpicker input {
  width: 100%;
  text-align: center;
  font-size: 30px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  padding: 10px;
}

.weightpicker span {
  color: var(--text-muted);
}

.builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.builder li {
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.builder__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.builder__fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.builder__fields label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.builder__fields input {
  padding: 9px 8px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- timer */

.overlay:has(.timerbox) {
  align-items: center;
}

.timerbox {
  width: 100%;
  max-width: 400px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timerbox__name {
  color: var(--text-muted);
  font-size: 15px;
}

.timerbox__clock {
  font-size: 68px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.timerbox__hint {
  color: var(--text-muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.timerbox__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

/* ----------------------------------------------------------------- chart */

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

.chart__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart__point {
  fill: var(--bg-raised);
  stroke: var(--accent);
  stroke-width: 2.5;
}

.chart__current {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.chart__axis {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- dashboard extras */

.ringcard {
  flex-direction: row;
  align-items: center;
  gap: 18px;
}

.ring {
  flex: 0 0 auto;
  width: 108px;
  height: 108px;
  transform: rotate(-90deg); /* start the arc at twelve o'clock */
}

.ring__track {
  fill: none;
  stroke: var(--bg-sunken);
  stroke-width: 12;
}

.ring__value {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s ease;
}

.ringcard__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ringcard__percent {
  font-size: 34px;
  font-weight: 650;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.streak {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-muted);
}

.streak strong {
  color: var(--accent);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.delta {
  font-size: 11px;
  font-style: normal;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.delta--up {
  color: var(--success);
}

.delta--down {
  color: var(--danger);
}

.delta--flat {
  color: var(--text-muted);
}

/* ---------------------------------------------------------------- heatmap */

.heatmap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.heatmap__labels,
.heatmap__row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}

.heatmap__labels span {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

.heatmap__cell {
  display: block;
  height: 26px;
  border-radius: 6px;
  background: var(--bg-sunken);
  border: 1px solid transparent;
}

.heatmap__cell--complete {
  background: var(--success);
}

.heatmap__cell--partial {
  background: var(--warning);
  opacity: 0.85;
}

.heatmap__cell--missed {
  background: var(--danger);
  opacity: 0.55;
}

.heatmap__cell--upcoming,
.heatmap__cell--empty {
  background: var(--bg-sunken);
}

.heatmap__cell--today {
  border-color: var(--accent);
}
