/* Фирменные цвета студии, тема Telegram не влияет */
:root {
  --app: #F6F6F6;
  --paper: #FFFFFF;
  --ink: #3C3D41;
  --ink-2: #6B6A72;
  --ink-3: #9A99A0;
  --line: #E6E2E6;
  --pink: #EB649B;
  --pink-ink: #B53B6E;
  --pink-soft: #FCE4EF;
  --pink-mist: #FDF2F7;
  --graphite: #3C3D41;
  --on-dark: #F6F6F6;
  --ok: #2E8A5F;
  --warn-bg: #FBF1D9;
  --warn-ink: #7A5B0E;
  --display: "Montserrat", "Arial Narrow", Arial, sans-serif;
  --body: "Onest", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --tabs-h: 62px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--app); color: var(--ink); }
body { font-family: var(--body); font-size: 15px; line-height: 1.45; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--pink-ink); }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
[hidden] { display: none !important; }

.demo { background: var(--graphite); color: var(--on-dark); font-size: 12.5px; padding: 9px 16px; text-align: center; }
.loading { padding: 40vh 0 0; text-align: center; color: var(--ink-3); }

.view {
  max-width: 560px; margin: 0 auto;
  padding: 18px 16px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

/* Типографика */
.h1 { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.1; margin: 0; text-wrap: balance; }
.h2 { font-family: var(--display); font-weight: 700; font-size: 18px; line-height: 1.2; margin: 10px 0 0; }
.h3 { font-family: var(--display); font-weight: 700; font-size: 15.5px; line-height: 1.25; margin: 0; }
.muted { color: var(--ink-2); font-size: 13.5px; margin: 0; }
.tiny { color: var(--ink-3); font-size: 12px; margin: 0; }
.text { font-size: 15px; line-height: 1.6; margin: 0; white-space: pre-line; }
.num { font-variant-numeric: tabular-nums; }

/* Главный элемент: день марафона */
.day-head { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: end; padding: 4px 2px 0; }
.day-head__n { font-family: var(--display); font-weight: 800; font-size: 76px; line-height: .82; letter-spacing: -.04em; color: var(--ink); grid-row: span 2; }
.day-head__of { font-size: 13px; color: var(--ink-2); }
.day-head__title { font-family: var(--display); font-weight: 700; font-size: 19px; line-height: 1.15; }

.grid28 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 2px; }
.grid28 i {
  aspect-ratio: 1.45; border-radius: 7px; background: var(--paper); border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.grid28 i::after { content: ""; position: absolute; inset: 0; background: var(--pink); opacity: var(--f, 0); }
.grid28 i.is-today { border: 2px solid var(--pink-ink); }
.grid28 i.is-future { background: transparent; border-style: dashed; }
.grid28__legend { font-size: 11.5px; color: var(--ink-3); padding: 4px 2px 0; margin: 0; }
.seg--sm { flex: none; }
.seg--sm button { padding: 6px 12px; font-size: 13px; }

/* Поверхности */
.panel { background: var(--paper); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); }
.panel--pink { background: var(--pink-mist); border-color: var(--pink-soft); }
.panel--dark { background: var(--graphite); color: var(--on-dark); border-color: var(--graphite); }
.panel--dark .muted { color: #CFCDD3; }
.task { background: var(--pink-soft); color: #6F2446; border-radius: 12px; padding: 11px 13px; font-size: 14.5px; line-height: 1.5; }
.task b { font-weight: 600; }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }
.lock { display: flex; gap: 10px; align-items: center; color: var(--ink-2); font-size: 13.5px; }
.lock svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; }

