:root {
  --bg: #f6f2ea;
  --chat-bg: #ece6da;
  --surface: #ffffff;
  --surface-2: #f0ebe1;
  --surface-glass: rgba(255, 255, 255, .82);
  --text: #1b221e;
  --muted: #6f766f;
  --accent: #2a7a63;
  --accent-2: #3a9478;
  --accent-soft: #dcefe7;
  --accent-text: #ffffff;
  --warm: #e2725b;
  --mine: #d3eedf;
  --other: #ffffff;
  --border: #e5ded1;
  --danger: #c63f31;
  --shadow-sm: 0 1px 1.5px rgba(40, 30, 10, .10);
  --shadow-md: 0 4px 14px rgba(40, 30, 10, .12);
  --shadow-lg: 0 14px 40px rgba(40, 30, 10, .22);
  --name-l: 36%;
  --avatar-l: 48%;
  --radius: 19px;
  --ease: cubic-bezier(.2, .8, .25, 1);
  --sat: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --sab: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --sal: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  --sar: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513;
    --chat-bg: #0c100e;
    --surface: #1a201d;
    --surface-2: #232a26;
    --surface-glass: rgba(26, 32, 29, .82);
    --text: #e9eeeb;
    --muted: #8f9a93;
    --accent: #5cbf9f;
    --accent-2: #6fd0b0;
    --accent-soft: #1d3a31;
    --accent-text: #0a1310;
    --mine: #1f4237;
    --other: #1d2421;
    --border: #29312d;
    --danger: #f07a6c;
    --shadow-sm: none;
    --shadow-md: 0 4px 14px rgba(0, 0, 0, .35);
    --shadow-lg: 0 14px 40px rgba(0, 0, 0, .55);
    --name-l: 70%;
    --avatar-l: 42%;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
h1 { font-size: 19px; }
h2 { font-size: 20px; margin-bottom: 14px; }
p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: var(--accent); }

.sprite { position: absolute; width: 0; height: 0; }
.ic {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- формы и кнопки ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
input, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
  transition: border-color .15s;
}
textarea { resize: none; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; word-break: break-all; }
.hint { font-size: 13px; color: var(--muted); margin: -4px 0 14px; }
.hint.center { text-align: center; margin: 10px 0 0; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  margin-top: 8px;
  border: 0;
  border-radius: 15px;
  background: var(--surface-2);
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s var(--ease), filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-text); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn .ic { width: 20px; height: 20px; }

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, transform .12s;
}
.icon-btn:active { background: var(--surface-2); transform: scale(.92); }
.icon-btn.sm { width: 36px; height: 36px; }
.icon-btn.sm .ic { width: 18px; height: 18px; }

/* ---------- аватары ---------- */
.avatar {
  --h: 160;
  flex: none;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(140deg, hsl(var(--h) 52% calc(var(--avatar-l) + 10%)), hsl(var(--h) 58% var(--avatar-l)));
  color: #fff;
  font-weight: 700;
  font-size: 21px;
  text-transform: uppercase;
  user-select: none;
}
.avatar.sm { width: 40px; height: 40px; font-size: 17px; }

/* ---------- первый запуск ---------- */
#setup { height: 100dvh; overflow-y: auto; display: flex; }
.setup-box {
  margin: auto;
  width: 100%;
  max-width: 400px;
  padding: calc(32px + var(--sat)) 16px calc(32px + var(--sab));
  text-align: center;
}
.logo { width: 100px; height: 100px; margin-bottom: 18px; filter: drop-shadow(0 10px 22px rgba(42, 122, 99, .35)); animation: float 4s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
.setup-box h1 { font-size: 30px; }
.lead { color: var(--muted); margin: 10px auto 24px; max-width: 320px; }
.card { text-align: left; padding: 20px 16px 12px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-md); }

/* ---------- раскладка: список + чат ---------- */
#app { position: fixed; inset: 0; overflow: hidden; }
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition: transform .32s var(--ease);
  will-change: transform;
}
#list { padding-left: var(--sal); padding-right: var(--sar); }
#list::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  opacity: var(--dim, 0);
  pointer-events: none;
  transition: opacity .32s var(--ease);
}
#chat {
  transform: translateX(100%);
  box-shadow: -10px 0 30px rgba(0, 0, 0, .12);
  touch-action: pan-y;
  z-index: 2;
}
body.chat-open #chat { transform: translateX(0); }
body.chat-open #list { transform: translateX(-25%); --dim: .35; }
.placeholder { display: none; }

