:root {
  --blue: #0077c1;
  --blue-dark: #005991;
  --blue-light: #009dff;
  --green: #57b131;
  --yellow: #ffd64e;
  --orange: #eca816;
  --text: #2e3742;
  --text-muted: #697077;
  --bg: #f4f8fb;
  --white: #ffffff;
  --card-border: #d0dae0;
  --shadow: 0 8px 30px rgba(10, 20, 27, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Source Sans 3', system-ui, sans-serif;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }

.container {
  width: min(1200px, 92vw);
  margin: 0 auto;
}

/* Header */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  font-weight: 800;
  flex-shrink: 0;
}

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-light), var(--blue));
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 800;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.25rem;
  flex: 1;
  min-width: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.nav-link-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.btn-admin {
  background: var(--orange);
  color: white;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.auth-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem 0.25rem 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.user-chip img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.btn-roblox {
  background: #393b3d;
  color: white;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.45rem 0.75rem;
}

.btn-danger {
  background: #e74c3c;
  color: white;
  font-size: 0.8rem;
  padding: 0.35rem 0.7rem;
}

.nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.nav-link.active,
.nav-link:hover { color: var(--blue); }

/* Hero */
.hero {
  background: linear-gradient(180deg, #009dff 0%, #0077c1 55%, #005991 100%);
  color: white;
  padding: 4rem 0 5rem;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.15), transparent 50%);
}

.hero-inner { position: relative; z-index: 1; text-align: center; }

.eyebrow {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.85rem;
  opacity: 0.9;
  margin-bottom: 0.75rem;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.hero-sub {
  font-size: 1.15rem;
  max-width: 640px;
  margin: 0 auto 2rem;
  opacity: 0.95;
}

.hero-sub code {
  background: rgba(255,255,255,0.15);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  font-size: 0.95em;
}

.hero-search {
  display: flex;
  gap: 0.75rem;
  max-width: 560px;
  margin: 0 auto;
}

.hero-search input {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.25rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  box-shadow: var(--shadow);
}

.hero-wave {
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--bg);
  clip-path: ellipse(55% 100% at 50% 100%);
}

/* Stats */
.stats-bar {
  margin-top: -1.5rem;
  position: relative;
  z-index: 2;
  padding-bottom: 2rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  color: var(--blue);
  line-height: 1.2;
}

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

/* Main */
.main-content { padding: 1rem 0 4rem; }

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

.filters {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.category-filter-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.category-select {
  display: block;
  min-width: 11rem;
  padding: 0.55rem 2rem 0.55rem 0.85rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6b7a' d='M2 4l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  appearance: none;
}

.category-select:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.chip {
  border: 1px solid var(--card-border);
  background: var(--white);
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover,
.chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.25rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--green);
  color: white;
  box-shadow: 0 4px 14px rgba(87, 177, 49, 0.35);
}

.btn-secondary {
  background: var(--white);
  color: var(--blue);
  border: 2px solid var(--blue);
}

.btn-block { width: 100%; margin-top: 0.5rem; }

.btn-copy {
  background: var(--yellow);
  color: var(--text);
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
}

/* Grid */
.decal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.decal-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}

.decal-card:hover {
  box-shadow: 0 8px 28px rgba(10, 20, 27, 0.1);
}

.decal-thumb {
  aspect-ratio: 1;
  background: #e8eef3;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.decal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.decal-thumb .placeholder {
  font-size: 2.5rem;
  opacity: 0.3;
}

.card-texture {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem 0.75rem;
  background: #f4f7fa;
  border-top: 1px solid var(--card-border);
}

.card-texture-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.card-texture-id {
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  color: var(--text);
}

.card-texture .btn-copy-block {
  width: 100%;
  margin-top: 0.2rem;
}

.decal-info { padding: 0.75rem 1rem 1rem; }

.decal-info h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.decal-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.decal-category {
  display: inline-block;
  margin-top: 0.5rem;
  background: rgba(0, 119, 193, 0.1);
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.empty-state,
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-weight: 600;
}

.hidden { display: none !important; }

/* Modal */
.modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
}

.modal::backdrop {
  background: rgba(10, 20, 27, 0.55);
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius);
  margin: 5vh auto;
  width: min(720px, 92vw);
  max-height: 90vh;
  overflow: auto;
  position: relative;
  box-shadow: var(--shadow);
}

.modal-card-sm { width: min(440px, 92vw); padding: 1.5rem; }

