:root {
 color-scheme: dark;
 --bg: #101216;
 --surface: #1d2228;
 --surface-raised: #242a31;
 --panel: #15191e;
 --line: #30363d;
 --text: #f3f4f6;
 --muted: #a4adb8;
 --accent: #9acd78;
 --accent-text: #a8d88a;
 --accent-soft: #263426;
 --ink: #132011;
 --alternate: #a4c7f7;
 --target: #e8c684;
 --extra: #e9a29c;
 --error: #ffb1a7;
 font: 16px/1.49 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
 background: var(--bg);
 color: var(--text);
}

:root[data-theme="light"] {
 color-scheme: light;
 --bg: #f2f5f0;
 --surface: #fff;
 --surface-raised: #f2f7f0;
 --panel: #eaf0e8;
 --line: #d3ddd1;
 --text: #1a251c;
 --muted: #546457;
 --accent: #9bd380;
 --accent-text: #37632a;
 --accent-soft: #e3f0dd;
 --ink: #132011;
 --alternate: #386eab;
 --target: #8d5f17;
 --extra: #a73d38;
 --error: #9f332a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 290px; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
h1, h2, h3, h4 { line-height: 1.19; }
h1 { margin: 0; font-size: clamp(1.95rem, 3.8vw, 2.85rem); font-weight: 760; letter-spacing: -.042em; overflow-wrap: anywhere; }
h2 { margin: 0 0 12px; font-size: 1.12rem; font-weight: 720; letter-spacing: -.022em; }
h3 { margin: 0 0 7px; font-size: 1rem; }
h4 { margin: 7px 0 12px; font-size: .92rem; }
.muted { color: var(--muted); font-size: .87rem; }
.accent { color: var(--accent-text) !important; }
.error, .danger { color: var(--error); }
.error:empty { display: none; }
.copy { white-space: pre-wrap; overflow-wrap: anywhere; }
.row { display: flex; align-items: center; gap: 9px; }
.wrap { flex-wrap: wrap; }
.spread, .between { justify-content: space-between; }
.stack { display: grid; gap: 11px; }
.margin-top { margin-top: 15px; }
.empty { padding: 18px 0; }

.shell { max-width: 1360px; margin-inline: auto; padding: 0 clamp(14px, 3vw, 34px); }
.topbar {
 height: 66px;
 display: flex;
 align-items: center;
 justify-content: space-between;
 gap: 12px;
 border-bottom: 1px solid var(--line);
 margin-bottom: 24px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: .88rem; font-weight: 800; letter-spacing: .10em; }
.brand b { color: var(--muted); }
.brand-icon, .metric-icon, .login-icon {
 display: inline-grid; place-items: center; flex: 0 0 auto;
 background: var(--accent-soft); color: var(--accent-text);
 border: 1px solid color-mix(in srgb,var(--accent-text) 16%,var(--line));
 border-radius: 10px;
}
.brand-icon { width: 38px; height: 38px; }
.brand-icon svg { width: 22px; height: 22px; }
.main-wrap { min-width: 0; min-height: 68vh; padding-bottom: 28px; }
.authenticated .main-wrap { padding-bottom: calc(91px + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px; margin: 0 0 19px; }
.page-head p { color: var(--muted); margin: 5px 0 0; font-size: .92rem; }
.phase, .badge { display: inline-flex; align-items: center; gap: 7px; border-radius: 100px; padding: 6px 11px; color: var(--muted); font-size: .77rem; background: var(--panel); border: 1px solid var(--line); }
.phase { color: var(--accent-text); background: var(--accent-soft); }
.phase i { width: 7px; height: 7px; background: var(--accent-text); border-radius: 50%; }
.badge { white-space: normal; max-width: 100%; overflow-wrap: anywhere; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: clamp(13px, 2.2vw, 20px); margin-bottom: 14px; min-width: 0; }
.summary-grid, .info-grid, .exercise-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.summary-grid { margin-bottom: 15px; }
.summary-grid .card, .info-grid .card, .exercise-grid .card { margin: 0; }
.metric { min-height: 104px; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 4px; }
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 5px; font-size: .82rem; font-weight: 580; color: var(--muted); overflow-wrap: anywhere; }
.metric-icon { width: 34px; height: 34px; }
.metric-icon svg { width: 18px; height: 18px; }
.metric strong, .training-count strong { font-size: clamp(1.25rem, 3.2vw, 2rem); line-height: 1.15; font-weight: 750; letter-spacing: -.035em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-hint { color: var(--muted); font-size: .77rem; margin-top: auto; padding-top: 2px; overflow-wrap: anywhere; }
.compact .metric { min-height: 91px; }
.compact .metric strong, .info-grid .metric strong { font-size: clamp(1.19rem, 2.65vw, 1.55rem); }
.info-grid .metric { border-radius: 11px; background: var(--panel); padding: 12px; min-height: 81px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin: 0 0 11px; }
.section-head > div { min-width: 0; overflow-wrap: anywhere; }
.section-head h2 { margin: 0 0 4px; }
.section-head p { margin: 0; }
.quiet-link { display: inline-flex; align-items: center; gap: 5px; color: var(--accent-text); min-height: 30px; font-size: .83rem; font-weight: 640; }
.quiet-link svg { width: 15px; height: 15px; }
.back-link { margin: -4px 0 9px; }
.dashboard-chart { margin-bottom: 12px; }
.measure-button { margin-bottom: 16px; }
.training-summary { display: grid; gap: 10px; margin-bottom: 14px; }
.training-summary .card { margin: 0; }
.training-count { display: flex; flex-direction: column; gap: 5px; justify-content: center; }
.training-count strong { display: block; }
.training-count p { margin: 0; }
.title-label { margin-bottom: 4px !important; }
.next-card .section-head h2 { font-size: 1.32rem; margin: 0; }

button, .button {
 font: inherit;
 font-size: .91rem;
 font-weight: 660;
 min-height: 44px;
 padding: 9px 14px;
 border: 1px solid var(--line);
 border-radius: 9px;
 background: var(--panel);
 color: var(--text);
 cursor: pointer;
 display: inline-flex;
 justify-content: center;
 align-items: center;
 gap: 7px;
 text-align: center;
 max-width: 100%;
}
button svg, .button svg { width: 18px; height: 18px; }
.primary { color: var(--ink); background: var(--accent); border-color: var(--accent); }
.outline { color: var(--accent-text); background: transparent; border-color: color-mix(in srgb,var(--accent-text) 60%,var(--line)); }
.ghost { background: transparent; }
.ghost.danger { color: var(--error); }
button:disabled { opacity: .52; cursor: default; }
.wide { width: 100%; }
.small { font-size: .79rem; padding: 6px 9px; min-height: 38px; }
.icon-button { width: 44px; height: 44px; padding: 7px; }
.icon-button svg { width: 20px; height: 20px; }
.icon-button[aria-pressed=true] { color: var(--accent-text); background: var(--accent-soft); }
@media (hover: hover) {
 :is(button,.button,.exercise-card):hover { filter: brightness(1.09); }
 .quiet-link:hover, .plan-list a:hover { text-decoration: underline; }
}
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; }

.form-grid, .filter-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px 13px; }
.form-grid .full { grid-column: 1/-1; }
.field { display: grid; align-content: start; gap: 5px; min-width: 0; color: var(--muted); font-size: .81rem; font-weight: 640; }
input, select, textarea {
 min-width: 0; width: 100%; max-width: 100%; min-height: 44px; margin: 0;
 border: 1px solid var(--line); border-radius: 9px;
 background: var(--bg); color: var(--text); font: 400 16px system-ui, sans-serif; padding: 8px 10px;
}
input:disabled { opacity: .55; }
textarea { resize: vertical; }
input[type=checkbox] { width: 17px; height: 17px; min-height: 17px; flex-shrink: 0; accent-color: var(--accent-text); }
.choice { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; font-size: .82rem; color: var(--muted); }
fieldset { min-width: 0; border: 0; margin: 0; padding: 4px 0 0; }
fieldset legend { color: var(--muted); font-size: .81rem; font-weight: 640; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { min-width: 40px; min-height: 44px; display: inline-grid; place-items: center; cursor: pointer; position: relative; }
.days input { position: absolute; opacity: 0; }
.days span { border: 1px solid var(--line); color: var(--muted); background: var(--panel); border-radius: 8px; padding: 7px 9px; font-size: .82rem; }
.days input:checked + span { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-text); }
.days input:focus-visible + span { outline: 2px solid var(--accent-text); }
.fieldline { border-top: 1px solid var(--line); padding: 10px 0; }
.fieldline:first-child { border-top: 0; }
.fieldline p { margin: 4px 0 0; }
.fieldline progress { margin-top: 7px; }
.measurement, .timeline-item, .set-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.measurement > div, .timeline-item > div, .set-row > div:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.measurement .badge { margin-inline-start: 5px; padding: 2px 6px; }
.measurement .note { white-space: pre-wrap; }
.filter-grid { margin-bottom: 11px; }
.chart-controls { flex-wrap: wrap; margin-bottom: 6px; gap: 2px 14px; }
.body-chart { margin-top: 14px; }
.settings-lower { margin-top: 20px; }
.subform { margin-top: 10px; }

