/* «Второй» — мини-приложение в цветах Телеграма. Цвета берём из темы (--tg-theme-*), запасные — для обычного браузера.
   Отступы — шаг 8. Шрифт — системный, как у самого Телеграма. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #F2F2F7);
  --sec: var(--tg-theme-section-bg-color, #FFFFFF);
  --tx: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8E8E93);
  --acc: var(--tg-theme-button-color, #2481CC);
  --acc-tx: var(--tg-theme-button-text-color, #FFFFFF);
  --link: var(--tg-theme-link-color, #2481CC);
  --red: var(--tg-theme-destructive-text-color, #E5393A);
  --sep: var(--tg-theme-section-separator-color, #E1E1E6);
  --head: var(--tg-theme-section-header-text-color, #6D6D72);
  --chip: color-mix(in srgb, var(--tx) 7%, var(--sec));
  --green: #34C759;
  --dot: #FF6B5A;
  --r: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #000000; --sec: #1C1C1E; --tx: #FFFFFF; --hint: #8E8E93; --acc: #3E88F7; --link: #3E88F7;
    --red: #FF453A; --sep: #2C2C2E; --head: #8E8E93;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--tx); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Segoe UI", "Helvetica Neue", sans-serif;
  font-variant-numeric: lining-nums tabular-nums;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
body.deep { padding-bottom: 24px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
#app { max-width: 640px; margin: 0 auto; }

/* шапка экрана */
.head { padding: 16px 16px 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.h1 { font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
.sub { font-size: 14px; color: var(--hint); margin-top: 4px; }
.logo { font-weight: 700; font-size: 16px; }
.logo i { font-style: normal; color: var(--dot); }

/* поле ввода сверху */
.ask { margin: 8px 16px 0; display: flex; gap: 8px; align-items: center; background: var(--chip); border-radius: 10px; padding: 0 12px; }
.ask svg { width: 18px; height: 18px; flex: none; stroke: var(--hint); fill: none; stroke-width: 2; stroke-linecap: round; }
.ask input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 11px 0; font-size: 16px; outline: none; }
.ask input::placeholder { color: var(--hint); }

/* разделы */
.cap { margin: 24px 16px 8px; padding: 0 16px; font-size: 13px; color: var(--head); text-transform: uppercase; letter-spacing: 0.04em; display: flex; justify-content: space-between; }
.cap button { color: var(--link); text-transform: none; letter-spacing: 0; font-size: 14px; }
.grp { margin: 0 16px; background: var(--sec); border-radius: var(--r); overflow: hidden; }
.note { margin: 8px 32px 0; font-size: 13px; color: var(--hint); }

/* строки */
.row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 16px; background: var(--sec); border-bottom: 0.5px solid var(--sep); width: 100%; text-align: left; }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .ttl { font-size: 16px; overflow-wrap: anywhere; }
.row .meta { font-size: 13px; color: var(--hint); margin-top: 2px; }
.row .end { margin-left: auto; color: var(--hint); font-size: 15px; white-space: nowrap; }
.row .chev::after { content: "›"; margin-left: 8px; font-size: 20px; line-height: 1; }
.row.link { color: var(--link); justify-content: center; }
.row.danger { color: var(--red); justify-content: center; }
.tm { width: 48px; flex: none; font-size: 14px; font-weight: 600; color: var(--link); }
.tm.no { color: var(--hint); font-weight: 400; }
.ck { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 1.5px solid var(--hint); display: grid; place-items: center; }
.ck.on { background: var(--green); border-color: var(--green); }
.ck.on::after { content: ""; width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.done .ttl { color: var(--hint); text-decoration: line-through; }
.red { color: var(--red); }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--hint); margin-left: 8px; }

