/* ============================================================
   styles.css — StrengthView PWA, ported from the Mac app's
   CUSTOM_CSS verbatim where possible. Cyan/violet palette,
   Inter font, dark base. Mobile-first.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-0: #08080c;
  --bg-1: #111116;
  --bg-2: #17171e;
  --bg-elev: #1c1c25;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.14);
  --text: #f5f5f7;
  --text-2: rgba(245,245,247,0.72);
  --muted: rgba(245,245,247,0.48);
  --accent: #06b6d4;         /* cyan */
  --accent-2: #8b5cf6;       /* violet */
  --green: #34d399;
  --yellow: #fbbf24;
  --red: #f87171;
  --shadow: 0 4px 16px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

html, body {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  background:
    radial-gradient(1400px 700px at 0% -20%, rgba(6,182,212,0.06) 0%, transparent 55%),
    radial-gradient(1200px 600px at 100% 0%, rgba(139,92,246,0.07) 0%, transparent 55%),
    var(--bg-0);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 16px 60px;
}

/* ---------- Typography ---------- */

h1, h2, h3, h4 {
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.025em;
  font-weight: 700;
  color: var(--text);
}
h2 {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 1.8rem 0 0.4rem;
}

.section-sub {
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.35;
  margin: 0 0 14px 0;
}

/* ---------- App header ---------- */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 8px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem;
  color: #0a0a0f;
  box-shadow: 0 4px 14px rgba(139,92,246,0.25);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text);
}
.brand-tag {
  font-size: 0.72rem; font-weight: 500;
  color: var(--muted); letter-spacing: 0.04em;
  text-transform: uppercase; margin-top: 2px;
}
.live-status {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 0.78rem; font-weight: 500;
}
.live-status b { color: var(--text-2); font-weight: 600; }
.pulse-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 10px var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.refresh-btn {
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--text-2); width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s, border-color .15s;
}
.refresh-btn:hover, .refresh-btn:active {
  color: var(--accent); background: rgba(6,182,212,0.08);
  border-color: rgba(6,182,212,0.4);
}
.refresh-btn.spinning svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 4-tile hero bar ---------- */

.hero-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 6px 0 4px;
}
@media (max-width: 900px) { .hero-bar { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .hero-bar { grid-template-columns: 1fr; } }

.hero-tile {
  background: linear-gradient(145deg, var(--bg-1) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
  min-height: 132px;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.hero-tile.ready   { border-color: rgba(52,211,153,0.35); }
.hero-tile.caution { border-color: rgba(251,191,36,0.35); }
.hero-tile.alert   { border-color: rgba(248,113,113,0.40); }

.hero-tile .ht-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 600;
  color: var(--muted); letter-spacing: 0.04em;
  text-transform: uppercase; margin-bottom: 10px;
}
.hero-tile .ht-head .dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.hero-tile.ready   .ht-head .dot { background: var(--green);  box-shadow: 0 0 8px var(--green); }
.hero-tile.caution .ht-head .dot { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.hero-tile.alert   .ht-head .dot { background: var(--red);    box-shadow: 0 0 8px var(--red); }
.hero-tile.neutral .ht-head .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.hero-tile .ht-big {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.hero-tile .ht-big .unit {
  font-size: 0.82rem; font-weight: 500;
  color: var(--text-2); margin-left: 3px;
}
.hero-tile .ht-sub {
  color: var(--text-2);
  font-size: 0.78rem;
  margin-top: auto;
  padding-top: 8px;
  line-height: 1.4;
}

/* ---------- Weekly recap (muscle grid) ---------- */

.muscle-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
@media (max-width: 900px) { .muscle-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .muscle-grid { grid-template-columns: repeat(2, 1fr); } }

.muscle-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  overflow: hidden;
  min-height: 90px;
}
.muscle-card .ml-label {
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
}
.muscle-card .ml-value {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.muscle-card .ml-value .unit {
  font-size: 0.78rem; color: var(--muted);
  margin-left: 4px; font-weight: 500;
}
.muscle-card .ml-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
}
.muscle-card .led {
  width: 8px; height: 8px; border-radius: 50%;
}
.muscle-card.g { box-shadow: inset 3px 0 0 var(--green); }
.muscle-card.y { box-shadow: inset 3px 0 0 var(--yellow); }
.muscle-card.r { box-shadow: inset 3px 0 0 var(--red); }
.led-g { background: var(--green);  box-shadow: 0 0 8px rgba(52,211,153,0.5); }
.led-y { background: var(--yellow); box-shadow: 0 0 8px rgba(251,191,36,0.5); }
.led-r { background: var(--red);    box-shadow: 0 0 8px rgba(248,113,113,0.5); }

/* ---------- Last week's compact row (read-only reference) ---------- */

.lw-header {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 1.4rem 0 8px 0;
}
.day-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
@media (max-width: 700px) {
  .day-strip { grid-template-columns: repeat(7, 1fr); gap: 4px; }
}

.last-week-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 8px 8px 12px;
  position: relative;
  overflow: hidden;
  min-height: 52px;
  opacity: 0.72;
}
.last-week-card::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--muted);
}
.last-week-card .lw-day {
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.3;
}
.last-week-card .lw-plan {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-2);
  margin-top: 2px;
  line-height: 1.2;
}
.last-week-card.push::before    { background: var(--red); }
.last-week-card.pull::before    { background: var(--accent); }
.last-week-card.legs::before    { background: var(--accent-2); }
.last-week-card.upper::before   { background: var(--yellow); }
.last-week-card.sprints::before { background: var(--green); }
.last-week-card.rest::before    { background: var(--muted); }

