:root {
    color-scheme: dark;
    --ink: #f2f4f8;
    --muted: #a3adbc;
    --canvas: #10151d;
    --surface: #1a222e;
    --raised: #222d3b;
    --rule: #334052;
    --accent: #b0007a;
    --accent-hover: #ca168f;
    --accent-soft: #371d34;
    --green: #81d5a6;
    --red: #ff8e86;
    --amber: #f0c77a;
    font-family: "Segoe UI Variable", "Segoe UI", sans-serif;
}

html[data-theme="light"] {
    color-scheme: light;
    --ink: #1f2430;
    --muted: #526078;
    --canvas: #f3f6fb;
    --surface: #fff;
    --raised: #f8fafd;
    --rule: #dde3ee;
    --accent: #5b6efb;
    --accent-hover: #4657e5;
    --accent-soft: #eef3ff;
    --green: #147a45;
    --red: #ad322c;
    --amber: #8a5a00;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--canvas); color: var(--ink); }
body { min-width: 320px; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; }
.main-area { min-width: 0; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 36px; }
.brand-mark { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 13px; background: var(--accent); color: #fff; font-size: 21px; font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; }
.topbar { position: relative; z-index: 5; min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 42px; border-bottom: 1px solid var(--rule); background: var(--surface); color: var(--muted); font-size: 13px; }
.topbar-brand { flex: 0 0 auto; padding: 0; color: var(--ink); }
.topbar-user { display: flex; align-items: center; justify-content: flex-end; gap: 16px; margin-left: auto; }
.settings-menu { position: relative; flex: 0 0 auto; }
.settings-menu-toggle { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--rule); border-radius: 10px; background: var(--raised); color: var(--ink); cursor: pointer; list-style: none; }
.settings-menu-toggle::-webkit-details-marker { display: none; }
.settings-menu-toggle::marker { content: ""; }
.settings-menu-toggle:hover, .settings-menu[open] .settings-menu-toggle { border-color: var(--accent); color: var(--accent); }
.settings-menu-toggle:focus-visible, .nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-menu-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.settings-menu:not([open]) > .menu-popover, .settings-menu:not([open]) > .menu-logout { display: none; }
.menu-popover { position: absolute; top: calc(100% + 10px); right: 0; width: min(280px, calc(100vw - 32px)); display: grid; gap: 4px; padding: 10px; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); box-shadow: 0 16px 42px #0004; }
.nav-link { width: 100%; min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; }
.nav-link > span { width: 20px; color: var(--muted); text-align: center; font-size: 17px; }
.nav-link:hover, .nav-link.active { background: var(--raised); color: var(--ink); }
.nav-link.active > span { color: var(--accent); }
.menu-logout { margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--rule); }
.logout:hover { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); }
.user-chip, .count-pill { padding: 5px 10px; border-radius: 999px; background: var(--raised); color: var(--ink); font-size: 12px; }
.content { width: min(100%, 1320px); margin: 0 auto; padding: 38px 42px 64px; }
.page-heading { margin-bottom: 28px; }
.eyebrow { margin: 0 0 9px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(27px, 3vw, 36px); line-height: 1.18; letter-spacing: -.025em; }
h2 { margin-bottom: 18px; font-size: 19px; line-height: 1.3; }
h3 { margin: 25px 0 10px; font-size: 15px; }
.page-description { margin: 9px 0 0; color: var(--muted); line-height: 1.55; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card, .panel { border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); }
.metric-card { min-height: 130px; padding: 20px 22px; }
.metric-card > span, .metric-card > small { display: block; color: var(--muted); font-size: 13px; }
.metric-card strong { display: block; margin: 12px 0 4px; font-size: 31px; line-height: 1; }
.metric-card strong small { margin-left: 5px; font-size: 13px; font-weight: 600; }
.dashboard-grid, .two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.panel { min-width: 0; padding: 22px; }
.panel-wide { grid-column: 1 / -1; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-title h2 { margin: 0; }
.section-title .eyebrow { margin-bottom: 6px; }
.muted, .empty-state { color: var(--muted); line-height: 1.6; }
.empty-state { padding: 12px 0; }
.success-text { margin: 18px 0 0; color: var(--green); }
.text-link { color: var(--accent); font-weight: 650; }
.text-link:hover { text-decoration: underline; }
.print-button { padding: 0; border: 0; background: transparent; font-size: inherit; cursor: pointer; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; transition: background .15s, transform .15s; }
.button:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--accent-hover); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button-secondary { border-color: var(--rule); background: var(--raised); color: var(--ink); }
.button-secondary:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.button-danger { border-color: color-mix(in srgb, var(--red) 45%, var(--rule)); background: transparent; color: var(--red); }
.button-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 14%, transparent); }
.button-small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.full-width { width: 100%; }
.icon-button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; font-size: 21px; cursor: pointer; }
.icon-button:hover { background: var(--raised); }
.danger-text { color: var(--red); }
.notice { margin: 0 0 20px; padding: 12px 15px; border: 1px solid var(--rule); border-radius: 9px; background: var(--raised); line-height: 1.5; }
.notice.success { border-color: color-mix(in srgb, var(--green) 40%, var(--rule)); color: var(--green); }
.notice.error { border-color: color-mix(in srgb, var(--red) 45%, var(--rule)); color: var(--red); }
.notice.warning { border-color: color-mix(in srgb, var(--amber) 45%, var(--rule)); color: var(--amber); }

