/* ---------------------------------------------------------- tokens */
:root {
  --bg: #0b0f14;
  --bg-soft: #111823;
  --card: #151d29;
  --card-2: #1b2534;
  --line: #24303f;
  --txt: #e8eef6;
  --muted: #8b9bb0;
  --accent: #b8ff3c;
  --accent-dim: #7ba829;
  --blue: #4da3ff;
  --amber: #ffb84d;
  --red: #ff6b6b;
  --radius: 16px;
  --tap: 44px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 1.2em; font-size: .9rem; margin: .6rem 0 0; }

/* ---------------------------------------------------------- login */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(90% 60% at 50% 0%, #16202d 0%, var(--bg) 70%);
}
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-mark {
  width: 76px; height: 76px; margin: 0 auto 20px;
  display: grid; place-items: center;
  border-radius: 22px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  color: #0b0f14; font-weight: 800; font-size: 1.5rem; letter-spacing: -.02em;
}
.login-card h1 { margin: 0 0 4px; font-size: 1.6rem; letter-spacing: -.02em; }
.login-card p { margin: 0 0 24px; font-size: .95rem; }
#pw {
  width: 100%; height: 56px; text-align: center;
  font-size: 1.6rem; letter-spacing: .5em; text-indent: .5em;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; color: var(--txt); outline: none;
}
#pw:focus { border-color: var(--accent); }

.btn-primary {
  width: 100%; height: 52px; margin-top: 14px;
  background: var(--accent); color: #0b0f14;
  border: 0; border-radius: 14px;
  font-size: 1rem; font-weight: 700; cursor: pointer;
}
.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled { opacity: .5; }

