:root{
  --bg:#fff; --text:#111; --muted:#6b7280; --line:#e5e7eb; --accent:#111; --accent-faint:#9ca3af; --good:#16a34a; --danger:#ef4444;
  --muscle-inactive: #d1d5db;
  
  /* Customizable theme colors - set by JavaScript */
  --color-consistency: #22c55e;
  --color-consistency-light: #a7f3d0;
  --color-consistency-shadow: rgba(34, 197, 94, 0.6);
  --color-balance: #3b82f6;
  --color-balance-light: #bfdbfe;
  --color-balance-shadow: rgba(59, 130, 246, 0.6);
  
  /* Muscle group colors - set by JavaScript based on consistency color */
  --muscle-complete: #22c55e;
  --muscle-partial: #a7f3d0;
}

/* Light mode override */
:root[data-theme="light"]{
  --bg:#fff; --text:#111; --muted:#6b7280; --line:#e5e7eb; --accent:#111; --accent-faint:#9ca3af; 
  --muscle-inactive: #d1d5db;
}

/* Dark mode override */
:root[data-theme="dark"]{
  --bg:#0b0b0b; --text:#eaeaea; --muted:#9aa0a6; --line:#222; --accent:#eaeaea; --accent-faint:#666; 
  --muscle-inactive: #374151;
}

/* System preference (default behavior) */
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){ 
    --bg:#0b0b0b; --text:#eaeaea; --muted:#9aa0a6; --line:#222; --accent:#eaeaea; --accent-faint:#666; 
    --muscle-inactive: #374151;
  }
}
*{box-sizing:border-box}
html,body{margin:0; touch-action:manipulation}

/* Loading state */
body.loading .loading-overlay{
  display:flex !important;
  opacity:1 !important;
}
body.loading > *:not(.loading-overlay){
  opacity:0 !important;
  pointer-events:none;
}

.loading-overlay{
  position:fixed;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background:var(--bg);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:99999;
  transition:opacity 0.3s ease;
}

.spinner{
  width:40px;
  height:40px;
  border:3px solid var(--line);
  border-top-color:var(--text);
  border-radius:50%;
  animation:spin 0.8s linear infinite;
}

@keyframes spin{
  to{ transform:rotate(360deg); }
}

body{font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif; background:var(--bg); color:var(--text); max-width:680px; margin:0 auto; padding:0 14px 96px; line-height:1.6}
a,button{cursor:pointer}

/* -------- Top bar -------- */
.topbar{
  position:sticky; top:0; background:var(--bg); z-index:20;
  display:flex; align-items:center; gap:20px;
  padding:12px 0; border-bottom:1px solid var(--line)
}
.brand{display:flex; align-items:center; gap:10px}
.logo-dot{width:10px; height:10px; border-radius:999px; background:var(--text)}
.brand-name{font-weight:800; letter-spacing:-0.01em; min-height:1.5em}
.brand-name.max-momentum{color:var(--color-consistency) !important; text-shadow:0 0 1px var(--color-consistency), 0 0 3px var(--color-consistency), 0 0 6px var(--color-consistency) !important; animation:pulse-glow 2s ease-in-out infinite !important; font-weight:500 !important}
@keyframes pulse-glow{0%, 100%{text-shadow:0 0 1px var(--color-consistency), 0 0 3px var(--color-consistency), 0 0 6px var(--color-consistency)} 50%{text-shadow:0 0 2px var(--color-consistency), 0 0 5px var(--color-consistency), 0 0 9px var(--color-consistency)}}
.brand-motto{font-size:11px; color:var(--muted); margin-top:-2px}
.tabs{display:flex; gap:4px}
.tab{border:none; background:transparent; padding:8px 16px; border-radius:8px; font-weight:600; color:var(--muted); cursor:pointer; transition:all .15s ease}
.tab:hover{color:var(--text); background:rgba(127,127,127,.06)}
.tab.active{color:var(--text); background:rgba(127,127,127,.1)}
.consistency-toggle{position:absolute; top:0; right:0; z-index:15; border:2px solid var(--line); background:var(--bg); width:42px; height:42px; border-radius:50%; cursor:pointer; transition:all .2s ease}
.consistency-toggle:hover{border-color:var(--accent-faint)}
.consistency-toggle.active{background:var(--color-consistency); border-color:var(--color-consistency); box-shadow:0 0 12px var(--color-consistency-shadow)}
.header-title{font-size:14px; color:var(--muted)}
.user-cta{display:flex; align-items:center; gap:12px; margin-left:auto}
.hamburger{border:1px solid var(--line); background:transparent; padding:7px 12px; border-radius:8px; line-height:1.2; font-weight:700; color:var(--text); font-size:115%}
.menu{position:relative}
.menu-dropdown{position:absolute; right:0; top:36px; background:var(--bg); border:1px solid var(--line); border-radius:10px; padding:6px; display:none; min-width:140px; box-shadow:0 8px 20px rgba(0,0,0,0.08); z-index:20}
.menu-item{display:block; width:100%; text-align:left; border:none; background:transparent; padding:8px 10px; border-radius:8px; transition:all 0.2s; color:var(--text); font-size:88%}
.menu-item:hover:not(:disabled){background:rgba(127,127,127,.06)}
.menu-item.active{background:rgba(127,127,127,.1); font-weight:700}
.menu-item:disabled{opacity:0.5; cursor:not-allowed}

