:root {
  color-scheme: dark;
  --bg: #0e0f11;
  --surface: #191b1e;
  --surface-2: #24272b;
  --line: #30343a;
  --text: #f3f3ef;
  --muted: #a2a6ad;
  --accent: #c8f135;
  --on-accent: #12140a;
  --danger: #ff7b72;
  --kacper: #c8f135;
  --brynjar: #5cc8ff;
  --tabbar: 62px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}

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

button { font: inherit; color: inherit; touch-action: manipulation; }

/* 16px stops iOS from zooming the page when a field gets focus. */
input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 18px;
  font-weight: 600;
}

input::placeholder { color: #7d8188; font-weight: 400; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.user-kacper { --user: var(--kacper); }
.user-brynjar { --user: var(--brynjar); }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) var(--gutter) 10px;
  max-width: 560px;
  margin: 0 auto;
}

.topbar h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }

.link {
  min-height: 44px;
  padding: 0 4px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 15px;
}

main#view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--gutter) calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px);
}

.tabs {
  position: fixed;
  inset: auto 0 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: #131518;
  border-top: 1px solid var(--line);
}

.tabs button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tabbar);
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.tabs svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.toast {
  position: fixed;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px);
  z-index: 20;
  max-width: 528px;
  margin: 0 auto;
  padding: 12px 14px;
  background: var(--text);
  border-radius: 10px;
  color: var(--bg);
  font-size: 15px;
  font-weight: 600;
}

.toast[hidden] { display: none; }

.load-error { padding: 32px 0; color: var(--muted); text-align: center; }

/* ---------- shared pieces ---------- */

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

.card h2 { font-size: 17px; font-weight: 700; }

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

.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.field span { color: var(--muted); font-size: 14px; font-weight: 500; }

.primary {
  width: 100%;
  min-height: 52px;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  color: var(--on-accent);
  font-size: 17px;
  font-weight: 800;
}

.primary:disabled { opacity: 0.6; }

.icon-button {
  flex: none;
  width: 44px;
  height: 44px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.icon-button:disabled { opacity: 0.25; }

/* ---------- login ---------- */

.login-page { min-height: 100dvh; display: grid; place-items: center; padding: var(--gutter); }

.login { width: 100%; max-width: 360px; }

.login h1 {
  margin-bottom: 28px;
  font-size: 56px;
  font-weight: 900;
  letter-spacing: -0.04em;
  text-align: center;
}

.login h1 span { color: var(--accent); }

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

.form-error { color: var(--danger); font-size: 15px; }
.form-error[hidden] { display: none; }

/* ---------- lifts ---------- */

.day-chips {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 0 calc(var(--gutter) * -1);
  padding: calc(env(safe-area-inset-top) + 6px) var(--gutter) 8px;
  background: var(--bg);
}

.day-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 54px;
  justify-content: center;
  padding: 4px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.chip-day { font-size: 15px; font-weight: 700; }
.chip-focus { color: var(--muted); font-size: 12px; }

.day-chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.day-chip.active .chip-focus { color: var(--on-accent); }

.day-chip.today::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

.day-chip.today.active::after { background: var(--on-accent); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 4px; }
.section-head h2 { font-size: 22px; font-weight: 800; }
.section-head span { color: var(--muted); font-size: 14px; text-align: right; }

.ex-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.ex-head h3 { font-size: 17px; font-weight: 700; }
.ex-head h3::first-letter { text-transform: uppercase; }

.ex-status { flex: none; color: var(--muted); font-size: 13px; }
.ex-status.good { color: var(--accent); }
.ex-status.bad { color: var(--danger); }

.ex-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.mini-field { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mini-field span { flex: none; color: var(--muted); font-size: 14px; }
.mini-field input { min-width: 0; text-align: center; }

.ex-other {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
}

.ex-other b { color: var(--user); font-weight: 700; }

/* ---------- body ---------- */

.summary { border-top: 3px solid var(--user); min-width: 0; }
.summary h3 { font-size: 15px; font-weight: 700; color: var(--user); }

.big-number { margin: 2px 0 4px; font-size: 32px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.big-number small { color: var(--muted); font-size: 13px; font-weight: 500; letter-spacing: 0; }

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

.form-card { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: 2fr 3fr; gap: 10px; }

input[type="date"] { font-size: 16px; font-weight: 500; -webkit-appearance: none; appearance: none; }

.history ul { margin: 6px 0 -6px; padding: 0; list-style: none; }

.history li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border-top: 1px solid var(--line);
}

.history li:first-child { border-top: 0; }
.history-date { flex: 1; color: var(--muted); }
.history .icon-button { margin-right: -10px; }

/* ---------- creatine ---------- */

.creatine-today {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 84px;
  padding: 12px;
  background: var(--surface);
  border: 2px dashed var(--accent);
  border-radius: 16px;
  font-size: 20px;
  font-weight: 800;
}

.creatine-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 20px;
}

.creatine-today.done {
  background: var(--accent);
  border-style: solid;
  color: var(--on-accent);
}

.cal-head { display: flex; align-items: center; justify-content: space-between; margin: -6px -6px 6px; }
.cal-head h2 { text-transform: capitalize; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.cal-letters { margin-bottom: 4px; color: var(--muted); font-size: 12px; font-weight: 600; text-align: center; }

.cal-day {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
}

.cal-day:disabled { background: none; color: #5d6167; }
.cal-day.is-today { border-color: var(--accent); }
.cal-day.taken { background: var(--accent); color: var(--on-accent); }

.cal-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--user);
  border-radius: 50%;
}

.cal-day .cal-dot {
  position: absolute;
  left: 50%;
  bottom: 4px;
  margin-left: -3.5px;
  box-shadow: 0 0 0 1.5px var(--bg);
}

.cal-legend { padding: 0 4px; color: var(--muted); font-size: 13px; }
