:root {
  --navy: #102a43;
  --navy-2: #1b3d5d;
  --blue: #2f80aa;
  --coral: #ff715b;
  --lime: #b8df4f;
  --ink: #172b3a;
  --muted: #667b8b;
  --paper: #f4f7f8;
  --white: #fff;
  --line: #dce5e9;
  --green: #1f8a5b;
  --shadow: 0 10px 30px rgba(16,42,67,.12);
}
* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
#app { min-height: 100dvh; max-width: 760px; margin: 0 auto; padding-bottom: 90px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 20px 12px;
  position: sticky; top: 0; z-index: 5;
  background: rgba(244,247,248,.94); backdrop-filter: blur(18px);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 32px; line-height: 1.05; }
h2 { font-size: 24px; margin-bottom: 8px; }
h3 { font-size: 16px; margin-bottom: 4px; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.icon-button {
  width: 42px; height: 42px; border: 0; border-radius: 50%;
  background: var(--white); color: var(--navy); font-size: 21px; box-shadow: 0 2px 12px rgba(16,42,67,.08);
}
main { padding: 8px 16px 20px; }
.view { display: none; }
.view.active { display: block; animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } }
.hero {
  min-height: 218px; border-radius: 8px; overflow: hidden; position: relative;
  background: var(--navy) url("./assets/training-banner.png") center/cover no-repeat;
  color: white; padding: 24px; display: flex; align-items: flex-end; box-shadow: var(--shadow);
}
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(6,24,41,.94) 0%, rgba(6,24,41,.6) 45%, transparent 76%); }
.hero-content { position: relative; z-index: 1; max-width: 52%; }
.hero h2 { font-size: 30px; margin: 0 0 7px; }
.hero p { color: #d5e4ee; line-height: 1.45; margin-bottom: 16px; }
.primary, .secondary, .file-button {
  border: 0; border-radius: 7px; min-height: 46px; padding: 0 18px; font-weight: 750;
  display: inline-flex; align-items: center; justify-content: center;
}
.primary { background: var(--coral); color: white; }
.secondary, .file-button { background: #e8f0f3; color: var(--navy); }
.wide { width: 100%; margin-top: 10px; }
.section-head { display: flex; align-items: end; justify-content: space-between; margin: 26px 2px 12px; }
.section-head h2 { margin: 0; font-size: 21px; }
.section-head button { border: 0; background: none; color: var(--blue); font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
.stat { background: var(--white); padding: 14px; border-radius: 7px; border: 1px solid var(--line); }
.stat strong { display: block; font-size: 23px; color: var(--navy); }
.stat span { font-size: 12px; color: var(--muted); }
.exercise-list, .day-list { display: grid; gap: 9px; }
.exercise {
  background: var(--white); border: 1px solid var(--line); border-radius: 7px;
  padding: 14px; display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center;
}
.exercise.done { background: #edf8f2; border-color: #c4e7d5; }
.check {
  width: 30px; height: 30px; border: 2px solid #b6c5ce; border-radius: 50%; background: white; color: white; padding: 0;
}
.done .check { background: var(--green); border-color: var(--green); }
.exercise-meta { color: var(--muted); font-size: 13px; }
.log-button { border: 0; background: #eaf1f4; color: var(--navy); padding: 8px 10px; border-radius: 6px; font-weight: 700; }
.day-card { background: white; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.day-head { display: flex; justify-content: space-between; padding: 15px; background: #eef4f6; }
.day-head strong:last-child { color: var(--blue); }
.day-body { padding: 5px 15px 12px; }
.day-body p { padding: 9px 0; margin: 0; border-bottom: 1px solid #edf1f3; display: flex; justify-content: space-between; gap: 10px; }
.day-body p:last-child { border: 0; }
.day-body span { color: var(--muted); white-space: nowrap; }
.progress-panel { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 18px; }
.progress-number { font-size: 42px; font-weight: 800; color: var(--navy); margin: 3px 0; }
.goal-track { height: 10px; background: #e8eef1; border-radius: 8px; overflow: hidden; margin: 14px 0 7px; }
.goal-fill { height: 100%; background: var(--lime); border-radius: inherit; }
.chart { width: 100%; height: 190px; display: block; margin-top: 12px; }
.chart-grid { stroke: #dfe7ea; stroke-width: 1; }
.chart-line { stroke: var(--coral); stroke-width: 4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: rgba(255,113,91,.12); }
.chart-dot { fill: var(--coral); stroke: white; stroke-width: 3; }
.empty { text-align: center; padding: 30px 12px; color: var(--muted); }
.posture-intro { padding: 18px; background: var(--navy); color: white; border-radius: 7px; }
.posture-intro p { color: #d4e2eb; margin-bottom: 0; }
.tabbar {
  position: fixed; z-index: 8; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(760px, 100%); height: calc(68px + env(safe-area-inset-bottom));
  padding: 7px 12px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255,255,255,.96); backdrop-filter: blur(18px); border-top: 1px solid var(--line);
}
.tab { border: 0; background: none; color: #7c8e9a; font-size: 11px; display: grid; place-items: center; align-content: center; gap: 3px; }
.tab.active { color: var(--navy); font-weight: 750; }
.tab-icon { font-size: 20px; line-height: 1; }
dialog { width: min(520px, calc(100vw - 32px)); max-width: none; border: 0; border-radius: 8px; padding: 22px; box-shadow: 0 24px 80px rgba(16,42,67,.3); }
dialog::backdrop { background: rgba(7,24,39,.52); backdrop-filter: blur(4px); }
.modal-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 650; margin: 12px 0; }
input, textarea { width: 100%; border: 1px solid #cbd8de; border-radius: 6px; padding: 12px; color: var(--ink); background: #fbfcfd; outline: none; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,128,170,.12); }
.file-button input { display: none; }
.danger-link { width: 100%; border: 0; background: none; color: #c84545; padding: 18px; margin-top: 6px; }
.muted { color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 14px); opacity: 0; pointer-events: none; background: var(--ink); color: white; padding: 10px 16px; border-radius: 7px; transition: .2s; z-index: 20; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 520px) {
  .hero { min-height: 205px; padding: 18px; background-position: 58% center; }
  .hero-content { max-width: 66%; }
  .hero h2 { font-size: 25px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:last-child { grid-column: 1 / -1; }
}
@media (display-mode: standalone) { .topbar { padding-top: calc(12px + env(safe-area-inset-top)); } }
