/* === MasterPlugins — space theme === */
:root {
  --bg:           #000;
  --panel:        #0a0814;
  --panel-edge:   rgba(139, 92, 246, 0.35);
  --panel-glow:   rgba(139, 92, 246, 0.15);
  --card:         #110d1c;
  --card-hover:   #160f24;
  --border:       #251b38;
  --fg:           #e8e6f0;
  --fg-mute:      #9b94b0;
  --fg-dim:       #6b6280;
  --accent:       #a78bfa;
  --accent-soft:  rgba(167, 139, 250, 0.12);
  --err:          #f87171;
  --info:         #34d399;
  --warn:         #fbbf24;
  --mono:         ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  overflow-x: hidden;
}
body.dark { background: var(--bg); }

/* --- starfield canvas --- */
#starfield {
  position: fixed; top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0; pointer-events: none;
}

/* --- centered panel ("screen in a screen") --- */
.space-frame {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.space-panel {
  width: 100%;
  max-width: 1280px;
  min-height: calc(100vh - 80px);
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid var(--panel-edge);
  box-shadow:
    0 0 0 1px rgba(167, 139, 250, 0.06),
    0 0 60px var(--panel-glow),
    0 20px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  overflow: hidden;
}
.space-panel::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% -20%, rgba(167,139,250,0.08), transparent 60%);
  z-index: 0;
}
.space-panel > * { position: relative; z-index: 1; }

@media (max-width: 768px) {
  .space-frame { padding: 0; }
  .space-panel {
    border-radius: 0;
    border: 0;
    min-height: 100vh;
    box-shadow: none;
  }
}

/* --- top nav (public layout) --- */
.topnav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(167,139,250,0.04), transparent);
}
.topnav .brand {
  color: var(--accent); font-weight: 700; text-decoration: none;
  font-size: 1.15rem; letter-spacing: 0.02em;
}
.topnav nav { display: flex; gap: 1.25rem; align-items: center; }
.topnav nav a {
  color: var(--fg-mute); text-decoration: none; font-size: 0.92rem;
  transition: color 120ms;
}
.topnav nav a:hover { color: var(--fg); }
.inline { display: inline; }
.inline button {
  background: transparent; border: 1px solid var(--border); color: var(--fg-mute);
  padding: 0.35rem 0.85rem; cursor: pointer; border-radius: 6px;
  font-size: 0.85rem; transition: all 120ms;
}
.inline button:hover { color: var(--fg); border-color: var(--accent); }

/* --- main content area --- */
main {
  padding: 2.25rem 2rem 3rem;
  max-width: 880px;
  margin: 0 auto;
}

/* --- auth forms --- */
.auth-form {
  display: flex; flex-direction: column; gap: 0.85rem;
  max-width: 380px; margin-top: 1.25rem;
}
.auth-form label {
  display: flex; flex-direction: column; gap: 0.35rem;
  color: var(--fg-mute); font-size: 0.9rem;
}
.auth-form input {
  padding: 0.65rem 0.8rem;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 8px;
  font-family: inherit; font-size: 0.95rem;
  transition: border-color 120ms;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-form button {
  padding: 0.7rem 1rem;
  background: var(--accent);
  color: #0c0815;
  border: 0; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 0.95rem;
  transition: filter 120ms, transform 120ms;
}
.auth-form button:hover { filter: brightness(1.1); }
.auth-form button:active { transform: translateY(1px); }

/* --- alerts --- */
.err, .info {
  padding: 0.85rem 1rem; border-radius: 8px;
  margin-bottom: 1.25rem; font-size: 0.92rem;
  border: 1px solid;
}
.err {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}
.info {
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.4);
  color: #6ee7b7;
}

h1, h2, h3 { color: var(--fg); }
h1 { font-size: 1.65rem; font-weight: 700; margin: 0 0 0.5rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 1.75rem 0 0.75rem; color: var(--fg); }
p { color: var(--fg-mute); }
code { font-family: var(--mono); background: rgba(167,139,250,0.08); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.88rem; color: #ddd6fe; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === ADMIN === */
.admin-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 80px);
}
@media (max-width: 768px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-grid .admin-side { display: none; }
}