@media (min-width: 860px) {
  #app { display: grid; grid-template-columns: minmax(320px, 380px) 1fr; grid-template-rows: 100%; }
  .screen { position: relative; inset: auto; height: 100%; min-height: 0; transform: none !important; transition: none; box-shadow: none; }
  #chat .messages { padding-left: max(16px, calc((100% - 860px) / 2)); padding-right: max(16px, calc((100% - 860px) / 2)); }
  #chat .composer-wrap { padding-left: max(12px, calc((100% - 880px) / 2)); padding-right: max(12px, calc((100% - 880px) / 2)); }
  .unread-line { margin-left: 0; margin-right: 0; border-radius: 10px; }
  #list { border-right: 1px solid var(--border); --dim: 0 !important; }
  #chat { grid-column: 2; grid-row: 1; }
  body:not(.chat-open) #chat { display: none; }
  .placeholder {
    grid-column: 2; grid-row: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: var(--chat-bg); color: var(--muted);
  }
  body.chat-open .placeholder { display: none; }
  .placeholder img { width: 84px; opacity: .85; }
  .back { display: none; }
  .fab { position: absolute; right: 20px; }
}

/* ---------- шапка ---------- */
.bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 60px;
  padding: calc(8px + var(--sat)) calc(6px + var(--sar)) 8px calc(6px + var(--sal));
  background: var(--surface-glass);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--border);
}
#list .bar { padding-left: 18px; padding-right: 6px; border-bottom: 0; background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
.bar-big h1 { font-size: 30px; font-weight: 750; letter-spacing: -.025em; }
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.status { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .6; animation: pulse 1.2s infinite; }
.online .dot { background: var(--accent); opacity: 1; animation: none; }
@keyframes pulse { 50% { opacity: .15; } }