.more { background: none; border: 0; padding: 0; color: var(--pink-ink); font-weight: 600; font-size: 14px; cursor: pointer; align-self: flex-start; }
.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* Привычки */
.habits { display: flex; flex-direction: column; }
.habit { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; padding: 11px 2px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; width: 100%; }
.habit:first-child { border-top: 0; }
.habit__box { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; transition: background .15s, border-color .15s; }
.habit__box svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 3; opacity: 0; }
.habit[aria-pressed="true"] .habit__box { background: var(--pink); border-color: var(--pink); }
.habit[aria-pressed="true"] .habit__box svg { opacity: 1; }
.habit__title { font-weight: 600; font-size: 15px; display: block; }
.habit__hint { font-size: 12.5px; color: var(--ink-3); display: block; margin-top: 1px; }
.habit__new { font-size: 11px; font-weight: 600; color: var(--pink-ink); background: var(--pink-soft); border-radius: 99px; padding: 1px 7px; margin-left: 6px; vertical-align: 2px; }
.habit--shop { align-items: center; padding: 9px 2px; }
.habit--shop .spread { width: 100%; }
.habit--shop[aria-pressed="true"] .habit__title { color: var(--ink-3); text-decoration: line-through; }

/* Кнопки */
.btn { border: 0; border-radius: 14px; padding: 14px 16px; font-weight: 600; font-size: 15.5px; background: var(--pink); color: #fff; cursor: pointer; text-align: center; width: 100%; text-decoration: none; display: block; transition: transform .08s ease; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--ghost { background: var(--pink-soft); color: var(--pink-ink); }
.btn--line { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn--light { background: #fff; color: var(--graphite); }
.btn--sm { padding: 9px 12px; font-size: 14px; border-radius: 11px; width: auto; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .btn { flex: 1; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* Переключатели */
.seg { display: flex; background: #ECE9EC; border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 2px; font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(60, 61, 65, .12); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 7px 13px; font-size: 13.5px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--graphite); border-color: var(--graphite); color: #fff; }

/* Списки */
.list { display: flex; flex-direction: column; background: var(--paper); border-radius: 20px; border: 1px solid var(--line); overflow: hidden; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 13px 16px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; width: 100%; cursor: pointer; }
.item:first-child { border-top: 0; }
.item__k { font-size: 12px; color: var(--ink-3); }
.item__t { font-weight: 600; font-size: 15px; grid-column: 1; }
.item__s { font-size: 12.5px; color: var(--ink-2); grid-column: 1; }
.item__r { grid-row: 1 / span 3; grid-column: 2; color: var(--ink-3); font-size: 13px; text-align: right; }
.item--off { cursor: default; color: var(--ink-3); }
.item--off .item__t { color: var(--ink-3); }
.swap { color: var(--pink-ink); }

/* Тарелка */
.plate { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; }
.plate svg { width: 120px; height: 120px; }
.plate dl { margin: 0; display: grid; gap: 8px; }
.plate dt { font-weight: 700; font-family: var(--display); font-size: 14px; }
.plate dd { margin: 0; font-size: 13px; color: var(--ink-2); }

/* КБЖУ */
.kbju { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.kbju b { display: block; font-family: var(--display); font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; }
.kbju span { font-size: 12px; color: var(--ink-2); }
.kbju div:first-child b { color: var(--pink-ink); }

/* Рецепт */
.recipe ul, .recipe ol { margin: 0; padding-left: 20px; display: grid; gap: 5px; font-size: 14.5px; }
.facts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }

/* Тренировки */
.week { display: flex; flex-direction: column; gap: 8px; }
.wcard { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; text-align: left; width: 100%; cursor: pointer; }
.wcard__type { width: 44px; height: 44px; border-radius: 12px; background: var(--pink-soft); color: var(--pink-ink); display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: 17px; }
.wcard--done .wcard__type { background: var(--pink); color: #fff; }
.wcard--locked { cursor: default; opacity: .55; }
.wcard--locked .wcard__type { background: #ECE9EC; color: var(--ink-3); }
.exlist { counter-reset: ex; display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }
.exlist li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.exlist li::before { counter-increment: ex; content: counter(ex); font-family: var(--display); font-weight: 800; color: var(--pink); font-size: 18px; line-height: 1.2; }
.exlist b { display: block; font-weight: 600; }
.exlist span { font-size: 13.5px; color: var(--ink-2); }

/* Таймер: полноэкранный графит */
.timer { position: fixed; inset: 0; z-index: 60; background: var(--graphite); color: var(--on-dark); display: flex; flex-direction: column; padding: calc(18px + env(safe-area-inset-top)) 20px calc(22px + env(safe-area-inset-bottom)); }
.timer__top { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: #CFCDD3; }
.timer__x { background: none; border: 0; color: #CFCDD3; font-size: 15px; cursor: pointer; padding: 6px 0; }
.timer__main { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; text-align: center; }
.timer__phase { font-family: var(--display); font-weight: 700; font-size: 15px; padding: 5px 14px; border-radius: 99px; background: rgba(255, 255, 255, .1); }
.timer[data-kind="work"] .timer__phase { background: var(--pink); color: #fff; }
.timer__ring { position: relative; width: min(72vw, 300px); aspect-ratio: 1; }
.timer__ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer__ring circle { fill: none; stroke-width: 7; }
.timer__ring .bg { stroke: rgba(255, 255, 255, .12); }
.timer__ring .fg { stroke: var(--pink); stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.timer[data-kind="rest"] .timer__ring .fg, .timer[data-kind="warmup"] .timer__ring .fg { stroke: #CFCDD3; }
.timer__sec { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-weight: 800; font-size: clamp(72px, 26vw, 120px); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.timer__title { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.15; max-width: 22ch; }
.timer__how { font-size: 14.5px; color: #CFCDD3; max-width: 34ch; line-height: 1.5; }
.timer__next { font-size: 13.5px; color: #CFCDD3; }
.timer__ctrl { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 10px; }
.timer__ctrl button { border: 0; border-radius: 14px; padding: 15px 8px; font-weight: 600; font-size: 15px; cursor: pointer; background: rgba(255, 255, 255, .1); color: var(--on-dark); }
.timer__ctrl .go { background: #fff; color: var(--graphite); }

/* Прогресс */
.score { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score div { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.score b { display: block; font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score span { font-size: 12.5px; color: var(--ink-2); }
table.m { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.m th { font-weight: 500; color: var(--ink-3); font-size: 12px; text-align: right; padding: 0 0 6px; }
table.m th:first-child, table.m td:first-child { text-align: left; }
table.m td { text-align: right; padding: 8px 0; border-top: 1px solid var(--line); }
.delta { color: var(--ok); font-weight: 600; }
.board li { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14.5px; }
.board li:first-child { border-top: 0; }
.board { list-style: none; margin: 0; padding: 0; }
.board .me { font-weight: 700; color: var(--pink-ink); }
.board i { font-style: normal; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Формы */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13.5px; font-weight: 600; }
.field small { font-size: 12px; color: var(--ink-3); }
.input { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 11px 12px; font-size: 16px; width: 100%; }
.input:focus { border-color: var(--pink); outline: none; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { border: 1.5px solid var(--line); background: #fff; border-radius: 99px; padding: 8px 13px; font-size: 14px; cursor: pointer; }
.opt[aria-pressed="true"] { border-color: var(--pink); background: var(--pink-soft); color: var(--pink-ink); font-weight: 600; }
.opts--col { flex-direction: column; }
.opts--col .opt { border-radius: 12px; text-align: left; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.check input { width: 20px; height: 20px; accent-color: var(--pink); margin: 0; flex: none; }
.photos { display: flex; gap: 8px; align-items: center; }

/* Нижние вкладки */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { border: 0; background: none; height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--ink-3); cursor: pointer; }
.tabs svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--pink-ink); font-weight: 600; }

/* Шторка */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(40, 40, 44, .45); }
.sheet__panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--app); border-radius: 22px 22px 0 0; padding: 22px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; max-width: 560px; margin: 0 auto; animation: up .22s ease-out; }
.sheet__panel #sheetBody { display: flex; flex-direction: column; gap: 14px; }
.sheet__close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: #ECE9EC; font-size: 20px; cursor: pointer; line-height: 1; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; background: var(--graphite); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.habit--shop .tiny { color: var(--ink-2); font-size: 14px; white-space: nowrap; }
.dishes { margin: 0; display: grid; gap: 10px; }
.dishes dt { font-weight: 600; font-size: 14.5px; }
.dishes dd { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); }
.wcard__r { color: var(--ink-3); font-size: 15px; }
.wcard--done .wcard__r { color: var(--pink-ink); font-weight: 700; }
