/* ===== Gym Buddy / workout.aidalee.com ===== */
* { box-sizing: border-box; }
:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-card: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #f97316;
  --accent-dim: #c2410c;
  --green: #2ea043;
  --green-bg: rgba(46, 160, 67, 0.12);
  --yellow: #d29922;
  --yellow-bg: rgba(210, 153, 34, 0.12);
  --red: #f85149;
  --red-bg: rgba(248, 81, 73, 0.12);
  --blue: #58a6ff;
  --blue-bg: rgba(88, 166, 255, 0.12);
  --purple: #bc8cff;
}
html, body { background: var(--bg); color: var(--text); margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px; line-height: 1.5; }
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
h1 .accent { color: var(--accent); }
.subtitle { color: var(--text-dim); font-size: 14px; }
.subtitle b { color: var(--text); }
.stats { display: flex; gap: 18px; flex-wrap: wrap; }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; font-size: 13px; }
.stat b { color: var(--accent); }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; }
.card h2 { margin: 0 0 12px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.card h2 .pill { background: var(--accent); color: #000; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; letter-spacing: 0.04em; }
.card .muted { color: var(--text-dim); font-size: 13px; }

/* Aida's notes — top card */
.notes { display: flex; flex-direction: column; gap: 10px; }
.note { padding: 10px 12px; border-radius: 8px; border-left: 3px solid var(--text-dim); background: var(--bg-elev); font-size: 14px; }
.note.green { border-left-color: var(--green); background: var(--green-bg); }
.note.yellow { border-left-color: var(--yellow); background: var(--yellow-bg); }
.note.red { border-left-color: var(--red); background: var(--red-bg); }
.note.blue { border-left-color: var(--blue); background: var(--blue-bg); }
.note .icon { margin-right: 6px; }
.note-empty { color: var(--text-dim); font-style: italic; }

/* Schedule grid */
.schedule { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 8px; }
.day-col { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; padding: 8px; text-align: center; font-size: 12px; }
.day-col .dow { color: var(--text-dim); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; }
.day-col.work { background: var(--accent-dim); color: #fff; border-color: var(--accent); }
.day-col.work .dow { color: rgba(255,255,255,0.7); }
.day-col.rest { opacity: 0.5; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: var(--bg-elev); }
td input { background: var(--bg-elev); border: 1px solid var(--border); color: var(--text); padding: 5px 7px; border-radius: 4px; width: 70px; font-size: 13px; font-family: inherit; }
td input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
td.exercise { font-weight: 500; }
td.exercise small { display: block; color: var(--text-dim); font-weight: 400; font-size: 11px; margin-top: 2px; }

/* Log cell visual states — empty / draft / saved */
td.log-cell { position: relative; }
td.log-cell input { width: 90px; }
td.log-cell.has-draft input {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.08);
  color: var(--text);
}
td.log-cell.saved input {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--text);
}
td.log-cell .set-badge {
  position: absolute; top: 2px; right: 4px;
  font-size: 10px; color: var(--green); font-weight: 700;
  pointer-events: none;
  background: var(--bg-card); border-radius: 50%;
  width: 14px; height: 14px; display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
td.log-cell.saved input::placeholder { color: var(--text-dim); opacity: 0.5; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tab { background: transparent; border: none; color: var(--text-dim); padding: 8px 14px; font-size: 13px; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-family: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Section nav (quick-jump pills at the top of the page) */
.section-nav {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin: 0 0 18px;
  padding: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: sticky; top: 0; z-index: 40;
}
.nav-pill {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  padding: 6px 12px; border-radius: 16px; font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.nav-pill:hover { color: var(--text); background: var(--bg-card); }
.nav-pill.active { color: var(--accent); border-color: var(--accent); background: rgba(249, 115, 22, 0.08); }

/* Section cards — accordion behavior */
.card.section { margin-bottom: 12px; padding: 0; overflow: hidden; }
.section-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: transparent; border: none; color: var(--text);
  padding: 18px 20px; cursor: pointer; font-family: inherit; text-align: left;
  gap: 12px;
}
.section-toggle h2 { margin: 0; font-size: 18px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.section-summary {
  flex: 1; min-width: 0;
  color: var(--text-dim); font-size: 13px; font-weight: 400;
  text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card.section[open] .section-summary { display: none; }
.section-chevron {
  color: var(--text-dim); font-size: 14px; transition: transform 0.2s;
  flex-shrink: 0; margin-left: 0;
}
.card.section[open] .section-chevron { transform: rotate(0deg); }
.card.section:not([open]) .section-chevron { transform: rotate(-90deg); }
.section-body {
  padding: 0 20px 18px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 0;
}
.card.section:not([open]) .section-body { display: none; }
.card.section[open] .section-toggle { padding-bottom: 14px; }
.card.section[open] .section-toggle h2 { font-size: 18px; }

/* Highlight effect when a section is jumped to via the nav */
.card.section.jump-highlight {
  animation: section-flash 1.2s ease-out;
}
@keyframes section-flash {
  0%   { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.5); }
  40%  { box-shadow: 0 0 0 6px rgba(249, 115, 22, 0.25); }
  100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0); }
}

/* "All" and "Min" pills — separated by a small gap from the section pills */
.nav-pill.expand-all, .nav-pill.collapse-all {
  margin-left: auto;
  color: var(--text-dim);
  border-color: var(--border);
}
.nav-pill.expand-all:hover, .nav-pill.collapse-all:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Trends card — grid of small inline-SVG charts */
.trends-grid {
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
@media (min-width: 800px) {
  .trends-grid { grid-template-columns: 1fr 1fr; }
}
.trend-chart {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}
.trend-chart h3 {
  margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--text);
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
}
.trend-chart .trend-meta { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.trend-chart .trend-empty {
  color: var(--text-dim); font-style: italic; font-size: 12px; padding: 20px 0; text-align: center;
}
.trend-chart svg { width: 100%; height: 120px; display: block; }
.trend-chart svg .axis { stroke: var(--border); stroke-width: 1; }
.trend-chart svg .gridline { stroke: var(--border); stroke-width: 0.5; stroke-dasharray: 2 2; opacity: 0.6; }
.trend-chart svg .label { fill: var(--text-dim); font-size: 9px; font-family: inherit; }
.trend-chart svg .line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.trend-chart svg .point { fill: var(--accent); }
.trend-chart svg .bar { fill: var(--accent); opacity: 0.8; }
.trend-chart svg .trend-up { stroke: var(--green); stroke-width: 1.5; fill: none; }
.trend-chart svg .trend-down { stroke: var(--red); stroke-width: 1.5; fill: none; }

/* Stats card */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 18px;
}
@media (min-width: 800px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-tile {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-tile .stat-value {
  font-size: 24px; font-weight: 700; color: var(--accent); line-height: 1.1;
}
.stat-tile .stat-label {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em;
}
.stat-tile .stat-sub {
  font-size: 11px; color: var(--text-dim); margin-top: 2px;
}
.stats-prs h3 { margin: 0 0 8px; font-size: 14px; color: var(--text); }
.pr-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: baseline;
  padding: 8px 12px; background: var(--bg-elev); border-radius: 6px;
  margin-bottom: 4px; font-size: 13px;
}
.pr-row .pr-ex { color: var(--text); }
.pr-row .pr-best { color: var(--accent); font-weight: 600; font-family: ui-monospace, monospace; }
.pr-row .pr-e1rm { color: var(--text-dim); font-size: 11px; font-family: ui-monospace, monospace; }

/* Buttons */
button.primary { background: var(--accent); color: #000; border: none; padding: 9px 18px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
button.primary:hover { background: #fb923c; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: var(--bg-elev); color: var(--text); border: 1px solid var(--border); padding: 7px 14px; border-radius: 6px; font-size: 13px; cursor: pointer; font-family: inherit; }
button.secondary:hover { border-color: var(--accent); }

/* Forms */
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.form-row label { color: var(--text-dim); font-size: 13px; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 7px 10px; border-radius: 5px; font-size: 14px; font-family: inherit; }
input[type="date"] { color-scheme: dark; }
textarea { width: 100%; min-height: 60px; resize: vertical; }

/* Plan pills (Cardio / Abs suggested workouts) */
.plan-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.plan-pills-label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.plan-pill {
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--text);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-family: inherit;
  cursor: pointer; transition: all 0.15s ease;
}
.plan-pill:hover { border-color: var(--accent); color: var(--accent); }
.plan-pill.active { background: var(--accent); color: var(--bg); border-color: var(--accent); font-weight: 600; }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--green); color: #fff; padding: 12px 20px; border-radius: 6px; font-weight: 600; box-shadow: 0 4px 16px rgba(0,0,0,0.4); opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 100; }
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }

/* Draft indicator */
.draft-status { color: var(--green); font-size: 12px; font-weight: 600; opacity: 0; transition: opacity 0.2s; }
.draft-status.visible { opacity: 1; }

/* Warm-up / cool-down exercises */
.exercise-list { display: grid; gap: 8px; }
.exercise-item { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.exercise-item .name { font-weight: 600; margin-bottom: 2px; }
.exercise-item .desc { color: var(--text-dim); font-size: 13px; }
.exercise-item .duration { color: var(--accent); font-size: 12px; font-weight: 600; margin-left: 6px; }

/* Progress card */
.history-row { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.history-row:last-child { border-bottom: none; }
.history-row .label { color: var(--text-dim); font-size: 13px; }
.history-row .data { font-family: ui-monospace, 'SF Mono', Monaco, monospace; font-size: 12px; }
.history-row .data .date { color: var(--purple); }
.history-row .data .weight { color: var(--accent); font-weight: 600; }

/* Body weight */
.bw-row { display: flex; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.bw-row:last-child { border-bottom: none; }
.bw-row .date { color: var(--text-dim); width: 100px; }
.bw-row .wt { font-weight: 600; color: var(--accent); width: 70px; }
.bw-row .note { color: var(--text-dim); flex: 1; }

/* Cardio / abs log */
.log-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.log-item { display: flex; gap: 10px; align-items: baseline; padding: 6px 10px; background: var(--bg-elev); border-radius: 4px; font-size: 13px; }
.log-item .date { color: var(--text-dim); width: 90px; }
.log-item .name { flex: 1; }
.log-item .meta { color: var(--accent); font-weight: 600; }

/* Saved Sessions — expandable rows */
#saved-sessions { display: flex; flex-direction: column; gap: 6px; }
.session-row { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.session-row summary {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  cursor: pointer; list-style: none; font-size: 14px; user-select: none;
}
.session-row summary::-webkit-details-marker { display: none; }
.session-row summary::before {
  content: "▶"; color: var(--text-dim); font-size: 10px; width: 12px; flex-shrink: 0;
  transition: transform 0.15s;
}
.session-row[open] summary::before { transform: rotate(90deg); }
.session-row summary:hover { background: var(--bg-card); }
.session-date { color: var(--purple); font-weight: 600; min-width: 70px; }
.session-day { color: var(--accent); font-weight: 600; }
.session-meta { color: var(--text-dim); font-size: 12px; margin-left: auto; }
.session-body { padding: 0 14px 14px 38px; display: flex; flex-direction: column; gap: 10px; }
.session-ex { display: grid; grid-template-columns: 200px 1fr; gap: 12px; align-items: baseline; }
.session-ex .ex-name { color: var(--text); font-size: 14px; }
.session-ex .ex-sets { font-family: ui-monospace, 'SF Mono', Monaco, monospace; font-size: 13px; color: var(--text-dim); }
.session-ex .ex-sets b { color: var(--text); font-weight: 600; }
.session-notes { color: var(--text-dim); font-size: 12px; font-style: italic; padding-top: 4px; border-top: 1px solid var(--border); }
@media (max-width: 700px) {
  .session-row summary { flex-wrap: wrap; }
  .session-meta { margin-left: 0; width: 100%; }
  .session-body { padding-left: 14px; }
  .session-ex { grid-template-columns: 1fr; gap: 2px; }
}

/* Mobile */
@media (max-width: 700px) {
  .container { padding: 16px 12px 100px; }
  .schedule { grid-template-columns: repeat(7, 1fr); font-size: 10px; }
  h1 { font-size: 22px; }
  .stat { font-size: 11px; padding: 4px 8px; }

  /* Log table — show 2 columns (Sets 1-3 and Sets 4-6) and let user scroll horizontally.
     Bigger inputs so thumbs can hit them. */
  #log-table { font-size: 14px; }
  #log-table th { font-size: 10px; padding: 6px 4px; }
  #log-table td { padding: 8px 4px; }
  #log-table td.exercise { font-size: 13px; }
  td.log-cell input { width: 64px; padding: 8px 6px; font-size: 15px; }
  td.log-cell .set-badge { width: 16px; height: 16px; font-size: 11px; }

  /* Cards: tighter padding on phones */
  .card { padding: 14px 14px; }
  .card h2 { font-size: 16px; }

  /* Saved Sessions — stack exercise + sets vertically on phones */
  .session-row summary { flex-wrap: wrap; }
  .session-meta { margin-left: 0; width: 100%; }
  .session-body { padding-left: 14px; }
  .session-ex { grid-template-columns: 1fr; gap: 2px; }

  /* Sticky Save bar at the bottom of the screen — always visible while scrolling */
  .log-actions { display: none; } /* hide the in-flow save bar on mobile */
  .log-actions-sticky {
    display: flex !important;
    position: fixed; left: 0; right: 0; bottom: 0;
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 50;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    align-items: center; gap: 10px;
  }
  .log-actions-sticky .primary { flex: 1; padding: 14px 18px; font-size: 16px; }
  .log-actions-sticky .secondary { padding: 14px 14px; }
  .log-actions-sticky .draft-status { font-size: 11px; flex-basis: 100%; text-align: center; }

  /* Tighter form rows on mobile */
  .form-row { gap: 8px; }
  .form-row input[type="text"], .form-row input[type="number"], .form-row input[type="date"] {
    font-size: 16px; /* iOS won't auto-zoom if font is >= 16px */
  }

  /* Toast higher to clear the sticky bar */
  .toast { bottom: 90px; }
}

/* Hide sticky bar on desktop; show in-flow bar */
.log-actions-sticky { display: none; }
@media (min-width: 701px) {
  .log-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
}
