:root {
  --bg: #0c0f14;
  --elev: #151a22;
  --card: #1c232e;
  --line: #313a48;
  --text: #f4f1ea;
  --muted: #a8b1be;
  --gold: #e8a838;
  --gold-ink: #2a1c04;
  --blue: #6ea2ff;
  --blue-ink: #071426;
  --green: #3dbe8c;
  --green-ink: #042218;
  --rest: #9aa6b8;
  --danger: #ff8b7a;
  --ok: #8ee0b0;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

#app { min-height: 100dvh; }

.shell {
  width: min(520px, 100%);
  margin: 0 auto;
  padding: calc(12px + var(--safe-t)) 16px calc(92px + var(--safe-b));
}
.shell.workout {
  padding-bottom: calc(108px + var(--safe-b));
}

.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
h1 { font-size: 1.7rem; line-height: 1.1; margin: 0; letter-spacing: -0.03em; }
h2 { font-size: 1.25rem; margin: 0 0 8px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 0.92rem; }
.tiny { font-size: 0.8rem; color: var(--muted); }

.phase-card, .card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 14px 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
}
.phase-card { background: linear-gradient(180deg, #243044, #1c232e); }
.phase-card strong { color: var(--gold); }

.days { display: grid; gap: 10px; margin-top: 12px; }
.day-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 76px;
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  text-align: left;
}
.day-btn .t { font-size: 1.35rem; font-weight: 750; letter-spacing: -0.02em; }
.day-btn .s { display: block; font-size: 0.95rem; opacity: 0.85; font-weight: 550; }
.day-btn.a { background: var(--gold); color: var(--gold-ink); }
.day-btn.b { background: var(--blue); color: var(--blue-ink); }
.day-btn.c { background: var(--green); color: var(--green-ink); }
.day-btn.rest { background: #2a3140; color: var(--text); }
.day-btn.today { outline: 3px solid #fff; outline-offset: 2px; }
.tag {
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(0,0,0,0.18);
  padding: 4px 8px;
  border-radius: 999px;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }

label.field { display: grid; gap: 4px; font-size: 0.85rem; color: var(--muted); margin: 8px 0; }
input[type="date"], input[type="number"], input[type="text"], select, textarea {
  background: #0e131b;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 48px;
  width: 100%;
}
textarea { min-height: 72px; }

.btn, .btn-ghost, .btn-line {
  border-radius: 14px;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  font-weight: 700;
}
.btn { background: var(--text); color: #14181f; }
.btn.danger { background: var(--danger); color: #2a0d0a; }
.btn-ghost { background: #2a3342; color: var(--text); }
.btn-line { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn[aria-pressed="true"], .chip[aria-pressed="true"] { outline: 2px solid #fff; }
.chip {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #121820;
  font-weight: 700;
}
.chip.on { background: var(--text); color: #14181f; }

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 10px calc(8px + var(--safe-b));
  background: rgba(12, 15, 20, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.nav button {
  background: transparent;
  border: 0;
  color: var(--muted);
  min-height: 48px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.85rem;
}
.nav button.on { color: var(--text); background: #222a36; }

.sticky {
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(12, 15, 20, 0.94);
  backdrop-filter: blur(10px);
  margin: 0 -16px;
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.clock {
  font-variant-numeric: tabular-nums;
  font-size: 1.8rem;
  font-weight: 760;
  letter-spacing: -0.04em;
}
.rest-live {
  margin-top: 8px;
  background: #101820;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.rest-live .num {
  font-variant-numeric: tabular-nums;
  font-size: 2rem;
  font-weight: 780;
  letter-spacing: -0.04em;
}
.rest-live.over .num { color: var(--gold); }
.rest-live.hold { background: #14201c; }

.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-b));
  background: rgba(12, 15, 20, 0.96);
  border-top: 1px solid var(--line);
}
.dock button { min-height: 54px; border-radius: 14px; font-weight: 780; }
.dock .btn { border: 0; }
.dock .btn-ghost { border: 0; }

.rx {
  font-size: 1.45rem;
  font-weight: 780;
  letter-spacing: -0.03em;
  margin: 6px 0;
}
.frames {
  position: relative;
  background: #f6f3ec;
  border-radius: 16px;
  min-height: 210px;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.frames img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 1;
}
.frames.anim img { opacity: 0; }
.frames.n2 img { animation: on2 1.4s infinite steps(1, end); }
.frames.n2 img:nth-child(2) { animation-delay: -0.7s; }
.frames.n3 img { animation: on3 2.1s infinite steps(1, end); }
.frames.n3 img:nth-child(2) { animation-delay: -0.7s; }
.frames.n3 img:nth-child(3) { animation-delay: -1.4s; }
@keyframes on2 {
  0% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 0; }
}
@keyframes on3 {
  0% { opacity: 1; }
  33.34% { opacity: 0; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .frames.anim img { animation: none !important; opacity: 0; }
  .frames.anim img:first-child { opacity: 1; }
}

.text-only {
  background: #10161f;
  border-radius: 14px;
  padding: 12px;
  border: 1px dashed var(--line);
}
.note {
  background: #2a2418;
  border-radius: 12px;
  padding: 10px 12px;
  color: #f3e2bf;
  margin: 8px 0;
}
.warn {
  background: #2a1a1a;
  color: #ffd0c8;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
}
.checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  background: #121820;
  border-radius: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
}
.check input { width: 22px; height: 22px; }

.seg {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 0.6fr;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 12px;
  margin: 4px 0;
}
.seg.on { background: #243044; outline: 1px solid var(--blue); }
.seg .k { font-weight: 750; }
.now {
  font-size: 1.35rem;
  font-weight: 780;
  letter-spacing: -0.03em;
}

.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.dow { text-align: center; color: var(--muted); font-size: 0.75rem; padding: 4px 0; }
.day {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: #121820;
  color: var(--text);
  position: relative;
  font-weight: 700;
}
.day.empty { background: transparent; }
.day.today { border-color: #fff; }
.day.type-a { background: #6a4a12; color: #ffe7b8; }
.day.type-b { background: #1d3f78; color: #e4eeff; }
.day.type-c { background: #0f5a3d; color: #d9ffef; }
.day.type-rest { background: #3a4252; color: #e7ebf2; }
.day .mark {
  display: block;
  width: 10px; height: 10px;
  border-radius: 99px;
  margin: 3px auto 0;
}
.mark.a { background: var(--gold); }
.mark.b { background: var(--blue); }
.mark.c { background: var(--green); }
.mark.rest { background: var(--rest); }
.mark.weight { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }

.list { margin: 0; padding-left: 1.1rem; }
.list li { margin: 6px 0; }
details { margin: 8px 0; }
summary { min-height: 44px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }

.flash {
  background: #163024;
  color: var(--ok);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
}
.dots { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; }
.dots button {
  width: 36px; height: 36px; border-radius: 99px;
  border: 0; background: #3a4454; padding: 0;
}
.dots button.on { background: var(--text); transform: scale(1.15); }
.thumb {
  width: 72px; height: 56px; object-fit: contain;
  background: #f6f3ec; border-radius: 8px; float: right; margin-left: 8px;
}
.checklist { display: grid; gap: 10px; }
.checklist article { overflow: auto; }

a { color: #9dc0ff; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
