:root {
  --bg: #0b0c0e;
  --surface: #141619;
  --surface-2: #1b1e22;
  --surface-3: #262a30;
  --line: #24282d;
  --text: #f1f3f5;
  --muted: #8d949e;
  --faint: #646b75;
  --accent: #c8f04a;
  --accent-ink: #12160a;
  --accent-soft: rgba(200, 240, 74, 0.1);
  --accent-line: rgba(200, 240, 74, 0.35);
  --danger: #ff6b5e;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; touch-action: manipulation; text-align: inherit; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.page { padding-top: 8px; padding-bottom: calc(108px + var(--safe-b)); }
.muted { color: var(--muted); }

/* ---------- Yläpalkki ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: var(--safe-t);
  background: rgba(11, 12, 14, 0.86);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
}
.top-row { display: flex; align-items: center; gap: 12px; min-height: 60px; }

.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.brand svg { width: 26px; height: 26px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; }
.top-date { margin-left: auto; color: var(--muted); font-size: 15px; }
.top-h1 { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; margin-right: auto; }

.top-title { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.top-title h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.icon-btn {
  width: 44px; height: 44px; margin-left: -10px;
  display: grid; place-items: center; border-radius: 12px; flex: none;
}
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { background: var(--surface-2); }

.rest {
  font-size: 13px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 6px 12px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.rest[hidden] { display: none; }

.progress { height: 2px; background: var(--line); }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }

/* ---------- Painikkeet ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  background: var(--surface-2); color: var(--text);
  font-weight: 650; font-size: 16px; text-align: center;
  border: 1px solid var(--line);
}
.btn:active { background: var(--surface-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:active { filter: brightness(0.92); }
.btn.danger { color: var(--danger); background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.block { display: flex; width: 100%; }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 4px;
  color: var(--accent); font-weight: 600; font-size: 15px;
}
.link-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.link-btn.danger { color: var(--danger); }

/* ---------- Otsikot ---------- */

.section {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 26px 2px 12px;
  font-size: 13px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.section-note { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); }
.group { margin: 18px 2px 8px; font-size: 15px; font-weight: 700; color: var(--text); }

/* ---------- Etusivu ---------- */

.live {
  display: flex; align-items: center; gap: 14px; width: 100%;
  margin-top: 8px; padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
}
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-ink); flex: none; animation: pulse 1.6s ease-in-out infinite; }
.live-text { display: flex; flex-direction: column; min-width: 0; }
.live-text strong { font-size: 17px; }
.live-text span { font-size: 14px; opacity: 0.75; }
.live-go { margin-left: auto; display: flex; align-items: center; gap: 2px; font-weight: 700; }
.live-go svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

@keyframes pulse { 50% { opacity: 0.3; } }

.days { display: grid; gap: 10px; }
.day {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  width: 100%; padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  transition: transform 0.12s ease, background 0.12s ease;
}
.day:active { transform: scale(0.985); background: var(--surface-2); }
.day.is-next { border-color: var(--accent-line); }
.day-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.day-name { font-size: 28px; font-weight: 750; letter-spacing: -0.03em; }
.day-meta { color: var(--text); font-size: 15px; opacity: 0.85; }
.day-last { color: var(--muted); font-size: 14px; }

