/* Powerlifting Plan & Progress — cream and clay design system.
   Layout: an app shell. A sticky sidebar on the left, a reading column on the right made of
   soft cards on a warm cream ground; on phones the sidebar becomes a slide-over drawer.
   A deliberately light-only look (cream is the brief), so every colour is set explicitly. */
:root {
  --cream: #F3EEE4;
  --ivory: #FBF9F4;
  --paper: #FFFDF9;
  --sand: #E7DFD0;
  --sand-2: #D8CDBA;
  --ink: #1D1B18;
  --ink-2: #4E4943;
  --ink-3: #847D72;
  --clay: #D46B45;
  --clay-strong: #B0502C;
  --clay-mid: #E9A27F;
  --clay-soft: #F7E3D7;
  --clay-ring: rgba(212, 107, 69, 0.22);
  --sage: #4F7550;
  --sage-soft: #E2EADB;
  --rose: #B0443A;
  --rose-soft: #F4DEDA;

  --shadow-1: 0 1px 2px rgba(70, 45, 20, 0.05), 0 1px 1px rgba(70, 45, 20, 0.03);
  --shadow-2: 0 18px 40px -20px rgba(90, 55, 25, 0.28), 0 3px 8px rgba(90, 55, 25, 0.05);
  --radius: 18px;
  --radius-sm: 11px;

  --font-display: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Consolas, monospace;

  --ease: cubic-bezier(0.22, 0.75, 0.18, 1);
  --sidebar-w: 268px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--clay-strong); text-decoration-thickness: 1px; text-underline-offset: 3px; transition: color 0.2s var(--ease); }
a:hover { color: var(--clay); }
a.broken { color: var(--ink-3); text-decoration: line-through; }
:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--clay-soft); }

.ic { width: 18px; height: 18px; flex: none; stroke-width: 1.75; }

/* ---------- Ambient background ---------- */
.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.55; }
.blob.b1 { width: 520px; height: 520px; background: radial-gradient(circle, #F2C7AE 0%, rgba(242, 199, 174, 0) 70%); top: -160px; right: -120px; animation: drift1 26s ease-in-out infinite alternate; }
.blob.b2 { width: 460px; height: 460px; background: radial-gradient(circle, #EADBC2 0%, rgba(234, 219, 194, 0) 70%); bottom: -180px; left: 18%; animation: drift2 32s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(-90px, 70px) scale(1.08); } }
@keyframes drift2 { to { transform: translate(110px, -60px) scale(0.94); } }

/* ---------- App shell ---------- */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding-block: 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: 14px;
  background: rgba(251, 249, 244, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--sand);
  display: flex; flex-direction: column; gap: 18px;
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); padding: 4px 6px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--ink); display: grid; place-items: center; box-shadow: var(--shadow-1); transition: transform 0.4s var(--ease); }
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.05); }
.brand-name { font-family: var(--font-display); font-size: 1.12rem; line-height: 1.1; font-weight: 500; letter-spacing: -0.01em; }
.brand-name small { display: block; font-family: var(--font-body); font-size: 0.72rem; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 2px; }

.nav ul { list-style: none; margin: 0; padding: 0; }
.nav > ul { display: flex; flex-direction: column; gap: 2px; }
.nav-top {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 0.93rem;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), transform 0.25s var(--ease);
}
.nav-top:hover { background: rgba(231, 223, 208, 0.6); color: var(--ink); }
.nav-top.current, .nav-group.in-group > .nav-top { color: var(--ink); background: var(--paper); box-shadow: var(--shadow-1); }
.nav-top.current .ic, .nav-group.in-group > .nav-top .ic { color: var(--clay); }
.nav-children { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.4s var(--ease); }
.nav-group.in-group .nav-children { grid-template-rows: 1fr; }
.nav-children > div { overflow: hidden; }
.nav-children ul { margin: 4px 0 8px 19px; padding-left: 12px; border-left: 1px solid var(--sand); }
.nav-children a {
  display: block; padding: 5px 10px; border-radius: 8px; text-decoration: none;
  color: var(--ink-2); font-size: 0.86rem; line-height: 1.35;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.nav-children a:hover { background: rgba(231, 223, 208, 0.55); color: var(--ink); }
.nav-children a.current { background: var(--clay-soft); color: var(--clay-strong); font-weight: 600; }
.nav-sub { display: block; font-size: 0.76rem; color: var(--ink-3); font-weight: 400; }
.nav-children a.current .nav-sub { color: var(--clay-strong); opacity: 0.8; }

.sidebar-foot { margin-top: auto; padding: 12px; border-radius: var(--radius-sm); background: var(--paper); border: 1px solid var(--sand); font-size: 0.8rem; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot strong { color: var(--ink); font-weight: 600; }
.mini-progress { height: 6px; border-radius: 99px; background: var(--sand); overflow: hidden; }
.mini-progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--clay-mid), var(--clay)); transition: width 1.2s var(--ease); }

