:root{
  --bg:#0d0f14;
  --surface:#171a22;
  --surface-2:#1e222c;
  --surface-3:#242936;
  --border:#2a2f3b;
  --border-soft:#20242e;
  --text:#eef0f5;
  --text-muted:#8a8fa3;
  --text-faint:#5b6072;
  --accent:#c6ff3d;
  --accent-dim:#8fb82a;
  --accent-ink:#101302;
  --danger:#ff5d6c;
  --danger-soft:rgba(255,93,108,0.12);
  --ok:#7be08a;
  --radius-lg:18px;
  --radius-md:12px;
  --radius-sm:8px;
  --shadow-lg:0 20px 40px -20px rgba(0,0,0,0.55);
  --shadow-sm:0 8px 20px -12px rgba(0,0,0,0.5);
}

*, *::before, *::after{ box-sizing:border-box; }

html{ -webkit-text-size-adjust:100%; }

body{
  margin:0;
  min-height:100vh;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Inter,Roboto,sans-serif;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(198,255,61,0.06), transparent 60%),
    var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
}

a{ color:inherit; }

h1,h2,h3{ margin:0; letter-spacing:-0.01em; }

button, input, select, textarea{ font-family:inherit; color:inherit; }

.muted{ color:var(--text-muted); }

/* ---------- header / nav ---------- */

.site-header{
  position:sticky;
  top:0;
  z-index:20;
  background:rgba(13,15,20,0.86);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
  padding:14px 24px 0;
}
.site-header__row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:10px 16px;
  max-width:920px;
  margin:0 auto;
  padding-bottom:12px;
}
.brand{
  font-weight:800;
  font-size:18px;
  text-transform:uppercase;
  letter-spacing:.04em;
  text-decoration:none;
  white-space:nowrap;
}
.brand span{ color:var(--accent); }

.header-actions{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.header-user{
  font-size:13px;
  font-weight:700;
  color:var(--text);
}

.user-switcher select{
  font:inherit;
  font-size:13.5px;
  font-weight:600;
  padding:9px 14px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  min-height:40px;
  max-width:42vw;
}

.btn-new-user{
  background:var(--accent);
  color:var(--accent-ink);
  border:none;
  padding:9px 14px;
  border-radius:10px;
  font-weight:700;
  font-size:12.5px;
  cursor:pointer;
  white-space:nowrap;
  min-height:40px;
}
.btn-new-user:hover{ filter:brightness(1.08); }

/* ---------- modal ---------- */

[x-cloak]{ display:none !important; }

.modal-overlay{
  position:fixed;
  inset:0;
  z-index:50;
  background:rgba(4,5,8,0.6);
  backdrop-filter:blur(2px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
}
.modal-card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:22px;
  width:100%;
  max-width:380px;
  box-shadow:var(--shadow-lg);
}
.modal-card__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:16px;
}
.modal-card__head h2{ font-size:16px; font-weight:800; }
.user-switcher select:focus{ outline:none; border-color:var(--accent); }

.site-nav{
  display:flex;
  gap:4px;
  max-width:920px;
  margin:0 auto;
  overflow-x:auto;
  scrollbar-width:none;
}
.site-nav::-webkit-scrollbar{ display:none; }
.site-nav a{
  flex:0 0 auto;
  padding:10px 14px;
  font-size:13px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.03em;
  text-decoration:none;
  color:var(--text-muted);
  border-bottom:2px solid transparent;
  white-space:nowrap;
}
.site-nav a.active{ color:var(--accent); border-bottom-color:var(--accent); }
.site-nav a:hover{ color:var(--text); }

.page{
  max-width:920px;
  margin:0 auto;
  padding:28px 20px 100px;
}

/* ---------- headings / toolbars ---------- */

.toolbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  gap:14px;
  margin-bottom:22px;
  flex-wrap:wrap;
}
.toolbar h1{ font-size:22px; font-weight:800; }
.sub{ margin:4px 0 0; color:var(--text-muted); font-size:13.5px; }

.section-title{
  font-size:12.5px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.06em;
  color:var(--text-muted);
  margin:32px 0 12px;
}

/* ---------- week meta (dashboard) ---------- */

.week-meta{
  color:var(--text-muted);
  font-size:12.5px;
  font-weight:600;
  letter-spacing:.02em;
  margin:0 0 18px;
}
.week-meta .num{ color:var(--accent); font-weight:700; }

/* ---------- tabs ---------- */

