:root {
  color-scheme: dark;
  --bg: #17181d;
  --bg-secondary: #202127;
  --bg-tertiary: #292b33;
  --bg-hover: #32343e;
  --border: #383a45;
  --text: #e7e9ee;
  --text-heading: #f5f6f8;
  --text-muted: #a0a4b2;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success: #43b581;
  --danger: #f27e85;
  --warning: #f0b44d;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .2);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

body > main {
  flex: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

svg {
  display: block;
}

.container {
  width: min(1200px, calc(100% - 2.5rem));
  margin: 0 auto;
}

.site-header {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 76px;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  min-width: 0;
  flex-shrink: 0;
}

.site-logo-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1;
  transition: background .2s ease;
}

.site-logo-mark:hover {
  background: var(--accent-hover);
}

.site-language {
  position: relative;
  min-width: 0;
}

.site-language-trigger {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .25rem;
  border-radius: 6px;
  color: var(--text-heading);
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.4;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color .2s ease;
}

.site-language-trigger::-webkit-details-marker {
  display: none;
}

.site-language-trigger::marker {
  content: "";
}

.site-language-trigger:hover,
.site-language[open] .site-language-trigger {
  color: #abb1ff;
}

.site-language-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform .2s ease;
}

.site-language[open] .site-language-chevron {
  transform: rotate(180deg);
}

.site-language-dropdown {
  position: absolute;
  z-index: 100;
  top: calc(100% + .75rem);
  left: 0;
  width: 185px;
  padding: .4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  box-shadow: var(--shadow);
}

.site-language-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: .7rem .8rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: .85rem;
  text-align: left;
  cursor: pointer;
  transition: background .2s ease;
}

.site-language-option:hover,
.site-language-option:focus-visible {
  background: var(--bg-hover);
}

.site-language-option[aria-pressed="true"] {
  background: rgba(88, 101, 242, .14);
  color: #b2b8ff;
}

.site-language-option[aria-pressed="true"]::after {
  content: "✓";
  color: #b2b8ff;
  font-size: .9rem;
  font-weight: 700;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 1.5rem;
  min-width: 0;
}

.site-nav a,
.site-nav .nav-logout {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: .4rem 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color .2s ease;
}

.site-nav a:hover,
.site-nav a.active,
.site-nav .nav-logout:hover {
  color: var(--text-heading);
}

.site-nav a.active {
  font-weight: 650;
}

.site-nav form {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.site-nav .nav-logout {
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 44px;
  padding: .75rem 1.2rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}

.button:active {
  transform: translateY(1px);
}

.button--primary {
  background: var(--accent);
  color: #fff;
}

.button--primary:hover {
  background: var(--accent-hover);
}

.button--secondary {
  border-color: var(--border);
  background: var(--bg-tertiary);
  color: var(--text);
}

.button--secondary:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.button--small {
  min-height: 36px;
  padding: .55rem .85rem;
  font-size: .8rem;
}

.hero {
  padding: 5rem 0 3.5rem;
  text-align: center;
}

.hero-eyebrow {
  display: inline-block;
  color: #a5acff;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.hero h1 {
  max-width: 850px;
  margin: 1rem auto;
  color: var(--text-heading);
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  font-weight: 750;
  letter-spacing: -.03em;
  line-height: 1.15;
}

.hero > p {
  max-width: 640px;
  margin: 0 auto;
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1.75;
}

.search-form {
  display: flex;
  align-items: stretch;
  gap: .75rem;
  max-width: 840px;
  margin: 2rem auto 0;
}

.search-form input,
.search-form select,
.edit-field input[type="text"],
.edit-field select,
.edit-field textarea {
  min-width: 0;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  background: var(--bg-secondary);
  color: var(--text);
  transition: border-color .2s ease, background .2s ease;
}

.search-form input:focus,
.search-form select:focus,
.edit-field input:focus,
.edit-field select:focus,
.edit-field textarea:focus {
  border-color: var(--accent);
}

.search-form input {
  flex: 1;
}

.search-form select {
  width: 190px;
  padding-right: 2.25rem;
}

.search-form input::placeholder,
.edit-field input::placeholder,
.edit-field textarea::placeholder {
  color: var(--text-muted);
  opacity: .75;
}

.listings-section {
  padding-bottom: 5rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.section-heading h2 {
  margin: 0 0 .35rem;
  color: var(--text-heading);
  font-size: 1.35rem;
  font-weight: 700;
}

.section-heading p,
.server-count {
  margin: 0;
  color: var(--text-muted);
  font-size: .85rem;
}

.server-count {
  display: inline-flex;
  align-items: center;
  padding: .4rem .75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-secondary);
  white-space: nowrap;
}

.server-grid,
.manage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.server-card,
.manage-card,
.detail-card,
.info-card,
.edit-form,
.empty-state {
  min-width: 0;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
}

.server-card,
.manage-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transition: border-color .2s ease, transform .2s ease;
}

