*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #386e44;
  --primary-dark: #2d5a37;
  --primary-light: #eef4ef;
  --primary-glow: rgba(56, 110, 68, 0.22);
  --accent-black: #030303;
  --surface: #ffffff;
  --surface-2: #f8faf8;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e5e7eb;
  --shadow-sm: 0 1px 2px rgba(3, 3, 3, 0.04);
  --shadow-md: 0 8px 30px rgba(3, 3, 3, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --pro: #2d5a37;
  --pro-bg: #e8f0ea;
  --free: #386e44;
  --free-bg: #eef4ef;
  --header-h: 72px;
  --dev-banner-h: 36px;
  --sidebar-w: 240px;
  --page-max: 1440px;
}

html {
  font-size: 15px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  background: #fff;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.has-site-footer {
  display: flex;
  flex-direction: column;
}

body.has-site-footer > .site-header,
body.has-site-footer > .page-wrap,
body.has-site-footer > .cart-page-wrap,
body.has-site-footer > .admin-wrap,
body.has-site-footer > .feed-page-wrap,
body.has-site-footer > .checkout-wrap,
body.has-site-footer > .detail-wrap,
body.has-site-footer > .account-page-wrap,
body.has-site-footer > main {
  flex-shrink: 0;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: #fafafa;
}

/* ─── Dev banner ─── */
.dev-banner {
  position: sticky;
  top: 0;
  z-index: 210;
  width: 100%;
  min-height: var(--dev-banner-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 20px;
  background: linear-gradient(90deg, #2d5a37 0%, #386e44 50%, #2d5a37 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-align: center;
  box-shadow: 0 2px 8px rgba(45, 90, 55, 0.25);
}

.dev-banner-label {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.06em;
  opacity: 0.95;
}

.dev-banner-sep {
  opacity: 0.5;
  font-weight: 400;
}

.dev-banner-date {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

body.has-dev-banner .site-header {
  top: var(--dev-banner-h);
}

body.has-dev-banner .feed-sidebar {
  top: calc(var(--header-h) + var(--dev-banner-h) + 20px);
}

body.has-dev-banner .account-sidebar {
  top: calc(var(--header-h) + var(--dev-banner-h) + 20px);
}

body.has-dev-banner .admin-list {
  max-height: calc(100vh - var(--header-h) - var(--dev-banner-h) - 120px);
}

/* ─── Header ─── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--page-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex-shrink: 0;
  color: var(--accent-black);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.logo-text {
  letter-spacing: -0.03em;
}

.top-nav {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.top-nav a {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  transition: color 0.15s;
}

.top-nav a:hover {
  color: var(--accent-black);
  background: transparent;
}

.top-nav a.active {
  color: var(--accent-black);
  background: transparent;
  font-weight: 600;
  box-shadow: inset 0 -2px 0 var(--primary);
}

.header-search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  transition: border-color 0.15s;
}

.header-search:focus-within {
  border-color: var(--primary);
  box-shadow: none;
  background: var(--surface);
}

.header-search svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.header-search .search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: white;
  background: var(--primary);
  border-radius: 0;
  transition: background 0.15s;
}

.btn-upload:hover {
  background: var(--primary-dark);
}

.btn-login {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent-black);
  border: 1px solid var(--accent-black);
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-login:hover {
  background: var(--accent-black);
  color: white;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 4px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  transition: box-shadow 0.15s;
}

.user-chip:hover {
  box-shadow: var(--shadow-sm);
}

.user-chip img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.user-chip span {
  font-size: 13px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Page layout ─── */
.page-wrap {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 28px 32px 48px;
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-radius: 0;
  border: 1px solid var(--border);
  padding: 20px 16px;
  box-shadow: none;
  position: sticky;
  top: calc(var(--header-h) + 20px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 16px 8px 10px;
}

.sidebar-title:first-child {
  margin-top: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: var(--surface-2);
  color: var(--primary);
}

.sidebar-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 8px;
}

.filter-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.filter-check input {
  accent-color: var(--primary);
}

.sidebar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 8px;
}

.tag-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.tag-btn:hover,
.tag-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.main-content {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

#home-sections,
.model-grid {
  width: 100%;
  max-width: 100%;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 20px;
}

.main-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent-black);
  margin-bottom: 6px;
}

.main-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

.segment-tabs {
  display: flex;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0;
  gap: 0;
  flex-shrink: 0;
}

.segment-tab {
  padding: 10px 22px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-radius: 0;
  transition: all 0.2s;
  white-space: nowrap;
  border-right: 1px solid var(--border);
}

.segment-tab:last-child {
  border-right: none;
}

.segment-tab:hover:not(.active) {
  color: var(--accent-black);
  background: var(--surface-2);
}

.segment-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: none;
}

.toolbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.results-count {
  font-size: 14px;
  color: var(--text-muted);
}

.results-count strong {
  color: var(--text);
  font-weight: 600;
}

.sort-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.sort-select select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}

.sort-select select:focus {
  border-color: var(--primary);
}

/* ─── Model grid (desktop cards) ─── */
.model-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.model-card {
  background: var(--surface);
  border-radius: 0;
  border: none;
  overflow: hidden;
  transition: opacity 0.2s;
  display: flex;
  flex-direction: column;
  color: inherit;
  height: 100%;
  min-width: 0;
}