.tabs{
  display:flex;
  gap:8px;
  margin-bottom:20px;
  overflow-x:auto;
  scrollbar-width:none;
  padding-bottom:2px;
}
.tabs::-webkit-scrollbar{ display:none; }
.tab-btn{
  flex:1 0 auto;
  min-width:110px;
  padding:12px 14px;
  border-radius:var(--radius-sm);
  border:1px solid var(--border);
  background:var(--surface);
  color:var(--text-muted);
  font-weight:700;
  font-size:12.5px;
  text-transform:uppercase;
  letter-spacing:.03em;
  cursor:pointer;
  text-align:center;
  transition:background .15s ease, color .15s ease, border-color .15s ease;
}
.tab-btn.active{
  background:var(--accent);
  color:var(--accent-ink);
  border-color:var(--accent);
}
.tab-btn:not(.active):hover{ border-color:#3a4152; color:var(--text); }

/* ---------- cards ---------- */

.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:20px;
  margin-bottom:14px;
  box-shadow:var(--shadow-sm);
}
.card-title{ font-size:14px; font-weight:800; margin-bottom:14px; }

.ex-card{ padding:18px 20px; }
.ex-head{ display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:14px; flex-wrap:wrap; }
.ex-name{ font-weight:800; font-size:16px; }
.ex-target{
  font-size:11.5px; font-weight:700; letter-spacing:.02em;
  color:var(--accent-dim);
  background:rgba(198,255,61,0.08);
  padding:4px 10px;
  border-radius:999px;
  white-space:nowrap;
}

.ex-fields{ display:grid; grid-template-columns:repeat(3,1fr) 2fr; gap:10px; }
.field label{
  display:block; font-size:10.5px; text-transform:uppercase; letter-spacing:.05em;
  color:var(--text-muted); margin-bottom:6px; font-weight:700;
}
.field input, .field select{
  width:100%;
  padding:11px 12px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  font-size:14px;
  font-weight:600;
  min-height:44px;
}
.field input::placeholder{ color:var(--text-faint); font-weight:500; }
.field input:focus, .field select:focus{ outline:none; border-color:var(--accent); background:var(--surface-3); }
.field-error{ color:var(--danger); font-size:12px; margin-top:6px; font-weight:600; }

.stack-form .field{ margin-bottom:14px; }

/* ---------- buttons ---------- */

.btn-primary{
  background:var(--accent);
  color:var(--accent-ink);
  border:none;
  padding:13px 24px;
  border-radius:12px;
  font-weight:800;
  font-size:13.5px;
  cursor:pointer;
  text-transform:uppercase;
  letter-spacing:.03em;
  min-height:46px;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transition:filter .15s ease, transform .1s ease;
}
.btn-primary:hover{ filter:brightness(1.08); }
.btn-primary:active{ transform:translateY(1px); }

.btn-outline{
  background:transparent;
  color:var(--accent);
  border:1px solid var(--accent);
  padding:10px 18px;
  border-radius:10px;
  font-weight:700;
  font-size:13px;
  cursor:pointer;
  min-height:42px;
}
.btn-outline:hover{ background:rgba(198,255,61,0.08); }

.add-workout-buttons{ display:flex; gap:8px; flex-wrap:wrap; }
.panel-reveal{ margin-top:16px; }

.btn-label-short{ display:none; }

.save-row{ display:flex; justify-content:flex-end; margin-top:18px; }

