/* DadStrength.
   Paletten är dragen ur logotypen: marinblå #0C263F och papper #F3F3F3.
   Accenten är samma kulör som marinen (210°) fast uppskruvad, så allt hänger ihop.
   Mörkt, stående, enhänt. Stora träffytor och text som går att läsa på armlängds avstånd. */

:root {
  --brand: #0c263f;
  --brand-lift: #16395c;
  --paper: #f3f3f3;

  --bg: #060f19;
  --surface: #0c1826;
  --surface-2: #112438;
  --line: #1c3149;
  --line-soft: rgba(126, 166, 209, 0.14);

  --text: #eaf2fb;
  --muted: #86a0be;
  --accent: #3b8fff;
  --accent-deep: #1d6be0;
  --done: #2fd08a;
  --warm: #f2a93b;
  --danger: #ff5e54;

  --radius: 16px;
  --radius-lg: 22px;
  --tap: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  padding-bottom: calc(var(--safe-bottom) + 20px);
  overscroll-behavior-y: contain;
}

/* Ljuset uppifrån, i logotypens blå. Ligger bakom allt och följer inte med i scrollen. */
body::before {
  content: '';
  position: fixed;
  inset: -20% -30% auto;
  height: 70vh;
  z-index: -1;
  background:
    radial-gradient(58% 52% at 22% 0%, rgba(59, 143, 255, 0.20), transparent 70%),
    radial-gradient(48% 46% at 88% 8%, rgba(22, 57, 92, 0.55), transparent 72%);
  pointer-events: none;
}

main { padding: 16px 16px 8px; max-width: 640px; margin: 0 auto; }

h1 { font-size: 30px; line-height: 1.1; margin: 4px 0 18px; letter-spacing: -0.8px; }
h2 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 30px 0 12px;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* --- Toppbar -------------------------------------------------------------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: linear-gradient(180deg, rgba(6, 15, 25, 0.96), rgba(6, 15, 25, 0.86));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line-soft);
}

#topbar .title { font-weight: 800; font-size: 19px; letter-spacing: -0.2px; }
#topbar .timer {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
#topbar .back {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
  padding: 8px 4px 8px 0;
  min-height: 44px;
}

/* Hur långt jag kommit i passet, som en hårfin linje längst ner i toppbaren. */
#topbar .progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--line-soft);
  overflow: hidden;
}
#topbar .progress i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, var(--accent-deep), var(--accent));
  box-shadow: 0 0 12px rgba(59, 143, 255, 0.65);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

/* --- Knappar -------------------------------------------------------------- */

button { font: inherit; color: inherit; }

.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 70px;
  padding: 16px;
  border: 0;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #4f9bff, var(--accent-deep));
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.3px;
  box-shadow: 0 12px 30px -12px rgba(59, 143, 255, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active { transform: scale(0.985); filter: brightness(0.94); }

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.danger {
  background: none;
  color: var(--danger);
  min-height: 56px;
  font-size: 17px;
  font-weight: 700;
  box-shadow: none;
}
.btn.small { min-height: var(--tap); font-size: 17px; }

.linkrow { display: flex; gap: 12px; margin-top: 14px; }
.linkrow .btn { font-size: 18px; min-height: var(--tap); border-radius: var(--radius); }

/* --- Menyn ---------------------------------------------------------------- */

.hero { padding-top: 6px; }

.hero h1 { margin-bottom: 6px; }
.hero .lede { color: var(--muted); margin: 0 0 18px; font-size: 16px; }

/* Kortet med nästa pass: vad som väntar och på vilka vikter. */
.next-card {
  margin-top: 14px;
  padding: 16px 16px 6px;
  background: linear-gradient(180deg, rgba(22, 57, 92, 0.55), rgba(12, 24, 38, 0.75));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.next-card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.next-card .head .label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--muted);
}
.next-card .head .count { margin-left: auto; color: var(--muted); font-size: 15px; }

