/* ==========================================================================
   Nimble · base design system
   tokens · themes · background · buttons · fields · avatars · overlays
   ========================================================================== */

/* ------------------------------- tokens --------------------------------- */
:root {
  --bg:        #070a16;
  --bg-2:      #0b1020;
  --bg-3:      #101736;

  --surface:      rgba(255, 255, 255, .05);
  --surface-2:    rgba(255, 255, 255, .08);
  --surface-3:    rgba(255, 255, 255, .12);
  --surface-solid: #121a33;

  --border:        rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .16);

  --text:   #e9eeff;
  --text-2: #9aa7c9;
  --text-3: #6c7899;

  --accent:   #7c8cff;
  --accent-2: #b06cff;
  --accent-3: #35d6f5;
  --grad:      linear-gradient(135deg, #7c8cff 0%, #b06cff 52%, #35d6f5 115%);
  --grad-soft: linear-gradient(135deg, rgba(124,140,255,.22), rgba(176,108,255,.18) 60%, rgba(53,214,245,.16));
  --accent-glow: 0 10px 30px -8px rgba(124, 140, 255, .65);

  --ok: #35d39a;
  --warn: #f7b955;
  --danger: #fb7185;

  --radius-xs: 10px;
  --radius-sm: 13px;
  --radius:    18px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-1: 0 10px 34px -12px rgba(2, 5, 18, .85);
  --shadow-2: 0 34px 80px -20px rgba(2, 5, 18, .95);
  --shadow-in: inset 0 1px 0 rgba(255, 255, 255, .09);

  --blur: 26px;
  --scroll: rgba(255, 255, 255, .14);
  --scroll-hover: rgba(255, 255, 255, .3);

  --bubble-them: rgba(255, 255, 255, .065);
  --bubble-them-border: rgba(255, 255, 255, .1);
  --bubble-me: var(--grad);
  --ring: 0 0 0 2px rgba(124, 140, 255, .5);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
          'Noto Sans', 'PT Sans', sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  color-scheme: dark;
}

[data-theme='light'] {
  --bg:   #eaeefb;
  --bg-2: #dfe5f7;
  --bg-3: #d3dcf5;

  --surface:   rgba(255, 255, 255, .72);
  --surface-2: rgba(255, 255, 255, .88);
  --surface-3: rgba(20, 30, 60, .06);
  --surface-solid: #ffffff;

  --border:        rgba(21, 31, 62, .1);
  --border-strong: rgba(21, 31, 62, .18);

  --text:   #101a34;
  --text-2: #56628a;
  --text-3: #8a93b4;

  --accent:   #5b6cf5;
  --accent-2: #9b4dfa;
  --accent-3: #12b6dd;
  --accent-glow: 0 12px 28px -10px rgba(91, 108, 245, .55);

  --shadow-1: 0 12px 34px -14px rgba(20, 32, 70, .28);
  --shadow-2: 0 40px 80px -24px rgba(20, 32, 70, .34);
  --shadow-in: inset 0 1px 0 rgba(255, 255, 255, .7);

  --scroll: rgba(21, 31, 62, .18);
  --scroll-hover: rgba(21, 31, 62, .34);

  --bubble-them: rgba(255, 255, 255, .95);
  --bubble-them-border: rgba(21, 31, 62, .08);
  --ring: 0 0 0 2px rgba(91, 108, 245, .45);

  color-scheme: light;
}