/* Visibility shells */
.auth-only{display:none}
body.authenticated .auth-only{display:revert}
body.authenticated .no-auth-only{display:none}
body:not(.authenticated) .topbar{display:none !important}

#content{margin-top:12px; position:relative}

/* Rest day warning - positioned alongside green button */
.rest-warning{
  background:transparent;
  border:1px solid var(--color-balance-shadow);
  color:var(--color-balance);
  padding:10px 14px;
  border-radius:10px;
  margin-bottom:12px;
  margin-right:60px; /* Space for green button on right */
  font-weight:600;
  font-size:13px;
  min-height:50px; /* Smaller reserved space */
  display:inline-block;
  width:fit-content;
  max-width:calc(100% - 60px); /* Don't overflow past button */
  visibility:hidden; /* Hide when empty but still takes up space */
}

/* Show rest warning content when there's a message AND consistency mode is active */
body.consistency-mode .rest-warning:not(:empty){
  visibility:visible;
}

/* Always show the box border when consistency mode is active (even if empty) */
body.consistency-mode .rest-warning{
  border-color:var(--color-balance-light); /* Lighter border when empty */
  background:transparent;
}

/* Darker border when it has content */
body.consistency-mode .rest-warning:not(:empty){
  border-color:var(--color-balance-shadow);
  background:transparent;
}

.rest-message{
  margin-bottom:8px;
}

/* Inline muscle recommendations */
.inline-recommendations{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:8px;
  font-size:12px;
  font-weight:500;
}

.rec-text{
  opacity:0.8;
}

.rec-icons{
  display:flex;
  gap:6px;
  align-items:center;
}

.rec-icon-small{
  width:16px;
  height:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:3px;
  padding:2px;
  transition:all 0.2s ease;
}

.rec-icon-small .muscle-svg{
  width:100%;
  height:100%;
  fill:currentColor;
}

/* Priority-based blue coloring for small icons */
.rec-icon-small.priority-high{
  background:rgba(37, 99, 235, 0.2);
  color:var(--color-balance);
  filter:drop-shadow(0 0 6px var(--color-balance-shadow));
}

.rec-icon-small.priority-medium{
  background:var(--color-balance-light);
  color:var(--color-balance);
  filter:drop-shadow(0 0 4px var(--color-balance-shadow));
}

.rec-icon-small.priority-low{
  background:rgba(96, 165, 250, 0.12);
  color:#60a5fa;
  filter:drop-shadow(0 0 2px var(--color-balance-shadow));
}

.rec-icon-small.priority-rest{
  background:rgba(127,127,127,0.08);
  color:var(--muscle-inactive);
  opacity:0.5;
}

/* Glowing motto words when consistency mode is active */
.motto-consistency, .motto-balance, .motto-strength{
  transition:all .3s ease;
}

body.consistency-mode .motto-consistency{
  color:var(--color-consistency);
  text-shadow:0 0 8px var(--color-consistency-shadow);
}

body.consistency-mode .motto-balance{
  color:var(--color-balance);
  text-shadow:0 0 8px var(--color-balance-shadow);
}

body.consistency-mode .motto-strength{
  color:var(--text);
  text-shadow:0 0 8px rgba(0, 0, 0, 0.4);
  font-weight:700;
}

/* Blue glowing shadow when rest recommendation exists */
.consistency-toggle.has-rest-notification{
  box-shadow:0 0 20px var(--color-balance-shadow);
  animation:pulseBlueGlow 2s ease-in-out infinite;
}

.consistency-toggle.active.has-rest-notification{
  box-shadow:0 0 12px var(--color-consistency-shadow), 0 0 20px var(--color-balance-shadow);
}

@keyframes pulseBlueGlow{
  0%, 100%{
    box-shadow:0 0 20px var(--color-balance-shadow);
  }
  50%{
    box-shadow:0 0 30px var(--color-balance);
  }
}

