:root {
  --board: #E8EBEE;      /* бетон подъезда */
  --paper: #FFFFFF;
  --ink: #1C2B4B;        /* синий, как на ваших листовках */
  --ink-soft: #5E6B7D;
  --line: #CDD3DA;
  --tab: #F2C230;        /* жёлтый отрывной корешок */
  --tab-ink: #3A2E00;
  --alarm: #C23B2E;
  --warn: #C27A12;
  --ok: #2F7D4F;
  --mine: #1C2B4B;
  --mine-ink: #FFFFFF;
  --radius-s: 6px;
  --radius-m: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--board); }
body { font-size: 16px; line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--tab); outline-offset: 2px; }
.hidden { display: none !important; }

/* кнопки */
.btn {
  border: 0; border-radius: var(--radius-s); padding: 10px 16px;
  background: var(--ink); color: #fff; font-weight: 600;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: var(--alarm); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; color: var(--ink-soft); }
.input, textarea.input, select.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-s);
  background: #fff; padding: 10px 12px;
}
textarea.input { min-height: 90px; resize: vertical; }

/* вход по коду */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: min(380px, 100%); background: var(--paper); padding: 28px 24px 0;
  border-radius: var(--radius-s) var(--radius-s) 0 0; position: relative;
}
.gate-card h1 { margin: 0 0 6px; font-size: 28px; line-height: 1.15; letter-spacing: -.01em; }
.gate-card p { margin: 0 0 20px; color: var(--ink-soft); }
.code-input {
  width: 100%; text-align: center; font-size: 30px; font-weight: 700; letter-spacing: .35em;
  text-transform: uppercase; padding: 12px 0 12px .35em; border: 2px solid var(--ink);
  border-radius: var(--radius-s); background: #fff;
}
.gate-card .btn { width: 100%; margin-top: 14px; padding: 14px; font-size: 17px; }
.gate-error { color: var(--alarm); min-height: 1.4em; margin-top: 10px; font-size: 15px; }
/* отрывные корешки внизу карточки — узнаваемая деталь */
.tabs-edge {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; margin: 24px -24px 0;
  border-top: 2px dashed var(--line);
}
.tabs-edge span {
  height: 46px; border-right: 1px dashed var(--line); background: var(--paper);
  display: grid; place-items: center; font-size: 11px; color: var(--ink-soft); writing-mode: vertical-rl;
}
.tabs-edge span:last-child { border-right: 0; }
.tabs-edge span:nth-child(3) { transform: translateY(6px) rotate(2deg); background: var(--tab); color: var(--tab-ink); }

