:root {
  --bg: #0f1115;
  --panel: #191c23;
  --panel-2: #222631;
  --line: #2e3340;
  --text: #eef0f4;
  --muted: #9aa1b1;
  --accent: #ff7a1a;
  --accent-ink: #1a0d02;
  --up: #34d399;
  --same: #60a5fa;
  --danger: #f87171;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
body.has-nav { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
a { color: inherit; text-decoration: none; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(15, 17, 21, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { font-weight: 800; color: var(--accent-ink); background: var(--accent); border-radius: 8px; padding: 2px 7px; font-size: 15px; }
.back { font-size: 34px; line-height: 1; padding: 0 12px 4px 0; margin: -6px 0; color: var(--accent); min-width: 44px; }

main { max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 0; }
h3 { font-size: 14px; color: var(--muted); margin: 12px 0 6px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--danger); }
.flash { background: var(--panel-2); padding: 10px 12px; border-radius: var(--r); }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.btn {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 10px 16px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; user-select: none;
  list-style: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.huge { min-height: 72px; font-size: 22px; font-weight: 800; }
.btn.small { width: auto; min-height: 40px; padding: 6px 14px; font-size: 15px; }
.btn.danger-link { background: none; border: 0; color: var(--danger); font-weight: 500; min-height: 44px; }
.btn[disabled] { opacity: .6; }
summary.btn::-webkit-details-marker { display: none; }

.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.hero { display: flex; flex-direction: column; gap: 4px; border-color: var(--accent); }
.hero strong { font-size: 24px; color: var(--accent); }

.list, .cards, .setlist { list-style: none; margin: 0; padding: 0; }
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list li + li { border-top: 1px solid var(--line); }
.list a { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; min-height: 56px; justify-content: center; }
.list a:active { background: var(--panel-2); }
.cards { display: flex; flex-direction: column; gap: 10px; }
.ex { display: flex; flex-direction: column; gap: 8px; }
.ex strong { font-size: 18px; }
.ex.done { border-color: var(--up); }
.ex .sets { font-variant-numeric: tabular-nums; color: var(--muted); }
.pill { background: var(--panel-2); border-radius: 999px; padding: 2px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.ex.done .pill { background: var(--up); color: #062a1d; }

.sugg { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; padding: 14px; border-radius: var(--r); background: var(--panel); border: 2px solid var(--line); }
.sugg strong { font-size: 20px; grid-column: 1; }
.sugg .btn { grid-column: 2; grid-row: 1 / span 2; }
.sugg-label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sugg-increase { border-color: var(--up); }
.sugg-increase strong { color: var(--up); }
.sugg-repeat { border-color: var(--same); }
.sugg-repeat strong { color: var(--same); }
.sugg.compact { padding: 8px 10px; border-width: 1px; }
.sugg.compact strong { font-size: 15px; }
.sugg-text.sugg-increase { color: var(--up); }
.sugg-text.sugg-repeat { color: var(--same); }
.sugg-text.sugg-start { color: var(--muted); }

.setlist { display: flex; flex-direction: column; gap: 6px; counter-reset: s; }
.setlist li { counter-increment: s; display: flex; align-items: center; justify-content: space-between; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 4px 4px 4px 14px; font-size: 19px; font-variant-numeric: tabular-nums; }
.setlist li::before { content: counter(s); color: var(--muted); font-size: 14px; width: 22px; }
.setlist li span { flex: 1; }
.icon { background: none; border: 0; color: var(--muted); font-size: 18px; min-width: 48px; min-height: 44px; cursor: pointer; }

.logger { display: flex; flex-direction: column; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.setno { display: flex; justify-content: space-between; font-weight: 700; }
.rest { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.stepper { display: grid; grid-template-columns: 64px 1fr 64px; grid-template-rows: auto 64px; gap: 4px 8px; }
.stepper > span { grid-column: 1 / -1; color: var(--muted); font-size: 14px; }
.stepper button { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: var(--r); font-size: 30px; font-weight: 600; cursor: pointer; }
.stepper button:active { background: var(--line); }
.stepper input { text-align: center; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }

input:not([type=radio]) {
  width: 100%; min-height: 48px; padding: 8px 12px; margin-top: 4px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 18px;
}
.stepper input { margin: 0; height: 64px; }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; color: var(--muted); font-size: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.seg { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg legend { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 52px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); color: var(--text); font-size: 16px; font-weight: 600; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.add { display: flex; flex-direction: column; gap: 8px; }
.add[open] > summary { margin-bottom: 4px; }
.add > .btn { margin-top: 8px; }
.pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pick .btn { min-height: 56px; font-weight: 600; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }

.chart { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 8px 4px; }
.chart figcaption { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; padding: 0 6px 4px; }
.key { display: inline-block; width: 16px; height: 3px; border-radius: 2px; margin-left: 6px; }
.k-top { background: var(--accent); }
.k-e1rm { background: var(--same); }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.l-top, .l-e1rm { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.l-top { stroke: var(--accent); }
.l-e1rm { stroke: var(--same); stroke-dasharray: 5 4; }
.d-top { fill: var(--accent); }
.d-e1rm { fill: var(--same); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(20, 22, 28, .96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; min-height: 64px; color: var(--muted); font-size: 12px; }
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current] { color: var(--accent); }
.login { margin-top: 10vh; }

.catalog { display: flex; flex-direction: column; gap: 8px; }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.results:empty { display: none; }
.results button { display: grid; grid-template-columns: 52px 1fr; gap: 2px 10px; align-items: center; width: 100%; min-height: 60px; padding: 6px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); font: inherit; cursor: pointer; }
.results button:active { background: var(--panel-2); }
.results img, .results .noimg { grid-row: 1 / span 2; width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--panel-2); }
.results .nm { font-weight: 600; font-size: 16px; }
.results .meta { font-size: 13px; color: var(--muted); }
.results .empty { color: var(--muted); font-size: 14px; padding: 4px 2px; }
.linked { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.linked strong { color: var(--up); }
.linkish { background: none; border: 0; color: var(--accent); font: inherit; padding: 8px 4px; cursor: pointer; }
.info { display: flex; flex-direction: column; gap: 6px; }
.imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.imgs img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: #fff; }
.howto { padding-left: 20px; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.linked[hidden] { display: none; }