/* ------- Notebook layout ------- */
.month{margin:14px 0}
.month > .row{font-weight:800; letter-spacing:-0.01em; margin:8px 0; display:flex; align-items:center; gap:6px; cursor:pointer}
.caret{display:inline-block; transform:rotate(0deg); transition:transform .12s ease; opacity:.6}
.caret.open{transform:rotate(90deg); opacity:1}
.week{margin-left:18px; border-left:1px solid var(--line); padding-left:12px; background:rgba(127,127,127,.03); padding:10px; border-radius:8px; border:1px solid var(--line); margin-bottom:12px}
.week > .row{color:var(--muted); font-weight:700; display:flex; align-items:center; gap:6px; margin:6px 0; cursor:pointer}
.week > .row .week-label{margin-right:auto}
.day{margin-left:18px; padding-left:12px; border-left:1px dashed var(--line)}
.day .date{font-weight:700; margin:6px 0 4px; display:flex; align-items:center; gap:6px; cursor:pointer}
.day .date .date-text{margin-right:auto}
.list{margin:2px 0 12px; padding-left:22px; border-left:1px dotted var(--line)}
.entry{display:flex; align-items:baseline; gap:8px; padding:3px 0; position:relative; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none}
.entry .dot{font-size:12px; opacity:.6}
.entry .line{flex:1 1 auto; min-width:0; display:flex; align-items:baseline; flex-wrap:wrap; gap:4px}
.entry .name{font-weight:600; white-space:nowrap}
.entry .sep{opacity:.35; padding:0 4px}
.entry .details{color:var(--muted); white-space:nowrap}
.entry .prog{font-size:11px; margin-left:8px; color:var(--good); opacity:.9}
.actions{display:flex; gap:6px; margin-left:8px; opacity:0; transition:opacity .12s ease}
.entry:hover .actions, .entry.show-actions .actions{opacity:1}
.icon{border:none; padding:0; background:transparent; color:var(--accent-faint); font-size:12px; line-height:1; opacity:.8}
.icon:hover{color:var(--accent); opacity:1}

/* Muscle group indicators */
.muscle-cell{
  display:flex;
  align-items:center;
  justify-content:center;
  align-self:center;
  width:23px;
  height:23px;
  margin-right:2px;
}
.muscle-cell:last-child{
  margin-right:0;
}
body:not(.consistency-mode) .muscle-cell{
  display:none;
}
.muscle-icon{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:21px;
  height:21px;
  transition:all 0.2s ease;
  flex-shrink:0;
}
.muscle-svg{
  width:19px;
  height:19px;
  fill:currentColor;
}
.muscle-icon.inactive{
  opacity:0.2;
  color:var(--muted);
}
.muscle-icon.inactive .muscle-svg{
  fill:var(--muted);
}
.muscle-icon.partial{
  opacity:0.6;
  color:var(--muscle-partial);
}
.muscle-icon.partial .muscle-svg{
  fill:var(--muscle-partial);
}
.muscle-icon.complete{
  opacity:1;
  color:var(--color-consistency);
  filter:drop-shadow(0 0 6px var(--color-consistency-shadow));
}
.muscle-icon.complete .muscle-svg{
  fill:var(--color-consistency);
}

/* Daily muscle indicators - smaller and vertically aligned */
.day .date .date-text{
  flex:0 0 auto;
  min-width:90px;
}

/* Muscle checkmarks for daily view */
.muscle-check{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:23px;
  height:23px;
  font-size:20px;
  transition:all 0.2s ease;
  flex-shrink:0;
}
.muscle-check.inactive{
  color:var(--muscle-inactive);
  opacity:0.4;
}
.muscle-check.complete{
  color:var(--color-consistency);
  opacity:1;
  filter:drop-shadow(0 0 3px var(--color-consistency-shadow));
}

