:root{
  --ink:#1f2937; --mut:#6b7280; --sky:#4da3ff; --bg:#f6f7fb; --card:#fff; --ok:#10b981; --bar:#0f172a;
}
*{box-sizing:border-box}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;background:var(--bg);color:var(--ink)}
.topbar{position:sticky;top:0;z-index:10;background:var(--sky);color:#fff;text-align:center;padding:14px}
.topbar h1{margin:0}
.muted{color:var(--mut)}
.container{max-width:1000px;margin:0 auto;padding:14px}

.tabs{display:flex;gap:6px;background:var(--bar);padding:6px;position:sticky;top:56px;z-index:9}
.tabs button{flex:1;border:0;border-radius:10px;padding:10px;font-weight:700;color:#fff;background:#1f2937;cursor:pointer}
.tabs button.active{background:#374151}

.section{display:none}.section.active{display:block}
.card{background:var(--card);border-radius:12px;padding:14px;box-shadow:0 2px 10px rgba(0,0,0,.06);margin-bottom:14px}

details>summary{cursor:pointer;font-weight:800;padding:10px 12px;border-radius:10px;background:#f9fbff;border:1px solid #e5e7eb}
details[open]>summary{background:#eef6ff}
.acc-body{padding:10px 12px;border:1px solid #e5e7eb;border-top:0;border-radius:0 0 10px 10px}

.ex-list{display:flex;flex-direction:column;gap:8px}
.ex-item{display:flex;justify-content:space-between;align-items:center;background:#fff;border:1px solid #e5e7eb;border-radius:10px;padding:10px;cursor:pointer}
.ex-item .name{font-weight:700}
.ex-item.open{outline:2px solid #e5e7eb}
.ex-details{display:none;background:#ffffff;border:1px solid #e5e7eb;border-radius:10px;padding:12px;margin:-6px 0 10px}
.media{display:flex;gap:10px;flex-wrap:wrap;align-items:flex-start}
.gif{width:240px;max-width:100%;height:auto;border-radius:10px;border:1px solid #e5e7eb;background:#fff}
.notes{flex:1 1 240px}
.btn{border:0;border-radius:10px;padding:10px 14px;font-weight:700;cursor:pointer}
.btn.small{padding:6px 10px;font-size:13px}
.btn.save{background:var(--ok);color:#fff}
textarea{width:100%;padding:10px;border:1px solid #e5e7eb;border-radius:10px;background:#fff}

/* ===== CALENDAR (compact + expand on tap) ===== */
.calendar-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:6px;grid-auto-rows:74px}
.calendar-head{display:grid;grid-template-columns:repeat(7,1fr);gap:6px;margin-bottom:6px}
.calendar-dow{background:#f3f6ff;font-weight:700;text-align:center;border:1px solid #e5e7eb;border-radius:10px;padding:8px}
.calendar-cell{
  position:relative;background:#fff;border:1px solid #e5e7eb;border-radius:12px;
  padding:8px;height:74px;overflow:hidden;transition:height .18s ease;
}
.calendar-cell.today{outline:2px solid #4da3ff}
.cell-date{font-weight:700;font-size:12px;color:#334155}
.cell-dot{position:absolute;right:8px;bottom:8px;width:10px;height:10px;border-radius:50%;background:#e5e7eb}

/* abbreviation (compact) */
.cell-abbrev{font-weight:600;font-size:11px;padding:2px 4px;border-radius:4px;margin-top:4px;display:inline-block}

/* full label (hidden until open) */
.cell-tag{display:none;margin-top:6px;padding:4px 8px;border-radius:10px;font-size:12px}

/* actions hidden in compact mode */
.calendar-cell .cell-actions{display:none}

/* expanded state */
.calendar-cell.open{height:auto}
.calendar-cell.open .cell-tag{display:inline-block}
.calendar-cell.open .cell-actions{display:flex;gap:8px;margin-top:8px}

/* color coding */
.dot-push{background:#2563eb}
.dot-pull{background:#059669}
.dot-legs{background:#b45309}
.dot-full{background:#7c3aed}
.dot-rest{background:#9ca3af}

.cell-tag.tag-push{background:#e8f1ff;color:#1e3a8a}
.cell-tag.tag-pull{background:#e9fbf2;color:#065f46}
.cell-tag.tag-legs{background:#fff3e6;color:#92400e}
.cell-tag.tag-full{background:#f5f3ff;color:#5b21b6}
.cell-tag.tag-rest{background:#f3f4f6;color:#6b7280}

/* Inline editor inside an open calendar cell */
.cell-form{margin-top:8px;background:#fafbff;border:1px solid #e5e7eb;border-radius:10px;padding:8px}
.cell-row{display:flex;gap:8px;flex-wrap:wrap}
.cell-row > div{flex:1 1 140px}
.cell-form select{width:100%;padding:8px;border:1px solid #e5e7eb;border-radius:8px;background:#fff}
.cell-form .actions{display:flex;gap:8px;justify-content:flex-end;margin-top:8px}

/* ===== PHASE (session → muscles → exercises) ===== */
.session-card{background:#fff;border:1px solid #e5e7eb;border-radius:12px;margin:10px 0;overflow:hidden}
.session-head{display:flex;align-items:center;gap:8px;padding:12px 14px;cursor:pointer;background:#f9fbff}
.session-head .date{font-weight:800}
.session-head .type{padding:2px 8px;border-radius:999px;font-size:12px;background:#eef2ff;color:#334155}
.session-body{padding:10px 14px;border-top:1px solid #e5e7eb}

.muscle-list{display:flex;flex-direction:column;gap:8px}
.muscle-item{background:#fff;border:1px solid #e5e7eb;border-radius:10px}
.muscle-title{padding:10px 12px;display:flex;justify-content:space-between;cursor:pointer;font-weight:700}
.muscle-body{display:none;padding:10px 12px;border-top:1px solid #e5e7eb}

.workout{background:#fff;border:1px solid #eef0f4;border-radius:10px;margin:8px 0}
.workout-title{padding:8px 10px;display:flex;justify-content:space-between;cursor:pointer}
.workout-body{display:none;padding:10px;border-top:1px solid #eef0f4}
.workout-body .muted{font-size:13px}
.workout-body .gif{width:240px;max-width:100%;border:1px solid #e5e7eb;border-radius:10px;margin:8px 0;background:#fff}

.session-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:6px}
.chip{display:inline-block;padding:2px 8px;border-radius:999px;font-size:12px;background:#f3f4f6;color:#374151}

/* tiny type-colored chips (reuse your tag colors) */
.chip.push{background:#e8f1ff;color:#1e3a8a}
.chip.pull{background:#e9fbf2;color:#065f46}
.chip.legs{background:#fff3e6;color:#92400e}
.chip.full{background:#f5f3ff;color:#5b21b6}

/* --- Expand/retract & centered abbrev --- */
.calendar-cell{
  position:relative;
  transition:height .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.calendar-cell.compact{height:74px; overflow:hidden;}
.calendar-cell.open{height:auto;}

/* Clickable date corner */
.cell-date{font-weight:700;font-size:12px;color:#334155;cursor:pointer}

/* Big centered abbreviation when compact */
.cell-center{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%);
  font-weight:800; font-size:18px; opacity:.9; pointer-events:none;
}
.calendar-cell.open .cell-center{display:none;} /* hide when expanded */

/* Hide the small tag in compact mode to keep it clean */
.calendar-cell:not(.open) .cell-tag{display:none;}
.calendar-cell.open .cell-actions{display:flex;gap:8px;margin-top:8px}

/* Full-cell color coding (backgrounds) */
.bg-push{ background:#e8f1ff; border-color:#c7dbff; }
.bg-pull{ background:#e9fbf2; border-color:#c6f0db; }
.bg-legs{ background:#fff3e6; border-color:#ffd7b3; }
.bg-full{ background:#f5f3ff; border-color:#e0d7ff; }
.bg-rest{ background:#f3f4f6; border-color:#e5e7eb; }

/* Make the dot subtle when the cell is color-coded */
.calendar-cell[class*="bg-"] .cell-dot{background:rgba(0,0,0,.12)}