/* Палитра и метрики сняты с мобильной анкеты (390px): фон #F3F3F7, карточки 24px,
   поля 12px, акцент #0B7B94 / #1EA0BC, подсказки #E5F4F7. Без бренда и логотипа.
   Шрифты: Inter/Montserrat, если есть в системе; на iPhone — SF, визуально почти то же. */
:root {
  --bg: #f3f3f7; --card: #fff; --fg: #21272a; --black: #000; --muted: #6d758f; --label: rgba(0,0,0,.48);
  --field: rgba(36,74,127,.06); --plain: #f2f4f7; --teal: #0b7b94; --teal2: #1ea0bc; --mint: #e5f4f7;
  --line: #d1d5e5; --border: #e3e6ed; --red: #ff3b30; --gold: #d9a766;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --head: Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --me: #0b7b94; --me-fg: #fff; --them: #e9ecf2;
  font-family: var(--sans); color: var(--fg);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); overscroll-behavior: none; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
input, select, button, textarea { font: inherit; font-size: 16px; color: inherit; } /* 16px — iOS не зумит */
button { cursor: pointer; }

/* ── страница ─────────────────────────────────────── */
.page { max-width: 390px; margin: 0 auto; padding: 0 16px max(40px, env(safe-area-inset-bottom)); }
.topbar { display: flex; justify-content: space-between; align-items: center; height: 48px; padding-top: env(safe-area-inset-top); box-sizing: content-box; }
.lang { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--black); }
.lang svg { width: 14px; height: 14px; color: var(--teal); }
.muted-sm { font-size: 13px; color: var(--muted); }
.h-page { font-family: var(--head); font-size: 24px; font-weight: 700; color: var(--black); text-align: center; margin: 28px 0 12px; line-height: 1.25; }
.sub { font-size: 16px; color: var(--muted); text-align: center; margin: 0 0 32px; line-height: 1.25; }

.card { background: var(--card); border-radius: 24px; padding: 24px 16px; margin-bottom: 24px; display: flex; flex-direction: column; gap: 24px; }
.h-card { font-size: 20px; font-weight: 600; color: var(--black); margin: 0 0 -16px; line-height: 1.2; }
.card-sub { font-size: 16px; color: var(--muted); margin: 0; line-height: 1.25; }

