/* Тренировки — mobile-first styles. No external fonts or libraries. */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f4f5f7;
  --card: #ffffff;
  --card-2: #f3f4f7;
  --text: #111418;
  --muted: #687083;
  --line: #e3e6eb;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-soft: #e7eeff;
  --ok: #15803d;
  --ok-soft: #e5f5ea;
  --warn: #b45309;
  --warn-soft: #fcf1df;
  --bad: #c42b2b;
  --bad-soft: #fdeaea;
  --info-soft: #eef1f6;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
  --tabs-h: 62px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

body[data-user="zhenya"] {
  --accent: #d6336c;
  --accent-soft: #fde8f0;
}

[data-theme="dark"] {
  --bg: #0f1217;
  --card: #181c23;
  --card-2: #20252e;
  --text: #e9ecf1;
  --muted: #9aa3b2;
  --line: #2b313b;
  --accent: #6ea2ff;
  --accent-ink: #0b1220;
  --accent-soft: #1b2944;
  --ok: #5ad08a;
  --ok-soft: #15301f;
  --warn: #f2b54b;
  --warn-soft: #362a12;
  --bad: #ff7b7b;
  --bad-soft: #3a1919;
  --info-soft: #1f2630;
  --shadow: none;
  color-scheme: dark;
}

[data-theme="dark"] body[data-user="zhenya"] {
  --accent: #f483b0;
  --accent-soft: #3b1a2b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.sheet-open { overflow: hidden; }

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }
h2 { font-size: 22px; margin: 0 0 6px; }
h3 { font-size: 17px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; padding-left: 20px; }
li + li { margin-top: 6px; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#app { max-width: 600px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }

.boot { text-align: center; color: #8a93a3; margin-top: 40vh; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 6px;
  padding: calc(var(--safe-t) + 6px) 10px 6px;
  background: var(--bg);
}
.top-title {
  margin: 0;
  font-size: 18px;
  font-weight: 750;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-gap { width: 44px; height: 44px; }

.sync-dot { width: 44px; height: 44px; border: 0; background: transparent; display: grid; place-items: center; padding: 0; }
.sync-dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.sync-dot.wait::after { background: var(--warn); }
.sync-dot.bad::after { background: var(--bad); }
.sync-dot.busy::after { background: var(--accent); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------------------------------------------------------------- layout */
.view { padding: 6px 14px calc(var(--tabs-h) + var(--safe-b) + 24px); }
body.no-tabs .view { padding-bottom: calc(var(--safe-b) + 28px); }
body.has-rest .view { padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 120px); }
body.no-tabs.has-rest .view { padding-bottom: calc(var(--safe-b) + 120px); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; align-items: flex-start; }
.row.gap { gap: 10px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.block { display: block; }
.accent-text { color: var(--accent); }
.danger-text { color: var(--bad) !important; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
[data-theme="dark"] .card { border: 1px solid var(--line); }
.card.accent { background: var(--accent-soft); box-shadow: none; border-color: transparent; }

.overline {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card-2);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.big-num { font-size: 26px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- icons & buttons */
.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 650;
  text-decoration: none;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.08s;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--card-2); color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 54px; font-size: 17px; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; border-radius: 12px; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-decoration: none;
  padding: 0;
}
.icon-btn[disabled] { opacity: 0.3; }
.icon-btn.small { width: 36px; height: 36px; }
.link { color: var(--accent); background: none; border: 0; padding: 0; font-weight: 650; text-decoration: none; }

/* ---------------------------------------------------------------- tabs */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--card);
  border-top: 1px solid var(--line);
  max-width: 600px;
  margin: 0 auto;
}
.tabs[hidden] { display: none; }
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 650;
}
.tab .icon { width: 24px; height: 24px; }
.tab.on { color: var(--accent); }

/* ---------------------------------------------------------------- forms */
.field {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  appearance: none;
  -webkit-appearance: none;
}
textarea.field { min-height: 72px; resize: vertical; line-height: 1.4; }
.field:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.label { font-weight: 650; font-size: 14px; }
.error { color: var(--bad); min-height: 1.3em; margin: 0; font-size: 14.5px; }

