/* ymsg — One Dark (тёмная) / нейтральная (светлая). Предпочтение системы. */
:root {
  --bg: #282c34; --bg-panel: #21252b; --bg-hover: #3e4451;
  --fg: #abb2bf; --fg-muted: #5c6370; --accent: #61afef;
  --bubble-in: #21252b; --bubble-out: #3e4451; --danger: #e06c75;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff; --bg-panel: #f5f6f8; --bg-hover: #e7eaef;
    --fg: #333333; --fg-muted: #8a919c; --accent: #4078c0;
    --bubble-in: #f0f1f3; --bubble-out: #dfe7f3; --danger: #c0392b;
  }
}
* { box-sizing: border-box; }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[x-cloak] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 16px/1.4 system-ui, sans-serif; }
#app { display: flex; flex-direction: column; height: 100dvh; }

.topbar { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--bg-panel); }
.logo { font-weight: 700; }
.spacer { flex: 1; }
.nick { color: var(--fg-muted); font-size: 14px; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--bg-hover); }
.pill.danger { color: var(--danger); }
.ghost { background: none; border: 1px solid var(--fg-muted); color: var(--fg);
  border-radius: 8px; padding: 2px 10px; font-size: 13px; cursor: pointer; }
.accent { background: var(--accent); border: none; color: #fff; border-radius: 8px;
  padding: 8px 16px; font-size: 15px; cursor: pointer; }

.onboard { margin: auto; text-align: center; padding: 24px; max-width: 380px; }
.onboard .big { font-size: 64px; }
.onboard input { width: 100%; padding: 10px; font-size: 16px; border-radius: 8px;
  border: 1px solid var(--fg-muted); background: var(--bg-panel); color: var(--fg); }
.onboard .nick-go { width: 100%; margin-top: 12px; padding: 10px; font-size: 16px; }
.err { color: var(--danger); }
.muted { color: var(--fg-muted); }

.layout { flex: 1; display: flex; min-height: 0; }
.list { width: 42%; max-width: 340px; overflow-y: auto; background: var(--bg-panel);
  border-right: 1px solid var(--bg-hover); padding: 8px; }
.search input { width: 100%; padding: 8px 10px; border-radius: 8px; border: none;
  background: var(--bg-hover); color: var(--fg); }
.row { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; color: var(--fg); padding: 10px 8px;
  border-radius: 8px; font-size: 15px; cursor: pointer; }
.row:hover, .row.active { background: var(--bg-hover); }
.row .last { color: var(--fg-muted); font-size: 20px; }
.badges { margin-left: auto; }
.unread { background: var(--accent); color: #fff; font-size: 12px; border-radius: 10px;
  padding: 1px 7px; }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { padding: 10px 14px; background: var(--bg-panel); font-weight: 600; display: flex; align-items: center; }
@media (min-width: 641px) { .back { display: none; } }
.msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex;
  flex-direction: column; gap: 6px; }
.msg { max-width: 78%; padding: 6px 12px; border-radius: 14px; font-size: 26px;
  line-height: 1.25; word-break: break-word; }
.msg.in { align-self: flex-start; background: var(--bubble-in); }
.msg.out { align-self: flex-end; background: var(--bubble-out); }

.compose { display: flex; align-items: center; gap: 8px; padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-panel); }
.input { flex: 1; padding: 10px; font-size: 20px; border-radius: 10px; border: none;
  background: var(--bg-hover); color: var(--fg); min-height: 44px; cursor: pointer;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.input.empty span { color: var(--fg-muted); }
.bks { font-size: 20px; background: none; border: none; color: var(--fg-muted); cursor: pointer;
  min-width: 44px; min-height: 44px; }
.counter { color: var(--fg-muted); font-size: 12px; min-width: 40px; text-align: center; }
.send { font-size: 22px; background: none; border: none; cursor: pointer; color: var(--accent);
  min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.send:disabled { opacity: 0.35; cursor: default; }

.picker { background: var(--bg-panel); padding: 8px; border-top: 1px solid var(--bg-hover);
  display: flex; flex-direction: column; gap: 6px; }
.psearch { padding: 7px 10px; border-radius: 8px; border: none;
  background: var(--bg-hover); color: var(--fg); font-size: 16px; }
.recents, .cats { display: flex; flex-wrap: wrap; gap: 2px; }
.cats { justify-content: space-between; }
.cat { font-size: 20px; background: none; border: none; cursor: pointer;
  border-radius: 6px; padding: 8px 9px; opacity: 0.55; }
.cat.on { opacity: 1; background: var(--bg-hover); }
.grid { max-height: 38vh; overflow-y: auto; position: relative; }
.sticky { position: sticky; top: 0; background: var(--bg-panel); color: var(--fg-muted);
  font-size: 12px; padding: 4px 2px; z-index: 1; }
.cells { display: flex; flex-wrap: wrap; }
.cell { font-size: 26px; line-height: 1; background: none; border: none; cursor: pointer;
  padding: 9px; border-radius: 8px; min-width: 44px; min-height: 44px; }
.cell:hover { background: var(--bg-hover); }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--bg-hover); color: var(--fg); padding: 10px 18px;
  border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,.35); font-size: 20px; }

.pushbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center;
  gap: 10px; justify-content: center; padding: 12px 14px; background: var(--bg-panel);
  border-top: 1px solid var(--bg-hover); box-shadow: 0 -2px 12px rgba(0,0,0,.25); font-size: 16px; }
.pushbar button { padding: 8px 16px; border-radius: 8px; font-size: 15px; cursor: pointer; }

@media (max-width: 640px) {
  .layout { flex-direction: column; }
  .layout .chat { display: none; }
  .layout .list { width: 100%; max-width: none; border-right: none; flex: 1; }
  .layout.open .list { display: none; }
  .layout.open .chat { display: flex; }
}
.back { background: none; border: none; color: var(--fg); font-size: 26px; line-height: 1;
  padding: 0 10px 0 4px; cursor: pointer; min-width: 44px; min-height: 44px; }
