:root {
  --accent: #9966CC;
  --accent-light: #b98ee0;
  --accent-dark: #7d4fb0;
  --bg: #0a0910;
  --surface: #17141f;
  --surface-2: #1d1929;
  --border: #2a2536;
  --text: #f5f2fa;
  --text-muted: #a79fb8;
  --ok: #6ee7a8;
  --warn: #f0b866;
  --bad: #ff8b8b;

  --font-text: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;

  --transition: 0.2s ease;
  --radius: 14px;
  --radius-sm: 10px;

  --app-bg: #0d0c11;
  --app-bar: #131118;
  --app-surface: #1a181f;
  --app-border: #2a2733;
  --app-text: #f1f0f5;
  --app-muted: #a6a2b5;
  --app-dim: #726d82;
  --app-accent: #a855f7;
  --app-accent-2: #8b5cf6;
  --app-success: #3ecf8e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-text);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

h1, h2, h3 {
  font-family: var(--font-display);
}

a {
  color: var(--accent-light);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--text);
}

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(153, 102, 204, 0.12);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  word-break: break-word;
}

:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 3px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---------------------------------------------------------------- *
 * Background
 * ---------------------------------------------------------------- */

.starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.75;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}

.glow--one {
  width: 560px;
  height: 560px;
  top: -180px;
  left: -140px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  animation: float-one 16s ease-in-out infinite;
}

.glow--two {
  width: 620px;
  height: 620px;
  bottom: -220px;
  right: -160px;
  background: radial-gradient(circle, var(--accent-dark) 0%, transparent 70%);
  animation: float-two 20s ease-in-out infinite;
}

@keyframes float-one {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.08); }
}

@keyframes float-two {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, -30px) scale(1.06); }
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 3px 3px;
}

.scanline {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(185, 142, 224, 0.05) 48%,
    rgba(185, 142, 224, 0.09) 50%,
    rgba(185, 142, 224, 0.05) 52%,
    transparent 100%
  );
  background-size: 100% 240px;
  background-repeat: no-repeat;
  animation: scan 9s linear infinite;
}

@keyframes scan {
  from { background-position: 0 -240px; }
  to   { background-position: 0 100vh; }
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  opacity: 0;
  animation: fade-in-up 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-in.delay-1 { animation-delay: 0.1s; }
.animate-in.delay-2 { animation-delay: 0.25s; }
.animate-in.delay-3 { animation-delay: 0.4s; }

/* ---------------------------------------------------------------- *
 * Header
 * ---------------------------------------------------------------- */

.navbar {
  position: relative;
  z-index: 2;
  padding: 28px 40px;
}

.navbar.animate-in {
  animation-delay: 0s;
}

.navbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1120px;
  margin: 0 auto;
}

.navbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.navbar__logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(153, 102, 204, 0.5));
}

.navbar__links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 0.9rem;
}

.navbar__links a {
  color: var(--text-muted);
}

.navbar__links a:hover {
  color: var(--text);
}

/* ---------------------------------------------------------------- *
 * Page layout
 * ---------------------------------------------------------------- */

.page {
  position: relative;
  z-index: 2;
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 40px 40px;
}

.page--narrow {
  max-width: 780px;
  padding-top: 40px;
}

.section {
  padding-top: clamp(56px, 7vw, 88px);
}

.section--last {
  padding-bottom: 32px;
}

.section__title {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 30px;
}


/* ---------------------------------------------------------------- *
 * Buttons
 * ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 14px 26px;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition),
              border-color var(--transition), color var(--transition);
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 60%, #63348f 100%);
  color: #fff;
  box-shadow: 0 10px 30px rgba(125, 79, 176, 0.38);
}

.btn--primary:hover {
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 60%, var(--accent-dark) 100%);
  color: #fff;
  box-shadow: 0 12px 34px rgba(125, 79, 176, 0.5);
}

.btn--ghost {
  background: rgba(23, 20, 31, 0.7);
  border-color: var(--border);
  color: var(--text);
}

.btn--ghost:hover {
  color: var(--text);
  border-color: var(--accent);
}

.btn--small {
  padding: 7px 16px;
  font-size: 0.85rem;
}

.btn--disabled {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.btn__icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent-light);
  cursor: pointer;
  border-bottom: 1px dotted currentColor;
}

.linklike:hover {
  color: var(--text);
}

.linklike.is-copied {
  color: var(--ok);
  border-bottom-color: transparent;
}

/* ---------------------------------------------------------------- *
 * Panels
 * ---------------------------------------------------------------- */

