:root {
  --bg: #f6f5f2; --card: #ffffff; --text: #1d1d1f; --muted: #6e6e73;
  --line: #e4e2dd; --accent: #2f7d4f; --accent-soft: #dcefe3; --danger: #c0392b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111312; --card: #1c1f1d; --text: #f2f2f0; --muted: #9a9e9b;
    --line: #2c302d; --accent: #5cc285; --accent-soft: #1f3a2a; --danger: #ff6b5b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: env(safe-area-inset-top) 16px calc(84px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: 28px; margin: 0; }
h2 { font-size: 20px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; margin: 4px 0; }

.top { padding: 16px 0 8px; }
.top-row { display: flex; justify-content: space-between; align-items: baseline; }
.week-pct { font-size: 22px; font-weight: 600; color: var(--accent); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.top p { margin: 6px 0 0; }

.cards, .rows, .log-list { list-style: none; padding: 0; margin: 0; }
.card {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; margin: 10px 0; cursor: pointer;
}
.card:active { transform: scale(.99); }
.card-name { font-weight: 600; }
.tag { display: inline-block; font-size: 13px; background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 1px 8px; margin-top: 6px; }
.card-foot { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; }
.today-n { font-size: 20px; font-weight: 700; }
.card.done .today-n { color: var(--accent); font-size: 16px; }

.row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 8px 0; }
.row-head { display: flex; justify-content: space-between; gap: 12px; }
.row .bar { height: 6px; }

.backup { margin: 28px 0 8px; }
.backup p { margin: 6px 0 12px; }
.btn {
  display: block; width: 100%; min-height: 48px; border: 0; border-radius: 12px;
  background: var(--accent); color: #fff; font: 600 17px/48px inherit; font-family: inherit;
  text-align: center; margin: 8px 0; cursor: pointer;
}
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); line-height: 46px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { flex: 1; min-height: 56px; border: 0; background: none; font: inherit; color: var(--muted); }
.tab.active { color: var(--accent); font-weight: 600; }

/* Лист открывается сверху: на iPhone клавиатура закрывает нижнюю половину экрана. */
dialog {
  width: 100%; max-width: 560px; margin: 0 auto auto; border: 0; padding: 0;
  max-height: 100dvh; overflow-y: auto;
  border-radius: 0 0 18px 18px; background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.4); }
#log-form { padding: calc(14px + env(safe-area-inset-top)) 16px 18px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.close { border: 0; background: none; font-size: 30px; line-height: 1; color: var(--muted); min-width: 44px; min-height: 44px; }
.field { display: block; font-size: 14px; color: var(--muted); margin-top: 12px; }
.field input {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 20px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.reps-row { display: flex; gap: 10px; margin-top: 4px; }
.reps-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 20px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.btn-save { width: auto; flex: 0 0 auto; margin: 0; padding: 0 18px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.field-row .narrow { flex: 0 0 96px; }
.log-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.del { border: 0; background: none; color: var(--danger); font: inherit; min-height: 44px; padding: 0 4px; }
