:root {
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r-control: 8px;
  --r-item: 12px;
  --r-panel: 20px;
  --fill-subtle: rgba(255, 255, 255, 0.035);
  --fill: rgba(255, 255, 255, 0.06);
  --fill-hover: rgba(255, 255, 255, 0.1);
  --fill-strong: rgba(255, 255, 255, 0.14);
  --surface-glass: rgba(18, 18, 20, 0.62);
  --hairline: rgba(255, 255, 255, 0.1);
}

html { scrollbar-color: rgba(255,255,255,.2) transparent; scrollbar-width: thin; }
::selection { background: rgba(255,255,255,.22); }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid rgba(255,255,255,.75);
  outline-offset: 2px;
  border-radius: var(--r-control);
}

main, .page-content, #page-content { animation: pg-enter .28s var(--ease) both; }
@keyframes pg-enter { from { opacity: 0; transform: translateY(6px); filter: blur(4px); } to { opacity: 1; transform: none; filter: blur(0); } }

#navbar {
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
  background: var(--surface-glass);
  border-bottom: 1px solid var(--hairline);
}

#cat-sidebar {
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  backdrop-filter: blur(28px) saturate(150%);
}
.cat-item { border-radius: var(--r-item); transition-timing-function: var(--ease); }
.cat-item.active { background: var(--fill-hover); border-color: var(--hairline); }

.channel-card, .notif-dropdown, .modal, .modal-box, .dropdown, #user-dropdown {
  background: var(--surface-glass);
  border: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  backdrop-filter: blur(24px) saturate(150%);
}
.channel-card { border-radius: var(--r-panel); transition: transform .35s var(--ease), border-color .25s ease, box-shadow .35s var(--ease), background .25s ease; }
.channel-card:hover { transform: translateY(-3px); background: var(--fill); box-shadow: 0 24px 48px rgba(0,0,0,.5); }
.modal, .modal-box { border-radius: var(--r-panel); }

.btn { border-radius: var(--r-item); transition: transform .2s var(--ease), background .2s ease, box-shadow .2s ease, filter .2s ease; }
.btn:active { transform: scale(.97); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], textarea, select {
  border-radius: var(--r-item);
  background: var(--fill);
  border: 1px solid var(--hairline);
  transition: background .2s ease, border-color .2s ease;
}
input:focus, textarea:focus, select:focus { background: var(--fill-hover); border-color: rgba(255,255,255,.3); }

#toast-container { gap: 8px; pointer-events: none; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  pointer-events: auto; min-width: 260px; padding: 12px 16px; border-radius: 12px;
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--hairline);
  box-shadow: 0 12px 36px rgba(0,0,0,.45);
  font-size: .84rem; font-weight: 560; position: relative; overflow: hidden;
  animation: toast-in2 .28s var(--ease) both;
}
.toast::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: rgba(255,255,255,.35); transform-origin: left;
  animation: toast-life var(--toast-life, 4s) linear forwards;
}
.toast.success::after { background: rgba(16,185,129,.8); }
.toast.error::after { background: rgba(239,68,68,.8); }
@keyframes toast-in2 { from { opacity: 0; transform: translateY(8px) scale(.98); filter: blur(4px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes toast-life { to { transform: scaleX(0); } }

.skeleton {
  background: linear-gradient(100deg, var(--fill-subtle) 30%, var(--fill) 50%, var(--fill-subtle) 70%);
  background-size: 200% 100%; border-radius: var(--r-item);
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}
@keyframes skeleton-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

html.tx-hidden .bg-orb, html.tx-hidden .skeleton, html.tx-hidden #online-count-badge::before { animation-play-state: paused !important; }

#tx-palette {
  position: fixed; inset: 0; z-index: 10000; display: none; align-items: flex-start; justify-content: center;
  padding: 14vh 1rem 1rem; background: rgba(0,0,0,.45);
  -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
}
#tx-palette.open { display: flex; animation: tx-fade .16s ease both; }
@keyframes tx-fade { from { opacity: 0; } to { opacity: 1; } }
.tx-pal-box {
  width: min(560px, 100%); border-radius: var(--r-panel); overflow: hidden;
  background: var(--surface-glass); border: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(28px); backdrop-filter: blur(28px);
  box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: pg-enter .22s var(--ease) both;
}
.tx-pal-box input {
  width: 100%; padding: 16px 20px; font-size: 1rem; color: var(--text);
  background: transparent !important; border: 0 !important; border-bottom: 1px solid var(--hairline) !important;
  border-radius: 0 !important; outline: none;
}
.tx-pal-list { max-height: 50vh; overflow-y: auto; padding: 8px; }
.tx-pal-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-item);
  color: var(--text-dim); font-size: .9rem; font-weight: 550; cursor: pointer;
}
.tx-pal-item small { margin-left: auto; color: var(--text-muted); font-size: .72rem; }
.tx-pal-item.sel, .tx-pal-item:hover { background: var(--fill-hover); color: var(--text); }
.tx-pal-empty { padding: 18px; text-align: center; color: var(--text-muted); font-size: .85rem; }
.tx-pal-foot { padding: 8px 16px; border-top: 1px solid var(--hairline); color: var(--text-muted); font-size: .7rem; display: flex; gap: 14px; }
.tx-kbd { padding: 1px 6px; border: 1px solid var(--hairline); border-radius: 5px; background: var(--fill); font-size: .68rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (max-width: 640px) { #tx-palette { padding-top: 8vh; } }