.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: manipulation; }
.chart svg text { fill: var(--muted); stroke: none; font: 11px system-ui,sans-serif; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--line); stroke-dasharray: 3 6; stroke-width: 1; }
.chart .area { stroke: none; pointer-events: none; }
.chart .chart-line, .chart .alternate-line { stroke: var(--accent-text); stroke-width: 2.6; vector-effect: non-scaling-stroke; pointer-events: none; }
.chart .alternate-line { stroke: var(--alternate); stroke-width: 1.8; }
.chart .target-line { stroke: var(--target); stroke-width: 1.1; stroke-dasharray: 5 5; }
.chart .point, .chart .alternate-point, .chart .extra-point, .chart .event-mark { cursor: pointer; stroke: none; fill: var(--accent-text); }
.chart .extra-point { fill: var(--extra); }
.chart .alternate-point { fill: var(--alternate); }
.chart .event-mark { color: var(--target); fill: currentColor; }
.chart .event-line { stroke: currentColor; stroke-width: 1; stroke-dasharray: 2 4; opacity: .65; }
.chart :is(.point-hit, .event-hit) { fill: transparent; }
.chart .event-hit { stroke: transparent; stroke-width: 15; }
.chart .selected > circle:first-child, .chart .selected > circle:last-child { stroke: var(--text); stroke-width: 1.4; }
.chart-caption { color: var(--muted); font-size: .78rem; display: flex; align-items: center; flex-wrap: wrap; gap: 5px 14px; }
.chart-readout { display: block; overflow-wrap: anywhere; width: 100%; }
.chart-readout:empty { display: none; }
.legend { display: inline-flex; align-items: center; gap: 5px; }
.legend::before { content: ""; display: inline-block; height: 7px; width: 7px; border-radius: 50%; background: currentColor; }
.goal-legend { color: var(--target); }.avg-legend { color: var(--alternate); }.extra-legend { color: var(--extra); }
.chart-empty { padding-top: 4px; }

