:root {
  --bg: #f1f5f9;
  --card: #fff;
  --ink: #0f172a;
  --muted: #64748b;
  --brand: #1e40af;
  --brand-2: #0f766e;
  --warn: #b45309;
  --danger: #b91c1c;
  --line: #e2e8f0;
  --yellow: #fef3c7;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "SF Pro Text", Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100dvh;
  padding-bottom: var(--safe-bottom);
}

.top {
  background: var(--ink);
  color: #fff;
  padding: calc(12px + var(--safe-top)) 16px 0;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}
.brand-mark {
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.brand-text {
  flex: 1;
  min-width: 0;
}
.top h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.sub { margin: 2px 0 0; color: #94a3b8; font-size: .82rem; }
.today-date {
  margin: 4px 0 8px;
  color: #e2e8f0;
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.header-reload {
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 36px;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  touch-action: manipulation;
}
.header-reload:hover,
.header-reload:active {
  background: rgba(255, 255, 255, 0.2);
  filter: none;
  color: #fff;
}

.home-date-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.home-date-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
}
.home-date-value {
  font-size: 1.1rem;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding-bottom: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: transparent;
  border: 0;
  color: #cbd5e1;
  padding: 12px 14px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  min-height: 44px; /* iOS tap target */
  touch-action: manipulation;
}
.tab.active { background: var(--bg); color: var(--ink); }
.badge {
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: .75rem;
  margin-left: 4px;
}
.tab.active .badge { background: var(--brand-2); }

main { max-width: 920px; margin: 0 auto; padding: 20px 16px 48px; }
.panel { display: none; }
.panel.active { display: block; }

.flow {
  background: #1e3a5f;
  color: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.flow ol { margin: 8px 0 0 18px; }

.core-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 900px) {
  .core-grid { grid-template-columns: 1fr 1fr; }
}

.pocket-h {
  margin: 22px 0 6px;
  font-size: 1.05rem;
  color: var(--ink);
}
.pocket-badge {
  display: inline-block;
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #d1fae5;
  color: #065f46;
  padding: 3px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 6px;
}
.hint.tight { margin-top: 0; margin-bottom: 10px; }

.marker-disclaimer {
  margin: 12px 0 4px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px dashed #94a3b8;
  border-radius: 10px;
  font-size: .82rem;
  color: #475569;
  line-height: 1.45;
}
.marker-disclaimer strong { color: var(--ink); }

.rules-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 4px;
}
.rule-pill {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #1e293b;
  color: #fbbf24;
  padding: 6px 10px;
  border-radius: 999px;
}

.more-muscles {
  margin: 18px 0 8px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fafafa;
  padding: 0 12px 10px;
}
.more-muscles summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 4px;
  list-style: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  touch-action: manipulation;
}
.more-muscles summary::-webkit-details-marker { display: none; }
.more-muscles summary::before {
  content: "▸";
  color: var(--muted);
  display: inline-block;
  transition: transform .15s ease;
}
.more-muscles[open] summary::before { transform: rotate(90deg); }

.pe-fail {
  margin: 0 0 8px;
  padding: 8px 10px;
  background: #fff7ed;
  border-left: 3px solid #ea580c;
  border-radius: 0 8px 8px 0;
  font-size: .82rem;
  color: #9a3412;
}
.pe-fail strong { color: #9a3412; }

.arc-note {
  margin: 0 0 8px;
  font-size: .82rem;
  color: #475569;
  font-weight: 600;
}
.arc-note.pick2 {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 8px;
  padding: 8px 10px;
  color: #065f46;
}
.pick2-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #059669;
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.arc-card.arc-close {
  border-color: #6ee7b7;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.15);
}

.arc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
@media (min-width: 800px) {
  .arc-grid { grid-template-columns: 1fr 1fr 1fr; }
}
.arc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.arc-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}
.arc-card h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--brand);
}
.arc-focus {
  margin: 0 0 8px;
  font-size: .88rem;
  color: #334155;
  font-weight: 600;
}
.marker-chip {
  display: inline-block;
  font-size: .68rem;
  font-weight: 700;
  background: #e0f2fe;
  color: #0c4a6e;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.muscle-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.filter-chip {
  background: #e2e8f0;
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 36px;
  font-size: .82rem;
  font-weight: 600;
}
.filter-chip.active {
  background: var(--brand);
  color: #fff;
}