/* чат */
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--ink); color: #fff;
}
.chat-head .title { font-weight: 700; font-size: 17px; line-height: 1.2; }
.chat-head .sub { font-size: 13px; opacity: .75; }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-head button { background: transparent; border: 0; color: #fff; padding: 6px; }
.feed { flex: 1; overflow-y: auto; padding: 16px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.day-sep { align-self: center; font-size: 13px; color: var(--ink-soft); padding: 4px 10px; }

.msg { max-width: min(82%, 560px); padding: 9px 12px; border-radius: var(--radius-m); background: var(--paper); white-space: pre-wrap; word-wrap: break-word; }
.msg time { display: block; font-size: 11px; opacity: .6; margin-top: 3px; text-align: right; }
.msg.me { align-self: flex-end; background: var(--mine); color: var(--mine-ink); border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; border-bottom-left-radius: 4px; }
.msg .who { font-size: 12px; font-weight: 700; color: var(--ink-soft); margin-bottom: 2px; }

/* сообщение бота — как листовка на доске */
.msg.bot {
  align-self: flex-start; background: var(--paper); border-radius: 2px;
  border-left: 5px solid var(--tab); box-shadow: 0 1px 0 var(--line);
}
.msg.bot .who { color: var(--tab-ink); }
.msg-buttons { display: flex; flex-wrap: wrap; gap: 0; margin: 10px -12px -9px; border-top: 2px dashed var(--line); }
.msg-buttons button {
  flex: 1 1 auto; border: 0; border-right: 1px dashed var(--line); background: var(--tab);
  color: var(--tab-ink); font-weight: 700; padding: 11px 10px;
}
.msg-buttons button:last-child { border-right: 0; background: #fff; color: var(--ink); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; width: min(82%, 420px); }
.photos.me { align-self: flex-end; }
.photos.them { align-self: flex-start; }
.ph { position: relative; aspect-ratio: 1; border-radius: var(--radius-s); overflow: hidden; background: var(--line); border: 0; padding: 0; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph.flag-dup { box-shadow: 0 0 0 3px var(--alarm); }
.ph.flag-old { box-shadow: 0 0 0 3px var(--warn); }
.ph .badge {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; font-weight: 700; line-height: 1.2;
  padding: 3px 4px; color: #fff; background: var(--alarm); text-align: left;
}
.ph.flag-old .badge { background: var(--warn); }
.photos-time { font-size: 11px; color: var(--ink-soft); grid-column: 1 / -1; text-align: right; }
.photos.them .photos-time { text-align: left; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600;
}
.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}
.composer textarea {
  flex: 1; resize: none; max-height: 120px; min-height: 44px; border: 1.5px solid var(--line);
  border-radius: 22px; padding: 10px 14px; background: #fff;
}
.round {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--ink); color: #fff;
}
.round.photo { background: var(--tab); color: var(--tab-ink); }
.round svg { width: 22px; height: 22px; }
.upload-bar { margin: 0 12px; font-size: 13px; color: var(--ink-soft); }

/* просмотр фото */
.lightbox {
  position: fixed; inset: 0; background: rgba(12, 18, 32, .92); z-index: 50; display: flex;
  flex-direction: column; align-items: center; justify-content: center; padding: 16px; gap: 10px;
}
.lightbox .pair { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; max-height: 82vh; overflow: auto; }
.lightbox figure { margin: 0; color: #fff; text-align: center; font-size: 14px; }
.lightbox img { max-width: min(92vw, 900px); max-height: 74vh; display: block; border-radius: 4px; }
.lightbox .pair.two img { max-width: min(92vw, 440px); }
.lightbox .close { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 14px; background: transparent; border: 0; color: #fff; font-size: 30px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: var(--radius-s); z-index: 60; max-width: 90vw;
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .2s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
}

/* фото-примеры в сообщениях Васьки */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-top: 10px; white-space: normal; }
.media-item { border: 0; padding: 0; background: var(--board); border-radius: var(--radius-s); overflow: hidden; text-align: left; display: flex; flex-direction: column; }
.media-item img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; }
.media-item span { font-size: 11px; line-height: 1.25; padding: 4px 5px; color: var(--ink); }
.lb-nav { position: fixed; left: 0; right: 0; top: 50%; display: flex; justify-content: space-between; padding: 0 8px; pointer-events: none; }
.lb-nav button { pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 28px; line-height: 1; }

/* выбор типа фото */
.sheet { position: fixed; inset: 0; background: rgba(12,18,32,.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { background: var(--paper); width: min(480px, 100%); border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 10px; }
.sheet-title { font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.sheet-buttons { display: grid; gap: 8px; }
.sheet-buttons .btn { padding: 14px; font-size: 17px; }

/* подсказка про установку */
.install-bar { display: flex; align-items: center; gap: 8px; background: var(--tab); color: var(--tab-ink); padding: 8px 10px; font-size: 14px; line-height: 1.3; }
.install-bar span { flex: 1; }
.install-x { border: 0; background: transparent; font-size: 22px; color: var(--tab-ink); padding: 0 4px; }

/* отметки на фото в админке */
.ph.flag-bad { box-shadow: 0 0 0 3px var(--warn); }
.ph.flag-bad .badge { background: var(--warn); }
.ph .kind { position: absolute; top: 3px; left: 3px; font-size: 10px; font-weight: 700; background: rgba(28,43,75,.85); color: #fff; padding: 1px 5px; border-radius: 3px; }
.navcount { background: var(--alarm); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; margin-left: 4px; vertical-align: 2px; }

/* голосовые */
.round.mic { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.round.mic.rec { background: var(--alarm); color: #fff; box-shadow: none; }
.composer { position: relative; }
.composer.recording textarea { visibility: hidden; }
.rec-bar { position: absolute; left: 62px; right: 110px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 6px; font-weight: 600; z-index: 2; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--alarm); }
@media (prefers-reduced-motion: no-preference) { .rec-dot { animation: blink 1s infinite; } @keyframes blink { 50% { opacity: .2; } } }
.rec-time { font-variant-numeric: tabular-nums; }
.rec-cancel { margin-left: auto; border: 0; background: transparent; color: var(--alarm); font-weight: 700; padding: 6px; }
.voice { display: grid; gap: 4px; min-width: 220px; }
.voice audio { width: 100%; height: 36px; }
.voice-text { font-size: 14px; white-space: pre-wrap; }
.msg.me .voice-text.muted { color: rgba(255,255,255,.7); }

/* ===== обновлённый вид чатов ===== */
.msg-buttons button { padding: 14px 10px; font-size: 16px; }
.chip { padding: 8px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.msg { box-shadow: 0 1px 2px rgba(20,30,50,.08); }
.chat-head { box-shadow: 0 2px 8px rgba(0,0,0,.15); position: relative; z-index: 2; }

/* промоутеры, расклейка: «доска объявлений» */
body.cat-raskleyka { --board: #EDE4D0; }
body.cat-raskleyka .feed {
  background-color: #EDE4D0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='none' stroke='%23C9B993' stroke-width='1.2' opacity='.55'%3E%3Crect x='14' y='18' width='42' height='54' rx='2' transform='rotate(-6 35 45)'/%3E%3Cpath d='M18 64h34M24 64v10M31 64v10M38 64v10M45 64v10' transform='rotate(-6 35 45)'/%3E%3Crect x='104' y='92' width='48' height='40' rx='2' transform='rotate(5 128 112)'/%3E%3Cpath d='M110 102h34M110 110h26' transform='rotate(5 128 112)'/%3E%3Crect x='112' y='14' width='36' height='46' rx='2' transform='rotate(3 130 37)'/%3E%3Crect x='22' y='112' width='50' height='44' rx='2' transform='rotate(-3 47 134)'/%3E%3Cpath d='M28 146h38M34 146v10M42 146v10M50 146v10M58 146v10' transform='rotate(-3 47 134)'/%3E%3C/g%3E%3Cg fill='%23D94A3D' opacity='.35'%3E%3Ccircle cx='35' cy='20' r='3'/%3E%3Ccircle cx='128' cy='92' r='3'/%3E%3Ccircle cx='130' cy='14' r='3'/%3E%3Ccircle cx='47' cy='112' r='3'/%3E%3C/g%3E%3C/svg%3E");
}
/* промоутеры, ящики: почтовые ящики */
body.cat-yashchiki { --board: #E3EAF2; }
body.cat-yashchiki .feed {
  background-color: #E3EAF2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='96' viewBox='0 0 120 96'%3E%3Cg fill='none' stroke='%23AFC0D3' stroke-width='1.2' opacity='.7'%3E%3Crect x='6' y='6' width='50' height='36' rx='3'/%3E%3Crect x='64' y='6' width='50' height='36' rx='3'/%3E%3Crect x='6' y='52' width='50' height='36' rx='3'/%3E%3Crect x='64' y='52' width='50' height='36' rx='3'/%3E%3Cpath d='M14 14h34M72 14h34M14 60h34M72 60h34'/%3E%3C/g%3E%3Cg fill='%23F2C230' opacity='.45'%3E%3Crect x='24' y='11' width='14' height='5' rx='1'/%3E%3Crect x='82' y='57' width='14' height='5' rx='1'/%3E%3C/g%3E%3Cg fill='%23AFC0D3' opacity='.8'%3E%3Ccircle cx='48' cy='34' r='2'/%3E%3Ccircle cx='106' cy='34' r='2'/%3E%3Ccircle cx='48' cy='80' r='2'/%3E%3Ccircle cx='106' cy='80' r='2'/%3E%3C/g%3E%3C/svg%3E");
}
/* мастера: тёмный фон с инструментами */
body.master { --board: #13203A; }
body.master .feed {
  background-color: #13203A;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%232A3E66' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M36 22a10 10 0 00-13 13L8 50l6 6 15-15a10 10 0 0013-13l-6 6-6-1-1-6z'/%3E%3Cpath d='M110 30l-8 16h10l-8 16'/%3E%3Cpath d='M120 108c0 8-6 13-12 13s-12-5-12-13c0-9 12-22 12-22s12 13 12 22z'/%3E%3Cpath d='M30 104l30 30M52 126l8 8 6-6-8-8'/%3E%3Ccircle cx='80' cy='80' r='6'/%3E%3C/g%3E%3C/svg%3E");
}
body.master .day-sep, body.master .photos-time, body.master .upload-bar { color: #9FB2D6; }
body.master .chips, body.master .composer { background: #13203A; }
body.master .chip { background: #1E2E52; color: #fff; border-color: #3B5488; }
body.master .composer textarea { background: #0F1A30; color: #fff; border-color: #2A3E66; }
body.master .round.mic { background: #1E2E52; color: #fff; box-shadow: none; }
body.master .msg.card { border-left-color: #F2C230; }
.upload-bar { background: var(--paper); padding: 8px 12px; border-radius: 10px; margin: 6px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.1); color: var(--ink); }
.progress { height: 6px; background: var(--line); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.ph.gone { display: grid; place-items: center; background: var(--line); }
.ph.gone .badge { position: static; background: transparent; color: var(--ink-soft); text-align: center; font-weight: 600; }

/* папки маршрутов */
.folder-card { display: flex; align-items: center; gap: 12px; width: min(320px, 82%); margin: 6px 0 6px auto; padding: 12px 14px; border: 0; border-radius: 16px; background: var(--paper); color: var(--ink); box-shadow: 0 2px 8px rgba(20,30,50,.12); text-align: left; cursor: pointer; }
.folder-card .fc-icon { font-size: 30px; }
.folder-card .fc-body { flex: 1; min-width: 0; }
.folder-card .fc-title { font-weight: 800; }
.folder-card .fc-sub { font-size: 13px; color: var(--ink-soft); }
.folder-card .fc-open { font-weight: 700; color: var(--ok); white-space: nowrap; }
.folder-ov { position: fixed; inset: 0; background: rgba(8,12,20,.6); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.folder-box { background: var(--paper); color: var(--ink); width: min(900px, 100%); max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 700px) { .folder-ov { align-items: center; } .folder-box { border-radius: 18px; } }
.folder-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.fh-title { flex: 1; font-weight: 800; font-size: 17px; }
.fh-close { border: 0; background: var(--board); color: var(--ink); width: 36px; height: 36px; border-radius: 50%; font-size: 16px; }
.folder-filt { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.folder-filt .chip.on { background: var(--tab, #F2C230); color: #1D1600; border-color: transparent; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.folder-grid .ph { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--line); }
.folder-grid .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.folder-grid .ph .badge { position: absolute; left: 4px; right: 4px; bottom: 4px; font-size: 10px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 2px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-grid .ph.flag-dup { outline: 3px solid var(--alarm); outline-offset: -3px; }
.sched h2 { margin: 4px 0; }
.sched-row { display: grid; grid-template-columns: 1fr 110px 100px; gap: 8px; align-items: center; padding: 8px; border-radius: 12px; margin-bottom: 6px; background: var(--board); opacity: .6; }
.sched-row.on { opacity: 1; box-shadow: inset 0 0 0 2px var(--tab, #F2C230); }
.sched-day { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.sched-day input { width: 22px; height: 22px; }