.chat-head {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.chat-head:active { background: var(--surface-2); }
.chat-head .title { font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub.typing, .prev.typing { color: var(--accent); }
.sub.typing::after, .prev.typing .txt::after { content: ""; display: inline-block; width: 1em; animation: dots 1.2s steps(4) infinite; text-align: left; }

/* ---------- список чатов ---------- */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 14px 8px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--muted);
}
.search .ic { width: 18px; height: 18px; }
.search input { margin: 0; padding: 11px 0; border: 0; background: transparent; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.chats { list-style: none; margin: 0; padding: 4px 0 calc(110px + var(--sab)); overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.chat-item {
  display: flex;
  gap: 13px;
  align-items: center;
  margin: 0 8px;
  padding: 10px;
  border-radius: 18px;
  cursor: pointer;
  user-select: none;
  transition: background .15s, transform .15s var(--ease);
}
.chat-item:active { background: var(--surface); transform: scale(.985); }
.chat-item.active { background: var(--accent-soft); }
@media (hover: hover) { .chat-item:hover { background: var(--surface); } .chat-item.active:hover { background: var(--accent-soft); } }
.chat-main { flex: 1; min-width: 0; }
.chat-top, .chat-bottom { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.chat-top b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flags { display: flex; gap: 2px; margin-right: auto; color: var(--muted); }
.flags .ic { width: 14px; height: 14px; }
.chat-top time { font-size: 12px; color: var(--muted); flex: none; }
.chat-item.unread .chat-top time { color: var(--accent); font-weight: 600; }
.prev { color: var(--muted); font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.prev .who { color: var(--text); opacity: .85; }
.badge {
  flex: none;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}
.badge.muted { background: var(--muted); color: var(--bg); }
.empty { flex: 1; text-align: center; padding: 56px 32px; color: var(--muted); }
.empty-logo { width: 84px; height: 84px; margin-bottom: 16px; }
.empty h2 { color: var(--text); margin-bottom: 8px; }
.fab {
  position: fixed;
  right: calc(20px + var(--sar));
  bottom: calc(24px + var(--sab));
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  color: var(--accent-text);
  box-shadow: 0 8px 22px rgba(42, 122, 99, .42);
  cursor: pointer;
  transition: transform .15s var(--ease);
}
.fab:active { transform: scale(.9) rotate(90deg); }
.fab .ic { width: 28px; height: 28px; stroke-width: 2.4; }

/* ---------- переписка ---------- */
#chat .bar { padding-left: calc(2px + var(--sal)); }
.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px calc(10px + var(--sar)) 12px calc(10px + var(--sal));
  display: flex;
  flex-direction: column;
  background-color: var(--chat-bg);
  background-image: radial-gradient(color-mix(in srgb, var(--accent) 13%, transparent) 1px, transparent 1.6px);
  background-size: 22px 22px;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.e2e-note {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 300px;
  margin: 12px auto 4px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  box-shadow: var(--shadow-sm);
}
.e2e-note .ic { width: 16px; height: 16px; color: var(--accent); }
.day {
  position: sticky;
  top: 6px;
  z-index: 1;
  align-self: center;
  margin: 12px 0 4px;
  padding: 4px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.unread-line {
  align-self: stretch;
  margin: 12px -10px 4px;
  padding: 5px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.msg {
  --h: 160;
  position: relative;
  align-self: flex-start;
  max-width: min(80%, 540px);
  margin-top: 8px;
  padding: 6px 10px 5px 11px;
  border-radius: var(--radius);
  border-top-left-radius: 6px;
  background: var(--other);
  box-shadow: var(--shadow-sm);
  overflow-wrap: anywhere;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform .25s var(--ease);
  animation: pop .22s var(--ease);
}
@media (pointer: fine) { .msg { user-select: text; -webkit-user-select: text; } }
.msg.mine { align-self: flex-end; background: var(--mine); border-radius: var(--radius); border-top-right-radius: 6px; }
.msg.cont { margin-top: 2px; border-radius: var(--radius); }
.msg.err, .msg.deleted { background: transparent; box-shadow: none; border: 1px dashed var(--border); }
.msg.pending { opacity: .75; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.msg.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 60%, transparent); } }
.msg.reacted .reactions { animation: bounce .35s var(--ease); }
@keyframes bounce { 40% { transform: scale(1.12); } }

/* стрелка «ответить» при свайпе */
.msg::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -44px;
  width: 30px;
  height: 30px;
  margin-top: -15px;
  border-radius: 50%;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232a7a63' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 17l-5-5 5-5'/%3E%3Cpath d='M20 18v-2a4 4 0 0 0-4-4H4'/%3E%3C/svg%3E") center / 18px no-repeat;
  box-shadow: var(--shadow-sm);
  opacity: var(--reply-p, 0);
  transform: scale(calc(.5 + var(--reply-p, 0) * .5));
  pointer-events: none;
}

.msg .from { font-size: 13.5px; font-weight: 650; color: hsl(var(--h) 55% var(--name-l)); margin-bottom: 1px; }
.msg .text { white-space: pre-wrap; }
.msg .text.muted { font-style: italic; color: var(--muted); font-size: 14px; }
.msg .meta {
  float: right;
  position: relative;
  top: 7px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 10px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.msg .tick { width: 14px; height: 14px; color: var(--accent); stroke-width: 2.4; }
.msg.pending .tick { color: var(--muted); stroke-width: 2; }

.quote {
  --h: 160;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 140px;
  margin: 2px 0 5px;
  padding: 5px 9px;
  border: 0;
  border-left: 3px solid hsl(var(--h) 55% var(--name-l));
  border-radius: 8px;
  background: color-mix(in srgb, hsl(var(--h) 55% var(--name-l)) 11%, transparent);
  text-align: left;
  cursor: pointer;
}
.quote b { font-size: 13px; color: hsl(var(--h) 55% var(--name-l)); }
.quote span { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg.photo { padding: 3px; }
.msg.photo .from, .msg.photo .quote { margin: 3px 6px 4px; width: auto; }
.msg img { display: block; max-width: 100%; max-height: 380px; min-width: 120px; border-radius: 16px; cursor: zoom-in; }
.msg.photo .meta {
  position: absolute;
  right: 10px;
  bottom: 9px;
  top: auto;
  padding: 2px 7px;
  border-radius: 9px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
}
.msg.photo .tick { color: #fff; }
.msg.photo .reactions { margin: 4px 4px 2px; }

.msg.jumbo { background: transparent; box-shadow: none; padding: 0 2px; }
.msg.jumbo .text { font-size: 46px; line-height: 1.1; }
.msg.jumbo .meta { float: none; display: flex; justify-content: flex-end; top: 0; }

.reactions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px; clear: both; margin-top: 6px; }
.reactions .meta { float: none; top: 0; margin-left: auto; padding-left: 8px; }
.msg.photo .reactions .meta { position: static; background: none; color: var(--muted); padding: 0 6px 2px 8px; }
.msg.photo .reactions .tick { color: var(--accent); }
.react {
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  transition: transform .12s;
}
.react:active { transform: scale(.9); }
.react.me { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }

.down-btn {
  position: absolute;
  right: calc(14px + var(--sar));
  bottom: calc(80px + var(--sab));
  z-index: 3;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  animation: pop .2s var(--ease);
}
.down-btn .badge { position: absolute; top: -6px; right: -4px; }

.composer-wrap {
  position: relative;
  z-index: 3;
  padding: 6px calc(8px + var(--sar)) calc(8px + var(--sab)) calc(8px + var(--sal));
  background: var(--surface-glass);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--border);
}
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 8px 8px;
  color: var(--accent);
  animation: slideUp .2s var(--ease);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } }
.reply-bar-body { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-left: 10px; border-left: 3px solid var(--accent); }
.reply-bar-body b { font-size: 13.5px; }
.reply-bar-body span { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.composer { display: flex; align-items: flex-end; gap: 6px; }
.composer .attach { color: var(--muted); }
.composer textarea {
  margin: 0;
  flex: 1;
  min-height: 44px;
  max-height: 150px;
  padding: 10px 16px;
  border-radius: 22px;
  border-color: transparent;
  background: var(--surface-2);
  line-height: 1.4;
}
.composer textarea:focus { border-color: transparent; }
.send-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
  color: var(--accent-text);
  cursor: pointer;
  transition: transform .2s var(--ease), opacity .2s, background .2s;
}
.send-btn:disabled { background: var(--surface-2); color: var(--muted); transform: scale(.88); cursor: default; }
.send-btn:not(:disabled):active { transform: scale(.88); }
.send-btn .ic { stroke-width: 2.5; }
.drop-hint {
  position: absolute;
  inset: 70px 16px 90px;
  z-index: 5;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 24px;
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
  color: var(--accent);
  font-weight: 650;
  pointer-events: none;
}

/* ---------- меню сообщения ---------- */
.msg-menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 15, 12, .35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.msg-menu-inner {
  position: absolute;
  left: calc(14px + var(--sal));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  width: min(300px, calc(100% - 28px));
}
.msg-menu.right .msg-menu-inner { left: auto; right: calc(14px + var(--sar)); align-items: flex-end; }
.msg-menu.show .msg-menu-inner > * { animation: menuIn .22s var(--ease) both; }
.msg-menu.show .menu-preview { animation-delay: .02s; }
.msg-menu.show .menu-list { animation-delay: .05s; }
@keyframes menuIn { from { opacity: 0; transform: scale(.92); } }
.react-bar {
  display: flex;
  gap: 2px;
  padding: 5px;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform-origin: left bottom;
}
.react-bar button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s var(--ease);
}
.react-bar button:active, .react-bar button:hover { transform: scale(1.25); }
.react-bar button.me { background: var(--accent-soft); }
.menu-preview {
  max-width: 100%;
  max-height: 30vh;
  overflow: hidden;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--other);
  box-shadow: var(--shadow-md);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}
