/* WorkoutLog Pro */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent:      #0ea5e9;
  --accent-dark: #0284c7;
  --accent-bg:   #e0f2fe;
  --green:       #22c55e;
  --green-bg:    #dcfce7;
  --red:         #ef4444;
  --surface:     #ffffff;
  --bg:          #f0f9ff;
  --bg2:         #e7f3fb;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --border:      #e2e8f0;
  --radius:      14px;
  --radius-sm:   8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 10px; font-size: .95rem; font-weight: 600;
  border: none; cursor: pointer; transition: opacity .15s, transform .1s; text-decoration: none;
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(.96); }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost    { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-sm       { padding: 6px 14px; font-size: .85rem; }
.btn-lg       { padding: 14px 32px; font-size: 1.05rem; border-radius: 12px; }
.btn-xl       { padding: 18px 48px; font-size: 1.2rem; border-radius: 16px; }
.btn-lg-tap   { padding: 14px 28px; font-size: 1rem; }

/* ── Landing ─────────────────────────────────────────────────────── */
.landing { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.landing-hero { text-align: center; max-width: 420px; }
.landing-icon  { font-size: 4.5rem; margin-bottom: 1rem; }
.landing-title { font-size: 2.4rem; font-weight: 800; margin-bottom: .5rem; }
.landing-sub   { font-size: 1.05rem; color: var(--text-muted); margin-bottom: 2rem; line-height: 1.6; }

/* ── App shell ───────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; max-width: 540px; margin: 0 auto; }

.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1.1rem; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1rem; color: var(--text); }
.nav-back {
  font-size: 1rem; font-weight: 600; color: var(--accent); text-decoration: none;
  padding: 4px 0; min-width: 50px;
}
.nav-right { display: flex; align-items: center; gap: .5rem; }
.nav-icon-btn { font-size: 1.2rem; text-decoration: none; padding: 4px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: none; }

/* ── Dashboard ───────────────────────────────────────────────────── */
.dash-header { padding: .6rem 1rem .2rem; }
.session-badge {
  display: inline-block; padding: .3rem .8rem; border-radius: 20px;
  font-size: .82rem; font-weight: 600;
}
.session-badge.active { background: var(--green-bg); color: #15803d; }
.session-badge.idle   { background: var(--bg2); color: var(--text-muted); }

.dash-main { padding: .5rem .75rem 4rem; display: flex; flex-direction: column; gap: .5rem; }

.ex-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1rem;
  text-decoration: none; color: inherit;
  transition: border-color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.ex-card:active { background: var(--bg2); }
.ex-card-done { border-color: var(--green); background: var(--green-bg); }
.ex-card-done:active { background: #bbf7d0; }

.ex-card-left { display: flex; align-items: center; gap: .8rem; flex: 1; min-width: 0; }
.ex-card-icon { font-size: 1.8rem; flex-shrink: 0; }
.ex-card-info { min-width: 0; }
.ex-card-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.ex-card-meta { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.ex-card-last { font-size: .78rem; color: var(--text-muted); margin-top: 2px; font-family: monospace; }

.ex-card-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.ex-done-badge {
  font-size: .75rem; font-weight: 700; color: #15803d;
  background: var(--green-bg); padding: 3px 8px; border-radius: 20px;
}
.ex-card-arrow { font-size: 1.4rem; color: var(--border); }

.section-divider {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: .05em;
  padding: .4rem .25rem .1rem;
}
.loading-msg, .empty-msg { text-align: center; color: var(--text-muted); padding: 2rem; font-size: .95rem; }
.empty-msg a { color: var(--accent); }

/* ── Exercise page ───────────────────────────────────────────────── */
.ex-main { padding: .75rem .75rem 5rem; display: flex; flex-direction: column; gap: .75rem; }

.ex-section {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: .9rem 1rem;
}
.today-section { border-color: var(--accent); }

.ex-section-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); margin-bottom: .6rem;
  display: flex; align-items: center; justify-content: space-between;
}
.ex-session-num { font-size: .75rem; font-weight: 600; color: var(--accent); }

/* Sets */
.sets-list { display: flex; flex-direction: column; gap: .3rem; }
.set-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .5rem; border-radius: var(--radius-sm);
  background: var(--bg);
}
.set-num { font-size: .78rem; color: var(--text-muted); width: 38px; flex-shrink: 0; }
.set-val { flex: 1; font-size: .95rem; font-weight: 600; }
.side-tag {
  font-size: .68rem; font-weight: 800; width: 18px; text-align: center;
  border-radius: 4px; padding: 1px 3px; flex-shrink: 0; text-transform: uppercase;
}
.side-tag.left  { background: #dbeafe; color: #1d4ed8; }
.side-tag.right { background: #fce7f3; color: #be185d; }
.btn-del-set {
  font-size: .75rem; background: none; border: none; color: #cbd5e1;
  cursor: pointer; padding: 2px 4px; border-radius: 4px; transition: color .15s;
  flex-shrink: 0;
}
.btn-del-set:hover { color: var(--red); }
.sets-empty { font-size: .88rem; color: var(--text-muted); padding: .25rem 0; }
.sets-empty-sm { font-size: .8rem; color: #cbd5e1; }

/* Bilateral cols */
.bilateral-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .5rem; }
.bilateral-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: .3rem; }

/* Add set form */
.add-set-form {
  background: var(--bg); border-radius: var(--radius-sm);
  padding: .85rem; margin-bottom: .6rem;
  display: flex; flex-direction: column; gap: .7rem;
}
.form-row { display: flex; align-items: center; gap: .6rem; }
.form-label { font-size: .85rem; font-weight: 600; color: var(--text-muted); min-width: 56px; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.form-check { display: flex; align-items: center; gap: .3rem; font-size: .88rem; cursor: pointer; }

.input-big {
  width: 90px; font-size: 1.5rem; font-weight: 700; text-align: center;
  border: 2px solid var(--border); border-radius: 10px; padding: .4rem .5rem;
  color: var(--text); background: var(--surface);
}
.input-big:focus { outline: none; border-color: var(--accent); }
.input-num {
  width: 64px; font-size: 1.2rem; font-weight: 700; text-align: center;
  border: 2px solid var(--border); border-radius: 10px; padding: .35rem .4rem;
  background: var(--surface);
}
.input-num:focus { outline: none; border-color: var(--accent); }
.input-sm {
  width: 70px; font-size: .95rem; font-weight: 600; text-align: center;
  border: 1.5px solid var(--border); border-radius: 8px; padding: .35rem .5rem;
  background: var(--surface);
}
.input-md {
  flex: 1; font-size: .95rem; border: 1.5px solid var(--border);
  border-radius: 10px; padding: .5rem .75rem; background: var(--surface);
}
.input-md:focus { outline: none; border-color: var(--accent); }
.input-unit {
  font-size: .88rem; border: 1.5px solid var(--border); border-radius: 8px;
  padding: .35rem .5rem; background: var(--surface); cursor: pointer;
}

.weight-input-group { display: flex; align-items: center; gap: .4rem; }
.time-input-group   { display: flex; align-items: center; gap: .3rem; }
.time-sep { font-size: .82rem; color: var(--text-muted); }

.side-btns { display: flex; gap: .3rem; }
.side-btn {
  padding: 6px 16px; border-radius: 8px; border: 1.5px solid var(--border);
  font-size: .88rem; font-weight: 600; cursor: pointer; background: var(--surface);
  color: var(--text-muted); transition: border-color .15s, background .15s;
}
.side-btn.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-dark); }

.btn-timer {
  font-size: .82rem; background: none; border: 1.5px solid var(--border);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--text-muted);
  margin-left: .25rem;
}
.btn-timer:hover { border-color: var(--accent); color: var(--accent); }

.btn-add-set {
  width: 100%; padding: 14px; border-radius: 12px;
  background: var(--accent); color: #fff; border: none;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-add-set:active { transform: scale(.97); background: var(--accent-dark); }

/* Rest timer bar */
.rest-timer-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--text); color: #fff; padding: .9rem 1.2rem;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  font-size: 1rem; font-weight: 700; z-index: 100;
}
.rest-timer-bar button {
  background: none; border: none; color: #94a3b8; font-size: 1rem;
  cursor: pointer; padding: 2px 8px; margin-left: .5rem;
}

