:root {
  --bg: #0e1116;
  --surface: #171c24;
  --surface-2: #1f2630;
  --line: #2a323e;
  --text: #eef2f7;
  --muted: #93a1b5;
  --accent: #4f8cff;
  --good: #35c48a;
  --good-dim: #143a2c;
  --warn: #f0a53a;
  --bad: #ff6b6b;
  --radius: 14px;
  --tap: 48px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overscroll-behavior-y: none;
}
.app { max-width: 560px; margin: 0 auto; padding: 16px 16px 96px; min-height: 100vh; }
.loading { text-align: center; color: var(--muted); padding: 40px; }

h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; }
h1 { font-size: 26px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
button { font-family: inherit; }

/* Cards & banners */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.banner.onramp { background: #10233f; border: 1px solid #274d80; color: #cfe0ff; }
.banner.deload { background: #3a2a12; border: 1px solid #7a5a22; color: #ffe0b0; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap); padding: 12px 16px;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius);
  font-size: 17px; font-weight: 600; cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.good { background: var(--good); }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; }

/* Login */
.login-wrap { min-height: 70vh; display: flex; flex-direction: column; justify-content: center; }
.brand { font-size: 40px; font-weight: 800; letter-spacing: -1px; text-align: center; margin-bottom: 4px; }
.brand .lift { color: var(--accent); }
input[type=password], input[type=number], input[type=text], textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px; font-size: 17px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
label.field { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }

/* Slot picker */
.slot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.slot-btn {
  position: relative; min-height: 96px; padding: 16px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font-size: 17px; font-weight: 600; cursor: pointer;
}
.slot-btn .sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 6px; }
.slot-btn.next { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.chip-next {
  position: absolute; top: 10px; right: 10px; font-size: 10px; font-weight: 700;
  background: var(--accent); color: #fff; padding: 3px 7px; border-radius: 999px; letter-spacing: .5px;
}

/* Logging */
.log-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.progress-dots { display: flex; gap: 6px; margin: 8px 0 16px; }
.dot { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.dot.done { background: var(--good); }
.dot.cur { background: var(--accent); }
.target-line { font-size: 15px; color: var(--muted); margin-bottom: 2px; }
.target-line b { color: var(--text); }
.ghost { color: var(--muted); font-size: 13px; margin-top: 6px; }
.why { color: var(--muted); font-size: 13px; margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }

.setrow { display: grid; grid-template-columns: 34px 1fr 1fr 46px; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.setrow:first-of-type { border-top: none; }
.set-idx { color: var(--muted); font-size: 13px; text-align: center; }
.set-idx.warm { color: var(--warn); }
.stepper { display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: var(--tap); min-height: var(--tap); background: transparent; border: none; color: var(--text); font-size: 24px; cursor: pointer; }
.stepper .val { flex: 1; text-align: center; font-size: 19px; font-weight: 700; min-width: 0; }
.stepper .unit { font-size: 11px; color: var(--muted); font-weight: 400; }
.set-done { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 22px; cursor: pointer; }
.set-done.on { background: var(--good-dim); border-color: var(--good); color: var(--good); }
.set-meta { display: flex; justify-content: space-between; margin-top: 10px; }
.link { background: none; border: none; color: var(--accent); font-size: 14px; cursor: pointer; padding: 8px 4px; }
.link.warm-toggle { color: var(--warn); }

/* sticky footer nav */
.footer-nav { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent); }
.footer-inner { max-width: 560px; margin: 0 auto; display: flex; gap: 10px; }

/* Summary */
.result { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.result:first-child { border-top: none; }
.result .badge { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; font-weight: 800; }
.badge.up { background: var(--good-dim); color: var(--good); }
.badge.hold { background: var(--surface-2); color: var(--muted); }
.badge.pause { background: #10233f; color: #7fb0ff; }
.result .r-main { font-weight: 600; }
.result .r-sub { color: var(--muted); font-size: 13px; }
.big-next { font-size: 15px; }

/* rest timer chip */
.rest-chip { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--accent); color: var(--text);
  padding: 8px 16px; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums; z-index: 5; }
.rest-chip button { background: none; border: none; color: var(--muted); margin-left: 10px; font-size: 14px; cursor: pointer; }

/* toast */
.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: #000; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: 90%; z-index: 20; border: 1px solid var(--line); }
.toast.err { border-color: var(--bad); }

.spacer { height: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
