/* ============ base / iOS standalone ============ */
:root {
  --bg: #0f1218;
  --bg2: #161b24;
  --card: #1b2230;
  --card2: #222b3c;
  --border: #2b3548;
  --text: #e8edf4;
  --text-dim: #8b96a8;
  --accent: #34d399;
  --accent-dim: #34d39922;
  --danger: #f87171;
  --warn: #fbbf24;

  --m-fresh: #34d399;
  --m-ok: #a3e635;
  --m-stale: #fbbf24;
  --m-old: #fb923c;
  --m-never: #f87171;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior-y: none;
}

body { -webkit-text-size-adjust: 100%; -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: auto; user-select: auto; }

#view {
  padding: calc(var(--sat) + 16px) 16px calc(var(--sab) + 110px);
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
}

h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.4px; }
h2 { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.subtitle { color: var(--text-dim); font-size: 14px; margin-top: 2px; }
.section { margin-top: 24px; }

/* ============ tab bar ============ */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around; align-items: stretch;
  background: rgba(18, 22, 30, 0.92);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 0.5px solid var(--border);
  padding: 6px 8px calc(var(--sab) + 6px);
  z-index: 50;
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-dim);
  font-size: 10px; font-weight: 600; padding: 6px 0 2px; cursor: pointer;
  transition: color .15s;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }
.tab-go svg { stroke-width: 2.2; }

/* ============ buttons / inputs ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 14px; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 700;
  padding: 14px 18px; color: var(--text); background: var(--card2);
  transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary { background: var(--accent); color: #07120d; }
.btn-danger { background: #3a1f24; color: var(--danger); }
.btn-block { display: flex; width: 100%; }
.btn-small { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); }

input[type="text"], input[type="number"], input[type="search"] {
  width: 100%; background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 16px; padding: 12px 14px;
  font-family: inherit; outline: none;
}
input:focus { border-color: var(--accent); }

input[type="date"] {
  background: var(--bg2); border: 1.5px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 10px; outline: none; -webkit-appearance: none; appearance: none;
  color-scheme: dark;
}

/* ============ cards ============ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 16px; margin-bottom: 12px;
}
.card-tight { padding: 12px 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; }
.muted { color: var(--text-dim); font-size: 13px; }
.hidden { display: none !important; }

/* ============ body map ============ */
.bodymap-wrap { display: flex; gap: 8px; justify-content: center; }
.bodymap { width: 50%; max-width: 200px; height: auto; }
.bodymap .silhouette * { fill: #232c3d; }
.bodymap .muscles * { fill: #3a4660; cursor: pointer; transition: opacity .15s; }
.bodymap .muscles *:active { opacity: 0.6; }
.bodymap .m-fresh { fill: var(--m-fresh); }
.bodymap .m-ok    { fill: var(--m-ok); }
.bodymap .m-stale { fill: var(--m-stale); }
.bodymap .m-old   { fill: var(--m-old); }
.bodymap .m-never { fill: var(--m-never); }
.figure-label { fill: var(--text-dim); font-size: 11px; font-weight: 700; text-anchor: middle; letter-spacing: 2px; }

.bodymap-mini { margin-top: 4px; }
.bodymap-mini .bodymap { max-width: 132px; }
.bodymap-mini .figure-label { font-size: 14px; }

.fade-legend {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin-top: 12px; font-size: 11px; font-weight: 700; color: var(--text-dim);
}
.fade-bar {
  width: 150px; height: 9px; border-radius: 99px;
  background: linear-gradient(90deg, rgba(52,211,153,0.10), rgba(52,211,153,1));
}

.ex-info-icon { color: var(--text-dim); font-size: 15px; flex-shrink: 0; }

.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: center; margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-dim); font-weight: 600; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ============ muscle status list / suggestions ============ */
.muscle-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.muscle-row:last-child { border-bottom: none; }
.muscle-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.muscle-name { font-weight: 600; font-size: 15px; flex: 1; }
.muscle-days { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.suggestion-card { border-color: var(--accent); border-width: 1.5px; background: linear-gradient(160deg, var(--card), var(--accent-dim)); }
.badge {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--accent); background: var(--accent-dim);
  padding: 4px 10px; border-radius: 999px; margin-bottom: 8px;
}
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 999px;
  background: var(--bg2); border: 1.5px solid var(--border); color: var(--text);
  cursor: pointer; transition: all .15s;
}
.chip.on { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.chip-static { cursor: default; }

/* ============ exercise list (plan/session) ============ */
.ex-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg2); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
}
.ex-info { flex: 1; min-width: 0; }
.ex-name { font-weight: 700; font-size: 15px; }
.ex-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.ex-remove { background: none; border: none; color: var(--text-dim); font-size: 22px; cursor: pointer; padding: 4px 8px; line-height: 1; }

