:root {
  --accent: #ef4444;
  --accent-hover: #f87171;
  --accent-soft: rgba(239, 68, 68, 0.18);
  --accent-border: rgba(239, 68, 68, 0.28);
  --accent-text: #1b0303;
  --bg: #060303;
  --panel: #151012;
  --panel-soft: #100b0c;
  --field: #090506;
  --text: #faf7f7;
  --muted: #b8aaaa;
  --dim: #897c7c;
  --border: rgba(255, 255, 255, 0.11);
  --radius-lg: 1.2rem;
  --radius-md: 0.9rem;
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(239, 68, 68, 0.18), transparent 18rem),
    linear-gradient(180deg, #140608 0%, var(--bg) 28rem);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(100%, 30rem);
  margin: 0 auto;
  padding:
    max(1rem, env(safe-area-inset-top))
    max(0.9rem, env(safe-area-inset-right))
    max(2rem, env(safe-area-inset-bottom))
    max(0.9rem, env(safe-area-inset-left));
}

.topbar {
  margin-bottom: 1rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: #ff9a9a;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.05rem, 10vw, 2.75rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.1rem;
}

.status {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 10;
  transform: translateX(-50%);
  min-width: 8rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: rgba(21, 16, 18, 0.96);
  color: var(--text);
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  font-weight: 900;
  text-align: center;
}

.status[hidden] {
  display: none;
}

.entry-panel,
.history {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(21, 16, 18, 0.96);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.entry-panel {
  padding: 1rem;
}

form {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.9rem;
}

label,
.metric-field {
  min-width: 0;
}

label {
  display: grid;
  gap: 0.38rem;
}

label > span,
.metric-field legend {
  color: #d3c5c5;
  font-size: 0.82rem;
  font-weight: 900;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 2.9rem;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--text);
  outline: none;
  padding: 0 0.82rem;
  font-weight: 800;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #ffb1b1 50%),
    linear-gradient(135deg, #ffb1b1 50%, transparent 50%);
  background-position:
    calc(100% - 1rem) 50%,
    calc(100% - 0.72rem) 50%;
  background-repeat: no-repeat;
  background-size: 0.32rem 0.32rem;
  padding-right: 2.1rem;
}

input::placeholder {
  color: #776c6c;
  opacity: 1;
}

input:focus,
select:focus {
  border-color: rgba(239, 68, 68, 0.85);
  box-shadow: 0 0 0 0.18rem var(--accent-soft);
}

.top-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(8.5rem, 0.85fr);
  gap: 0.7rem;
}

.numbers-row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr);
  gap: 0.7rem;
}

.detail-toggle {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0.45rem 0.35rem 0.85rem;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--field);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 900;
}

.detail-toggle input {
  position: relative;
  width: 3.1rem;
  min-height: 1.8rem;
  height: 1.8rem;
  flex: 0 0 auto;
  appearance: none;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: #0b0708;
  cursor: pointer;
}

.detail-toggle input::before {
  content: "";
  position: absolute;
  top: 0.22rem;
  left: 0.22rem;
  width: 1.22rem;
  height: 1.22rem;
  border-radius: 50%;
  background: #8d7d7d;
  transition:
    background 160ms ease,
    transform 160ms ease;
}

