:root {
  color-scheme: dark;

  --bg: #16171b;
  --bg-2: #1d1f24;
  --bg-3: #25282e;
  --bg-4: #2f333b;
  --line: #33373f;
  --line-soft: #282b31;

  --text: #e7e9ec;
  --muted: #98a0ab;

  --blurple: #5865f2;
  --blurple-2: #7d86ff;
  --green: #57f287;
  --yellow: #fee75c;
  --red: #ed4245;
  --spotify: #1db954;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 3px 12px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }

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

* { scrollbar-width: thin; scrollbar-color: var(--bg-4) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--bg-4); border-radius: 8px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #3d424b; background-clip: content-box; }

body {
  margin: 0;
  color: var(--text);
  font: 15px/1.55 "Inter", "gg sans", "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1100px 520px at 12% -12%, rgba(88, 101, 242, 0.16), transparent 62%),
    radial-gradient(900px 480px at 100% -6%, rgba(29, 185, 84, 0.07), transparent 58%),
    var(--bg);
  background-attachment: fixed;
}

main { max-width: 1160px; margin: 0 auto; padding: 22px 20px 60px; display: grid; gap: 18px; }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px;
  background: rgba(29, 31, 36, 0.82);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.topbar img {
  width: 46px; height: 46px; border-radius: 50%; background: var(--bg-3); flex: none;
  box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3.5px rgba(88, 101, 242, 0.45);
}
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: -0.01em; }
.topbar p { margin: 1px 0 0; font-size: 12.5px; }
.spacer { flex: 1; }

.dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none;
  transition: background 0.2s ease;
}
.dot.online { background: var(--green); animation: pulse 2.4s ease-in-out infinite; }
.dot.offline { background: var(--red); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(87, 242, 135, 0.5); }
  50% { box-shadow: 0 0 0 7px rgba(87, 242, 135, 0); }
}

.muted { color: var(--muted); }

/* ---------- buttons ---------- */

button {
  background: linear-gradient(180deg, var(--blurple-2), var(--blurple));
  color: #fff; border: 0; border-radius: 10px;
  padding: 9px 16px; font: inherit; font-size: 13.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(88, 101, 242, 0.26);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
button:hover { filter: brightness(1.08); transform: translateY(-1px); }
button:active { transform: translateY(0); filter: brightness(0.98); }
button:focus-visible { outline: 2px solid var(--blurple-2); outline-offset: 2px; }
button:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }

button.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--text); box-shadow: none;
}
button.ghost:hover { background: var(--bg-3); border-color: var(--bg-4); }

button.danger { background: linear-gradient(180deg, #ff6f72, var(--red)); box-shadow: 0 4px 14px rgba(237, 66, 69, 0.28); }

/* ---------- stat cards ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 14px; }

.stat {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 13px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.stat::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--blurple), transparent 70%);
  opacity: 0.6;
}
.stat:hover { transform: translateY(-2px); border-color: rgba(88, 101, 242, 0.45); box-shadow: var(--shadow-sm); }
.stat .icon { font-size: 15px; opacity: 0.9; line-height: 1; }
.stat .v { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; }
.stat .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.09em; margin-top: 2px; }
.stat .sub { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- layout + cards ---------- */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  display: flex; align-items: center; gap: 9px;
  margin: 0 0 15px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted);
}
.card h2::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }

h4 {
  margin: 16px 0 7px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
}
h4:first-child { margin-top: 4px; }

/* ---------- forms ---------- */

label { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--muted); }
input, textarea, select {
  width: 100%; margin-top: 5px; color: var(--text);
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font: inherit; font-size: 14px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
input:hover, textarea:hover, select:hover { border-color: var(--bg-4); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--blurple);
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.22);
}
textarea { resize: vertical; min-height: 90px; }

hr { border: 0; border-top: 1px solid var(--line-soft); margin: 16px 0; }

.result { font-size: 13px; min-height: 18px; margin: 9px 0 0; }
.result.ok { color: var(--green); }
.result.err { color: var(--red); }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.022); }
tr:last-child th, tr:last-child td { border-bottom: 0; }

table.kv th { width: 40%; }
table.kv td { word-break: break-word; }

code {
  background: var(--bg-3); border: 1px solid var(--line-soft);
  padding: 1px 6px; border-radius: 6px; font-size: 12px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

/* ---------- pills ---------- */

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--muted);
  margin: 2px 4px 2px 0; white-space: nowrap;
}
.pill.green { color: var(--green); border-color: rgba(87, 242, 135, 0.35); background: rgba(87, 242, 135, 0.09); }
.pill.red { color: var(--red); border-color: rgba(237, 66, 69, 0.35); background: rgba(237, 66, 69, 0.09); }
.pill.yellow { color: var(--yellow); border-color: rgba(254, 231, 92, 0.32); background: rgba(254, 231, 92, 0.08); }

/* ---------- guild list ---------- */

