/* ── Shared tokens ── */
:root {
  --purple: #6b2fb0;
  --purple-deep: #4a1f7d;
  --purple-bright: #8b4dd9;
  --green: #6dbb6d;
  --green-bg: rgba(109,187,109,0.15);
  --red: #c75858;
  --red-bg: rgba(199,88,88,0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Night theme (default) ── */
body, body.theme-night {
  --bg: #0d0518;
  --bg-deep: #08030f;
  --surface: #1a0d2e;
  --surface-2: #261541;
  --surface-3: #311a55;
  --border: rgba(212,175,55,0.12);
  --border-strong: rgba(212,175,55,0.28);
  --border-bright: rgba(212,175,55,0.55);
  --text: #f5ecd7;
  --text-muted: #b3a98d;
  --text-dim: #7d7560;
  --gold: #d4af37;
  --gold-bright: #f0c958;
  --gold-deep: #a8861f;
  --gold-bg: rgba(212,175,55,0.12);
  --grad-1: rgba(107,47,176,0.15);
  --grad-2: rgba(212,175,55,0.04);
}

/* ── Day theme ── */
body.theme-day {
  --bg: #ffffff;
  --bg-deep: #f4f0fa;
  --surface: #faf8ff;
  --surface-2: #ede8f8;
  --surface-3: #e0d8f2;
  --border: rgba(107,47,176,0.14);
  --border-strong: rgba(107,47,176,0.3);
  --border-bright: rgba(107,47,176,0.55);
  --text: #1a0d2e;
  --text-muted: #5a4a7a;
  --text-dim: #9a88b8;
  --gold: #a0700a;
  --gold-bright: #c08a14;
  --gold-deep: #7a5008;
  --gold-bg: rgba(160,112,10,0.1);
  --grad-1: rgba(107,47,176,0.06);
  --grad-2: rgba(160,112,10,0.03);
  --purple: #5a22a0;
  --purple-deep: #3d1570;
  --purple-bright: #7a3dc8;
  --green: #1e7e34;
  --green-bg: rgba(30,126,52,0.12);
  --red: #b02020;
  --red-bg: rgba(176,32,32,0.1);
}

/* ── Base ── */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at top, var(--grad-1) 0%, transparent 50%),
    radial-gradient(ellipse at bottom, var(--grad-2) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;
  font-size: 16px; line-height: 1.5;
  overscroll-behavior: none; -webkit-font-smoothing: antialiased;
  padding: calc(var(--safe-top) + 1rem) 1rem calc(var(--safe-bottom) + 1.5rem);
  min-height: 100vh; min-height: 100dvh;
  transition: background 0.5s ease, color 0.3s ease;
}
.screen { display: none; max-width: 480px; margin: 0 auto; }
.screen.active { display: block; }

/* ── Typography ── */
.app-brand { font-size: 11px; letter-spacing: 0.25em; font-weight: 600; color: var(--gold); margin-bottom: 1.5rem; text-transform: uppercase; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gold-deep); font-weight: 500; margin-bottom: 6px; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.section-label { font-size: 11px; font-weight: 600; color: var(--gold-deep); margin-bottom: 10px; margin-top: 0.5rem; text-transform: uppercase; letter-spacing: 0.15em; }

/* ── Auth screen ── */
.auth-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(100vh - 2rem); min-height: calc(100dvh - 2rem);
  padding-top: 0; text-align: center;
}
.auth-tagline { font-size: 13px; color: var(--text-dim); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 2.5rem; }
.auth-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 24px 20px; width: 100%; max-width: 360px; text-align: left; }
.auth-field { margin-bottom: 14px; }
.auth-input {
  width: 100%; padding: 11px 14px; border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--bg-deep); color: var(--text);
  font-size: 15px; font-family: inherit; -webkit-appearance: none; appearance: none;
  transition: border-color 0.15s;
}
.auth-input:focus { outline: none; border-color: var(--gold); }
.auth-error { font-size: 13px; color: var(--red); margin-bottom: 10px; min-height: 18px; }

