/* Главный экран. Общие величины и компоненты новой системы. */
:root {
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px; --s6: 40px; --s7: 48px;
  --radius: 16px;
  --radius-s: 12px;
  --hit: 48px;
  --fast: 160ms;
  --slow: 240ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.dm { font: 400 16px/24px var(--font); }
.dm h1, .dm h2, .dm p, .dm dl, .dm dd, .dm ol, .dm ul { margin: 0; padding: 0; }
.dm button, .dm a { font: inherit; color: inherit; }
.dm button { border: 0; border-radius: 0; min-height: 0; padding: 0; background: none; cursor: pointer; text-align: start; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.d-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --- каркас --- */
.d-screen {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--s3) + var(--safe-top)) var(--s3) calc(88px + var(--safe-bottom));
}
.d-stack > * + * { margin-top: var(--s3); }
.dm .d-card { background: var(--surface); border-radius: var(--radius); padding: var(--s3); }
.dm .d-card.d-flush { padding: 0; overflow: hidden; }
.dm .d-title { font-size: 20px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; }
.dm .d-label { color: var(--muted); font-size: 14px; line-height: 20px; }
.dm .d-section { display: flex; align-items: baseline; justify-content: space-between; padding: var(--s2) var(--s1) 0; }
.dm .d-section h2 { font-size: 16px; line-height: 24px; font-weight: 600; }

/* --- шапка --- */
.dm .d-greeting { display: flex; align-items: center; gap: var(--s3); padding: var(--s1) var(--s1) var(--s2); }
.dm .d-greeting img { flex: none; width: var(--s7); height: var(--s7); border-radius: 50%; }
.dm .d-greeting > div { min-width: 0; }
.dm .d-greeting .d-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* Знак бота: форма в accent.svg, цвет из theme.css */
.accent-icon { flex: none; width: 40px; height: 40px; background: var(--theme-gold); -webkit-mask: url("accent.svg") center / contain no-repeat; mask: url("accent.svg") center / contain no-repeat; }
.dm .d-greeting > .accent-icon { margin-inline-start: auto; }
.dm .d-empty .accent-icon { margin: 0 auto var(--s2); }

/* --- главная цифра --- */
.dm .d-today { display: flex; align-items: end; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s3) 0; }
.dm .d-figure { font-size: 56px; line-height: 56px; font-weight: 600; letter-spacing: -0.03em; margin: var(--s1) 0; }
.dm .d-figure.d-long { font-size: 48px; }
.dm .d-today > .d-label { padding-bottom: var(--s2); white-space: nowrap; }

/* 7 столбцов по 44 px и шире: каждый можно нажать пальцем даже на экране 360 px */
.dm .d-chart { display: flex; align-items: end; height: 96px; margin: var(--s2) 0 var(--s3); }
.dm .d-chart button { flex: 1; height: 100%; min-width: 0; display: flex; flex-direction: column; justify-content: end; align-items: center; border-radius: var(--s2); }
.dm .d-chart i { display: block; width: 16px; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--bar); transition: opacity var(--fast) var(--ease); transform-origin: bottom; animation: grow var(--slow) var(--ease) backwards; }
.dm .d-chart .d-now i { background: var(--bar-now); }
.dm .d-chart [aria-pressed="true"] i { outline: 2px solid var(--text); outline-offset: 2px; }
.dm .d-chart span { width: 100%; padding-top: var(--s1); border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 16px; text-align: center; }
.dm .d-chart .d-now span { color: var(--text); font-weight: 600; }
@keyframes grow { from { transform: scaleY(0); } }

