:root{
  --bg:#f6f9ff;
  --card:#ffffff;
  --text:#1e293b;
  --muted:#64748b;
  --line:#e2e8f0;
  --soft:#f1f5f9;
  --accent-1:#ff7ab6;
  --accent-2:#7c83ff;
  --accent-3:#4ade80;
  --accent-4:#38bdf8;
  --accent-5:#f59e0b;
  --shadow:0 20px 40px rgba(15,23,42,.08);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color:var(--text);
  background:linear-gradient(180deg, #f6f9ff 0%, #fdfcff 100%);
}

.wrap{
  width:min(1100px, calc(100% - 32px));
  margin:0 auto;
}

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  background:rgba(255,255,255,.9);
  border-bottom:1px solid var(--line);
  backdrop-filter:blur(10px);
}

.topbar .wrap{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:16px 0;
  gap:16px;
}
.topbar .wrap{flex-wrap:wrap}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-family:"Space Grotesk", Inter, sans-serif;
  font-weight:700;
  letter-spacing:.2px;
}
.brand{color:var(--text); text-decoration:none}
.brand__mark{width:30px; height:30px}
.brand__text{font-size:18px}

.nav{display:flex; gap:10px; flex-wrap:wrap}
.navtoggle{
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  border-radius:12px;
  padding:8px 10px;
  cursor:pointer;
  display:none;
}
.navtoggle:hover{box-shadow:0 8px 18px rgba(15,23,42,.08)}
.nav__link{
  color:var(--muted);
  text-decoration:none;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid transparent;
  font-weight:500;
}
.nav__link:hover{color:var(--text); border-color:var(--line); background:var(--soft)}
.nav__link--active{color:var(--text); border-color:rgba(124,131,255,.4); background:rgba(124,131,255,.12)}

.card{
  margin:20px 0 30px;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:20px;
  padding:20px;
  box-shadow:var(--shadow);
  animation:card-rise .45s ease both;
}

.card__row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
  flex-wrap:wrap;
}

.h1{font-family:"Space Grotesk", Inter, sans-serif; font-size:26px; margin:0}
.h2{font-family:"Space Grotesk", Inter, sans-serif; font-size:20px; margin:12px 0}
.h3{font-family:"Space Grotesk", Inter, sans-serif; font-size:16px; margin:0}

.label{display:block; font-size:12px; color:var(--muted); margin:12px 0 6px}

.input{
  width:100%;
  border-radius:12px;
  border:1px solid var(--line);
  background:#f8fafc;
  color:var(--text);
  padding:10px 12px;
  outline:none;
  transition:border-color .15s ease, box-shadow .15s ease;
}
.input:focus{border-color:rgba(124,131,255,.7); box-shadow:0 0 0 4px rgba(124,131,255,.15)}

.searchrow{display:flex; gap:10px}
.searchrow .input{flex:1}

.btn{
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  border-radius:12px;
  padding:10px 14px;
  cursor:pointer;
  font-weight:600;
}
.btn:hover{border-color:rgba(124,131,255,.4); box-shadow:0 8px 20px rgba(124,131,255,.12)}
.btn:disabled{opacity:.5; cursor:not-allowed}

.btn--primary{
  border:none;
  color:#fff;
  background:linear-gradient(135deg, var(--accent-2), var(--accent-1));
}
.btn--ghost{background:transparent}
.btn--soft{background:var(--soft)}

.card__actions{
  display:flex;
  gap:10px;
  margin-top:12px;
  flex-wrap:wrap;
}

.pillset{display:flex; gap:8px}
.pill{
  border:1px solid var(--line);
  background:#fff;
  color:var(--muted);
  border-radius:999px;
  padding:8px 14px;
  cursor:pointer;
  font-weight:500;
}
.pill--active{
  color:#fff;
  border-color:transparent;
  background:linear-gradient(135deg, var(--accent-4), var(--accent-3));
}

