:root {
  color-scheme: light;
  --background: #f3f5ef;
  --surface: #fff;
  --ink: #20251c;
  --muted: #596352;
  --line: #dfe5d8;
  --accent: #cef666;
  --accent-soft: #edf5dc;
  --green: #3f5d22;
  --error: #91372b;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--ink); }
h1, h2, h3, p, dl, dd { margin: 0; }
button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
fieldset { min-width: 0; margin: 0; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid #6e972d; outline-offset: 3px; }
section[id] { scroll-margin-top: 18px; }
.container { width: min(1180px, calc(100% - 64px)); margin-inline: auto; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner, .brand, .main-nav { display: flex; align-items: center; }
.header-inner { min-height: 68px; justify-content: space-between; gap: 16px; }
.brand { gap: 10px; font-size: 15px; font-weight: 750; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); }
.brand-mark .icon { stroke-width: 2.15; }
.main-nav { gap: 4px; flex-wrap: wrap; }
.main-nav a { display: grid; place-items: center; min-height: 38px; padding: 0 12px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.main-nav a:hover { background: var(--background); }
.main-nav a[aria-current] { background: var(--accent-soft); color: var(--green); }

.main-content { padding-block: 28px 54px; }
.top-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; gap: 18px; }
.section-heading { display: flex; min-height: 44px; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 10px; }
.section-heading h1, .section-heading h2 { font-size: clamp(21px, 3vw, 30px); line-height: 1.3; letter-spacing: -.035em; }
.section-heading h2 { font-size: clamp(20px, 2.5vw, 25px); }
.lower-section { margin-top: 23px; }
.card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 2px 4px #26331a09; }
.card-heading { display: flex; align-items: center; gap: 10px; }
.heading-icon { flex: none; display: grid; place-items: center; width: 37px; height: 37px; border-radius: 9px; background: var(--accent-soft); color: var(--green); }
.heading-icon .icon { width: 18px; height: 18px; }
.card h2, .card h3 { font-size: 16px; line-height: 1.4; }
.card-heading p { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.55; }

.field { display: grid; gap: 5px; min-width: 0; align-content: start; font-size: 12px; font-weight: 700; }
.field input, .field select { width: 100%; min-width: 0; min-height: 42px; padding: 7px 10px; border: 1px solid #d6dfcd; border-radius: 8px; background: #fcfdfb; color: var(--ink); font-size: 13px; font-weight: 500; }
.field input::placeholder { color: #687161; opacity: 1; }
.field select { cursor: pointer; }
.field [aria-invalid="true"] { border-color: var(--error); }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 7px 12px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; font-weight: 750; line-height: 1.35; text-align: center; }
.button .icon { width: 16px; height: 16px; }
.button-primary { min-height: 44px; background: var(--accent); color: #243412; }
.button-primary:hover:not(:disabled) { background: #c0ec50; }
.button-outline { border-color: #d5e0cb; background: #f6f9f0; color: var(--green); }
.button-outline:hover:not(:disabled) { background: var(--accent-soft); }
.button-text { width: fit-content; min-height: 35px; padding-inline: 7px; background: transparent; color: var(--green); }
.button-text:hover:not(:disabled) { background: var(--accent-soft); }
.remove-set, .remove-activity, .delete-record { color: var(--error); }
.remove-set:hover:not(:disabled), .remove-activity:hover:not(:disabled), .delete-record:hover:not(:disabled) { background: #fbefeb; }

.record-date { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.record-date .field { width: min(200px, 100%); }
.edit-label { color: var(--green); padding-bottom: 10px; font-size: 12px; font-weight: 750; }
.activity-editors { display: grid; gap: 11px; margin-top: 12px; }
.activity-editor { padding: 10px 12px 12px; border: 1px solid #e1e8da; border-radius: 10px; background: #f7f9f4; }
.activity-editor legend { padding-inline: 4px; color: var(--green); font-size: 12px; font-weight: 800; }
.activity-heading { display: grid; grid-template-columns: minmax(134px, 1fr) minmax(0, 1.25fr) auto; align-items: end; gap: 8px; }
.activity-heading .remove-activity { align-self: end; min-height: 42px; }
.strength-fields, .cardio-fields { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e2e8db; }
.set-editors { display: grid; gap: 7px; }
.set-editor { display: grid; grid-template-columns: 55px repeat(2, minmax(0, 1fr)) 45px; align-items: end; gap: 8px; }
.set-label { align-self: end; margin-bottom: 12px; font-size: 11px; font-weight: 700; color: var(--muted); }
.set-editor .remove-set { align-self: end; min-height: 42px; }
.add-set { margin-top: 4px; }
.cardio-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.add-activity { margin-top: 12px; }
.record-form-actions { display: flex; gap: 8px; margin-top: 12px; }
.record-form-actions .button-primary { flex: 1; }
.feedback { font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.feedback:not(:empty) { margin-top: 8px; }
.feedback[data-state="error"] { color: var(--error); }
.feedback[data-state="success"] { color: var(--green); }

.history-card { margin-top: 12px; }
.history-list { display: grid; gap: 7px; }
.history-list:not(:empty) { margin-top: 10px; }
.history-item { min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.history-top { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.history-toggle { flex: 1; min-width: 0; }
.history-toggle summary { align-content: center; min-height: 36px; cursor: pointer; font-size: 12px; font-weight: 750; overflow-wrap: anywhere; }
.history-toggle time { margin-right: 6px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.history-actions { flex: none; display: flex; gap: 2px; }
.history-exercises { display: grid; gap: 7px; margin: 5px 0 2px; padding-left: 19px; }
.history-exercises li { padding-left: 1px; font-size: 12px; line-height: 1.55; overflow-wrap: anywhere; }
.history-exercises p { margin-top: 2px; color: var(--muted); }
.empty-message { margin-top: 10px; padding: 12px; border-radius: 8px; background: #f4f7ef; color: var(--muted); font-size: 12px; line-height: 1.6; }

.coach-card { color: #f3f7eb; background: radial-gradient(ellipse at top right, #3c5128 0, #24301f 50%, #202a1b 100%); border-color: #283821; }
.coach-card .card-heading p { color: #e1ead7; margin: 0; }
.coach-icon { background: #425a2c; color: #d8f888; }
#coach-form { display: grid; gap: 12px; margin-top: 15px; }
.coach-card .field select { border-color: #647454; background: #303f28; color: #f4f8ef; color-scheme: dark; }
.coach-styles { display: grid; gap: 6px; padding: 0; border: 0; }
.coach-styles legend { margin-bottom: 6px; padding: 0; font-size: 12px; font-weight: 700; }
.coach-styles label { display: flex; min-height: 40px; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid #516347; border-radius: 8px; color: #eff3e9; font-size: 12px; cursor: pointer; }
.coach-styles label:has(input:checked) { border-color: #a0c354; background: #3e502d; }
.coach-styles input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.ai-result { display: grid; align-content: center; gap: 6px; min-height: 63px; margin-top: 12px; padding: 12px; border: 1px dashed #d6dfcd; border-radius: 8px; background: #f5f8f0; color: var(--muted); font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.ai-result[data-state="success"] { align-content: start; border-style: solid; }
.ai-result[data-state="error"] { color: var(--error); }
.ai-result .ai-prose { white-space: pre-wrap; }
.coach-card .ai-result { border-color: #56684d; color: #dbe6d3; background: #263020; }
.coach-card .ai-result[data-state="error"] { color: #ffc6b8; }
.coach-card .ai-result h3 { font-size: 13px; color: #e5f6ce; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.85fr) minmax(0, 1fr); gap: 12px; }
.level-card { background: #e8f2d8; border-color: #d4e4c1; }
.level-card h3, .level-rule { color: var(--green); }
.level-number { margin-block: 10px; font-size: 55px; line-height: 1; letter-spacing: -.07em; }
.level-number span { font-size: .47em; font-weight: 750; letter-spacing: -.04em; }
.xp-details { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 7px; color: var(--green); font-size: 11px; font-weight: 700; }
progress { display: block; appearance: none; width: 100%; height: 9px; border: 0; border-radius: 999px; overflow: hidden; background: #cbdab9; color: #568526; }
progress::-webkit-progress-bar { background: #cbdab9; }
progress::-webkit-progress-value { border-radius: 999px; background: #568526; }
progress::-moz-progress-bar { border-radius: 999px; background: #568526; }
.level-rule { margin-top: 9px; font-size: 11px; }
.trend-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.chart-wrap { margin-top: 8px; height: 162px; }
#training-chart { display: block; width: 100%; height: 100%; }
.summary-list { display: grid; gap: 6px; margin-top: 12px; }
.summary-list div { display: flex; min-height: 38px; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 8px; border-radius: 7px; background: #f3f6ef; }
.summary-list dt, .summary-list dd { color: var(--muted); font-size: 11px; }
.summary-list strong { color: var(--ink); font-size: 18px; }
.menu-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: start; gap: 12px; margin-top: 12px; }
.menu-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.menu-form .button { grid-column: 1 / -1; }
.menu-layout .ai-result { margin-top: 0; }

@media (max-width: 950px) {
  .container { width: calc(100% - 36px); }
  .activity-heading { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .activity-heading .remove-activity { grid-column: 1 / -1; min-height: 30px; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trend-card { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 700px) {
  .top-grid, .menu-layout { grid-template-columns: minmax(0, 1fr); }
  .header-inner { flex-wrap: wrap; align-content: center; justify-content: start; gap: 7px; padding-block: 9px; }
  .main-nav { width: 100%; }
  .main-content { padding-top: 17px; }
}
@media (max-width: 460px) {
  .container { width: calc(100% - 24px); }
  .main-nav a { padding-inline: 7px; font-size: 11px; }
  .main-nav { gap: 2px; }
  .card { padding: 14px; }
  .activity-editor { padding-inline: 8px; }
  .activity-heading, .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .trend-card { grid-column: auto; grid-row: auto; }
  .set-editor { grid-template-columns: 39px repeat(2, minmax(0, 1fr)) 37px; gap: 4px; }
  .field input, .field select { min-height: 44px; padding-inline: 6px; font-size: 16px; }
  .set-editor .remove-set, .history-actions .button { padding-inline: 3px; }
  .history-item { padding-inline: 7px; }
}
