:root {
  --bg: #111418;
  --panel: #1a1f25;
  --panel-2: #232a32;
  --line: #2e363f;
  --text: #e8edf2;
  --muted: #8b97a3;
  --accent: #4fa3ff;
  --ok: #3ecf8e;
  --warn: #f5b942;
  --err: #ff6b6b;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding-bottom: calc(64px + var(--safe-b));
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: rgba(17, 20, 24, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  flex: none;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--muted);
}
.pill.ok { color: var(--ok); border-color: rgba(62, 207, 142, 0.35); }
.pill.pending { color: var(--warn); border-color: rgba(245, 185, 66, 0.4); }
.pill.err { color: var(--err); border-color: rgba(255, 107, 107, 0.45); }

main { padding: 12px 16px 24px; max-width: 640px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: rgba(17, 20, 24, 0.97);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1; border: 0; background: none; padding: 14px 0; color: var(--muted); font-size: 15px;
}
.tabbar button.active { color: var(--accent); font-weight: 600; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }

.btn {
  border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 10px; padding: 10px 14px; min-height: 44px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 650; }
.btn.danger { color: var(--err); }
.btn.block { width: 100%; }
.ghost { border: 0; background: none; color: var(--accent); padding: 8px; min-height: 44px; }
.ghost.danger { color: var(--err); }

/* Week */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.week-nav h2 { margin: 0; font-size: 17px; }
.day {
  display: flex; gap: 12px; align-items: stretch;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px;
}
.day.today { border-color: var(--accent); }
.day-date { width: 44px; flex: none; text-align: center; }
.day-date .dow { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.day-date .dom { font-size: 22px; font-weight: 650; }
.day-items { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.day-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; text-align: left; border: 1px solid var(--line); background: var(--panel-2);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
.day-item .name { font-weight: 600; }
.badge { font-size: 12px; border-radius: 999px; padding: 2px 8px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: rgba(62, 207, 142, 0.35); }
.badge.pending { color: var(--warn); border-color: rgba(245, 185, 66, 0.4); }
.day-add { align-self: flex-start; border: 0; background: none; color: var(--muted); font-size: 13px; padding: 4px 0; }

/* Session */
.session-head { margin-bottom: 12px; }
.session-head .focus { color: var(--muted); font-size: 14px; }
.ex-name { font-weight: 650; font-size: 16px; border: 0; background: none; padding: 0; text-align: left; color: var(--text); }
.ex-name::after { content: " ›"; color: var(--muted); }
.ex-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ex-meta .last { color: #b7c3cf; }
.sets { width: 100%; border-collapse: collapse; margin-top: 8px; }
.sets th { font-size: 12px; font-weight: 500; color: var(--muted); text-align: center; padding: 2px 4px; }
.sets td { padding: 3px 3px; text-align: center; }
.sets td.n { width: 28px; color: var(--muted); font-size: 14px; }
.sets input[type="text"] {
  width: 100%; min-width: 0; height: 44px; text-align: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font-size: 17px;
}
.sets input::placeholder { color: #55606b; }
.sets tr.done input[type="text"] { border-color: rgba(62, 207, 142, 0.45); }
.sets td.chk { width: 52px; }
.check {
  width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 20px;
}
.check.on { background: var(--ok); border-color: var(--ok); color: #05170e; }
.ex-actions { display: flex; justify-content: space-between; margin-top: 4px; }

textarea, .field input, .field select {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.finish-bar {
  position: sticky; bottom: calc(64px + var(--safe-b)); padding-top: 8px;
  background: linear-gradient(to bottom, rgba(17, 20, 24, 0), var(--bg) 30%);
}

/* History */
h3.section { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 18px 0 8px; }
.list-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; min-height: 44px;
}
.seg { display: flex; gap: 6px; margin-bottom: 12px; }
.seg button { flex: 1; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px; color: var(--muted); }
.seg button.active { color: var(--text); border-color: var(--accent); }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; }
.sheet-panel {
  width: 100%; max-height: 85vh; overflow: auto; background: var(--panel);
  border-radius: 16px 16px 0 0; padding: 12px 16px calc(16px + var(--safe-b));
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.hist-row { border-top: 1px solid var(--line); padding: 8px 0; }
.hist-row .sets-line { font-variant-numeric: tabular-nums; }
.status { font-size: 14px; margin-top: 8px; white-space: pre-wrap; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.spacer { margin-bottom: 10px; }
