/* Designed for one hand, mid-rest, in a bright room. Every interactive target
   is at least 48px; the ones you hit while out of breath are much larger. */

:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --line: #d4d4d8;
  --text: #18181b;
  --muted: #52525b;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --good: #15803d;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --radius: 14px;
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09;
    --card: #1c1917;
    --line: #3f3f46;
    --text: #fafaf9;
    --muted: #a1a1aa;
    --accent: #3b82f6;
    --accent-text: #ffffff;
    --good: #4ade80;
    --warn: #fbbf24;
    --warn-bg: #422006;
    --danger: #f87171;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font: 19px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }

/* --- header --------------------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.bar-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.bar-title strong { font-size: 21px; }
.bar-title span { color: var(--muted); font-size: 16px; }

.bar-nav { display: flex; gap: 4px; flex: none; }
.bar-nav a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 17px;
}
.bar-nav a[aria-current="page"] { background: var(--accent); color: var(--accent-text); }

/* --- layout --------------------------------------------------------------- */

main { padding: 14px 12px 0; max-width: 640px; margin: 0 auto; }

.stack > * + * { margin-top: 12px; }

.note {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid currentColor;
  font-size: 17px;
}

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

h2 { margin: 22px 4px 10px; font-size: 16px; text-transform: uppercase;
     letter-spacing: .06em; color: var(--muted); }

/* --- exercise card -------------------------------------------------------- */

.ex {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.ex[data-done="true"] .ex-name { color: var(--muted); }

.ex-head {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  background: none;
  text-align: left;
}

.ex-top { display: flex; align-items: center; gap: 8px; }
.ex-name { font-size: 21px; font-weight: 600; flex: 1; }
.ex-dots { letter-spacing: 3px; color: var(--good); font-size: 15px; flex: none; }

.ex-sub { margin-top: 4px; font-size: 18px; }
.ex-sub b { font-size: 22px; }
.ex-last { margin-top: 2px; font-size: 16px; color: var(--muted); }

.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  background: var(--line);
  color: var(--muted);
  vertical-align: middle;
}
.chip.up { background: var(--good); color: var(--card); }

.ex-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }

/* --- logged sets ---------------------------------------------------------- */

.sets { list-style: none; margin: 14px 0 0; padding: 0; }
.sets li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap);
  border-bottom: 1px solid var(--line);
}
.sets .n { width: 26px; color: var(--muted); font-size: 16px; }
.sets .v { flex: 1; font-size: 20px; font-variant-numeric: tabular-nums; }
.sets .rir { color: var(--muted); font-size: 15px; }
.sets .drop {
  width: var(--tap); height: var(--tap);
  border: 0; background: none; color: var(--muted); font-size: 24px;
}

/* --- steppers ------------------------------------------------------------- */

.field { margin-top: 16px; }
.field-label { font-size: 15px; color: var(--muted); text-transform: uppercase;
               letter-spacing: .05em; margin-bottom: 6px; }

.stepper { display: flex; align-items: stretch; gap: 10px; }
.stepper button {
  flex: none;
  width: 76px;
  height: 68px;
  font-size: 30px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  user-select: none;
}
.stepper button:active { background: var(--accent); color: var(--accent-text); }
.stepper-value {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
.stepper-value b { font-size: 34px; font-weight: 700; }
.stepper-value small { font-size: 17px; color: var(--muted); }

.rir-row { display: flex; gap: 8px; flex-wrap: wrap; }
.rir-row button {
  min-width: var(--tap); height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.rir-row button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text);
                                       border-color: var(--accent); }

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

.log {
  display: block;
  width: 100%;
  margin-top: 18px;
  min-height: 68px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 22px;
  font-weight: 700;
}
.log:disabled { background: var(--line); color: var(--muted); }

.row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.link {
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: none;
  color: var(--accent);
  font-size: 17px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.link.danger { color: var(--danger); }

textarea {
  width: 100%;
  margin-top: 10px;
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  resize: vertical;
}

input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 10px;
  min-height: 56px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

input[type="date"], input[type="file"] {
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

/* --- history & detail ----------------------------------------------------- */

.session {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  text-decoration: none;
  color: inherit;
}
.session .when { flex: 1; }
.session .when b { font-size: 19px; }
.session .when small { display: block; color: var(--muted); font-size: 16px; }
.session .go { color: var(--muted); font-size: 24px; }

table { width: 100%; border-collapse: collapse; background: var(--card);
        border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line);
         font-variant-numeric: tabular-nums; }
th { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
td.dim { color: var(--muted); }

/* --- rest timer & toast --------------------------------------------------- */

.rest {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 616px;
  margin: 0 auto;
  padding: 10px 10px 10px 18px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
}
.rest-label { flex: 1; font-size: 17px; opacity: .85; overflow: hidden;
              text-overflow: ellipsis; white-space: nowrap; }
.rest-clock { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rest-close { width: var(--tap); height: var(--tap); border: 0; background: none;
              color: inherit; font-size: 26px; }
.rest[data-done="true"] { background: var(--good); color: #04120a; }

.toast {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 616px;
  margin: 0 auto;
  padding: 12px 12px 12px 18px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
}
.toast[data-tone="error"] { background: var(--danger); color: #fff; }
.toast-text { flex: 1; font-size: 17px; }
.toast-action {
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid currentColor; border-radius: 10px;
  background: none; color: inherit; font-weight: 600;
}

@media (prefers-reduced-motion: no-preference) {
  .rest[data-done="true"] { animation: pulse .6s ease-in-out 3; }
  @keyframes pulse { 50% { opacity: .55; } }
}