.server-card:hover,
.manage-card:hover {
  border-color: #555968;
  transform: translateY(-2px);
}

.server-card-heading,
.manage-card-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.server-avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 14px;
  background: var(--bg-tertiary);
  color: var(--text-heading);
  font-size: 1.25rem;
  font-weight: 750;
}

.server-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.server-card-title,
.manage-card-title {
  min-width: 0;
}

.server-card-title h3,
.manage-card-title h2 {
  margin: 0 0 .4rem;
  color: var(--text-heading);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.server-card-title h3 a:hover {
  color: #a5acff;
}

.premium-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  width: fit-content;
  padding: .3rem .65rem;
  border-radius: 6px;
  font-size: .7rem;
  font-weight: 750;
  line-height: 1.4;
}

.premium-badge {
  border: 1px solid rgba(245, 158, 11, .25);
  background: rgba(245, 158, 11, .1);
  color: var(--warning);
  letter-spacing: .4px;
}

.premium-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.status-badge--active {
  border: 1px solid rgba(67, 181, 129, .25);
  background: rgba(67, 181, 129, .1);
  color: var(--success);
}

.status-badge--muted {
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.server-description {
  display: -webkit-box;
  flex: 1;
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: .85rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-line;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.server-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.server-category {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: .3rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: .75rem;
  text-transform: capitalize;
}

.server-card-bump {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem;
  color: var(--text-muted);
  font-size: .75rem;
}

.server-card-bump time {
  color: var(--text);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: .85rem;
}

.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: .6rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color .2s ease, background .2s ease;
}

.pagination a:hover {
  border-color: var(--accent);
  background: var(--bg-secondary);
}

.pagination-current {
  padding: .6rem .25rem;
  white-space: nowrap;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  min-height: 260px;
  text-align: center;
}

.empty-state-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: .25rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.empty-state-icon svg {
  width: 30px;
  height: 30px;
}

.empty-state h2,
.empty-state h3 {
  margin: 0;
  color: var(--text-heading);
  font-size: 1.15rem;
}

.empty-state p {
  max-width: 420px;
  margin: 0;
  color: var(--text-muted);
  font-size: .9rem;
}

.detail-page {
  max-width: 850px;
  padding-top: 3rem;
  padding-bottom: 5rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: .85rem;
  transition: color .2s ease;
}

.back-link:hover {
  color: var(--text-heading);
}

.detail-card {
  padding: 2rem;
}

.detail-heading {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-width: 0;
}

.detail-heading-content {
  min-width: 0;
}

.server-avatar--large {
  width: 92px;
  height: 92px;
  border-radius: 20px;
  font-size: 2rem;
}

.detail-heading h1 {
  margin: 0 0 .75rem;
  color: var(--text-heading);
  font-size: clamp(1.4rem, 4vw, 2rem);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.detail-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}

.detail-section {
  margin: 2rem 0;
}

.detail-section h2 {
  margin: 0 0 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-heading);
  font-size: 1.1rem;
}

.detail-description {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.8;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.detail-stat {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-tertiary);
}

.detail-stat span {
  color: var(--text-muted);
  font-size: .8rem;
}

.detail-stat strong {
  color: var(--text-heading);
  font-size: .9rem;
  overflow-wrap: anywhere;
}

.join-button {
  width: 100%;
}

.manage-page,
.edit-page {
  padding-top: 3rem;
  padding-bottom: 5rem;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.page-heading h1 {
  margin: 0 0 .4rem;
  color: var(--text-heading);
  font-size: 1.8rem;
  line-height: 1.3;
}

.page-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: .9rem;
}

.account-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .35rem;
  color: var(--text-muted);
  font-size: .85rem;
}

.account-info strong {
  color: var(--text-heading);
  overflow-wrap: anywhere;
}