/* Timer overlay */
.timer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.5rem;
}
.timer-display { font-size: 5rem; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.timer-status  { font-size: 1rem; color: #94a3b8; }
.timer-controls { display: flex; gap: 1rem; }

/* ── Settings ────────────────────────────────────────────────────── */
.settings-main { padding: .75rem .75rem 4rem; display: flex; flex-direction: column; gap: .75rem; }
.settings-section {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.section-title { font-size: 1rem; font-weight: 700; margin-bottom: .25rem; }
.section-sub   { font-size: .82rem; color: var(--text-muted); margin-bottom: .75rem; }

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .6rem 0; border-bottom: 1px solid var(--border); gap: .5rem;
}
.setting-row:last-child { border-bottom: none; }

.setting-ex-wrapper {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: .45rem; overflow: hidden;
}
.setting-ex-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .65rem;
}
.setting-ex-icon { font-size: 1.4rem; flex-shrink: 0; }
.setting-ex-info { flex: 1; min-width: 0; }
.setting-ex-name { font-size: .95rem; font-weight: 600; display: block; }
.setting-ex-meta { font-size: .75rem; color: var(--text-muted); }
.setting-ex-actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.btn-edit-ex {
  background: none; border: none; padding: 4px 5px; cursor: pointer;
  font-size: .95rem; color: var(--text-muted); border-radius: 6px; line-height: 1;
}
.btn-edit-ex:hover { background: var(--bg2); color: var(--text); }
.ex-edit-panel {
  background: var(--bg2); border-top: 1.5px solid var(--border);
  padding: .7rem .65rem; display: flex; flex-direction: column; gap: .55rem;
}
.edit-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.edit-label { min-width: 66px; font-size: .82rem; color: var(--text-muted); font-weight: 500; }
.edit-hint { font-size: .76rem; color: var(--text-muted); }
.edit-name-input { flex: 1; min-width: 0; }
.edit-actions { display: flex; gap: .5rem; justify-content: flex-end; padding-top: .15rem; }

.btn-del {
  font-size: 1rem; background: none; border: none; cursor: pointer;
  padding: 4px; color: #cbd5e1; transition: color .15s;
}
.btn-del:hover { color: var(--red); }

.add-ex-form { display: flex; flex-direction: column; gap: .65rem; }
.form-row-inline { display: flex; align-items: center; gap: .5rem; }
.type-btns { display: flex; gap: .3rem; }
.type-btn {
  padding: 5px 14px; border-radius: 8px; border: 1.5px solid var(--border);
  font-size: .85rem; font-weight: 600; cursor: pointer; background: var(--surface);
  color: var(--text-muted); transition: border-color .15s, background .15s;
}
.type-btn.active { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-dark); }

