:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #15181c;
  --muted: #5b6470;
  --border: #d5d9df;
  --accent: #0b6e4f;
  --accent-text: #ffffff;
  --warn: #a4400f;
  --ok: #0b6e4f;
  --danger: #b3261e;
  --done: #0b6e4f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --surface: #1f252c;
    --text: #f1f3f5;
    --muted: #a7b0ba;
    --border: #39424c;
    --accent: #3ecf9a;
    --accent-text: #06291d;
    --warn: #ffb08a;
    --ok: #6fe0b8;
    --danger: #ff9d96;
    --done: #157a58;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px 32px;
}

main.with-timer { padding-bottom: calc(112px + env(safe-area-inset-bottom)); }

h1 { font-size: 1.3rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 20px 0 8px; }
.card h2 { margin-top: 0; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin: 12px 0;
}

label {
  display: block;
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: .9rem;
}

input, select {
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.inputs input {
  font-size: 1.6rem;
  font-weight: 600;
  text-align: center;
}

button {
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled { opacity: .5; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }

.primary {
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}

.primary.small { width: auto; margin: 0; }
.ghost { background: transparent; }
.tiny { min-height: 40px; min-width: 40px; padding: 4px; }

.danger {
  width: 100%;
  margin-top: 12px;
  color: var(--danger);
  border-color: var(--danger);
}

.row { display: flex; gap: 10px; margin-top: 8px; }
.row > * { flex: 1 1 0; min-width: 0; }

.session {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 2px;
  margin-bottom: 8px;
  padding: 12px 14px;
  text-align: left;
  background: var(--surface);
}

.session span { color: var(--muted); font-size: .9rem; }
.session.today { border: 2px solid var(--accent); }

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px;
  padding: 2px 16px 8px;
  scrollbar-width: none;
}

.chip {
  flex: 0 0 auto;
  max-width: 75vw;
  min-height: 44px;
  overflow: hidden;
  border-radius: 22px;
  background: var(--surface);
  font-size: .9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.has-sets { border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 700; }

.goal { margin: 0 0 6px; font-weight: 600; }
.hint { margin: 4px 0; color: var(--muted); font-size: .9rem; }
.status { margin: 8px 0; font-size: .92rem; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); font-weight: 600; }

.sets { list-style: none; margin: 10px 0; padding: 0; }

.sets li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.timer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.timer[hidden] { display: none; }
.timer button { padding: 8px 10px; }

.timer-label {
  min-width: 0;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.timer.done { background: var(--done); color: #ffffff; }
.timer.done button { color: #ffffff; border-color: #ffffff; }
.timer.done .timer-label { font-size: 1.05rem; }
