:root {
  --bg: #f5f5f4; --card: #fff; --text: #1c1917; --muted: #78716c; --line: #e7e5e4;
  --push: #dc2626; --pull: #2563eb; --leg: #16a34a; --accent: #1c1917;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c0a09; --card: #1c1917; --text: #f5f5f4; --muted: #a8a29e; --line: #292524; --accent: #f5f5f4; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif; font-size: 16px; }
main { max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 12px 96px; }
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
h1 { font-size: 18px; margin: 0; }
button { font: inherit; color: inherit; background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; cursor: pointer; }
button:active { transform: scale(.97); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }

/* date bar */
.datebar { display: flex; align-items: center; gap: 8px; }
.datebar .date { font-size: 18px; font-weight: 600; flex: 1; text-align: center; cursor: pointer; }
/* calendar */
.cal { margin-top: 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-grid .dow { font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-grid .day { border: none; padding: 6px 0 4px; border-radius: 8px; min-height: 42px; display: flex;
  flex-direction: column; align-items: center; gap: 3px; }
.cal-grid .day.other { opacity: .35; }
.cal-grid .day.today { outline: 1px solid var(--muted); }
.cal-grid .day.sel { background: var(--accent); color: var(--bg); }
.dots { display: flex; gap: 2px; height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.push { background: var(--push); } .dot.pull { background: var(--pull); } .dot.leg { background: var(--leg); }

/* PPL tabs */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tab { padding: 12px 0; font-weight: 700; letter-spacing: .05em; border-width: 2px; position: relative; }
.tab.push.on { background: var(--push); border-color: var(--push); color: #fff; }
.tab.pull.on { background: var(--pull); border-color: var(--pull); color: #fff; }
.tab.leg.on  { background: var(--leg);  border-color: var(--leg);  color: #fff; }
.tab .badge { position: absolute; top: 4px; right: 6px; font-size: 10px; }

.status { font-size: 13px; padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; background: var(--card); border: 1px dashed var(--line); }
.status.saved { border-style: solid; }

/* exercise */
.ex-title { font-weight: 700; margin-bottom: 2px; }
.prev { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.set { display: grid; grid-template-columns: 28px 1fr 1fr 32px; gap: 6px; align-items: center; margin-bottom: 6px; }
.set .n { color: var(--muted); font-size: 13px; text-align: center; }
.field { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: var(--bg); }
.field input { width: 100%; border: none; background: none; color: inherit; font: inherit; font-size: 18px;
  padding: 8px 0; text-align: right; outline: none; }
.field span { color: var(--muted); font-size: 13px; margin-left: 4px; }
.icon { border: none; padding: 4px; color: var(--muted); }
.addset { width: 100%; border-style: dashed; color: var(--muted); font-size: 14px; }

.savebar { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); }
.savebar .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; }
.primary { flex: 1; background: var(--accent); color: var(--bg); border-color: var(--accent); padding: 12px; font-weight: 700; }

/* settings */
dialog { border: none; border-radius: 14px; padding: 0; width: min(560px, 94vw); max-height: 88vh;
  background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.dlg-body { padding: 14px; overflow: auto; max-height: calc(88vh - 56px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ex-item { display: flex; align-items: center; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ex-item input { flex: 1; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.addrow { display: flex; gap: 6px; margin-top: 8px; }
.addrow input { flex: 1; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
h3 { margin: 16px 0 6px; font-size: 15px; }
h3.push { color: var(--push); } h3.pull { color: var(--pull); } h3.leg { color: var(--leg); }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--accent); color: var(--bg);
  padding: 8px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