/* ── Sync indicator ── */
.sync-indicator { font-size: 11px; color: var(--text-dim); margin-top: 8px; letter-spacing: 0.05em; }
.sync-indicator.online::before { content: "●"; color: var(--green); margin-right: 6px; }
.sync-indicator.offline::before { content: "●"; color: var(--text-dim); margin-right: 6px; }
.sync-indicator.syncing::before { content: "●"; color: var(--gold); margin-right: 6px; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:.4} 50%{opacity:1} }

/* ── Home header ── */
.home-header { margin-bottom: 2rem; padding-top: 0.5rem; }
.home-header h1 {
  font-size: 38px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(135deg, var(--text) 0%, var(--gold) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.home-header .muted { font-size: 14px; }

/* ── Stats grid ── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1.75rem; }
.stat-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; transition: background 0.3s, border-color 0.3s; }
.stat-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; color: var(--gold); }

/* ── Week schedule ── */
.day-row { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; transition: background 0.3s, border-color 0.3s; }
.day-row.today { border-color: var(--border-bright); background: var(--surface-2); }
.day-row-left { display: flex; align-items: center; gap: 12px; }
.day-name { font-size: 14px; color: var(--text); }
.day-name.today { font-weight: 500; color: var(--gold-bright); }
.day-meta { font-size: 12px; color: var(--text-dim); }

/* ── Pills ── */
.pill { font-size: 10px; font-weight: 600; padding: 3px 10px; border-radius: 20px; letter-spacing: 0.08em; text-transform: uppercase; }
.pill-today { background: var(--gold); color: var(--bg); }
.pill-rest { background: transparent; color: var(--text-dim); border: 0.5px solid var(--border); }
.pill-lift { background: var(--gold-bg); color: var(--gold); border: 0.5px solid var(--border); }
.pill-pr { background: var(--gold); color: var(--bg); }
.pill-done { background: var(--green-bg); color: var(--green); border: 0.5px solid rgba(109,187,109,0.3); }

/* ── Logged banner ── */
.logged-banner { display: flex; align-items: center; justify-content: space-between; background: var(--green-bg); border: 0.5px solid rgba(109,187,109,0.35); border-radius: var(--radius); padding: 12px 14px; margin-top: 10px; }
.logged-banner-title { font-size: 14px; font-weight: 500; color: var(--green); }
.logged-banner-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.btn-delete-session { background: transparent; border: 0.5px solid var(--red); border-radius: var(--radius-sm); color: var(--red); font-size: 12px; font-weight: 500; padding: 6px 12px; cursor: pointer; font-family: inherit; flex-shrink: 0; transition: background 0.15s; }
.btn-delete-session:active { background: var(--red-bg); }
.btn-edit-session { background: transparent; border: 0.5px solid var(--border-strong); border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12px; font-weight: 500; padding: 6px 12px; cursor: pointer; font-family: inherit; flex-shrink: 0; transition: border-color 0.15s, color 0.15s; }
.btn-edit-session:active { color: var(--gold); border-color: var(--gold); }

/* ── Buttons ── */
.btn { display: block; width: 100%; padding: 14px; border: 0.5px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 15px; font-weight: 500; font-family: inherit; cursor: pointer; margin-top: 10px; transition: opacity 0.15s, transform 0.1s, background 0.3s; letter-spacing: 0.01em; }
.btn:active { transform: scale(0.98); opacity: 0.8; }
.btn-primary { background: linear-gradient(135deg, var(--purple) 0%, var(--purple-deep) 100%); color: var(--gold-bright); border: 0.5px solid var(--gold); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; font-size: 14px; }
.btn-ghost { border: none; color: var(--text-muted); font-size: 13px; padding: 10px; background: transparent; }
.btn-danger { border-color: var(--red); color: var(--red); background: var(--surface); }
.btn-back { background: none; border: none; color: var(--gold); font-size: 15px; cursor: pointer; padding: 4px 8px 4px 0; font-family: inherit; }

/* ── Headers ── */
.workout-header, .sub-header { display: flex; align-items: center; gap: 12px; margin-bottom: 1.5rem; padding-top: 0.5rem; }
.workout-title-wrap { flex: 1; }
.workout-title { font-size: 17px; font-weight: 500; color: var(--text); }
.timer { font-size: 14px; font-weight: 500; color: var(--gold); font-variant-numeric: tabular-nums; padding: 6px 10px; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius-sm); }
.sub-title { font-size: 17px; font-weight: 500; color: var(--text); }

/* ── Cards ── */
.card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; transition: background 0.3s, border-color 0.3s; }
.card-label { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 8px; }