.plan-grid, .exercise-grid { margin-bottom: 14px; display: grid; gap: 12px; }
.plan-grid .card { margin: 0; }
.exercise-grid { grid-template-columns: minmax(0, 1fr); }
.exercise-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; }
.exercise-card h2 { margin: 0 0 3px; font-size: 1rem; overflow-wrap: anywhere; }
.exercise-card p { margin: 0; }
.exercise-card > svg { width: 16px; height: 16px; color: var(--muted); }
.exercise-meta { color: var(--accent-text); font-size: .78rem; }
.plan-list { list-style: none; padding: 0; margin: 0 0 14px; }
.plan-list li { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); font-size: .9rem; padding: 9px 0; }
.plan-list li div { min-width: 0; overflow-wrap: anywhere; }
.plan-list li span { flex-shrink: 0; }
.warmup-card .row > div { flex: 1 1 240px; }
.warmup-card .row h2 { margin: 0 0 5px; }
.warmup-card button { margin-top: 12px; }
.elapsed { border: 1px solid var(--line); background: var(--surface); padding: 6px 11px; border-radius: 9px; font-size: 1rem; font-variant-numeric: tabular-nums; }
.workout-progress { margin-bottom: 5px; }
progress { display: block; width: 100%; height: 7px; border: 0; border-radius: 8px; overflow: hidden; background: var(--line); accent-color: var(--accent); }
progress::-webkit-progress-bar { background-color: var(--line); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.active-exercise { margin-top: 15px; }
.active-title { font-size: 1.35rem; }
.instruction, .progression { background: var(--panel); color: var(--text); padding: 11px; border-radius: 9px; font-size: .9rem; }
.progression { color: var(--accent-text); }
.logged-sets { margin: 13px 0; border-block: 1px solid var(--line); }
.done-icon { display: inline-flex; vertical-align: middle; color: var(--accent-text); }
.done-icon svg { width: 17px; height: 17px; }
.rest-box { margin-top: 15px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: 10px; }
.rest-box svg { width: 18px; height: 18px; }
.timer { font-size: 1.8rem; font-weight: 730; font-variant-numeric: tabular-nums; }
.timer.running { color: var(--accent-text); }
.timer-controls { margin-top: 5px; }
.finish-row { margin-top: 15px; }
.history-card summary { display: flex; justify-content: space-between; gap: 10px; align-items: center; list-style: none; }
.history-card summary::-webkit-details-marker { display:none; }
.history-card summary span { display: block; }
.history-card[open] summary { margin-bottom: 12px; }
.history-card[open] summary > svg { transform: rotate(90deg); }
.compact-list { margin: 5px 0; padding-left: 20px; color: var(--muted); font-size: .86rem; }
.sync-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; color: var(--muted); font-size: .8rem; border: 1px solid var(--line); background:var(--panel); border-radius: 9px; padding: 7px 10px; margin-bottom: 10px; }
details summary { cursor: pointer; min-height: 39px; font-weight: 650; }
.status-text { color: var(--accent-text); }
dialog {
 border: 1px solid var(--line); border-radius: 17px; background: var(--panel); color: var(--text);
 width: min(660px, calc(100% - 24px)); max-height: 86vh; max-height: 86dvh; padding: 16px;
}
dialog::backdrop { background: #070a0dd9; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; font-size: 1.23rem; }
.login { max-width: 400px; padding: clamp(17px,4vw,27px); margin: clamp(20px,12vh,130px) auto 0; }
.login h1 { font-size: 1.81rem; margin: 13px 0 24px; }
.login-icon { width: 49px; height: 49px; }
.login-icon svg { width: 29px; height: 29px; }

nav {
 position: fixed; inset: auto 0 0; z-index: 4; display: grid;
 grid-template-columns: repeat(5,minmax(0,1fr)); gap: 3px;
 padding: 7px max(6px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left));
 border-top: 1px solid var(--line); background: var(--bg);
}
nav a { display: grid; align-content: center; place-items: center; gap: 4px; min-height: 47px; font-weight: 610; font-size: clamp(.62rem,2.4vw,.77rem); color: var(--muted); border-radius: 8px; }
nav a[aria-current=page] { color: var(--accent-text); background: var(--accent-soft); }
nav svg { width: 19px; height: 19px; }

@media (min-width: 610px) {
 .training-summary { grid-template-columns: 1.5fr 1fr; }
 .plan-grid, .exercise-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
 .info-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
 .summary-grid { gap: 12px; }
 .chart svg text { font-size: 12px; }
}
@media (min-width: 930px) {
 .authenticated .shell { display: grid; grid-template-columns: 192px minmax(0,1fr); column-gap: 24px; }
 .topbar { grid-column: 1/-1; grid-row: 1; }
 .authenticated .main-wrap { grid-column: 2; grid-row: 2; padding-bottom: 35px; }
 nav { grid-row: 2; grid-column: 1; align-self: start; position: sticky; inset: 20px auto auto; padding: 0 9px 0 0; grid-template-columns: 1fr; border: 0; }
 nav a { display: flex; align-items: center; justify-content: flex-start; gap: 10px; padding: 10px 12px; min-height: 44px; font-size: .9rem; }
 .summary-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
 .exercise-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 380px) {
 .card { padding: 11px; }
 .row { gap: 6px; }
 .metric-icon { width: 27px; height: 27px; }
 .metric-icon svg { width: 16px; height: 16px; }
 .measurement .button,.measurement button { flex-shrink: 0; font-size: .75rem; padding: 7px; }
}
