:root {
  --bg: #0f1115;
  --card: #181b22;
  --card2: #20242d;
  --line: #2b303b;
  --text: #eef0f4;
  --muted: #9aa1ae;
  --accent: #ff7a1a;
  --ok: #34c77b;
  --warn: #f2b33d;
  --bad: #ff5a5a;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: calc(env(safe-area-inset-top) + 64px) 0 calc(env(safe-area-inset-bottom) + 76px);
  min-height: 100vh;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }

.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: rgba(15, 17, 21, .95); border-bottom: 1px solid var(--line);
}
.top-mid { flex: 1; text-align: center; }
.top-date { font-weight: 700; font-size: 16px; }
.top-sub { color: var(--muted); font-size: 13px; }
.nav-day { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 26px; line-height: 1; }

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

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: rgba(15, 17, 21, .97); border-top: 1px solid var(--line);
}
.tabs button { background: none; border: 0; padding: 10px 4px; color: var(--muted); font-weight: 600; border-radius: 10px; }
.tabs button.active { color: var(--accent); background: var(--card); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 4px; font-size: 19px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--card2); color: var(--accent); margin-right: 4px; }
.tag.ok { color: var(--ok); }
.tag.warn { color: var(--warn); }
.tag.bad { color: var(--bad); }
.done-banner { border-color: var(--ok); }
.alert { border-color: var(--warn); }

details { margin-top: 8px; }
summary { color: var(--accent); font-weight: 600; cursor: pointer; }
ul.plain { margin: 6px 0 0; padding-left: 18px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2); font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; }
.btn.ghost { background: none; }
.btn.block { width: 100%; margin-top: 10px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.ex { background: var(--card2); border-radius: 12px; padding: 12px; margin-top: 10px; }
.ex-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ex-name { font-weight: 700; }
.ex-target { color: var(--accent); font-weight: 700; white-space: nowrap; font-size: 14px; }
.set-row { display: grid; grid-template-columns: 26px 1fr 1fr 52px; gap: 8px; align-items: center; margin-top: 8px; }
.set-row.bw { grid-template-columns: 26px 1fr 52px; }
.set-no { color: var(--muted); font-weight: 700; text-align: center; }
.field { position: relative; }
.field input { width: 100%; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: 0 34px 0 10px; font-size: 17px; }
.field span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.check { width: 52px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 20px; color: var(--muted); }
.check.on { background: var(--ok); border-color: var(--ok); color: #08210f; }

.track { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.track:first-of-type { border-top: 0; }
.track .label { font-weight: 600; }
.track .sub { color: var(--muted); font-size: 13px; }
.track .field input { width: 120px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); font-size: 20px; font-weight: 700; }
.stepper strong { min-width: 44px; text-align: center; font-size: 18px; }
.habit { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.habit input { width: 24px; height: 24px; accent-color: var(--ok); }

.bar { height: 6px; background: var(--bg); border-radius: 6px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar i.ok { background: var(--ok); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.table-wrap th, .table-wrap td { white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid2 label { font-size: 13px; color: var(--muted); display: block; }
.grid2 .field input { padding-right: 32px; }

.timer {
  position: fixed; left: 12px; right: 12px; z-index: 6;
  bottom: calc(env(safe-area-inset-bottom) + 72px);
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--accent); color: #111; border-radius: 14px; font-weight: 700;
  max-width: 616px; margin: 0 auto;
}
.timer strong { font-size: 22px; flex: 1; font-variant-numeric: tabular-nums; }
.timer button { border: 0; background: rgba(0, 0, 0, .15); border-radius: 10px; padding: 8px 10px; font-weight: 700; }
.timer.over { background: var(--ok); }
.hidden { display: none; }