.form-stack { display: grid; gap: 15px; }
.form-stack > label, .field-pair > label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 600; }
input:not([type="checkbox"]):not([type="file"]), select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--rule); border-radius: 8px; outline: none; background: var(--canvas); color: var(--ink); }
input[type="file"] { width: 100%; padding: 9px 0; color: var(--muted); font-size: 12px; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
fieldset { min-width: 0; margin: 0; padding: 13px; border: 1px solid var(--rule); border-radius: 9px; }
legend { padding: 0 6px; color: var(--muted); font-size: 13px; font-weight: 650; }
.area-checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.select-all-option { margin-bottom: 7px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.check-option { display: flex; align-items: center; gap: 8px; min-height: 34px; color: var(--muted); font-size: 13px; cursor: pointer; }
.check-option input { flex: 0 0 auto; }

.activity-list, .plan-list, .user-list, .music-list, .exercise-list { margin: 0; padding: 0; list-style: none; }
.activity-list li, .plan-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.activity-list li:last-child, .plan-list li:last-child { border-bottom: 0; }
.activity-list strong, .activity-list small, .exercise-info strong, .exercise-info small, .music-row strong, .music-row small, .user-row strong, .user-row small { display: block; }
.activity-list small, .exercise-info small, .music-row small, .user-row small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.activity-list b, .plan-list small { white-space: nowrap; color: var(--muted); font-size: 12px; }
.exercise-row, .music-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.exercise-row:last-child, .music-row:last-child { border-bottom: 0; }
.exercise-thumb { width: 52px; height: 52px; flex: 0 0 52px; object-fit: cover; border-radius: 9px; background: var(--raised); }
.exercise-thumb.placeholder { display: grid; place-items: center; color: var(--accent); font-size: 21px; }
.exercise-info { min-width: 0; flex: 1; }
.exercise-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exercise-row form, .music-row form { margin: 0; }
.music-note { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 18px; }
.music-row > div { min-width: 0; flex: 1; }
.music-row strong { overflow-wrap: anywhere; }

.timer-panel { grid-column: span 1; }
.training-timer-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(240px, .8fr); gap: 16px; align-items: stretch; }
.training-summary { position: sticky; top: 20px; }
.training-summary-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.training-summary-heading .eyebrow { margin: 12px 0 0; }
.settings-summary { display: grid; gap: 0; margin: 0 0 20px; padding: 0; list-style: none; }
.settings-summary li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.settings-summary li span { color: var(--muted); }
.settings-summary li strong { text-align: right; overflow-wrap: anywhere; }
.empty-training { max-width: 720px; }
.empty-training .text-link { margin-left: 14px; }
.timer-display { margin: 18px 0; padding: 28px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--raised); text-align: center; }
.timer-display.resting { background: color-mix(in srgb, var(--green) 16%, var(--raised)); }
.timer-status { color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.timer-clock { margin: 10px 0; font-variant-numeric: tabular-nums; font-size: clamp(48px, 8vw, 72px); font-weight: 750; line-height: 1; }
.timer-exercise { min-height: 24px; font-size: 19px; font-weight: 650; }
.timer-round { margin-top: 8px; color: var(--muted); font-size: 13px; }
.timer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.music-toggle { margin-top: 14px; }
.plan-list { max-height: 250px; overflow-x: hidden; overflow-y: auto; }
.plan-list li { padding: 8px 2px; font-size: 13px; }
.plan-list li > span { min-width: 0; }
.plan-list li > small { margin-right: 10px; }
.plan-list li.plan-rest { color: var(--muted); }
.plan-list li.plan-rest small { color: var(--muted); }
.plan-list li.is-current, .plan-list li.is-upcoming { padding-inline: 10px; border-radius: 7px; }
.plan-list li.is-current { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); box-shadow: inset 3px 0 var(--accent); font-weight: 700; }
.plan-list li.is-current small { color: var(--accent); font-weight: 700; }
.plan-list li.is-upcoming { border-color: color-mix(in srgb, var(--accent) 40%, var(--rule)); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.plan-list li.is-upcoming small { color: var(--accent); }
.plan-list li.is-upcoming > span::before { content: ""; display: inline-block; width: 0; height: 0; margin-right: 7px; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 7px solid #e04444; vertical-align: -1px; }
.timer-exercise-image { width: 100%; max-height: 180px; margin: 14px 0 0; border-radius: 9px; object-fit: contain; }

.weight-chart { min-height: 190px; display: flex; align-items: end; gap: 9px; overflow-x: auto; padding: 8px 2px 0; border-bottom: 1px solid var(--rule); }
.weight-point { min-width: 42px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: end; gap: 5px; height: 174px; color: var(--muted); font-size: 10px; }
.weight-point > div { width: min(28px, 70%); min-height: 8px; border-radius: 5px 5px 2px 2px; background: var(--accent); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.user-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.user-row:last-child { border-bottom: 0; }
.avatar { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 420px); padding: 32px; border: 1px solid var(--rule); border-radius: 14px; background: var(--surface); box-shadow: 0 20px 80px #0002; }
.auth-brand { padding: 0 0 30px; }
.auth-card h1 { font-size: 30px; }
.auth-card .page-description { margin-bottom: 22px; }
.auth-card .eyebrow { margin-top: 2px; }
.auth-footnote { margin: 19px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

@media (max-width: 960px) {
    .content { padding: 30px 24px 52px; }
    .topbar { padding-inline: 24px; }
}
@media (max-width: 720px) {
    .topbar { min-height: 62px; gap: 10px; padding: 8px 14px; font-size: 12px; }
    .topbar-brand { gap: 8px; }
    .topbar-brand .brand-mark { width: 34px; height: 34px; flex-basis: 34px; font-size: 18px; }
    .topbar-brand strong { font-size: 14px; }
    .topbar-brand small { font-size: 9px; }
    .topbar-user { gap: 8px; }
    .topbar-user > span:first-child { display: none; }
    .settings-menu-toggle { width: 40px; height: 40px; }
    .content { padding: 25px 16px 40px; }
    .metric-grid { grid-template-columns: 1fr; gap: 9px; }
    .metric-card { min-height: 100px; padding: 16px; }
    .metric-card strong { margin: 8px 0 3px; font-size: 27px; }
    .dashboard-grid, .two-column { grid-template-columns: 1fr; }
    .training-timer-layout { grid-template-columns: 1fr; }
    .training-summary { position: static; }
    .panel-wide { grid-column: auto; }
    .panel { padding: 17px; }
    .field-pair { grid-template-columns: 1fr 1fr; gap: 8px; }
}
@media print {
    .topbar, .page-heading, .timer-actions, .music-toggle, .text-link { display: none !important; }
    .app-shell { display: block; }
    .content { width: 100%; padding: 0; }
    .panel { border: 0; }
    .training-timer-layout { display: block; }
    .training-summary { display: none; }
    .plan-list { max-height: none; overflow: visible; }
    body, html { background: white; color: black; }
}