.main-col { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding-block: 12px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
  background: rgba(243, 238, 228, 0.78);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid rgba(216, 205, 186, 0.6);
}
.crumbs { flex: 1; min-width: 0; font-size: 0.86rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--clay-strong); }
.crumbs .sep { margin: 0 6px; color: var(--sand-2); }
.save-pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 0.78rem; color: var(--ink-2); background: var(--paper); border: 1px solid var(--sand);
  padding: 4px 10px; border-radius: 99px; transition: all 0.3s var(--ease);
}
.save-pill .ic { width: 14px; height: 14px; color: var(--sage); }
.save-pill.saving { color: var(--clay-strong); border-color: var(--clay-mid); }
.save-pill.saving .ic { color: var(--clay); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn { display: none; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--sand); background: var(--paper); color: var(--ink); cursor: pointer; }
.scrim { display: none; }

main {
  width: 100%; max-width: 1060px;
  padding-block: 28px 64px;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}

/* ---------- Page transition and reveals ---------- */
#content.page-enter { animation: pageIn 0.6s var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.rise { animation: rise 0.7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.985); } to { opacity: 1; transform: none; } }
@supports (animation-timeline: view()) {
  .sections > .card { animation: reveal linear both; animation-timeline: view(); animation-range: entry 0% entry 35%; }
  @keyframes reveal { from { opacity: 0.001; transform: translateY(26px); } to { opacity: 1; transform: none; } }
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 { text-wrap: balance; color: var(--ink); }
#content h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(2rem, 1.4rem + 2.2vw, 2.9rem); line-height: 1.08; letter-spacing: -0.02em; margin: 6px 0 0; }
#content h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.55rem; line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 12px; }
#content h3 { font-family: var(--font-body); font-weight: 600; font-size: 1.05rem; margin: 0 0 10px; }
#content h2 a, #content h1 a { color: inherit; text-decoration: none; }
#content h2 a:hover { color: var(--clay-strong); }
#content p, #content li { max-width: 72ch; }
#content p { margin: 0 0 12px; color: var(--ink-2); }
#content strong { color: var(--ink); font-weight: 600; }
#content ul, #content ol { padding-left: 1.3em; color: var(--ink-2); }
#content li { margin: 4px 0; }
#content li::marker { color: var(--clay); }
code { font-family: var(--font-mono); font-size: 0.85em; background: var(--clay-soft); color: var(--clay-strong); padding: 1px 6px; border-radius: 6px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--clay-strong);
}
.eyebrow .ic { width: 14px; height: 14px; }

/* ---------- Page head and sections ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head-text { min-width: 0; flex: 1 1 320px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-intro > .callout { margin-bottom: 16px; }
.page-intro > p { font-size: 1rem; }

.sections { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.card {
  background: var(--paper);
  border: 1px solid var(--sand);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-1);
  min-width: 0;
  transition: box-shadow 0.35s var(--ease), border-color 0.35s var(--ease), transform 0.35s var(--ease);
}
.card:hover { box-shadow: var(--shadow-2); border-color: var(--sand-2); }
.card > :last-child, .subcard > :last-child { margin-bottom: 0; }
.subcard { border-top: 1px dashed var(--sand); padding-top: 18px; margin-top: 18px; }
.subcard h3 { display: flex; align-items: center; gap: 10px; }
.subcard h3::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--clay); box-shadow: 0 0 0 4px var(--clay-soft); }

/* Home guide sections sit in a grid */
.page-home .sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.page-home .sections > .card.wide { grid-column: 1 / -1; }

