/* ---------- base ---------- */

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg-rail);
  color: var(--text-normal);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.375;
  -webkit-font-smoothing: antialiased;
}

#boot-bg {
  display: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--text-link);
  text-decoration: none;
}

.link {
  color: var(--text-link);
  cursor: pointer;
}
.link:hover {
  text-decoration: underline;
}

.app-root {
  position: fixed;
  inset: 0;
}

.icon {
  flex: none;
  display: block;
}

::selection {
  background: rgba(88, 101, 242, 0.45);
}

/* scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 8px;
  min-height: 40px;
}
::-webkit-scrollbar-track {
  background: transparent;
}

:root[data-reduced-motion="1"] *,
:root[data-reduced-motion="1"] *::before,
:root[data-reduced-motion="1"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* ---------- buttons and fields ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 2px 16px;
  border: none;
  border-radius: 3px;
  font-size: 14px;
  font-weight: 500;
  line-height: 16px;
  color: #fff;
  background: var(--brand);
  transition: background-color var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:hover {
  background: var(--brand-hover);
}
.btn:active {
  background: var(--brand-active);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-sm {
  height: 32px;
  padding: 2px 12px;
}
.btn-secondary {
  background: #4e5058;
}
.btn-secondary:hover {
  background: #6d6f78;
}
.btn-danger {
  background: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-hover);
}
.btn-positive {
  background: var(--positive);
}
.btn-positive:hover {
  background: var(--positive-hover);
}
.btn-link {
  background: transparent;
  color: var(--text-normal);
}
.btn-link:hover {
  background: transparent;
  text-decoration: underline;
}
.btn-outline-danger {
  background: transparent;
  color: var(--text-danger);
  box-shadow: inset 0 0 0 1px var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger);
  color: #fff;
}

.field {
  margin-bottom: 20px;
}
.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--interactive-normal);
}
.field .req {
  color: var(--text-danger);
}
.field-error {
  font-style: italic;
  font-weight: 500;
  text-transform: none;
  color: var(--text-danger);
}
.field.has-error .field-label {
  color: var(--text-danger);
}
.field-input {
  width: 100%;
  height: 40px;
  padding: 10px;
  border: none;
  border-radius: 3px;
  outline: none;
  background: var(--bg-input-inset);
  font-size: 16px;
  transition: box-shadow var(--dur) var(--ease);
}
.field-input:focus {
  box-shadow: 0 0 0 2px var(--brand);
}
.field.has-error .field-input {
  box-shadow: 0 0 0 1px var(--danger);
}
.field-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.dots-loader {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.dots-loader i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  animation: dots-bounce 1.1s infinite ease-in-out;
}
.dots-loader i:nth-child(2) {
  animation-delay: 0.15s;
}
.dots-loader i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes dots-bounce {
  0%,
  70%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  35% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ---------- loading screen ---------- */

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1e1f22;
  opacity: 1;
  transition: opacity 400ms var(--ease);
}
.loading-screen.fading {
  opacity: 0;
  pointer-events: none;
}
.loading-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  padding: 0 24px;
  text-align: center;
}
.loading-ember {
  transform-origin: 50% 90%;
  animation: ember-hop 1.8s infinite var(--ease);
}
.ember-body {
  transform-origin: 50% 94%;
  animation: ember-squash 1.8s infinite var(--ease);
}
.ember-eyes {
  animation: ember-blink 4.2s infinite;
  transform-origin: 50% 63px;
}
@keyframes ember-hop {
  0%, 100% { transform: translateY(0) rotate(0); }
  18% { transform: translateY(0) rotate(-3deg); }
  42% { transform: translateY(-14px) rotate(4deg); }
  60% { transform: translateY(0) rotate(0); }
}
@keyframes ember-squash {
  0%, 100% { transform: scale(1, 1); }
  18% { transform: scale(1.06, 0.92); }
  42% { transform: scale(0.95, 1.06); }
  60% { transform: scale(1.04, 0.94); }
  72% { transform: scale(1, 1); }
}
@keyframes ember-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}
.loading-tip {
  max-width: 440px;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease);
}
.loading-tip.swapping {
  opacity: 0;
  transform: translateY(4px);
}
.loading-tip-label {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}
.loading-tip-text {
  font-size: 16px;
  color: #b5bac1;
}

.boot-blank {
  position: absolute;
  inset: 0;
  background: var(--bg-rail);
}

/* ---------- auth ---------- */

.auth-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: var(--auth-bg);
  animation: fade-in 300ms var(--ease);
}
.auth-shapes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.auth-brand {
  position: absolute;
  top: 32px;
  left: 36px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
}
.auth-card {
  position: relative;
  width: 480px;
  max-width: calc(100vw - 32px);
  padding: 32px;
  border-radius: 5px;
  background: #313338;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  animation: card-in 260ms var(--ease);
}
.auth-head {
  margin-bottom: 20px;
  text-align: center;
}
.auth-head h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  line-height: 30px;
  color: #f2f3f5;
}
.auth-head p {
  margin: 0;
  font-size: 16px;
  color: #b5bac1;
}
.auth-card .field-input {
  background: #1e1f22;
}
.auth-submit {
  width: 100%;
  height: 44px;
  margin-top: 4px;
  font-size: 16px;
}
.auth-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
  color: #949ba4;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 4px;
  background: #111214;
  color: #f2f3f5;
  font-size: 14px;
  box-shadow: var(--elevation-high);
  animation: card-in 200ms var(--ease);
}

/* ---------- avatars ---------- */

.avatar {
  position: relative;
  flex: none;
  border-radius: 50%;
}
.avatar-img,
.avatar-default {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  user-select: none;
}
.status-dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 30%;
  height: 30%;
  min-width: 10px;
  min-height: 10px;
  border-radius: 50%;
  border: 3px solid var(--status-ring, var(--bg-sidebar));
  box-sizing: content-box;
  transform: translate(0, 0);
}
.status-dot.online { background: var(--status-online); }
.status-dot.idle { background: var(--status-idle); }
.status-dot.dnd { background: var(--status-dnd); }
.status-dot.offline { background: var(--status-offline); }