.admin-side {
  background: rgba(0,0,0,0.35);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0.75rem;
  display: flex; flex-direction: column;
}
.admin-side-header { padding: 0 0.75rem 1.5rem; }
.admin-side-header .brand {
  color: var(--accent); font-weight: 700; font-size: 1.1rem;
  text-decoration: none; letter-spacing: 0.02em;
}
.admin-side-sub {
  color: var(--fg-dim); font-size: 0.78rem; margin-top: 0.25rem;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.admin-side nav { display: flex; flex-direction: column; gap: 0.15rem; flex-grow: 1; }
.admin-side nav a {
  color: var(--fg-mute); text-decoration: none; font-size: 0.92rem;
  padding: 0.55rem 0.85rem; border-radius: 6px;
  transition: all 120ms;
}
.admin-side nav a:hover { background: var(--accent-soft); color: var(--fg); }
.admin-side nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  position: relative;
}
.admin-side nav a.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.admin-side-logout { padding: 0 0.75rem; }
.admin-side-logout button {
  width: 100%; padding: 0.55rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-mute); cursor: pointer; border-radius: 6px;
  font-size: 0.85rem; transition: all 120ms;
}
.admin-side-logout button:hover { color: var(--fg); border-color: var(--accent); }

.admin-main {
  padding: 2rem 2.25rem;
  max-width: none;
  overflow-x: auto;
}
.admin-main h1 { margin: 0; }

