/* Dark, high-contrast, thumb-first. Used outdoors with sweaty hands:
   big targets (min 48px), min 16px text, no hover-dependent UI. */

:root {
  --bg: #0c0e12; --surface: #171b24; --surface2: #1f2530;
  --text: #f2f4f8; --muted: #98a2b3; --line: #2a3140;
  --accent: #ff6b35; --good: #3ddc84; --warn: #ffd166; --bad: #ff5c5c;
  --sick: #7aa2ff;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ---------- login ---------- */
#login { display: flex; align-items: center; justify-content: center; min-height: 90vh; }
.login-box { width: min(320px, 86vw); display: flex; flex-direction: column; gap: 14px; }
.login-box h1 { text-align: center; font-size: 1.8rem; margin-bottom: 8px; }

/* ---------- layout ---------- */
main { padding: 16px 14px calc(84px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
h2 { font-size: 1.35rem; margin: 4px 0 12px; }
h3 { font-size: 1.05rem; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.sub { color: var(--muted); font-size: 1rem; }

/* ---------- nav ---------- */
#nav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 20;
}
.nav-btn {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: .85rem; padding: 10px 0 12px; min-height: 56px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.nav-btn .ic { font-size: 1.15rem; line-height: 1; }
.nav-btn.active { color: var(--accent); font-weight: 700; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; margin-bottom: 12px;
}
.card.session { border-left: 5px solid var(--accent); }
.card.session.done { border-left-color: var(--good); }
.card.session.missed { border-left-color: var(--bad); opacity: .85; }
.card.session.sick { border-left-color: var(--sick); opacity: .85; }
.session-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.session-title { font-size: 1.15rem; font-weight: 700; }
.session-mins { font-size: 1.5rem; font-weight: 800; color: var(--accent); white-space: nowrap; }
.steps { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px;
         display: flex; flex-direction: column; gap: 6px; }
.step { display: flex; gap: 10px; font-size: 1rem; }
.step .k { color: var(--muted); min-width: 86px; }
.badge { display: inline-block; border-radius: 20px; padding: 3px 10px; font-size: .8rem;
         font-weight: 700; background: var(--surface2); color: var(--muted); }
.badge.done { color: var(--good); } .badge.missed { color: var(--bad); }
.badge.sick { color: var(--sick); } .badge.cutback { color: var(--warn); }

/* ---------- buttons ---------- */
.btn {
  background: var(--surface2); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 16px; font-size: 1rem; font-weight: 600;
  min-height: 48px; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #14100c; }
.btn.big { width: 100%; font-size: 1.1rem; }
.btn.small { min-height: 40px; padding: 8px 12px; font-size: .9rem; }
.btn.danger { color: var(--bad); }
.btnrow { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.btnrow .btn { flex: 1; }

/* ---------- RPE picker ---------- */
.rpe-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
.rpe-btn {
  min-height: 52px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface2); color: var(--text); font-size: 1.2rem; font-weight: 800;
  cursor: pointer;
}
.rpe-btn.sel { background: var(--accent); border-color: var(--accent); color: #14100c; }
.rpe-scale { display: flex; justify-content: space-between; color: var(--muted);
             font-size: .8rem; margin-top: 6px; }

/* ---------- forms ---------- */
input, select, textarea {
  background: var(--surface2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px; font-size: 1rem; width: 100%; min-height: 48px;
}
textarea { min-height: 70px; }
label { display: block; color: var(--muted); font-size: .9rem; margin: 12px 0 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.day-toggles { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-t { min-height: 46px; border-radius: 10px; border: 1px solid var(--line);
         background: var(--surface2); color: var(--muted); font-weight: 700; cursor: pointer; }
.day-t.on { background: var(--accent); color: #14100c; border-color: var(--accent); }

/* ---------- banner / toast / modal ---------- */
.banner { padding: 12px 14px; font-weight: 600; text-align: center; }
.banner.sick { background: #223055; color: var(--sick); }
.banner.warn { background: #3a2f14; color: var(--warn); }
#toast {
  position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 12px; z-index: 40; font-weight: 600; max-width: 86vw;
}
#modal-wrap {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
}
#modal {
  background: var(--surface); border-radius: 18px 18px 0 0; width: 100%; max-width: 640px;
  max-height: 86vh; overflow-y: auto; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal-grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }

/* ---------- charts ---------- */
.chart { width: 100%; overflow-x: auto; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: .85rem; margin-top: 6px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- stats ---------- */
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
        padding: 12px 6px; text-align: center; }
.stat-v { font-size: 1.5rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat-l { font-size: .75rem; color: var(--muted); margin-top: 4px; }
@media (max-width: 380px) { .statgrid { grid-template-columns: repeat(2, 1fr); } }

.mstone { margin-bottom: 14px; }
.mstone:last-child { margin-bottom: 0; }
.bar { height: 10px; background: var(--surface2); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 6px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.badge.earned { background: #16281c; color: var(--good); font-size: .82rem; padding: 6px 11px; }

.guide-body h3 { font-size: .95rem; margin: 12px 0 4px; color: var(--accent); }
.guide-body { border-left: 3px solid var(--line); padding-left: 12px; margin-top: 10px; }

/* ---------- misc ---------- */
.event { border-left: 3px solid var(--accent); padding: 8px 12px; margin-bottom: 10px; }
.event .meta { color: var(--muted); font-size: .82rem; }
.event.ai { border-left-color: var(--sick); }
.event.manual { border-left-color: var(--warn); }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 1rem; }
.kv:last-child { border-bottom: none; }
.err { color: var(--bad); text-align: center; }
.center { text-align: center; }
.mt { margin-top: 14px; }
pre.copytext { white-space: pre-wrap; background: var(--surface2); border-radius: 10px;
               padding: 12px; font-size: .92rem; margin-top: 10px; }
