:root {
  --bg: #0f1115;
  --card: #181b22;
  --card-2: #20242d;
  --line: #2a2f3a;
  --text: #eef1f6;
  --muted: #8b93a3;
  --brand: #7c5cff;
  --brand-2: #a28bff;
  --good: #51cf66;
  --gold: #ffc53d;
  --danger: #ff6b6b;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app { max-width: 560px; margin: 0 auto; }

a { color: inherit; text-decoration: none; }

main { padding: 4px 16px 48px; }

.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.center { text-align: center; margin-top: 20px; }

/* ---------- top bar ---------- */

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 8px;
  background: rgba(15, 17, 21, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.bar h1 {
  flex: 1; margin: 0; text-align: center;
  font-size: 17px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 12px; background: transparent;
  color: var(--text); font-size: 26px; line-height: 1; cursor: pointer;
}
a.icon-btn:active, button.icon-btn:active { background: var(--card-2); }

/* ---------- home ---------- */

.h-big { font-size: 26px; line-height: 1.2; margin: 4px 0 18px; }

.day-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.day-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 2px;
  min-height: 128px; padding: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform .1s;
}
.day-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--accent);
}
.day-card:active { transform: scale(.97); }
.day-emoji { font-size: 34px; margin-bottom: auto; }
.day-name { font-size: 19px; font-weight: 700; }
.day-last { font-size: 13px; color: var(--muted); }

/* ---------- exercise list ---------- */

.section {
  margin: 24px 0 10px;
  font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted);
}

.ex-card {
  display: block; margin-bottom: 10px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.ex-card:active { background: var(--card-2); }
.ex-card.done { border-color: rgba(81, 207, 102, .5); }
.ex-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ex-name { font-weight: 650; font-size: 16.5px; }
.tick {
  flex: none; display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--good); color: #0b2a12; font-weight: 800; font-size: 14px;
}
.ex-hits { color: var(--muted); font-size: 14px; margin: 2px 0 0; }
.ex-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  background: rgba(124, 92, 255, .16); color: var(--brand-2);
}
.chip.ghost { background: var(--card-2); color: var(--muted); }
.chip.pr { background: rgba(255, 197, 61, .15); color: var(--gold); }

/* ---------- log screen ---------- */

.cue {
  margin: 12px 0; padding: 12px 14px; font-size: 14.5px;
  background: var(--card); border-radius: 12px; border-left: 3px solid var(--brand);
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats > div {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 10px; background: var(--card); border-radius: 12px;
}
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stat-val { font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.pr-text { color: var(--gold); }

.hint {
  margin: 12px 0 0; padding: 10px 14px; font-size: 14px;
  background: rgba(81, 207, 102, .1); color: #b2f2bb; border-radius: 12px;
}

.date-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 18px 0 8px; font-weight: 600;
}

input {
  font: inherit; color: var(--text);
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; min-height: 48px; width: 100%;
}
input:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: transparent; }
input[type="date"] { width: auto; }
input[type="number"] { text-align: center; font-size: 19px; font-weight: 650; -moz-appearance: textfield; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input::placeholder { color: #5d6575; font-weight: 500; }

.sets { margin-top: 8px; }
.set-row {
  display: grid; grid-template-columns: 36px 1fr 1fr 44px;
  align-items: center; gap: 8px; margin-bottom: 8px;
}
.sets.no-w .set-row { grid-template-columns: 36px 1fr 44px; }
.set-head { margin-bottom: 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; text-align: center; }
.set-no {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--card-2); color: var(--muted); font-weight: 700; font-size: 14px;
}
.del { font-size: 17px; color: var(--muted); }

/* ---------- buttons ---------- */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 50px; margin-top: 10px; padding: 12px 16px;
  font: inherit; font-weight: 650; color: var(--text); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.btn:active { transform: scale(.985); }
.btn.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.big { min-height: 56px; font-size: 17px; margin-top: 16px; }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, .4); }

.seg { display: flex; gap: 6px; padding: 4px; background: var(--card); border-radius: 14px; }
.seg button {
  flex: 1; min-height: 44px; font: inherit; font-weight: 650; cursor: pointer;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- history ---------- */

.history { list-style: none; margin: 0; padding: 0; }
.history li {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px 10px 14px; margin-bottom: 6px;
  background: var(--card); border-radius: 12px;
}
.h-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.h-date { font-size: 13px; color: var(--muted); }
.h-sets { font-weight: 600; overflow-wrap: anywhere; }

/* ---------- lock screen ---------- */

.lock {
  display: flex; flex-direction: column; align-items: center;
  min-height: 100dvh; padding: 48px 24px 24px;
}
.brand { text-align: center; margin-bottom: 28px; }
.brand img { border-radius: 18px; }
.brand h1 { margin: 10px 0 0; font-size: 28px; }
.lock-title { font-weight: 600; margin: 0 0 16px; }
.dots { display: flex; gap: 16px; }
.dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--muted); transition: background .1s;
}
.dots span.on { background: var(--brand); border-color: var(--brand); }
.dots.shake { animation: shake .35s; }
.lock-msg { min-height: 22px; margin: 12px 0; color: var(--danger); font-size: 14px; }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 16px; margin-top: auto; padding-bottom: 24px; }
.pad button {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--card-2); color: var(--text); font: 600 28px system-ui, sans-serif;
}
.pad button:active { background: var(--brand); }
.pad .pad-ghost { background: transparent; font-size: 15px; color: var(--muted); }
.pad .pad-ghost[aria-label="Delete"] { font-size: 26px; }

@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; text-align: center;
  background: #2b3040; color: var(--text); border-radius: 14px;
  font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, .4);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.pr { background: linear-gradient(135deg, #ffc53d, #ff8f3d); color: #2b1900; font-size: 17px; }
