:root {
  --bg: #07070c;
  --bg-card: #12121d;
  --bg-card-2: #19192a;
  --text: #f7f7ff;
  --muted: #a8aac5;
  --line: #2f3150;
  --line-soft: #40436b;
  --primary: #d10f5c;
  --primary-2: #7d1dff;
  --success: #2ad18b;
  --shadow: 0 26px 54px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Sora", "Avenir Next", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 8% 12%, #271026 0%, var(--bg) 38%),
    radial-gradient(circle at 90% 90%, #16123a 0%, var(--bg) 34%), var(--bg);
}

.bg-glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(85px);
  opacity: 0.34;
  pointer-events: none;
}

.bg-glow-a {
  width: 360px;
  height: 360px;
  left: -130px;
  top: -130px;
  background: linear-gradient(145deg, var(--primary), var(--primary-2));
}

.bg-glow-b {
  width: 320px;
  height: 320px;
  right: -110px;
  bottom: -120px;
  background: linear-gradient(145deg, var(--primary-2), #4d81ff);
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: linear-gradient(transparent 95%, rgba(255, 255, 255, 0.06) 96%),
    linear-gradient(90deg, transparent 95%, rgba(255, 255, 255, 0.05) 96%);
  background-size: 36px 36px;
}

.layout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}

.sidebar {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.brand {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(145deg, rgba(209, 15, 92, 0.27), rgba(125, 29, 255, 0.2));
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(145deg, var(--primary), var(--primary-2));
  box-shadow: 0 0 0 8px rgba(209, 15, 92, 0.2);
}

.brand h1 {
  margin: 0;
  font-size: 1.08rem;
}

.sidebar-card {
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(18, 18, 30, 0.95);
  box-shadow: var(--shadow);
  padding: 16px;
  flex: 1;
  min-height: 0;
}

.sidebar-card h2 {
  margin: 0;
  font-size: 1.08rem;
}

.guild-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: calc(100vh - 230px);
  overflow: auto;
  padding-right: 3px;
}

.guild-item {
  border: 1px solid var(--line);
  background: var(--bg-card-2);
  color: var(--text);
  border-radius: 13px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: 0.15s ease;
}

.guild-item:hover {
  border-color: #595b80;
  transform: translateY(-1px);
}

.guild-item.active {
  border-color: rgba(209, 15, 92, 0.9);
  background: linear-gradient(145deg, rgba(209, 15, 92, 0.35), rgba(125, 29, 255, 0.3));
}

.guild-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.guild-item .name {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
}

.guild-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.guild-icon-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.14);
}

.guild-item .meta {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(18, 18, 30, 0.96);
  box-shadow: var(--shadow);
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h2 {
  margin: 2px 0 0;
  font-size: 1.2rem;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.viewer-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
}

.viewer-chip img {
  width: 29px;
  height: 29px;
  border-radius: 999px;
  object-fit: cover;
}

.viewer-chip p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.1;
}

.viewer-chip span {
  color: var(--muted);
  font-size: 0.72rem;
}

.page-nav-wrap {
  position: sticky;
  top: 10px;
  z-index: 8;
  backdrop-filter: blur(8px);
}

.page-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.page-tab {
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}

.page-tab:hover {
  transform: translateY(-1px);
  border-color: #6f70a0;
}

.page-tab.active {
  border-color: rgba(209, 15, 92, 0.86);
  background: linear-gradient(145deg, rgba(209, 15, 92, 0.8), rgba(125, 29, 255, 0.9));
}

.page-panel {
  display: none;
}

.page-panel.active {
  display: block;
}

.section-title h3 {
  margin: 0;
  font-size: 1.18rem;
}

.section-title p {
  margin: 5px 0 0;
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  padding: 13px;
}

.stat-label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.stat-card h4 {
  margin: 8px 0 0;
  font-size: 1rem;
}

.preview-card {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.preview-card h4 {
  margin: 0 0 8px;
}

.preview-text {
  margin: 0;
  color: #e6e6ff;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.guard-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.guard-list li {
  line-height: 1.35;
}

.manager-list {
  display: grid;
  gap: 10px;
}

.manager-item {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.manager-main {
  min-width: 0;
}

.manager-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.92rem;
}

.manager-meta {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.manager-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn.small {
  padding: 7px 10px;
  font-size: 0.76rem;
}

.btn.warn {
  border-color: rgba(254, 231, 92, 0.8);
  background: rgba(254, 231, 92, 0.16);
}

.btn.danger-soft {
  border-color: rgba(237, 66, 69, 0.8);
  background: rgba(237, 66, 69, 0.16);
}

.manager-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.big-gap {
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 0.95rem;
}

.field > span {
  font-weight: 600;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line-soft);
  background: var(--bg-card-2);
  border-radius: 13px;
  min-height: 48px;
  padding: 12px;
  font-size: 0.95rem;
}

.switch.big {
  min-height: 54px;
  padding: 13px;
}

.switch input {
  accent-color: var(--primary);
}

.input {
  width: 100%;
  border: 1px solid var(--line-soft);
  background: #10101a;
  color: var(--text);
  border-radius: 13px;
  padding: 13px 14px;
  font-size: 0.95rem;
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(209, 15, 92, 0.2);
}

.textarea {
  resize: vertical;
  min-height: 112px;
}

.payload-preview {
  margin: 0;
  border: 1px solid var(--line-soft);
  background: #0e0e16;
  border-radius: 13px;
  min-height: 170px;
  max-height: 300px;
  overflow: auto;
  padding: 13px;
  color: #d7e6ff;
  font-size: 0.84rem;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.between {
  justify-content: space-between;
}

.wrap-mobile {
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line-soft);
  background: var(--bg-card-2);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.danger {
  border-color: rgba(209, 15, 92, 0.8);
  background: linear-gradient(145deg, rgba(209, 15, 92, 0.9), rgba(125, 29, 255, 0.92));
}

.btn.ghost {
  background: transparent;
}

.btn.unsaved {
  box-shadow: 0 0 0 4px rgba(209, 15, 92, 0.2);
}

.auth-gate h3 {
  margin-top: 0;
}

.key-login {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.empty {
  text-align: center;
  padding: 46px 20px;
}

.sticky-footer {
  position: sticky;
  bottom: 14px;
  backdrop-filter: blur(9px);
}

.live-actions-wrap {
  align-items: stretch;
  gap: 12px;
}

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

.tiny {
  font-size: 0.78rem;
}

.mt-12 {
  margin-top: 12px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: linear-gradient(145deg, rgba(209, 15, 92, 0.96), rgba(125, 29, 255, 0.96));
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 150;
}

.invite-modal {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.invite-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
}

.invite-modal-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  border-radius: 16px;
  border: 1px solid var(--line-soft);
  background: rgba(18, 18, 30, 0.98);
  box-shadow: var(--shadow);
  padding: 18px;
}

.invite-modal-card h3 {
  margin: 0;
}

.invite-table-wrap {
  margin-top: 12px;
  overflow: auto;
}

.invite-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 540px;
}

.invite-table th,
.invite-table td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.invite-table th {
  font-size: 0.79rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.invite-table td {
  font-size: 0.9rem;
}

@media (max-width: 1260px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1140px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .guild-list {
    max-height: 240px;
  }

  .page-nav-wrap {
    position: static;
  }
}

@media (max-width: 760px) {
  .grid.two,
  .grid.four,
  .grid.three,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .live-actions-wrap {
    flex-direction: column;
  }
}
