:root {
  --bg: #0b1120;
  --bg-2: #0f172a;
  --card: #131c31;
  --card-2: #1b2742;
  --line: #243152;
  --text: #e7ecf6;
  --muted: #93a1bd;
  --brand: #3b82f6;
  --brand-2: #2563eb;
  --accent: #22d3ee;
  --good: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #16233f 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

#app { max-width: 720px; margin: 0 auto; padding: calc(16px + var(--safe-top)) 16px calc(96px + var(--safe-bottom)); }
.boot { text-align: center; color: var(--muted); padding: 80px 0; }

a { color: var(--accent); }
button { font-family: inherit; }

/* ---- Header ---- */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar .logo { width: 40px; height: 40px; border-radius: 11px; }
.topbar h1 { font-size: 18px; margin: 0; line-height: 1.1; }
.topbar .sub { font-size: 12px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); object-fit: cover; background: var(--card-2); }
.role-chip { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; background: var(--card-2); color: var(--accent); border: 1px solid var(--line); }
.role-chip.admin { color: var(--warn); }

/* ---- Cards & layout ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.pill { display: inline-block; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }

/* ---- Day cards ---- */
.day-card { display: block; text-decoration: none; color: inherit; position: relative; overflow: hidden; }
.day-card .badge { position: absolute; top: 14px; right: 14px; font-size: 11px; }
.day-card .dow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.day-card h2 { font-size: 18px; margin: 2px 0 2px; }
.day-card .goal { color: var(--muted); font-size: 13px; }
.day-card.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset, 0 8px 30px rgba(37,99,235,.18); }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); padding: 11px 16px; border-radius: 12px; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: linear-gradient(180deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Exercise ---- */
.group-title { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 18px 0 8px; }
.ex { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.ex-head { display: flex; align-items: flex-start; gap: 10px; }
.ex-head .name { font-weight: 600; font-size: 15px; }
.ex-head .scheme { color: var(--accent); font-size: 13px; margin-top: 2px; }
.ex-head .spacer { flex: 1; }
.ex .note { color: var(--muted); font-size: 12px; margin-top: 4px; }
.ex .last { color: var(--warn); font-size: 12px; margin-top: 6px; }
.video-link { font-size: 12px; white-space: nowrap; }
.superset-tag { font-size: 10px; background: var(--brand-2); color: #fff; border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }

/* ---- Set logging rows ---- */
.set-rows { margin-top: 10px; display: grid; gap: 6px; }
.set-row { display: grid; grid-template-columns: 28px 1fr 1fr 34px; gap: 8px; align-items: center; }
.set-row .idx { color: var(--muted); font-size: 13px; text-align: center; }
.set-row input { width: 100%; background: var(--bg-2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 10px; font-size: 15px; text-align: center; }
.set-row input:focus { outline: none; border-color: var(--brand); }
.set-row .check { width: 22px; height: 22px; accent-color: var(--good); }
.field-label { display: grid; grid-template-columns: 28px 1fr 1fr 34px; gap: 8px; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.field-label span { text-align: center; }

/* simple checkoff */
.simple-check { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.simple-check input { width: 22px; height: 22px; accent-color: var(--good); }

/* ---- Mode toggle ---- */
.toggle { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.toggle button { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 999px; font-size: 13px; cursor: pointer; }
.toggle button.active { background: var(--brand); color: #fff; }

/* ---- Bottom nav ---- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(11,17,32,.92); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 8px 8px calc(8px + var(--safe-bottom)); display: flex; justify-content: space-around; z-index: 50; }
.tabbar a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 11px; padding: 4px 0; }
.tabbar a .ic { display: block; font-size: 20px; line-height: 1.2; }
.tabbar a.active { color: var(--accent); }

/* ---- Login ---- */
.login-wrap { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.login-wrap .logo-lg { width: 84px; height: 84px; border-radius: 22px; }
.login-wrap h1 { margin: 0; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; max-width: 360px; width: 100%; }
#gbtn { display: flex; justify-content: center; margin-top: 6px; min-height: 44px; }
.err { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ---- Guide ---- */
.guide h3 { margin: 18px 0 6px; font-size: 15px; }
.guide ul { margin: 6px 0; padding-left: 20px; }
.guide li { margin: 4px 0; color: var(--text); }
.callout { border-left: 3px solid var(--brand); background: var(--card-2); padding: 10px 14px; border-radius: 0 12px 12px 0; margin: 10px 0; }
.callout.warn { border-left-color: var(--warn); }
.callout.good { border-left-color: var(--good); }

/* ---- Admin / history tables ---- */
.log-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; background: var(--card); }
.log-item .when { font-size: 12px; color: var(--muted); }
.log-item .ex-line { font-size: 13px; padding: 3px 0; border-top: 1px dashed var(--line); }
.log-item .ex-line:first-of-type { border-top: 0; }
.editrow { display: grid; grid-template-columns: 1fr 60px 70px; gap: 6px; margin-bottom: 6px; }
.editrow input { background: var(--bg-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 7px; font-size: 13px; }
.toast { position: fixed; bottom: calc(80px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); background: var(--good); color: #062018; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 100; }

.sticky-save { position: sticky; bottom: calc(78px + var(--safe-bottom)); z-index: 40; padding-top: 8px; }

.center { text-align: center; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