.badge {
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: 5px 10px; border-radius: 999px;
}

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wk { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wk-d { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; }
.wk-box {
  width: 100%; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 11px; font-weight: 700; color: var(--accent-ink);
}
.wk.is-today .wk-d { color: var(--text); }
.wk.is-today .wk-box { border-color: var(--muted); }
.wk.is-done .wk-box { background: var(--accent); border-color: var(--accent); }

/* ---------- Kortit ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.ex-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 16px 16px 14px;
}
.ex-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin-right: auto; }
.ex-name { font-size: 17px; font-weight: 650; line-height: 1.25; letter-spacing: -0.01em; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meta .pr { color: var(--accent); font-weight: 650; }

.count { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; flex: none; }
.done-mark {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.done-mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.ex.is-complete:not(.is-open) .ex-name { color: var(--muted); }
.summary { padding: 0 16px 16px; margin-top: -4px; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }

.variants { display: flex; gap: 8px; padding: 0 16px 12px; flex-wrap: wrap; }
.chip {
  min-height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--muted);
}
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

.sets { padding: 0 12px; }
.set-head, .set {
  display: grid;
  grid-template-columns: 34px 1fr 1fr 52px;
  gap: 8px; align-items: center;
}
.set-head { padding: 0 4px 6px; font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.set-head span { text-align: center; }
.set-head span:first-child { text-align: left; }
.set { padding: 4px; border-radius: 14px; transition: background 0.15s ease; }
.set + .set { margin-top: 4px; }
.set-n { font-size: 15px; font-weight: 650; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }

.set input {
  width: 100%; min-width: 0; height: 50px;
  border-radius: 12px; border: 1.5px solid transparent;
  background: var(--surface-2);
  text-align: center; font-size: 20px; font-weight: 650;
  font-variant-numeric: tabular-nums;
  outline: none; -webkit-appearance: none; appearance: none;
}
.set input::placeholder { color: var(--faint); font-weight: 550; opacity: 1; }
.set input:focus { border-color: var(--accent); background: var(--surface-3); }

.set.is-done { background: var(--accent-soft); }
.set.is-done .set-n { color: var(--accent); }
.set.is-done input { background: transparent; }
.set.is-done input:focus { background: var(--surface-2); }

.tick {
  width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center; justify-self: end;
  border: 2px solid var(--surface-3); color: var(--faint);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.tick svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.tick:active { transform: scale(0.92); }
.tick.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.cardio .ex-head { padding: 14px 14px 14px 16px; }
.cardio.is-complete .ex-name { color: var(--muted); }

.ex-foot { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 8px; font-size: 13px; }

.shake { animation: shake 0.32s ease; }
@keyframes shake {
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ---------- Lopetuspalkki ---------- */

.finish-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 18px 0 calc(14px + var(--safe-b));
  background: linear-gradient(to bottom, rgba(11, 12, 14, 0), var(--bg) 40%);
}
.finish-bar .btn { min-height: 54px; font-size: 17px; border-radius: 16px; }

