/* chat.rus21.ru — 2026 edition, winter skin.
   Winter / dark / classic 2002. No frameworks, no build step. */

:root {
  --bg: #e4eaf2;
  --surface: #fbfdff;
  --surface-2: #f1f6fc;
  --surface-3: #e3ecf8;
  --text: #16233b;
  --muted: #5e7290;
  --line: #c8d7e8;
  --accent: #2f5fb3;
  --accent-2: #6d8fd1;
  --accent-soft: #dce8f8;
  --danger: #cf3b4a;
  --success: #1f9d6a;
  --warning: #d98b1f;
  --gold: #b07050;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(22 35 59 / .05), 0 16px 40px rgb(47 95 179 / .12);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --topbar-h: 64px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0d1015;
  --surface: #151920;
  --surface-2: #1a1f28;
  --surface-3: #202633;
  --text: #e9ecf2;
  --muted: #98a2b3;
  --line: #262d3a;
  --accent: #7aa2ff;
  --accent-2: #a78bfa;
  --accent-soft: #1b2742;
  --danger: #ff6b6b;
  --success: #3ddc97;
  --warning: #ffb547;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 18px 48px rgb(0 0 0 / .35);
  color-scheme: dark;
}

[data-theme="classic"] {
  --bg: #071426;
  --surface: #0b1f3a;
  --surface-2: #0e2748;
  --surface-3: #12325c;
  --text: #e6f0ff;
  --muted: #8fb0d9;
  --line: #2a4a7a;
  --accent: #ffd166;
  --accent-2: #7bdff2;
  --accent-soft: #1b3a63;
  --danger: #ff7b7b;
  --success: #6ee7a8;
  --warning: #ffc857;
  --radius: 0px;
  --radius-sm: 0px;
  --shadow: none;
  --font: var(--mono);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[data-theme="winter"] body {
  background:
    url("snow.svg") repeat,
    radial-gradient(1100px 620px at 12% -12%, #ffffff 0%, transparent 58%),
    radial-gradient(900px 520px at 100% 0%, #d6e5f7 0%, transparent 55%),
    var(--bg);
  background-size: 180px 180px, auto, auto, auto;
}

[data-theme="dark"] body {
  background:
    radial-gradient(1100px 600px at 15% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--accent-2) 9%, transparent), transparent 55%),
    var(--bg);
}

[data-theme="classic"] body { background: var(--bg); }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.app {
  height: 100dvh;
  max-width: 1600px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas:
    "top top"
    "chat users";
  gap: 14px;
}

/* ---------- top bar ---------- */

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

[data-theme="winter"] .topbar {
  position: relative;
  overflow: hidden;
  background:
    url("snow.svg") repeat,
    linear-gradient(180deg, #f8fbff 0%, #dce9f8 55%, #c9dcf2 100%);
  background-size: 180px 180px, auto;
  border-color: #b9cde4;
  box-shadow: 0 10px 30px rgb(47 95 179 / .13);
}

[data-theme="winter"] .topbar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 16px;
  background: url("snow-cap.svg") repeat-x;
  background-size: 120px 16px;
  pointer-events: none;
  z-index: 0;
}

[data-theme="winter"] .topbar > * { position: relative; z-index: 1; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-flake {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--accent);
}

.brand-flake svg { width: 100%; height: 100%; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.brand-sub::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 16%, transparent);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 11px;
  font-size: 18px;
  line-height: 1;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

[data-theme="classic"] .icon-btn { border-radius: 0; }

.avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: hsl(var(--avatar-h, 222) 70% 93%);
  color: hsl(var(--avatar-h, 222) 55% 38%);
  font-weight: 700;
  font-size: 14px;
  user-select: none;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}

[data-theme="dark"] .avatar {
  background: hsl(var(--avatar-h, 222) 38% 22%);
  color: hsl(var(--avatar-h, 222) 75% 78%);
}

.avatar-me {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: 0;
  cursor: pointer;
}