.guild {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  margin-bottom: 10px; overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.014), transparent);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.guild:hover { border-color: rgba(88, 101, 242, 0.4); }
.guild.open { border-color: rgba(88, 101, 242, 0.5); box-shadow: var(--shadow-sm); }

.guild-head { display: flex; align-items: center; gap: 13px; padding: 13px 15px; cursor: pointer; }
.guild-head::after {
  content: "▾"; margin-left: auto; color: var(--muted); font-size: 12px;
  transition: transform 0.2s ease;
}
.guild.open .guild-head::after { transform: rotate(180deg); }
.guild-head img {
  width: 38px; height: 38px; border-radius: 50%; background: var(--bg-3); flex: none;
  box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3px var(--line);
}
.guild-head .name { font-weight: 650; letter-spacing: -0.01em; }
.guild-head .meta { font-size: 12px; color: var(--muted); margin-top: 1px; }

.guild-body {
  padding: 6px 15px 16px; border-top: 1px solid var(--line-soft);
  animation: reveal 0.18s ease;
}
@keyframes reveal { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

.guild-body .grid-2 { gap: 22px; }

/* ---------- details / warnings ---------- */

details {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  margin-bottom: 8px; padding: 10px 13px; background: var(--bg-3);
}
details[open] { border-color: var(--line); }
details summary { cursor: pointer; list-style: none; font-size: 13.5px; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; color: var(--muted); }
details[open] summary::before { content: "▾ "; }

/* ---------- status lines ---------- */

.status-line {
  padding: 6px 0; border-bottom: 1px solid var(--line-soft);
  font-size: 13px; display: flex; align-items: baseline; gap: 8px;
}
.status-line:last-child { border-bottom: 0; }
.status-line .pill { flex: none; }

/* ---------- log feed ---------- */

.log-feed { display: grid; gap: 8px; max-height: 460px; overflow: auto; padding-right: 4px; }
.log-entry {
  border-left: 3px solid var(--blurple);
  background: var(--bg-3);
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
}
.log-entry.success { border-left-color: var(--green); }
.log-entry.danger { border-left-color: var(--red); }
.log-entry.warn { border-left-color: var(--yellow); }
.log-entry.info { border-left-color: var(--blurple); }
.log-title { font-weight: 650; font-size: 13px; }
.log-body { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: pre-wrap; }
.log-time { font-size: 11px; color: var(--muted); padding-left: 15px; margin-top: -4px; }

ol.queue { margin: 8px 0 0; padding-left: 20px; font-size: 13px; }
ol.queue li { margin-bottom: 3px; }

/* ---------- toast ---------- */

.error {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: linear-gradient(180deg, #ff6f72, var(--red));
  color: #fff; padding: 11px 18px; border-radius: 12px; max-width: 90vw;
  box-shadow: var(--shadow); font-size: 13.5px; z-index: 50;
  animation: toast 0.22s ease;
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- login screen ---------- */

.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  background:
    radial-gradient(700px 420px at 50% -8%, rgba(88, 101, 242, 0.22), transparent 65%),
    radial-gradient(600px 380px at 85% 110%, rgba(29, 185, 84, 0.1), transparent 60%),
    var(--bg);
}
.login-card {
  width: min(390px, 100%);
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line); border-radius: 18px;
  padding: 30px 28px 26px;
  box-shadow: var(--shadow);
  animation: reveal 0.25s ease;
}
.login-card h1 { margin: 0; font-size: 26px; letter-spacing: -0.02em; }
.login-card > p.muted { margin: 2px 0 22px; font-size: 13px; }
.login-card label { margin-bottom: 14px; }
.login-card button { width: 100%; padding: 11px; margin-top: 8px; font-size: 14px; }

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

@media (max-width: 560px) {
  main { padding: 16px 13px 50px; gap: 14px; }
  .topbar { padding: 12px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar img { width: 40px; height: 40px; }
  .topbar h1 { font-size: 17px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
  .stat { padding: 12px 13px; }
  .stat .v { font-size: 21px; }
  .card { padding: 15px 14px 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ================= app shell ================= */

body::before {
  content: ""; position: fixed; inset: -25% -15%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(620px 420px at 18% 18%, rgba(88, 101, 242, 0.18), transparent 60%),
    radial-gradient(520px 380px at 82% 8%, rgba(29, 185, 84, 0.10), transparent 60%),
    radial-gradient(560px 440px at 62% 92%, rgba(170, 84, 255, 0.10), transparent 60%);
  filter: blur(52px);
  animation: aurora 26s ease-in-out infinite alternate;
}
@keyframes aurora {
  0% { transform: translate3d(-2%, -1%, 0) scale(1); }
  100% { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

.app { display: grid; grid-template-columns: 258px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 16px;
  padding: 18px 14px;
  background: rgba(23, 25, 30, 0.72);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-right: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 0; }
.brand img {
  width: 44px; height: 44px; border-radius: 50%; background: var(--bg-3); flex: none;
  box-shadow: 0 0 0 2px var(--bg-2), 0 0 0 3.5px rgba(88, 101, 242, 0.5);
}
.brand-name {
  font-weight: 800; font-size: 16px; letter-spacing: -0.01em;
  background: linear-gradient(90deg, #fff, var(--blurple-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub { font-size: 11.5px; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: transparent; color: var(--muted);
  border: 0; border-radius: 11px; padding: 10px 12px;
  font: inherit; font-size: 13.5px; font-weight: 600; text-align: left;
  cursor: pointer; box-shadow: none;
  transition: background 0.14s ease, color 0.14s ease;
}
.nav-item span { font-size: 15px; line-height: 1; }
.nav-item:hover { background: var(--bg-3); color: var(--text); transform: none; filter: none; }
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(88, 101, 242, 0.30), rgba(88, 101, 242, 0.05));
  box-shadow: inset 2px 0 0 var(--blurple);
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding-left: 6px; }
.foot-buttons { display: flex; gap: 8px; }
.foot-buttons button { flex: 1; padding: 8px 10px; font-size: 12.5px; }

.content { max-width: none; margin: 0; padding: 26px 28px 70px; display: block; }
.view { display: grid; gap: 18px; animation: reveal 0.22s ease; }
.view[hidden] { display: none; }

/* ================= hero ================= */

.hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 20px;
  padding: 22px 24px; border-radius: 18px; border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(88, 101, 242, 0.26), rgba(29, 185, 84, 0.10) 55%, transparent 82%),
    var(--bg-2);
  box-shadow: var(--shadow-sm);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(88, 101, 242, 0.35), transparent 70%);
  filter: blur(10px); pointer-events: none;
}
.hero > img {
  width: 74px; height: 74px; border-radius: 50%; flex: none; background: var(--bg-3);
  box-shadow: 0 0 0 3px var(--bg-2), 0 0 0 5px rgba(88, 101, 242, 0.45);
}
.hero-main { min-width: 0; }
.hero-name { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.hero-meta { font-size: 12.5px; margin-top: 2px; }
.hero-pills { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.hero-right {
  margin-left: auto; text-align: right;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.hero-metric .hv { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.hero-metric .hk { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.sparkline { width: 132px; height: 36px; display: block; }

/* ================= meters ================= */

.bar {
  height: 7px; border-radius: 999px; background: var(--bg-4);
  overflow: hidden; margin-top: 6px; min-width: 96px;
}
.bar > i { display: block; height: 100%; border-radius: 999px; transition: width 0.5s ease; }

/* ================= small screens ================= */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; height: auto;
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 12px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand-sub { display: none; }
  .nav { flex-direction: row; margin: 0; }
  .nav-item { white-space: nowrap; }
  .nav-item.active { box-shadow: inset 0 -2px 0 var(--blurple); background: rgba(88, 101, 242, 0.16); }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .conn { display: none; }
  .content { padding: 18px 15px 60px; }
  .hero { flex-wrap: wrap; }
  .hero-right { margin-left: 0; width: 100%; align-items: flex-start; text-align: left; }
}

/* ================= voice room controls ================= */

.room {
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 12px 13px; margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.012);
  transition: border-color 0.15s ease;
}
.room:hover { border-color: rgba(88, 101, 242, 0.35); }
.room-name { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.room-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 11px 0 9px; }
.room-actions button { padding: 6px 11px; font-size: 12.5px; }
.room-members { font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.room-members .pill { display: inline-flex; align-items: center; gap: 5px; padding-right: 5px; }

button.tiny {
  padding: 1px 7px; font-size: 10.5px; border-radius: 999px;
  background: var(--bg-4); box-shadow: none; font-weight: 600; color: var(--text);
}
button.tiny:hover { background: #3d424b; transform: none; filter: none; }

.error.ok { background: linear-gradient(180deg, #6cf59a, #34c06a); color: #06331a; }

/* ================= messages tool ================= */

.msg-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.msg-toolbar label { margin-bottom: 0; flex: 1 1 170px; }
.msg-toolbar .pill { align-self: center; }
.msg-toolbar button { align-self: center; }

.msg-list {
  display: grid; gap: 6px; align-content: start;
  max-height: 420px; min-height: 120px; overflow: auto; padding: 8px;
  background: var(--bg-3); border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}
.msg { padding: 7px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.02); }
.msg.bot { background: rgba(88, 101, 242, 0.09); }
.msg-head { display: flex; gap: 8px; align-items: baseline; font-size: 12.5px; }
.msg-author { font-weight: 650; }
.msg-time { font-size: 11px; }
.msg-body { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; margin-top: 2px; }

#messages-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#messages-form textarea { margin-top: 0; width: 100%; }
#messages-form button { align-self: flex-start; }
#messages-locked { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
