:root {
  --bg: #07080f;
  --panel: rgba(18, 22, 36, 0.55);
  --panel-2: rgba(255, 255, 255, 0.035);
  --solid: #0d1019;
  --line: rgba(120, 200, 230, 0.14);
  --line-h: rgba(34, 211, 238, 0.45);
  --text: #e9f2f7;
  --muted: #7f8aa3;
  --cyan: #22d3ee;
  --cyan-hi: #56e2f4;
  --magenta: #f472b6;
  --discord: #5865f2;
  --discord-hi: #4c59e0;
  --radius: 14px;
  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(680px 420px at 10% -5%, rgba(34, 211, 238, 0.16), transparent 60%),
    radial-gradient(680px 460px at 100% 105%, rgba(244, 114, 182, 0.13), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: radial-gradient(circle at 50% 30%, #000 40%, transparent 92%);
}

a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* Sidebar (glass) */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 21px; letter-spacing: -0.02em; padding: 4px 8px 22px; }
.brand span { color: var(--cyan); margin-left: 1px; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 500; font-size: 14.5px; cursor: pointer; border: none;
  background: none; width: 100%; text-align: left; font-family: inherit;
  transition: color 0.12s ease, background 0.12s ease;
}
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.active { color: var(--text); background: rgba(34, 211, 238, 0.10); box-shadow: inset 2px 0 0 var(--cyan); }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.nav-item.active .ico { color: var(--cyan); }
.nav-item.admin.active { background: rgba(244, 114, 182, 0.10); box-shadow: inset 2px 0 0 var(--magenta); }
.nav-item.admin.active .ico { color: var(--magenta); }

.side-foot { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 4px; }
.side-user .avatar { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); }
.side-user .who { min-width: 0; flex: 1; }
.side-user .who .name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who .role { font-size: 11.5px; color: var(--muted); }
.side-logout {
  width: 100%; margin-top: 12px; padding: 9px; border-radius: 9px; background: transparent;
  border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 13px;
  cursor: pointer; font-family: inherit; text-align: center; display: block;
  transition: color 0.12s, border-color 0.12s;
}
.side-logout:hover { color: var(--text); border-color: var(--line-h); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer;
  border: 1px solid transparent; font-family: inherit; width: 100%;
  transition: transform 0.08s ease, background 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
.btn:active { transform: translateY(1px); }
.btn.cyan { background: var(--cyan); color: #04121a; box-shadow: 0 0 0 rgba(34, 211, 238, 0); }
.btn.cyan:hover { background: var(--cyan-hi); box-shadow: 0 6px 24px rgba(34, 211, 238, 0.28); }
.btn.discord { background: var(--discord); color: #fff; }
.btn.discord:hover { background: var(--discord-hi); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--line-h); }
.btn.magenta { background: var(--magenta); color: #2a0d1c; }
.btn.magenta:hover { box-shadow: 0 6px 24px rgba(244, 114, 182, 0.28); }
.btn .ico { width: 17px; height: 17px; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 16px clamp(18px, 4vw, 40px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.topbar-title { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.topbar-right { margin-left: auto; }
.icon-btn {
  display: none; width: 38px; height: 38px; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.icon-btn .ico { width: 18px; height: 18px; }

.content { padding: clamp(22px, 4vw, 40px); max-width: 1200px; width: 100%; }
.section-lead { color: var(--muted); font-size: 14.5px; margin: 0 0 24px; }

/* Product grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card {
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer;
  text-align: left; padding: 0; font-family: inherit; color: inherit; display: flex; flex-direction: column;
  position: relative; transition: border-color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}
.card:hover { border-color: var(--line-h); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(4, 10, 20, 0.5), 0 0 0 1px rgba(34, 211, 238, 0.12); }
.card:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.thumb { aspect-ratio: 16 / 10; background: rgba(34, 211, 238, 0.06); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.noimg { font-family: "Space Grotesk", sans-serif; font-size: 44px; color: rgba(34, 211, 238, 0.35); }

.card-body { padding: 15px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.chip { align-self: flex-start; font-size: 11px; letter-spacing: 0.03em; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; }
.card-title { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 15.5px; margin: 0; }
.card-desc { color: var(--muted); font-size: 13px; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.badge-owned {
  position: absolute; top: 12px; right: 12px; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(7, 8, 15, 0.7); backdrop-filter: blur(4px); color: var(--cyan); font-weight: 600;
  font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid rgba(34, 211, 238, 0.45);
}
.badge-owned::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }

/* Empty / auth states */
.empty {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 48px 28px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 520px; margin: 8px auto;
  background: var(--panel-2);
}
.empty h2 { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 19px; margin: 0; }
.empty p { color: var(--muted); margin: 0; font-size: 14.5px; }
.empty .btn { width: auto; margin-top: 6px; }

/* Admin */
.admin-wrap { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.panel { background: var(--panel); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel h3 { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 16px; margin: 0 0 4px; }
.panel .hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input, .field select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  color: var(--text); font-family: inherit; font-size: 14px; width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--line-h); }
.result { margin-top: 12px; font-size: 13.5px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); white-space: pre-wrap; }
.result.ok { border-color: rgba(34, 211, 238, 0.4); color: var(--cyan); }
.result.err { border-color: rgba(244, 114, 182, 0.4); color: var(--magenta); }

/* Modal */
.modal-root { position: fixed; inset: 0; z-index: 50; display: none; }
.modal-root.open { display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 5, 11, 0.72); backdrop-filter: blur(6px); }
.modal {
  position: relative; max-width: 560px; width: 100%;
  background: rgba(15, 18, 30, 0.86); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line-h); border-radius: 18px; overflow: hidden;
  max-height: calc(100vh - 36px); display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(34, 211, 238, 0.08);
  animation: modalIn 0.16s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.modal-hero { aspect-ratio: 16 / 8; background: rgba(34, 211, 238, 0.06); overflow: hidden; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.modal-hero img { width: 100%; height: 100%; object-fit: cover; }
.modal-hero.noimg { font-family: "Space Grotesk", sans-serif; font-size: 60px; color: rgba(34, 211, 238, 0.35); }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; display: flex; align-items: center;
  justify-content: center; border-radius: 9px; background: rgba(7, 8, 15, 0.7); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.modal-close:hover { border-color: var(--line-h); }
.modal-body { padding: 22px 24px 24px; overflow-y: auto; }
.modal-chip { margin-bottom: 12px; }
.modal-title { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 22px; margin: 0 0 12px; letter-spacing: -0.01em; }
.modal-desc { color: #bcc6d6; font-size: 14.5px; white-space: pre-wrap; margin: 0 0 20px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }
.modal-actions .row2 { display: flex; gap: 10px; }
.modal-actions .row2 .btn { width: 100%; }

.filebox { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.filebox .lbl { font-size: 11.5px; color: var(--muted); }
.filebox code { font-family: "JetBrains Mono", monospace; font-size: 12.5px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 10px; word-break: break-all; }
.instr { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.instr summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted); }
.instr summary:hover { color: var(--text); }
.instr .txt { margin-top: 10px; font-size: 13.5px; color: var(--muted); white-space: pre-wrap; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 6px; }

/* Mobile */
.scrim { display: none; position: fixed; inset: 0; background: rgba(4, 5, 11, 0.6); z-index: 29; }
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform 0.2s ease; }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .scrim { display: block; }
  .icon-btn { display: inline-flex; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