.stepper {
  display: grid;
  grid-template-columns: 34px minmax(40px, 1fr) 34px;
  align-items: center;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  overflow: hidden;
}
.step-btn { height: 100%; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; padding: 0; }
.step-btn:active { background: var(--line); }
.step-btn .icon { width: 18px; height: 18px; }
.step-input {
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.step-input::placeholder { color: var(--muted); opacity: 0.6; font-weight: 500; }
.step-input:focus { outline: none; background: var(--accent-soft); }

.choice { display: flex; gap: 4px; background: var(--card-2); padding: 4px; border-radius: 14px; }
.choice.wrap { flex-wrap: wrap; background: none; padding: 0; gap: 8px; }
.choice-btn {
  flex: 1;
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  font-weight: 650;
}
.choice.wrap .choice-btn { flex: 0 0 auto; background: var(--card-2); border-color: var(--line); }
.choice .choice-btn.on, .choice.wrap .choice-btn.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.scale-btn {
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  font-weight: 750;
  font-size: 16px;
  border-bottom-width: 3px;
}
.scale-btn.ok { border-bottom-color: var(--ok); }
.scale-btn.warn { border-bottom-color: var(--warn); }
.scale-btn.bad { border-bottom-color: var(--bad); }
.scale-btn.on.ok { background: var(--ok); color: #fff; }
.scale-btn.on.warn { background: var(--warn); color: #fff; }
.scale-btn.on.bad { background: var(--bad); color: #fff; }
[data-theme="dark"] .scale-btn.on { color: #0b1220; }
.scale-btn.clear { color: var(--muted); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 50px;
  height: 30px;
  flex: none;
  margin: 0;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background 0.2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

.checklist { list-style: none; padding: 0; margin: 12px 0 8px; display: grid; gap: 10px; }
.checklist li + li { margin-top: 0; }
.check-row { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; }
.checklist .check-row span { font-size: 14.5px; line-height: 1.4; color: var(--muted); }
.checklist .check-row b { color: var(--text); font-weight: 700; }
.check-row input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); }

/* ---------------------------------------------------------------- feedback */
.advice { border-radius: 12px; padding: 10px 12px; font-size: 14.5px; margin: 10px 0 0; background: var(--info-soft); }
.advice.ok { background: var(--ok-soft); color: var(--ok); }
.advice.warn { background: var(--warn-soft); color: var(--warn); }
.advice.bad { background: var(--bad-soft); color: var(--bad); }
.advice.info { background: var(--info-soft); color: var(--text); }

.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-t) + 10px);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  width: max-content;
  max-width: min(92vw, 520px);
  padding: 10px 14px;
  border-radius: 14px;
  background: #1f2430;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -160%);
  /* hidden after sliding up, so neither the pill nor its shadow shows at the top edge */
  visibility: hidden;
  transition: transform 0.25s, visibility 0s linear 0.25s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); pointer-events: auto; visibility: visible; transition: transform 0.25s, visibility 0s; }