/* -------------------------------- reset --------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  transition: background .5s ease, color .3s ease;
}

h1, h2, h3, h4, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
::selection { background: rgba(124, 140, 255, .35); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }

/* анимации без смещения позиции — только opacity+scale, чтобы не вылетали за границы */
@keyframes popIn {
  from { opacity: 0; transform: scale(.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes bubbleIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes slideUp {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes slideDown {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes slideRight {
  from { opacity: 0; transform: scale(.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.anim-pop { animation: popIn .28s cubic-bezier(.2, .9, .25, 1) both; }
.anim-up { animation: slideUp .3s cubic-bezier(.2, .9, .25, 1) both; }

/* ------------------------------ background ------------------------------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(1100px 700px at 12% -10%, rgba(124, 140, 255, .22), transparent 60%),
    radial-gradient(900px 600px at 105% 5%, rgba(176, 108, 255, .20), transparent 62%),
    radial-gradient(1000px 800px at 60% 120%, rgba(53, 214, 245, .16), transparent 60%),
    linear-gradient(170deg, var(--bg) 0%, var(--bg-2) 55%, var(--bg-3) 100%);
}
[data-theme='light'] .aurora {
  background:
    radial-gradient(1100px 700px at 10% -10%, rgba(124, 140, 255, .35), transparent 60%),
    radial-gradient(900px 600px at 105% 0%, rgba(176, 108, 255, .28), transparent 62%),
    radial-gradient(1000px 800px at 55% 120%, rgba(53, 214, 245, .26), transparent 60%),
    linear-gradient(170deg, var(--bg) 0%, var(--bg-2) 60%, var(--bg-3) 100%);
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .5;
  will-change: transform;
}
.blob--1 { width: 46vw; height: 46vw; left: -10vw; top: -12vw; background: rgba(124, 140, 255, .55); animation: drift1 34s ease-in-out infinite; }
.blob--2 { width: 38vw; height: 38vw; right: -8vw; top: 6vh;   background: rgba(176, 108, 255, .45); animation: drift2 41s ease-in-out infinite; }
.blob--3 { width: 34vw; height: 34vw; left: 26vw; bottom: -16vw; background: rgba(53, 214, 245, .38); animation: drift3 38s ease-in-out infinite; }
.blob--4 { width: 22vw; height: 22vw; right: 22vw; bottom: 6vh; background: rgba(120, 90, 255, .35); animation: drift1 46s ease-in-out infinite reverse; }
@media (prefers-reduced-motion: reduce) { .blob { animation: none; } }

.grain {
  position: absolute;
  inset: -50%;
  opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  pointer-events: none;
}

@keyframes drift1 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(6vw, 5vh, 0) scale(1.12); }
}
@keyframes drift2 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1.06); }
  50%      { transform: translate3d(-7vw, 7vh, 0) scale(.94); }
}
@keyframes drift3 {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50%      { transform: translate3d(-5vw, -6vh, 0) scale(1.15); }
}

/* ------------------- performance switches (settings modal) ---------------- */
/* Every effect can be disabled individually; all are enabled by default. */
html.fx-no-blobs .blob { display: none; }
html.fx-no-aurora .aurora {
  background: linear-gradient(170deg, var(--bg) 0%, var(--bg-2) 55%, var(--bg-3) 100%);
}
html.fx-no-grain .grain { display: none; }
html.fx-no-glass .glass,
html.fx-no-glass .modal__card,
html.fx-no-glass .rail,
html.fx-no-glass .panel,
html.fx-no-glass .side,
html.fx-no-glass .composer__box,
html.fx-no-glass .chat__search,
html.fx-no-glass .ctx,
html.fx-no-glass .toast,
html.fx-no-glass .auth__card {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html.fx-no-anim *,
html.fx-no-anim *::before,
html.fx-no-anim *::after {
  animation: none !important;
  transition: none !important;
}
html.fx-no-msg-anim .msg { animation: none !important; }
html.fx-no-typing-anim .typing-dots i { animation: none !important; opacity: .5; }
html.fx-no-hover .btn:hover,
html.fx-no-hover .icon-btn:hover,
html.fx-no-hover .chip:hover,
html.fx-no-hover .rail__btn:hover,
html.fx-no-hover .chat-item:hover,
html.fx-no-hover .palette__swatch:hover,
html.fx-no-hover .ctx__emoji button:hover,
html.fx-no-hover .emoji-pop__item:hover,
html.fx-no-hover .msg__action:hover {
  transform: none !important;
}

/* ------------------------------- surfaces -------------------------------- */
.glass {
  background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .032));
  backdrop-filter: blur(var(--blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(150%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1), var(--shadow-in);
}
[data-theme='light'] .glass {
  background: linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(255, 255, 255, .72));
}

/* --------------------------------- icons -------------------------------- */
.ico {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico--xs { width: 14px; height: 14px; stroke-width: 2.1; }
.ico--sm { width: 17px; height: 17px; }
.ico--lg { width: 26px; height: 26px; }

.logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--grad);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -.5px;
  box-shadow: var(--accent-glow), var(--shadow-in);
  user-select: none;
}
.logo--lg { width: 54px; height: 54px; border-radius: 18px; font-size: 26px; }

/* -------------------------------- buttons -------------------------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform .16s cubic-bezier(.2, .8, .2, 1), background .2s, box-shadow .25s, border-color .2s, opacity .2s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:disabled { opacity: .5; pointer-events: none; }

.btn--primary {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  box-shadow: var(--accent-glow), var(--shadow-in);
}
.btn--primary:hover { filter: brightness(1.07); box-shadow: 0 16px 38px -10px rgba(124, 140, 255, .8), var(--shadow-in); }

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

.btn--danger { background: rgba(251, 113, 133, .14); color: #ffb3c0; border-color: rgba(251, 113, 133, .3); }
.btn--danger:hover { background: rgba(251, 113, 133, .22); }

.btn--block { width: 100%; }
.btn--lg { padding: 14px 22px; font-size: 15.5px; border-radius: var(--radius); }
.btn--sm { padding: 8px 13px; font-size: 13.5px; border-radius: var(--radius-xs); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  color: var(--text-2);
  border: 1px solid transparent;
  transition: background .18s, color .18s, transform .16s, border-color .18s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.is-active { background: var(--surface-3); color: var(--text); }
.icon-btn--accent { background: var(--grad); color: #fff; box-shadow: var(--accent-glow); }
.icon-btn--accent:hover { filter: brightness(1.08); color: #fff; }
.icon-btn--danger:hover { background: rgba(251, 113, 133, .16); color: #ffb3c0; }
.icon-btn--ghost { border-color: transparent; }
.icon-btn[disabled] { opacity: .4; pointer-events: none; }

.spinner {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner--dark { border-color: rgba(255, 255, 255, .25); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------- fields -------------------------------- */
.field { display: block; margin-bottom: 16px; }
.field__label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .2px;
  color: var(--text-2);
}
.field__box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  height: 50px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color .2s, box-shadow .2s, background .2s, transform .2s;
}
.field__box > .ico { color: var(--text-3); transition: color .2s; }
.field__box input,
.field__box textarea,
.field__box select {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 15px;
}
.field__box input::placeholder, .field__box textarea::placeholder { color: var(--text-3); }
.field:focus-within .field__box {
  border-color: rgba(124, 140, 255, .55);
  box-shadow: 0 0 0 4px rgba(124, 140, 255, .14);
  background: var(--surface-2);
}
.field:focus-within .field__box > .ico { color: var(--accent); }
.field__action {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  color: var(--text-3);
  transition: background .18s, color .18s;
}
.field__action:hover { background: var(--surface-3); color: var(--text); }
.field__hint { display: block; margin-top: 6px; font-size: 12.5px; color: var(--text-3); }
.field--invalid .field__box { border-color: rgba(251, 113, 133, .6); box-shadow: 0 0 0 4px rgba(251, 113, 133, .13); }
.field--invalid .field__hint { color: #ff9fb0; }
.field--valid .field__box { border-color: rgba(53, 211, 154, .5); }

/* --------------------------------- chips --------------------------------- */
.chip {
  padding: 7px 14px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all .2s;
  white-space: nowrap;
}
.chip:hover { color: var(--text); background: var(--surface-2); transform: translateY(-1px); }
.chip.is-active {
  color: #fff;
  background: var(--grad);
  border-color: transparent;
  box-shadow: var(--accent-glow);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill .ico { width: 15px; height: 15px; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 6px 16px -6px rgba(124, 140, 255, .9);
}
.badge--soft {
  color: var(--text);
  background: var(--surface-3);
  box-shadow: none;
  border: 1px solid var(--border);
}
.badge--danger { background: linear-gradient(135deg, #fb7185, #f97316); }

/* -------------------------------- avatars -------------------------------- */
.avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.2px;
  background: var(--grad);
  box-shadow: var(--shadow-in), 0 8px 20px -10px rgba(0, 0, 0, .8);
  user-select: none;
  overflow: hidden;
}
.avatar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 120% at 20% 0%, rgba(255, 255, 255, .35), transparent 55%);
  pointer-events: none;
}
.avatar--xs { width: 26px; height: 26px; border-radius: 9px; font-size: 11px; }
.avatar--sm { width: 36px; height: 36px; border-radius: 12px; font-size: 14px; }
.avatar--md { width: 46px; height: 46px; }
.avatar--lg { width: 62px; height: 62px; border-radius: 20px; font-size: 23px; }
.avatar--xl { width: 92px; height: 92px; border-radius: 30px; font-size: 36px; }

.av-0 { background: linear-gradient(135deg, #7c8cff, #6a5cff); }
.av-1 { background: linear-gradient(135deg, #ff7ac6, #b06cff); }
.av-2 { background: linear-gradient(135deg, #ffb457, #ff6b6b); }
.av-3 { background: linear-gradient(135deg, #35d39a, #23a6d5); }
.av-4 { background: linear-gradient(135deg, #35d6f5, #4c6fff); }
.av-5 { background: linear-gradient(135deg, #b06cff, #7a3cff); }
.av-6 { background: linear-gradient(135deg, #9ae66e, #22b573); }
.av-7 { background: linear-gradient(135deg, #ff8f70, #ff3d71); }
.av-8 { background: linear-gradient(135deg, #7f9cf5, #5a67d8); }
.av-9 { background: linear-gradient(135deg, #f472b6, #a855f7); }

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-3);
  border: 2.5px solid var(--bg-2);
  flex: none;
}
.dot--online { background: var(--ok); box-shadow: 0 0 0 0 rgba(53, 211, 154, .6); animation: pulseRing 2.4s infinite; }
.dot--idle { background: var(--warn); }
.dot--offline { background: var(--text-3); }
.dot--corner { position: absolute; right: -3px; bottom: -2px; border-color: var(--bg-2); }
.avatar-wrap { position: relative; display: inline-flex; flex: none; }
.avatar__emoji { font-size: 1.06em; line-height: 1; font-family: var(--font); }
.avatar--photo { background: var(--bg-3); }
.avatar__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(53, 211, 154, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(53, 211, 154, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 211, 154, 0); }
}

/* ------------------------------- scrolling ------------------------------- */
.scroll { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-track { background: transparent; }
.scroll::-webkit-scrollbar-thumb {
  background: var(--scroll);
  background-clip: content-box;
  border: 3px solid transparent;
  border-radius: 99px;
}
.scroll::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); background-clip: content-box; }

/* -------------------------------- helpers -------------------------------- */
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .92em; }
.sep { height: 1px; background: var(--border); margin: 14px 0; }
.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 18px 0 10px;
}
.typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.typing-dots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: .55;
  animation: bounceDot 1.25s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounceDot {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ------------------------------- animations ------------------------------ */
/* определения @keyframes popIn/slideUp/… — вверху файла (безопасные, без сдвига) */

/* -------------------------------- toasts --------------------------------- */
.toasts {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 11px;
  width: min(370px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(28, 34, 62, .92), rgba(18, 24, 46, .92));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(18px);
  animation: slideRight .32s cubic-bezier(.2, .9, .25, 1) both;
  pointer-events: auto;
  cursor: pointer;
}
[data-theme='light'] .toast { background: linear-gradient(180deg, #fff, #f4f6ff); }
.toast--out { animation: fadeOutRight .25s ease forwards; }
@keyframes fadeOutRight {
  to { opacity: 0; transform: translateX(30px) scale(.97); }
}
.toast__icon {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  background: var(--grad-soft);
  color: var(--accent);
}
.toast__icon--ok { background: rgba(53, 211, 154, .16); color: var(--ok); }
.toast__icon--warn { background: rgba(247, 185, 85, .16); color: var(--warn); }
.toast__icon--danger { background: rgba(251, 113, 133, .16); color: var(--danger); }
.toast__body { min-width: 0; flex: 1; }
.toast__title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.toast__text { font-size: 13.2px; color: var(--text-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.toast__close { color: var(--text-3); align-self: flex-start; }

/* -------------------------------- overlays ------------------------------- */
.overlays { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 7, 18, .55);
  backdrop-filter: blur(8px);
  animation: fadeIn .2s ease both;
  pointer-events: auto;
  z-index: 82;
}
[data-theme='light'] .modal { background: rgba(30, 40, 80, .28); }
.modal--full { padding: 0; }
.modal__card {
  width: min(560px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(24, 30, 56, .96), rgba(15, 20, 40, .97));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(30px) saturate(150%);
  animation: slideUp .32s cubic-bezier(.2, .9, .25, 1) both;
  overflow: hidden;
}
[data-theme='light'] .modal__card { background: linear-gradient(180deg, #fff, #f7f9ff); }
.modal__card--wide { width: min(880px, 100%); }
.modal__card--full { width: 100%; height: 100%; max-height: none; border-radius: 0; }
.modal__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal__head-text { flex: 1; min-width: 0; }
.modal__title { font-size: 19px; font-weight: 750; letter-spacing: -.2px; }
.modal__sub { font-size: 13.2px; color: var(--text-2); margin-top: 3px; }
.modal__body { padding: 20px 24px; overflow-y: auto; }
.modal__body--flush { padding: 0; }
.modal__foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, .12);
}
[data-theme='light'] .modal__foot { background: rgba(20, 30, 60, .03); }

/* ----------------------------- context menu ------------------------------ */
.ctx {
  position: fixed;
  z-index: 95;
  min-width: 216px;
  padding: 6px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(28, 34, 62, .97), rgba(17, 22, 44, .98));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(20px);
  animation: popIn .16s ease both;
}
[data-theme='light'] .ctx { background: #fff; }
.ctx__item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 550;
  color: var(--text);
  text-align: left;
  transition: background .15s, color .15s;
}
.ctx__item:hover { background: var(--surface-2); }
.ctx__item--danger { color: #ff9fb0; }
.ctx__item--danger:hover { background: rgba(251, 113, 133, .14); }
.ctx__item .ico { color: var(--text-3); }
.ctx__item--danger .ico { color: inherit; }
.ctx__sep { height: 1px; margin: 5px 8px; background: var(--border); }
.ctx__emoji { display: flex; gap: 4px; padding: 4px 6px 7px; }
.ctx__emoji button {
  width: 34px; height: 34px;
  border-radius: 11px;
  font-size: 19px;
  display: grid; place-items: center;
  transition: background .15s, transform .15s;
}
.ctx__emoji button:hover { background: var(--surface-3); transform: translateY(-2px) scale(1.06); }

/* ------------------------------ emoji picker ----------------------------- */
.emoji-pop {
  position: fixed;
  z-index: 96;
  width: min(360px, calc(100vw - 28px));
  max-height: 400px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(28, 34, 62, .97), rgba(17, 22, 44, .98));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(24px);
  overflow: hidden;
  animation: popIn .2s ease both;
}
[data-theme='light'] .emoji-pop { background: #fff; }
.emoji-pop__head { display: flex; gap: 8px; padding: 12px 12px 8px; }
.emoji-pop__head .field__box { height: 42px; flex: 1; }
.emoji-pop__tabs {
  display: flex;
  gap: 3px;
  padding: 0 10px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.emoji-pop__tabs::-webkit-scrollbar { display: none; }
.emoji-pop__tab {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
  opacity: .55;
  transition: all .18s;
}
.emoji-pop__tab:hover { background: var(--surface-2); opacity: .85; }
.emoji-pop__tab.is-active { background: var(--surface-3); opacity: 1; }
.emoji-pop__grid {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 2px;
}
.emoji-pop__item {
  height: 38px;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background .14s, transform .14s;
}
.emoji-pop__item:hover { background: var(--surface-3); transform: scale(1.12); }
.emoji-pop__empty { padding: 26px 12px; text-align: center; color: var(--text-3); font-size: 13.5px; grid-column: 1 / -1; }

/* ---------------------------- offline banner ----------------------------- */
.offline-banner {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border-radius: 99px;
  font-size: 13.5px;
  font-weight: 600;
  color: #ffe6c2;
  background: linear-gradient(135deg, rgba(247, 185, 85, .22), rgba(251, 113, 133, .22));
  border: 1px solid rgba(247, 185, 85, .35);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(16px);
  animation: slideUp .3s ease both;
}
.offline-banner .ico { animation: spin 2.4s linear infinite; }

/* ------------------------- settings modal widgets ------------------------- */
.setting-section { margin: 20px 2px 8px; }
.setting-section:first-child { margin-top: 4px; }
.setting-section__head h4 { margin: 0; font-size: 14.5px; font-weight: 700; letter-spacing: .01em; }
.setting-section__sub { margin: 5px 0 0; font-size: 12.6px; color: var(--text-3); max-width: 62ch; }
.setting-section__note { display: grid; gap: 8px; margin: 12px 0 0; padding: 12px 14px; font-size: 12.8px; line-height: 1.5; color: var(--text-2); background: var(--surface-2, rgba(127,127,127,.08)); border: 1px solid var(--border, rgba(127,127,127,.2)); border-radius: 12px; max-width: 66ch; }
.setting-section__note p { margin: 0; }

.setting {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 8px;
  cursor: pointer;
}
.setting:hover { background: var(--surface-2); }
.setting--stack { flex-direction: column; align-items: stretch; gap: 10px; cursor: default; }
.setting__row { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.setting__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.setting__text b { font-size: 13.8px; font-weight: 600; }
.setting__hint { font-size: 12.2px; color: var(--text-3); }
.setting__volume { display: flex; align-items: center; gap: 12px; padding: 0 2px; }
.setting__volume .ico { color: var(--text-3); }
.setting__vol { font-size: 12.4px; color: var(--text-3); min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.setting-reset { margin: 6px 2px 4px; }

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 44px;
  height: 25px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background .2s, border-color .2s;
  cursor: pointer;
  flex: none;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2.5px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  transition: transform .18s ease;
}
.switch:checked {
  background: var(--grad);
  border-color: transparent;
}
.switch:checked::after { transform: translateX(19px); }

.range {
  appearance: none;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 99px;
  background: var(--surface-3);
  flex: 1;
  cursor: pointer;
}
.range::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .35);
}
html[data-theme='dark'] .range::-webkit-slider-thumb { border-color: #1a2138; }

@media (max-width: 620px) {
  .setting { padding: 10px 11px; gap: 10px; }
  .setting__hint { font-size: 11.6px; }
}