/* поля */
.field { position: relative; display: block; background: var(--field); border: 1px solid transparent; border-radius: 12px; min-height: 56px; padding: 7px 48px 7px 16px; }
.field:focus-within { border-color: var(--teal2); background: #fff; }
.field .lbl { display: block; font-size: 12.5px; font-weight: 500; color: var(--label); line-height: 1.5; }
.field .lbl i { font-style: normal; color: var(--red); }
.field input, .field select {
  display: block; width: 100%; border: 0; outline: 0; background: transparent; padding: 0;
  font-size: 15px; line-height: 1.5; color: var(--black); -webkit-appearance: none; appearance: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field > .ic { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.field.plain { background: var(--plain); padding: 12px 16px; min-height: 74px; }
.field.plain .lbl-plain { display: block; font-size: 16px; color: var(--muted); line-height: 1.5; }
.field.plain input { font-size: 16px; }
.ic { width: 22px; height: 22px; color: #6d758f; flex: none; }
.ic.teal { color: var(--teal); }

.note { display: flex; gap: 12px; background: var(--mint); border-radius: 16px; padding: 16px; color: var(--muted); }
.note .ic { width: 20px; height: 20px; color: var(--teal); margin-top: 1px; }
.note b { display: block; font-size: 14px; font-weight: 700; line-height: 1.3; margin-bottom: 8px; }
.note p { margin: 0; font-size: 14px; line-height: 1.3; }

/* переключатели */
.sw-row { display: flex; align-items: center; gap: 12px; font-size: 16px; color: var(--black); margin: -8px 0; }
.sw-row > span { flex: 1; line-height: 1.5; }
.sw { position: relative; width: 56px; height: 30px; flex: none; }
.sw input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.sw span { position: absolute; inset: 0; border-radius: 1000px; background: #e9ecef; border: 1px solid #dee2e6; transition: background .15s; pointer-events: none; }
.sw span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 1px solid #dee2e6; transition: transform .15s; }
.sw input:checked + span { background: var(--teal); border-color: var(--teal); }
.sw input:checked + span::after { transform: translateX(26px); border-color: #fff; }

/* итог */
.result { background: var(--mint); border-radius: 24px; padding: 32px 26px; display: flex; flex-direction: column; gap: 4px; }
.r-lbl { font-size: 12px; color: var(--muted); }
.result > .r-lbl { font-size: 14px; }
.r-big { font-family: var(--head); font-size: 32px; font-weight: 700; color: var(--teal); line-height: 1.2; margin-bottom: 20px; }
.r-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.r-grid div { display: flex; flex-direction: column; gap: 8px; }
.r-grid b { font-size: 16px; font-weight: 700; color: #34495e; }
.row-link { display: flex; align-items: center; gap: 16px; background: var(--plain); border: 0; border-radius: 16px; padding: 16px; text-align: left; font-weight: 500; color: var(--black); margin-top: -8px; }
.row-link span { flex: 1; }

/* варианты */
.opt { display: flex; flex-direction: column; gap: 12px; text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 24px; padding: 24px; margin: -8px 0; }
.opt.on { background: var(--mint); border: 6px solid var(--teal2); padding: 19px; }
.opt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.opt-head b { font-size: 18px; font-weight: 700; color: var(--black); }
.radio { width: 24px; height: 24px; border-radius: 50%; background: #e6e8ee; flex: none; }
.opt.on .radio { background: #fff; border: 7px solid var(--teal2); }
.opt-sub { font-size: 16px; font-weight: 500; color: #28323c; }
.bul { display: flex; gap: 12px; font-size: 16px; color: var(--muted); line-height: 1.4; }
.bul svg { width: 24px; height: 24px; flex: none; }

.div-card { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--border); border-radius: 24px; padding: 25px; margin-top: -8px; }
.tiny { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.div-card b { font-size: 16px; font-weight: 700; }
.div-sum { font-size: 24px; font-weight: 700; margin-top: 10px; }
.muted { color: var(--muted); font-size: 16px; font-weight: 500; }
.muted.sm { font-size: 14px; font-weight: 400; line-height: 1.4; }

.promo { display: flex; gap: 10px; align-items: stretch; margin-bottom: -16px; }
.promo .field { flex: 1; padding-right: 16px; }
.btn-ghost { border: 0; border-radius: 12px; background: var(--plain); color: var(--teal); font-weight: 600; padding: 0 16px; }
.btn-ghost:disabled { opacity: .6; }
.err { margin: 0; font-size: 14px; color: var(--red); }
.err:empty { display: none; }

.sep { border: 0; border-top: 1px solid var(--line); margin: 0 0 24px; }
.btn { width: 100%; height: 52px; border: 0; border-radius: 16px; background: var(--teal); color: #fff; font-weight: 600; font-size: 16px; }
.btn:disabled { opacity: .6; }
.toast { margin: 12px 0 0; padding: 14px; border-radius: 12px; background: #f3f7f8; color: var(--teal); font-size: 14px; font-weight: 500; text-align: center; }

/* вход */
#gate .card { gap: 16px; }

/* график */
#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet-box { width: min(390px, 100%); max-height: 80vh; overflow: auto; background: #fff; border-radius: 24px 24px 0 0; padding: 20px 16px max(20px, env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 18px; }
.sheet-head button { border: 0; background: transparent; font-size: 18px; color: var(--muted); }
#sheet table { width: 100%; border-collapse: collapse; font-size: 15px; }
#sheet th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 6px 4px; }
#sheet td { padding: 10px 4px; border-top: 1px solid var(--border); }
#sheet td:last-child, #sheet th:last-child { text-align: right; }

/* ── чат ──────────────────────────────────────────── */
#chat-view { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
#chat-head {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--border); background: var(--card);
  touch-action: none; user-select: none; -webkit-user-select: none; /* жест паники, не скролл */
}
#panic-corner { position: absolute; left: 0; top: 0; width: 56px; height: 100%; z-index: 2; }
#chat-head .who { flex: 1; display: grid; }
#chat-head small { color: var(--muted); font-size: 12px; }
#fp { font-size: 20px; letter-spacing: 2px; }
#leave { border: 0; background: transparent; color: var(--muted); padding: 6px 10px; }
#conn { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
#conn[data-s="online"] { background: #30d158; }
#conn[data-s="offline"], #conn[data-s="full"] { background: var(--red); }
#conn[data-s="connecting"] { background: #ffd60a; }

#list { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
#list li { max-width: 78%; padding: 8px 12px; border-radius: 16px; }
#list li p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
#list li small { display: block; font-size: 11px; opacity: .65; text-align: right; margin-top: 2px; }
#list li.me { align-self: flex-end; background: var(--me); color: var(--me-fg); }
#list li.them { align-self: flex-start; background: var(--them); }

#composer {
  display: flex; gap: 8px; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--card);
}
#composer input { flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
#composer select { border: 1px solid var(--border); border-radius: 12px; background: var(--bg); padding: 0 6px; }
#composer button { border: 0; border-radius: 12px; padding: 0 16px; background: var(--teal); color: #fff; }

/* свернули приложение — в снимке переключателя задач только анкета */
body.covered #chat-view { display: none !important; }
body.covered #decoy { display: block !important; }
