:root {
  --bg: #0b0d10;
  --bg-2: #111419;
  --surface: #161a21;
  --surface-2: #1d222b;
  --border: #262c37;
  --text: #eef1f5;
  --muted: #8b94a3;
  --accent: #c8f135;
  --accent-ink: #11140a;
  --accent-soft: rgba(200, 241, 53, .12);
  --blue: #5b9dff;
  --blue-soft: rgba(91, 157, 255, .14);
  --danger: #ff5d5d;
  --danger-soft: rgba(255, 93, 93, .12);
  --warn: #ffb547;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --sidebar: 260px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; }
img, video, iframe { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Icons ---------- */
.ico { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ico-sm { width: 16px; height: 16px; }
.ico-lg { width: 28px; height: 28px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: transform .08s ease, background .15s ease, border-color .15s; white-space: nowrap;
}
.btn:hover { background: #252b36; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #d6fb52; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 93, 93, .2); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 10px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; font-size: inherit; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text); font-family: inherit; font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-sm { height: 38px; font-size: 14px; padding: 0 10px; border-radius: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.chips-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle { position: relative; }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle span {
  display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer;
}
.chip-toggle input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Auth ---------- */
.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.auth-hero {
  position: relative; overflow: hidden; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(900px 500px at 10% 10%, rgba(200, 241, 53, .18), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(91, 157, 255, .16), transparent 60%),
    var(--bg-2);
  border-right: 1px solid var(--border);
}
.auth-hero h1 { font-size: clamp(34px, 4vw, 54px); font-weight: 800; max-width: 560px; }
.auth-hero h1 em { font-style: normal; color: var(--accent); }
.auth-hero p.lead { color: var(--muted); font-size: 17px; max-width: 480px; margin-top: 16px; }
.hero-feats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 620px; }
.hero-feat { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.hero-feat .ico { color: var(--accent); margin-bottom: 8px; }
.hero-feat strong { display: block; font-size: 14px; }
.hero-feat span { color: var(--muted); font-size: 13px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand-mark .ico { stroke-width: 2.4; }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 28px; font-weight: 800; }
.auth-card .sub { color: var(--muted); margin: 6px 0 24px; }
.role-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; margin-bottom: 22px;
}
.role-switch button {
  height: 44px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, color .15s;
}
.role-switch button.active { background: var(--accent); color: var(--accent-ink); }
.role-switch button.active.teacher { background: var(--blue); color: #fff; }
.auth-row { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 18px; font-size: 14px; }
.auth-foot { text-align: center; margin-top: 22px; color: var(--muted); font-size: 14px; }
.demo-box { margin-top: 26px; padding: 14px 16px; border: 1px dashed var(--border); border-radius: 12px; font-size: 13px; color: var(--muted); }
.demo-box b { color: var(--text); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); cursor: pointer; padding: 8px; }
.code-inputs { display: flex; gap: 8px; }
.code-inputs input { text-align: center; font-size: 22px; font-weight: 700; padding: 0; letter-spacing: .1em; }
.steps { display: flex; gap: 6px; margin-bottom: 20px; }
.steps span { flex: 1; height: 4px; border-radius: 4px; background: var(--border); }
.steps span.on { background: var(--accent); }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; position: sticky; top: 0; height: 100vh; padding: 22px 16px;
  background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 22px;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px; border-radius: 12px; color: var(--muted); font-weight: 600;
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.sidebar .me .who { flex: 1; min-width: 0; }
.sidebar .me .who strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .me .who span { font-size: 12px; color: var(--muted); }
.role-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 999px; }
.role-tag.teacher { background: var(--blue-soft); color: var(--blue); }
.role-tag.student { background: var(--accent-soft); color: var(--accent); }

.main { flex: 1; min-width: 0; padding: 28px 36px 60px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 800; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 14px; margin-bottom: 12px; cursor: pointer; background: none; border: none; padding: 0; }
.back:hover { color: var(--text); }

.bottom-nav { display: none; }

.avatar {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 15px; flex-shrink: 0;
  background: linear-gradient(135deg, #2a3140, #1b2029); color: var(--text); border: 1px solid var(--border);
}
.avatar.lg { width: 64px; height: 64px; border-radius: 18px; font-size: 22px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 17px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .k { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .k .ico { color: var(--accent); }
.stat .v { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item strong { display: block; font-size: 14px; }
.list-item .muted { font-size: 13px; }
.clickable { cursor: pointer; border-radius: 12px; transition: background .15s; }
.clickable:hover { background: var(--surface-2); }
.list-item.clickable { padding: 12px; border-bottom: none; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--accent-soft); color: var(--accent); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.red { background: var(--danger-soft); color: var(--danger); }

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; }
.toolbar .search .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search .input { padding-left: 42px; }
.toolbar select.input { width: auto; min-width: 170px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico { width: 44px; height: 44px; color: var(--border); margin-bottom: 10px; }
.empty h3 { color: var(--text); font-size: 17px; margin-bottom: 6px; }

/* ---------- Exercise grid ---------- */
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.ex-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; cursor: pointer; transition: border-color .15s, transform .15s; }
.ex-card:hover { border-color: #3a4250; transform: translateY(-2px); }
.ex-thumb { aspect-ratio: 16/9; background: linear-gradient(135deg, #1f2530, #141820); display: grid; place-items: center; position: relative; overflow: hidden; }
.ex-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ex-thumb .play { position: absolute; width: 46px; height: 46px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; color: #fff; backdrop-filter: blur(4px); }
.ex-thumb .novideo { color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; }
.ex-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ex-body h4 { font-size: 15px; font-weight: 700; }
.ex-meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Video ---------- */
.video-frame { position: relative; width: 100%; aspect-ratio: 16/9; background: #000; border-radius: 14px; overflow: hidden; }
.video-frame iframe, .video-frame video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-empty { aspect-ratio: 16/9; border-radius: 14px; border: 1px dashed var(--border); display: grid; place-items: center; color: var(--muted); text-align: center; padding: 16px; }

/* ---------- Sheets ---------- */
.sheet-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet-card .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sheet-letter { width: 48px; height: 48px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 20px; flex-shrink: 0; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days span { width: 30px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.days span.on { background: var(--accent-soft); color: var(--accent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
table.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 12px; background: var(--bg-2); border-bottom: 1px solid var(--border); }
table.tbl td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }

/* Editor items */
.item-row { background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.item-row .head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.item-row .num { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.item-row .head strong { flex: 1; min-width: 0; }
.item-row .head .tools { display: flex; gap: 4px; }
.item-fields { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.item-fields .field { margin: 0; }
.item-fields .field label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.item-fields .wide { grid-column: span 3; }

/* ---------- Workout (student) ---------- */
.hero-card {
  border-radius: 20px; padding: 24px; position: relative; overflow: hidden; border: 1px solid var(--border);
  background: radial-gradient(600px 300px at 100% 0%, rgba(200, 241, 53, .22), transparent 60%), var(--surface);
}
.hero-card h2 { font-size: 24px; font-weight: 800; }
.progress { height: 8px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 8px; transition: width .3s ease; }

.wo-ex { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden; margin-bottom: 16px; }
.wo-ex.done { border-color: rgba(200, 241, 53, .45); }
.wo-ex-head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; cursor: pointer; }
.wo-ex-head .num { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.wo-ex.done .wo-ex-head .num { background: var(--accent); color: var(--accent-ink); }
.wo-ex-head .grow { flex: 1; min-width: 0; }
.wo-ex-head h4 { font-size: 16px; font-weight: 700; }
.wo-ex-head .chev { color: var(--muted); transition: transform .2s; }
.wo-ex.open .chev { transform: rotate(180deg); }
.wo-ex-body { display: none; padding: 0 18px 18px; }
.wo-ex.open .wo-ex-body { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
.spec-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.spec { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.spec span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.spec strong { font-size: 18px; font-weight: 800; }
.set-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.set-btn {
  min-width: 64px; height: 52px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg-2); color: var(--text);
  font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; font-size: 13px;
}
.set-btn small { font-size: 10px; color: var(--muted); font-weight: 600; }
.set-btn.done { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.set-btn.done small { color: var(--accent-ink); opacity: .7; }
.note { background: var(--bg-2); border-left: 3px solid var(--blue); border-radius: 8px; padding: 10px 12px; font-size: 14px; color: #c9d1dd; }

.rest-timer {
  position: fixed; right: 24px; bottom: 24px; z-index: 50; background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); min-width: 260px;
}
.rest-timer .time { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); }
.rest-timer .grow { flex: 1; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4, 6, 9, .72); backdrop-filter: blur(4px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s ease; }
.modal { width: 100%; max-width: 640px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); animation: pop .18s ease; }
.modal.lg { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { font-size: 18px; font-weight: 800; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.tabs { display: flex; gap: 6px; padding: 5px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 14px; }
.tabs button { flex: 1; height: 36px; border: none; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.tabs button.active { background: var(--surface-2); color: var(--text); }
.dropzone { border: 1.5px dashed var(--border); border-radius: 14px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone:hover { border-color: var(--accent); color: var(--text); }
.picker-list { max-height: 380px; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.picker-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; border: 1px solid var(--border); cursor: pointer; }
.picker-item:hover { border-color: var(--accent); }
.picker-item.sel { border-color: var(--accent); background: var(--accent-soft); }
.picker-thumb { width: 64px; height: 40px; border-radius: 8px; background: var(--surface-2); overflow: hidden; display: grid; place-items: center; flex-shrink: 0; color: var(--muted); }
.picker-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: flex-start; animation: pop .2s ease; font-size: 14px; }
.toast.ok .ico { color: var(--accent); }
.toast.err .ico { color: var(--danger); }
.toast.info .ico { color: var(--blue); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .item-fields { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .wo-ex.open .wo-ex-body { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { display: none; }
  .main { padding: 16px 16px 100px; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30;
    padding: 12px 16px; margin: -16px -16px 16px; background: rgba(11, 13, 16, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(17, 20, 25, .95); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 0; }
  .bottom-nav a.active { color: var(--accent); }
  .page-head h1 { font-size: 23px; }
  .page-head { align-items: flex-start; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat .v { font-size: 24px; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .item-fields { grid-template-columns: repeat(2, 1fr); }
  .item-fields .wide { grid-column: span 2; }
  .rest-timer { left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); min-width: 0; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-height: 92vh; border-radius: 20px 20px 0 0; }
  .ex-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .toolbar select.input { flex: 1; min-width: 0; }
}
@media (max-width: 420px) {
  .grid-2 { grid-template-columns: 1fr; }
  .ex-grid { grid-template-columns: 1fr 1fr; }
  .ex-body { padding: 10px 12px 12px; }
  .ex-body h4 { font-size: 13px; }
}

/* ---------- Print (ficha) ---------- */
@media print {
  body { background: #fff; color: #000; }
  .sidebar, .topbar, .bottom-nav, .page-head .actions, .back, .no-print, #toast-root { display: none !important; }
  .main { padding: 0; }
  .card, .table-wrap { border-color: #ccc; background: #fff; }
  table.tbl th { background: #f2f2f2; color: #333; }
  .badge { border: 1px solid #ccc; background: #fff; color: #000; }
  .muted { color: #555; }
}
.span-3 { grid-column: span 3; }
@media (max-width: 820px) { .span-3 { grid-column: 1 / -1; } }
.grid-code { display: grid; grid-template-columns: 150px 1fr; gap: 12px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@media (max-width: 820px) { .grid-4 { grid-template-columns: 1fr 1fr; } .grid-code { grid-template-columns: 120px 1fr; } }

/* ---------- Gestor (admin) ---------- */
.role-tag.admin { background: rgba(255, 181, 71, .14); color: var(--warn); }
.role-switch.three { grid-template-columns: repeat(3, 1fr); }
.role-switch button.active.admin { background: var(--warn); color: #1a1205; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.stat.clickable:hover { border-color: #3a4250; }
@media (max-width: 600px) {
  .user-row { flex-wrap: wrap; }
  .user-row .row-actions { width: 100%; padding-left: 52px; }
  .hide-sm { display: none; }
}

/* ---------- Ajustes: cadastro, séries editáveis, histórico ---------- */
[hidden] { display: none !important; }
.form-section { font-weight: 700; font-size: 14px; margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--border); }
/* IMC: escondido até ter peso e altura; aparece deslizando */
.imc-box {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid rgba(200, 241, 53, .35);
  max-height: 0; opacity: 0; overflow: hidden; padding: 0 14px; margin: 0; border-width: 0;
  transition: max-height .25s ease, opacity .2s ease, padding .25s ease, margin .25s ease;
}
.imc-box.show { max-height: 80px; opacity: 1; padding: 12px 14px; margin: -4px 0 14px; border-width: 1px; }
.imc-box .ico { color: var(--accent); }
.imc-box b { font-size: 17px; }
.field-warn { display: flex; align-items: center; gap: 6px; color: var(--warn); font-size: 13px; margin-top: 2px; }
.rest-hint { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; padding: 10px 12px; border-radius: 12px; background: var(--blue-soft); color: #c9dcff; font-size: 14px; }
.rest-hint .ico { color: var(--blue); }
.set-table { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.set-head, .set-line { display: grid; grid-template-columns: 42px 1fr 1fr 46px; gap: 8px; align-items: center; }
.set-head span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.set-line { padding: 4px; border-radius: 12px; transition: background .15s; }
.set-line.done { background: var(--accent-soft); }
.set-line .input { text-align: center; }
.set-n { font-weight: 800; text-align: center; }
.set-check { width: 46px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-2); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.set-check.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.log-ex { padding: 14px 0; border-top: 1px solid var(--border); }
.log-ex-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 2px; }
.set-chips, .legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.legend { margin: 0 0 6px; }
.set-chip { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 8px; background: var(--surface-2); }
.set-chip.ok { background: var(--accent-soft); color: var(--accent); }
.set-chip.low { background: rgba(255, 181, 71, .14); color: var(--warn); }
.set-chip.miss { background: var(--danger-soft); color: var(--danger); }

/* ---------- Aprovações e notificações ---------- */
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.bell { position: relative; }
.bell-dot { position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; display: inline-grid; place-items: center; }
.bottom-nav a { position: relative; }
.bottom-nav .nav-badge { position: absolute; top: 0; left: 55%; margin: 0; height: 17px; min-width: 17px; font-size: 10px; }
.nav a span { display: flex; align-items: center; flex: 1; gap: 8px; }
.alert-card { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 18px; border-radius: 16px; cursor: pointer;
  background: rgba(255, 181, 71, .1); border: 1px solid rgba(255, 181, 71, .4); color: var(--text); }
.alert-card > .ico { color: var(--warn); }
.alert-card .grow { flex: 1; min-width: 0; }
.notif.unread { background: var(--accent-soft); border-radius: 12px; }
.notif { padding-left: 8px !important; padding-right: 8px !important; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--accent); }
@media (max-width: 820px) { .bottom-nav a { font-size: 10px; } }

/* ---------- Marca: TreinOn + nome da academia ---------- */
.brand { min-width: 0; }
.brand-mark { flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-app { font-weight: 800; letter-spacing: -.02em; }
.brand.has-gym .brand-app { font-size: 15px; }
.brand-gym {
  font-size: 13px; font-weight: 700; color: var(--accent); letter-spacing: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.brand-lg .brand-mark { width: 46px; height: 46px; border-radius: 13px; }
.brand-lg .brand-app { font-size: 22px; }
.brand-lg.has-gym .brand-app { font-size: 16px; color: var(--muted); font-weight: 700; }
.brand-lg .brand-gym { font-size: 22px; font-weight: 800; color: var(--text); -webkit-line-clamp: 1; }
.side-top { align-items: flex-start; }
.topbar .brand { flex: 1; }
.topbar .brand-gym { -webkit-line-clamp: 1; font-size: 12px; }
.topbar > div:last-child { flex-shrink: 0; }

.gym-chip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 22px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.gym-chip .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.gym-chip b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gym-mono { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.sidebar .brand-gym { font-size: 14px; }

/* ---------- Confirmação de e-mail ---------- */
.verify-icon { width: 60px; height: 60px; border-radius: 18px; display: grid; place-items: center; margin-bottom: 16px; background: var(--accent-soft); color: var(--accent); }

/* ---------- Componentes nativos no tema escuro ---------- */
:root { color-scheme: dark; }               /* barras de rolagem e campos nativos escuros */
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* ---------- Lista suspensa própria (substitui o <select> do sistema) ---------- */
.csel { position: relative; width: 100%; }
.csel > select { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.csel-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  text-align: left; cursor: pointer; font-weight: 500;
}
.csel-btn .csel-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.csel-btn.placeholder .csel-label { color: var(--muted); }
.csel-btn .ico { color: var(--muted); transition: transform .15s, color .15s; }
.csel-btn:hover .ico { color: var(--text); }
.csel-btn.open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.csel-btn.open .ico { transform: rotate(180deg); color: var(--accent); }
.toolbar .csel { width: auto; min-width: 190px; }
@media (max-width: 820px) { .toolbar .csel { flex: 1; min-width: 0; } }

.csel-list {
  position: fixed; z-index: 300; overflow-y: auto; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); animation: pop .12s ease;
}
.csel-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text);
}
.csel-opt.ph { color: var(--muted); }
.csel-opt.active { background: rgba(255, 255, 255, .06); }
.csel-opt.sel { color: var(--accent); font-weight: 700; }
.csel-opt.sel .ico { color: var(--accent); }
.csel-list::-webkit-scrollbar { width: 8px; }
.csel-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ---------- Carregando ---------- */
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.busy { cursor: progress; }
body.busy .btn-primary { opacity: .7; pointer-events: none; }

/* ---------- Marca TreinOn: "Trein" + "On" em destaque ---------- */
.brand-app { white-space: nowrap; }
.brand-on { color: var(--accent); }
.brand-lg.has-gym .brand-app .brand-on { color: var(--accent); opacity: .85; }

/* ---------- Celular: sem zoom automático ao digitar ----------
   O Safari do iPhone dá zoom em campos com letra menor que 16px
   (e a tela fica ampliada depois do login). Com 16px isso não acontece,
   e o zoom com dois dedos continua funcionando normalmente. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (max-width: 820px) {
  .input, .input-sm, select.input, textarea.input, .set-line .input { font-size: 16px; }
}

/* ---------- Escolha da academia ---------- */
.acad-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.acad-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; text-align: left; cursor: pointer;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, background .15s; }
.acad-item:hover:not([disabled]) { border-color: var(--accent); background: var(--surface-2); }
.acad-item[disabled] { opacity: .55; cursor: not-allowed; }
.acad-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acad-item .acad-go { transform: rotate(-90deg); color: var(--muted); }
.txt-red { color: var(--danger); } .txt-warn { color: var(--warn); }