/* свайп по делу */
.swipe { position: relative; overflow: hidden; border-bottom: 0.5px solid var(--sep); }
.swipe:last-child { border-bottom: 0; }
.swipe .row { border-bottom: 0; transition: transform .2s ease; touch-action: pan-y; }
.swipe .bgL, .swipe .bgR { opacity: 0; position: absolute; inset: 0; display: flex; align-items: center; padding: 0 24px; color: #fff; font-weight: 600; font-size: 15px; }
.swipe .bgL { background: var(--green); }
.swipe .bgR { background: var(--acc); justify-content: flex-end; }

/* «следующее» */
.next { margin: 0 16px; background: var(--sec); border-radius: var(--r); padding: 16px; display: block; width: calc(100% - 32px); text-align: left; }
.next .when { font-size: 14px; font-weight: 600; color: var(--link); }
.next .what { font-size: 20px; font-weight: 600; margin-top: 4px; line-height: 1.25; overflow-wrap: anywhere; }
.empty { margin: 32px 32px 0; text-align: center; color: var(--hint); font-size: 15px; line-height: 1.5; text-wrap: pretty; }
.empty b { display: block; color: var(--tx); font-size: 17px; margin-bottom: 8px; font-weight: 600; }

/* неделя */
.week { margin: 8px 16px 0; background: var(--sec); border-radius: var(--r); display: grid; grid-template-columns: repeat(7, 1fr); padding: 8px 4px; }
.week button { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--hint); padding: 4px 0; }
.week .d { width: 32px; height: 32px; line-height: 32px; border-radius: 50%; font-size: 16px; font-weight: 600; color: var(--tx); text-align: center; }
.week .on .d { background: var(--acc); color: var(--acc-tx); }
.week .dots { height: 6px; display: flex; gap: 2px; }
.week .dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--hint); }
.seg { margin: 16px 16px 0; display: flex; background: var(--chip); border-radius: 9px; padding: 2px; }
.seg button { flex: 1; padding: 6px 4px; border-radius: 7px; font-size: 14px; }
.seg .on { background: var(--sec); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.08); }

/* память */
.answer { margin: 0 16px; background: var(--sec); border-radius: var(--r); padding: 16px; font-size: 16px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer .src { display: block; font-size: 13px; color: var(--hint); margin-top: 8px; }
.people { display: flex; gap: 16px; overflow-x: auto; padding: 0 16px; scrollbar-width: none; }
.people button { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; min-width: 56px; }
.ava { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 20px; }

/* деньги */
.big { font-size: 36px; font-weight: 700; line-height: 1.1; margin-top: 4px; }
.bar { height: 6px; border-radius: 3px; background: var(--chip); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--acc); border-radius: 3px; }
.cat { padding: 12px 16px; border-bottom: 0.5px solid var(--sep); }
.cat:last-child { border-bottom: 0; }
.cat .line { display: flex; justify-content: space-between; font-size: 15px; }
.cat .line span:last-child { color: var(--hint); }

/* формы в карточке */
.field { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; border-bottom: 0.5px solid var(--sep); }
.field:last-child { border-bottom: 0; }
.field label { flex: none; font-size: 16px; }
.field input, .field select { flex: 1; min-width: 0; text-align: right; border: 0; background: transparent; font-size: 16px; color: var(--link); padding: 12px 0; outline: none; -webkit-appearance: none; appearance: none; }
.title-in { width: 100%; border: 0; background: transparent; font-size: 20px; font-weight: 600; padding: 16px; outline: none; }
textarea.big-in { width: 100%; min-height: 160px; border: 0; background: transparent; padding: 16px; font-size: 16px; line-height: 1.5; resize: vertical; outline: none; }
.lead { margin: 16px 32px 0; font-size: 16px; line-height: 1.5; text-wrap: pretty; }
.lead.sm { font-size: 14px; color: var(--hint); }
.btn { display: block; margin: 16px; padding: 14px; border-radius: var(--r); background: var(--acc); color: var(--acc-tx); font-weight: 600; text-align: center; width: calc(100% - 32px); font-size: 16px; }
.btn.ghost { background: var(--sec); color: var(--link); }
.tg-main .btn.main { display: none; } /* в Телеграме — его нижняя кнопка */

/* нижние вкладки */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: var(--sec); border-top: 0.5px solid var(--sep); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); z-index: 5; }
#tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--hint); min-width: 64px; }
#tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs .on { color: var(--acc); }
body.deep #tabs { display: none; }

