:root {
  --bg: #F6F2EA; --ink: #1F1D1A; --mut: #8C8578; --soft: #A69F91; --ln: #D9D2C3; --s: #ECE5D8;
  --acc: #6B5B3E; --var: #9A7A45; --ok: #5E7A4F; --bad: #A0533F;
  --g1: #0B0B0B; --g2: #FFFFFF;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #181715; --ink: #EDE8DE; --mut: #8F887B; --soft: #6F695E; --ln: #2E2C28; --s: #24221F;
    --acc: #B08D57; --var: #C9A46A; --ok: #8DAA7C; --bad: #C98471;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #181715; --ink: #EDE8DE; --mut: #8F887B; --soft: #6F695E; --ln: #2E2C28; --s: #24221F;
  --acc: #B08D57; --var: #C9A46A; --ok: #8DAA7C; --bad: #C98471;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 400 14px/1.5 Onest, system-ui, sans-serif; min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
.ti { line-height: 1; }

.view { max-width: 520px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) 24px calc(104px + env(safe-area-inset-bottom)); }

/* типографика */
.k { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--mut); display: flex; align-items: center; gap: 6px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 22px; }
.top .ti { font-size: 20px; }
.h { font-weight: 300; letter-spacing: -0.03em; font-size: 40px; line-height: 1.05; margin: 14px 0 0; word-break: break-word; }
.h.big { font-size: 84px; line-height: .9; }
.h.mid { font-size: 56px; line-height: 1; }
.mut { color: var(--mut); }
.sub { color: var(--mut); margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.small { font-size: 12px; }
.ln { height: .5px; background: var(--ln); margin: 22px 0; }
.lbl { font-size: 12px; color: var(--mut); margin: 22px 0 10px; display: flex; align-items: center; gap: 6px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.ic-row { display: flex; align-items: center; gap: 6px; }
.quote { font-weight: 300; font-size: 17px; line-height: 1.5; margin-top: 28px; padding-left: 16px; border-left: 1px solid var(--acc); white-space: pre-wrap; word-break: break-word; }
.quote .v { color: var(--var); }

/* кнопки */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border-radius: 26px; font-size: 14px; transition: transform .12s; }
.btn:active { transform: scale(.98); }
.btn .ti { font-size: 19px; }
.btn.fill { background: var(--ink); color: var(--bg); }
.btn.out { border: .5px solid var(--ink); }
.btn.soft { background: var(--s); }
.btn[disabled] { opacity: .45; }
.gb { padding: 1.5px; border-radius: 27px; background: linear-gradient(90deg, var(--g1), var(--g2), var(--g1), var(--g2), var(--g1)); background-size: 300% 100%; animation: flow 3.5s linear infinite; }
.gb .btn { background: var(--bg); height: 49px; }
.gb.slow { animation-duration: 6s; opacity: .7; }
@keyframes flow { to { background-position: 150% 0; } }
.stack { display: flex; flex-direction: column; gap: 10px; }
.pair { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.link.acc { color: var(--acc); }

/* выбор */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 18px; border: .5px solid var(--ln); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs { display: flex; gap: 16px; color: var(--mut); margin-top: 10px; align-items: center; overflow-x: auto; scrollbar-width: none; }
.tabs button { white-space: nowrap; padding: 4px 0; }
.tabs .on { color: var(--ink); }
.picker { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin-top: 14px; text-align: left;
  font-weight: 300; letter-spacing: -0.03em; font-size: 40px; line-height: 1.1; }
.picker span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .ti { font-size: 22px; color: var(--mut); flex: none; transition: transform .2s; }
.picker:active .ti { transform: translateY(2px); }

/* лист выбора поверх экрана */
.sheet { position: fixed; inset: 0; z-index: 20; background: var(--bg); opacity: 0; transform: translateY(24px); transition: opacity .2s, transform .2s; overflow-y: auto; overscroll-behavior: contain; }
.sheet.show { opacity: 1; transform: none; }
.sheet-in { max-width: 520px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) 24px calc(40px + env(safe-area-inset-bottom)); }
.sheet .close .ti { font-size: 22px; }
.sheet .search { position: sticky; top: 0; background: var(--bg); z-index: 1; }
.it.city { font-size: 20px; font-weight: 300; letter-spacing: -0.01em; padding: 16px 0; }
.it.city .ti { font-size: 20px; color: var(--acc); }
.it.city.on { color: var(--ink); }
@media (hover: hover) { .it.city:hover { color: var(--acc); } }
body.locked { overflow: hidden; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: .5px solid var(--ln); }
.field:last-child { border-bottom: 0; }
.field input[type=number], .field input[type=time], .field input[type=text] { width: 92px; text-align: right; background: none; border: 0; border-bottom: .5px solid var(--ln); padding: 4px 0; }
.field input[type=text].wide { width: 170px; }
.range { display: flex; gap: 8px; align-items: center; }
.seg { display: inline-flex; border: .5px solid var(--ln); border-radius: 18px; padding: 2px; }
.seg button { padding: 6px 12px; border-radius: 16px; font-size: 12.5px; color: var(--mut); }
.seg .on { background: var(--ink); color: var(--bg); }
.switch { width: 44px; height: 26px; border-radius: 13px; background: var(--ln); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); transition: transform .2s; }
.switch.on { background: var(--ink); }
.switch.on::after { transform: translateX(18px); }
input.search { width: 100%; background: none; border: 0; border-bottom: .5px solid var(--ink); padding: 8px 0; margin-top: 14px; outline: none; }
textarea { width: 100%; min-height: 180px; background: var(--s); border: 0; border-radius: 14px; padding: 14px; font-weight: 300; font-size: 16px; line-height: 1.55; resize: vertical; outline: none; }
textarea.note { min-height: 80px; font-size: 14px; }
input.title { width: 100%; background: none; border: 0; border-bottom: .5px solid var(--ln); font-weight: 300; font-size: 28px; letter-spacing: -0.02em; padding: 6px 0; outline: none; }