.plan { list-style: none; margin: 0; padding: 0; }
.plan li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 15px;
}
.plan li:first-child { border-top: 0; }
.plan .n {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: rgba(59, 143, 255, 0.14);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}
.plan .nm { flex: 1; min-width: 0; }
.plan .scheme { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plan .w { min-width: 62px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plan .w .unit { margin-left: 3px; color: var(--muted); font-size: 12px; font-weight: 600; }
.plan .w.none { color: var(--muted); font-size: 13px; font-weight: 500; }

.passmark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(180deg, var(--brand-lift), var(--brand));
  border: 1px solid var(--line);
  font-size: 20px;
  font-weight: 800;
}

.rowlink {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.rowlink:active { transform: scale(0.99); }
.rowlink .label { color: var(--muted); }
.rowlink .value { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.rowlink .chev { color: var(--muted); font-size: 22px; line-height: 1; }

.login { padding-top: 30px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login input { min-height: 62px; font-size: 19px; }

/* --- Passvyns kedja ------------------------------------------------------- */

/* En grupp är en övning: hopfälld till en rad, eller utfälld med sina boxar. */
.group { scroll-margin-top: 88px; }
.group + .group { margin-top: 8px; }
.group.open { margin: 18px 0 22px; }

.ex-row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.ex-row:active { transform: scale(0.99); }
.ex-row .mark {
  display: grid;
  place-items: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.ex-row .name { font-size: 17px; font-weight: 600; }
.ex-row .meta { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ex-row .w {
  margin-left: auto;
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ex-row .w .unit { margin-left: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.ex-row .chev { margin-left: auto; color: var(--muted); font-size: 20px; line-height: 1; }
.ex-row .w + .chev { margin-left: 0; }
.ex-row.done { opacity: 0.5; }
.ex-row.done .mark { background: var(--done); border-color: var(--done); color: #04160e; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  padding: 0 2px;
}
.divider .pos {
  display: grid;
  place-items: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(59, 143, 255, 0.16);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}
.divider .name { flex: 1; min-width: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.4px; }
.divider .scheme { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.divider .skip {
  margin-left: 0;
  white-space: nowrap;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 15px;
  padding: 6px 0 6px 10px;
  min-height: 40px;
}

.box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  margin-bottom: 9px;
  padding: 10px 14px 10px 52px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, opacity 0.25s ease, transform 0.12s ease;
}
.box:active { transform: scale(0.99); }

/* Kedjan: en linje mellan boxarnas punkter, som fylls i takt med passet. */
.box:has(+ .box)::before,
.box:has(+ .setcontrols)::before {
  content: '';
  position: absolute;
  left: 26px;
  top: 50%;
  bottom: -10px;
  width: 2px;
  background: var(--line);
}
.box.done:has(+ .box)::before { background: rgba(47, 208, 138, 0.4); }

/* Punkten är också bocken — därför ligger .check till vänster, inte till höger. */
.box .check {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--bg);
  color: transparent;
  font-size: 15px;
  font-weight: 900;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.box .kicker { color: var(--muted); font-size: 15px; min-width: 78px; }
.box .detail {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 21px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.4px;
}
.box .unit { color: var(--muted); font-size: 15px; font-weight: 600; white-space: nowrap; }
.box .note { color: var(--muted); font-size: 15px; font-weight: 500; text-align: right; }

.box.active {
  border-color: rgba(59, 143, 255, 0.75);
  background: linear-gradient(180deg, rgba(59, 143, 255, 0.12), rgba(12, 24, 38, 0.9));
  box-shadow: 0 0 0 1px rgba(59, 143, 255, 0.25), 0 14px 34px -22px rgba(59, 143, 255, 0.9);
}
.box.active .check { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(59, 143, 255, 0.16); }
.box.active .kicker { color: var(--text); }

.box.done { opacity: 0.55; }
.box.done .check { background: var(--done); border-color: var(--done); color: #04160e; }
.box.warmup .kicker { color: var(--warm); font-weight: 600; }
.box.warmup .detail { font-size: 19px; }

.box.just-done .check { animation: pop 0.34s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pop {
  0% { transform: translateY(-50%) scale(0.5); }
  55% { transform: translateY(-50%) scale(1.22); }
  100% { transform: translateY(-50%) scale(1); }
}

.box input {
  width: 72px;
  min-height: 46px;
  padding: 6px 8px;
  background: rgba(6, 15, 25, 0.85);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  font: 800 21px/1 inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.box input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.box input.reps { width: 56px; }

.setcontrols { display: flex; gap: 10px; margin: 4px 0 10px; }
.setcontrols button {
  flex: 1;
  min-height: 48px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}
.setcontrols button:active { background: var(--surface); }

.question {
  margin: 12px 0 6px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(22, 57, 92, 0.6), rgba(12, 24, 38, 0.85));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.question.active {
  border-color: rgba(59, 143, 255, 0.75);
  box-shadow: 0 0 0 1px rgba(59, 143, 255, 0.25), 0 16px 40px -24px rgba(59, 143, 255, 0.9);
}
.question p { margin: 0 0 14px; font-size: 18px; font-weight: 700; }
.question .options { display: flex; gap: 10px; }
.question .options button {
  flex: 1;
  min-height: var(--tap);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 21px;
  font-weight: 800;
  transition: transform 0.12s ease;
}
.question .options button:active { transform: scale(0.97); }
.question .options button.picked {
  background: linear-gradient(180deg, #4f9bff, var(--accent-deep));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 26px -14px rgba(59, 143, 255, 0.9);
}

.hint { color: var(--muted); font-size: 15px; margin: 8px 2px 12px; }
.finish { margin: 34px 0 10px; }

/* --- Historik ------------------------------------------------------------- */

.session-row { display: flex; align-items: center; gap: 12px; }
.session-row .date { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.session-row .pass {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(180deg, var(--brand-lift), var(--brand));
  border: 1px solid var(--line);
  font-weight: 800;
}

/* Passets nyckeltal överst i detaljvyn. */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 26px; }
.stat {
  padding: 14px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}
.stat .v { font-size: 23px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
.stat .k { margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; }

.detail-ex {
  margin-bottom: 12px;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.detail-ex header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.detail-ex .name { font-weight: 800; font-size: 18px; letter-spacing: -0.3px; }
.detail-ex .sets { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.detail-ex .change {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.detail-ex .change .arrow { font-weight: 800; }
.detail-ex .change.up { color: var(--done); }
.detail-ex .change.down { color: var(--warm); }
.detail-ex .change.flat { color: var(--muted); }
.detail-ex.skipped { opacity: 0.5; }

.badge {
  margin-left: auto;
  white-space: nowrap;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.badge.success { background: rgba(47, 208, 138, 0.16); color: var(--done); }
.badge.fail { background: rgba(255, 94, 84, 0.16); color: var(--danger); }
.badge.skipped { background: var(--surface-2); color: var(--muted); }

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

/* --- Inställningar -------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  padding: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.tabs button {
  flex: 1;
  min-height: 46px;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}
.tabs button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 6px 16px -10px rgba(0, 0, 0, 0.9); }

.ex-row + .ex-card, .ex-card + .ex-row { margin-top: 10px; }
.ex-row { margin-bottom: 10px; }

.ex-card {
  margin-bottom: 12px;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ex-card .top { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.ex-card .top .mark {
  display: grid;
  place-items: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(59, 143, 255, 0.16);
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}
.ex-card .top .heading { flex: 1; min-width: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.3px; }
.ex-card .move {
  min-width: 46px;
  min-height: 46px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 18px;
}
.ex-card .move:disabled { opacity: 0.3; }

.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.3px; }
.field input, .field select { width: 100%; min-width: 0; }
.field.wide { grid-column: 1 / -1; }

input[type='text'], input[type='number'], input[type='password'], select {
  min-height: 52px;
  padding: 10px 13px;
  background: rgba(6, 15, 25, 0.85);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: 700 17px/1.2 inherit;
  font-variant-numeric: tabular-nums;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
select { appearance: none; }
input::placeholder { color: var(--muted); font-weight: 500; }

.checkline { display: flex; flex-direction: row; align-items: center; gap: 10px; min-height: 52px; }
.checkline input { width: 26px; min-width: 26px; height: 26px; accent-color: var(--accent); }
.checkline label { font-size: 16px; color: var(--text); }

.state-line { display: flex; align-items: center; margin-top: 12px; color: var(--muted); font-size: 15px; }
.state-line .remove {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 0 8px 14px;
  min-height: 44px;
}

.state-line .remove.ghost { color: var(--accent); margin-left: 0; padding-left: 0; padding-right: 14px; }
.ex-card .top .badge { margin-left: 0; }
.login form input + input { margin-top: 0; }
.modal form.actions input { margin-bottom: 4px; min-height: 58px; font-size: 18px; }

.savebar {
  position: sticky;
  bottom: 0;
  padding: 14px 0 calc(var(--safe-bottom) + 14px);
  background: linear-gradient(transparent, var(--bg) 30%);
}

/* --- Modal och toast ------------------------------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  background: rgba(3, 8, 14, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade 0.18s ease;
}
/* display: grid ovan slår ut webbläsarens egen regel för hidden — den måste vinna tillbaka. */
.modal[hidden] { display: none; }

.modal .sheet {
  width: 100%;
  max-width: 640px;
  padding: 24px 16px calc(var(--safe-bottom) + 24px);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--line);
  animation: rise 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal h3 { margin: 0 0 8px; font-size: 22px; letter-spacing: -0.4px; }
.modal p { margin: 0 0 16px; color: var(--muted); }
.modal ul { margin: 0 0 18px; padding-left: 20px; color: var(--muted); }
.modal li { padding: 2px 0; }
.modal .actions { display: flex; flex-direction: column; gap: 10px; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(18px); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 22px);
  z-index: 60;
  transform: translateX(-50%);
  padding: 13px 20px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.9);
  animation: rise 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