/* всплывашка и выезжающая панель */
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 480px; background: color-mix(in srgb, var(--tx) 88%, transparent); color: var(--sec); border-radius: var(--r); padding: 12px 16px; font-size: 15px; display: flex; gap: 16px; align-items: center; justify-content: space-between; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; z-index: 20; white-space: pre-wrap; }
#toast.show { opacity: 1; transform: none; pointer-events: auto; }
#toast button { color: var(--dot); font-weight: 600; flex: none; }
#sheet-back { position: fixed; inset: 0; background: rgb(0 0 0 / 0.35); opacity: 0; pointer-events: none; transition: .2s; z-index: 10; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-radius: 16px 16px 0 0; padding: 8px 0 calc(16px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .25s ease; z-index: 11; max-width: 640px; margin: 0 auto; }
body.sheet #sheet-back { opacity: 1; pointer-events: auto; }
body.sheet #sheet { transform: none; }
#sheet .grip { width: 36px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 8px; }
#sheet .cap { margin-top: 8px; }

.spin { margin: 64px auto; width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--sep); border-top-color: var(--acc); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* голос — главная кнопка */
.mic { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.mic button.round { width: 72px; height: 72px; border-radius: 50%; background: var(--acc); color: var(--acc-tx); display: grid; place-items: center; box-shadow: 0 4px 16px color-mix(in srgb, var(--acc) 35%, transparent); transition: transform .15s ease, background .2s; }
.mic button.round:active { transform: scale(.94); }
.mic svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mic .lbl { white-space: nowrap; font-size: 13px; color: var(--hint); background: var(--bg); padding: 2px 8px; border-radius: 999px; }
.mic.rec button.round { background: var(--red); animation: pulse 1.2s ease-out infinite; }
.mic.busy button.round { opacity: .6; pointer-events: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 45%, transparent); } 100% { box-shadow: 0 0 0 22px transparent; } }
body.has-mic { padding-bottom: calc(176px + env(safe-area-inset-bottom)); }
body.has-mic #toast { bottom: calc(176px + env(safe-area-inset-bottom)); }
.heard { margin: 0 16px; padding: 12px 16px; border-radius: var(--r); background: var(--chip); font-size: 15px; color: var(--hint); font-style: italic; overflow-wrap: anywhere; }
.reply { margin: 8px 16px 0; padding: 16px; border-radius: var(--r); background: var(--sec); font-size: 16px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

/* --- стиль: приветствие, кольцо дня, плавность --- */
.hello { font-size: 15px; color: var(--hint); margin-bottom: 2px; }
.ring { width: 52px; height: 52px; position: relative; flex: none; }
.ring svg { width: 52px; height: 52px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring .bg { stroke: var(--chip); }
.ring .fg { stroke: var(--green); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.next { position: relative; overflow: hidden; padding-left: 20px; }
.next::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--acc); }
.next .when { display: flex; align-items: center; gap: 8px; }
.next .soon { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--acc) 14%, transparent); color: var(--link); font-weight: 600; }
.fade { animation: fade .22s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.gone { transition: opacity .2s ease, max-height .25s ease, padding .25s ease; opacity: 0; max-height: 0 !important; overflow: hidden; }
.skel { margin: 16px; display: grid; gap: 8px; }
.skel i { display: block; height: 48px; border-radius: var(--r); background: linear-gradient(90deg, var(--sec) 0%, var(--chip) 50%, var(--sec) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skel i:first-child { height: 72px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty .ico { width: 64px; height: 64px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; margin: 0 auto 16px; }
.empty .ico svg { width: 30px; height: 30px; fill: none; stroke: var(--hint); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.week .today .d { box-shadow: inset 0 0 0 1.5px var(--acc); }
.mic .halo { position: absolute; width: 72px; height: 72px; border-radius: 50%; background: color-mix(in srgb, var(--red) 30%, transparent); transform: scale(1); transition: transform .08s linear; pointer-events: none; }
.mic { --lvl: 1; }
.mic .wrap { position: relative; display: grid; place-items: center; }
.mic .halo { opacity: 0; }
.mic.rec .halo { opacity: 1; transform: scale(var(--lvl)); }
.mic.rec button.round { animation: none; }

/* аудит 12.10: цели нажатия ≥ 44 px */
.ck { position: relative; }
.ck::before { content: ""; position: absolute; inset: -10px; }
.row > button.main { align-self: stretch; display: flex; flex-direction: column; justify-content: center; min-height: 44px; }
#tabs button { min-height: 44px; justify-content: center; }