.grid{display:grid; gap:16px}
.grid--2{grid-template-columns:1.1fr .9fr}
@media (max-width: 900px){
  .grid--2{grid-template-columns:1fr}
  .navtoggle{display:inline-flex}
  .nav{
    display:none;
    width:100%;
    flex-direction:column;
    align-items:flex-start;
    gap:6px;
    padding:10px;
    border:1px solid var(--line);
    border-radius:14px;
    background:#fff;
  }
  .nav.nav--open{display:flex}
}
@media (max-width: 700px){
  .chartwrap canvas{height:280px}
  .chartwrap--tall canvas{height:340px}
}

.status{margin-top:10px; color:var(--muted); font-size:12px; min-height:16px}
.muted{color:var(--muted); font-size:12px}

.listhead{display:flex; align-items:center; justify-content:space-between; margin-top:10px}
.linkbtn{
  background:transparent;
  border:none;
  color:var(--accent-2);
  cursor:pointer;
  padding:6px 0;
  font-weight:600;
}
.linkbtn:hover{text-decoration:underline}

.list{
  list-style:none;
  padding:0;
  margin:10px 0 0;
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  max-height:520px;
  overflow:auto;
  background:#fff;
}

.list li{
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.list__section{
  display:block;
  background:var(--soft);
  color:var(--muted);
  font-size:12px;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:.06em;
}
.list li:last-child{border-bottom:none}
.list li button{
  border:1px solid rgba(124,131,255,.4);
  background:rgba(124,131,255,.08);
  color:var(--text);
  border-radius:10px;
  padding:8px 10px;
  cursor:pointer;
}
.list li button:hover{background:rgba(124,131,255,.15)}
.badge{
  font-size:11px;
  color:#1e293b;
  background:rgba(56,189,248,.15);
  border-radius:999px;
  padding:4px 10px;
}

.today{
  list-style:none;
  padding:0;
  margin:8px 0 0;
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  background:#fff;
}
.today li{
  padding:12px 14px;
  border-bottom:1px solid var(--line);
}
.today li:last-child{border-bottom:none}
.today__row{display:flex; justify-content:space-between; gap:10px; align-items:flex-start}
.today__title{font-weight:600}
.today__meta{color:var(--muted); font-size:12px; margin-top:4px}
.today__remove{
  background:transparent;
  border:1px solid var(--line);
  color:var(--muted);
  border-radius:10px;
  padding:6px 8px;
  cursor:pointer;
}
.today__remove:hover{color:#ef4444; border-color:rgba(239,68,68,.5)}

.empty{
  border:1px dashed rgba(148,163,184,.6);
  border-radius:14px;
  padding:12px;
  color:var(--muted);
  font-size:13px;
  background:#fff;
}

.hint{color:var(--muted); font-size:12px; margin:12px 0 0}

.modalbackdrop{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.35);
  z-index:50;
  backdrop-filter:blur(2px);
}
.modal{
  position:fixed;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
  width:min(540px, calc(100% - 28px));
  background:#fff;
  border:1px solid var(--line);
  border-radius:20px;
  z-index:60;
  box-shadow:var(--shadow);
}
.modal__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:16px 16px 12px;
  border-bottom:1px solid var(--line);
}
.modal__body{padding:16px}
.modal__actions{display:flex; gap:10px; margin-top:12px; flex-wrap:wrap}
.iconbtn{
  border:1px solid var(--line);
  background:transparent;
  color:var(--text);
  border-radius:12px;
  width:38px;
  height:38px;
  cursor:pointer;
}
.hidden{display:none}
.split{display:flex; gap:10px}
.field{min-width:0}

.weekpicker{display:flex; align-items:center; gap:10px}
.weekpicker__label{font-size:14px; color:var(--muted)}

.summarygrid{display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:12px; margin-bottom:12px}
.summarygrid--loose{gap:16px; margin-bottom:16px}
.summarycard{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  background:#fff;
}
.summaryvalue{font-size:22px; font-weight:700}

.dayrow{display:flex; align-items:center; justify-content:space-between; gap:8px}
.sessiondetail{font-size:13px; color:var(--muted); display:grid; gap:8px}

