:root {
  --black: #0b0b0b;
  --panel: #161616;
  --panel2: #1f1f1f;
  --line: #2c2c2c;
  --white: #ffffff;
  --muted: #a3a3a3;
  --red: #d71920;
  --red-dark: #a91217;
  --green: #2fb36d;
  --amber: #e0a526;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--black); color: var(--white); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--white); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.red { color: var(--red); }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  background: var(--black); border-bottom: 3px solid var(--red);
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; font-weight: 800; letter-spacing: .06em; }
.brand b { color: var(--red); }
#nav { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
#nav a, #nav button {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: .9rem;
  padding: .35rem .55rem; border-radius: 8px; text-decoration: none; cursor: pointer;
}
#nav a.active { color: var(--white); background: var(--panel2); }

main { max-width: 760px; margin: 0 auto; padding: 1rem; }
.loading { padding: 3rem 0; text-align: center; color: var(--muted); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.card.accent { border-left: 4px solid var(--red); }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
@media (max-width: 480px) { .grid4 { grid-template-columns: 1fr 1fr; } }

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
input, select, textarea {
  width: 100%; background: var(--black); color: var(--white);
  border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); border-color: transparent; }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: .75rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--red); color: var(--white); border: 0; border-radius: 10px;
  padding: .7rem 1.1rem; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--red-dark); }
.btn.secondary { background: var(--panel2); border: 1px solid var(--line); }
.btn.ghost { background: none; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.btn.small { padding: .4rem .7rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

.auth { max-width: 380px; margin: 2rem auto; text-align: center; }
.auth .logo { width: 88px; height: 88px; margin-bottom: 1rem; }
.auth form { text-align: left; }

.pill {
  display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .5rem;
  border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
}
.pill.red { background: rgba(215,25,32,.15); border-color: var(--red); color: #ff6b70; }
.pill.amber { background: rgba(224,165,38,.12); border-color: var(--amber); color: var(--amber); }
.pill.green { background: rgba(47,179,109,.12); border-color: var(--green); color: var(--green); }
.flags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .4rem; }

.exercise { border-top: 1px solid var(--line); padding-top: .9rem; margin-top: .9rem; }
.exercise:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.target { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }
.setrow { display: grid; grid-template-columns: 2rem 1fr 1fr 1fr 2rem; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.setrow .n { color: var(--muted); font-weight: 700; text-align: center; }
.setrow.head { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.iconbtn { background: none; border: 0; color: var(--muted); font-size: 1.2rem; cursor: pointer; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .6rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--white); border-color: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.scroll { overflow-x: auto; }

.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: .25rem; }
.scale input { display: none; }
.scale span {
  display: block; text-align: center; padding: .45rem 0; border-radius: 6px;
  background: var(--black); border: 1px solid var(--line); cursor: pointer; font-size: .9rem;
}
.scale input:checked + span { background: var(--red); border-color: var(--red); font-weight: 700; }

.macro { background: var(--black); border: 1px solid var(--line); border-radius: 10px; padding: .6rem; text-align: center; }
.macro .v { font-size: 1.25rem; font-weight: 800; }
.macro .t { font-size: .75rem; color: var(--muted); }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin-top: .35rem; }
.bar > i { display: block; height: 100%; background: var(--green); }
.bar > i.over { background: var(--red); }
.bar > i.under { background: var(--amber); }

.comment { background: var(--black); border-left: 3px solid var(--red); padding: .6rem .8rem; border-radius: 6px; margin-top: .6rem; }
.comment b { color: var(--red); }

#toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(150%);
  background: var(--white); color: var(--black); padding: .7rem 1.1rem; border-radius: 10px; font-weight: 600;
  transition: transform .25s; max-width: 90vw; z-index: 50;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); color: var(--white); }

.daypick { display: flex; gap: .4rem; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem 0; }
details summary { cursor: pointer; }
@media (max-width: 480px) {
  .brand span { display: none; }
  #nav { flex-wrap: nowrap; gap: 0; }
  #nav a, #nav button { padding: .35rem .4rem; font-size: .8rem; white-space: nowrap; }
}