.modal-card-wide { width: min(900px, 92vw); padding: 1.5rem; }

.admin-body { margin-top: 1rem; }

.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.5rem;
}

.admin-tab {
  background: none;
  border: none;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.admin-tab:hover { color: var(--blue-dark); }

.admin-tab.active {
  color: var(--blue-dark);
  background: #e8f2fa;
}

.admin-panel { margin-top: 1rem; }

.scraper-label {
  display: block;
  margin-bottom: 1rem;
}

.scraper-label textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font: inherit;
  resize: vertical;
  min-height: 8rem;
}

.scraper-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.scraper-options label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.scraper-options input[type="number"],
.scraper-options input[type="text"] {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font: inherit;
}

.scraper-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.scraper-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.scraper-log {
  max-height: 240px;
  overflow-y: auto;
}

.admin-section { margin-bottom: 1.5rem; }

.admin-section h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--blue-dark);
}

.contributor-card {
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

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

.contributor-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.contributor-actions a {
  font-size: 0.85rem;
  color: var(--blue);
  text-decoration: none;
}

.contributor-actions a:hover { text-decoration: underline; }

.contributor-banned {
  border-color: #f5c6cb;
  background: #fff8f8;
}

.ban-badge,
.admin-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  vertical-align: middle;
}

.ban-badge {
  background: #fde8e8;
  color: #b42318;
}

.ban-notice {
  color: #b42318;
  font-weight: 600;
}

.admin-badge {
  background: #e8f2fa;
  color: var(--blue-dark);
}

.contributor-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.admin-decal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--card-border);
  font-size: 0.9rem;
}

.admin-decal-row:first-of-type { border-top: none; }

.admin-decal-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.admin-decal-info img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: #e8eef3;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: none;
  background: var(--bg);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  z-index: 2;
}

.modal-body { padding: 1.5rem; }

.modal-detail {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
}

.modal-detail img {
  width: 100%;
  border-radius: var(--radius-sm);
  background: #e8eef3;
}

.modal-preview {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.preview-texture {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  background: var(--card-bg, #f8fafc);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
}

.preview-texture-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.preview-texture-id {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--text);
}

.btn-copy-block {
  width: 100%;
  margin-top: 0.25rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 0.9rem;
}

.detail-row strong { color: var(--text-muted); font-weight: 600; }

.detail-row code {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  word-break: break-all;
}

.modal-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 1rem;
}

.add-modal-card { padding: 1.5rem; }

.add-tabs {
  display: flex;
  gap: 0.35rem;
  margin: 1rem 0;
  padding: 0.25rem;
  background: #eef2f6;
  border-radius: var(--radius-sm);
}

.add-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.add-tab.active {
  background: var(--white);
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(10, 20, 27, 0.08);
}

.add-tab-panel.hidden { display: none; }

.catalog-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.catalog-search input {
  flex: 1;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.catalog-meta-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.catalog-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.65rem;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
}

.catalog-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s, opacity 0.15s;
}

.catalog-item:hover:not(:disabled) {
  border-color: var(--blue);
}

.catalog-item:disabled,
.catalog-item-added {
  opacity: 0.55;
  cursor: default;
}

.catalog-item-unsupported {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.catalog-item-thumb {
  aspect-ratio: 1;
  background: #e8eef3;
  border-radius: 4px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.catalog-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalog-item-name {
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-item-id {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}

.import-log {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  max-height: 160px;
  overflow-y: auto;
  font-size: 0.82rem;
}

.import-log li {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--card-border);
}

.import-log li.ok { color: #1e7e34; }
.import-log li.err { color: #c0392b; }

.modal-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

form label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

form input,
form select.category-select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
}

form select.category-select {
  padding-right: 2rem;
  background-position: right 0.75rem center;
  cursor: pointer;
}

.label-hint { font-weight: 400; color: var(--text-muted); }

.form-error {
  color: #c0392b;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* Footer */
.site-footer {
  background: #0a141b;
  color: rgba(255,255,255,0.75);
  padding: 2rem 0;
  text-align: center;
}

.footer-inner p { margin-bottom: 0.35rem; }

.footer-meta a { color: var(--blue-light); }

@media (max-width: 640px) {
  .hero-search { flex-direction: column; }
  .modal-detail { grid-template-columns: 1fr; }
  .header-inner { flex-wrap: wrap; }
  .nav {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .nav-actions { margin-left: auto; }
}