/* ---------------------------------------------------------- chrome */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: rgba(11, 15, 20, .86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-sub { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.topbar-title { margin: 2px 0 0; font-size: 1.25rem; letter-spacing: -.02em; }
.icon-btn {
  flex: none; width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; color: var(--txt); cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }

main {
  padding: 16px 16px calc(92px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto;
}

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 2px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(11, 15, 20, .94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  min-height: var(--tap); padding: 6px 2px;
  background: none; border: 0; border-radius: 12px;
  color: var(--muted); font-size: .65rem; font-weight: 600; cursor: pointer;
}
.tabbar button svg { width: 21px; height: 21px; }
.tabbar button.on { color: var(--accent); background: rgba(184, 255, 60, .09); }

/* ---------------------------------------------------------- cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.card h2 {
  margin: 0 0 12px; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.card h2 .pill { margin-left: auto; }

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: .68rem; font-weight: 700; letter-spacing: .04em;
  background: var(--card-2); color: var(--muted); text-transform: uppercase;
}
.pill.accent { background: rgba(184, 255, 60, .14); color: var(--accent); }
.pill.blue   { background: rgba(77, 163, 255, .14); color: var(--blue); }
.pill.amber  { background: rgba(255, 184, 77, .15); color: var(--amber); }

/* hero */
.hero {
  background: linear-gradient(150deg, #1c2a1a 0%, var(--card) 55%);
  border: 1px solid #2c3d22;
}
.hero.rest { background: linear-gradient(150deg, #1a2430 0%, var(--card) 55%); border-color: #26374a; }
.hero-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.hero-day { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.hero-date { font-size: .85rem; color: var(--muted); }
.hero-focus { margin: 10px 0 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.hero-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

.progress-track { height: 6px; background: var(--card-2); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); border-radius: 99px; transition: width .4s ease; }

/* ---------------------------------------------------------- exercises */
.note-banner {
  padding: 10px 12px; margin-bottom: 12px;
  background: rgba(255, 184, 77, .1); border: 1px solid rgba(255, 184, 77, .28);
  border-radius: 12px; font-size: .85rem; color: #ffd79a;
}
.note-line { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }

.ex {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; margin-bottom: 8px;
  background: var(--card-2); border: 1px solid transparent;
  border-radius: 12px; cursor: pointer; min-height: var(--tap);
}
.ex:last-child { margin-bottom: 0; }
.ex.done { border-color: rgba(184, 255, 60, .3); background: rgba(184, 255, 60, .06); }
.ex.done .ex-name { color: var(--muted); text-decoration: line-through; }

.box {
  flex: none; width: 24px; height: 24px; margin-top: 1px;
  border: 2px solid var(--line); border-radius: 7px;
  display: grid; place-items: center; transition: .15s;
}
.box svg { width: 14px; height: 14px; stroke: #0b0f14; stroke-width: 3.5; opacity: 0; }
.done .box, .check.on .box { background: var(--accent); border-color: var(--accent); }
.done .box svg, .check.on .box svg { opacity: 1; }

.ex-code {
  flex: none; min-width: 26px; height: 22px; padding: 0 6px;
  display: grid; place-items: center;
  background: var(--card); border-radius: 6px;
  font-size: .7rem; font-weight: 800; color: var(--accent);
}
.ex-body { flex: 1; min-width: 0; }
.ex-name { font-size: .95rem; font-weight: 600; line-height: 1.3; }
.ex-presc { font-size: .8rem; color: var(--muted); margin-top: 2px; }

.plain { font-size: .93rem; line-height: 1.5; }

/* daily checks */
.checks { display: grid; gap: 8px; }
.check {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; min-height: var(--tap);
  background: var(--card-2); border: 1px solid transparent;
  border-radius: 12px; cursor: pointer; font-size: .95rem; font-weight: 600;
}
.check.on { border-color: rgba(184, 255, 60, .3); background: rgba(184, 255, 60, .06); }

/* ---------------------------------------------------------- calendar */
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 8px;
}
.cal-head h3 { margin: 0; font-size: 1.05rem; letter-spacing: -.01em; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--txt); cursor: pointer;
}
.cal-nav button svg { width: 16px; height: 16px; }
.cal-nav button:disabled { opacity: .3; }

.dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px;
  margin-bottom: 6px;
}
.dow span {
  text-align: center; font-size: .65rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
}

.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }

.cell { aspect-ratio: 1 / 1.18; }
.cell.blank { visibility: hidden; }

/* a calendar day = a tickable checkbox */
.cell button {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 2px;
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: 12px; color: var(--muted); cursor: pointer;
  font-family: inherit; position: relative; transition: .15s;
}
.cell button:active { transform: scale(.94); }

.cell .dnum { font-size: .82rem; font-weight: 700; color: var(--txt); line-height: 1; }
.cell .dtick {
  width: 19px; height: 19px;
  border: 1.5px solid var(--line); border-radius: 6px;
  display: grid; place-items: center;
}
.cell .dtick svg { width: 12px; height: 12px; stroke: #0b0f14; stroke-width: 4; opacity: 0; }

.cell button.off   { opacity: .32; cursor: default; }
.cell button.off .dtick { display: none; }

.cell button.rest .dtick { border-style: dashed; }
.cell button.rest .dnum { color: var(--blue); }

.cell button.done { background: rgba(184, 255, 60, .1); border-color: var(--accent); }
.cell button.done .dtick { background: var(--accent); border-color: var(--accent); }
.cell button.done .dtick svg { opacity: 1; }

.cell button.partial { border-color: var(--amber); }
.cell button.partial .dtick { border-color: var(--amber); background: rgba(255, 184, 77, .25); }

.cell button.today { box-shadow: 0 0 0 2px var(--accent) inset; }
.cell button.today .dnum { color: var(--accent); }

.cell button.missed { border-color: rgba(255, 107, 107, .35); }
.cell button.missed .dnum { color: var(--red); }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; font-size: .72rem; color: var(--muted); }
.legend i { width: 11px; height: 11px; border-radius: 4px; display: inline-block; margin-right: 5px; vertical-align: -1px; border: 1.5px solid var(--line); }
.legend i.d { background: var(--accent); border-color: var(--accent); }
.legend i.p { background: rgba(255, 184, 77, .3); border-color: var(--amber); }
.legend i.t { box-shadow: 0 0 0 2px var(--accent) inset; }
.legend i.r { border-style: dashed; border-color: var(--blue); }

/* ---------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px;
}
.stat .k { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.stat .v { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.stat .v small { font-size: .8rem; font-weight: 600; color: var(--muted); }
.stat .v.up { color: var(--red); }
.stat .v.down { color: var(--accent); }

/* ---------------------------------------------------------- forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--txt);
  font-size: 1rem; font-family: inherit; outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 88px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-ghost {
  width: 100%; min-height: var(--tap); padding: 12px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--txt);
  font-size: .95rem; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn-ghost.danger { color: var(--red); border-color: rgba(255, 107, 107, .3); }

/* weigh-in */
.weigh { display: flex; gap: 10px; align-items: stretch; }
.weigh input {
  flex: 1; min-width: 0; text-align: center;
  padding: 12px 14px;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; color: var(--txt);
  font-size: 1.3rem; font-weight: 700; font-family: inherit;
  outline: none; -moz-appearance: textfield;
}
.weigh input:focus { border-color: var(--accent); }
.weigh input::-webkit-outer-spin-button,
.weigh input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.weigh button { flex: none; width: 88px; }

.chart { width: 100%; height: 190px; display: block; margin-top: 4px; }

.wlist { margin-top: 4px; }
.wrow {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: .9rem;
}
.wrow:last-child { border-bottom: 0; }
.wrow .wd { flex: 1; color: var(--muted); }
.wrow .wk { font-weight: 700; font-variant-numeric: tabular-nums; }
.wrow .wdelta { font-size: .78rem; width: 58px; text-align: right; font-variant-numeric: tabular-nums; }
.wdelta.up { color: var(--red); }
.wdelta.down { color: var(--accent); }
.wrow .wdel {
  flex: none; width: 30px; height: 30px; display: grid; place-items: center;
  background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem;
}

/* guide */
.guide-sec h3 {
  margin: 0 0 10px; font-size: .82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--accent);
}
.guide-sec ul { margin: 0; padding-left: 18px; }
.guide-sec li { font-size: .9rem; line-height: 1.55; margin-bottom: 8px; color: #cdd8e6; }

/* ---------------------------------------------------------- misc */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px); z-index: 60;
  padding: 11px 18px; border-radius: 999px;
  background: var(--accent); color: #0b0f14;
  font-size: .87rem; font-weight: 700;
  opacity: 0; pointer-events: none; transition: .22s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 32px 16px; font-size: .92rem; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; color: var(--accent);
  font-size: .88rem; font-weight: 600; font-family: inherit;
  padding: 6px 0; margin-bottom: 8px; cursor: pointer;
}

@media (min-width: 560px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .cell { aspect-ratio: 1 / 1; }
}

.cell button.future { opacity: .5; }
.cell button.future .dnum { color: var(--muted); }
