/* Экран входа */
  .gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--bg); z-index: 20; }
  /* стикер выглядывает из-за карточки сверху */
  /* поле под стикер тянет группу вниз — компенсируем половиной, чтобы по центру была карточка */
  .gate-wrap { position: relative; max-width: 360px; width: 100%; padding-top: 128px; margin-top: -64px; }
  .gate-sticker {
    position: absolute; top: 0; left: 50%;
    width: 260px; max-width: 80%; height: auto; z-index: 0; pointer-events: none;
    filter: drop-shadow(0 6px 14px rgba(16, 32, 48, .18));
    /* сдвиг от курсора живёт в переменных, центрирование — в самом transform */
    --px: 0px; --py: 0px;
    transform: translate(calc(-50% + var(--px)), var(--py));
    transition: transform .25s cubic-bezier(.22, .61, .36, 1);
    will-change: transform;
  }
  @media (prefers-reduced-motion: reduce) { .gate-sticker { transition: none; } }
  .gate-card {
    position: relative; z-index: 1; container-type: inline-size;
    width: 100%; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-card); padding: 24px; text-align: left;
  }
  @media (min-width: 560px) { .gate-card { padding: 32px; } }
  /* заголовок считается от ширины карточки, поэтому пропорции не плывут */
  .gate-card h1 { margin-bottom: 0; font-size: 8vw; }
  @media (min-width: 560px) { .gate-card h1 { font-size: 30px; } }
  @supports (container-type: inline-size) {
    .gate-card h1 { font-size: clamp(22px, 10.2cqi, 30px); }
  }
  .gate-card p { font-size: 14px; }

  /* описание для поиска и человека */
  .err:empty { display: none; }   /* пустая строка ошибки добавляла лишний отступ */

  .gate-about { margin: 16px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
  .gate-about p { margin: 0; font-size: 14px; }
  /* кнопка Яндекс ID: тёмная версия с логотипом в круге, высота 44 */
  .btn.ya {
    margin-top: 20px; width: 100%; height: 44px; padding: 0 20px;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    background: var(--ya-bg); color: var(--ya-fg); font: 600 16px/1 var(--body);
  }
  .btn.ya:hover:not(:disabled) { background: var(--ya-bg-hover); }
  .btn.ya:disabled { opacity: .45; cursor: not-allowed; }
  .ya-logo { display: block; flex: none; border-radius: 50%; }   /* официальная иконка: квадрат скругляем в круг */

  /* запасной путь: второстепенная кнопка, чтобы вход Яндексом остался главным */
  .btn.tg {
    margin-top: 12px; width: 100%; height: 44px; padding: 0 20px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: transparent; color: var(--muted); border: 1px solid var(--line);
    font: 600 16px/1 var(--body); text-decoration: none;
  }
  .btn.tg:hover { color: var(--ink); border-color: var(--faded); }
  .tg-logo { display: block; flex: none; }

  /* согласие с политикой: пустой чекбокс по умолчанию, он и открывает вход */
  .consent {
    display: flex; gap: 10px; align-items: flex-start; margin-top: 16px;
    font-size: 13px; line-height: 1.4; color: var(--muted);
    position: relative; z-index: 1;   /* иначе соседний абзац перекрывает поле вокруг чекбокса */
  }
  /* Свой чекбокс. Сам элемент 36×36 и прозрачный — это область клика,
     видимый квадрат 20×20 рисуется внутри него. Отрицательные поля
     возвращают квадрат на место в строке. */
  .consent input {
    appearance: none; -webkit-appearance: none;
    flex: none; width: 36px; height: 36px; margin: -9px -8px 0 -8px; padding: 0;
    position: relative; background: none; border: 0; cursor: pointer;
    /* Lucide check (ISC) — тот же набор, что у крутилки синхронизации.
       Толщина 3 вместо 2: на 11px штатная линия выглядит слишком тонкой */
    --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  }
  .consent input::before {
    content: ""; position: absolute; left: 8px; top: 8px;
    width: 20px; height: 20px; box-sizing: border-box;
    border: 1.5px solid var(--line); border-radius: 6px; background: var(--bg);
    transition: background .12s, border-color .12s;
  }
  .consent input:hover::before { border-color: var(--faded); }
  .consent input:checked::before { background: var(--accent); border-color: var(--accent); }
  .consent input:checked::after {            /* галка ровно по центру поля */
    content: ""; position: absolute; inset: 0;
    background: var(--accent-ink);
    -webkit-mask: var(--tick) center / 11px 11px no-repeat;
            mask: var(--tick) center / 11px 11px no-repeat;
  }
  .consent input:focus-visible { outline: none; }
  .consent input:focus-visible::before { outline: 3px solid var(--accent); outline-offset: 2px; }
  .consent a {
    color: inherit; text-decoration: underline;
    text-decoration-thickness: 1px; text-underline-offset: 3px;
    text-decoration-skip-ink: none;          /* линия сплошная, не рвётся о «у» и «р» */
    text-decoration-color: color-mix(in srgb, currentColor 32%, transparent);
  }
  .consent a:hover {
    color: var(--ink);
    text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
  }

  .err { color: var(--red); margin-top: 12px; font-size: 14px; }
  /* прижата к нижнему краю окна, с учётом системных полос на телефоне */
  .policy {
    position: fixed; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    margin: 0; text-align: center; font-size: 12px;
  }
  .policy a { color: var(--faded); text-decoration: none; }
  .policy a:hover { color: var(--muted); }
  .policy .sep { margin: 0 8px; color: var(--line); }   /* разделитель тише ссылок */

  /* те же ссылки в подвале приложения — без выхода из аккаунта */
  .app-links {
    margin: 40px 0 calc(14px + env(safe-area-inset-bottom, 0px) - 48px);
    text-align: center; font-size: 12px;
  }
  .app-links a { color: var(--faded); text-decoration: none; }
  .app-links a:hover { color: var(--muted); }
  .app-links .sep { margin: 0 8px; color: var(--line); }
  .signout { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; line-height: 0; }
  .signout:hover { color: var(--ink); }
  .head { gap: 10px; }
  .head-tools { display: flex; align-items: center; gap: 18px; margin-top: 6px; }

  /* Ввод максимума */
  .max {
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
    margin-top: 22px; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-card); padding: 10px;
  }
  .max button {
    width: 52px; height: 52px; border-radius: var(--r-control); border: 1px solid var(--line);
    background: var(--bg); font: 500 24px/1 var(--display); cursor: pointer;
  }
  .max input {
    width: 100%; text-align: center; border: 0; background: transparent;
    font: 700 44px/1 var(--display); -moz-appearance: textfield;
  }
  .max input::-webkit-outer-spin-button, .max input::-webkit-inner-spin-button { -webkit-appearance: none; }
  .max-label { text-align: center; margin-top: 6px; font-size: 14px; }

  /* Дорожка до 100 */
  .track { display: grid; grid-template-columns: repeat(25, 1fr); gap: 3px; margin-top: 18px; }
  .track i { height: 14px; border-radius: 2px; background: var(--line); transition: background .25s; }
  @media (min-width: 560px) { .track i { height: 22px; } }
  .track i.on { background: var(--accent); }
  .track i:nth-child(25n) { box-shadow: inset -2px 0 0 var(--tape); }
  .track-cap { display: flex; justify-content: space-between; font-size: 14px; margin-top: 8px; }


  /* Плашка. Вылет за сетку гасится равным внутренним отступом, поэтому
     содержимое любой плашки стоит на одной вертикали с остальным текстом. */
  .note, .donate, .tg-box, .day.today {
    margin-left: -16px; margin-right: -16px; padding: 16px;
    border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line);
  }
  /* Заголовок, текст и кнопка у всех плашек одинаковые */
  .note-head, .donate h3, .tg-box h3 { font: 600 16px/1.4 var(--body); margin: 0 0 6px; display: block; }
  .note p, .donate p, .tg-box p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
  .note .btn, .donate .btn, .tg-box .btn {
    display: inline-block; margin-top: 14px; padding: 9px 18px;
    font-size: 16px; text-decoration: none;
  }

  /* Сообщение о состоянии плана: приглушённая заливка и такая же рамка —
     пара, которой в дизайн-системах помечают информационные блоки */
  .note {
    margin-top: 16px;
    background: var(--warn-bg); border-color: var(--warn-line);
  }
  /* текст остаётся в общих цветах: цвет несёт только заливка */
  .note .btn.quiet { border-color: var(--warn-line); }
  .note .btn.quiet:hover { border-color: var(--warn-ink); }

  /* План недели */
  .week { list-style: none; margin: 0; padding: 0; }
  .day {
    /* последняя колонка ровно по ширине галочки: её край — край сетки */
    display: grid; grid-template-columns: 32px minmax(0, 1fr) 30px; gap: 8px; align-items: start;
    padding: 18px 0; border-bottom: 1px solid var(--line); position: relative;
  }
  /* 4. выделенный день — карточка со скруглением как у поля ввода */
  .day.today { margin-top: 6px; margin-bottom: 6px; }
  /* Прошедшие и отмеченные дни уходят на второй план цветом, без прозрачности */
  .day.past .dtitle, .day.past .dmain { color: var(--faded); }
  .day.past .dnote { color: var(--faded); }
  .day:has(+ .day.today) { border-bottom-color: transparent; }   /* линия не упирается в карточку */
  .dname { font: 600 16px/1.5 var(--body); color: var(--muted); }
  .dtitle { font: 600 16px/1.5 var(--body); overflow-wrap: anywhere; }
  /* отступ живёт у заголовка, иначе при переносе тег уезжает с лишним зазором */
  .dtitle-text { margin-right: 8px; }
  .dmain { font: 600 19px/1.3 var(--body); margin: 2px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
  .dnote { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
  /* счётчик подходов в дне объёма */
  .vol { margin-top: 14px; }
  .vol-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
  .vol-bar i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
  .vol-sum { margin-top: 8px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .vol-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
  .vol-in {
    width: 58px; height: 36px; padding: 0 6px; text-align: center; border-radius: var(--r-control);
    border: 1px solid var(--line); background: var(--bg); font: 600 16px/1 var(--body);
    font-variant-numeric: tabular-nums; -moz-appearance: textfield;
  }
  .vol-in::-webkit-outer-spin-button, .vol-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
  .vol-add { height: 36px; padding: 0 14px; border-radius: var(--r-control); font: 600 14px/1 var(--body); white-space: nowrap; }
  .vol-undo {
    height: 36px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
    font: 500 14px/1 var(--body); padding: 0 6px; white-space: nowrap;
  }
  .vol-undo:hover { color: var(--ink); }

  /* подсказка на случай, когда план не по силам */
  .dtip {
    margin-top: 16px; padding: 8px 12px; border-radius: var(--r-control);
    background: var(--bg); color: var(--muted); font-size: 13px;
  }
  /* мягкий тег: подложка из акцента, текст акцентом */
  .today-tag {
    display: inline-block; padding: 3px 7px 4px; border-radius: var(--r-tag);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent); font: 600 13px/1 var(--body); vertical-align: 1px;
  }

  /* Галочка выполнения */
  .chk {
    position: relative; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line);
    background: transparent; padding: 0; display: grid; place-items: center; justify-self: end;
    cursor: pointer; color: var(--muted); margin-top: 2px; -webkit-tap-highlight-color: transparent;
  }
  .chk::before { content: ""; position: absolute; top: -10px; right: -10px; bottom: -10px; left: -10px; } /* палец попадает точнее */
  .chk svg { pointer-events: none; }   /* клик всегда достаётся кнопке */
  .chk:not([disabled]):active { transform: scale(.92); }
  .chk[disabled] { cursor: default; border-style: dashed; color: var(--faded); }
  .chk.missed { border-color: var(--line); color: var(--muted); border-style: solid; }
  .chk.done { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  /* прошедший день закрыт — заливка третьего уровня: видно, но не спорит с сегодняшним */
  .day.past .chk.done { background: var(--line); border-color: var(--line); color: var(--muted); }

  .day.checked .dtitle, .day.checked .dmain, .day.checked .dnote { color: var(--faded); transition: color .25s; }

  /* Нажатие: галочка подпрыгивает, от неё расходится кольцо */
  .chk.pop { animation: chk-pop .38s cubic-bezier(.2, 1.4, .4, 1); }
  .chk.pop svg { animation: chk-tick .32s .04s backwards cubic-bezier(.2, 1.5, .4, 1); }
  .chk.pop::after {
    content: ""; position: absolute; inset: -4px; border-radius: 50%;
    border: 2px solid var(--accent); animation: chk-ring .5s ease-out forwards;
  }
  .day.past .chk.pop::after { border-color: var(--muted); }   /* у прошедших дней всплеск тоже спокойный */
  @keyframes chk-pop { 0% { transform: scale(.7); } 55% { transform: scale(1.18); } 100% { transform: scale(1); } }
  @keyframes chk-tick { from { transform: scale(0) rotate(-25deg); opacity: 0; } to { transform: none; opacity: 1; } }
  @keyframes chk-ring { from { opacity: .55; transform: scale(.85); } to { opacity: 0; transform: scale(1.9); } }
  @media (prefers-reduced-motion: reduce) {
    .chk.pop, .chk.pop svg, .chk.pop::after { animation: none; }
  }
  .chk svg { display: block; pointer-events: none; }

  .btn { padding: 10px 16px; border-radius: var(--r-control); border: 0; cursor: pointer; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
  .btn.fill { background: var(--line); color: var(--ink); }
  /* тихая кнопка: та же геометрия, что у основной, но без заливки */
  .btn.quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
  .btn.quiet:hover { border-color: var(--faded); }
  .btn.fill:hover { filter: brightness(.97); }

  /* История тестов */
  .hist { list-style: none; margin: 0; padding: 0; }
  .hist-sum:empty { display: none; }
  .hist-sum { display: flex; align-items: baseline; gap: 8px; font-size: 14px; color: var(--muted); margin: -4px 0 10px; }
  .hist-sum .arrow { flex: none; align-self: center; color: var(--faded); }
  .hist-sum b { font: 600 16px/1.4 var(--body); color: var(--ink); }

  /* график роста по тестам */
  .hist-chart { margin: 2px 0 16px; }
  .spark { display: block; width: 100%; height: 70px; }
  .spark-line {
    fill: none; stroke: var(--accent); stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  }
  .spark-area { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: none; }

  .hist li {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 14px 0; font-variant-numeric: tabular-nums;
  }
  /* линия сверху, а не снизу: под последней видимой строкой её не остаётся
     ни когда список свёрнут, ни когда раскрыт */
  .hist li + li { border-top: 1px solid var(--line); }
  /* свежие тесты сверху, хвост списка раскрывается кнопкой */
  .hist li.more { display: none; }
  .hist.open li.more { display: flex; }
  .hist-more {
    display: block; width: 100%; margin-top: 14px; height: 40px; padding: 0 16px;
    border: 1px solid var(--line); border-radius: var(--r-control);
    background: transparent; color: var(--muted);
    font: 600 14px/1 var(--body); cursor: pointer;
  }
  .hist-more:hover { color: var(--ink); border-color: var(--faded); }
  .hist-more[hidden] { display: none; }

  .hist b { font: 600 16px/1.4 var(--body); min-width: 26px; text-align: right; }
  .hist-val { display: inline-flex; align-items: center; gap: 6px; }
  /* дельта к прошлому тесту — пилюлей */
  .diff {
    font: 600 13px/1.4 var(--body); font-style: normal;
    padding: 2px 8px; border-radius: var(--r-tag); white-space: nowrap;
  }
  .diff.up { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
  .diff.down { color: var(--red); background: color-mix(in srgb, var(--red) 14%, transparent); }
  .diff.flat { color: var(--faded); background: color-mix(in srgb, var(--faded) 14%, transparent); }
  /* крестик удаления — как у пропущенного дня, только без кружка */
  .hist .del {
    border: 0; background: transparent; padding: 6px; cursor: pointer;
    color: var(--muted); display: inline-flex; align-items: center; line-height: 0;
  }
  .hist .del:hover { color: var(--ink); }
  .hist .del svg { display: block; pointer-events: none; }

  /* Полезное — короткая справка в конце страницы */
  .tips { list-style: none; margin: 0; padding: 0; }
  .tips li { padding: 16px 0; border-bottom: 1px solid var(--line); }
  .tips li:last-child { border-bottom: 0; }
  .tips b { display: block; font: 600 16px/1.4 var(--body); margin-bottom: 3px; }
  .tips span { font-size: 14px; color: var(--muted); }

  @media (prefers-reduced-motion: reduce) { .track i { transition: none; } }

  /* Блок с поддержкой проекта */
  .donate { margin-top: 52px; }


  /* Подключение Telegram */
  .tg-box { margin-top: 24px; }
  .tg-box .tg-state { margin-top: 12px; font-size: 13px; }
  .tg-box .tg-state:empty { display: none; }
  .tg-box .tg-state.err { color: var(--red); }

  /* отступ держит ряд, а не кнопки: при переносе они не разъезжаются по вертикали */
  .merge-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
  .merge-row .btn { margin-top: 0; font-size: 16px; padding: 9px 18px; }

  /* кнопка в работе: крутилка вместо текста */
  .btn.busy { position: relative; color: transparent; pointer-events: none; }
  .btn.busy::after {
    content: ""; position: absolute; inset: 0; margin: auto;
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid currentColor; border-top-color: transparent;
    color: var(--accent-ink); animation: spin .7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* подсказка во встроенном браузере */
  .inapp { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-control); }
  .inapp p { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
  .inapp-row { display: flex; gap: 6px; }
  .inapp-row input {
    flex: 1; min-width: 0; height: 36px; padding: 0 10px; border-radius: var(--r-control);
    border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 400 13px/1 var(--body);
  }
  .inapp-row .btn { height: 36px; padding: 0 12px; font-size: 13px; white-space: nowrap; }