.page-foot { margin-top: 28px; display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem; }
.page-foot p { color: var(--ink-3) !important; margin: 0 !important; }
.page-foot a, .chips a {
  display: inline-block; margin: 3px 2px; padding: 4px 12px; border-radius: 99px;
  background: var(--paper); border: 1px solid var(--sand); color: var(--ink-2); text-decoration: none; font-size: 0.84rem;
  transition: all 0.25s var(--ease);
}
.page-foot a:hover, .chips a:hover { border-color: var(--clay-mid); color: var(--clay-strong); background: var(--clay-soft); transform: translateY(-1px); }
#content p.chips { display: flex; flex-wrap: wrap; gap: 8px; max-width: none; margin: 0; }
.chips a { margin: 0; }

/* ---------- Buttons ---------- */
.btn, button, .button-like {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 500 0.9rem/1 var(--font-body);
  padding: 10px 16px; border-radius: 99px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--sand-2); background: var(--paper); color: var(--ink);
  transition: transform 0.2s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease);
}
.btn:hover, button:hover, .button-like:hover { border-color: var(--ink-3); transform: translateY(-1px); box-shadow: var(--shadow-1); color: var(--ink); }
.btn:active, button:active { transform: translateY(0) scale(0.98); }
.btn-primary, #content form button[type=submit], .confirm-yes, #editor-save {
  background: var(--ink); color: var(--ivory); border-color: var(--ink);
}
.btn-primary:hover, #content form button[type=submit]:hover, .confirm-yes:hover, #editor-save:hover { background: var(--clay-strong); border-color: var(--clay-strong); color: #fff; box-shadow: 0 10px 24px -10px rgba(176, 80, 44, 0.6); }
.btn-ghost { background: transparent; }
.btn .arrow { transition: transform 0.3s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
.btn-small { padding: 7px 12px; font-size: 0.82rem; }
.edited-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; color: var(--clay-strong); background: var(--clay-soft); padding: 5px 10px; border-radius: 99px; }
.edited-chip .ic { width: 14px; height: 14px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--sand); border-radius: 14px; background: var(--paper); }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--sand); }
th { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); background: var(--ivory); white-space: nowrap; }
tbody tr { transition: background 0.2s var(--ease); }
tbody tr:hover { background: #FBF4EC; }
tbody tr:last-child td { border-bottom: 0; }
td { color: var(--ink-2); }
td strong { color: var(--ink); }

/* ---------- Callouts ---------- */
.callout {
  --tone: var(--clay); --tone-soft: var(--clay-soft);
  border-radius: 14px; margin: 14px 0; background: linear-gradient(180deg, var(--tone-soft), rgba(255, 253, 249, 0.6) 140%);
  border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent);
  padding: 14px 16px; overflow: hidden;
}
.callout.tone-calm { --tone: var(--ink-3); --tone-soft: #F1ECE2; }
.callout.tone-good { --tone: var(--sage); --tone-soft: var(--sage-soft); }
.callout.tone-alert { --tone: var(--rose); --tone-soft: var(--rose-soft); }
.callout-title { display: flex; align-items: flex-start; gap: 12px; list-style: none; }
.callout-title::-webkit-details-marker { display: none; }
details.callout > summary { cursor: pointer; }
.callout-icon { width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--paper); color: var(--tone); box-shadow: var(--shadow-1); }
.callout-icon .ic { width: 17px; height: 17px; }
.callout-head { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding-top: 1px; }
.callout-type { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--tone); }
.callout-text { font-weight: 600; color: var(--ink); line-height: 1.4; }
.callout .chev { margin-top: 6px; color: var(--ink-3); transition: transform 0.35s var(--ease); }
details.callout[open] > summary .chev { transform: rotate(180deg); }
.callout-body { margin: 10px 0 0 44px; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-body .table-wrap { margin: 8px 0; }
details.callout[open] > .callout-body { animation: unfold 0.45s var(--ease) both; }
@keyframes unfold { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Forms and inputs ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--ivory);
  border: 1px solid var(--sand); border-radius: 10px; padding: 7px 10px;
  transition: border-color 0.2s var(--ease), box-shadow 0.25s var(--ease), background 0.2s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--sand-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--clay); box-shadow: 0 0 0 4px var(--clay-ring); background: var(--paper); }
