:root {
  --bg: #000;
  --bg-soft: #0a0a0a;
  --surface: #111;
  --surface-hover: #1a1a1a;
  --border: #222;
  --text: #fff;
  --text-muted: #999;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,0.6);
  --maxw: 1160px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: #000;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

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

/* ======================== Navbar ======================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav-link:hover { color: #fff; background: var(--surface); }
.nav-link.active { color: #fff; background: var(--surface); }
.nav-cta {
  background: #fff;
  color: #000 !important;
  font-weight: 600;
  margin-left: 4px;
}
.nav-cta:hover { background: #e5e5e5; }
.auth-nav { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  margin-right: 4px;
}
.nav-user svg { width: 15px; height: 15px; }
button.nav-link {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

/* ======================== Layout ======================== */
main.container {
  flex: 1;
  padding-top: 36px;
  padding-bottom: 64px;
}
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 6px; font-size: 1.85rem; letter-spacing: -0.03em; font-weight: 700; }
.page-head p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

/* ======================== Toolbar / Search ======================== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.search-wrap {
  flex: 1 1 260px;
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 11px 14px 11px 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}
.search-input:focus { border-color: #555; }
.search-input::placeholder { color: #555; }

/* ======================== Tags ======================== */
.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}
.chip {
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}
.chip:hover { color: #fff; border-color: #555; }
.chip.active {
  background: #fff;
  color: #000;
  border-color: #fff;
  font-weight: 600;
}

/* ======================== Sidebar / Engine tabs ======================== */
.browse-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 28px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 72px;
}
.sidebar-title {
  margin: 0 0 10px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #666;
  font-weight: 600;
}
.engine-tabs { display: flex; flex-direction: column; gap: 4px; }
.engine-tab {
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}
.engine-tab:hover { color: #fff; background: var(--surface); }
.engine-tab.active { background: #fff; color: #000; font-weight: 600; }

/* Card engine badge */
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-top .card-icon { margin-bottom: 0; }
.engine-badge {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #333;
  color: #ccc;
}

/* ======================== Grid ======================== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.card:hover {
  border-color: #444;
  background: var(--surface-hover);
  transform: translateY(-2px);
}
.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  margin-bottom: 14px;
}
.card h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
}
.card .desc {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.88rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  line-height: 1.5;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.76rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag-pill {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: #1a1a1a;
  color: #aaa;
  font-weight: 500;
}
.unity-badge {
  margin-top: 10px;
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 6px;
  background: #fff;
  color: #000;
  font-weight: 700;
  display: inline-block;
  letter-spacing: -0.01em;
}

/* ======================== Buttons ======================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s ease;
}
.btn:hover { border-color: #555; background: var(--surface-hover); }
.btn-primary {
  background: #fff;
  border: none;
  color: #000;
  font-weight: 700;
}
.btn-primary:hover { background: #e5e5e5; }
.btn-danger {
  border-color: #444;
  color: #bbb;
  font-weight: 600;
}
.btn-danger:hover { border-color: #888; color: #fff; background: #1a1a1a; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ======================== Forms ======================== */
.form-card {
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.field { margin-bottom: 18px; }
.field label {
  display: block;
  margin-bottom: 7px;
  font-weight: 600;
  font-size: 0.88rem;
}
.field .hint { color: #666; font-size: 0.8rem; margin-top: 5px; }
input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #080808;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}
input:focus, textarea:focus, select:focus { border-color: #555; }
input::placeholder, textarea::placeholder { color: #444; }
textarea { resize: vertical; min-height: 96px; }
select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  padding-right: 40px;
}
select option { background: #111; color: #fff; }

.dropzone {
  border: 1.5px dashed #333;
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  background: #080808;
}
.dropzone:hover, .dropzone.dragover { border-color: #666; color: #fff; }
.dropzone .dz-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.dropzone strong { color: #fff; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.82rem;
}

/* ======================== Progress ======================== */
.progress-wrap { display: none; margin-top: 20px; }
.progress-wrap.visible { display: block; }
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.progress-track {
  height: 6px;
  border-radius: 999px;
  background: #1a1a1a;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 999px;
  transition: width 0.2s ease;
}

/* ======================== Alerts ======================== */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  margin: 16px 0;
}
.alert-error { background: #111; border: 1px solid #333; color: #e5e5e5; }
.alert-success { background: #111; border: 1px solid #333; color: #fff; }
.alert-info { background: #111; border: 1px solid #333; color: #ccc; }

/* ======================== Storage meter ======================== */
.storage-meter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 22px;
}
.storage-meter .storage-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.storage-meter .storage-head strong { color: #fff; }
.storage-track { height: 6px; border-radius: 999px; background: #1a1a1a; overflow: hidden; }
.storage-fill { height: 100%; background: #fff; border-radius: 999px; transition: width 0.3s ease; }
.storage-fill.warn { background: #888; }

/* ======================== Detail page ======================== */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.detail-card h1 { margin: 0 0 10px; font-size: 1.65rem; letter-spacing: -0.03em; font-weight: 700; }
.detail-desc { color: var(--text-muted); white-space: pre-wrap; margin-bottom: 20px; line-height: 1.6; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.auth-card { max-width: 420px; }
.form-alt { margin: 16px 0 0; text-align: center; color: var(--text-muted); font-size: 0.88rem; }
.form-alt a { color: #fff; text-decoration: underline; }
.manage-panel {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}
.manage-panel h3 { margin: 0 0 16px; font-size: 1.05rem; font-weight: 700; }
.manage-panel h4 { margin: 0 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: #888; }
.collab-section { margin: 20px 0; }
.collab-list { list-style: none; margin: 12px 0 0; padding: 0; }
.collab-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 0.88rem;
}
.collab-item svg { width: 15px; height: 15px; color: var(--text-muted); }
.collab-add { display: flex; gap: 8px; }
.collab-add input { flex: 1; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

/* Mode toggle (ZIP vs External) */
.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.mode-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s ease;
  border-right: 1px solid var(--border);
  user-select: none;
}
.mode-option:last-child { border-right: none; }
.mode-option svg { width: 18px; height: 18px; }
.mode-option.active {
  background: #fff;
  color: #000;
  font-weight: 600;
}
.mode-option input { display: none; }

/* Media upload / display */
.media-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed #333;
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s ease;
  background: #080808;
}
.media-dropzone:hover, .media-dropzone.dragover { border-color: #666; color: #fff; }
.media-add-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: #1a1a1a;
  display: grid; place-items: center;
  font-size: 1.3rem; font-weight: 300;
  color: #888;
  margin-bottom: 8px;
}
.media-dropzone:hover .media-add-icon, .media-dropzone.dragover .media-add-icon { background: #fff; color: #000; }
.media-previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.media-thumb {
  position: relative;
  width: 100px; height: 100px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb-video { width: 180px; }
.media-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.75);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  display: grid; place-items: center;
  line-height: 1;
}
.detail-thumb { margin-bottom: 16px; }
.detail-thumb img { max-width: 100%; max-height: 360px; border-radius: var(--radius); border: 1px solid var(--border); object-fit: contain; }
.detail-screenshots {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.detail-screenshots img {
  height: 180px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  transition: opacity 0.15s;
}
.detail-screenshots img:hover { opacity: 0.85; }
.detail-video { margin-bottom: 16px; }
.detail-video video { max-width: 100%; max-height: 400px; border-radius: var(--radius); border: 1px solid var(--border); background: #000; }
.replace-section { margin: 16px 0; }
.replace-section h4 { margin: 0 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: #888; }
.dev-badge {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  background: #1a1a1a;
  color: #888;
  vertical-align: middle;
  margin-left: 6px;
  line-height: 1.4;
}
.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin: 22px 0;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.meta-item .meta-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin-bottom: 3px;
  font-weight: 600;
}
.meta-item .meta-value { font-weight: 600; font-size: 0.92rem; }
.back-link { display: inline-block; margin-top: 20px; color: var(--text-muted); font-size: 0.88rem; }
.back-link:hover { color: #fff; }

/* ======================== Empty / Loading ======================== */
.empty-state {
  text-align: center;
  padding: 72px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; display: block; margin-bottom: 12px; }
.empty-state h2 { color: #fff; margin: 0 0 6px; font-size: 1.2rem; }
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 0;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid #222;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======================== Footer ======================== */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  color: #555;
  font-size: 0.82rem;
}
.footer p { margin: 0; }
.footer code { color: #aaa; }

/* ======================== Responsive ======================== */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .page-head h1 { font-size: 1.4rem; }
  .nav-inner { height: 50px; }
  .brand span { display: none; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .detail-card, .form-card { padding: 20px; }
  .detail-meta { grid-template-columns: 1fr 1fr; }
}

/* ======================== Icons ======================== */
.card-icon { color: #000; }
.card-icon svg { width: 20px; height: 20px; }
.empty-icon { color: #fff; }
.empty-icon svg { width: 44px; height: 44px; }
.dz-icon svg { width: 34px; height: 34px; }
.file-chip svg { width: 16px; height: 16px; flex-shrink: 0; }
.card-meta svg { width: 13px; height: 13px; flex-shrink: 0; }
.meta-value { display: inline-flex; align-items: center; gap: 7px; }
.meta-value svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.brand svg { width: 22px; height: 22px; flex-shrink: 0; }
.detail-card h1 { display: flex; align-items: center; gap: 10px; }
.detail-card h1 svg { width: 26px; height: 26px; flex-shrink: 0; }

@media (max-width: 860px) {
  .browse-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .engine-tabs { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .engine-tab { text-align: center; }
}