/* ---------- Alavalikko ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 16px calc(8px + var(--safe-b));
  background: rgba(11, 12, 14, 0.9);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  backdrop-filter: saturate(140%) blur(16px);
  border-top: 1px solid var(--line);
}
.in-workout .tabbar { display: none; }
.tab {
  flex: 1; max-width: 200px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; border-radius: 12px;
  font-size: 12px; font-weight: 600; color: var(--faint);
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.tab.on { color: var(--accent); }

/* ---------- Tilastot ---------- */

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 14px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line);
}
.tile-n { font-size: 26px; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile-n small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.tile-l { font-size: 13px; color: var(--muted); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.row + .row { border-top: 1px solid var(--line); }
.row:active { background: var(--surface-2); }
.row-main { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.row-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-val { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 76px; text-align: right; }

.spark { width: 64px; height: 24px; flex: none; overflow: visible; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

.session { overflow: hidden; }
.session summary {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
  padding: 14px 16px; cursor: pointer; list-style: none;
}
.session summary::-webkit-details-marker { display: none; }
.session-name { font-size: 16px; font-weight: 700; }
.session-date { grid-row: 1; grid-column: 2; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.session-meta { font-size: 13px; color: var(--muted); }
.session[open] summary { border-bottom: 1px solid var(--line); }
.session-list { list-style: none; padding: 6px 16px; }
.session-list li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; font-size: 14px; }
.session-list li + li { border-top: 1px solid var(--line); }
.session-list li span:first-child { color: var(--muted); }
.session-list li span:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.session-foot { padding: 0 12px 8px; }

.empty { margin-top: 28px; padding: 28px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--surface-3); border-radius: var(--radius); }
.empty .btn { margin-top: 16px; }
.note { margin: 28px 4px 0; font-size: 13px; color: var(--faint); text-align: center; }

/* ---------- Kaavio ---------- */

.chart-card { margin-top: 10px; padding: 16px 12px 10px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 8px; }
.chart-head h2 { font-size: 15px; font-weight: 650; }
.chart-head span { font-size: 13px; }
.chart { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: 0.1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart-empty { padding: 32px 8px; text-align: center; color: var(--muted); font-size: 14px; }
.tip {
  position: absolute; transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 12px; border-radius: 10px;
  background: var(--surface-3); border: 1px solid #333840;
  font-size: 13px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.tip strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.tip span { color: var(--muted); font-size: 12px; }
.tip[hidden] { display: none; }

.table-card { overflow: hidden; }
.log { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.log th { text-align: left; font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; padding: 12px 16px 8px; }
.log td { padding: 11px 16px; border-top: 1px solid var(--line); vertical-align: top; }
.log td:first-child { color: var(--muted); white-space: nowrap; width: 1%; }
.log td:last-child { font-weight: 600; }

/* ---------- Dialogi ja ilmoitus ---------- */

dialog {
  margin: auto auto 0; width: 100%; max-width: 560px;
  border: 0; padding: 0; background: transparent; color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog[open] { animation: rise 0.2s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }

.sheet {
  margin: 0 8px calc(8px + var(--safe-b));
  padding: 22px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.sheet h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; padding: 0 4px; }
.sheet p { margin-top: 6px; padding: 0 4px; color: var(--muted); font-size: 15px; }
.sheet-actions { display: grid; gap: 8px; margin-top: 20px; }
.sheet-actions .btn { min-height: 52px; width: 100%; }

#toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); z-index: 30;
  transform: translate(-50%, 12px);
  padding: 12px 18px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: 15px; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ---------- Ohjelma ja lomakkeet ---------- */

.chip { max-width: 100%; white-space: normal; line-height: 1.25; padding: 8px 14px; text-align: left; }

.ex-note { font-size: 13px; color: var(--accent); opacity: 0.85; }
.ex-foot { gap: 8px; }
.foot-right { display: flex; align-items: center; gap: 4px; }
.muted-btn { color: var(--muted); }
.muted-btn svg { width: 17px; height: 17px; }

.icon-btn.sm { width: 40px; height: 40px; margin: 0; border-radius: 10px; color: var(--muted); }
.icon-btn.sm svg { width: 20px; height: 20px; }
.icon-btn:disabled { opacity: 0.25; pointer-events: none; }

.add-ex { margin-top: 12px; gap: 8px; color: var(--accent); background: transparent; border-style: dashed; border-color: var(--surface-3); }
.add-ex svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; margin-right: 6px; flex: none; }
.btn:disabled { opacity: 0.35; pointer-events: none; }
.btn.block.danger { border-color: var(--line); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stack { display: grid; gap: 8px; }
.del-day { margin-top: 24px; }

.chev { color: var(--faint); flex: none; }
.chev svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
button.row { width: 100%; text-align: left; }

.tag {
  flex: none; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: 3px 8px; border-radius: 999px; vertical-align: 1px;
}
.tag.dim { color: var(--muted); background: var(--surface-2); }

.erow { display: flex; align-items: center; gap: 2px; padding-right: 8px; }
.erow + .erow { border-top: 1px solid var(--line); }
.erow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 14px 8px 14px 16px; }
.erow-main:active { background: var(--surface-2); }
.erow-main .row-name { white-space: normal; }

.field-label { display: block; margin: 18px 4px 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.page > .field-label:first-child { margin-top: 12px; }
.field {
  display: block; width: 100%; height: 50px; padding: 0 14px;
  border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font-size: 17px; outline: none; -webkit-appearance: none; appearance: none;
}
.field::placeholder { color: var(--faint); }
.field:focus { border-color: var(--accent); }
input[type="search"].field::-webkit-search-cancel-button { -webkit-appearance: none; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; min-width: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 46px; padding: 6px 10px; border-radius: 12px;
  background: var(--surface-2); border: 1.5px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.seg input:checked + span { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }

.stepper { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; }
.stepper button {
  height: 50px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface-2); border: 1.5px solid var(--line); color: var(--text);
}
.stepper button:active { background: var(--surface-3); }
.stepper button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.stepper input {
  height: 50px; width: 100%; text-align: center; border: 0; border-radius: 12px;
  background: transparent; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; outline: none;
}

.alt-list { display: grid; gap: 6px; }
.alt {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 4px 4px 4px 14px;
  border-radius: 12px; background: var(--surface-2); font-size: 15px; font-weight: 600;
}
.alt span { flex: 1; min-width: 0; }
.alt-list + .link-btn { margin-top: 4px; }

.check { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 4px; font-size: 15px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

.pick-list {
  margin-top: 10px; max-height: 42vh; max-height: 42dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg);
}
.pick {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 48px; padding: 10px 14px; text-align: left; font-size: 15px;
}
.pick + .pick { border-top: 1px solid var(--line); }
.pick span:first-child { flex: 1; min-width: 0; }
.pick:active { background: var(--surface-2); }
.pick:disabled { opacity: 0.35; }
.pick[hidden] { display: none; }
.pick-empty { padding: 16px; color: var(--muted); font-size: 14px; text-align: center; }
.new-btn { margin-top: 10px; color: var(--accent); }
.new-btn[hidden] { display: none; }

dialog { max-height: 100%; }
.sheet { max-height: calc(100dvh - 16px - var(--safe-b)); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet h2:focus { outline: none; }

.wk-box span { display: block; max-width: 100%; padding: 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty .btn { display: inline-flex; }
.pick-list[hidden] { display: none; }

/* ---------- Päivä ja historia ---------- */

a.day { color: inherit; }
.start-btn { margin-top: 12px; min-height: 56px; font-size: 17px; border-radius: 16px; }
.more-btn { margin-top: 10px; }
.filters { padding: 0 0 12px; }

.row-date { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-last { margin-top: 4px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row-last strong { color: var(--text); font-weight: 600; }
.plan-row .row-name { white-space: normal; }

.log-card { padding-bottom: 6px; overflow: hidden; }
.log-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.log-head .ex-name { margin-right: auto; }
.delta { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--accent); }
.delta.down { color: var(--muted); }
.sets-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sets-table th { font-size: 12px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 16px; text-align: left; }
.sets-table td { padding: 8px 16px; border-top: 1px solid var(--line); font-size: 16px; font-weight: 600; }
.sets-table td:first-child, .sets-table th:first-child { width: 70px; color: var(--muted); }
.log-prev { padding: 8px 16px 10px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.log-prev strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.log a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--surface-3); text-underline-offset: 3px; }

/* ---------- Pitkät nimet ---------- */

.days { grid-template-columns: minmax(0, 1fr); }
.day, .card, .list, .tile { min-width: 0; }
.day-name, .ex-name, .alt span, .sheet h2, .sheet p, .chip, .pick span, .row-last,
.erow-main .row-name, .plan-row .row-name, .session-list li span, .log-head .ex-name,
.sets-table td, .log td { overflow-wrap: anywhere; }
.top-title { flex: 1; }
.pick.is-target { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- Asetukset ---------- */

.hint { margin: -4px 4px 12px; font-size: 14px; color: var(--muted); }
.list + .hint { margin-top: 10px; }
.radio-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.radio-row + .radio-row { border-top: 1px solid var(--line); }
.radio-row input { position: absolute; opacity: 0; pointer-events: none; }
.radio-row .row-name { white-space: normal; }
.radio-dot {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  border: 2px solid var(--surface-3); display: grid; place-items: center;
}
.radio-row input:checked ~ .radio-dot { border-color: var(--accent); }
.radio-row input:checked ~ .radio-dot::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.radio-row input:checked ~ .row-main .row-name { color: var(--accent); }
.radio-row input:focus-visible ~ .radio-dot { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab { font-size: 11px; }
.tab circle { fill: none; stroke: currentColor; stroke-width: 2.2; }

/* ---------- Palaute ja yhteenveto ---------- */

.sets.bw .set-head, .sets.bw .set { grid-template-columns: 34px 1fr 52px; }

.set.just-done .tick, .set.just-pr .tick { animation: pop 0.34s cubic-bezier(0.3, 1.6, 0.5, 1); }
.set.just-done { animation: flash 0.5s ease-out; }
.set.just-pr { animation: prflash 1.1s ease-out; }
@keyframes pop { 0% { transform: scale(0.7); } 100% { transform: scale(1); } }
@keyframes flash { 0% { background: rgba(200, 240, 74, 0.28); } 100% { background: var(--accent-soft); } }
@keyframes prflash {
  0% { background: rgba(200, 240, 74, 0.45); box-shadow: 0 0 0 2px var(--accent); }
  100% { background: var(--accent-soft); box-shadow: 0 0 0 2px transparent; }
}

.hero {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin-top: 12px; padding: 26px 16px 22px; border-radius: var(--radius);
  background: radial-gradient(120% 90% at 50% 0%, rgba(200, 240, 74, 0.16), transparent 70%), var(--surface);
  border: 1px solid var(--accent-line);
}
.hero-mark {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  animation: heropop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.hero-mark svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.hero-title { margin-top: 14px; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.hero-sub { margin-top: 2px; font-size: 15px; color: var(--accent); font-weight: 600; }
@keyframes heropop { 0% { transform: scale(0.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.pr-line { margin: 12px 4px 0; font-size: 14px; font-weight: 600; color: var(--accent); }
.log-card.is-pr { border-color: var(--accent-line); }

.switch {
  position: relative; width: 50px; height: 30px; flex: none; border-radius: 999px;
  background: var(--surface-3); transition: background 0.2s ease;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--text); transition: transform 0.2s ease;
}
.radio-row input:checked ~ .switch { background: var(--accent); }
.radio-row input:checked ~ .switch::after { transform: translateX(20px); background: var(--accent-ink); }
.radio-row input:disabled ~ * { opacity: 0.5; }
.radio-row input[type="checkbox"]:checked ~ .row-main .row-name { color: var(--text); }

/* ---------- Ohitus ---------- */

.set.is-skipped { grid-template-columns: 34px 1fr 52px; }
.sets.bw .set.is-skipped { grid-template-columns: 34px 1fr 52px; }
.skip-label {
  display: flex; align-items: center; height: 50px; padding: 0 14px;
  border-radius: 12px; border: 1.5px dashed var(--surface-3);
  color: var(--faint); font-size: 15px; font-weight: 600;
}
.set.is-skipped .set-n { color: var(--faint); }
.tick.undo { border-style: dashed; }
.tick.undo svg { width: 20px; height: 20px; stroke-width: 2.2; }
.skip-mark { font-size: 13px; font-weight: 600; color: var(--muted); flex: none; }
.tile-d { margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--faint); font-variant-numeric: tabular-nums; }
.tile-d.up { color: var(--accent); }
.tile-d.down { color: var(--muted); }
.compare-note { margin: 8px 4px 0; font-size: 12px; color: var(--faint); }

/* ---------- Ohjaus treenin aikana ---------- */

.foot-left { display: flex; align-items: center; gap: 14px; }
.skipped-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 12px; margin-top: -4px; color: var(--muted); font-size: 15px; }
.skipped-row .link-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.bump {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  margin: 0 16px 12px; width: calc(100% - 32px); padding: 10px 14px;
  border-radius: 14px; border: 1.5px solid var(--accent-line);
  background: linear-gradient(90deg, var(--accent-soft), transparent);
  text-align: left;
}
.bump-main { font-size: 16px; font-weight: 700; color: var(--accent); }
.bump-sub { font-size: 12px; color: var(--muted); }
.bump:active { transform: scale(0.98); }

.set.is-next .tick { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.set.is-next input::placeholder { color: var(--muted); }

.rest { font-size: 15px; padding: 8px 14px; transition: background 0.3s ease, color 0.3s ease; }
.rest.is-ready { background: var(--accent); color: var(--accent-ink); }

.hero-more { margin-top: 2px; font-size: 13px; color: var(--muted); }
.hero-backup { margin-top: 10px; font-size: 14px; }
.tag.plain { text-transform: none; letter-spacing: 0; font-size: 12px; }
.set input.invalid { border-color: var(--danger); }

/* ---------- Pitkät nimet ikkunoissa ---------- */

.sheet { overflow-x: hidden; }
.sheet-actions { grid-template-columns: minmax(0, 1fr); }
.sheet .btn, .check span, .new-btn { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.live-text { flex: 1; }
.live-text strong, .ex-note, .compare-note, .hero-sub, .bump-main, .skipped-row span { overflow-wrap: anywhere; min-width: 0; }