input::placeholder, textarea::placeholder { color: #B3AA9C; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23847D72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
td input, td select { width: 100%; min-width: 84px; padding: 6px 9px; font-size: 0.87rem; }
td input[type=number] { min-width: 64px; }
input[type=checkbox] {
  appearance: none; -webkit-appearance: none; width: 20px; height: 20px; padding: 0; margin: 0 8px 0 0;
  border-radius: 6px; border: 1.5px solid var(--sand-2); background: var(--paper); vertical-align: -4px; cursor: pointer;
  display: inline-grid; place-content: center; transition: background 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.2s var(--ease);
}
input[type=checkbox]::after {
  content: ""; width: 10px; height: 6px; border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0); margin-top: -2px; transition: transform 0.3s var(--ease);
}
input[type=checkbox]:checked { background: var(--clay); border-color: var(--clay); }
input[type=checkbox]:checked::after { transform: rotate(-45deg) scale(1); }
input[type=checkbox]:active { transform: scale(0.9); }
li.task { list-style: none; margin-left: -1.3em; padding: 4px 0; transition: color 0.3s var(--ease); }
li.task:has(input:checked) { color: var(--ink-3); }
.own-goal { width: min(70%, 420px); }
.e1rm { display: block; margin-top: 4px; font-size: 0.74rem; font-weight: 600; color: var(--clay-strong); font-family: var(--font-mono); }
.e1rm:empty { display: none; }
.computed { font-weight: 600; color: var(--ink); font-family: var(--font-mono); font-size: 0.86rem; }

#content form { display: flex; flex-direction: column; gap: 14px; }
#content form p { margin: 0; max-width: none; }
#content form label { display: inline-flex; flex-direction: column; gap: 5px; margin: 0 14px 6px 0; font-size: 0.8rem; font-weight: 500; color: var(--ink-2); }
#content form label:has(input[type=checkbox]) { flex-direction: row; align-items: center; font-size: 0.9rem; }
#content form input[type=number] { width: 110px; }
.lift-inputs { display: flex; flex-wrap: wrap; gap: 4px 0; margin-top: 6px; }
.form-label { display: block; font-weight: 600; color: var(--ink); font-size: 0.92rem; }
.form-hint { font-weight: 400; color: var(--ink-3); font-size: 0.82rem; }

.confirm-box {
  margin: 12px 0; padding: 14px 16px; max-width: 560px; border-radius: 14px;
  background: var(--paper); border: 1px solid var(--clay-mid); box-shadow: var(--shadow-2);
  animation: rise 0.4s var(--ease) both;
}
.confirm-box p { margin: 0 0 10px !important; color: var(--ink) !important; }
.confirm-box button { margin-right: 6px; }