.muscle-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(15,23,42,.04);
}
.muscle-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}
.muscle-card h3 { margin: 0; color: var(--brand); font-size: 1rem; }
.muscle-card .short { color: #334155; font-size: .9rem; margin: 0 0 8px; }
.muscle-card h4 {
  margin: 10px 0 4px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

/* Drill cards tab */
.drill-list { display: grid; gap: 12px; margin-top: 8px; }
.drill-card-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px 8px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.drill-card-panel.is-active {
  border-color: #99f6e4;
  box-shadow: 0 0 0 1px #5eead4;
}
.drill-card-panel summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 4px;
  min-height: 44px;
  touch-action: manipulation;
}
.drill-card-panel summary::-webkit-details-marker { display: none; }
.drill-summary-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.drill-title {
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--ink);
}
.active-badge {
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #d1fae5;
  color: #065f46;
  padding: 3px 8px;
  border-radius: 999px;
}
.drill-sub {
  display: block;
  margin-top: 4px;
  font-size: .85rem;
  color: var(--muted);
  font-weight: 500;
}
.drill-body { padding-bottom: 10px; }
.drill-h {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 14px 0 8px;
}
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.pill {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #1e293b;
  color: #fbbf24;
  padding: 4px 8px;
  border-radius: 999px;
}
.rules {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: .9rem;
}
.rules strong { color: #9a3412; }
.rules ol { margin: 8px 0 0 18px; padding: 0; }
.rules li { margin: 4px 0; }
.drill {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.drill .n {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 6px;
  background: #1e3a5f;
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  margin-right: 6px;
}
.avoid {
  font-size: .82rem;
  color: var(--danger);
  text-decoration: line-through;
  opacity: .9;
  margin: 6px 0;
}
.muscle {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  background: #e0f2fe;
  color: #0c4a6e;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 8px;
}
.after {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: .9rem;
  margin-top: 8px;
}
.after h3 {
  margin: 0 0 6px;
  font-size: .85rem;
  color: var(--brand-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.after.red {
  background: #fef2f2;
  border-color: #fecdd3;
}
.after.red h3 { color: var(--danger); }
.after p { margin: 0; }

.howto-card { margin-top: 12px; }
.howto-card h3 { margin: 0 0 8px; font-size: 1rem; color: var(--brand); }
.simple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.simple-table th,
.simple-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.simple-table th { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.link-list { margin: 0; padding-left: 18px; }
.link-list a { color: var(--brand); font-weight: 600; }
.stem {
  background: #fefce8;
  border-left: 4px solid #eab308;
  padding: 6px 8px;
  margin: 4px 0;
  font-size: .85rem;
  font-style: italic;
  border-radius: 4px;
}
.guard { color: #991b1b; font-size: .82rem; margin: 0; padding-left: 16px; }
.micro { font-size: .85rem; margin: 0; padding-left: 18px; }

.form, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
}
.form label, fieldset label {
  display: block;
  margin: 10px 0;
  font-size: .92rem;
  font-weight: 600;
}
.form input[type="text"],
.form input[type="date"],
.form select,
.form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  max-width: 100%;
}
.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 700px) {
  .row { grid-template-columns: 1fr 1fr; }
  .row.triple { grid-template-columns: 1fr 1fr 1fr; }
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 14px 0;
  padding: 10px 12px 4px;
}
legend { padding: 0 6px; color: var(--muted); font-size: .85rem; }
label.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
label.inline input { width: auto; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
button {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
  min-height: 44px;
  touch-action: manipulation;
}
button.primary { background: var(--brand); color: #fff; }
button.ghost { background: #e2e8f0; color: var(--ink); }
button.danger { background: #fee2e2; color: var(--danger); }
button:hover { filter: brightness(0.97); }

.counters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 600px) {
  .counters { grid-template-columns: 1fr 1fr; }
}
.counter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .9rem;
}
.counter div { display: flex; align-items: center; gap: 8px; }
.counter button {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--brand);
  color: #fff;
  font-size: 1.1rem;
}
.counter strong { min-width: 1.5rem; text-align: center; }

.hint { color: var(--muted); font-size: .92rem; }
.howto h3 { margin-top: 0; }
.progress {
  margin: 14px 0;
  padding: 12px 14px;
  background: var(--yellow);
  border-radius: 10px;
  font-weight: 600;
}
.log-list { display: grid; gap: 10px; margin-top: 12px; }
.log-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.log-item header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: .85rem;
  color: var(--muted);
}
.log-item h3 { margin: 4px 0; font-size: 1rem; }
.log-item p { margin: 4px 0; font-size: .9rem; }
.log-item .del {
  background: transparent;
  color: var(--danger);
  padding: 0;
  font-size: .85rem;
}

.foot {
  text-align: center;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  color: var(--muted);
  font-size: .85rem;
}
.foot a { color: var(--brand); }
.install-hint {
  margin-top: 10px;
  padding: 10px 12px;
  background: #e0f2fe;
  color: #0c4a6e;
  border-radius: 10px;
  font-size: .88rem;
}
@media (display-mode: standalone) {
  .install-hint { display: none; }
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: .9rem;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}

/* ——— Phase 1: quick log ——— */
.pocket-cta { margin-top: 16px; }
.section-label {
  margin: 0 0 8px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
}
.quick-log {
  padding-bottom: 4px;
}
.chip-fieldset {
  border: 0;
  margin: 12px 0;
  padding: 0;
}
.chip-fieldset legend {
  padding: 0;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: .92rem;
  font-weight: 600;
}
.chip-fieldset .req { color: var(--danger); }
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  margin: 0 !important;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  font-weight: 600;
  font-size: .88rem;
  cursor: pointer;
  min-height: 44px;
  touch-action: manipulation;
  user-select: none;
}
.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.chip:has(input:checked) {
  background: #dbeafe;
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.chip:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.muscle-pick {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 640px) {
  .muscle-pick { grid-template-columns: 1fr 1fr 1fr; }
}
.muscle-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 !important;
  padding: 14px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  cursor: pointer;
  min-height: 72px;
  touch-action: manipulation;
  font-weight: 500;
}
.muscle-btn input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.muscle-btn-title {
  font-weight: 700;
  font-size: .95rem;
  color: var(--ink);
}
.muscle-btn-sub {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.3;
}
.muscle-btn:has(input:checked) {
  background: #ecfdf5;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 1px var(--brand-2);
}
.muscle-btn:has(input:checked) .muscle-btn-title { color: var(--brand-2); }
.muscle-btn:has(input:focus-visible) {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

.more-block {
  margin: 16px 0 8px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fafafa;
  padding: 0 12px 4px;
}
.more-block summary {
  cursor: pointer;
  font-weight: 700;
  padding: 14px 4px;
  list-style: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  touch-action: manipulation;
}
.more-block summary::-webkit-details-marker { display: none; }
.more-block summary::before {
  content: "▸";
  color: var(--muted);
  display: inline-block;
  transition: transform .15s ease;
}
.more-block[open] summary::before { transform: rotate(90deg); }
.muted-inline {
  font-weight: 500;
  color: var(--muted);
  font-size: .85rem;
}
.more-body { padding-bottom: 8px; }

.draft-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #78350f;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: .9rem;
}
.draft-meta { color: #92400e; font-weight: 500; }
.draft-status {
  margin: 8px 0 0;
  font-size: .8rem;
  color: var(--muted);
  min-height: 1.2em;
}
button.sm {
  padding: 8px 12px;
  min-height: 36px;
  font-size: .85rem;
}

.success-card {
  background: linear-gradient(160deg, #ecfdf5 0%, #fff 55%);
  border: 1px solid #a7f3d0;
  border-radius: 14px;
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(15, 118, 110, .08);
}
.success-card h3 {
  margin: 0 0 6px;
  color: var(--brand-2);
  font-size: 1.15rem;
}
.success-progress {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 1rem;
}
.success-refine {
  margin: 0 0 12px;
  color: #334155;
  font-size: .95rem;
}

.sticky-actions {
  position: sticky;
  bottom: calc(8px + var(--safe-bottom));
  background: linear-gradient(to top, var(--card) 70%, transparent);
  padding-top: 12px;
  margin-top: 8px;
  z-index: 5;
}