.model-card-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  color: inherit;
}

.model-card-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px 0 0;
  margin-top: auto;
}

.btn-card-buy {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: white;
  background: var(--accent-black);
  border-radius: 0;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-card-buy:hover:not(:disabled) {
  background: var(--primary);
}

.btn-card-buy.owned,
.btn-card-buy[data-download-id] {
  background: var(--primary);
}

.btn-card-buy.owned:hover,
.btn-card-buy[data-download-id]:hover {
  background: var(--primary-dark);
}

.btn-card-buy:disabled {
  background: var(--primary);
  cursor: default;
}

.model-card:hover {
  opacity: 0.92;
}

.model-card-image {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #f5f5f5;
}

.model-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.model-card:hover .model-card-image img {
  transform: scale(1.03);
}

.model-card-fav {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.model-card:hover .model-card-fav {
  opacity: 1;
}

.model-card-fav.liked {
  opacity: 1;
  color: #ef4444;
}

.model-card-body {
  padding: 14px 0 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.model-card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 6px;
  min-height: calc(1.4em * 2);
  color: var(--accent-black);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.model-card-meta {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0 0 10px;
  min-height: 1.5em;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.model-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 10px;
  border-top: none;
}

.model-card-price {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-black);
}

.model-card-price.free {
  color: var(--primary);
}

.badge-pro,
.badge-free {
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-pro {
  background: var(--pro-bg);
  color: var(--pro);
}

.badge-free {
  background: var(--free-bg);
  color: var(--free);
}

/* List card fallback (related on model page) */
.model-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.model-list-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.model-list-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.model-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
}

.model-list-body {
  padding: 12px 14px 14px;
}

.model-list-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-list-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.model-list-badges {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.badge-format {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
}

.model-chevron {
  display: none;
}

/* ─── Buttons ─── */
.btn-primary {
  background: var(--primary);
  color: white;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 12px 24px;
  border-radius: 0;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent-black);
  background: var(--surface);
  border: 1px solid var(--accent-black);
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
}

.btn-outline:hover {
  border-color: var(--accent-black);
  background: var(--accent-black);
  color: #fff;
}

.btn-full {
  width: 100%;
}

/* Hide mobile-only */
.bottom-nav,
.fab,
.page-header,
.glass-search,
.category-chips,
.header-avatar-wrap,
.header-login-btn {
  display: none !important;
}

/* Wider screens */
@media (min-width: 1400px) {
  .model-grid,
  .model-list {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* Tablet */
@media (max-width: 1023px) {
  .model-grid,
  .model-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .page-wrap {
    padding: 20px;
  }

  .header-inner {
    padding: 0 20px;
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-h);
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .top-nav {
    display: none;
  }
}

/* Mobile */
@media (max-width: 768px) {
  :root {
    --header-h: auto;
  }

  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'logo actions'
      'search search';
    gap: 10px 8px;
    padding: 10px 16px;
    align-items: center;
  }

  .logo {
    grid-area: logo;
    font-size: 20px;
  }

  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 10px;
  }

  .header-search {
    grid-area: search;
    max-width: none;
    width: 100%;
    padding: 9px 14px;
  }

  .header-actions {
    grid-area: actions;
    margin-left: 0;
    gap: 4px;
  }

  .top-nav {
    display: none;
  }

  .btn-upload {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    overflow: hidden;
    font-size: 0;
    border-radius: var(--radius-sm);
  }

  .btn-upload svg {
    flex-shrink: 0;
  }

  .btn-login {
    padding: 8px 12px;
    font-size: 13px;
  }

  .user-chip span {
    display: none;
  }

  .user-chip {
    padding: 4px;
  }

  .page-wrap {
    flex-direction: column;
    padding: 12px 16px 80px;
    gap: 16px;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  .main-content {
    order: 1;
  }

  .sidebar {
    order: 2;
    width: 100%;
    position: static;
    max-height: none;
    padding: 14px 12px;
  }

  .sidebar-title {
    margin: 12px 4px 8px;
  }

  .sidebar-title:first-child {
    margin-top: 0;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .sidebar-link {
    width: auto;
    padding: 7px 12px;
    font-size: 13px;
    background: var(--surface-2);
  }

  .sidebar-link.active {
    background: var(--primary-light);
  }

  .sidebar-filters,
  .sidebar-tags {
    display: none;
  }

  .main-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 14px;
  }

  .main-title {
    font-size: 22px;
  }

  .main-subtitle {
    font-size: 13px;
  }

  .segment-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .segment-tabs::-webkit-scrollbar {
    display: none;
  }

  .segment-tab {
    padding: 8px 16px;
    font-size: 13px;
  }

  .toolbar-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 14px;
  }

  .sort-select {
    width: 100%;
    justify-content: space-between;
  }

  .sort-select select {
    flex: 1;
  }

  .model-grid,
  .model-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .model-card-actions {
    padding-top: 6px;
  }

  .model-card-title {
    font-size: 13px;
  }

  .account-page-wrap {
    padding: 12px 16px 80px;
  }
}

@media (max-width: 480px) {
  .model-grid,
  .model-list {
    grid-template-columns: 1fr;
  }

  .header-actions .icon-btn:nth-child(1) {
    display: none;
  }

  .segment-tab {
    padding: 8px 14px;
    font-size: 12px;
  }
}