.menu-preview.mine { background: var(--mine); }
.menu-preview img { display: block; max-width: 220px; max-height: 26vh; border-radius: 12px; margin: -4px -8px; }
.menu-list {
  display: flex;
  flex-direction: column;
  min-width: 220px;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.menu-list button {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border: 0;
  background: transparent;
  font-size: 15.5px;
  text-align: left;
  cursor: pointer;
}
.menu-list button + button { border-top: 1px solid var(--border); }
.menu-list button:active { background: var(--surface-2); }
.menu-list .ic { width: 20px; height: 20px; color: var(--muted); }
.menu-list .danger, .menu-list .danger .ic { color: var(--danger); }

/* ---------- нижние панели ---------- */
dialog.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  margin: auto auto 0;
  padding: 8px calc(18px + var(--sar)) calc(14px + var(--sab)) calc(18px + var(--sal));
  border: 0;
  border-radius: 26px 26px 0 0;
  background: var(--bg);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
}
dialog.sheet[open] { animation: up .28s var(--ease); }
dialog::backdrop { background: rgba(10, 15, 12, .45); animation: fade .2s; }
@keyframes up { from { transform: translateY(60px); opacity: .3; } }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 26px; } }
.handle { width: 40px; height: 5px; margin: 4px auto 14px; border-radius: 3px; background: var(--border); }
.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
dialog .menu-list { box-shadow: none; margin-bottom: 8px; }
dialog p { font-size: 14px; }

.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 18px; background: var(--surface-2); border-radius: 15px; }
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.tab .ic { width: 18px; height: 18px; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.notice { display: flex; gap: 12px; padding: 12px 14px; margin-bottom: 12px; border-radius: 15px; background: var(--accent-soft); font-size: 14px; }
.notice .ic { color: var(--accent); margin-top: 1px; }

/* ---------- баннер, фото, всплывашки ---------- */
.banner {
  position: fixed;
  top: calc(8px + var(--sat));
  left: 50%;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  width: calc(100% - 16px);
  max-width: 460px;
  padding: 10px 14px;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: left;
  cursor: pointer;
  transform: translateX(-50%);
}
.banner.show { animation: drop .32s var(--ease); }
@keyframes drop { from { transform: translate(-50%, -40px); opacity: 0; } }
.banner-body { min-width: 0; display: flex; flex-direction: column; }
.banner-body b { font-size: 14.5px; }
.banner-body span { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(0, 0, 0, calc(.95 * var(--bg-a, 1)));
  touch-action: none;
  animation: fade .2s;
}
.viewer.closing { animation: fade .18s reverse forwards; }
.viewer img { max-width: 100%; max-height: 100%; transform-origin: center; user-select: none; -webkit-user-drag: none; }
.viewer-btn {
  position: absolute;
  top: calc(12px + var(--sat));
  right: calc(12px + var(--sar));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--sab));
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 11px 18px;
  border-radius: 15px;
  background: #1d2420;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  transform: translateX(-50%);
  animation: toastIn .25s var(--ease);
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