.toast.bad { background: #b42323; }
.toast-btn { flex: none; border: 0; border-radius: 10px; padding: 8px 12px; background: rgba(255, 255, 255, 0.2); color: #fff; font-weight: 750; }

/* ---------------------------------------------------------------- sheet */
.sheet-root { position: fixed; inset: 0; z-index: 70; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); opacity: 0; transition: opacity 0.2s; }
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 600px;
  max-height: 90vh;
  max-height: 90dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding-bottom: var(--safe-b);
  transform: translateY(100%);
  transition: transform 0.22s ease-out;
}
.sheet-root.open .sheet-backdrop { opacity: 1; }
.sheet-root.open .sheet { transform: none; }
.sheet-head { position: relative; padding: 20px 56px 8px 18px; }
.sheet-grip { position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
.sheet-title { margin: 0; font-size: 18px; }
.sheet-x { position: absolute; right: 6px; top: 8px; }
.sheet-body { overflow-y: auto; padding: 6px 18px 18px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-body:empty { display: none; }
.sheet-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; padding: 12px 18px 14px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- login */
.login { min-height: 82vh; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding-top: 16px; }
.login-hero { text-align: center; }
.login-hero h1 { margin: 12px 0 4px; font-size: 30px; }
.logo {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 22px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #d6336c);
}
.logo .icon { width: 38px; height: 38px; }
.logo.small { width: 56px; height: 56px; border-radius: 18px; margin-bottom: 8px; }
.logo.small .icon { width: 30px; height: 30px; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 10px;
  border-radius: 20px;
  border: 2px solid var(--line);
  background: var(--card);
  font-weight: 750;
  font-size: 18px;
}
.who-initial { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; color: #fff; background: #2563eb; }
.who-btn[data-user="zhenya"] .who-initial { background: #d6336c; }
.who-btn.on[data-user="aleksei"] { border-color: #2563eb; }
.who-btn.on[data-user="zhenya"] { border-color: #d6336c; }
.login-form { display: flex; flex-direction: column; gap: 10px; }

/* ---------------------------------------------------------------- today */
.hello { padding: 2px 2px 0; }
.hello h2 { margin: 4px 0 2px; font-size: 26px; letter-spacing: -0.01em; }
.next h3 { font-size: 22px; margin: 2px 0; }
.mini-list { margin: 12px 0 14px; padding-left: 22px; }
.mini-list li { display: list-item; }
.mini-list li span:last-child { margin-left: 6px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
}
.chip[disabled] { opacity: 0.55; }
.dots { display: flex; gap: 6px; padding-top: 4px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--accent); }
.weeks { display: grid; grid-template-columns: repeat(13, 1fr); gap: 3px; margin: 10px 0 4px; }
.wk { height: 12px; border-radius: 4px; background: var(--line); }
.wk.past { background: var(--accent); opacity: 0.4; }
.wk.now { background: var(--accent); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
.wk.p2, .wk.p4 { border-radius: 4px; }
.weeks-legend { display: flex; justify-content: space-between; margin-bottom: 10px; }
.tips h3 { display: flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------- workout */
.w-head h2 { margin: 2px 0 0; font-size: 22px; }
.w-clock { text-align: right; }
.progress { height: 8px; border-radius: 999px; background: var(--card-2); overflow: hidden; margin-top: 12px; }
.progress span { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--accent); border-radius: inherit; transition: width 0.3s; }
.pain-btn {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-2);
  font-weight: 650;
}
.pain-btn.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pain-btn.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pain-btn.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

.ex-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
}
.card > .ex-head:only-child { min-height: 44px; }
.ex-title { min-width: 0; }
.ex-name { font-weight: 750; font-size: 16.5px; line-height: 1.25; }
.ex-meta { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.ex-count {
  min-width: 46px;
  height: 32px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--card-2);
  display: inline-grid;
  place-items: center;
  font-weight: 750;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.ex-count.ok { background: var(--ok-soft); color: var(--ok); }
.ex-count .icon { width: 18px; height: 18px; }
.thumb {
  width: 56px;
  height: 56px;
  flex: none;
  display: block;
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
  border: 1px solid var(--line);
}
.plan-row .thumb { width: 48px; height: 48px; border-radius: 10px; }
.ex-summary { margin: 8px 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: 12.5px; padding: 4px 9px; border-radius: 999px; background: var(--card-2); color: var(--muted); font-weight: 650; }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.ex-note { font-size: 14px; margin: 10px 0 0; }
.ex-last { font-size: 14px; margin: 10px 0 0; }

.sets { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.set-row { display: grid; grid-template-columns: 20px 1fr 1fr 46px; gap: 8px; align-items: center; }
.set-row.extra { grid-template-columns: 20px 1fr 1fr 46px 26px; }
.set-row.head { font-size: 12px; color: var(--muted); font-weight: 650; margin-bottom: -2px; }
.set-row.head span:nth-child(2), .set-row.head span:nth-child(3) { text-align: center; }
.set-n { font-weight: 750; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.set-bw { text-align: center; }
.set-other { grid-column: 2 / -1; margin-top: -4px; }
.set-del { width: 26px; height: 26px; border-radius: 50%; border: 0; background: var(--card-2); color: var(--muted); display: grid; place-items: center; padding: 0; }
.set-del .icon { width: 14px; height: 14px; }
.check {
  width: 46px;
  height: 44px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  transition: background 0.15s, transform 0.08s;
}
.check:active { transform: scale(0.94); }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check .icon { width: 22px; height: 22px; }
.set-row.done .stepper { background: var(--accent-soft); border-color: transparent; }
.ex-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.pick {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card-2);
  text-align: left;
}
.pick.on { border-color: var(--accent); background: var(--accent-soft); }
.pick-name { font-weight: 750; }

/* rest timer */
.rest {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--tabs-h) + var(--safe-b));
  z-index: 40;
  max-width: 600px;
  margin: 0 auto;
  padding: 6px 12px 8px;
}
.rest[hidden] { display: none; }
body.no-tabs .rest { bottom: 0; padding-bottom: calc(var(--safe-b) + 10px); }
.rest-bar {
  height: 4px;
  margin: 0 6px 6px;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(var(--p, 1));
  transition: transform 0.25s linear;
}
.rest-row {
  display: grid;
  grid-template-columns: 58px 1fr 58px 44px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 18px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.rest-btn { height: 46px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.2); font-weight: 750; font-size: 15px; display: grid; place-items: center; padding: 0; }
[data-theme="dark"] .rest-btn { background: rgba(0, 0, 0, 0.15); }
.rest-main { text-align: center; min-width: 0; }
.rest-label { font-size: 12.5px; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rest-time { font-size: 30px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.rest.done .rest-row { background: var(--ok); color: #fff; animation: pulse 0.9s ease-in-out 3; }
.rest.done .rest-bar { background: var(--ok); }
@keyframes pulse { 50% { transform: scale(1.03); } }

/* ---------------------------------------------------------------- technique */
.tech-head p { margin: 0 0 4px; }
.figure { margin: 12px 0 6px; }
.figure-img {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
}
.figure-img.single img { display: block; max-width: 100%; max-height: 320px; object-fit: contain; }
.figure-img.frames { position: relative; height: 290px; cursor: pointer; }
.figure-img.frames img {
  position: absolute;
  top: 8px;
  left: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  object-fit: contain;
  transition: opacity 0.35s;
}
.figure-img.frames .f1 { opacity: 0; }
.figure-img.frames.show-1 .f0 { opacity: 0; }
.figure-img.frames.show-1 .f1 { opacity: 1; }
.frame-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.frame-btn { min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card-2); font-size: 14px; font-weight: 650; }
.frame-btn.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.frame-bar .icon-btn { margin-left: auto; }
figcaption { margin-top: 6px; font-size: 13.5px; color: var(--muted); }
.attrib { font-size: 12px; color: var(--muted); margin: 4px 0 12px; }
.attrib span { display: block; }
.attrib a { color: inherit; }
.tech-sec h3 { font-size: 16px; margin: 18px 0 6px; }
.tech-sec ul, .tech-sec ol { display: grid; gap: 6px; }
.tech-sec li + li { margin-top: 0; }
.tech .btn { margin-top: 4px; }

/* ---------------------------------------------------------------- lists */
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li + li { margin-top: 0; border-top: 1px solid var(--line); }
.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: none;
  text-align: left;
}
.link-row > div { flex: 1; min-width: 0; }
.link-row > .icon { color: var(--muted); }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.plain li + li { margin-top: 0; }
.plan-list { list-style: none; padding: 0; margin: 0; }
.plan-list li + li { margin-top: 0; border-top: 1px solid var(--line); }
.plan-row { display: grid; grid-template-columns: 48px 1fr 20px; gap: 12px; align-items: center; padding: 10px 0; color: inherit; text-decoration: none; }
.plan-row > .icon { color: var(--muted); }
.plan-name { font-weight: 650; }
.tabs-inline { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
[data-theme="dark"] .tabs-inline { border: 1px solid var(--line); }
.tab-inline { flex: 1; min-height: 42px; border: 0; border-radius: 11px; background: transparent; font-weight: 750; }
.tab-inline.on { background: var(--accent); color: var(--accent-ink); }

/* ---------------------------------------------------------------- progress */
.bars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; align-items: end; height: 120px; margin: 18px 0 6px; }
.bar-col { display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; height: 100%; }
.bar { position: relative; min-height: 4px; height: calc(var(--h, 0) * 84px + 4px); border-radius: 6px 6px 3px 3px; background: var(--accent); }
.bar.zero { background: var(--line); }
.bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 750; }
.bar-label { font-size: 10.5px; color: var(--muted); text-align: center; white-space: nowrap; }
.chart { display: block; width: 100%; height: auto; margin: 6px 0; overflow: visible; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-line.faint { stroke: var(--muted); stroke-width: 1.2; opacity: 0.45; }
.chart-line.alt { stroke: var(--warn); }
.chart-dot { fill: var(--accent); }
.chart-dot.faint { fill: var(--muted); opacity: 0.6; }
.chart-dot.alt { fill: var(--warn); }
.chart-label { font-size: 11px; fill: var(--muted); }
.legend { display: flex; gap: 16px; }
.lg::before { content: ""; display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--accent); }
.lg.alt::before { background: var(--warn); }
.pain-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.pain-cell { padding: 8px; border-radius: 12px; background: var(--card-2); text-align: center; }
.pain-cell.ok { background: var(--ok-soft); }
.pain-cell.warn { background: var(--warn-soft); }
.pain-cell.bad { background: var(--bad-soft); }
.done-card { text-align: center; }
.done-card ul { text-align: left; }
.note { white-space: pre-wrap; padding: 10px 12px; border-radius: 12px; background: var(--card-2); }

/* ---------------------------------------------------------------- diary */
.date-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; margin-bottom: 10px; }
.date-title { text-align: center; font-weight: 750; font-size: 17px; }
.diary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.diary-card > .stack.tight { margin-bottom: 14px; }
.diary-field { display: flex; flex-direction: column; gap: 4px; }
.diary-label { font-weight: 650; font-size: 14px; }

@media (max-width: 360px) {
  .set-row { grid-template-columns: 16px 1fr 1fr 42px; gap: 6px; }
  .stepper { grid-template-columns: 30px minmax(36px, 1fr) 30px; }
  .check { width: 42px; }
}

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