/* Всё помню — Mini App. Цвета берутся из темы Telegram (--tg-theme-*), запасные — светлая тема. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111318);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --link: var(--tg-theme-link-color, #5B6CFF);
  --accent: var(--tg-theme-button-color, #5B6CFF);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --sep: color-mix(in srgb, var(--hint) 22%, transparent);
  --brand: linear-gradient(135deg, #5B6CFF 0%, #8E44EC 100%);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg2);
  color: var(--text);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

/* ---------- Лендинг (не в Telegram) ---------- */
.landing {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--brand); color: #fff; text-align: center;
}
.landing-card { max-width: 440px; }
.landing-logo { font-size: 64px; line-height: 1; }
.landing h1 { font-size: 40px; margin: 12px 0 8px; letter-spacing: -.5px; }
.landing p { font-size: 18px; opacity: .92; margin: 0 0 24px; }
.landing-ex {
  background: rgba(255,255,255,.15); border-radius: 14px; padding: 12px 16px;
  margin: 0 0 24px; text-align: left; line-height: 1.6;
}
.landing-btn {
  display: inline-block; background: #fff; color: #5B3CE0; text-decoration: none;
  font-weight: 700; font-size: 18px; padding: 14px 28px; border-radius: 14px;
}

/* ---------- Шапка ---------- */
.app { padding-bottom: calc(96px + var(--safe-bottom)); }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; background: var(--bg);
}
.top-title { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; background: var(--brand);
  display: grid; place-items: center; font-size: 22px;
}
.top h1 { font-size: 20px; margin: 0; letter-spacing: -.2px; }
.subtitle { font-size: 13px; color: var(--hint); }
.top-actions { display: flex; gap: 4px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; font-size: 18px;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--bg2); }

.search { padding: 0 16px 10px; background: var(--bg); }
.search input, .quick input, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--sep); background: var(--bg2);
  border-radius: 12px; padding: 11px 14px; outline: none;
}
.search input:focus, .quick input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
}

/* ---------- Быстрое добавление ---------- */
.quick { padding: 4px 16px 12px; background: var(--bg); border-bottom: 1px solid var(--sep); }
.quick-row { display: flex; gap: 8px; }
.quick-add {
  flex: 0 0 46px; height: 46px; border-radius: 12px; background: var(--accent);
  color: var(--accent-text); font-size: 24px; font-weight: 600;
}
.quick-add:disabled { opacity: .45; }
.quick-preview { font-size: 13px; color: var(--hint); min-height: 0; padding: 6px 2px 0; }
.quick-preview:empty { display: none; }
.quick-preview.ok { color: var(--link); }
.quick-preview.err { color: var(--danger); }