.dm .d-facts { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.dm .d-fact { display: block; width: 100%; min-height: 72px; padding: var(--s2) var(--s3); text-decoration: none; }
.dm .d-fact + .d-fact { border-inline-start: 1px solid var(--line); }
.dm .d-fact b { display: flex; align-items: center; gap: var(--s1); font-size: 24px; line-height: 32px; font-weight: 600; letter-spacing: -0.01em; }
.dm .d-fact b .icon { margin-inline-start: auto; color: var(--muted); }
.dm .d-fact.d-hot b { color: var(--brand); }

/* --- внимание --- */
.dm .d-notice { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 64px; padding: var(--s3); border-radius: var(--radius); background: var(--brand-soft); color: var(--brand-on-soft); }
.dm .d-notice b { display: block; font-weight: 600; }
.dm .d-notice > span { flex: 1; min-width: 0; }
.dm .d-notice .d-one { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm .d-notice small { display: block; font-size: 14px; line-height: 20px; color: var(--text); }

/* --- список каналов --- */
.dm .d-rows { list-style: none; }
.dm .d-row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 72px; padding: var(--s2) var(--s3); text-decoration: none; transition: background var(--fast) var(--ease); }
.dm .d-row:active, .dm .d-fact:is(button):active { background: var(--fill); }
.dm .d-rows li + li .d-row { position: relative; }
.dm .d-rows li + li .d-row::before { content: ""; position: absolute; inset: 0 0 auto 76px; border-top: 1px solid var(--line); }
.dm .d-row .d-body { flex: 1; min-width: 0; }
.dm .d-row .d-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-weight: 600; }
.dm .d-row > .icon { color: var(--muted); }
.dm .d-row[disabled] { cursor: default; }
.dm .d-row[disabled] .d-name { color: var(--muted); }
.dm .d-monogram { display: grid; flex: none; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-s); background: var(--fill); font-size: 18px; font-weight: 600; }
.dm .d-monogram.d-add { background: none; box-shadow: inset 0 0 0 1px var(--line); }
.dm .d-state { display: flex; align-items: center; gap: var(--s1); color: var(--muted); font-size: 14px; line-height: 20px; }
.dm .d-state.d-good .icon { color: var(--good); }
.dm .d-state.d-warn { color: var(--warn); }
.dm .d-state.d-bad { color: var(--brand); }
.dm .d-state .icon { align-self: start; margin-top: 2px; }
.dm .d-gain { color: var(--text); white-space: nowrap; }

/* --- кнопка --- */
.dm .d-button { display: flex; align-items: center; justify-content: center; gap: var(--s2); width: 100%; min-height: var(--hit); padding: 12px var(--s3); border-radius: var(--radius-s); background: var(--primary); color: var(--primary-ink); font-weight: 600; text-align: center; text-decoration: none; transition: transform var(--fast) var(--ease), opacity var(--fast) var(--ease); }
.dm .d-button:active { transform: scale(0.98); opacity: 0.9; }

/* --- пустое состояние и ошибка --- */
.dm .d-empty { padding: var(--s5) var(--s3) var(--s4); text-align: center; }
.dm .d-empty img { width: 128px; height: 128px; border-radius: 50%; margin-bottom: var(--s4); }
.dm .d-empty .d-title { font-size: 24px; line-height: 32px; }
.dm .d-empty p { max-width: 32ch; margin: var(--s2) auto var(--s4); color: var(--muted); }
.dm .d-steps { list-style: none; counter-reset: step; }
.dm .d-steps li { counter-increment: step; position: relative; padding: 0 0 var(--s3) var(--s6); }
.dm .d-steps li:last-child { padding-bottom: 0; }
.dm .d-steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1.500px var(--gold); font-size: 14px; line-height: 24px; font-weight: 600; text-align: center; }
.dm .d-steps li:not(:last-child)::after { content: ""; position: absolute; left: 11.500px; top: 28px; bottom: 4px; border-left: 1px solid var(--line); }
.dm .d-steps b { font-weight: 600; }
.dm .d-sign { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto var(--s3); border-radius: 50%; background: var(--fill); }

/* --- скелетон --- */
.dm .d-bone { border-radius: var(--s2); background: var(--bone); animation: breathe 1.6s ease-in-out infinite; }
.dm .d-on-page .d-bone { background: var(--line); }
@keyframes breathe { 50% { opacity: 0.5; } }

/* --- реклама (только Free) --- */
.dm .d-ad { white-space: pre-line; }

.d-enter > * { animation: enter var(--slow) var(--ease) backwards; }
.d-enter > :nth-child(2) { animation-delay: 30ms; }
.d-enter > :nth-child(n + 3) { animation-delay: 60ms; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }
.dm h1.d-title, .dm .d-empty .d-title { font-family: var(--font); }
@media (prefers-reduced-motion: reduce) { .dm *, .dm *::before { animation: none !important; transition: none !important; } }