.toast{
  position:fixed;
  right:16px;
  bottom:16px;
  background:#fff;
  border:1px solid var(--line);
  padding:10px 12px;
  border-radius:12px;
  box-shadow:var(--shadow);
  z-index:70;
}

.authpage{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:30px 0;
}
.authlayout{
  width:100%;
  display:grid;
  grid-template-columns:1fr 1.1fr;
  gap:28px;
  align-items:stretch;
}
.authleft{display:grid; gap:16px; align-content:center}
.authlogo{display:flex; align-items:center; gap:10px; color:var(--text); text-decoration:none}
.authcard{max-width:420px; width:min(420px, 100%); margin:0}
.authright{
  border-radius:24px;
  background:linear-gradient(135deg, #4267f6, #4f8bff);
  color:#fff;
  padding:40px;
  position:relative;
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:320px;
  box-shadow:0 24px 60px rgba(15,23,42,.18);
}
.authright::before{
  content:"";
  position:absolute;
  inset:-80px;
  background:radial-gradient(circle at 20% 20%, rgba(255,255,255,.18), transparent 40%);
  opacity:.8;
}
.quote{
  position:relative;
  max-width:520px;
  text-align:left;
}
.quote__text{
  font-family:"Space Grotesk", Inter, sans-serif;
  font-size:32px;
  line-height:1.2;
  font-weight:700;
  margin-bottom:16px;
  opacity:0;
  transform:translateY(8px);
  transition:opacity .5s ease, transform .5s ease;
}
.quote__author{
  font-size:14px;
  letter-spacing:.08em;
  text-transform:uppercase;
  opacity:.75;
}
.quote__author:empty{display:none}
.quote--show .quote__text{
  opacity:1;
  transform:translateY(0);
}
@media (max-width: 900px){
  .authlayout{grid-template-columns:1fr}
  .authright{order:-1}
}

.weightgrid{display:grid; gap:12px}

.pace{margin-top:12px; font-size:13px; color:var(--muted)}

.list__row{display:flex; align-items:center; gap:8px}
.list__row input[type="checkbox"]{width:16px; height:16px}
.starbtn{
  border:1px solid var(--line);
  background:transparent;
  color:var(--muted);
  border-radius:10px;
  padding:6px 8px;
  cursor:pointer;
}
.starbtn--active{color:var(--accent-2); border-color:rgba(124,131,255,.6)}
.managebtn{border:1px solid var(--line); background:transparent; color:var(--muted); border-radius:10px; padding:6px 8px; cursor:pointer}
.managebtn{width:32px; height:32px; display:inline-flex; align-items:center; justify-content:center}
.managebtn:hover{color:var(--text); background:var(--soft)}

.toolbar{display:flex; gap:10px; flex-wrap:wrap; align-items:center}
.formrow{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
.formrow .input{min-width:150px}

.quickfill{display:flex; gap:8px; flex-wrap:wrap; margin-top:8px}
.quickfill button{border:1px solid var(--line); background:var(--soft); border-radius:999px; padding:6px 10px; cursor:pointer}
.quickfill button#restStartBtn,.quickfill button#restStopBtn{border-radius:10px}

.tabs{display:flex; gap:8px; flex-wrap:wrap; margin:12px 0}
.tabbtn{border:1px solid var(--line); background:#fff; border-radius:999px; padding:6px 12px; cursor:pointer; font-weight:600}
.tabbtn:hover{transform:translateY(-1px); box-shadow:0 8px 18px rgba(15,23,42,.08)}
.tabbtn--active{background:linear-gradient(135deg, var(--accent-4), var(--accent-2)); color:#fff; border-color:transparent}
.chartwrap{border:1px solid var(--line); border-radius:16px; padding:12px; background:#fff}
.chartwrap{position:relative}
.chartwrap canvas{width:100%; height:240px; animation:chart-fade .5s ease}
.chartwrap--tall canvas{height:280px}

.progressbar{
  height:10px;
  border-radius:999px;
  background:var(--soft);
  overflow:hidden;
  margin-top:10px;
}
.progressbar__fill{
  height:100%;
  background:linear-gradient(135deg, var(--accent-3), var(--accent-4));
  width:0%;
  transition:width .2s ease;
}

@property --ring-progress{
  syntax:'<number>';
  inherits:false;
  initial-value:0;
}
.ringstack{
  position:relative;
  width:220px;
  height:220px;
  margin:16px auto 10px;
}
.ring{
  --ring-progress:0;
  --ring-target:0;
  --ring-color:var(--accent-2);
  position:absolute;
  inset:0;
  border-radius:50%;
  background:conic-gradient(var(--ring-color) calc(var(--ring-progress) * 1%), #e8eef7 0);
  box-shadow:inset 0 0 0 1px rgba(15,23,42,.06), 0 8px 20px rgba(15,23,42,.08);
}
.ring::after{
  content:"";
  position:absolute;
  inset:14px;
  background:#fff;
  border-radius:50%;
}
.ring--outer{width:220px; height:220px; --ring-color:var(--accent-1)}
.ring--outer::after{inset:16px}
.ring--mid{
  width:170px;
  height:170px;
  margin:auto;
  top:25px; left:25px; right:25px; bottom:25px;
  --ring-color:var(--accent-2);
}
.ring--mid::after{inset:13px}
.ring--inner{
  width:130px;
  height:130px;
  margin:auto;
  top:45px; left:45px; right:45px; bottom:45px;
  --ring-color:var(--accent-3);
}
.ring--inner::after{inset:11px}
.ring--core{
  width:98px;
  height:98px;
  margin:auto;
  top:61px; left:61px; right:61px; bottom:61px;
  --ring-color:var(--accent-4);
}
.ring--core::after{inset:9px}
.ring--animate{animation:ring-fill 1.6s ease forwards}
@keyframes card-rise{
  from{opacity:0; transform:translateY(8px)}
  to{opacity:1; transform:translateY(0)}
}
@keyframes chart-fade{
  from{opacity:0; transform:translateY(6px)}
  to{opacity:1; transform:translateY(0)}
}
@keyframes ring-fill{
  to{--ring-progress:var(--ring-target)}
}
.ringstack__label{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  text-align:center;
  z-index:2;
}
.ringlegend{
  display:flex;
  justify-content:center;
  gap:12px;
  font-size:13px;
  color:var(--muted);
}
.dot{
  display:inline-block;
  width:8px;
  height:8px;
  border-radius:50%;
  margin-right:6px;
}
.dot--workouts{background:var(--accent-1)}
.dot--exercise{background:var(--accent-2)}
.dot--weight{background:var(--accent-3)}
.dot--calories{background:var(--accent-4)}

.historylist{list-style:none; margin:0; padding:0; border:1px solid var(--line); border-radius:14px; background:#fff}
.historylist li{padding:12px 14px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; gap:10px; transition:transform .2s ease, box-shadow .2s ease}
.historylist li:hover{transform:translateY(-2px); box-shadow:0 10px 24px rgba(15,23,42,.08)}
.historylist li:last-child{border-bottom:none}
.historymeta{display:flex; flex-wrap:wrap; gap:8px; margin-top:6px}
.sparklinewrap{display:flex; align-items:center; justify-content:flex-end; min-width:120px}
.sparkline{width:120px; height:36px; opacity:.9}
.metricpill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  background:rgba(124,131,255,.12);
  color:var(--text);
  font-size:12px;
  font-weight:600;
}
.metricpill--soft{
  background:rgba(56,189,248,.12);
  color:var(--text);
}
.metricpill--goal{
  background:rgba(74,222,128,.18);
  color:var(--text);
}

@media (prefers-reduced-motion: reduce){
  .card,
  .ring--animate,
  .chartwrap canvas,
  .historylist li,
  .tabbtn{animation:none; transition:none}
}

#recentLocations{margin-top:8px}
#restTimer{font-weight:600}