.page-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.75rem;
  gap: 1rem; flex-wrap: wrap;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1.15rem 1.25rem;
  border-radius: 10px;
  transition: border-color 120ms, transform 120ms;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-num {
  font-size: 2rem; font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.card-label {
  color: var(--fg-dim); font-size: 0.78rem;
  margin-top: 0.4rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}

table.data {
  width: 100%; border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  font-size: 0.92rem;
}
table.data th, table.data td {
  padding: 0.75rem 1rem; text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data th {
  background: rgba(167,139,250,0.04);
  font-weight: 600; color: var(--fg-mute);
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover { background: var(--card-hover); }
table.data code { background: rgba(167,139,250,0.06); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 0.95rem;
  background: var(--accent); color: #0c0815;
  border: 0; border-radius: 7px;
  cursor: pointer; text-decoration: none;
  font-size: 0.88rem; font-weight: 600;
  transition: filter 120ms, transform 120ms;
}
.btn:hover { filter: brightness(1.1); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-danger { background: var(--err); color: #1a0808; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-mute);
}
.btn-ghost:hover { color: var(--fg); border-color: var(--accent); background: var(--accent-soft); filter: none; }

.form-grid {
  display: grid; gap: 0.95rem;
  max-width: 620px;
}
.form-grid label {
  display: flex; flex-direction: column; gap: 0.35rem;
  color: var(--fg-mute); font-size: 0.88rem;
}
.form-grid input,
.form-grid textarea,
.form-grid select {
  padding: 0.6rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 7px;
  font-family: inherit; font-size: 0.93rem;
  transition: border-color 120ms;
}
.form-grid input:focus, .form-grid textarea:focus, .form-grid select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-grid textarea {
  min-height: 220px;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.row-actions { display: flex; gap: 0.6rem; margin-top: 0.5rem; flex-wrap: wrap; }

/* === customer portal === */
.account-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 80px);
}
@media (max-width: 768px) {
  .account-grid { grid-template-columns: 1fr; }
  .account-grid .account-side { display: none; }
}
.account-side {
  background: rgba(0,0,0,0.35);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0.75rem;
  display: flex; flex-direction: column;
}
.account-side-header { padding: 0 0.75rem 1.5rem; }
.account-side-header .brand {
  color: var(--accent); font-weight: 700; font-size: 1.1rem;
  text-decoration: none; letter-spacing: 0.02em;
}
.account-side-sub {
  color: var(--fg-dim); font-size: 0.78rem; margin-top: 0.25rem;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.account-side nav { display: flex; flex-direction: column; gap: 0.15rem; flex-grow: 1; }
.account-side nav a {
  color: var(--fg-mute); text-decoration: none; font-size: 0.92rem;
  padding: 0.55rem 0.85rem; border-radius: 6px;
  transition: all 120ms;
}
.account-side nav a:hover { background: var(--accent-soft); color: var(--fg); }
.account-side nav a.active {
  background: var(--accent-soft); color: var(--accent);
  position: relative;
}
.account-side nav a.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.account-side-discord {
  margin: 0.5rem 0.75rem;
  padding: 0.55rem 0.85rem;
  background: #5865F2;
  color: white;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  text-align: center;
  transition: filter 120ms;
}
.account-side-discord:hover { filter: brightness(1.1); text-decoration: none; }
.account-side-logout { padding: 0 0.75rem; }
.account-side-logout button {
  width: 100%; padding: 0.55rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-mute); cursor: pointer; border-radius: 6px;
  font-size: 0.85rem; transition: all 120ms;
}
.account-side-logout button:hover { color: var(--fg); border-color: var(--accent); }
.account-main {
  padding: 2rem 2.25rem;
  max-width: none;
  overflow-x: auto;
}
.account-main h1 { margin: 0; }

/* license card list */
.license-list { display: grid; gap: 1rem; }
.license-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.25rem 1.4rem;
}
.license-card h3 { margin: 0 0 0.4rem; font-size: 1.05rem; color: var(--fg); }
.license-card .license-key {
  font-family: var(--mono); color: var(--accent);
  font-size: 0.9rem; user-select: all;
}
.license-card .license-meta { color: var(--fg-mute); font-size: 0.85rem; margin-top: 0.4rem; }
.license-card .license-meta strong { color: var(--fg); font-weight: 600; }
.slot-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  margin-top: 0.6rem;
  background: rgba(0,0,0,0.25);
  font-size: 0.88rem;
}
.slot-row .slot-info { display: flex; flex-direction: column; gap: 0.15rem; }
.slot-row .slot-uuid { font-family: var(--mono); color: var(--fg); }
.slot-row .slot-meta { color: var(--fg-dim); font-size: 0.78rem; }
.slot-empty {
  padding: 0.7rem 0.9rem; border: 1px dashed var(--border);
  border-radius: 7px; margin-top: 0.6rem;
  color: var(--fg-dim); font-size: 0.85rem; text-align: center;
}
.download-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 1rem; align-items: center;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.download-row:last-child { border-bottom: 0; }
.download-row .download-version { font-family: var(--mono); color: var(--fg); }
.download-row .download-channel { color: var(--fg-dim); font-size: 0.78rem; text-transform: uppercase; }
.download-row .download-size { color: var(--fg-mute); font-size: 0.85rem; }
.changelog-md {
  margin-top: 0.4rem; padding: 0.6rem 0.85rem;
  background: rgba(0,0,0,0.25); border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.85rem; color: var(--fg-mute);
}
.changelog-md p { margin: 0.4rem 0; }
.changelog-md code { background: rgba(167,139,250,0.06); }

/* === public catalog === */
.hero {
  text-align: center;
  padding: 3.5rem 1rem 2.5rem;
}
.hero h1 {
  font-size: 2.5rem;
  margin: 0 0 0.5rem;
  background: linear-gradient(135deg, var(--accent), #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.02em;
}
.hero p { font-size: 1.1rem; color: var(--fg-mute); max-width: 560px; margin: 0 auto; }
.plugin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
  padding: 0 1rem;
}
.plugin-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  color: var(--fg);
  transition: all 160ms;
  display: block;
}
.plugin-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(167, 139, 250, 0.15);
  text-decoration: none;
}
.plugin-card .plugin-cat {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
}
.plugin-card h3 { margin: 0 0 0.4rem; font-size: 1.15rem; color: var(--fg); }
.plugin-card .plugin-tagline { color: var(--fg-mute); font-size: 0.92rem; margin: 0; }

