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

:root {
  --bg: #090b11;
  --bg2: #121624;
  --bg3: #1b2136;
  --border: #28304f;
  --border-focus: #4b5563;
  --accent: hsl(var(--hue, 250),85%,65%);
  --accent-hover: hsl(var(--hue, 250),80%,55%);
  --accent2: #f43f5e;
  --success: #10b981;
  --text: #f3f4f6;
  --text-dim: #9ca3af;
  --text-muted: #6b7280;
  
  /* Corner Rounding System (Proportional) */
  --radius: 12px;
  --radius-md: calc(var(--radius) - 4px);
  --radius-sm: calc(var(--radius) - 8px);
  
  --font: 'Inter', sans-serif;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  /* Disable global transitions for instant UI updates */
  --transition: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  background-image: radial-gradient(circle at top right, rgba(139, 92, 246, 0.08), transparent 450px),
                    radial-gradient(circle at bottom left, rgba(244, 63, 94, 0.03), transparent 400px);
}

.page { display: none; }
.page.active { display: block; }
.subpage { display: none; }
.subpage.active { display: block; }
.hidden { display: none !important; }

/* ---- AUTH ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
}

.brand { 
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.brand-logo {
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}
.brand-logo span { color: var(--accent); }
.brand-sub {
  font-size: 0.95rem;
  color: var(--text-dim);
  font-weight: 600;
  margin-top: 0.25rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.auth-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.35rem;
}
.tab {
  flex: 1;
  padding: 0.65rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.tab.active {
  color: var(--text);
  background: var(--bg2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.tab:hover:not(.active) { color: var(--text); }

.tab-panel {
  display: none;
  padding: 1.75rem 2rem;
  flex-direction: column;
  gap: 1rem;
  height: auto; /* Correct variable height to prevent bottom padding gaps */
}
.tab-panel.active { display: flex; }

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  margin: 0.25rem 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.divider::before { margin-right: .75em; }
.divider::after { margin-left: .75em; }