.manage-card-title span {
  color: var(--text-muted);
  font-size: .75rem;
  overflow-wrap: anywhere;
}

.manage-card-status {
  flex: 1;
}

.manage-card > .button {
  width: 100%;
}

.manage-card-note {
  margin: 0;
  color: var(--text-muted);
  font-size: .8rem;
  line-height: 1.6;
}

.edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(270px, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.edit-main,
.edit-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  min-width: 0;
}

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.edit-field {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  min-width: 0;
}

.edit-field > label:first-child {
  color: var(--text-heading);
  font-size: .85rem;
  font-weight: 650;
}

.edit-field input[type="text"],
.edit-field select,
.edit-field textarea {
  width: 100%;
  background: var(--bg-tertiary);
}

.edit-field select {
  padding-right: 2.25rem;
}

.edit-field textarea {
  min-height: 140px;
  resize: vertical;
  line-height: 1.7;
}

.field-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: .8rem;
  line-height: 1.6;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  width: fit-content;
  color: var(--text);
  font-size: .85rem;
  cursor: pointer;
}

.checkbox-label input {
  width: 17px;
  height: 17px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.info-card h2 {
  margin: 1rem 0 .25rem;
  color: var(--text-heading);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.info-card h3 {
  margin: 0 0 1.25rem;
  color: var(--text-heading);
  font-size: 1rem;
}

.info-card-id {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: .75rem;
  overflow-wrap: anywhere;
}

.info-stat {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
  font-size: .85rem;
}

.info-stat span {
  color: var(--text-muted);
}

.info-stat strong {
  color: var(--text-heading);
  text-align: right;
  overflow-wrap: anywhere;
}

.info-card .field-hint {
  margin-top: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.preview-link {
  width: 100%;
}

.alert {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  line-height: 1.6;
}

.alert--success {
  border-color: rgba(67, 181, 129, .3);
  background: rgba(67, 181, 129, .08);
  color: #7eddb0;
}

.alert--error {
  border-color: rgba(242, 126, 133, .3);
  background: rgba(242, 126, 133, .08);
  color: #f59aa0;
}

.site-footer {
  margin-top: auto;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: .8rem;
}

.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-footer a:hover {
  color: var(--text-heading);
}

@media (max-width: 1100px) {
  .site-header-inner {
    gap: 1rem;
  }

  .site-nav {
    gap: 1rem;
  }

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

  .edit-layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .edit-sidebar .preview-link {
    grid-column: 1 / -1;
  }
}

@media (max-width: 750px) {
  .site-header-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: .75rem;
    padding: 1rem 0;
  }

  .site-nav {
    justify-content: flex-start;
    width: 100%;
    gap: .6rem 1.25rem;
  }

  .hero {
    padding: 3.5rem 0 3rem;
  }

  .search-form {
    flex-direction: column;
  }

  .search-form select,
  .search-form .button {
    width: 100%;
  }
}

@media (max-width: 650px) {
  .container {
    width: calc(100% - 2rem);
  }

  .site-language-trigger {
    max-width: 100%;
    font-size: .95rem;
  }

  .site-language-dropdown {
    width: 175px;
  }

  .hero {
    padding: 3rem 0;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .section-heading,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .server-grid,
  .manage-grid,
  .detail-stats,
  .edit-sidebar {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-page,
  .manage-page,
  .edit-page {
    padding-top: 2rem;
    padding-bottom: 3rem;
  }

  .server-card,
  .manage-card,
  .detail-card,
  .info-card,
  .edit-form {
    padding: 1rem;
  }

  .detail-heading {
    align-items: flex-start;
    gap: 1rem;
  }

  .server-avatar--large {
    width: 72px;
    height: 72px;
    border-radius: 16px;
  }

  .edit-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .edit-actions .button {
    width: 100%;
  }

  .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 390px) {
  .site-logo {
    gap: .5rem;
  }

  .site-logo-mark {
    width: 34px;
    height: 34px;
  }

  .site-language-trigger {
    font-size: .87rem;
  }

  .server-card-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .server-card-footer .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .site-logo-mark,
  .site-language-trigger,
  .site-language-chevron,
  .site-language-option,
  .site-nav a,
  .button,
  .server-card,
  .manage-card,
  .pagination a {
    transition: none;
  }

  .server-card:hover,
  .manage-card:hover {
    transform: none;
  }

  .button:active {
    transform: none;
  }
}