.avatar.tiny { width: 24px; height: 24px; font-size: 10px; }

[data-theme="classic"] .avatar { border-radius: 3px; background: var(--surface-3); color: var(--accent); }

/* ---------- panels ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.users-panel { grid-area: users; }

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 10px;
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 700;
}

.panel-head .icon-btn { margin-left: auto; }

.pill {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

[data-theme="classic"] .pill { border-radius: 0; border: 1px solid var(--line); background: transparent; }

.panel-foot {
  margin: 0 16px 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.user-list {
  list-style: none;
  margin: 0;
  padding: 4px 8px 8px;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
}

/* ---------- native commands frame under the user list ---------- */

.commands {
  flex: 0 0 auto;
  min-width: 0;
  margin: 8px;
  padding: 4px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.commands legend {
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.command-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.command-btn {
  appearance: auto;
  -webkit-appearance: auto;
  padding: 3px 9px;
  border: 1px solid ButtonBorder;
  border-radius: 3px;
  background: ButtonFace;
  color: ButtonText;
  font: 12px var(--font);
  text-align: center;
  box-shadow: none;
}

.command-btn:hover { filter: brightness(.96); }

.command-btn.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: ButtonFace;
  border-color: ButtonBorder;
  color: ButtonText;
}

.command-links {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.command-links button {
  padding: 0;
  border: 0;
  background: transparent;
  color: LinkText;
  text-decoration: underline;
  font: 11px var(--font);
}

.command-links button:hover { filter: brightness(.9); }

[data-theme="classic"] .commands { border-radius: 0; }
[data-theme="classic"] .command-btn { border-radius: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 70;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow);
}

.user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .12s ease;
}

.user-item:hover { background: var(--surface-2); }
.user-item.active { background: var(--accent-soft); }
.user-item.active .user-nick { color: var(--accent); }
[data-theme="classic"] .user-item { border-radius: 0; }

.user-item .avatar { width: 34px; height: 34px; font-size: 12px; }

.user-meta { min-width: 0; display: flex; flex-direction: column; }
.user-nick { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.user-status { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }

.presence {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent);
}
.presence.away { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 18%, transparent); }
.presence.offline { background: var(--muted); box-shadow: none; }

.role-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- chat ---------- */