/* ---- INPUTS ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}
.form-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select, textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
  resize: vertical;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  background: rgba(27, 33, 54, 0.8);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }

/* ---- BUTTONS ---- */
.btn-primary {
  width: 100%;
  padding: 0.85rem 1.75rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary-sm {
  padding: 0.65rem 1.35rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary-sm:hover { background: var(--accent-hover); }

.btn-secondary {
  display: inline-block;
  padding: 0.65rem 1.35rem;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(139, 92, 246, 0.1);
}

.btn-danger {
  padding: 0.65rem 1.35rem;
  background: transparent;
  color: var(--accent2);
  border: 1px solid var(--accent2);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-danger:hover { background: var(--accent2); color: #fff; }

.btn-discord {
  width: 100%;
  padding: 0.85rem 1.75rem;
  background: #5865F2;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  transition: var(--transition);
}
.btn-discord:hover {
  background: #4752c4;
  transform: translateY(-1px);
}
.btn-discord svg {
  width: 20px;
  height: 20px;
}

.error-msg { color: var(--accent2); font-size: 0.85rem; min-height: 1.2em; font-weight: 500; }
.success-msg { color: var(--success); font-size: 0.85rem; min-height: 1.2em; font-weight: 500; }

/* ---- NAVBAR ---- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  background: rgba(18, 22, 36, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-left {
  display: flex;
  align-items: center;
  gap: 2.5rem;
}
.nav-brand {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-brand span { color: var(--accent); }
.nav-brand .nav-brand-sub {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-left: 1px solid var(--border);
  padding-left: 0.5rem;
  height: 1.2rem;
  display: flex;
  align-items: center;
}
.nav-links {
  display: flex;
  gap: 0.25rem;
}
.nav-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.5rem 1.1rem;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.nav-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
.nav-btn.active {
  color: var(--accent);
  background: rgba(139, 92, 246, 0.1);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
  .nav-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0.4rem;
    border-radius: 40px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    /* No transition for instant visual feedback */
    transition: none;
  }

/* Ensure brand logo text aligns vertically */
.brand-logo {
  display: inline-flex;
  align-items: baseline;
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}
.nav-avatar-wrap {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-avatar, .nav-avatar-placeholder {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.nav-avatar-placeholder {
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-avatar-placeholder::before {
  content: '';
  display: inline-block;
  width: 1rem;
  height: 1rem;
  background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-user"%3E%3Cpath d="M20 21v-2a4 4 0 0 0-3-3.87"/%3E%3Cpath d="M4 21v-2a4 4 0 0 1 3-3.87"/%3E%3Ccircle cx="12" cy="7" r="4"/%3E%3C/svg%3E') center/contain no-repeat;
}
.nav-username {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-logout:hover {
  border-color: var(--accent2);
  color: var(--accent2);
  background: rgba(244, 63, 94, 0.05);
}

/* ---- DASHBOARD PAGES ---- */
.subpage {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.subpage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}
.subpage-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.subpage-desc {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.filter-bar {
  display: flex;
  background: rgba(0, 0, 0, 0.15);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.filter-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.45rem 1rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.filter-btn:hover { color: var(--text); }
.filter-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ---- ASSET GRID & CARDS ---- */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}
.loading, .empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-dim);
  font-size: 1.1rem;
  font-weight: 500;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.01);
}

.asset-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  transition: var(--transition);
}
.asset-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.15);
}

.asset-thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-bottom: 1px solid var(--border);
}
.asset-thumb-placeholder {
  width: 100%;
  height: 160px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.asset-thumb-placeholder::before {
  content: '';
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-file"%3E%3Cpath d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/%3E%3Cpolyline points="14 2 14 8 20 8"/%3E%3C/svg%3E') center/contain no-repeat;
}

.asset-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.asset-type {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 50px;
  width: fit-content;
}
.asset-type.map { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.asset-type.model { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.asset-type.addon { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.asset-type.save { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.asset-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}
.asset-desc {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-bottom: 0.85rem;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.asset-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  font-weight: 500;
}

.asset-actions {
  display: flex;
  gap: 0.5rem;
}
.btn-insert {
  flex: 1;
  padding: 0.55rem 0.9rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-insert:hover { background: var(--accent-hover); }
.btn-insert.queued {
  background: var(--success);
}
.btn-edit {
  padding: 0.55rem 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-edit:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--text-dim); }

/* ---- FORMS & DROPAREA ---- */
.form-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow);
  height: auto; /* Correct variable height to prevent bottom padding gaps */
}

.profile-form {
  max-width: 500px;
}

.upload-method-tabs {
  display: flex;
  background: rgba(0,0,0,0.15);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
}
.upload-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 0.45rem 1rem;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.upload-tab:hover { color: var(--text); }
.upload-tab.active {
  background: var(--accent);
  color: #fff;
}

.file-drop {
  border: 2px dashed var(--border);
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.file-drop:hover, .file-drop.dragover {
  border-color: var(--accent);
  background: rgba(139, 92, 246, 0.03);
}
.file-drop input[type="file"] {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
  cursor: pointer;
}
.file-drop-icon {
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
}
.file-drop-text {
  font-size: 0.9rem;
  color: var(--text-dim);
}
.file-drop-link {
  color: var(--accent);
  font-weight: 600;
}
.file-selected {
  font-size: 0.85rem;
  color: var(--success);
  font-weight: 600;
  word-break: break-all;
  margin-top: 0.5rem;
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.progress-bar {
  background: var(--bg3);
  border-radius: 50px;
  height: 6px;
  overflow: hidden;
  width: 100%;
}
.progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}
#progress-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
}

/* ---- PROFILE SUBPAGE SPECIFICS ---- */
.avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 0.5rem;
}
.avatar-wrap {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--bg3);
  border: 2px solid var(--border);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-placeholder {
  font-size: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-placeholder::before {
  content: '👤';
}
.profile-email {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
}

/* ---- THEME CUSTOMIZER ---- */
.theme-customizer {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}
.theme-customizer label {
  margin-bottom: 0.25rem;
}
#theme-hue-val {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  margin-left: 0.5rem;
}
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  outline: none;
  padding: 0;
  border: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.hue-preview-bar {
  height: 8px;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  background: linear-gradient(to right, hsl(0,85%,65%), hsl(120,85%,65%), hsl(240,85%,65%));
  opacity: 0.85;
}

/* ---- MODAL ---- */
.modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 500px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
}
.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.75rem;
}
.thumb-preview-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  max-height: 150px;
}
.thumb-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