/* списки */
.list { margin-top: 18px; }
.it { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: .5px solid var(--ln); width: 100%; text-align: left; }
.it:last-child { border-bottom: 0; }
.it .grow { flex: 1; min-width: 0; }
.it .name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ic { width: 36px; height: 36px; border-radius: 50%; background: var(--s); display: flex; align-items: center; justify-content: center; flex: none; color: var(--acc); }
.ic .ti { font-size: 17px; }
.st { font-size: 12px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.st.new, .st.skipped, .st.no_tg { color: var(--mut); }
.st.sent, .st.reminded { color: var(--acc); }
.st.replied, .st.talk, .st.paid { color: var(--ok); }
.st.refused { color: var(--bad); }

/* прогресс и воронка */
.bar { height: 1px; background: var(--ln); margin-top: 22px; position: relative; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink); width: 0; transition: width .4s; }
.bar.run i { width: 35%; animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { from { left: -35%; } to { left: 100%; } }
.fb { margin-top: 16px; }
.fb .track { height: 6px; border-radius: 3px; background: var(--s); margin-top: 7px; overflow: hidden; }
.fb .track i { display: block; height: 100%; border-radius: 3px; background: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 30px; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 26px; }
.actions a, .actions button { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; color: var(--mut); }
.actions .ic { width: 48px; height: 48px; }
.actions .ic .ti { font-size: 21px; }
.empty { margin-top: 40px; color: var(--mut); line-height: 1.6; }
.hint { font-size: 12px; color: var(--mut); text-align: center; display: flex; justify-content: center; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--soft); }
.dot.on { background: var(--ok); }

/* карточка рассылки: свайп */
.card { touch-action: pan-y; transition: transform .25s, opacity .25s; }
.card.drag { transition: none; }

/* нижнее меню */
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; max-width: 520px; margin: 0 auto;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); border-top: .5px solid var(--ln); z-index: 5; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; color: var(--soft); min-width: 64px; }
.nav .ti { font-size: 22px; }
.nav a.on { color: var(--ink); }
.nav a.on::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--acc); margin-top: 1px; }

.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); border-radius: 22px; padding: 11px 18px; font-size: 13px; display: flex; gap: 14px; align-items: center;
  transition: opacity .2s, transform .2s; z-index: 10; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: var(--bg); text-decoration: underline; text-underline-offset: 3px; }

/* сообщения (шаблоны) */
.v { color: var(--var); }
.num { width: 26px; height: 26px; border-radius: 50%; border: .5px solid var(--ink); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.tsec { margin-top: 34px; }
.tsec-h { display: flex; gap: 14px; align-items: flex-start; }
.tsec-h .num { margin-top: 1px; }
.tsec-t { font-size: 18px; display: block; margin-bottom: 4px; }
.tcard { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 0 40px; padding: 14px 16px; border-radius: 16px; background: var(--s); }
.tcard-t { font-size: 15px; }
.tcard-p { font-weight: 300; font-size: 13.5px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.tcard.off { opacity: .55; }
.tadd { margin: 14px 0 0 40px; }
.step { display: flex; align-items: center; gap: 10px; margin: 34px 0 14px; font-size: 15px; }
.kinds { display: flex; flex-direction: column; gap: 8px; }
.kind { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 16px; border: .5px solid var(--ln); }
.kind.on { border-color: var(--ink); background: var(--s); }
.radio { width: 20px; height: 20px; border-radius: 50%; border: .5px solid var(--mut); flex: none; position: relative; }
.kind.on .radio { border-color: var(--ink); }
.kind.on .radio::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--ink); }
.vars { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.var { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 14px; border: .5px solid var(--ln); }
.var:active { background: var(--s); }
.var .ti { color: var(--acc); }
.phone-pv { background: var(--s); border-radius: 20px; padding: 14px; }
.bubble { margin-top: 10px; background: var(--bg); border-radius: 4px 16px 16px 16px; padding: 12px 14px; font-weight: 300; font-size: 15px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }

@media (prefers-reduced-motion: reduce) { .gb, .bar.run i { animation: none; } }