.emoji-btn {
  font-size: 1.6rem; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 5px 10px; cursor: pointer; flex-shrink: 0;
}
.emoji-btn:hover { border-color: var(--accent); }

.rest-secs-input { display: flex; align-items: center; gap: .35rem; font-size: .88rem; color: var(--text-muted); }

/* ── Toggle ──────────────────────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 12px;
  transition: background .2s; cursor: pointer;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle-thumb {
  position: absolute; left: 3px; top: 3px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-box {
  background: var(--surface); border-radius: 20px; padding: 24px 20px;
  width: 100%; max-width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-title { font-size: 1rem; font-weight: 700; text-align: center; margin-bottom: 1rem; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: .5rem; }
.emoji-opt {
  font-size: 1.4rem; background: none; border: none; border-radius: 8px;
  padding: 6px 4px; cursor: pointer; text-align: center; line-height: 1;
}
.emoji-opt:hover { background: var(--bg2); }

/* ── Version badge ───────────────────────────────────────────────── */
#app-ver-badge {
  position: fixed; bottom: 4px; left: 0; right: 0; text-align: center;
  font-size: .62rem; color: rgba(0,0,0,.25); pointer-events: none; z-index: 999;
}

/* ── History section ─────────────────────────────────────────────── */
.history-section { margin-top: 1rem; }
.history-toggle { cursor: pointer; user-select: none; }
.history-toggle:hover { color: var(--accent); }
.history-chevron { font-size: .85rem; margin-left: .3rem; }
.hist-session {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: .6rem; overflow: hidden;
}
.hist-sess-header {
  display: flex; align-items: center; gap: .5rem; padding: .55rem .75rem;
  background: var(--bg2); cursor: pointer; font-size: .88rem;
}
.hist-sess-header:hover { background: var(--accent-bg); }
.hist-set-count { margin-left: auto; color: var(--text-muted); font-size: .8rem; }
.hist-chevron { font-size: .8rem; color: var(--text-muted); }
.hist-sess-body { padding: .5rem .75rem .75rem; }
.hist-add-form { padding: .5rem 0; border-top: 1px solid var(--border); margin-top: .5rem; }
.btn-hist-add {
  margin-top: .5rem; padding: 5px 12px; font-size: .8rem; font-weight: 600;
  background: var(--bg2); border: 1.5px solid var(--border); border-radius: 8px;
  cursor: pointer; color: var(--text-muted);
}
.btn-hist-add:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