/* ── Exercise cards ── */
.ex-name { font-size: 15px; font-weight: 500; margin-bottom: 2px; color: var(--text); }
.ex-meta-row { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.ex-meta-item { font-size: 11px; }
.ex-meta-item.pr { color: var(--gold); }
.ex-meta-item.last { color: var(--text-muted); }
.ex-meta-item span { color: var(--text-dim); }

/* ── Per-set table ── */
.sets-table { width: 100%; border-collapse: collapse; }
.sets-table th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); font-weight: 500; padding: 0 6px 8px; text-align: left; }
.sets-table th:first-child { width: 36px; text-align: center; }
.sets-table td { padding: 4px 6px; vertical-align: middle; }
.sets-table td:first-child { text-align: center; }
.set-number-btn { width: 32px; height: 32px; border-radius: 50%; border: 0.5px solid var(--border-strong); background: transparent; color: var(--text-muted); cursor: pointer; font-size: 12px; font-weight: 500; font-family: inherit; transition: all 0.12s; }
.set-number-btn:active { transform: scale(0.9); }
.set-number-btn.done { background: var(--purple); border-color: var(--purple-bright); color: var(--gold-bright); }
.set-number-btn.pr { background: var(--gold); border-color: var(--gold-bright); color: var(--bg); }
.set-input { width: 58px; padding: 7px 8px; border: 0.5px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-deep); color: var(--text); font-size: 14px; font-family: inherit; text-align: center; -webkit-appearance: none; appearance: none; transition: background 0.3s, color 0.3s; }
.set-input:focus { outline: none; border-color: var(--gold); }
input[type="time"] { width: 110px; padding: 8px 10px; border: 0.5px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-deep); color: var(--text); font-size: 15px; font-family: inherit; text-align: left; margin-top: 4px; }
input[type="time"]:focus { outline: none; border-color: var(--gold); }
.pr-badge { display: none; font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--gold); color: var(--bg); letter-spacing: 0.05em; text-transform: uppercase; }
.pr-badge.visible { display: inline-block; }

/* ── Effort ── */
.effort-card { margin-top: 14px; }
.effort-buttons { display: flex; gap: 6px; }
.effort-btn { flex: 1; padding: 10px 4px; border: 0.5px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); font-size: 13px; cursor: pointer; font-family: inherit; transition: all 0.15s; }
.effort-btn.selected { border-color: var(--gold); color: var(--gold); background: var(--gold-bg); font-weight: 500; }

/* ── History ── */
.history-item { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; transition: border-color 0.15s; }
.history-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.history-day { font-size: 14px; font-weight: 500; color: var(--text); }
.history-date { font-size: 12px; color: var(--text-dim); }
.history-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); }
.history-actions { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 0.5px solid var(--border); }
.history-actions .btn { margin-top: 0; padding: 9px 14px; font-size: 13px; flex: 1; }
.pr-list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.pr-name { font-size: 13px; color: var(--text); }
.pr-value { font-size: 13px; font-weight: 600; color: var(--gold); font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-dim); font-size: 14px; }

/* ── Edit session ── */
.edit-meta-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.edit-meta-group { display: flex; flex-direction: column; gap: 6px; }
.edit-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); font-weight: 500; }
.edit-ex-card { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.edit-ex-name { font-size: 14px; font-weight: 500; color: var(--text); margin-bottom: 10px; }

/* ── Dashboard ── */
.ex-select { width: 100%; padding: 10px 12px; border: 0.5px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-deep); color: var(--text); font-size: 14px; font-family: inherit; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23d4af37' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer; }
.ex-select:focus { outline: none; border-color: var(--gold); }
#chart-container { position: relative; width: 100%; height: 200px; }
#volume-chart { width: 100% !important; height: 100% !important; }
.chart-empty { font-size: 13px; color: var(--text-dim); text-align: center; padding: 2rem 0; }
.dash-session-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 0.5px solid var(--border); font-size: 13px; }
.dash-session-row:first-child { border-top: none; }
.dash-session-date { color: var(--text-muted); }
.dash-session-vol { color: var(--gold); font-weight: 500; font-variant-numeric: tabular-nums; }
.dash-session-sets { color: var(--text-dim); font-size: 12px; }