.link-btn{
  background:none;
  border:none;
  color:var(--accent);
  font:inherit;
  font-weight:700;
  font-size:12.5px;
  cursor:pointer;
  padding:6px 4px;
  text-decoration:none;
}
.link-btn:hover{ color:#dbff85; }
.link-btn.danger{ color:var(--danger); }
.link-btn.danger:hover{ color:#ff8a94; }

.icon-btn{
  border:1px solid var(--border);
  background:var(--surface-2);
  border-radius:8px;
  width:30px; height:30px;
  min-width:30px;
  cursor:pointer;
  color:var(--text-muted);
  font-size:13px;
  line-height:1;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.icon-btn:hover{ color:var(--text); border-color:#3a4152; }

.row-actions{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; }

/* ---------- toasts ---------- */

.toast-ok{
  background:rgba(123,224,138,0.1);
  color:var(--ok);
  border:1px solid rgba(123,224,138,0.3);
  padding:10px 14px;
  border-radius:10px;
  font-weight:700;
  font-size:13px;
  margin-bottom:14px;
  display:inline-block;
}

.import-confirm{
  color:var(--ok);
  font-size:12px;
  font-weight:700;
  white-space:nowrap;
}

/* ---------- empty states ---------- */

.empty-state{
  background:var(--surface);
  border:1px dashed var(--border);
  border-radius:var(--radius-lg);
  padding:36px 24px;
  text-align:center;
}
.empty-state.small{ padding:20px; }
.empty-state h1{ font-size:20px; margin-bottom:8px; }
.empty-state p{ color:var(--text-muted); margin:0 0 16px; font-size:14px; }

.welcome-hero{ padding:48px 28px; }
.welcome-logo{
  color:var(--accent);
  width:130px;
  margin:0 auto 22px;
  filter:drop-shadow(0 0 18px rgba(198,255,61,0.35));
}
.welcome-hero h1{
  font-size:clamp(22px, 5vw, 28px);
  text-transform:uppercase;
  letter-spacing:.03em;
  margin-bottom:20px;
}
.welcome-quote{
  margin:0 auto 22px;
  max-width:440px;
  font-size:15px;
  font-style:italic;
  line-height:1.5;
  color:var(--text);
  border:none;
  padding:0;
}
.welcome-quote cite{
  display:block;
  margin-top:10px;
  font-style:normal;
  font-size:12px;
  font-weight:700;
  letter-spacing:.04em;
  text-transform:uppercase;
  color:var(--accent-dim);
}

/* ---------- row cards (user list) ---------- */

.user-list{ display:flex; flex-direction:column; gap:10px; }
.row-card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.row-card--edit{ align-items:flex-end; }
.row-card--edit .field{ margin:0 10px 0 0; }
.row-title{ font-weight:700; font-size:14.5px; }
.row-sub{ font-size:12px; color:var(--text-muted); margin-top:2px; }

/* ---------- tables ---------- */

.table-scroll{ overflow-x:auto; border-radius:var(--radius-md); border:1px solid var(--border); }
table.grid{
  width:100%;
  border-collapse:collapse;
  background:var(--surface);
}
table.grid caption{
  text-align:left; padding:10px 14px; font-weight:800; font-size:12px;
  background:var(--surface-2);
  color:var(--text-muted); text-transform:uppercase; letter-spacing:.04em;
}
table.grid th, table.grid td{
  text-align:left; padding:10px 12px; font-size:13.5px;
  border-bottom:1px solid var(--border-soft);
}
table.grid thead th{
  background:var(--surface-2);
  font-size:10.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--text-muted);
  font-weight:700;
}
table.grid tbody tr:last-child td{ border-bottom:none; }
table.grid td.target{ color:var(--text-muted); white-space:nowrap; }

table.grid.grid--compact th, table.grid.grid--compact td{ padding:8px 10px; }
table.grid.grid--compact input{
  width:100%;
  padding:8px 9px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text);
  font-size:13px;
  min-height:38px;
}
table.grid.grid--compact input:focus{ outline:none; border-color:var(--accent); }

.mini-fields{ display:flex; gap:6px; }
.mini-fields input{ min-width:0; }

.toolbar-add{ padding:10px 12px; background:var(--surface-2); }

/* ---------- template cards (setup) ---------- */

.template-list{ display:flex; flex-direction:column; gap:16px; }
.template-card{ padding:0; overflow:hidden; }
.template-card__head{
  display:flex; justify-content:space-between; align-items:center; gap:12px;
  padding:16px 18px;
  border-bottom:1px solid var(--border);
  flex-wrap:wrap;
}
.template-card__head--edit{ background:var(--surface-2); }
.template-card__head--edit input{
  padding:9px 11px; border-radius:8px; border:1px solid var(--border);
  background:var(--surface); color:var(--text); font-size:14px; min-width:0; flex:1;
}
.template-card__name{ font-weight:800; font-size:15.5px; }
.template-card table.grid{ border:none; }
.template-card table.grid thead th:first-child{ border-top-left-radius:0; }

/* ---------- history ---------- */

.hist-filter{
  min-height:40px;
}

.history-session table.grid{ border:none; }
.history-session__head{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:10px;
  margin-bottom:14px;
  flex-wrap:wrap;
}
.history-session__week{ font-weight:800; font-size:14px; }
.history-session__workout{ color:var(--text-muted); font-size:12.5px; font-weight:600; }

/* ---------- htmx loading affordance ---------- */

.htmx-request{ opacity:.55; transition:opacity .15s ease; }
.htmx-request.htmx-swapping{ opacity:.3; }

/* ---------- responsive ---------- */

@media (max-width: 640px){
  .site-header{ padding:12px 16px 0; }
  .page{ padding:20px 14px 90px; }
  .ex-fields{ grid-template-columns:1fr 1fr; }
  .ex-fields .field:last-child{ grid-column:1 / -1; }
  .tab-btn{ min-width:96px; font-size:11.5px; padding:11px 10px; }
  .toolbar{ flex-direction:column; align-items:flex-start; }
  .toolbar--inline{ flex-direction:row; align-items:center; }
  .btn-label-full{ display:none; }
  .btn-label-short{ display:inline; }
  .btn-outline{ padding:8px 12px; font-size:12px; min-height:36px; }
  .row-card--edit{ flex-direction:column; align-items:stretch; }
  .row-card--edit .field{ margin:0 0 10px; }
  .mini-fields{ flex-direction:column; }
}

@media (max-width: 420px){
  .brand{ font-size:16px; }
  .user-switcher select{ max-width:38vw; font-size:12.5px; padding:8px 10px; }
  .btn-new-user{ padding:8px 10px; font-size:11.5px; }
  .ex-fields{ grid-template-columns:1fr; }
  .ex-fields .field:last-child{ grid-column:auto; }
  .toolbar--inline .add-workout-buttons{ gap:6px; }
  .btn-outline{ padding:7px 9px; font-size:11px; }
}