.detail-toggle input:checked {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.detail-toggle input:checked::before {
  background: var(--accent);
  transform: translateX(1.25rem);
}

.set-detail-panel {
  display: grid;
  gap: 0.55rem;
}

.set-detail-panel[hidden] {
  display: none;
}

.set-detail-list {
  display: grid;
  gap: 0.55rem;
}

.set-row {
  display: grid;
  gap: 0.55rem;
  padding: 0.65rem;
  border: 1px solid rgba(239, 68, 68, 0.18);
  border-radius: var(--radius-md);
  background: rgba(9, 5, 6, 0.72);
}

.set-row-top {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0.55rem;
  align-items: center;
}

.set-number {
  color: #ff9a9a;
  font-size: 0.9rem;
  font-weight: 950;
}

.set-reps {
  min-height: 2.45rem;
}

.variant-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.variant-chips label {
  display: block;
}

.variant-chips input {
  position: absolute;
  width: 1px;
  min-height: 0;
  height: 1px;
  opacity: 0;
}

.variant-chips span {
  min-height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  color: #eadcdc;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
}

.variant-chips input:checked + span {
  border-color: var(--accent-border);
  background: var(--accent);
  color: var(--accent-text);
}

.metric-field {
  display: grid;
  gap: 0.38rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.metric-field legend {
  padding: 0;
}

.metric-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  align-items: stretch;
}

.unit-toggle {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 0.22rem;
  min-width: 0;
  min-height: 2.9rem;
  padding: 0.22rem;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  background: var(--field);
}

.unit-toggle label {
  position: relative;
  display: block;
}

.unit-toggle input {
  position: absolute;
  width: 1px;
  min-height: 0;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
}

.unit-toggle span {
  min-height: 2.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.72rem;
  color: #ffd8d8;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
}

.unit-toggle input:checked + span {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 0.6rem 1.3rem rgba(239, 68, 68, 0.22);
}

.metric-value {
  position: relative;
  display: block;
}

.metric-value input {
  height: 100%;
  padding-right: 4.5rem;
}

.metric-suffix {
  position: absolute;
  top: 50%;
  right: 0.85rem;
  transform: translateY(-50%);
  color: #ffb1b1;
  font-size: 0.82rem;
  font-weight: 900;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

button {
  min-height: 3.05rem;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  font-weight: 950;
}

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

.date-field {
  display: grid;
  gap: 0.38rem;
  position: relative;
}

.date-control {
  position: relative;
}

.date-button {
  width: 100%;
  min-height: 2.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--accent-border);
  background: var(--field);
  color: var(--text);
  font-weight: 900;
  pointer-events: none;
}

.date-button::before {
  content: "";
  width: 1.05rem;
  height: 1.05rem;
  display: block;
  background:
    linear-gradient(#ffb1b1, #ffb1b1) 20% 27% / 60% 0.12rem no-repeat,
    linear-gradient(#ffb1b1, #ffb1b1) 30% 0 / 0.12rem 28% no-repeat,
    linear-gradient(#ffb1b1, #ffb1b1) 70% 0 / 0.12rem 28% no-repeat;
  border: 0.13rem solid #ffb1b1;
  border-radius: 0.22rem;
}

.date-native {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 2.9rem;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0.6rem 0;
}

.summary-grid div {
  min-height: 4.6rem;
  display: grid;
  align-content: center;
  gap: 0.35rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(16, 11, 12, 0.94);
}

.summary-grid span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.summary-grid strong {
  font-size: 1.55rem;
  line-height: 1;
}

#lastTraining {
  font-size: 1.05rem;
  line-height: 1.15;
}

.history {
  padding: 1rem;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ghost {
  min-height: 2.25rem;
  padding: 0 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: #e8dddd;
  font-size: 0.78rem;
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.empty {
  margin-top: 1rem;
  color: var(--muted);
}

.log-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.day-group {
  display: grid;
  gap: 0.55rem;
}

.day-group h3 {
  color: #ff9a9a;
  font-size: 0.82rem;
}

.entries {
  display: grid;
  gap: 0.5rem;
}

.entry-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
}

.exercise {
  display: block;
  overflow-wrap: anywhere;
}

.meta {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.set-detail-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.set-detail-summary[hidden] {
  display: none;
}

.set-detail-summary span {
  min-height: 1.85rem;
  display: inline-flex;
  align-items: center;
  padding: 0 0.55rem;
  border: 1px solid rgba(239, 68, 68, 0.18);
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.08);
  color: #f2d5d5;
  font-size: 0.76rem;
  font-weight: 850;
}

.note {
  margin-top: 0.3rem;
  color: var(--dim);
  font-size: 0.86rem;
}

.note:empty {
  display: none;
}

.delete {
  min-height: 2.25rem;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #231617;
  color: #ffb3b8;
  font-size: 0.78rem;
}

.delete:hover {
  background: #3a1c20;
}

@media (max-width: 34rem) {
  .shell {
    width: 100%;
  }

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

  .top-fields {
    grid-template-columns: minmax(0, 1fr) minmax(7.6rem, 0.9fr);
    gap: 0.55rem;
  }

  .numbers-row,
  .metric-control {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.55rem;
  }

  .unit-toggle span {
    font-size: 0.78rem;
  }

  .entry-panel,
  .history {
    border-radius: 1.15rem;
  }

  .summary-grid {
    gap: 0.55rem;
  }

  .entry-card {
    grid-template-columns: 1fr;
  }

  .delete {
    width: 100%;
  }
}

@media (min-width: 48rem) {
  .shell {
    padding-top: 1.6rem;
  }
}