.catalog-filters {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.catalog-filters a {
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--fg-mute);
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 120ms;
}
.catalog-filters a:hover, .catalog-filters a.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

/* plugin detail */
.plugin-detail-head {
  display: grid; grid-template-columns: 1fr auto; gap: 2rem;
  align-items: start;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}
@media (max-width: 640px) { .plugin-detail-head { grid-template-columns: 1fr; } }
.plugin-detail-head h1 { font-size: 2rem; margin: 0 0 0.5rem; }
.plugin-detail-head .plugin-tagline { font-size: 1.1rem; color: var(--fg-mute); margin: 0; }
.plugin-detail-meta { font-size: 0.85rem; color: var(--fg-dim); margin-top: 0.75rem; }
.plugin-detail-meta strong { color: var(--fg); }
.plugin-detail-cta { display: flex; flex-direction: column; gap: 0.5rem; min-width: 200px; }
.plugin-detail-cta .btn { justify-content: center; }
.plugin-description {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
  font-size: 0.95rem;
  color: var(--fg);
}
.plugin-description h1, .plugin-description h2, .plugin-description h3 { color: var(--fg); }
.plugin-description p { color: var(--fg); }
.plugin-description code { background: rgba(167,139,250,0.08); }
.plugin-description pre { background: #06040c; padding: 1rem; border-radius: 6px; overflow-x: auto; border: 1px solid var(--border); }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--fg-dim);
}

/* === docs === */
.docs-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  padding: 1rem 0;
}
@media (max-width: 768px) { .docs-grid { grid-template-columns: 1fr; } }
.docs-side { position: sticky; top: 1rem; align-self: start; }
.docs-side-back {
  display: block; padding: 0.4rem 0.75rem; margin-bottom: 0.75rem;
  color: var(--fg-mute); font-size: 0.85rem;
}
.docs-side nav { display: flex; flex-direction: column; gap: 0.15rem; }
.docs-side nav a {
  padding: 0.5rem 0.75rem; border-radius: 6px;
  color: var(--fg-mute); font-size: 0.9rem;
  text-decoration: none; transition: all 120ms;
}
.docs-side nav a:hover { background: var(--accent-soft); color: var(--fg); }
.docs-side nav a.active {
  background: var(--accent-soft); color: var(--accent); position: relative;
}
.docs-side nav a.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; background: var(--accent); border-radius: 0 2px 2px 0;
}
.docs-article h1 { margin-top: 0; }
.docs-body {
  color: var(--fg);
  font-size: 0.96rem;
  line-height: 1.7;
}
.docs-body h2 { margin-top: 2rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); }
.docs-body h3 { margin-top: 1.5rem; }
.docs-body p { color: var(--fg); }
.docs-body code { background: rgba(167,139,250,0.08); }
.docs-body pre {
  background: #06040c;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
}
.docs-body pre code { background: transparent; padding: 0; color: var(--fg); }
.docs-body ul, .docs-body ol { color: var(--fg); }
.docs-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin-left: 0;
  color: var(--fg-mute);
}
.docs-updated { color: var(--fg-dim); font-size: 0.78rem; margin-top: 2rem; }
.docs-index-list { list-style: none; padding: 0; }
.docs-index-list li { margin: 0.4rem 0; }

/* === changelog === */
.changelog-list { display: flex; flex-direction: column; gap: 1.5rem; }
.changelog-entry {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 1.5rem 1.75rem;
}
.changelog-entry header { margin-bottom: 0.75rem; }
.changelog-entry h2 { margin: 0 0 0.3rem; font-size: 1.2rem; }
.changelog-entry-meta { color: var(--fg-dim); font-size: 0.82rem; }
.changelog-entry-meta a { color: var(--accent); }
.changelog-body { color: var(--fg); font-size: 0.92rem; }
.changelog-body p { color: var(--fg); margin: 0.5rem 0; }
.changelog-body ul, .changelog-body ol { margin: 0.5rem 0; }
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; margin-top: 2rem;
}
.pagination-info { color: var(--fg-dim); font-size: 0.85rem; }