/* Inputs */
.inline{display:flex; align-items:center; gap:8px; flex-wrap:nowrap}
.input{flex:0 1 auto; max-width:500px; min-width:280px; display:flex; align-items:center; gap:2px; background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:10px; padding:8px 12px; position:relative}
.input input[type=text]{flex:1; border:none; background:transparent; color:var(--text); font-size:14px; outline:none; min-width:0;}
.input input[type=text]:first-of-type{flex:1.2;} /* Make exercise field a bit wider */
.input input[type=text]:last-of-type{flex:2;} /* Make details field much wider */
.btn{border:1px solid var(--line); background:transparent; padding:8px 12px; border-radius:10px; flex:0 0 auto; white-space:nowrap; cursor:pointer; color:var(--text)}
.btn.primary{background:var(--text); color:var(--bg); border-color:var(--text); font-weight:700}
.btn.secondary-btn{background:transparent; color:var(--text); border:1px solid var(--line); font-weight:600; width:100%; padding:10px}
.btn.secondary-btn:hover{background:rgba(127,127,127,.06)}
.btn.danger-btn{background:var(--danger); color:#fff; border-color:var(--danger); font-weight:600; width:100%; padding:10px}
.btn.danger-btn:hover{background:#dc2626; border-color:#dc2626}
.btn.rest-day{background:var(--color-balance); color:#fff; border-color:var(--color-balance); font-weight:700}

/* Quick weight chips */
.quick{display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; min-height:0;}
.quick:empty{display:none; margin:0;} /* Hide when empty */
.chip{border:1px solid var(--line); background:rgba(127,127,127,.06); padding:6px 10px; border-radius:8px; font-size:12px; cursor:pointer}
.chip:hover{background:rgba(127,127,127,.12); border-color:var(--accent-faint)}

/* Collapsing */
.collapsed{display:none}

/* Insights Page */
.insights{max-width:600px; margin:0 auto; padding:20px 0}
.insight-section{margin:32px 0}
.insight-section h2{font-size:18px; font-weight:700; margin-bottom:16px; color:var(--text)}

/* Streak Bar */
.streak-container{background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:12px; padding:24px; text-align:center; transition:all .3s ease}
.streak-container.momentum-full{
  border-color:var(--color-consistency-shadow);
  background:var(--color-consistency-light);
  box-shadow:0 0 20px var(--color-consistency-shadow);
}
.streak-container.momentum-full .streak-label{
  color:var(--color-consistency);
}
.streak-label{font-size:14px; color:var(--muted); margin-bottom:8px; text-transform:uppercase; letter-spacing:0.5px; font-weight:600}
.streak-bar-bg{width:100%; height:24px; background:rgba(127,127,127,.1); border-radius:12px; overflow:hidden; margin:16px 0}
.streak-bar-fill{height:100%; background:linear-gradient(90deg, var(--color-consistency), var(--color-consistency)); transition:width .3s ease; border-radius:12px}
.streak-text{font-size:13px; color:var(--muted); margin-top:8px}

/* Stats Grid */
.stats-grid{display:grid; grid-template-columns:repeat(4, 1fr); gap:16px; margin:20px 0}
@media (max-width: 768px) {
  .stats-grid{grid-template-columns:repeat(2, 1fr)}
}
.stat-card{background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:12px; padding:20px; text-align:center; transition:all 0.2s ease}
.stat-card:hover{transform:translateY(-2px); box-shadow:0 4px 12px rgba(0,0,0,0.08); border-color:rgba(127,127,127,0.2)}
.stat-value{font-size:32px; font-weight:800; color:var(--text); line-height:1}
.stat-label{font-size:13px; color:var(--muted); margin-top:8px; text-transform:uppercase; letter-spacing:0.5px; font-weight:600}

/* Charts */
.chart{background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:12px; padding:20px}
.chart-bars{display:flex; flex-direction:column; gap:12px}
.chart-row{display:flex; align-items:center; gap:12px}
.chart-label{min-width:80px; font-size:13px; color:var(--muted); font-weight:600}
.chart-bar-bg{flex:1; height:24px; background:rgba(127,127,127,.1); border-radius:6px; overflow:hidden; position:relative}
.chart-bar-fill{height:100%; background:linear-gradient(90deg, var(--color-balance), var(--color-balance)); border-radius:6px; transition:width .3s ease}
.chart-value{min-width:40px; text-align:right; font-size:13px; font-weight:600; color:var(--text)}

/* Keep volume trend green */
.chart-volume .chart-bar-fill{
  background:linear-gradient(90deg, var(--color-consistency), var(--color-consistency));
}

/* Insights Grid (for side-by-side sections) */
.insights-grid{display:grid; grid-template-columns:1fr; gap:20px}
@media (max-width: 768px) {
  .insights-grid{gap:16px}
}
.insight-card{flex:1; min-width:0; background:rgba(127,127,127,.04); border:1px solid var(--line); border-radius:12px; padding:20px; box-shadow:0 1px 3px rgba(0,0,0,0.04)}
.insight-card h2{font-size:16px; font-weight:700; margin-bottom:16px; color:var(--text)}

/* Personal Records with Line Charts */
.pr-charts{display:grid; grid-template-columns:repeat(auto-fit, minmax(280px, 1fr)); gap:20px; max-width:100%}
.pr-chart-card{background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:12px; padding:16px}
.pr-chart-header{display:flex; justify-content:space-between; align-items:baseline; margin-bottom:4px}
.pr-chart-name{font-weight:600; font-size:14px; color:var(--text)}
.pr-chart-current{font-size:20px; font-weight:700; color:var(--color-consistency)}
.pr-chart-dual{display:flex; gap:12px; font-size:14px; font-weight:700}
.pr-chart-left{color:var(--color-balance)}
.pr-chart-right{color:var(--color-consistency)}
.pr-chart-date{font-size:11px; color:var(--muted); margin-bottom:12px}
.pr-line-chart{width:100%; height:80px; display:block}

/* Streak Stats */
.streak-stats{display:grid; grid-template-columns:repeat(auto-fit, minmax(160px, 1fr)); gap:16px}
.streak-stat{background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:12px; padding:20px; text-align:center}
.streak-stat.highlight{border-color:rgba(234, 88, 12, 0.4); background:rgba(234, 88, 12, 0.08)}
.streak-stat-label{font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:0.5px; margin-bottom:8px}
.streak-stat-value{font-size:28px; font-weight:800; color:var(--text); line-height:1; margin-bottom:4px}
.streak-stat-date{font-size:11px; color:var(--muted)}

/* Activity Heatmap */
.heatmap{background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:12px; padding:20px; overflow-x:auto; max-width:fit-content; margin:0 auto}
.heatmap-row{display:flex; gap:8px; margin-bottom:8px; align-items:center}
.heatmap-day-label, .heatmap-week-label{width:60px; font-size:11px; color:var(--muted); font-weight:600; text-align:right; padding-right:8px}
.heatmap-day-name{width:28px; height:28px; font-size:12px; color:var(--muted); display:flex; align-items:center; justify-content:center}
.heatmap-cell{width:28px; height:28px; background:rgba(127,127,127,.1); border-radius:5px; transition:all .2s}
.heatmap-cell.active{background:var(--color-consistency); box-shadow:0 0 4px var(--color-consistency-shadow)}
.heatmap-cell:hover{transform:scale(1.2)}

/* Rest Stats */
.rest-stats{display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:16px}
.rest-stat-item{background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:12px; padding:20px}
.rest-stat-label{font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:0.5px; margin-bottom:8px}
.rest-stat-value{font-size:24px; font-weight:700; color:var(--text)}

/* Body Part Split */
.body-split{display:grid; grid-template-columns:180px 1fr; gap:24px; align-items:center}
.body-diagram{width:180px; margin:0 auto}
.body-diagram svg{width:100%; height:auto; display:block}
.body-part{fill:#e5e7eb; transition:fill .3s ease}
.body-part.chest{fill:var(--muscle-inactive)}
.body-part.shoulders{fill:var(--muscle-inactive)}
.body-part.arms{fill:var(--muscle-inactive)}
.body-part.back{fill:var(--muscle-inactive)}
.body-part.legs{fill:var(--muscle-inactive)}
.body-part.core{fill:var(--muscle-inactive)}
.body-split-legend{display:flex; flex-direction:column; gap:2px}
.split-item{display:inline-flex; align-items:center; gap:6px; padding:1px 0; width:100%}
.split-item.unused{opacity:0.4}
.split-item.unused .split-label{font-weight:400}
.split-color{width:10px; height:10px; border-radius:2px; flex-shrink:0}
.split-label{font-size:13px; font-weight:600; color:var(--text); text-transform:capitalize; white-space:nowrap}
.split-value{font-size:13px; font-weight:700; color:var(--muted); white-space:nowrap}
.split-color.chest{background:#ef4444}
.split-color.shoulders{background:#f97316}
.split-color.arms{background:#eab308}
.split-color.back{background:var(--color-consistency)}
.split-color.legs{background:var(--color-balance)}
.split-color.core{background:#a855f7}
.split-color.cardio{background:#ec4899}
.split-label{flex:1; font-size:14px; font-weight:600; color:var(--text); text-transform:capitalize}
.split-value{font-size:14px; font-weight:700; color:var(--muted)}

/* Color body parts based on data */
body.authenticated .body-part.chest{fill:#ef4444; opacity:0.8}
body.authenticated .body-part.shoulders{fill:#f97316; opacity:0.8}
body.authenticated .body-part.arms{fill:#eab308; opacity:0.8}
body.authenticated .body-part.back{fill:var(--color-consistency); opacity:0.5}
body.authenticated .body-part.legs{fill:var(--color-balance); opacity:0.8}
body.authenticated .body-part.core{fill:#a855f7; opacity:0.8}

/* Action popup for mobile long press */
.action-popup{
  display:flex;
  visibility:hidden;
  position:absolute;
  right:0;
  bottom:100%;
  margin-bottom:4px;
  background:var(--bg);
  border:1px solid var(--line);
  border-radius:10px;
  padding:6px;
  gap:6px;
  box-shadow:0 4px 12px rgba(0,0,0,0.15);
  z-index:100;
  opacity:0;
  transform:scale(0.3) translateY(12px);
  transform-origin:bottom right;
  transition:opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
             transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
             visibility 0s 0.3s;
  pointer-events:none;
}

.action-popup.show{
  visibility:visible;
  opacity:1;
  transform:scale(1) translateY(0);
  transition:opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), 
             transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
             visibility 0s 0s;
  pointer-events:auto;
}

.action-popup-btn{
  width:38px;
  height:38px;
  border-radius:50%;
  border:1px solid var(--line);
  background:var(--bg);
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:all 0.2s;
}

.action-popup-btn:active{
  background:rgba(127,127,127,.1);
  transform:scale(0.95);
}

.action-popup-btn .action-icon{
  font-size:18px;
  color:var(--text);
}

/* Mobile tweaks - ENHANCED */
@media (max-width: 640px){
  body{padding:0 10px 96px}
  
  /* Make consistency toggle same size as desktop on mobile */
  .consistency-toggle{
    width:42px;
    height:42px;
    top:0;
    right:0;
  }
  
  /* Adjust rest warning margin for bigger button on mobile */
  .rest-warning{
    margin-right:50px; /* More space for bigger button */
  }
  
  /* Fix day and list containers on mobile */
  .day{
    margin-left:12px;
    padding-left:8px;
  }
  .list{
    margin:2px 0 8px;
    padding-left:12px;
    min-height:0; /* Critical: prevent height expansion */
  }
  
  /* Fix the add exercise row on mobile */
  .add-exercise-row{
    flex-direction:column;
    align-items:stretch;
    gap:8px;
    margin:4px 0; /* Reduce spacing */
    min-height:0; /* Critical: prevent height expansion */
  }
  .add-exercise-row .input{
    max-width:100%;
    width:100%;
    margin-bottom:0;
    flex:0 0 auto; /* Don't let it flex-grow */
    min-height:44px; /* Reasonable touch target */
    max-height:44px; /* Prevent expansion */
    height:44px; /* Fixed height */
  }
  .add-exercise-row .input input[type=text]{
    height:28px;
    line-height:28px;
  }
  .add-exercise-row .btn.primary{
    width:100%;
    flex:0 0 auto;
    height:44px; /* Match input height */
  }
  
  /* Hide default action buttons on mobile - use long press popup instead */
  .entry .actions{
    display:none !important;
  }
  
  /* Smaller muscle icons on mobile */
  .muscle-icon{
    font-size:12px;
  }
  
  /* Adjust header on very small screens */
  @media (max-width: 380px){
    .brand-motto{display:none}
    .header-title{font-size:12px}
  }
}

/* Auth styles */
.auth-container{display:flex; min-height:70vh; align-items:center; justify-content:center}
.auth-card{width:100%; max-width:420px; background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:14px; padding:24px}
.auth-header{margin-bottom:12px}
.auth-header h1{margin:0 0 6px; font-size:22px}
.auth-header p{margin:0; color:var(--muted); font-size:14px}
.auth-tabs{display:flex; gap:6px; background:rgba(127,127,127,.06); padding:4px; border-radius:10px; margin:10px 0 14px}
.auth-tab{flex:1; border:none; background:transparent; color:var(--muted); padding:8px; border-radius:8px; cursor:pointer; font-weight:600}
.auth-tab.active{background:var(--bg); color:var(--text); border:1px solid var(--line)}
.auth-form .form-group{display:flex; flex-direction:column; gap:6px; margin-bottom:12px}
.auth-form label{font-size:12px; color:var(--muted)}
.auth-form input{border:1px solid var(--line); background:transparent; padding:10px 12px; border-radius:10px; color:var(--text)}
.password-input-wrapper{position:relative; display:flex; align-items:center}
.password-input-wrapper input{flex:1; padding-right:40px}
.password-toggle{position:absolute; right:8px; border:none; background:transparent; padding:4px; cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--muted); border-radius:4px}
.password-toggle:hover{background:rgba(127,127,127,.08); color:var(--text)}
.password-toggle .eye-icon{width:18px; height:18px}
.auth-message{padding:10px 12px; border-radius:10px; font-size:12px; margin-bottom:8px}
.auth-message.success{background:rgba(22,163,74,.12); color:var(--good); border:1px solid rgba(22,163,74,.3)}
.auth-message.error{background:rgba(239,68,68,.12); color:var(--danger); border:1px solid rgba(239,68,68,.3)}
#authButton{width:100%; margin-top:6px}
.auth-links{margin-top:12px; text-align:center}
.auth-links a{color:var(--muted); font-size:13px; text-decoration:none}
.auth-links a:hover{color:var(--text); text-decoration:underline}

/* FAB (floating action buttons) */
.fab{
  position:fixed;
  bottom:20px;
  right:20px;
  width:108px;
  height:108px;
  border-radius:54px;
  border:1px solid var(--line);
  background:var(--bg);
  box-shadow:0 4px 12px rgba(0,0,0,0.15);
  font-size:40px;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition:transform 0.2s;
}
.fab:hover{
  transform:scale(1.1);
}
.fab:first-child{
  right:136px;
}

/* Settings Modal */
.modal{
  display:none;
  position:fixed;
  z-index:1000;
  left:0;
  top:0;
  width:100%;
  height:100%;
  background:rgba(0,0,0,0.6);
  backdrop-filter:blur(4px);
  align-items:center;
  justify-content:center;
}
.modal.show{
  display:flex;
}
.modal-content{
  background:var(--bg);
  border:1px solid var(--line);
  border-radius:16px;
  max-width:480px;
  width:90%;
  max-height:85vh;
  overflow-y:auto;
  box-shadow:0 20px 60px rgba(0,0,0,0.3);
}
.modal-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:24px 28px;
  border-bottom:1px solid var(--line);
}
.modal-header h2{
  margin:0;
  font-size:22px;
  font-weight:700;
  letter-spacing:-0.02em;
}
.close-btn{
  border:none;
  background:transparent;
  font-size:28px;
  line-height:1;
  color:var(--muted);
  cursor:pointer;
  padding:0;
  width:36px;
  height:36px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:8px;
  transition:all 0.2s;
}
.close-btn:hover{
  background:rgba(127,127,127,.1);
  color:var(--text);
}
.modal-body{
  padding:28px;
}
.form-group{
  margin-bottom:28px;
}
.form-group:last-child{
  margin-bottom:0;
}
.section-label{
  display:block;
  font-size:13px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.8px;
  color:var(--muted);
  margin-bottom:12px;
}
.modal-body h3{
  margin:0 0 12px;
  font-size:16px;
  font-weight:700;
}
.settings-desc{
  margin:0 0 16px;
  color:var(--muted);
  font-size:14px;
  line-height:1.5;
}
.checkbox-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(140px, 1fr));
  gap:8px;
}
.checkbox-label{
  display:flex;
  align-items:center;
  gap:10px;
  cursor:pointer;
  padding:12px 14px;
  border-radius:10px;
  border:1px solid var(--line);
  background:rgba(127,127,127,.02);
  transition:all 0.2s;
}
.checkbox-label:hover{
  background:rgba(127,127,127,.08);
  border-color:var(--accent-faint);
}
.checkbox-label input[type="checkbox"]{
  width:20px;
  height:20px;
  min-width:20px;
  min-height:20px;
  flex-shrink:0;
  cursor:pointer;
  appearance:none;
  -webkit-appearance:none;
  border:2px solid var(--line);
  border-radius:4px;
  background:transparent;
  position:relative;
  transition:all 0.2s ease;
}

.checkbox-label input[type="checkbox"]:checked{
  background:var(--text);
  border-color:var(--text);
}

.checkbox-label input[type="checkbox"]:checked::after{
  content:'✓';
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%, -50%);
  color:var(--bg);
  font-size:14px;
  font-weight:bold;
  line-height:1;
}
.checkbox-label span{
  font-size:14px;
  font-weight:500;
}
.muscle-icon-inline {
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}
.muscle-icon-inline svg {
  width: 100%;
  height: 100%;
  display: block;
}
.muscle-icon-inline svg path {
  fill: currentColor;
}
/* Support for stroke-based icons (like cardio) */
.muscle-icon-inline svg path[stroke] {
  stroke: currentColor;
}
.muscle-icon-inline svg path[fill="none"] {
  fill: none !important;
}
.modal-footer{
  padding:20px 28px;
  border-top:1px solid var(--line);
  display:flex;
  justify-content:flex-end;
  gap:12px;
  position:sticky;
  bottom:0;
  background:var(--bg);
  z-index:10;
}

/* Backfill Modal */
.backfill-exercises{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top:12px;
}
.backfill-exercise-row{
  display:flex;
  gap:8px;
  align-items:flex-start;
}
.backfill-exercise-row .input-wrapper{
  position:relative;
}
.backfill-exercise-row input{
  flex:1;
  border:1px solid var(--line);
  background:transparent;
  padding:8px 12px;
  border-radius:8px;
  color:var(--text);
  font-size:14px;
  width:100%;
}
.backfill-exercise-row button{
  padding:6px 10px;
  font-size:16px;
  flex-shrink:0;
}
.backfill-exercise-row .ac{
  position:absolute;
  top:calc(100% + 4px);
  left:0;
  right:0;
  width:auto;
  background:var(--bg);
  border:1px solid var(--line);
  border-radius:8px;
  box-shadow:0 4px 12px rgba(0,0,0,.1);
  max-height:200px;
  overflow:auto;
  display:none;
  z-index:1000;
}

/* Update daily muscle indicators to use dots */
.muscle-indicators-daily{
  display:flex;
  gap:6px;
  flex:0 0 auto;
  align-items:center;
}

/* Force header layout (scoped) */
header.topbar{
  display:flex !important;
  flex-direction:row !important;
  align-items:center !important;
  justify-content:flex-start !important;
  flex-wrap:nowrap !important;
}
header.topbar .brand{
  display:flex !important;
  align-items:center !important;
  gap:10px !important;
  flex:0 1 auto !important;
  min-width:0 !important;
}
header.topbar .user-cta{
  display:flex !important;
  align-items:center !important;
  gap:12px !important;
  margin-left:auto !important;
  flex:0 0 auto !important;
}
header.topbar .header-title,
header.topbar .brand-motto{
  white-space:nowrap !important;
}

/* Optional: allow a neat two-line wrap on very narrow screens */
@media (max-width: 480px){
  header.topbar{flex-wrap:wrap !important; row-gap:6px !important;}
  header.topbar .user-cta{margin-left:auto !important;}
}

/* Autocomplete visibility & stacking fix */
.input{position:relative; overflow:visible;}
.inline{overflow:visible; position:relative;}
.add-exercise-row{position:relative; min-height:0;}

/* the dropdown is absolutely positioned */
.input .ac{
  position:absolute !important;
  top:calc(100% + 6px);
  left:12px;
  width:260px;
  background:var(--bg);
  border:1px solid var(--line);
  border-radius:10px;
  box-shadow:0 8px 20px rgba(0,0,0,.08);
  max-height:220px;
  overflow:auto;
  display:none;
  z-index:1000;
  flex:none;
}

/* Mobile autocomplete fixes */
@media (max-width: 640px){
  .input .ac{
    left:0;
    right:0;
    width:auto;
    max-width:calc(100vw - 40px);
    max-height:180px;
  }
}

.ac-item{
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:10px 12px;
  cursor:pointer;
  border-radius:6px;
  transition:background 0.15s;
}
.ac-item:hover{background:rgba(127,127,127,.08);}

.ac-main{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  width:100%;
}

.ac-name{
  font-weight:500;
  font-size:14px;
  color:var(--text);
}

.ac-meta{
  font-size:11px;
  color:var(--muted);
  line-height:1.4;
}

.ac-badge{
  font-size:10px;
  padding:2px 6px;
  border-radius:4px;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.3px;
  white-space:nowrap;
}

.ac-badge.history{
  background:var(--color-consistency-light);
  color:var(--color-consistency);
}

.ac-badge.beginner{
  background:var(--color-balance-light);
  color:var(--color-balance);
}

.ac-badge.intermediate{
  background:rgba(249, 115, 22, 0.12);
  color:#ea580c;
}

.ac-badge.advanced{
  background:rgba(239, 68, 68, 0.12);
  color:#dc2626;
}

.ac .small{font-size:12px; color:var(--muted);}

/* Mobile autocomplete adjustments */
@media (max-width: 640px){
  .input .ac{
    width:calc(100vw - 40px);
    max-width:320px;
    left:0;
  }
  
  /* Mobile insights adjustments */
  .body-split{
    grid-template-columns:1fr;
    gap:20px;
  }
  
  .body-diagram{
    width:160px;
  }
  
  .heatmap{
    padding:12px;
  }
  
  .heatmap-day-label, .heatmap-week-label{
    width:20px;
    font-size:9px;
  }
  
  .pr-item{
    flex-direction:column;
    align-items:flex-start;
    gap:8px;
  }
  
  .pr-weight{
    margin:0;
  }
}
/* Momentum Bar */
.momentum-section{margin-bottom:32px}
.momentum-bar-container{background:rgba(127,127,127,.06); border:1px solid var(--line); border-radius:16px; padding:24px; box-shadow:0 1px 3px rgba(0,0,0,0.05)}
.momentum-header{margin-bottom:16px; text-align:center}
.momentum-title{font-size:20px; font-weight:700; text-transform:uppercase; letter-spacing:1.5px; color:var(--muted)}
.momentum-bar{height:14px; background:rgba(127,127,127,.1); border-radius:7px; margin-bottom:14px; overflow:visible}
.momentum-fill{height:100%; background:linear-gradient(90deg, var(--color-consistency) 0%, var(--color-consistency) 100%); border-radius:7px; transition:width 0.3s ease, box-shadow 0.3s ease; box-shadow:0 0 4px var(--color-consistency)}
.momentum-fill.max-momentum{box-shadow:0 0 8px var(--color-consistency), 0 0 16px var(--color-consistency) !important; animation:pulse-bar-glow 2s ease-in-out infinite}
@keyframes pulse-bar-glow{0%, 100%{box-shadow:0 0 8px var(--color-consistency), 0 0 16px var(--color-consistency)} 50%{box-shadow:0 0 12px var(--color-consistency), 0 0 24px var(--color-consistency)}}
.momentum-label{font-size:13px; color:var(--muted); text-align:center; font-weight:500}

/* Insights Container */
.insights-container{max-width:1200px; margin:0 auto; padding:20px}

/* PR Muscle Groups */
.pr-muscle-group{margin-bottom:32px}
.pr-muscle-title{font-size:16px; font-weight:700; text-transform:capitalize; color:var(--text); margin-bottom:16px; padding-bottom:8px; border-bottom:2px solid var(--line)}

/* Brand motto styling */
.motto-consistency, .motto-balance, .motto-strength {
  transition: all 0.3s ease;
}

/* When consistency toggle is on, make all motto words bold and add shine */
body.consistency-mode .motto-consistency,
body.consistency-mode .motto-balance,
body.consistency-mode .motto-strength {
  font-weight: 700;
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Typing Animation */
@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink {
  50% { border-color: transparent; }
}

.typing-animation {
  overflow: hidden;
  border-right: 2px solid var(--text);
  white-space: nowrap;
  animation: typing 1.5s steps(20, end), blink 0.75s step-end infinite;
}

.typing-animation.erase {
  animation: typing 0.8s steps(20, end) reverse;
}

.typing-complete {
  border-right: none;
}

/* Select input styling */
.select-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.select-input:hover {
  border-color: var(--primary);
}

.select-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Empty week message */
.empty-week-message {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-style: italic;
  font-size: 14px;
}

/* Empty week styling */
.week.empty-week .row {
  border: 1px dashed var(--line);
  opacity: 0.6;
}

.week.empty-week .week-label {
  font-style: italic;
}

.week.empty-week .row {
  cursor: default;
  pointer-events: none;
}

/* Empty week styling */
.week.empty .week-label {
  font-style: italic;
  color: var(--muted);
}

.week.empty {
  border: 1px dashed var(--line);
  background: rgba(127, 127, 127, 0.02);
}

.week.empty .row {
  cursor: default;
  opacity: 0.6;
}

/* Color picker grid */
.color-picker-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.color-picker-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.color-picker-item label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.color-input {
  width: 80px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  background: var(--bg);
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

/* Legal links in auth form */
.legal-links {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.legal-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.legal-links a:hover {
  color: var(--text);
  text-decoration: underline;
}

.legal-links span {
  margin: 0 8px;
  color: var(--muted);
}

/* App footer */
.app-footer {
  text-align: center;
  padding: 20px;
  margin-top: 40px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.app-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}

.app-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

.app-footer span {
  margin: 0 8px;
}