:root {
  --bg: #0e0f12;
  --card: #17191e;
  --line: #262a31;
  --text: #eef0f3;
  --muted: #8b919c;
  --accent: #c6ff3d;
  --accent-ink: #11140a;
  --bulk: #ff8a3d;
  --cut: #3dc8ff;
  --transition: #b18cff;
  --warn: #ffcc4d;
  --bad: #ff5d5d;
  --ok: #4dff9a;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
main { max-width: 560px; margin: 0 auto; padding: 12px; display: grid; gap: 12px; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 28px; } h2 { font-size: 17px; } h3 { font-size: 16px; margin: 0; }
p { margin: 4px 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.error { color: var(--bad); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 8px; }
.card.complete { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.phase { border-left: 4px solid var(--accent); }
.phase.bulk { border-left-color: var(--bulk); }
.phase.cut { border-left-color: var(--cut); }
.phase.transition { border-left-color: var(--transition); }
.phase-label { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.phase-sub { color: var(--muted); }

.btn, button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 0 18px; border-radius: 12px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 16px;
  text-decoration: none; cursor: pointer;
}
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:active { transform: scale(0.98); }
button.icon { background: none; border: 0; color: var(--text); font-size: 26px; width: 44px; height: 44px; cursor: pointer; }
button.icon.del { color: var(--muted); font-size: 22px; width: 36px; height: 36px; }
.chip { background: var(--line); color: var(--text); border: 0; border-radius: 999px; padding: 8px 12px; font-size: 14px; cursor: pointer; min-height: 36px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

input, select {
  width: 100%; min-height: 46px; padding: 0 12px; font-size: 17px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
}
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--accent); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label[for] { display: flex; align-items: center; gap: 8px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 0; }
legend { padding: 0 6px; font-weight: 700; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row.three { grid-template-columns: repeat(3, 1fr); }
.row.four { grid-template-columns: repeat(4, 1fr); }
.food-form .row:first-child { grid-template-columns: 1fr 2fr; }
.food-form, .body-form, .settings, .login { display: grid; gap: 10px; }

.datenav { display: flex; align-items: center; gap: 4px; }
.datenav input { flex: 1; text-align: center; }

.bar { display: grid; gap: 4px; }
.bar-head { display: flex; justify-content: space-between; font-size: 14px; }
.bar-track { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar-track.thin { height: 5px; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar-fill.over { background: var(--warn); }

.hint { border-radius: 10px; padding: 10px 12px; font-size: 14px; background: var(--line); }
.hint.ok { background: color-mix(in srgb, var(--ok) 14%, var(--card)); }
.hint.warn { background: color-mix(in srgb, var(--warn) 18%, var(--card)); }

.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.set-input { display: grid; grid-template-columns: 1fr 1fr 74px auto; gap: 6px; }
.set-input .btn { padding: 0 12px; }
ol.sets, ul.items, ul.checklist { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
ol.sets { counter-reset: s; }
ol.sets li, ul.items li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--line); }
ol.sets li::before { counter-increment: s; content: counter(s); color: var(--muted); width: 18px; font-size: 13px; }
ol.sets li span { flex: 1; }
ul.checklist li { padding: 6px 0 6px 26px; position: relative; }
ul.checklist li::before { content: "□"; position: absolute; left: 2px; color: var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; }

.chart { width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .dot { fill: var(--muted); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .marker { stroke: var(--cut); stroke-dasharray: 3 3; }
.legend { text-align: right; }

details summary { cursor: pointer; padding: 6px 0; }

nav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
nav a { display: grid; justify-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 11px; min-width: 60px; padding: 4px; }
nav a span { font-size: 18px; }
nav a.active { color: var(--accent); }
body.logged-out nav { display: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .2s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--bad); color: #fff; }

@media (min-width: 600px) { main { padding: 20px; } }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px 4px; }
.stat-val { font-size: 18px; font-weight: 700; }

.secret { display: block; padding: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; word-break: break-all; user-select: all; }
.sec-flow { display: grid; gap: 8px; }
.sec-flow:empty { display: none; }
.ok-text { color: var(--ok); font-weight: 700; }
.warn-text { color: var(--warn); font-weight: 700; }
button:disabled { opacity: .5; }
