:root {
  --bg: #0e1014; --surface: #171a21; --surface-2: #1f232c; --border: #2a2f3a;
  --track: #262b35; --text: #e7e9ee; --text-muted: #8b909c; --accent: #f2a25f; --radius: 13px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: radial-gradient(1100px 500px at 75% -10%, #221a16 0%, var(--bg) 55%); color: var(--text); font-family: 'Inter', system-ui, sans-serif; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { font-size: 24px; }
.topbar h1 { font-family: 'Fraunces', serif; font-size: 21px; margin: 0; }
.tagline { margin: 0; font-size: 12px; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.db-indicator { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; }
.db-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); }
.db-dot.ok { background: #5fd28a; box-shadow: 0 0 7px rgba(95,210,138,.7); }
.db-dot.off { background: #f2554d; }

.tabbar { display: flex; align-items: center; gap: 6px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.tab { background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); border-radius: 9px; padding: 7px 15px; cursor: pointer; font: inherit; font-size: 13px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #1a0f06; font-weight: 600; }
.add-btn { margin-left: auto; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 7px 14px; cursor: pointer; font: inherit; font-size: 13px; }
.add-btn:hover { border-color: var(--accent); }

.wrap { max-width: 720px; margin: 0 auto; padding: 22px 20px 60px; }
.day-head, .week-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.day-head h2 { font-family: 'Fraunces', serif; font-size: 22px; margin: 0; }
.big { font-size: 16px; padding: 30px 0; text-align: center; }

.cards { display: flex; flex-direction: column; gap: 10px; }
.session { display: flex; align-items: center; gap: 13px; text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 13px 15px; cursor: pointer; color: var(--text); transition: background .12s, border-color .12s; }
.session:hover { border-color: var(--accent); }
.session.done { background: color-mix(in srgb, var(--surface) 80%, #2f5d3f 20%); }
.session-check { width: 24px; height: 24px; flex: none; border: 1.5px solid var(--border); border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #0b1220; }
.session.done .session-check { background: #5fd28a; border-color: #5fd28a; }
.session-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.session-name { font-size: 15px; font-weight: 600; }
.session.done .session-name { text-decoration: line-through; color: var(--text-muted); }
.session-groups { font-size: 12px; color: var(--text-muted); }
.session-meta { font-size: 13px; text-align: right; flex: none; }

.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.week-col { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-height: 90px; }
.week-dow { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; text-align: center; }
.week-dow.is-today { color: var(--accent); font-weight: 700; }
.chip { font-size: 10.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 5px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.done { background: rgba(95,210,138,.18); border-color: transparent; color: #5fd28a; }
.chip.rest { color: var(--text-muted); opacity: .6; }
@media (max-width: 600px) { .week-grid { grid-template-columns: repeat(3, 1fr); } }

.manage-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 12px 15px; }
.manage-row .muted { font-size: 12px; grid-column: 1; }
.manage-actions { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 6px; }
.ghost { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 11px; cursor: pointer; font: inherit; font-size: 12px; }
.ghost:hover { border-color: var(--accent); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 420px; max-width: 100%; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-family: 'Fraunces', serif; font-size: 17px; margin: 0; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.f { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.f > span { color: var(--text-muted); }
input, select { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 7px 10px; font: inherit; }
.f input:not([style]) { flex: 1; }
.day-picks { display: flex; gap: 4px; }
.day-pick { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); border-radius: 7px; padding: 6px 8px; cursor: pointer; font: inherit; font-size: 11px; }
.day-pick.on { background: var(--accent); border-color: var(--accent); color: #1a0f06; font-weight: 600; }
.save { background: var(--accent); color: #1a0f06; border: none; border-radius: 9px; padding: 9px 16px; font-weight: 600; cursor: pointer; margin-top: 4px; }

/* session card split into check + open */
.session { padding: 0; overflow: hidden; }
.session-check-btn { background: none; border: none; border-right: 1px solid var(--border); padding: 0 14px; align-self: stretch; cursor: pointer; display: flex; align-items: center; }
.session-open { flex: 1; display: flex; align-items: center; gap: 13px; background: none; border: none; color: var(--text); cursor: pointer; padding: 13px 15px; text-align: left; min-width: 0; }
.session-open:hover { background: rgba(242,162,95,.06); }

/* ---------- routine viewer ---------- */
.ex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 460px) { .ex-grid { grid-template-columns: 1fr; } }
.ex-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px; text-align: center; }
.ex-illo { background: #11141a; border-radius: 9px; margin-bottom: 8px; }
.ex-name { font-size: 13px; font-weight: 600; }
.ex-sets { font-size: 12px; color: var(--accent); margin-top: 2px; }

/* ---------- animated exercise figures ---------- */
.ex-anim { width: 100%; height: 92px; display: block; color: var(--accent); }
.ex-anim line, .ex-anim circle { stroke: currentColor; stroke-width: 3; stroke-linecap: round; fill: none; }
.ex-anim .ground, .ex-anim .bar { stroke: var(--border); stroke-width: 2.5; }
.ex-anim g { transform-box: fill-box; }

.anim-pushup .mover { transform-origin: 92% 100%; animation: a-pushup 1.3s ease-in-out infinite; }
@keyframes a-pushup { 0%,100% { transform: rotate(0) } 50% { transform: rotate(-11deg) translateY(3px) } }

.anim-squat .mover { transform-origin: 50% 100%; animation: a-squat 1.4s ease-in-out infinite; }
@keyframes a-squat { 0%,100% { transform: translateY(0) scaleY(1) } 50% { transform: translateY(11px) scaleY(.8) } }

.anim-pullup .mover { transform-origin: 50% 0%; animation: a-pullup 1.5s ease-in-out infinite; }
@keyframes a-pullup { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-13px) } }

.anim-core .legs { transform-origin: 0% 50%; animation: a-core 1.6s ease-in-out infinite; }
@keyframes a-core { 0%,100% { transform: rotate(0) } 50% { transform: rotate(-52deg) } }

.anim-run .legA, .anim-run .armB { transform-origin: 50% 0%; animation: a-swingA .5s ease-in-out infinite; }
.anim-run .legB, .anim-run .armA { transform-origin: 50% 0%; animation: a-swingB .5s ease-in-out infinite; }
@keyframes a-swingA { 0%,100% { transform: rotate(24deg) } 50% { transform: rotate(-24deg) } }
@keyframes a-swingB { 0%,100% { transform: rotate(-24deg) } 50% { transform: rotate(24deg) } }

.anim-jump .mover { transform-origin: 50% 100%; animation: a-hop .8s ease-in-out infinite; }
.anim-jump .armA { transform-origin: 50% 0%; animation: a-jackA .8s ease-in-out infinite; }
.anim-jump .armB { transform-origin: 50% 0%; animation: a-jackB .8s ease-in-out infinite; }
@keyframes a-hop { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-7px) } }
@keyframes a-jackA { 0%,100% { transform: rotate(0) } 50% { transform: rotate(-120deg) } }
@keyframes a-jackB { 0%,100% { transform: rotate(0) } 50% { transform: rotate(120deg) } }

@media (prefers-reduced-motion: reduce) { .ex-anim * { animation: none !important; } }