/* ── Plan editor ── */
.plan-day-row { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; transition: border-color 0.15s; }
.plan-day-row:active { border-color: var(--border-strong); }
.plan-day-name { font-size: 15px; font-weight: 500; color: var(--text); }
.plan-day-count { font-size: 12px; color: var(--text-dim); }
.plan-day-arrow { color: var(--gold-deep); font-size: 14px; }
.plan-ex-row { background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
.plan-ex-info { flex: 1; }
.plan-ex-name { font-size: 14px; font-weight: 500; color: var(--text); }
.plan-ex-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.btn-remove-ex { background: transparent; border: 0.5px solid var(--red); border-radius: var(--radius-sm); color: var(--red); font-size: 12px; font-weight: 500; padding: 5px 10px; cursor: pointer; font-family: inherit; flex-shrink: 0; }
.add-ex-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* ── Theme switcher ── */
.theme-switcher { display: flex; gap: 8px; margin-top: 4px; }
.theme-btn { flex: 1; padding: 10px 6px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-weight: 500; font-family: inherit; border: 0.5px solid var(--border); background: var(--surface-2); color: var(--text-muted); transition: all 0.15s; text-align: center; }
.theme-btn.active { border-color: var(--gold); color: var(--gold); background: var(--gold-bg); }
.theme-btn .theme-icon { display: block; font-size: 18px; margin-bottom: 4px; }

/* ── Auth tabs ── */
.auth-tabs { display: flex; gap: 0; margin-bottom: 20px; border: 0.5px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.auth-tab { flex: 1; padding: 10px; background: transparent; border: none; color: var(--text-muted); font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; transition: all 0.15s; }
.auth-tab.active { background: var(--purple); color: var(--gold-bright); }

/* ── Password field with eye ── */
.password-wrap { position: relative; display: flex; align-items: center; }
.password-wrap .auth-input { padding-right: 44px; width: 100%; }
.eye-btn { position: absolute; right: 12px; background: none; border: none; cursor: pointer; color: var(--text-dim); padding: 4px; display: flex; align-items: center; justify-content: center; transition: color 0.15s; }
.eye-btn:active { color: var(--gold); }

/* ── Password strength ── */
.password-strength { margin-top: 6px; font-size: 11px; font-weight: 500; letter-spacing: 0.05em; min-height: 16px; }
.password-strength.weak { color: var(--red); }
.password-strength.fair { color: var(--amber, #e8a020); }
.password-strength.strong { color: var(--green); }

/* ── Welcome message ── */
.auth-welcome { font-size: 13px; color: var(--gold-deep); font-weight: 500; margin-bottom: 4px; letter-spacing: 0.05em; }

/* ── Admin panel ── */
.admin-user-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-top: 0.5px solid var(--border); gap: 10px;
}
.admin-user-row:first-child { border-top: none; }
.admin-user-info { flex: 1; min-width: 0; }
.admin-user-email { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-user-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.admin-user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-admin-action {
  font-size: 11px; font-weight: 500; padding: 5px 10px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-family: inherit; border: 0.5px solid var(--border-strong);
  background: transparent; color: var(--text-muted); transition: all 0.15s;
  white-space: nowrap;
}
.btn-admin-action.promote { border-color: var(--gold); color: var(--gold); }
.btn-admin-action.demote { border-color: var(--text-dim); color: var(--text-dim); }
.btn-admin-action.remove { border-color: var(--red); color: var(--red); }
.role-badge { display: inline-block; font-size: 9px; font-weight: 600; padding: 2px 7px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.08em; }
.role-badge.admin { background: var(--gold-bg); color: var(--gold); border: 0.5px solid var(--border); }
.role-badge.user { background: var(--surface-2); color: var(--text-dim); border: 0.5px solid var(--border); }