/* ---------- This week's split (taller, TODAY highlight) ---------- */

.day-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 10px 12px 16px;
  position: relative;
  min-height: 78px;
  overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
}
.day-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--muted);
}
.day-card.push::before     { background: var(--red); }
.day-card.pull::before     { background: var(--accent); }
.day-card.legs::before     { background: var(--accent-2); }
.day-card.upper::before    { background: var(--yellow); }
.day-card.sprints::before  { background: var(--green); }
.day-card.recovery::before { background: #5eead4; }
.day-card.rest::before     { background: var(--muted); }

.day-card .day-lbl {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
  line-height: 1.3;
}
.day-card .plan-lbl {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-top: 6px;
  line-height: 1.2;
}
.day-card.rest { opacity: 0.62; }

.day-card.today {
  background: linear-gradient(180deg, rgba(6,182,212,0.09), rgba(6,182,212,0.02));
  border-color: rgba(6,182,212,0.30);
}
.day-card.today .day-lbl {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.22em;
}

@media (max-width: 520px) {
  .day-card { padding: 10px 6px 10px 12px; min-height: 64px; }
  .day-card .day-lbl { font-size: 0.55rem; letter-spacing: 0.14em; }
  .day-card .plan-lbl { font-size: 0.78rem; }
  .last-week-card { padding: 6px 6px 6px 10px; min-height: 44px; }
  .last-week-card .lw-plan { font-size: 0.7rem; }
}

/* ---------- Section header w/ reset link (Mac parity) ---------- */

.wk-split-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin: 1.8rem 0 0.3rem 0;
  gap: 16px;
}
.wk-split-header .wk-split-title { flex: 1; min-width: 0; }
.wk-split-header .wk-split-title h2 { margin: 0 0 4px; }
.wk-split-header .reset-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.01em;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 10px;
  font-family: 'Inter', sans-serif;
  transition: border-color 120ms, color 120ms, background 120ms;
}
.wk-split-header .reset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(6,182,212,0.06);
}
.wk-split-header .reset-btn:active { transform: translateY(1px); }

/* ---------- Day-card select (Mac parity) ---------- */
/* The <select> is the bottom half of the day card — it inherits the stripe
   color from the parent's .day-card.<class>. Tapping it on iOS opens the
   native picker. */

.day-card .day-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent
              url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'><path d='M1 1l4 4 4-4' stroke='rgba(245,245,247,0.48)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>")
              no-repeat right 4px center;
  border: 0;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 4px 14px 4px 0;
  margin-top: 6px;
  width: 100%;
  cursor: pointer;
  line-height: 1.2;
  outline: none;
}
.day-card .day-select:focus {
  outline: none;
}
.day-card .day-select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background-image: none;
  padding-right: 0;
}
.day-card .day-select option {
  background: var(--bg-1);
  color: var(--text);
}
/* Hide the plain text when select is rendered */
.day-card.has-select .plan-lbl { display: none; }

/* ---------- Alert banner (CNS conflict) ---------- */

.alert {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 18px;
  border-radius: 14px;
  font-weight: 500;
  font-size: 0.93rem;
  margin: 4px 0 16px;
}
.alert-red {
  background: linear-gradient(90deg, rgba(248,113,113,0.14), rgba(248,113,113,0.02));
  border: 1px solid rgba(248,113,113,0.35);
  color: var(--text);
}
.alert-red .alert-title {
  font-weight: 700; color: var(--red);
  letter-spacing: -0.01em; display: block; margin-bottom: 2px;
}
.alert-icon { font-size: 1.2rem; line-height: 1.3; }

/* ---------- Tonnage chart ---------- */

.chart-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 16px 12px;
  margin-top: 6px;
}
.chart-wrap { position: relative; height: 200px; }
@media (min-width: 720px) { .chart-wrap { height: 240px; } }

/* ---------- Split audit ---------- */

.split-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 6px;
}
.split-row .lbl {
  font-size: 0.92rem; color: var(--text); font-weight: 500;
  display: inline-flex; align-items: center; gap: 10px;
}
.split-row .lbl .led { width: 8px; height: 8px; border-radius: 50%; }
.split-row .count {
  font-size: 0.78rem; color: var(--text-2);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

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

.coach-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 700px) { .coach-grid { grid-template-columns: 1fr; } }

.coach-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  transition: border-color 0.2s;
}
.coach-card:hover { border-color: var(--line-strong); }
.coach-card.sev-red    { border-left: 3px solid var(--red); }
.coach-card.sev-yellow { border-left: 3px solid var(--yellow); }
.coach-card.sev-green  { border-left: 3px solid var(--green); }
.coach-card .tag {
  display: inline-block;
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  background: rgba(255,255,255,0.05);
  padding: 3px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
}
.coach-card .text {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.55;
  font-weight: 400;
}

/* ---------- Loading / error ---------- */

.loading, .error {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-2);
}
.loading .ring {
  width: 34px; height: 34px; margin: 0 auto 18px;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.error h2 { color: var(--text); font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.error p  { font-size: 13px; margin: 0; color: var(--muted); }

/* ---------- Footer ---------- */

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

/* Two-column layout for big charts row on desktop */
.row-2col {
  display: grid; gap: 14px;
  grid-template-columns: 1.4fr 1fr;
}
@media (max-width: 900px) { .row-2col { grid-template-columns: 1fr; } }