/* ---------- Editor ---------- */
.editor textarea { width: 100%; min-height: 55vh; font-family: var(--font-mono); font-size: 0.84rem; line-height: 1.55; padding: 14px; border-radius: 14px; }
.editor .wide { width: 100%; margin-top: 6px; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- Diagrams ---------- */
.mermaid { margin: 14px 0; overflow-x: auto; padding: 14px; border-radius: 14px; background: var(--ivory); border: 1px solid var(--sand); text-align: center; }
.mermaid .node.clickable { cursor: pointer; }
.mermaid .node.clickable rect, .mermaid .node.clickable polygon { transition: fill 0.25s var(--ease); }
.mermaid .node.clickable:hover rect, .mermaid .node.clickable:hover polygon { fill: var(--clay-soft) !important; }

/* ---------- Home: hero ---------- */
.home { display: flex; flex-direction: column; gap: 18px; margin-bottom: 40px; }
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: center; gap: 12px;
  padding: 44px 40px; border-radius: 26px;
  background:
    radial-gradient(circle at 1px 1px, rgba(132, 125, 114, 0.18) 1px, transparent 0) 0 0 / 22px 22px,
    linear-gradient(140deg, var(--paper) 0%, var(--ivory) 55%, #F8E9DE 100%);
  border: 1px solid var(--sand);
  box-shadow: var(--shadow-2);
}
.hero-title { font-family: var(--font-display); font-weight: 500; font-size: clamp(2.2rem, 1.3rem + 3.3vw, 3.7rem); line-height: 1.02; letter-spacing: -0.03em; margin: 14px 0 14px; }
.hero-title em { font-style: italic; color: var(--clay); }
.hero-lede { font-size: 1.05rem; color: var(--ink-2); max-width: 46ch; margin: 0 0 22px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-notice { margin-top: 16px; display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 12px; background: var(--clay-soft); color: var(--clay-strong); font-weight: 600; text-decoration: none; }
.hero-art { position: relative; min-height: 240px; display: grid; place-items: center; }
.hero-art svg.barbell { width: 100%; max-width: 420px; height: auto; overflow: visible; animation: float 7s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.barbell .plate { transform-box: fill-box; transform-origin: center; animation: plateL 0.9s var(--ease) both; }
.barbell .right .plate { animation-name: plateR; }
.barbell .plate:nth-child(2) { animation-delay: 0.12s; }
.barbell .plate:nth-child(3) { animation-delay: 0.24s; }
.barbell .collar { animation: fade 0.6s 0.4s var(--ease) both; }
@keyframes plateL { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: none; } }
@keyframes plateR { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.barbell .orbit { transform-origin: 210px 100px; animation: orbit 40s linear infinite; }
@keyframes orbit { to { transform: rotate(360deg); } }
.float-chip {
  position: absolute; display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 12px; background: rgba(255, 253, 249, 0.92);
  border: 1px solid var(--sand); box-shadow: var(--shadow-2); font-size: 0.8rem; color: var(--ink-2); white-space: nowrap;
  animation: chipIn 0.8s var(--ease) both, bob 6s ease-in-out infinite;
}
.float-chip strong { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }
.float-chip .ic { width: 15px; height: 15px; color: var(--clay); }
.float-chip.c1 { top: 4%; left: 0; animation-delay: 0.5s, 0s; }
.float-chip.c2 { bottom: 6%; right: 2%; animation-delay: 0.65s, 1.2s; }
.float-chip.c3 { bottom: 2%; left: 8%; animation-delay: 0.8s, 2.4s; }
@keyframes chipIn { from { opacity: 0; transform: translateY(12px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }

/* ---------- Home: KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 500; color: var(--ink-3); }
.kpi-label .ic { width: 16px; height: 16px; color: var(--clay); }
.kpi-value { font-family: var(--font-display); font-size: 2.1rem; line-height: 1.05; letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-value small { font-family: var(--font-body); font-size: 0.9rem; color: var(--ink-3); letter-spacing: 0; margin-left: 3px; }
.kpi-sub { font-size: 0.8rem; color: var(--ink-3); }
.kpi-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ring { width: 62px; height: 62px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .ring-track { stroke: var(--sand); }
.ring .ring-fill { stroke: var(--clay); stroke-linecap: round; transition: stroke-dashoffset 1.4s var(--ease); }
.bar { height: 8px; border-radius: 99px; background: var(--sand); overflow: hidden; margin-top: 4px; }
.bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--clay-mid), var(--clay)); transition: width 1.3s var(--ease); }

/* ---------- Home: lift cards ---------- */
.lifts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.lift { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.lift-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lift-name { font-weight: 600; color: var(--ink); }
.lift-tag { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.lift-value { font-family: var(--font-display); font-size: 2.3rem; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.lift-value small { font-family: var(--font-body); font-size: 0.9rem; color: var(--ink-3); }
.lift-value.muted { color: var(--ink-3); }
.track { position: relative; height: 10px; border-radius: 99px; background: var(--sand); margin: 14px 0 6px; }
.track .fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--clay-mid), var(--clay)); transition: width 1.4s var(--ease); }
.track .mark { position: absolute; top: -5px; width: 2px; height: 20px; background: var(--ink); border-radius: 2px; }
.track .mark::after { content: attr(data-label); position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.lift-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; color: var(--ink-3); font-family: var(--font-mono); }

/* ---------- Home: 12-week map ---------- */
.timeline-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.timeline-head h2 { margin: 0 !important; }
.weeks { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; }
.week {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 12px 4px 10px; border-radius: 12px; text-decoration: none; color: var(--ink);
  background: var(--ph, var(--clay-soft)); border: 1px solid transparent;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: rise 0.6s var(--ease) both; animation-delay: calc(var(--i) * 45ms);
}
.week:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); color: var(--ink); }
.week .wk { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 600; }
.week .dots { display: flex; gap: 3px; }
.week .dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(29, 27, 24, 0.18); }
.week .dot.on { background: var(--ink); }
.week.ph-b1 { --ph: #F7E3D7; }
.week.ph-dl { --ph: #ECE5D8; }
.week.ph-b2 { --ph: #F1C4AB; }
.week.ph-b3 { --ph: #E58E68; }
.week.ph-test { --ph: var(--ink); color: var(--ivory); }
.week.ph-test .dot { background: rgba(251, 249, 244, 0.3); }
.week.ph-test .dot.on { background: var(--ivory); }
.week.is-now { border-color: var(--ink); box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--clay); }
.week.is-now::after { content: ""; position: absolute; inset: -6px; border-radius: 16px; border: 2px solid var(--clay); opacity: 0; animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0% { opacity: 0.7; transform: scale(0.96); } 100% { opacity: 0; transform: scale(1.12); } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 0.78rem; color: var(--ink-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Data tools ---------- */
.data-tools { margin-top: 36px; padding: 22px 24px; border-radius: var(--radius); background: var(--ivory); border: 1px solid var(--sand); }
.data-tools h2 { font-family: var(--font-display); font-weight: 500; font-size: 1.3rem; margin: 0 0 6px; }
.data-tools p { color: var(--ink-2); font-size: 0.9rem; margin: 0 0 14px; max-width: 70ch; }
.data-tools .buttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Device sync panel ---------- */
.rs-panel { margin: 4px 0 18px; padding: 16px 18px; border-radius: 14px; background: var(--paper); border: 1px solid var(--sand); display: flex; flex-direction: column; gap: 12px; animation: rise 0.5s var(--ease) both; }
.rs-head { display: flex; gap: 12px; align-items: flex-start; }
.rs-head > .ic { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: var(--clay-soft); color: var(--clay-strong); flex: none; }
.rs-head strong { display: block; color: var(--ink); font-size: 0.95rem; }
.rs-head p { margin: 2px 0 0 !important; font-size: 0.86rem; }
.rs-state.is-error { color: var(--rose) !important; }
.rs-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rs-join { display: flex; flex-direction: column; gap: 6px; font-size: 0.84rem; color: var(--ink-2); }
.rs-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rs-row input { flex: 1 1 260px; min-width: 0; font-family: var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.rs-key-box { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; background: var(--ivory); border: 1px dashed var(--clay-mid); animation: rise 0.45s var(--ease) both; }
.rs-key-box p { margin: 0 !important; font-size: 0.86rem; }
.rs-key { font-size: 1rem; padding: 8px 12px; letter-spacing: 0.08em; user-select: all; word-break: break-all; }
.rs-choice { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 12px; background: var(--ivory); border: 1px solid var(--sand); }
.rs-choice p { margin: 0 !important; font-size: 0.86rem; color: var(--ink) !important; }
.rs-merge { font-size: 0.84rem !important; color: var(--ink-2) !important; }
.rs-card { margin: 4px 0 18px; background: linear-gradient(150deg, var(--paper), #F9EBE1); border-color: var(--clay-mid); }
.rs-card h2 { margin-top: 6px !important; }
.rs-steps { margin: 6px 0 16px; padding-left: 1.4em; display: flex; flex-direction: column; gap: 6px; }
.rs-steps li { padding-left: 4px; }
.rs-steps li::marker { font-family: var(--font-mono); font-weight: 600; color: var(--clay-strong); }
.rs-inline { margin: 0; }
.rs-erase { align-self: flex-start; color: var(--rose); border-color: var(--rose-soft); background: transparent; }
.rs-erase:hover { color: var(--rose); border-color: var(--rose); }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  right: calc(20px + env(safe-area-inset-right, 0px)); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}
.toast {
  display: inline-flex; align-items: center; gap: 10px; max-width: min(420px, calc(100vw - 40px));
  padding: 12px 16px; border-radius: 14px; background: var(--ink); color: var(--ivory); font-size: 0.88rem;
  box-shadow: 0 18px 40px -16px rgba(29, 27, 24, 0.55); animation: toastIn 0.5s var(--ease) both; pointer-events: auto;
}
.toast .ic { width: 17px; height: 17px; color: var(--clay-mid); }
.toast.leaving { animation: toastOut 0.4s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lifts { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 50; inset: 0 auto 0 0; width: min(86vw, 300px); height: 100%;
    background: var(--ivory); transform: translateX(-104%); transition: transform 0.45s var(--ease);
    box-shadow: 0 0 60px rgba(29, 27, 24, 0.2);
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
  body.nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(29, 27, 24, 0.32); opacity: 0; pointer-events: none; transition: opacity 0.4s var(--ease); }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .icon-btn { display: inline-grid; }
  .topbar { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  main { padding-block: 18px 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .hero { grid-template-columns: minmax(0, 1fr); padding: 30px 22px 22px; }
  .hero-art { min-height: 200px; }
  .weeks { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .card { padding: 18px; }
  .callout-body { margin-left: 0; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .save-pill span { display: none; }
  .float-chip.c3 { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .blob, .hero-art svg.barbell, .float-chip, .barbell .orbit, .week.is-now::after { animation: none !important; }
}
