/* Platy 4 PT — Swiss International Style, iOS-first.
   Palette: Swiss red, paper white, anthracite, steel. One accent, used hard. */
:root {
  --red: #DA291C;
  --red-dark: #B22217;
  --paper: #FAFAF8;
  --ink: #1C1C1E;
  --steel: #8E8E93;
  --line: #E3E3E0;
  --card: #FFFFFF;
  --ok: #2E7D32;
  --radius: 12px;
  --pad: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--paper); color: var(--ink);
  font-size: 16px; line-height: 1.45;
  padding-bottom: calc(64px + var(--safe-b));
  overscroll-behavior-y: contain;
}
body.login-mode { padding-bottom: 0; }

h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
h3 { font-size: 15px; font-weight: 600; }
.eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--steel);
}
.num { font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -1px; }
.muted { color: var(--steel); font-size: 13px; }

/* ---------- layout */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(250,250,248,0.92); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: calc(10px + var(--safe-t)) var(--pad) 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar img.logo { height: 26px; display: block; }
.view { padding: var(--pad); max-width: 680px; margin: 0 auto; }
.section { margin-bottom: 24px; }
.section > .eyebrow { display: block; margin-bottom: 8px; }

/* ---------- cards: signature element = red baseline rule + big numerals */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px var(--pad);
  margin-bottom: 10px; position: relative; overflow: hidden;
}
.card.rule::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 3px; background: var(--red);
}
.card .big { font-size: 34px; line-height: 1.05; }
.card .unit { font-size: 14px; font-weight: 600; color: var(--steel); margin-left: 2px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-grid .card { margin-bottom: 0; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.list-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px var(--pad);
  margin-bottom: 8px; display: flex; justify-content: space-between;
  align-items: center; gap: 10px; cursor: pointer;
}
.list-item:active { background: #F4F4F2; }
.chip {
  display: inline-block; font-size: 11px; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 100px;
  background: var(--ink); color: #fff;
}
.chip.red { background: var(--red); }
.chip.ghost { background: transparent; color: var(--steel); border: 1px solid var(--line); }

/* ---------- buttons & inputs */
button, .btn {
  font: inherit; border: none; cursor: pointer;
  border-radius: var(--radius); font-weight: 700;
}
.btn-primary {
  background: var(--red); color: #fff; width: 100%;
  padding: 15px; font-size: 17px;
}
.btn-primary:active { background: var(--red-dark); }
.btn-secondary {
  background: var(--ink); color: #fff; padding: 12px 16px; font-size: 15px;
}
.btn-ghost {
  background: transparent; color: var(--ink);
  border: 1.5px solid var(--ink); padding: 11px 16px; font-size: 15px;
}
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.btn-icon {
  background: #F0F0EE; color: var(--ink); width: 38px; height: 38px;
  border-radius: 10px; font-size: 19px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
button:disabled { opacity: 0.45; }

input, select, textarea {
  font: inherit; width: 100%; padding: 13px 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); font-size: 16px; /* 16px stops iOS zoom */
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); }
label { display: block; margin-bottom: 14px; }
label > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--steel); }

/* ---------- set logging table: the training card */
.ex-card { padding: 0; overflow: hidden; }
.ex-head { padding: 13px var(--pad) 10px; border-bottom: 1px solid var(--line); }
.ex-head .row { align-items: flex-start; }
.ex-name { font-size: 16px; font-weight: 700; line-height: 1.25; }
.ex-meta { font-size: 12.5px; color: var(--steel); margin-top: 3px; }
.ex-note { font-size: 13px; color: var(--ink); background: #FFF6E8;
  border-left: 3px solid #E8A33D; padding: 8px 10px; margin: 8px var(--pad) 0; border-radius: 6px; }
.set-row {
  display: grid; grid-template-columns: 40px 1fr 1fr 52px;
  gap: 8px; align-items: center; padding: 8px var(--pad);
  border-bottom: 1px solid #F0F0EE;
}
.set-row:last-child { border-bottom: none; }
.set-row .set-n { font-weight: 800; color: var(--steel); font-size: 14px; }
.set-row input { padding: 10px 8px; text-align: center; font-weight: 700; font-size: 18px; }
.set-row .done-btn {
  width: 44px; height: 40px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; color: var(--steel); font-size: 17px;
}
.set-row.done .done-btn { background: var(--ok); border-color: var(--ok); color: #fff; }
.set-row.done input { color: var(--steel); }
.set-head { display: grid; grid-template-columns: 40px 1fr 1fr 52px;
  gap: 8px; padding: 8px var(--pad) 4px; font-size: 11px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--steel); }

/* ---------- rest timer */
.rest-bar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(72px + var(--safe-b)); z-index: 30;
  background: var(--ink); color: #fff; border-radius: 14px;
  padding: 12px 16px; display: flex; align-items: center;
  justify-content: space-between; box-shadow: 0 8px 28px rgba(0,0,0,0.25);
}
.rest-bar .t { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- bottom tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 25;
  background: rgba(255,255,255,0.94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + var(--safe-b));
}
.tabbar a {
  text-decoration: none; color: var(--steel); text-align: center;
  font-size: 10.5px; font-weight: 600; padding: 4px 0;
}
.tabbar a .ic { display: block; font-size: 21px; line-height: 1.2; }
.tabbar a.active { color: var(--red); }

/* ---------- login */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  justify-content: center; padding: 32px 24px; max-width: 420px; margin: 0 auto;
}
.login-wrap .logo-big { width: 240px; margin: 0 auto 14px; display: block; }
.login-tag { text-align: center; margin-bottom: 36px; }
.swiss-rule { width: 46px; height: 4px; background: var(--red); margin: 18px auto; }
.user-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.user-pick button {
  padding: 18px 10px; background: #fff; border: 1.5px solid var(--line);
  font-size: 17px; font-weight: 700;
}
.user-pick button.sel { border-color: var(--red); color: var(--red); }

/* ---------- charts */
.chart-box { background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.chart-box canvas { max-height: 240px; }

/* ---------- misc */
.hint-card { display: flex; gap: 12px; align-items: flex-start; }
.hint-day {
  min-width: 46px; text-align: center; background: var(--ink); color: #fff;
  border-radius: 10px; padding: 6px 4px; font-size: 11px; font-weight: 700;
}
.hint-day.rest { background: var(--steel); }
.hint-day.ride, .hint-day.train { background: var(--red); }
.toast {
  position: fixed; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 100px;
  font-size: 14px; font-weight: 600; z-index: 99; box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }
.empty { text-align: center; color: var(--steel); padding: 36px 16px; }
.spin { text-align: center; padding: 40px; color: var(--steel); }
a { color: var(--red); }
.seg { display: flex; background: #ECECEA; border-radius: 11px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 9px; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 600; color: var(--steel); }
.seg button.sel { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.12); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- exercise icons (silhouette + equipment badge) */
.ex-vis { display: inline-flex; flex: 0 0 auto; line-height: 0; }
.ex-vis .ex-ic, .ex-vis .ex-img { border-radius: 10px; display: block; }
.ex-vis .ex-img { object-fit: cover; background: #fff; border: 1.5px solid var(--line); }
.ex-head-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ex-head-main .ex-name { line-height: 1.2; }
.ex-pick { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ex-pick > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