/* ============ session sets ============ */
.set-row { display: grid; grid-template-columns: 36px 1fr 1fr 44px; gap: 8px; align-items: center; margin-bottom: 6px; }
.set-num { color: var(--text-dim); font-size: 13px; font-weight: 700; text-align: center; }
.set-row input { padding: 10px 8px; text-align: center; font-variant-numeric: tabular-nums; border-radius: 10px; }
.set-row input.done-input { border-color: var(--accent); }
.set-check {
  width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--bg2); color: var(--text-dim); font-size: 18px; cursor: pointer;
}
.set-check.done { background: var(--accent); border-color: var(--accent); color: #07120d; }
.set-head { display: grid; grid-template-columns: 36px 1fr 1fr 44px; gap: 8px; font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.set-head span { text-align: center; }

.session-timer { font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 700; color: var(--accent); }

/* ============ session floating bar ============ */
.session-bar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--sab) + 78px);
  background: var(--card2); border: 1.5px solid var(--accent);
  border-radius: 16px; padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  z-index: 49; box-shadow: 0 8px 24px rgba(0,0,0,.45);
  max-width: 536px; margin: 0 auto;
}
.session-bar-info { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ============ calendar ============ */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-title { font-weight: 800; font-size: 16px; }
.cal-nav { background: var(--bg2); border: 1px solid var(--border); color: var(--text); width: 36px; height: 36px; border-radius: 10px; font-size: 16px; cursor: pointer; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--text-dim); padding: 4px 0; }
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; background: transparent;
  border: none; color: var(--text); font-family: inherit; gap: 2px;
}
.cal-day.other { color: #3d4a61; }
.cal-day.today { background: var(--accent-dim); color: var(--accent); }
.cal-day.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-day .dots { display: flex; gap: 2px; height: 5px; }
.cal-day .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: block; }

/* ============ modal sheet ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .18s;
}
@keyframes fadein { from { opacity: 0; } }
.modal-sheet {
  background: var(--bg2); width: 100%; max-width: 560px;
  border-radius: 22px 22px 0 0; padding: 18px 18px calc(var(--sab) + 18px);
  max-height: 82vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: slideup .22s ease-out;
}
@keyframes slideup { from { transform: translateY(40%); } }
.modal-grab { width: 38px; height: 4.5px; background: var(--border); border-radius: 99px; margin: 0 auto 14px; }

/* ============ misc ============ */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.stat { background: var(--bg2); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 20px; font-weight: 800; color: var(--accent); }
.stat span { font-size: 11px; color: var(--text-dim); font-weight: 600; }

.empty { text-align: center; color: var(--text-dim); padding: 28px 12px; font-size: 14px; }
.seg { display: flex; background: var(--bg2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: none; background: transparent; color: var(--text-dim);
  font-family: inherit; font-size: 13px; font-weight: 700; padding: 9px 4px; border-radius: 9px; cursor: pointer;
}
.seg button.on { background: var(--card2); color: var(--text); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sab) + 140px);
  background: var(--card2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 20px; border-radius: 999px; font-size: 14px; font-weight: 600;
  z-index: 200; animation: fadein .2s; box-shadow: 0 6px 20px rgba(0,0,0,.4);
  white-space: nowrap;
}