.chat {
  grid-area: chat;
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

[data-theme="winter"] .chat,
[data-theme="winter"] .panel {
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

/* Топик — разделитель в ленте, по ширине как «Сегодня». */
.topic-message {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}

.topic-message::before, .topic-message::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.topic-label {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

.topic-text {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  overflow-wrap: anywhere;
}

.messages {
  --msg-pad-x: 20px;
  --msg-pad-y: 18px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--msg-pad-y) var(--msg-pad-x) 10px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}

.date-divider::before, .date-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.system-message {
  margin: 10px auto;
  width: fit-content;
  max-width: 90%;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

[data-theme="classic"] .system-message { border-radius: 0; }

.message {
  display: flex;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 12px;
  transition: background .12s ease;
}

.message:hover { background: var(--surface-2); }
.message.grouped { margin-top: -2px; }
.message.grouped .avatar, .message.grouped .message-head { visibility: hidden; height: 0; margin: 0; padding: 0; overflow: hidden; }
.message.grouped .message-main { margin-top: -4px; }

.message .avatar { width: 36px; height: 36px; font-size: 12px; margin-top: 2px; }

.message-main { min-width: 0; flex: 1; }

.message-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 1px;
}

.message-nick { font-size: 13.5px; font-weight: 700; }
.message-time { color: var(--muted); font-size: 11px; }

.message-text {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message.own .message-nick { color: var(--accent); }

[data-theme="classic"] .message { padding: 2px 8px; border-radius: 0; }
[data-theme="classic"] .message:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
[data-theme="classic"] .message .avatar { display: none; }
[data-theme="classic"] .message-nick::before { content: "<"; color: var(--muted); }
[data-theme="classic"] .message-nick::after { content: ">"; color: var(--muted); }
[data-theme="classic"] .message-text { font-family: var(--mono); font-size: 13.5px; }

/* ---------- composer ---------- */

.typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 22px 2px;
  color: var(--muted);
  font-size: 12px;
}

.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted);
  animation: bounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.composer textarea {
  flex: 1;
  min-height: 42px;
  max-height: 160px;
  resize: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.composer textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
  background: var(--surface);
}

[data-theme="classic"] .composer textarea { border-radius: 0; background: var(--surface-2); }

.counter {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: right;
  opacity: 0;
  transition: opacity .15s ease;
}
.counter.show { opacity: 1; }

.send-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: transform .12s ease, filter .12s ease;
}
.send-btn:hover { filter: brightness(1.06); }
.send-btn:active { transform: scale(.96); }
[data-theme="classic"] .send-btn { border-radius: 0; box-shadow: none; background: var(--accent); color: #071426; }
[data-theme="classic"] .avatar-me { background: var(--surface-3); color: var(--accent); border: 1px solid var(--line); }

.emoji-pop {
  position: absolute;
  left: 14px;
  bottom: 68px;
  width: 292px;
  max-height: 232px;
  overflow-y: auto;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.emoji-pop button {
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  padding: 6px;
  border-radius: 8px;
}
.emoji-pop button:hover { background: var(--surface-2); }

/* ---------- recipient / inline private ---------- */

.target-wrap { position: relative; flex: 0 0 auto; align-self: flex-end; }

.target-btn {
  height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.target-btn:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); color: var(--text); }
.target-btn.active { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.target-prefix { color: var(--muted); font-weight: 500; }
.target-caret { color: var(--muted); font-size: 10px; }
[data-theme="classic"] .target-btn { border-radius: 0; }

.target-pop {
  position: absolute;
  left: 0;
  bottom: 52px;
  width: 236px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.target-pop button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font-size: 13.5px;
}

.target-pop button:hover { background: var(--surface-2); }
.target-pop .target-all { border-bottom: 1px solid var(--line); border-radius: 9px 9px 0 0; margin-bottom: 4px; }
.target-pop .target-all.active { color: var(--accent); }
.target-empty { padding: 10px; color: var(--muted); font-size: 12px; }
[data-theme="classic"] .target-pop, [data-theme="classic"] .target-pop button { border-radius: 0; }

.message.private {
  box-shadow: inset 3px 0 0 var(--accent);
}

.message.private.outgoing {
  background: rgb(217 164 65 / .16);
  box-shadow: inset 3px 0 0 #d9a441;
}
.message.private.outgoing:hover { background: rgb(217 164 65 / .24); }
.message.private.outgoing .message-nick { color: #8a5a12; }
.message.private.outgoing .private-badge { background: rgb(217 164 65 / .22); color: #8a5a12; }

.message.private:not(.outgoing) {
  background: rgb(47 157 106 / .14);
  box-shadow: inset 3px 0 0 #2f9d6a;
}
.message.private:not(.outgoing):hover { background: rgb(47 157 106 / .22); }
.message.private:not(.outgoing) .message-nick { color: #1f7a52; }
.message.private:not(.outgoing) .private-badge { background: rgb(47 157 106 / .20); color: #1f7a52; }

[data-theme="dark"] .message.private.outgoing {
  background: rgb(201 154 69 / .20);
  box-shadow: inset 3px 0 0 #c99a45;
}
[data-theme="dark"] .message.private.outgoing:hover { background: rgb(201 154 69 / .28); }
[data-theme="dark"] .message.private.outgoing .message-nick { color: #f0c36a; }
[data-theme="dark"] .message.private.outgoing .private-badge { background: rgb(201 154 69 / .24); color: #f0c36a; }

[data-theme="dark"] .message.private:not(.outgoing) {
  background: rgb(61 220 151 / .16);
  box-shadow: inset 3px 0 0 #3ddc97;
}
[data-theme="dark"] .message.private:not(.outgoing):hover { background: rgb(61 220 151 / .24); }
[data-theme="dark"] .message.private:not(.outgoing) .message-nick { color: #7ee2b0; }
[data-theme="dark"] .message.private:not(.outgoing) .private-badge { background: rgb(61 220 151 / .20); color: #7ee2b0; }

[data-theme="classic"] .message.private {
  background: transparent;
  box-shadow: inset 3px 0 0 var(--accent);
}
[data-theme="classic"] .message.private.outgoing {
  background: rgb(255 209 102 / .14);
  box-shadow: inset 3px 0 0 #ffd166;
}
[data-theme="classic"] .message.private.outgoing:hover { background: rgb(255 209 102 / .22); }
[data-theme="classic"] .message.private:not(.outgoing) {
  background: rgb(110 231 168 / .12);
  box-shadow: inset 3px 0 0 #6ee7a8;
}
[data-theme="classic"] .message.private:not(.outgoing):hover { background: rgb(110 231 168 / .20); }
[data-theme="classic"] .message.private .message-nick { color: var(--accent); }

.private-badge {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  vertical-align: 1px;
}

[data-theme="classic"] .private-badge { border-radius: 0; border: 1px solid var(--line); background: transparent; }

/* ---------- profile sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgb(9 12 18 / .45);
  backdrop-filter: blur(3px);
  z-index: 40;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
}

.sheet-card {
  width: min(460px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgb(0 0 0 / .28);
  padding: 18px;
}

[data-theme="classic"] .sheet-card { border-radius: 0; box-shadow: none; }

.sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-head .icon-btn { margin-left: auto; }

.profile-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin: 10px 0 16px;
}
.profile-preview .avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.profile-preview strong { display: block; }
.muted { color: var(--muted); font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field input {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }

.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 16px; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.themes { border: 0; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 8px; }
.themes legend { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.themes label { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.themes label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.themes input { accent-color: var(--accent); }

.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
[data-theme="classic"] .btn, [data-theme="classic"] .themes label, [data-theme="classic"] .field input, [data-theme="classic"] .profile-preview { border-radius: 0; }

/* ---------- responsive ---------- */

.only-mobile { display: none; }

@media (max-width: 1180px) {
  .app {
    grid-template-columns: minmax(0, 1fr) 260px;
    grid-template-areas:
      "top top"
      "chat users";
  }
}

@media (max-width: 760px) {
  .app {
    padding: 0;
    gap: 0;
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) minmax(0, 1fr);
    grid-template-areas:
      "top"
      "chat";
  }

  .topbar, .chat {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .topbar { position: relative; z-index: 20; }

  .only-mobile { display: inline-grid; }

  .users-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 88vw);
    z-index: 45;
    border-radius: 0;
    transform: translateX(102%);
    transition: transform .2s ease;
  }
  .users-panel.open { transform: none; }

  .messages { --msg-pad-x: 12px; --msg-pad-y: 14px; padding: var(--msg-pad-y) var(--msg-pad-x) 8px; }
  .message { padding: 6px; }
  .message .avatar { width: 32px; height: 32px; }
  .composer { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .counter { display: none; }
  .target-prefix { display: none; }
  .target-btn { padding: 0 8px; }
  .emoji-pop { left: 10px; right: 10px; width: auto; bottom: 64px; grid-template-columns: repeat(8, 1fr); }
  .brand-sub { display: none; }
  .sheet { align-items: end; padding: 0; }
  .sheet-card { width: 100%; border-radius: 20px 20px 0 0; max-height: 88dvh; }
  [data-theme="classic"] .sheet-card { border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* thin scrollbars */
.messages, .user-list, .emoji-pop, .sheet-card {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 35%, transparent) transparent;
}
.messages::-webkit-scrollbar, .user-list::-webkit-scrollbar,
.emoji-pop::-webkit-scrollbar,
.sheet-card::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb, .user-list::-webkit-scrollbar-thumb,
.emoji-pop::-webkit-scrollbar-thumb,
.sheet-card::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 999px;
}