/* ---------- Фильтры ---------- */
.chips {
  display: flex; gap: 8px; padding: 12px 16px 4px; overflow-x: auto; scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 13px; border-radius: 999px; font-size: 14px;
  background: var(--card); color: var(--text); border: 1px solid var(--sep); white-space: nowrap;
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.chip .count { opacity: .7; margin-left: 4px; }

/* ---------- Список ---------- */
.list { padding: 4px 12px; }
.group-title {
  font-size: 13px; font-weight: 600; color: var(--hint); text-transform: uppercase;
  letter-spacing: .4px; padding: 14px 6px 6px;
}
.group-title.overdue { color: var(--danger); }
.card {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 12px 10px;
  background: var(--card); border-radius: var(--radius); margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); transition: transform .15s, opacity .25s;
}
.card:active { transform: scale(.985); }
.card.leaving { opacity: 0; transform: translateX(40px); }
.swipe.leaving .card { transform: translateX(110%); }
.check {
  flex: 0 0 26px; height: 26px; margin-top: 1px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--hint) 60%, transparent);
  display: grid; place-items: center; font-size: 14px; color: transparent;
}
.check:active, .check.done { background: #22c55e; border-color: #22c55e; color: #fff; }
.card-main { flex: 1; min-width: 0; }
.card-text { word-wrap: break-word; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; font-size: 13px; color: var(--hint); }
.card-time { font-weight: 600; color: var(--link); }
.card-time.overdue { color: var(--danger); }

.empty { text-align: center; padding: 56px 24px; color: var(--hint); }
.empty-icon { font-size: 52px; margin-bottom: 8px; }
.empty b { color: var(--text); display: block; font-size: 18px; margin-bottom: 6px; }
.skeleton { height: 64px; border-radius: var(--radius); margin-bottom: 8px; background: var(--card); opacity: .6; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.fab {
  position: fixed; right: 18px; bottom: calc(22px + var(--safe-bottom)); width: 58px; height: 58px;
  border-radius: 18px; background: var(--brand); color: #fff; font-size: 30px; font-weight: 500;
  box-shadow: 0 8px 22px rgba(91,108,255,.4); z-index: 5;
}
.fab:active { transform: scale(.94); }

/* ---------- Окно снизу ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 16px calc(18px + var(--safe-bottom));
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--sep); margin: 0 auto 10px; }
.sheet h2 { font-size: 19px; margin: 4px 0 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 6px; }
.field textarea { resize: none; min-height: 70px; }
.row2 { display: flex; gap: 10px; }
.row2 .field { flex: 1; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick .chip { font-size: 14px; }
.btn {
  width: 100%; padding: 14px; border-radius: 14px; font-weight: 600; font-size: 16px;
  background: var(--accent); color: var(--accent-text);
}
.btn:disabled { opacity: .5; }
.btn.secondary { background: var(--bg2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); }
.actions { display: grid; gap: 8px; margin-top: 6px; }
.actions-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.snooze { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.snooze button { padding: 10px 4px; border-radius: 12px; background: var(--bg2); font-size: 14px; }
.snooze button:active { background: var(--sep); }
.note { font-size: 13px; color: var(--hint); margin: -4px 0 14px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 8px; background: var(--bg2); font-size: 12px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 14px; }
.switch input { width: 46px; height: 28px; appearance: none; border-radius: 999px; background: var(--sep); position: relative; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: #22c55e; }
.switch input:checked::after { left: 21px; }

/* ---------- Уведомление ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(92px + var(--safe-bottom)); z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #1f2430; color: #fff; padding: 12px 14px; border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: up .2s ease-out;
}
.toast button { color: #8fa2ff; font-weight: 700; padding: 0 4px; }

/* ---------- Вкладки ---------- */
.tabs {
  display: flex; margin: 10px 12px 0; background: var(--card); border-radius: 12px; padding: 3px;
  border: 1px solid var(--sep);
}
.tabs button { flex: 1; padding: 8px 4px; border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--hint); }
.tabs button.active { background: var(--accent); color: var(--accent-text); }

/* ---------- Жесты ---------- */
.swipe { position: relative; margin-bottom: 8px; border-radius: var(--radius); overflow: hidden; transition: opacity .25s; }
.swipe .card { margin-bottom: 0; position: relative; z-index: 1; }
.swipe.swiping .card { transition: none; }
.swipe.leaving { opacity: 0; }
.swipe-bg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; font-weight: 600; font-size: 15px; color: #fff; background: var(--sep); visibility: hidden;
}
.swipe.swiping .swipe-bg { visibility: visible; }
.swipe.go-done .swipe-bg { background: #22c55e; }
.swipe.go-del .swipe-bg { background: var(--danger); }
.swipe-bg span { opacity: 0; transition: transform .15s; }
.swipe.go-done .sb-done, .swipe.go-del .sb-del { opacity: .75; }
.swipe.armed .sb-done, .swipe.armed .sb-del { transform: scale(1.12); }
.swipe.armed.go-done .sb-done, .swipe.armed.go-del .sb-del { opacity: 1; }

/* ---------- Календарь ---------- */
.cal { background: var(--card); margin: 10px 12px 0; border-radius: var(--radius); padding: 8px 8px 10px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 6px; }
.cal-head b { font-size: 17px; }
.cal-nav { width: 40px; height: 36px; border-radius: 10px; font-size: 24px; line-height: 1; color: var(--link); }
.cal-nav:disabled { opacity: .2; }
.cal-nav:active { background: var(--bg2); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-wd { font-size: 12px; color: var(--hint); padding: 4px 0 6px; }
.cal-wd.we { color: color-mix(in srgb, var(--danger) 70%, var(--hint)); }
.cal-day {
  aspect-ratio: 1 / 1; max-height: 52px; border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 15px; padding: 0;
}
.cal-day:active { background: var(--bg2); }
.cal-day.past { opacity: .3; }
.cal-day.today { color: var(--accent); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day.sel { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.dots { display: flex; gap: 3px; height: 5px; margin-top: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.cal-day.sel .dots i { background: var(--accent-text); }
.day-empty { color: var(--hint); text-align: center; padding: 18px 0; }
.add-day { margin: 4px 0 8px; }
.card.occ { opacity: .8; }
.check.ghost { border-style: dashed; color: var(--hint); font-size: 12px; }

/* ---------- История ---------- */
.hint-line { font-size: 13px; color: var(--hint); margin: 10px 6px 0; }
.card.past .card-text { color: var(--hint); }
.card.past .check { background: color-mix(in srgb, #22c55e 75%, transparent); border-color: transparent; color: #fff; }
.big-text { font-size: 18px; margin: 0 0 16px; overflow-wrap: anywhere; }

/* ---------- Форма: время, повтор, чек-лист, голос ---------- */
.quick-times { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; padding-bottom: 2px; }
.quick-times::-webkit-scrollbar { display: none; }
.field .field { margin-bottom: 0; }
.when-hint { font-size: 13px; color: var(--link); margin-top: 6px; min-height: 18px; }
.when-hint.err { color: var(--danger); }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.weekdays button { padding: 9px 0; border-radius: 10px; background: var(--bg2); font-size: 14px; }
.weekdays button.on { background: var(--accent); color: var(--accent-text); }
.every { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.field .every input { width: 84px; text-align: center; }
.cl-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cl-check {
  flex: 0 0 24px; height: 24px; border-radius: 7px; border: 2px solid color-mix(in srgb, var(--hint) 60%, transparent);
  color: transparent; font-size: 13px; display: grid; place-items: center; padding: 0;
}
.cl-check.on { background: #22c55e; border-color: #22c55e; color: #fff; }
.field .cl-text {
  flex: 1; border: 0; border-bottom: 1px solid var(--sep); border-radius: 0; background: transparent; padding: 7px 2px;
}
.cl-static { flex: 1; padding: 4px 0; }
.cl-item.on .cl-text, .cl-item.on .cl-static { text-decoration: line-through; color: var(--hint); }
.cl-del { flex: 0 0 30px; height: 30px; color: var(--hint); font-size: 20px; }
.cl-add { display: flex; gap: 8px; margin-top: 4px; }
.cl-add input { flex: 1; }
.cl-add button { flex: 0 0 46px; border-radius: 12px; background: var(--bg2); font-size: 22px; }
.voice-row { display: flex; gap: 8px; }
.voice-row .btn { padding: 12px 8px; font-size: 15px; }
#vPlayer audio { width: 100%; margin-top: 10px; }

/* ---------- Подсказки при первом открытии ---------- */
.onboard {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column;
  justify-content: space-between; padding: 48px 28px calc(24px + var(--safe-bottom)); text-align: center; animation: fade .25s;
}
.ob-skip { position: absolute; top: 12px; right: 14px; color: var(--hint); font-size: 15px; padding: 8px; }
.ob-slide { animation: fade .3s; }
.ob-icon {
  width: 120px; height: 120px; margin: 7vh auto 26px; border-radius: 34px; background: var(--brand);
  display: grid; place-items: center; font-size: 60px; box-shadow: 0 14px 34px rgba(91,108,255,.35);
}
.ob-slide h2 { font-size: 26px; margin: 0 0 12px; letter-spacing: -.3px; }
.ob-slide p { color: var(--hint); font-size: 17px; line-height: 1.5; margin: 0 auto; max-width: 360px; }
.ob-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 18px; }
.ob-dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--sep); transition: width .2s; }
.ob-dots i.on { background: var(--accent); width: 22px; }
