:root {
  --bg: #f4ede4;
  --paper: #fffaf4;
  --ink: #2b2420;
  --muted: #8a7d72;
  --line: #e6dbcf;
  --accent: #b5502f;
  --accent-soft: #f3dccf;
  --sage: #5f7a63;
  --sage-soft: #dfe8dc;
  --gold: #b9862c;
  --gold-soft: #f4e6c8;
  --out: #f1d9c9;
  --in: #ffffff;
  --r: 14px;
  --nav: 64px;
  --top: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- вход ---------- */
.login { height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; }
.login h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: 40px; margin: 0 0 4px; letter-spacing: -0.5px; }
.login h1 em { color: var(--accent); font-style: italic; }
.login p { color: var(--muted); margin: 0 0 28px; }
.login input { width: 100%; padding: 16px; font-size: 20px; letter-spacing: 3px; text-align: center; font-family: ui-monospace, Menlo, monospace;
  border: 1.5px solid var(--line); border-radius: var(--r); background: var(--paper); outline: none; }
.login input:focus { border-color: var(--accent); }
.login .err { color: var(--accent); min-height: 22px; margin-top: 10px; font-size: 14px; }

/* ---------- каркас ---------- */
.shell { height: 100%; display: flex; flex-direction: column; }
.top { flex: 0 0 auto; height: calc(var(--top) + var(--safe-t)); padding: var(--safe-t) 14px 0; display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.top h2 { margin: 0; font-family: Georgia, serif; font-weight: 400; font-size: 23px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wish-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 99px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; }
.wish-btn svg { width: 16px; height: 16px; }
.main { flex: 1; min-height: 0; display: flex; }
.pane { flex: 1; min-width: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.nav { flex: 0 0 auto; height: calc(var(--nav) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: var(--paper); border-top: 1px solid var(--line); }
.nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; color: var(--muted); position: relative; }
.nav button svg { width: 23px; height: 23px; }
.nav button.on { color: var(--accent); }
.nav .dot { position: absolute; top: 9px; left: calc(50% + 7px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 10.5px; line-height: 17px; font-weight: 700; }

/* ---------- чаты ---------- */
.chips { display: flex; gap: 7px; padding: 10px 12px; overflow-x: auto; scrollbar-width: none; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.chips::-webkit-scrollbar { display: none; }
/* Одна строка; на компьютере колёсико листает вбок, а по краям стрелки ‹ › (0.3.2, пожелание сестры; перенос строк из 0.3.1 убран). */
.chipbar { position: sticky; top: 0; z-index: 2; background: var(--bg); }
.chipbar .chips { position: static; }
.cnav { display: none; position: absolute; top: 0; bottom: 0; width: 44px; border: 0; padding: 0; font-size: 24px; line-height: 1; color: var(--ink); cursor: pointer; }
.cnav.l { left: 0; background: linear-gradient(to right, var(--bg) 55%, transparent); text-align: left; padding-left: 8px; }
.cnav.r { right: 0; background: linear-gradient(to left, var(--bg) 55%, transparent); text-align: right; padding-right: 8px; }
.chipbar.can-l .cnav.l, .chipbar.can-r .cnav.r { display: block; }
@media (hover: none), (pointer: coarse) { .cnav { width: 28px; pointer-events: none; font-size: 0; } }
.chip { flex: 0 0 auto; padding: 7px 13px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.search { margin: 0 12px 6px; display: block; width: calc(100% - 24px); padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); outline: none; }
.row { display: flex; gap: 12px; padding: 10px 14px; align-items: center; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:active, .row.on { background: var(--accent-soft); }
.ava { flex: 0 0 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; color: #fff; font-size: 17px; }
.row .mid { flex: 1; min-width: 0; }
.row .nm { display: flex; gap: 6px; align-items: baseline; }
.row .nm b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.row .nm time { color: var(--muted); font-size: 12.5px; flex: 0 0 auto; }
.row .sub { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.row .sub span { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.badge { flex: 0 0 auto; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px; background: var(--sage); color: #fff; font-size: 12px; font-weight: 700; line-height: 21px; text-align: center; }
.tag { flex: 0 0 auto; font-size: 11px; padding: 2px 7px; border-radius: 6px; font-weight: 600; }
.st-new { background: #ebe4dc; color: #6f6157; }
.st-work { background: var(--accent-soft); color: var(--accent); }
.st-wait { background: var(--gold-soft); color: #8a6115; }
.st-client { background: var(--sage-soft); color: var(--sage); }
.st-archive { background: #eee; color: #999; }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); line-height: 1.5; }

/* ---------- переписка ---------- */
.chat { display: flex; flex-direction: column; height: 100%; background: var(--bg); }
.chat-head { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--paper); }
.chat-head .ava { flex-basis: 38px; height: 38px; font-size: 15px; }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who small { color: var(--muted); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; }
.card-btn { padding: 8px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px; }
.msgs { flex: 1; overflow-y: auto; padding: 12px 10px 6px; display: flex; flex-direction: column; gap: 4px; }
.more { align-self: center; color: var(--muted); font-size: 13px; padding: 6px 12px; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--paper); padding: 3px 10px; border-radius: 99px; margin: 8px 0; }
.b { max-width: min(80%, 520px); padding: 7px 11px 6px; border-radius: 16px; background: var(--in); align-self: flex-start; box-shadow: 0 1px 0 rgba(0,0,0,.04); word-wrap: break-word; white-space: pre-wrap; line-height: 1.38; font-size: 15.5px; }
.b.o { align-self: flex-end; background: var(--out); }
.b .snd { font-size: 12.5px; font-weight: 600; color: var(--accent); margin-bottom: 1px; }
.b .meta { font-size: 11px; color: var(--muted); text-align: right; margin-top: 2px; }
.b img { display: block; max-width: 100%; max-height: 300px; border-radius: 10px; margin: 2px 0; }
.b audio { width: 240px; max-width: 100%; height: 38px; display: block; }
.b .lbl { color: var(--muted); }
.tr-btn { margin-top: 4px; font-size: 13px; color: var(--accent); font-weight: 600; padding: 2px 0; }
.tr { margin-top: 5px; padding: 6px 9px; background: rgba(0,0,0,.035); border-radius: 9px; font-size: 14.5px; font-style: italic; }
.composer { flex: 0 0 auto; display: flex; gap: 8px; padding: 8px 10px calc(8px + var(--safe-b)); background: var(--paper); border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 20px; padding: 10px 14px; background: var(--bg); outline: none; max-height: 140px; font-size: 16px; line-height: 1.35; }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.send svg { width: 20px; height: 20px; }
.send:disabled { opacity: .45; }

/* ---------- задачи и формы ---------- */
.sec { padding: 14px 14px 4px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.sec.red { color: var(--accent); }
.task { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; background: var(--paper); }
.chk { flex: 0 0 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); display: grid; place-items: center; margin-top: 1px; }
.chk.on { background: var(--sage); border-color: var(--sage); color: #fff; }
.task .tt { flex: 1; min-width: 0; }
.task .tt b { font-weight: 500; display: block; }
.task.done .tt b { text-decoration: line-through; color: var(--muted); }
.task .tt small { color: var(--muted); font-size: 13px; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.task .tt small a { text-decoration: none; }
.task .del { color: var(--muted); font-size: 20px; line-height: 1; padding: 0 4px; }
.add { margin: 12px; padding: 12px; background: var(--paper); border-radius: var(--r); border: 1px solid var(--line); display: grid; gap: 8px; }
.add .r { display: flex; gap: 8px; }
.add .r > * { flex: 1; min-width: 0; }
.inp { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); outline: none; font-size: 16px; }
.inp:focus { border-color: var(--accent); }
textarea.inp { resize: vertical; min-height: 70px; }
.btn { padding: 11px 16px; border-radius: 11px; background: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.btn.sage { background: var(--sage); }
.btn:disabled { opacity: .5; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; padding: 7px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.box { margin: 12px; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); }
.box h3 { margin: 0 0 6px; font-size: 17px; }
.box p { margin: 0 0 12px; color: var(--muted); font-size: 14.5px; line-height: 1.45; }
.box .r { display: flex; gap: 8px; }
.small { font-size: 13px; color: var(--muted); }

/* ---------- лист снизу ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(43,36,32,.38); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 560px; max-height: 92%; overflow-y: auto; background: var(--paper); border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); animation: up .2s ease-out; }
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 4px; font-family: Georgia, serif; font-weight: 400; font-size: 24px; }
.sheet .lead { color: var(--muted); margin: 0 0 14px; font-size: 14.5px; }
.sheet label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
.sheet .acts { display: flex; gap: 8px; margin-top: 16px; }
.sheet .acts .btn { flex: 1; }
.stbar { display: flex; flex-wrap: wrap; gap: 6px; }
.stbar button { padding: 7px 12px; border-radius: 99px; font-size: 14px; border: 1px solid var(--line); }
.stbar button.on { border-color: transparent; font-weight: 600; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- запись пожелания ---------- */
.rec { display: grid; place-items: center; gap: 10px; margin: 10px 0 4px; }
.rec-btn { width: 92px; height: 92px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 20px rgba(181,80,47,.35); }
.rec-btn svg { width: 38px; height: 38px; }
.rec-btn.live { animation: pulse 1.3s infinite; background: #9b3a1e; }
.rec .t { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; min-height: 20px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(181,80,47,.5); } 70% { box-shadow: 0 0 0 22px rgba(181,80,47,0); } 100% { box-shadow: 0 0 0 0 rgba(181,80,47,0); } }
.wish { padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--paper); }
.wish .h { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.wish .h span { flex: 1; }
.wish p { margin: 6px 0 0; white-space: pre-wrap; line-height: 1.4; }
.wish audio { margin-top: 6px; width: 100%; height: 36px; }
.wish select { font-size: 13px; padding: 3px 6px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg); }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav) + 18px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; z-index: 40; font-size: 14.5px; max-width: 90%; animation: fade .2s; }

/* ---------- широкий экран: список + переписка рядом ---------- */
.side { display: none; }
@media (min-width: 900px) {
  .main.split .pane { flex: 0 0 380px; border-right: 1px solid var(--line); }
  .main.split .side { display: block; flex: 1; min-width: 0; }
  .main.split .side .chat-back { display: none; }
  .shell { max-width: 1400px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
.overlay-chat { position: fixed; inset: 0; z-index: 10; }

/* ---------- звонок ---------- */
.call-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 99px; background: var(--sage-soft); color: var(--sage); font-weight: 600; font-size: 14px; }
.call-btn svg { width: 16px; height: 16px; }
@media (max-width: 420px) { .call-btn span { display: none; } }
.call { position: fixed; inset: 0; z-index: 90; background: #231d1a; color: #fff; display: flex; flex-direction: column; }
.call-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.call-stage video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.call-stage video.contain { object-fit: contain; }
.call-stage.has-video .call-ava { display: none; }
.call-stage video.pip { position: absolute; left: 14px; top: calc(var(--safe-t) + 74px); width: 104px; height: auto; aspect-ratio: 3/4; border-radius: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.4); z-index: 2; }
@media (min-width: 900px) { .call-stage video.pip { width: 200px; aspect-ratio: 4/3; } }
.call-ava .ava { width: 128px; height: 128px; font-size: 44px; box-shadow: 0 0 0 10px rgba(255,255,255,.06), 0 0 0 22px rgba(255,255,255,.03); }
.call-self { position: absolute; right: 14px; top: calc(var(--safe-t) + 74px); width: 104px; aspect-ratio: 3/4; border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 6px 20px rgba(0,0,0,.4); z-index: 2; }
.call-self video { width: 100%; height: 100%; object-fit: cover; }
.call-self video.mirror { transform: scaleX(-1); }
@media (min-width: 900px) { .call-self { width: 200px; aspect-ratio: 4/3; } }
.call-head { position: relative; z-index: 2; padding: calc(var(--safe-t) + 22px) 20px 30px; text-align: center; background: linear-gradient(rgba(0,0,0,.45), transparent); }
.call-head b { display: block; font-family: Georgia, serif; font-weight: 400; font-size: 28px; }
.call-head span { display: block; margin-top: 4px; opacity: .75; font-size: 15px; font-variant-numeric: tabular-nums; }
.call-sound { position: relative; z-index: 2; align-self: center; padding: 10px 16px; border-radius: 99px; background: #fff; color: var(--ink); font-weight: 600; }
.call-bar { position: relative; z-index: 2; margin-top: auto; display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 26px 14px calc(var(--safe-b) + 26px); background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.cb { display: flex; flex-direction: column; align-items: center; gap: 6px; color: #fff; font-size: 12px; background: none; min-width: 64px; }
.cb svg { box-sizing: content-box; width: 24px; height: 24px; padding: 16px; border-radius: 50%; background: rgba(255,255,255,.16); }
.cb.off svg { background: #fff; color: var(--ink); }
.cb.on svg { background: var(--sage); }
.cb.green svg { background: #3f9b5a; }
.cb.red svg { background: #d2452f; }
#cNo svg, #cEnd svg { transform: rotate(135deg); }
.cb[hidden] { display: none; }

/* свёрнутый звонок (0.2.7): полоса сверху, сайт под ней */
.call-min-btn { position: absolute; left: 10px; top: calc(var(--safe-t) + 14px); padding: 8px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; }
.call-min-btn svg { display: block; width: 26px; height: 26px; }
.call-min-btn[hidden] { display: none; }
.call-mini { display: none; }
.call.min { inset: 0 0 auto 0; height: calc(var(--safe-t) + 52px); padding-top: var(--safe-t); background: #2f7d47; flex-direction: row; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.call.min > :not(.call-mini) { display: none; }
.call.min .call-mini { display: flex; align-items: center; gap: 8px; width: 100%; padding: 0 8px 0 4px; }
.cm-open { flex: 1; min-width: 0; height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 10px; color: #fff; text-align: left; }
.cm-open i { width: 9px; height: 9px; border-radius: 50%; background: #fff; flex: 0 0 auto; animation: cmpulse 1.6s infinite; }
@keyframes cmpulse { 50% { opacity: .3; } }
.cm-open b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-open span { opacity: .85; font-variant-numeric: tabular-nums; font-size: 14px; }
.cm-open span::after { content: " · развернуть"; opacity: .7; }
.cm-b { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); color: #fff; flex: 0 0 auto; }
.cm-b svg { width: 20px; height: 20px; }
.cm-b.off { background: #fff; color: var(--ink); }
.cm-b.red { background: #d2452f; }
.cm-b.red svg { transform: rotate(135deg); }
body.call-min #app, body.call-min .overlay-chat { --safe-t: 0px; position: fixed; left: 0; right: 0; bottom: 0; top: calc(env(safe-area-inset-top, 0px) + 52px); height: auto; }
