@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: light;
  --paper: #f5f4ef;
  --surface: #fffefa;
  --ink: #211d28;
  --muted: #645d6a;
  --line: #ded9e2;
  --primary: #462480;
  --primary-soft: #eee6fa;
  --lime: #d8fa6f;
  --green: #165947;
  --green-soft: #edf7eb;
  --danger: #a62f46;
  --display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  font: 16px/1.45 Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, select { font: inherit; }
button { touch-action: manipulation; cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 3px solid #794dc1; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2 { line-height: 1.05; }
h1 { font-family: var(--display); font-size: clamp(3rem, 9vw, 5.1rem); letter-spacing: -.02em; font-weight: 800; }
h2 { font-size: 1.3rem; letter-spacing: -.035em; }
h3 { font-size: 1rem; }
.shell { width: min(100% - 36px, 940px); margin-inline: auto; }
.app-header { border-bottom: 1px solid var(--line); background: var(--paper); }
.header-content { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 12px; }
.wordmark { padding: 0; display: inline-flex; align-items: center; min-height: 44px; border: 0; background: none; color: var(--ink); font-size: 1.07rem; font-weight: 800; letter-spacing: -.065em; }
.wordmark > span:last-child { color: var(--primary); }
.brand-icon { display: grid; place-items: center; width: 33px; height: 33px; margin-right: 8px; border-radius: 10px; background: var(--ink); color: var(--lime); }
.brand-icon i { position: relative; display: block; width: 17px; height: 2px; background: currentColor; transform: rotate(-29deg); }
.brand-icon i::before, .brand-icon i::after { position: absolute; content: ""; width: 4px; height: 11px; top: -4.5px; border-radius: 1px; background: currentColor; }
.brand-icon i::before { left: 2px; }
.brand-icon i::after { right: 2px; }
.header-unit { color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .01em; }
main { padding: 23px 0 calc(115px + env(safe-area-inset-bottom)); }
main:focus { outline: none; }
.hero { position: relative; isolation: isolate; overflow: hidden; display: grid; align-content: end; min-height: 218px; border-radius: 22px; padding: 24px 26px; color: #fdf9ff; background: #291741; }
.hero::after {
  content: ""; position: absolute; z-index: -1; width: 260px; height: 260px; right: -48px; top: -98px;
  border: 34px solid #5d3596; border-radius: 50%; box-shadow: 0 0 0 22px #392251, inset 0 0 0 19px #392251;
  transform: rotate(-22deg) scaleX(.76);
}
.hero h1 { color: var(--lime); }
.hero p { max-width: 36ch; margin-top: 7px; color: #e9def5; font-size: .91rem; }
.section-heading { margin: 28px 0 14px; }
.routine-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.routine-card, .exercise-card, .summary-card, .empty, .history-card { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; }
.routine-card { min-width: 0; display: flex; flex-direction: column; padding: 16px; }
.routine-card:nth-child(1) { --tint: #ede5fb; }
.routine-card:nth-child(2) { --tint: #e7eed9; }
.routine-card:nth-child(3) { --tint: #f8eadb; }
.routine-top { display: flex; align-items: start; justify-content: space-between; gap: 6px; }
.routine-title { display: inline-flex; align-items: center; padding: 4px 12px 6px; border-radius: 8px; background: var(--tint); font: 800 2rem/1 var(--display); text-transform: uppercase; letter-spacing: .02em; }
.routine-group { color: var(--muted); font-size: .8rem; font-weight: 600; margin: 9px 0 7px; }
.routine-exercises { margin: 0 0 15px; padding: 0; list-style: none; font-size: .84rem; overflow-wrap: anywhere; }
.routine-exercises li + li { margin-top: 4px; }
.routine-card > .button { width: 100%; margin-top: auto; }
.button { min-height: 44px; border-radius: 10px; border: 1px solid transparent; padding: 9px 14px; font-weight: 700; text-align: center; background: transparent; color: var(--ink); }
.button.primary { color: white; background: var(--primary); }
.button.primary:hover { background: #372061; }
.button.secondary { border-color: var(--line); background: var(--surface); }
.button.quiet { color: var(--primary); padding-inline: 8px; }
.button.danger { color: var(--danger); }
.button.small { font-size: .8rem; }
.back { padding: 0 4px 0 0; min-height: 44px; border: none; background: none; color: var(--primary); font-weight: 700; }
.page-intro { margin-bottom: 20px; }
.data-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.page-intro p { color: var(--muted); margin-top: 6px; }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 14px 16px; border-radius: 13px; background: var(--primary-soft); }
.resume p { font-size: .85rem; color: var(--muted); }
.tabbar { position: fixed; inset: auto 0 0; z-index: 2; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: env(safe-area-inset-bottom); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 560px; }
.tabs button { display: grid; place-items: center; align-content: center; gap: 5px; padding: 7px 2px; min-height: 61px; border: 0; background: none; color: var(--muted); font-size: .73rem; font-weight: 700; }
.tabs button[aria-current="page"] { color: var(--primary); }
.tab-icon { position: relative; width: 35px; height: 21px; display: grid; place-items: center; }
.tabs button[aria-current="page"] .tab-icon { background: var(--primary-soft); border-radius: 6px; }
.tab-icon::before, .tab-icon::after { content: ""; display: block; position: absolute; }
.icon-routines::before { width: 13px; height: 12px; border: 1.5px solid currentColor; border-radius: 2px; }
.icon-routines::after { width: 6px; height: 5px; border-block: 1px solid currentColor; }
.icon-chart::before { width: 14px; height: 12px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; }
.icon-chart::after { width: 2px; height: 3px; background: currentColor; box-shadow: 3px -2px, 6px -4px; bottom: 7px; left: 14px; }
.icon-records::before { width: 12px; height: 8px; top: 3px; border: 1.5px solid currentColor; border-radius: 1px 1px 6px 6px; }
.icon-records::after { width: 8px; height: 7px; bottom: 2px; border-bottom: 1.5px solid currentColor; background: linear-gradient(currentColor, currentColor) center / 1.5px 100% no-repeat; }
.icon-history::before { width: 14px; height: 14px; border: 1.5px solid currentColor; border-radius: 50%; }
.icon-history::after { width: 4px; height: 5px; border-left: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; top: 6px; left: 17px; }
.workout-top { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 16px; }
.count { font-weight: 700; color: var(--primary); font-size: .85rem; padding: 6px 10px; border-radius: 7px; background: var(--primary-soft); }
.workout-note { font-size: .85rem; color: var(--muted); margin-bottom: 13px; }
.exercise-list { display: grid; gap: 13px; }
.exercise-card { padding: 14px; }
.exercise-card h2 { font-size: 1.12rem; overflow-wrap: anywhere; }
.exercise-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.add-exercise { width: 100%; margin-top: 13px; border-style: dashed; color: var(--primary); }
.empty-note { color: var(--muted); font-size: .9rem; }
.records-group + .records-group { margin-top: 22px; }
.records-group h2 { margin-bottom: 9px; }
.record-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.record { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1px 12px; width: 100%; min-height: 56px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface); text-align: left; }
.record-name { font-weight: 700; overflow-wrap: anywhere; }
.record-value { grid-row: span 2; font: 800 1.45rem/1 var(--display); color: var(--primary); white-space: nowrap; }
.record-date { color: var(--muted); font-size: .8rem; }
.set-grid { display: grid; grid-template-columns: 2.25rem minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, .9fr) repeat(2, 44px); align-items: center; gap: 6px; }
.set-labels { padding: 0 5px 5px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.set-row { border-radius: 9px; padding: 4px 5px; margin-bottom: 4px; background: #f7f5f9; }
.set-row.checked { background: var(--green-soft); }
.set-number { text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.input, .set-input { width: 100%; min-height: 44px; border: 1px solid #d2c9dc; border-radius: 8px; color: var(--ink); background: #fff; padding: 7px 9px; font-size: 16px; }
.set-input { text-align: center; padding-inline: 1px; font-variant-numeric: tabular-nums; }
.set-input[aria-invalid="true"] { border: 2px solid var(--danger); }
.set-error { color: var(--danger); font-size: .82rem; margin: 3px 5px 8px; }
.previous { min-width: 0; min-height: 44px; padding: 3px; border: 1px solid #dbd0eb; border-radius: 7px; font-size: .76rem; font-weight: 700; color: var(--primary); background: var(--primary-soft); font-variant-numeric: tabular-nums; }
.previous-value { color: var(--muted); text-align: center; }
.check { width: 44px; height: 44px; border: 1px solid #cabfd4; border-radius: 8px; color: var(--primary); background: var(--surface); font-size: 1.15rem; font-weight: 800; }
.check[aria-pressed="true"] { border-color: var(--green); color: white; background: var(--green); }
.remove-set { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 8px; color: var(--danger); background: transparent; font-size: 1.25rem; font-weight: 700; }
.remove-set:active { background: #fbe8ee; }
.finish { margin-top: 15px; display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.finish p { font-size: .84rem; color: var(--muted); }
.finish-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
.empty { padding: 19px; }
.empty p, .card-subtitle { margin-top: 6px; color: var(--muted); font-size: .88rem; }
.selector { display: grid; gap: 6px; font-weight: 700; max-width: 420px; margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; margin-bottom: 13px; }
.summary-card { padding: 13px; }
.metric { font: 800 clamp(1.8rem, 6vw, 2.6rem)/1.1 var(--display); color: var(--primary); }
.chart-box { padding: 16px 12px 9px; }
.chart-box h2 { margin-left: 4px; }
.chart { display: block; width: 100%; height: 214px; margin-top: 8px; }
.table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .86rem; }
.table th, .table td { text-align: left; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: .76rem; }
.table tr:last-child td { border-bottom: 0; }
.history-list { display: grid; gap: 9px; }
.history-card { padding: 12px 15px; }
.history-card summary { min-height: 44px; padding: 9px 0; cursor: pointer; font-weight: 800; }
.history-card ul { margin: 0 0 6px; padding-left: 18px; }
.history-card li { margin: 5px 0; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.message { padding: 12px; margin-bottom: 12px; background: #fbe8ee; border-radius: 8px; color: var(--danger); font-size: .86rem; }
dialog { width: min(100% - 24px, 535px); max-height: 86dvh; overflow: auto; border: 1px solid var(--line); border-radius: 17px; padding: 18px; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: #21172bb3; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.dialog-intro { margin: 8px 0 12px; color: var(--muted); }
.edit-row { display: grid; grid-template-columns: minmax(0, 1fr) 58px 58px 44px; gap: 6px; align-items: end; margin-top: 7px; }
.edit-row label { display: grid; gap: 3px; font-size: .72rem; font-weight: 700; }
.edit-row .button { padding-inline: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 670px) {
  .routine-grid { grid-template-columns: 1fr; }
  .routine-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 9px; }
  .routine-top { grid-column: 1 / -1; }
  .routine-group { grid-column: 1 / -1; }
  .routine-exercises { margin-bottom: 0; }
  .routine-card > .button { align-self: end; }
}
@media (max-width: 400px) {
  .shell { width: calc(100% - 24px); }
  .hero { min-height: 175px; padding: 20px; }
  .exercise-card { padding: 10px; }
  .set-grid { gap: 4px; grid-template-columns: 1.45rem minmax(0, 1.35fr) minmax(0, .95fr) minmax(0, .85fr) repeat(2, 44px); }
  .set-row, .set-labels { padding-inline: 3px; }
  .routine-card { padding: 13px; }
}