.panel {
  background: rgba(23, 20, 31, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 26px;
}

.panel--empty {
  color: var(--text-muted);
  text-align: center;
}

/* ---------------------------------------------------------------- *
 * Lede
 * ---------------------------------------------------------------- */

.lede {
  padding: 30px 0 34px;
}

.lede__title {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.lede__sub {
  margin-top: 12px;
  color: var(--text-muted);
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.muted--foot {
  margin-top: 24px;
  text-align: center;
}

/* ---------------------------------------------------------------- *
 * Forms
 * ---------------------------------------------------------------- */

.form {
  display: grid;
  gap: 18px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field--row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.form-field__label {
  font-size: 0.86rem;
  font-weight: 600;
}

.form-field__hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="file"],
.form-field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color var(--transition);
}

.form-field textarea {
  font-family: var(--mono);
  font-size: 0.84rem;
  resize: vertical;
}

.form-field input[type="file"] {
  padding: 8px 10px;
  cursor: pointer;
}

.form-field input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color var(--transition);
}

.form-field input[type="file"]::file-selector-button:hover {
  border-color: var(--accent);
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--accent);
  outline: none;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}

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

.form__actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.form__status {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.form__status.is-ok { color: var(--ok); }
.form__status.is-bad { color: var(--bad); }

.banner--bad {
  border-color: rgba(255, 139, 139, 0.45);
  background: rgba(255, 139, 139, 0.08);
}

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

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.88rem;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.admin-row:first-child {
  border-top: none;
}

.admin-row__version {
  font-weight: 650;
  min-width: 4.5em;
}

.admin-row__meta {
  color: var(--text-muted);
  margin-right: auto;
}

/* ---------------------------------------------------------------- *
 * Footer
 * ---------------------------------------------------------------- */

.footer {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 34px 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer a {
  color: var(--text-muted);
}

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

.footer__dot {
  margin: 0 8px;
  opacity: 0.5;
}

.footer__domain {
  color: var(--accent-light);
  font-weight: 600;
}

/* ---------------------------------------------------------------- *
 * Login and notices
 * ---------------------------------------------------------------- */

.page--narrow {
  margin: 0 auto;
  padding-top: 0;
}

.notice {
  margin-bottom: 20px;
  padding: 14px 18px;
  font-size: 0.92rem;
}

.notice--warn {
  border-color: rgba(240, 184, 102, 0.45);
  background: rgba(240, 184, 102, 0.08);
}

.stack {
  display: grid;
  gap: 18px;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.panel__title {
  font-size: 1.08rem;
  font-weight: 650;
  margin-bottom: 14px;
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.panel__actions {
  margin-top: 16px;
}

.qr {
  display: block;
  background: #fff;
  padding: 10px;
  border-radius: var(--radius-sm);
}

.qr__hint {
  margin-top: 12px;
}

.navbar__logout {
  display: inline;
}

.btn--danger:hover {
  border-color: var(--bad);
  color: var(--bad);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.admin-row__title {
  font-weight: 600;
  color: var(--text);
}

.admin-row form {
  display: inline;
}

.notice--ok {
  border-color: rgba(110, 231, 168, 0.45);
  background: rgba(110, 231, 168, 0.08);
}

.section--compact {
  padding-top: 40px;
}

.form--narrow {
  max-width: 520px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
}

.pill,
.pill-button {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
  vertical-align: 1px;
}

.pill-button {
  cursor: pointer;
  transition: border-color var(--transition);
}

.pill-button:hover {
  border-color: var(--accent);
}

.pill--ok { color: var(--ok); border-color: rgba(110, 231, 168, 0.4); background: rgba(110, 231, 168, 0.08); }
.pill--warn { color: var(--warn); border-color: rgba(240, 184, 102, 0.4); background: rgba(240, 184, 102, 0.08); }
.pill--bad { color: var(--bad); border-color: rgba(255, 139, 139, 0.4); background: rgba(255, 139, 139, 0.08); }

/* ---------------------------------------------------------------- *
 * Account
 * ---------------------------------------------------------------- */

.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.site-card {
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 18px 20px;
  background: rgba(23, 20, 31, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color var(--transition), transform var(--transition);
}

.site-card:hover {
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-2px);
}

.site-card__name {
  font-weight: 650;
}

.site-card__host {
  color: var(--text-muted);
  font-size: 0.84rem;
}

/* ---------------------------------------------------------------- *
 * Admin
 * ---------------------------------------------------------------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 22px;
}

.tabs__item {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.tabs__item:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tabs__item.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: var(--accent);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}

.table th {
  color: var(--text-muted);
  font-weight: 600;
}

.table tr:last-child td {
  border-bottom: none;
}

.table form {
  display: inline;
}

.table .cell--wrap {
  white-space: normal;
  min-width: 220px;
}

.row--bad td {
  color: var(--bad);
}

/* ---------------------------------------------------------------- *
 * Narrow screens
 * ---------------------------------------------------------------- */

@media (max-width: 640px) {
  .navbar {
    padding: 20px;
  }

  .navbar__links {
    gap: 14px;
    font-size: 0.84rem;
  }

  .page {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 440px) {
  .btn {
    padding: 13px 22px;
    font-size: 0.94rem;
  }

  .btn--small {
    padding: 7px 14px;
    font-size: 0.85rem;
  }
}

/* ---------------------------------------------------------------- *
 * Reduced motion
 * ---------------------------------------------------------------- */

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

  .glow--one,
  .glow--two,
  .scanline {
    animation: none;
  }

  .animate-in {
    animation-duration: 0.01ms;
    opacity: 1;
  }
}
