:root{color-scheme:light;box-sizing:border-box;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
html{scroll-padding-top:env(safe-area-inset-top,0px);touch-action:manipulation}
body{margin:0;padding:0;font:14px -apple-system,BlinkMacSystemFont,sans-serif;background:#fff;color:#000;touch-action:manipulation}
img{max-width:100%}
[hidden]:not([hidden=until-found i]){display:none!important}

/* Layout: một cột đọc như sổ tập; thẻ "buổi tiếp theo" ở trên, mỗi tuần là một khối, ngày chạy chọn được từng buổi, màu theo loại buổi tập. */
/* Bảng màu lấy thẳng từ logo RUNN: navy #0E2551, xanh #1366D6 (chữ N chuyển
   sắc) và cam #FF7C1D (dấu swoosh). */
:root {
  --bg: #F2F5FB;
  --surface: #FFFFFF;
  --fg: #0E2551;
  --muted: #5A6B8C;
  --line: #DBE3F0;
  --easy: #1366D6;
  --easy-bg: #E3EDFD;
  --quality: #E8690F;
  --quality-bg: #FFE9D6;
  --long: #5B5BD6;
  --long-bg: #E8E8FB;
  --race: #FFFFFF;
  --race-bg: #0E2551;
  --rest: #5A6B8C;
  --rest-bg: #E8EDF5;
  --focus: #1366D6;
  --brand-1: #1366D6;
  --brand-2: #FF7C1D;
  --brand-grad: linear-gradient(120deg, var(--brand-1), var(--brand-2));
  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #080F20; --surface: #111A30; --fg: #E9EEFA; --muted: #94A3C2; --line: #223052;
    --easy: #5B9DFF; --easy-bg: #13254A; --quality: #FF9A4D; --quality-bg: #3A2412;
    --long: #9B9BFF; --long-bg: #242454; --race: #080F20; --race-bg: #E9EEFA;
    --rest: #94A3C2; --rest-bg: #182440; --focus: #5B9DFF;
    --brand-1: #5B9DFF; --brand-2: #FF9A4D; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #080F20; --surface: #111A30; --fg: #E9EEFA; --muted: #94A3C2; --line: #223052;
  --easy: #5B9DFF; --easy-bg: #13254A; --quality: #FF9A4D; --quality-bg: #3A2412;
  --long: #9B9BFF; --long-bg: #242454; --race: #080F20; --race-bg: #E9EEFA;
  --rest: #94A3C2; --rest-bg: #182440; --focus: #5B9DFF;
  --brand-1: #5B9DFF; --brand-2: #FF9A4D; color-scheme: dark;
}

/* chuyển trang mượt bằng View Transitions — trình duyệt chưa hỗ trợ thì bỏ qua, điều hướng vẫn bình thường */
@view-transition {
  navigation: auto;
}
/* Chỉ mờ dần, không phóng/trượt: đổi opacity chạy thẳng trên GPU nên gần như
   không tốn gì, trong khi transform cả trang buộc máy vẽ lại toàn bộ ảnh —
   đó là chỗ máy yếu hay khựng. */
::view-transition-group(root) { animation-duration: 150ms; }
::view-transition-old(root) { animation: vt-out 90ms linear both; }
::view-transition-new(root) { animation: vt-in 150ms linear both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
/* menu bar giữ nguyên vị trí, không crossfade cùng nội dung trang khi chuyển tab */
.navbar { view-transition-name: app-navbar; contain: layout; }
::view-transition-old(app-navbar), ::view-transition-new(app-navbar) { animation: none; mix-blend-mode: normal; }
* { box-sizing: border-box; }
/* Không cho bôi đen / sao chép chữ của app; ô nhập vẫn chọn được để sửa và dán. */
html { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, [contenteditable="true"] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  /* tối thiểu bằng chiều cao màn hình: trang ngắn (vd. Cài đặt) vẫn đủ "cao" để
     Safari di động tính đúng vị trí phần tử fixed ngay từ lần vẽ đầu tiên,
     tránh thanh menu bị nhảy khi mới chuyển sang. */
  min-height: 100vh;
  min-height: 100svh;
  padding-block: 20px calc(82px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; margin: 0; text-wrap: balance; letter-spacing: 0; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* link quay về trang chủ */
.back-link { align-self: flex-start; font-size: 13px; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--fg); text-decoration: underline; }

/* menu bar dùng chung — cố định ở đáy màn hình, icon + nhãn kiểu app di động.
   transform: translateZ(0) ép trình duyệt tạo riêng 1 lớp GPU cho thanh này,
   tránh nó bị vẽ lại/giật khi Safari di động thu phóng thanh địa chỉ lúc cuộn
   hoặc lúc trang vừa chuyển sang. */
.navbar {
  position: fixed; left: 0; right: 0; bottom: 0; max-width: 760px; margin: 0 auto; z-index: 50;
  display: flex; gap: 2px; padding: 7px 6px calc(7px + env(safe-area-inset-bottom, 0px));
  min-height: calc(64px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(0,0,0,.07);
  transform: translateZ(0); -webkit-transform: translateZ(0); will-change: transform;
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  /* bán kính blur vừa phải: hiệu ứng kính vẫn rõ nhưng máy phải tính lại ít
     hơn hẳn ở mỗi khung hình khi cuộn */
  .navbar {
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    backdrop-filter: saturate(150%) blur(12px);
    -webkit-backdrop-filter: saturate(150%) blur(12px);
  }
}
.navbar-item { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 2px; border-radius: 12px; color: var(--muted); text-decoration: none; transition: color .18s, background .18s, transform .14s; }
.navbar-item:hover { color: var(--fg); }
.navbar-item:active { transform: scale(.94); }
.navbar-item.on { color: var(--easy); background: var(--easy-bg); }
.navbar-item .nav-icon { width: 23px; height: 23px; flex: 0 0 auto; }
.navbar-item .nav-label { font-size: 10.5px; font-weight: 600; letter-spacing: .01em; line-height: 1; white-space: nowrap; }

/* header */
.head { display: flex; flex-direction: column; gap: 14px; }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
h1 { font-size: clamp(34px, 8vw, 52px); line-height: 1.02; }

/* thanh thương hiệu: logo góc trên bên trái, cạnh nó là lời chào (hoặc tên
   trang) và thứ/ngày/tháng/năm ở dòng dưới */
.app-head { display: flex; align-items: center; gap: 13px; min-width: 0; }
.app-logo { flex: 0 0 auto; display: block; }
.app-logo img { display: block; height: 36px; width: auto; }
.app-head-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.app-head-text h1 { font-size: clamp(21px, 5.6vw, 29px); line-height: 1.06; }
.app-head-text .eyebrow { font-size: 11.5px; letter-spacing: .09em; }
@media (max-width: 360px) {
  .app-head { gap: 10px; }
  .app-logo img { height: 31px; }
}
.head-row { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: flex-end; justify-content: space-between; }
.count { display: flex; align-items: baseline; gap: 8px; }
.count b { font-family: var(--font-display); font-size: 64px; line-height: .9; font-weight: 700; }
.count span { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-size: 13px; font-weight: 500; padding: 8px 14px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--easy); width: 0; transition: width .25s; }
.bar-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

/* next session */
.next { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.06); }
.next h2 { font-size: 30px; line-height: 1.1; }
.next .when { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.next .detail { max-width: 62ch; }
.next .note { max-width: 62ch; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.btn {
  font: inherit; font-weight: 700; font-size: 14px; padding: 11px 18px; border-radius: 10px; border: 0;
  background: var(--fg); color: var(--bg); cursor: pointer; align-self: flex-start;
  transition: transform .16s cubic-bezier(.2,.9,.3,1.3), box-shadow .2s, opacity .14s;
  box-shadow: 0 8px 20px -8px rgba(0,0,0,.35);
}
.btn:hover { opacity: .94; }
.btn:active { transform: scale(.96); }
@supports (color: color-mix(in srgb, red, transparent)) {
  .btn {
    background: var(--brand-grad); color: #fff;
    box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--brand-1) 65%, transparent);
  }
}
.lnk { font: inherit; font-size: 12.5px; color: var(--muted); background: none; border: 0; text-decoration: underline; cursor: pointer; padding: 2px 0; }

/* chips */
.chip { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 5px; white-space: nowrap; }
.t-easy { background: var(--easy-bg); color: var(--easy); }
.t-quality { background: var(--quality-bg); color: var(--quality); }
.t-long { background: var(--long-bg); color: var(--long); }
.t-race { background: var(--race-bg); color: var(--race); }
.t-rest { background: var(--rest-bg); color: var(--rest); }
.tag-now { background: var(--fg); color: var(--bg); }

/* selects */
select { font: inherit; font-size: 13px; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px; max-width: 100%; cursor: pointer; }

/* weekday schedule */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.045); }
.panel h2 { font-size: 26px; }
.panel .hint { color: var(--muted); font-size: 13.5px; max-width: 64ch; }
.sched-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.sf { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.sf select { font-size: 14px; padding: 8px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 6px 16px; }

/* weeks */
.sec-title { font-size: 26px; margin-bottom: 4px; }
.weeks { display: flex; flex-direction: column; gap: 14px; }
.week { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: border-color .2s, box-shadow .2s, transform .2s; }
.week.current { border-color: var(--fg); }
.week.full { border-color: var(--easy); }
@media (hover: hover) { .week:hover { box-shadow: 0 6px 20px rgba(0,0,0,.07); transform: translateY(-1px); } }
.wk-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 14px 16px 10px; }
.wk-head h3 { font-size: 24px; }
.wk-head .dates { color: var(--muted); font-size: 13px; }
.wk-head .sp { flex: 1 1 auto; }
.wk-head .km { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.wk-phase { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 0 16px 10px; font-size: 13px; color: var(--muted); }
.row { display: grid; grid-template-columns: 24px 104px minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 12px 16px; border-top: 1px solid var(--line); }
.row .day { position: relative; font-size: 13px; line-height: 1.3; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row .day b { font-weight: 600; }
.row .day select { width: 100%; }
.row .day span { color: var(--muted); }
.row .what { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row .what strong { font-weight: 600; font-size: 15px; }
.row .what p { color: var(--muted); font-size: 13.5px; max-width: 60ch; }
.row .kmv { font-family: var(--font-display); font-weight: 600; font-size: 19px; text-align: right; white-space: nowrap; }
.row { transition: background .25s; }
.row.done .what strong { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--muted); transition: color .25s; }
.row.done .kmv { color: var(--muted); }
.row.just { animation: row-flash .9s ease; }
@keyframes row-flash { 0% { background: var(--easy-bg); } 60% { background: var(--easy-bg); } 100% { background: transparent; } }
.row input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--easy); cursor: pointer; transition: transform .14s; }
.row input:hover { transform: scale(1.12); }
.row input:checked { animation: pop .34s cubic-bezier(.2,.9,.3,1.4); }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.38); } 100% { transform: scale(1); } }
.row .spacer { width: 20px; }
.wk-note { padding: 10px 16px 14px; font-size: 13.5px; color: var(--muted); border-top: 1px solid var(--line); }
@media (max-width: 520px) {
  .row { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .row .day { grid-column: 2 / 4; flex-direction: row; align-items: center; gap: 10px; }
  .row .day select { width: auto; }
  .row .what { grid-column: 2 / 3; }
  .row .kmv { grid-column: 3 / 4; grid-row: 2; }
  .row input, .row .spacer { grid-row: 1 / 3; }
}

/* reference */
.zones { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 12px; }
.zone { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.zone .pace { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1.1; }
.zone p { font-size: 13px; color: var(--muted); }
.tbl { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
ul.rules { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; max-width: 64ch; }
.splits { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.split { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.split .a { font-size: 12px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.split .b { font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.foot { font-size: 12.5px; color: var(--muted); }

/* màn hình chờ — chỉ hiện khi mở app từ đầu, nền navy thương hiệu cho cả hai
   chế độ sáng/tối để nhận diện luôn nhất quán */
.splash { display: none; }
.splash-on body { overflow: hidden; }
.splash-on .splash {
  display: flex; position: fixed; inset: 0; z-index: 200;
  flex-direction: column; align-items: center; justify-content: center;
  padding: 32px; background: #0E2551;
  background-image: radial-gradient(118% 78% at 50% 16%, #1D4282 0%, #0E2551 56%, #081732 100%);
}
.splash-card { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.splash-logo { width: min(62vw, 268px); height: auto; animation: sp-logo .8s cubic-bezier(.2,.9,.3,1.1) both; }
.splash-slogan {
  font-family: var(--font-display); font-weight: 600; font-size: clamp(14px, 4.2vw, 19px);
  letter-spacing: .3em; text-transform: uppercase; color: #9DB5E0; margin: 0;
  animation: sp-slogan .7s cubic-bezier(.2,.9,.3,1) .32s both;
}
.splash-bar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  width: min(150px, 38vw); height: 3px; border-radius: 2px;
  background: rgba(255,255,255,.15); overflow: hidden;
}
.splash-bar i { display: block; height: 100%; width: 0; border-radius: 2px; background: linear-gradient(90deg, #1366D6, #FF7C1D); animation: sp-bar 3.5s cubic-bezier(.35,.55,.3,1) both; }
.splash.out { animation: sp-out .42s ease forwards; }
@keyframes sp-logo { from { opacity: 0; transform: translateY(12px) scale(.93); } to { opacity: 1; transform: none; } }
@keyframes sp-slogan { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@keyframes sp-bar { from { width: 0; } to { width: 100%; } }
@keyframes sp-out { to { opacity: 0; transform: scale(1.035); } }
@media (prefers-reduced-motion: reduce) {
  .splash-logo, .splash-slogan { animation-duration: .01ms; animation-delay: 0s; }
  .splash-bar i { animation: none; width: 100%; }
}

/* khoá chiều dọc — app chỉ thiết kế cho portrait; API screen.orientation.lock
   chỉ có tác dụng khi chạy như PWA đã cài (xem "orientation" trong manifest),
   nên luôn cần lớp phủ CSS này làm lưới chắn cuối cho mọi trình duyệt/di động.
   Chỉ chặn màn hình cảm ứng (pointer: coarse) — laptop/desktop xoay ngang là bình thường. */
.orient-lock { display: none; }
@media (orientation: landscape) and (pointer: coarse) {
  .orient-lock {
    display: flex; position: fixed; inset: 0; z-index: 500;
    flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    padding: 32px; text-align: center; background: #0E2551;
    background-image: radial-gradient(118% 78% at 50% 16%, #1D4282 0%, #0E2551 56%, #081732 100%);
  }
  .orient-lock-icon { font-size: 42px; animation: ol-spin 1.6s ease-in-out infinite; }
  .orient-lock p {
    margin: 0; max-width: 280px; color: #E9EEFA;
    font-family: var(--font-body); font-size: 15px; line-height: 1.5;
  }
}
@keyframes ol-spin {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}
@media (prefers-reduced-motion: reduce) {
  .orient-lock-icon { animation: none; }
}

/* vòng tiến độ tuần này */
.ring-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ring-box { position: relative; width: 128px; height: 128px; flex: 0 0 auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--line); stroke-width: 11; }
.ring-fill { fill: none; stroke: url(#ringGrad); stroke-width: 11; stroke-linecap: round; transition: stroke-dashoffset .75s cubic-bezier(.2,.8,.2,1); }
.ring-g1 { stop-color: var(--brand-1); }
.ring-g2 { stop-color: var(--brand-2); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-v { font-family: var(--font-display); font-size: 32px; font-weight: 800; line-height: 1; }
.ring-l { font-size: 11px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; }
.ring-side { flex: 1 1 150px; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.ring-stat { display: flex; align-items: baseline; gap: 8px; }
.ring-stat b { font-family: var(--font-display); font-size: 23px; font-weight: 700; line-height: 1; }
.ring-stat span { font-size: 13px; color: var(--muted); }
.ring-stat.lead b { font-size: 36px; }

/* fireworks canvas */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* toast chúc mừng */
.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(78px + env(safe-area-inset-bottom, 0px)); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; cursor: pointer; width: 100%; background: var(--fg); color: var(--bg); border-radius: 12px; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 12px 32px rgba(0,0,0,.22); animation: toast-in .34s cubic-bezier(.2,.9,.3,1.2) both; }
.toast strong { font-family: var(--font-display); font-size: 22px; font-weight: 700; line-height: 1.1; }
.toast span { font-size: 13px; opacity: .78; }
.toast.out { animation: toast-out .4s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }

/* tabs */
.tabs { position: sticky; top: max(0px, env(safe-area-inset-top, 0px)); z-index: 30; display: flex; gap: 4px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; scrollbar-width: none; }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .tabs { background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(150%) blur(10px); -webkit-backdrop-filter: saturate(150%) blur(10px); }
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; white-space: nowrap; font: inherit; font-size: 13.5px; font-weight: 600; padding: 9px 14px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; transition: background .18s, color .18s, transform .12s; }
.tabs button:hover { color: var(--fg); }
.tabs button:active { transform: scale(.97); }
.tabs button[aria-selected="true"] { background: var(--fg); color: var(--bg); }
.tabpane { display: flex; flex-direction: column; gap: 28px; }
.tabpane.in { animation: pane-in .3s ease both; }
@keyframes pane-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.sec-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }

/* tóm tắt nhanh trên trang chủ — cả khối bấm vào mở trang Thống kê */
.qstat-link { text-decoration: none; color: inherit; transition: border-color .15s, transform .12s; }
.qstat-link:hover { border-color: var(--fg); }
.qstat-link:active { transform: scale(.99); }
.qstat-row { display: flex; gap: 10px; }
.qstat { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qstat .qv { font-family: var(--font-display); font-size: 23px; font-weight: 600; line-height: 1.1; }
.qstat .ql { font-size: 11.5px; color: var(--muted); }
.qstat-cta { font-size: 12.5px; color: var(--muted); align-self: flex-end; }

/* PR */
.pr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 620px) { .pr-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pr-card { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 15px 14px 13px; display: flex; flex-direction: column; gap: 3px; min-width: 0; box-shadow: 0 4px 14px rgba(14,37,81,.04); }
.pr-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--brand-grad); }
.pr-card.empty { background: transparent; border-style: dashed; box-shadow: none; }
.pr-card.empty::before { display: none; }
.pr-card.empty .pr-v { color: var(--muted); }
.pr-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 20px; }
.pr-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.pr-v { font-family: var(--font-display); font-size: 28px; font-weight: 700; line-height: 1.1; }
.pr-d { font-size: 12px; color: var(--muted); }

/* mục tiêu */
.goal-form, .race-form { display: flex; flex-direction: column; gap: 10px; }
.race-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.goal-list { display: flex; flex-direction: column; }
.goal-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.goal-row:first-child { border-top: 0; padding-top: 4px; }
.goal-info { flex: 1 1 auto; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.goal-info strong { font-size: 14px; font-weight: 600; }
.goal-top { display: flex; align-items: center; gap: 8px; }
.goal-pct { margin-left: auto; font-family: var(--font-display); font-size: 21px; font-weight: 700; line-height: 1; }
.goal-bar { height: 8px; border-radius: 4px; }
.goal-bar i { border-radius: 4px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.goal-row.done .goal-bar i { background: var(--brand-grad); }
.goal-sub { font-size: 12.5px; color: var(--muted); }

/* danh sách giải */
.race-list { display: flex; flex-direction: column; gap: 10px; }
.race-card { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; text-decoration: none; color: var(--fg); transition: border-color .15s, transform .12s; box-shadow: 0 4px 14px rgba(0,0,0,.035); }
.race-card:hover { border-color: var(--fg); }
.race-card:active { transform: scale(.99); }
.race-card strong { font-size: 16px; }
.race-card-main { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.race-card-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--line); }

/* quote card */
.quote-card { gap: 10px; }
.quote-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.quote-card blockquote { margin: 0; font-family: var(--font-display); font-size: clamp(20px, 4.4vw, 27px); font-weight: 600; line-height: 1.25; text-wrap: balance; }
.quote-card cite { font-style: normal; font-size: 13px; color: var(--muted); }

/* thanh dung lượng chia đoạn, kiểu thanh bộ nhớ của điện thoại */
.meter { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line); }
.meter i { display: block; height: 100%; min-width: 3px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.m-photo { background: var(--easy); }
.m-app { background: var(--quality); }
.m-free { background: var(--line); }
.meter-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--muted); }
.meter-legend span { display: inline-flex; align-items: center; gap: 6px; }
.meter-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }

/* nhắc chạy */
.nt-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.nt-time { max-width: 150px; }
#nt-toggle[disabled] { opacity: .55; cursor: default; }

/* lịch tháng */
.cal-head { display: flex; align-items: center; gap: 10px; }
.cal-head h2 { flex: 1 1 auto; text-align: center; font-size: 24px; }
.cal-nav { font: inherit; font-size: 20px; line-height: 1; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--fg); cursor: pointer; }
.cal-nav[disabled] { opacity: .35; cursor: default; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 11px; color: var(--muted); text-align: center; letter-spacing: .06em; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cday { position: relative; aspect-ratio: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font: inherit; border: 1px solid transparent; border-radius: 9px; background: var(--bg); color: var(--fg); cursor: pointer; transition: background .15s, border-color .15s, transform .1s; }
.cday:hover { border-color: var(--line); }
.cday:active { transform: scale(.94); }
.cday.out { opacity: .32; }
.cday.today { border-color: var(--fg); }
.cday.sel { background: var(--fg); color: var(--bg); }
.cday.done .cd-num { text-decoration: line-through; text-decoration-thickness: 1px; }
.cd-num { font-size: 13.5px; font-weight: 500; }
.cd-dot { width: 7px; height: 7px; border-radius: 50%; display: block; }
.cd-dots { display: flex; gap: 2px; align-items: center; }
.cd-pic { position: absolute; top: 5px; right: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--long); }
.cday.sel .cd-pic { background: var(--bg); }
.t-easy.cd-dot, .t-easy.lg-dot { background: var(--easy); }
.t-quality.cd-dot, .t-quality.lg-dot { background: var(--quality); }
.t-long.cd-dot, .t-long.lg-dot { background: var(--long); }
.t-race.cd-dot, .t-race.lg-dot { background: var(--fg); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.cal-day { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.cdh { display: flex; align-items: center; gap: 8px; }
.cdh strong { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.cdn { font-size: 13.5px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 10px; }
.cal-day .btn-sm { align-self: flex-start; }
@media (max-width: 420px) { .cday { gap: 2px; } .cd-num { font-size: 12.5px; } }

/* weekly chart */
.chart { display: flex; align-items: stretch; gap: 6px; height: 170px; margin-top: 4px; }
.cweek { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.cval { font-size: 10px; color: var(--muted); white-space: nowrap; }
.cbar { position: relative; width: 100%; max-width: 26px; height: var(--h); min-height: 3px; background: var(--line); border-radius: 4px 4px 0 0; transform-origin: bottom; transition: filter .2s; }
.cweek:hover .cbar { filter: brightness(1.08); }
.cweek.now .cbar { outline: 2px solid var(--fg); outline-offset: 2px; }
.cfill { position: absolute; left: 0; right: 0; bottom: 0; height: var(--f); background: var(--easy); border-radius: 4px 4px 0 0; transition: height .45s cubic-bezier(.2,.8,.2,1); }
.chart.in .cbar { animation: grow .55s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 45ms); }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.clabel { font-size: 11px; color: var(--muted); white-space: nowrap; }
.cweek.now .clabel { color: var(--fg); font-weight: 600; }
@media (max-width: 520px) { .chart { height: 140px; } .cval { display: none; } }

/* per-session notes */
.note-box { margin-top: 2px; }
.note-box summary { font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; }
.note-box[open] summary { color: var(--fg); }
.note-ta { margin-top: 6px; width: 100%; min-height: 54px; font: inherit; font-size: 13px; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; resize: vertical; }

/* Strava uploads */
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 22px 16px; border: 2px dashed var(--line); border-radius: 10px; color: var(--muted); cursor: pointer; position: relative; }
.drop strong { color: var(--fg); font-weight: 600; }
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--fg); }
.lg-list { display: flex; flex-direction: column; gap: 12px; }
.lg { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.lg-thumb { padding: 0; border: 0; background: none; cursor: zoom-in; align-self: start; min-width: 0; }
.lg-thumb img { width: 100%; height: auto; max-height: 220px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--line); display: block; }
.lg.zoom { grid-template-columns: minmax(0, 1fr); }
.lg.zoom .lg-thumb { cursor: zoom-out; }
.lg.zoom .lg-thumb img { max-height: none; object-fit: contain; }
.lg-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.lg-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.fld { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
.fld input, .fld select { font: inherit; font-size: 14px; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; min-width: 0; }
.fld.wide { grid-column: 1 / -1; }
.lg-msg { font-size: 13px; color: var(--muted); }
.lg-actions { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.btn-sm { font: inherit; font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; }
a.btn-sm { display: inline-block; text-decoration: none; align-self: flex-start; }
a.btn-sm:hover { border-color: var(--fg); }
.btn-sm[disabled] { opacity: .55; cursor: default; }
.btn-sm[data-armed="1"] { background: var(--quality-bg); color: var(--quality); border-color: var(--quality); }
.btn-sm.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.sv-upload { display: flex; flex-direction: column; gap: 10px; }
.sv-cat { max-width: 260px; }
.lg.photo .lg-thumb img { object-fit: cover; }
.lg.photo { border-color: var(--long); }
.row .what .actual { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 13px; color: var(--fg); }

/* thẻ ảnh thu gọn sau khi đã lưu */
.lg-mini { grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; }
.lg-mini .lg-thumb img { max-height: 56px; }
.lg-mini-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lg-mini-top { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-size: 12.5px; color: var(--muted); }
.lg-mini-stats { font-size: 14px; font-weight: 600; }
.lg-mini .hint { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-mini.zoom { grid-template-columns: minmax(0, 1fr); }
.lg-mini.zoom .lg-thumb img { max-height: none; }

/* form sửa ảnh trong chi tiết ngày của lịch */
.cal-cards { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
@media (max-width: 520px) { .lg { grid-template-columns: 88px minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) {
  .bar i, .cfill, .week, .row, .row input, .tabs button, .btn, .meter i { transition: none; }
  .chart.in .cbar, .row.just, .row input:checked, .tabpane.in, .toast { animation: none; }
}

/* ===== Nhập nhanh (log.html) ===== */
.qe-drop { padding: 18px 16px; }
.qe-photo { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; align-items: start; }
.qe-photo img { width: 100%; max-height: 150px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--line); display: block; }
.qe-photo-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; min-width: 0; }
.qe-photo-side .hint.ok { color: var(--easy); }
.qe-photo-side .hint.err { color: var(--quality); }
.qe-photo-side .hint.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--easy); animation: qe-spin .7s linear infinite; vertical-align: -1px; }
@keyframes qe-spin { to { transform: rotate(360deg); } }
.qe-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.qe.reading #qe-km, .qe.reading #qe-pace, .qe.reading #qe-time { animation: qe-pulse 1s ease-in-out infinite; }
@keyframes qe-pulse { 50% { background: var(--easy-bg); } }
.qe-link { display: flex; gap: 10px; align-items: center; font-size: 14px; cursor: pointer; }
.qe-link input { width: 20px; height: 20px; margin: 0; accent-color: var(--easy); flex: 0 0 auto; }
.qe-more { align-self: flex-start; margin-top: 10px; }
.qe-nophoto { display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 6px; border: 1px solid var(--line); background: var(--easy-bg); color: var(--easy); font-family: var(--font-display); font-weight: 600; font-size: 18px; cursor: default; overflow: hidden; }
.lg-acts { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 520px) {
  .lg-mini { grid-template-columns: 56px minmax(0, 1fr) auto; }
  .qe-photo { grid-template-columns: 80px minmax(0, 1fr); }
}

/* ===== Sửa / xóa buổi trong Lịch tập ===== */
.tag-edited { font-size: 11.5px; color: var(--quality); font-weight: 600; }
.sess-edit { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--bg); }
.sess-edit textarea { font: inherit; font-size: 14px; color: var(--fg); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; min-height: 70px; resize: vertical; }
.sess-edit .lg-actions { grid-column: 1 / -1; }
.removed-list { display: flex; flex-direction: column; gap: 6px; }
.removed-item { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 14px; }
.removed-item .hint { flex: 1 1 140px; }
.hint.ok { color: var(--easy); }
.hint.err { color: var(--quality); }
.qe-key { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; align-items: end; border: 1px dashed var(--line); border-radius: 10px; padding: 12px; }
.qe-key .hint { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }

/* ===== Nhập hàng loạt ===== */
.qb-list { display: flex; flex-direction: column; gap: 10px; }
.qb-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.qb-thumb img { width: 100%; max-height: 110px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--line); display: block; }
.qb-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.qb-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.qb-st { font-size: 12.5px; color: var(--muted); }
.qb-st.ok { color: var(--easy); }
.qb-st.err { color: var(--quality); }
.qb-st.busy::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--easy); animation: qe-spin .7s linear infinite; vertical-align: -1px; }
.qb-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.qb-use { display: flex; gap: 6px; align-items: center; font-size: 13px; cursor: pointer; }
.qb-use input { width: 18px; height: 18px; margin: 0; accent-color: var(--easy); }
.hint.busy::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--easy); animation: qe-spin .7s linear infinite; vertical-align: -1px; }

/* ===== Dự đoán thành tích & báo cáo AI ===== */
.pred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.pred-card { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.pred-pace { font-size: 14px; font-weight: 600; color: var(--easy); }
.pred-sub { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin-top: 6px; }
.conf-hi { background: var(--easy-bg); color: var(--easy); }
.conf-mid { background: var(--long-bg); color: var(--long); }
.conf-lo { background: var(--quality-bg); color: var(--quality); }
.zone-list { display: flex; flex-direction: column; }
.zone-row { display: flex; flex-direction: column; gap: 6px; padding: 11px 0; border-top: 1px solid var(--line); font-size: 14px; }
.zone-row:first-child { border-top: 0; padding-top: 2px; }
.zone-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.zone-top strong { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.zone-top strong::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--zc); flex: 0 0 auto; }
.zone-v { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.zone-scale { position: relative; height: 10px; border-radius: 5px; background: var(--rest-bg); }
.zone-scale i { position: absolute; top: 0; bottom: 0; border-radius: 5px; background: var(--zc); }
.zone-row .hint { font-size: 12.5px; }
.zone-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); padding-top: 4px; border-top: 1px solid var(--line); }
.z-easy { --zc: var(--easy); }
.z-tempo { --zc: var(--quality); }
.z-interval { --zc: var(--fg); }
.z-marathon { --zc: var(--long); }
.ai-body h3 { font-family: var(--font-display); font-size: 19px; font-weight: 600; margin: 12px 0 4px; }
.ai-body h3:first-child { margin-top: 0; }
.ai-body p, .ai-body li { font-size: 14px; line-height: 1.55; }
.pace-hint { color: var(--easy); border-left-color: var(--easy); }

/* ===== Giày chạy ===== */
:root { --bad: #C8372D; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bad: #FF7A70; } }
:root[data-theme="dark"] { --bad: #FF7A70; }
.shoe-list { display: flex; flex-direction: column; gap: 10px; }
.shoe { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.shoe.retired { opacity: .7; }
.shoe-top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.shoe-km { margin-left: auto; font-family: var(--font-display); font-size: 18px; font-weight: 600; }
.shoe-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.shoe-bar i { display: block; height: 100%; border-radius: 4px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.shoe-bar i.ok { background: var(--easy); }
.shoe-bar i.warn { background: var(--quality); }
.shoe-bar i.over { background: var(--bad); }
.chip.shoe-ok { background: var(--easy-bg); color: var(--easy); }
.chip.shoe-warn { background: var(--quality-bg); color: var(--quality); }
.chip.shoe-over { background: var(--bad); color: #fff; }
.shoe-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.shoe-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.shoe-form .wide, .shoe-form .lg-actions { grid-column: 1 / -1; }
.qb-shoe { max-width: 320px; }

/* ===== Gợi ý chỉnh giáo án ===== */
.adapt-list { display: flex; flex-direction: column; gap: 10px; }
.adapt-item { border: 1px solid var(--line); border-left: 4px solid var(--easy); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; background: var(--bg); }
.adapt-item.lv-high { border-left-color: var(--quality); }
.adapt-top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.adapt-why { margin: 0; font-size: 14px; line-height: 1.5; }
.adapt-diff { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.adj-why { color: var(--quality); border-left-color: var(--quality); }

/* ===== Thống kê: thanh mục lục dính ===== */
.jump { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 8px); z-index: 30; display: flex; gap: 4px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; scrollbar-width: none; box-shadow: 0 6px 18px rgba(14,37,81,.07); }
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .jump { background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: saturate(150%) blur(10px); -webkit-backdrop-filter: saturate(150%) blur(10px); }
}
.jump::-webkit-scrollbar { display: none; }
.jump a { flex: 0 0 auto; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; transition: background .18s, color .18s; }
.jump a:hover { color: var(--fg); }
.jump a[aria-current="true"] { background: var(--fg); color: var(--bg); }
.jump-sec { scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 72px); }
#s-overview { display: flex; flex-direction: column; gap: 12px; }

/* ===== Thống kê: tuần này ===== */
.week-hero { gap: 14px; }
@supports (color: color-mix(in srgb, red, transparent)) {
  .week-hero { background-image: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--brand-1) 10%, transparent), transparent 62%); }
}
.week-hero .sec-head { margin-bottom: 0; }
.wd-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0 2px; border-radius: 8px; cursor: default; }
.wd-track { width: 100%; max-width: 24px; height: 56px; display: flex; align-items: flex-end; background: var(--rest-bg); border-radius: 6px; overflow: hidden; }
.wd-track i { display: block; width: 100%; background: var(--easy); border-radius: 4px 4px 0 0; animation: grow .55s cubic-bezier(.2,.8,.2,1) both; transform-origin: bottom; }
.wd.today .wd-track { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--fg); }
.wd.fut { opacity: .45; }
.wd.hot .wd-track i { filter: brightness(1.12); }
.wd b { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.wd.today b { color: var(--fg); }
.wd span { font-size: 11px; line-height: 14px; min-height: 14px; color: var(--fg); }

/* ===== Thống kê: ô số liệu ===== */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; box-shadow: 0 4px 14px rgba(14,37,81,.04); }
.tile-l { font-size: 12px; font-weight: 500; color: var(--muted); }
.tile-v { font-family: var(--font-display); font-size: 31px; font-weight: 700; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-v small, .fig b small { font-family: var(--font-body); font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.tile-s, .delta { font-size: 12px; line-height: 1.35; color: var(--muted); }
.delta b { font-weight: 600; }
.delta.good b { color: var(--easy); }
.delta.bad b { color: var(--quality); }

/* số liệu nhỏ đầu mỗi khung */
.figs { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.fig { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fig b { font-family: var(--font-display); font-size: 25px; font-weight: 700; line-height: 1.1; }
.fig span { font-size: 12px; color: var(--muted); }
.seg-sm button { padding: 6px 12px; font-size: 12.5px; }

/* ===== Lịch nhiệt ===== */
.hm { display: flex; flex-direction: column; gap: 4px; }
.hm-months { display: grid; grid-template-columns: repeat(var(--w), minmax(0, 1fr)); gap: 3px; margin-left: 26px; height: 14px; font-size: 10.5px; color: var(--muted); }
.hm-months span { white-space: nowrap; }
.hm-body { display: flex; gap: 6px; }
.hm-days { flex: 0 0 20px; display: grid; grid-template-rows: repeat(7, minmax(0, 1fr)); gap: 3px; font-size: 9.5px; color: var(--muted); }
.hm-days span { display: flex; align-items: center; }
.hm-grid { flex: 1 1 auto; min-width: 0; display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }
.hm-c { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--rest-bg); }
.hm-c.l1 { background: var(--easy-bg); }
.hm-c.l2 { background: var(--easy); opacity: .5; }
.hm-c.l3 { background: var(--easy); opacity: .75; }
.hm-c.l4 { background: var(--easy); }
@supports (color: color-mix(in srgb, red, transparent)) {
  .hm-c.l1 { background: color-mix(in srgb, var(--easy) 26%, var(--surface)); }
  .hm-c.l2 { background: color-mix(in srgb, var(--easy) 50%, var(--surface)); opacity: 1; }
  .hm-c.l3 { background: color-mix(in srgb, var(--easy) 75%, var(--surface)); opacity: 1; }
}
.hm-c.fut { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.hm-c.today { box-shadow: 0 0 0 1.5px var(--fg); }
.hm-c.hot { box-shadow: 0 0 0 2px var(--fg); }
.hm-legend { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.hm-legend .hm-c { width: 12px; }
.hm-legend span:first-child { margin-right: 2px; }
.hm-legend span:last-child { margin-left: 2px; }

/* ===== Biểu đồ cột ===== */
.ch-box { position: relative; min-width: 0; }
.ch-cols { display: flex; flex-direction: column; gap: 6px; padding-top: 20px; }
.ch-plot { position: relative; height: 170px; margin-left: 34px; }
.ch-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--line); }
.ch-grid span { position: absolute; right: calc(100% + 7px); top: 0; transform: translateY(-50%); font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.ch-ref { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px solid var(--muted); z-index: 2; pointer-events: none; }
.ch-ref span { position: absolute; right: 0; bottom: 3px; padding: 0 4px; border-radius: 4px; background: var(--surface); font-size: 10.5px; font-weight: 600; color: var(--muted); }
.ch-bars { position: absolute; inset: 0; display: flex; gap: 4px; }
.ch-col { flex: 1 1 0; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: 6px 6px 0 0; cursor: default; transition: background .15s; }
.ch-col:hover, .ch-col.hot { background: var(--rest-bg); }
.ch-bar { position: relative; width: min(24px, 72%); background: var(--easy); border-radius: 4px 4px 0 0; transform-origin: bottom; animation: grow .55s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i) * 35ms); }
.ch-col.now .ch-bar { background: var(--quality); }
.ch-cap { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 600; color: var(--fg); white-space: nowrap; }
.ch-x { display: flex; gap: 4px; margin-left: 34px; }
.ch-x span { flex: 1 1 0; min-width: 0; text-align: center; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.ch-x span.now { color: var(--fg); font-weight: 600; }
@media (max-width: 520px) { .ch-x span.alt { visibility: hidden; } }

/* chú giải */
.ch-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.ch-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ch-legend i { display: inline-block; flex: 0 0 auto; }
.lk-bar { width: 10px; height: 10px; border-radius: 3px; background: var(--easy); }
.lk-bar.now { background: var(--quality); }
.lk-ref { width: 16px; border-top: 1.5px solid var(--muted); }
.lk-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--easy); opacity: .45; }
.lk-line { width: 18px; border-top: 2px solid var(--easy); border-radius: 1px; }

/* ===== Biểu đồ đường pace ===== */
.ch-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.ch-svg:focus-visible { outline-offset: 4px; border-radius: 6px; }
.ch-gl { stroke: var(--line); stroke-width: 1; }
.ch-tk { fill: var(--muted); font-family: var(--font-body); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.ch-dot { fill: var(--easy); fill-opacity: .42; stroke: var(--surface); stroke-width: 2; }
.ch-line { fill: none; stroke: var(--easy); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-end, .ch-hot { fill: var(--easy); stroke: var(--surface); stroke-width: 2; }
.ch-endl { fill: var(--fg); font-family: var(--font-body); font-size: 12px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.ch-cross { stroke: var(--muted); stroke-width: 1; }
.ch-hit { fill: transparent; cursor: crosshair; }
.ch-empty { padding: 26px 16px; text-align: center; font-size: 13.5px; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }

/* ===== Tooltip chung ===== */
.ch-tip { position: fixed; left: 0; top: 0; z-index: 80; pointer-events: none; min-width: 120px; max-width: 240px; padding: 9px 11px; display: flex; flex-direction: column; gap: 3px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 28px rgba(14,37,81,.18); font-size: 12.5px; line-height: 1.4; }
.ch-tip-h { font-size: 11.5px; color: var(--muted); margin-bottom: 1px; }
.ch-tip-r { display: flex; align-items: baseline; gap: 6px; }
.ch-tip-r b { font-weight: 700; font-variant-numeric: tabular-nums; }
.ch-tip-r span { color: var(--muted); }

/* ===== Thanh ngang ===== */
.hb { display: flex; flex-direction: column; gap: 8px; }
.hb-r { display: grid; grid-template-columns: 74px minmax(0, 1fr) 64px; gap: 10px; align-items: center; padding: 2px 0; border-radius: 6px; font-size: 13px; cursor: default; }
.hb-l { white-space: nowrap; }
.hb-t { height: 14px; }
.hb-t i { display: block; height: 100%; background: var(--easy); border-radius: 0 4px 4px 0; transform-origin: left; animation: grow-x .55s cubic-bezier(.2,.8,.2,1) both; }
.hb-r.hot .hb-t i { filter: brightness(1.12); }
.hb-v { text-align: right; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ===== Bảng số liệu thay cho biểu đồ ===== */
.ch-table summary { font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; }
.ch-table[open] summary { color: var(--fg); margin-bottom: 6px; }
.ch-table table { font-size: 13px; }
.ch-table th, .ch-table td { padding: 6px 14px 6px 0; }

/* ===== Nhận xét ===== */
.insights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.insights li { position: relative; padding: 10px 12px 10px 36px; border-radius: 10px; background: var(--bg); font-size: 13.5px; line-height: 1.5; }
.insights li::before { content: "i"; position: absolute; left: 11px; top: 12px; width: 17px; height: 17px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; line-height: 1; color: var(--surface); background: var(--easy); }
.insights li.warn::before { content: "!"; background: var(--quality); }
.insights li.ok::before { content: "✓"; }

/* ===== Sparkline cột nhỏ (trang chủ) ===== */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; }
.spark i { flex: 1 1 0; max-width: 12px; min-height: 2px; background: var(--easy); opacity: .45; border-radius: 2px 2px 0 0; }
.spark i.now { background: var(--quality); opacity: 1; }
.qstat-trend { display: flex; align-items: flex-end; gap: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.qstat-trend .spark { flex: 0 0 116px; }
.qstat-trend-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 12.5px; color: var(--muted); }
.qstat-trend-t b { color: var(--fg); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .ch-bar, .wd-track i, .hb-t i { animation: none; }
  .goal-bar i, .ch-col { transition: none; }
}

/* ===== Lịch tập: thẻ tổng quan ===== */
.plan-hero { gap: 14px; }
@supports (color: color-mix(in srgb, red, transparent)) {
  .plan-hero { background-image: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--brand-2) 9%, transparent), transparent 62%); }
}
.ph-body { display: flex; flex-direction: column; gap: 14px; }
.ph-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.ph-name { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ph-name h2 { font-size: 27px; line-height: 1.1; }
.ph-name .hint { font-size: 13px; }
.ph-count { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 82px; padding: 9px 10px; border-radius: 12px; background: var(--race-bg); color: var(--race); text-align: center; }
.ph-count b { font-family: var(--font-display); font-size: 30px; font-weight: 800; line-height: 1; }
.ph-count span { font-size: 11px; line-height: 1.3; opacity: .8; }
.ph-prog { display: flex; align-items: center; gap: 10px; }
.ph-prog .bar { flex: 1 1 auto; height: 8px; border-radius: 4px; }
.ph-prog .bar i { background: var(--brand-grad); border-radius: 4px; }
.ph-prog span { font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.pw { display: flex; gap: 4px; height: 104px; padding-top: 4px; }
.pw-w { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0; border: 0; border-radius: 6px; background: none; font: inherit; color: var(--muted); cursor: pointer; }
.pw-col { flex: 1 1 auto; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.pw-bar { width: min(20px, 80%); min-height: 3px; display: flex; align-items: flex-end; overflow: hidden; background: var(--rest-bg); border-radius: 4px 4px 0 0; transform-origin: bottom; animation: grow .55s cubic-bezier(.2,.8,.2,1) both; }
.pw-bar i { display: block; width: 100%; background: var(--easy); }
.pw-w.now .pw-bar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--fg); }
.pw-w.now .pw-n { color: var(--fg); font-weight: 700; }
.pw-w:hover .pw-bar, .pw-w.hot .pw-bar { filter: brightness(.94); }
.pw-n { font-size: 10px; line-height: 1; }
.lk-bar.pw-plan { background: var(--rest-bg); box-shadow: inset 0 0 0 1px var(--line); }
.lk-bar.pw-cur { background: transparent; box-shadow: inset 0 0 0 1.5px var(--fg); }
.ph-list { display: flex; flex-direction: column; gap: 10px; }
.ph-item { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; text-align: left; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .15s; }
.ph-item:hover { border-color: var(--fg); }
.ph-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ph-item-top .num { font-family: var(--font-display); font-size: 19px; font-weight: 700; }
.ph-item .bar { display: block; }
.ph-item .hint { font-size: 12.5px; color: var(--muted); }

/* ===== Lịch tập: lịch tháng ===== */
.cal-sum { text-align: center; margin-top: -4px; }
.cday.done { background: var(--easy-bg); }
.cday.done .cd-num { text-decoration: none; font-weight: 700; color: var(--easy); }
.cday.miss { background: var(--quality-bg); }
.cday.miss .cd-num { color: var(--quality); font-weight: 600; }
.cday.sel, .cday.sel.done, .cday.sel.miss { background: var(--fg); }
.cday.sel .cd-num { color: var(--bg); }
.lg-sw { display: inline-block; width: 12px; height: 12px; border-radius: 4px; }
.lg-sw.done { background: var(--easy-bg); box-shadow: inset 0 0 0 1px var(--easy); }
.lg-sw.miss { background: var(--quality-bg); box-shadow: inset 0 0 0 1px var(--quality); }

/* ===== Lịch tập: buổi trong ngày ===== */
.sess { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 12px 14px 12px 10px; background: var(--bg); border: 1px solid var(--line); border-left: 4px solid var(--sc); border-radius: 12px; }
.s-easy { --sc: var(--easy); }
.s-quality { --sc: var(--quality); }
.s-long { --sc: var(--long); }
.s-race { --sc: var(--fg); }
.sess.done .sess-title { color: var(--muted); }
.sess-check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--easy); cursor: pointer; }
.sess-check input:checked { animation: pop .34s cubic-bezier(.2,.9,.3,1.4); }
.sess-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.sess-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.sess-km { margin-left: auto; font-family: var(--font-display); font-size: 20px; font-weight: 700; line-height: 1; }
.sess-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.sess-st { font-size: 11.5px; font-weight: 600; color: var(--quality); }
.sess-st.ok { color: var(--easy); }
.sess-acts, .rc-acts, .row-foot { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sess-acts { margin-top: 2px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

/* ===== Lịch tập: lịch tuần thu gọn ===== */
details.week > summary { list-style: none; cursor: pointer; }
details.week > summary::-webkit-details-marker { display: none; }
.wk-sum { display: block; padding-bottom: 12px; }
.wk-head::after { content: ""; flex: 0 0 auto; align-self: center; width: 8px; height: 8px; margin: -4px 2px 0 6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
details.week[open] .wk-head::after { transform: rotate(225deg); margin-top: 4px; }
.wk-head .km small { font-family: var(--font-body); font-size: 12.5px; font-weight: 500; color: var(--muted); }
.wk-count { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.wk-bar { margin: 0 16px; height: 5px; }
.week.full .wk-bar i { background: var(--brand-grad); }
.week.past .wk-count { color: var(--quality); }
.row.miss .day b { color: var(--quality); }
.row-foot { margin-top: 2px; }
.row-foot .note-box { margin-top: 0; }
.row-foot .note-box[open] { flex-basis: 100%; }
@media (prefers-reduced-motion: reduce) { .pw-bar { animation: none; } .wk-head::after { transition: none; } }

/* ===== Thẻ buổi chạy (Nhập nhanh, chi tiết ngày) ===== */
.rc-groups { display: flex; flex-direction: column; gap: 18px; }
.rc-week { display: flex; flex-direction: column; gap: 8px; }
.rc-week-h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 0 2px; font-size: 12.5px; color: var(--muted); }
.rc-week-h strong { font-size: 14px; font-weight: 600; color: var(--fg); }
.rc { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; transition: border-color .15s, box-shadow .15s; }
.cal-day .rc { background: var(--bg); }
.rc-log { grid-template-columns: 46px minmax(0, 1fr) auto; }
.rc.editing { border-color: var(--easy); box-shadow: 0 0 0 3px var(--easy-bg); }
.rc-date { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 54px; border-radius: 10px; background: var(--easy-bg); color: var(--easy); }
.rc-date b { font-family: var(--font-display); font-size: 23px; font-weight: 700; line-height: 1; }
.rc-date span { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; }
.rc-main { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rc-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.rc-top .hint { font-size: 12px; color: var(--muted); }
.rc-stats { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; font-size: 12.5px; color: var(--muted); }
.rc-stats b { font-family: var(--font-display); font-size: 21px; font-weight: 700; color: var(--fg); }
.rc-note { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-acts { margin-top: 2px; }
.rc-pic img { display: block; width: 56px; height: 74px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--line); }

/* ===== Nhập nhanh: form ===== */
.seg-fill { display: flex; width: 100%; }
.seg-fill button { flex: 1 1 0; padding: 10px 8px; font-size: 14px; font-weight: 600; transition: background .15s, color .15s; }
.qe-days { display: flex; gap: 6px; margin-top: 6px; }
.qe-days button { flex: 1 1 0; min-width: 0; white-space: nowrap; padding: 4px 4px; font: inherit; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.qe-days button[aria-pressed="true"] { color: var(--easy); background: var(--easy-bg); border-color: var(--easy); }
.qe-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.qe-nums input { padding: 8px 6px; font-family: var(--font-display); font-size: 23px; font-weight: 600; text-align: center; border-radius: 8px; }
.qe-nums input::placeholder { color: var(--muted); opacity: .45; }
.qe-nums input.is-auto { color: var(--easy); background: var(--easy-bg); border-color: transparent; }
.qe-calc { margin-top: -4px; }
.qe-calc.ok { color: var(--easy); }
.qe-actions { display: flex; align-items: center; gap: 10px; }
.qe-save { flex: 1 1 auto; padding: 13px 18px; font-size: 15px; text-align: center; }
.btn[disabled] { opacity: .6; cursor: default; }
