/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Outfit:wght@400;600;700;800&display=swap');

/* CSS Variables for Premium Design System */
:root {
  --bg-color: #0b0f19;
  --card-bg: rgba(15, 23, 42, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #10b981;
  /* Emerald */
  --accent-secondary: #3b82f6;
  /* Blue */
  --accent-glow: rgba(16, 185, 129, 0.2);
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-lg: 20px;
  --radius-md: 12px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset & Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  padding: 2rem 1rem;
}

/* Background Mesh Glow Gradients */
body::before,
body::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.45;
  animation: pulse 10s infinite alternate;
}

body::before {
  background: radial-gradient(circle, var(--accent-primary) 0%, transparent 70%);
  top: -100px;
  right: -50px;
}

body::after {
  background: radial-gradient(circle, var(--accent-secondary) 0%, transparent 70%);
  bottom: -100px;
  left: -50px;
}

@keyframes pulse {
  0% {
    transform: scale(1) translate(0, 0);
  }

  100% {
    transform: scale(1.15) translate(20px, -20px);
  }
}

/* Main Container Layout */
.container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Typography */
h1 {
  font-family: var(--font-title);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  text-align: left;
  margin-bottom: 0.2rem;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-secondary) 70%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow-wrap: break-word;
  word-break: break-word;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Glassmorphic Card Style */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3),
    inset 0 1px 1px rgba(255, 255, 255, 0.05);
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
  opacity: 0.8;
}

/* ── Input Section ──────────────────────────────────────────────────────── */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Label row */
.input-label {
  font-family: var(--font-title);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-label span {
  color: rgba(100, 116, 139, 0.7);
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* Unified URL + Qty + Calc row */
.search-bar-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: stretch;
  width: 100%;
}

.url-input-container {
  display: flex;
  flex: 1;
  gap: 0;
  align-items: stretch;
  background: rgba(10, 15, 30, 0.7);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-md);
  transition: var(--transition-smooth);
  overflow: hidden;
}

.url-input-container:focus-within {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.url-field-wrapper {
  flex: 1;
  position: relative;
}

/* Divider between URL and qty */
.url-field-wrapper::after {
  content: '';
  position: absolute;
  right: 0;
  top: 20%;
  height: 60%;
  width: 1px;
  background: var(--card-border);
}

.url-input {
  width: 100%;
  height: 100%;
  padding: 1rem 1.125rem;
  font-family: var(--font-body);
  font-size: 0.925rem;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  transition: var(--transition-smooth);
}

.url-input::placeholder {
  color: var(--text-muted);
}

.url-input:focus {
  background: transparent;
}

/* Calculate: button beside the input row */
.submit-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0 1.5rem;
  background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-primary) 100%);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.18), 0 1px 4px rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  height: auto; /* Match height of container */
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.28), 0 2px 8px rgba(0, 0, 0, 0.3);
  filter: brightness(1.08);
}

.submit-btn:active {
  transform: translateY(0);
  filter: brightness(0.97);
}

@media (max-width: 600px) {
  .search-bar-wrapper {
    flex-direction: column;
  }
  .submit-btn {
    padding: 0.875rem 1.5rem;
  }
}

/* Loading Spinner Overlay */
.loading-overlay {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding: 2rem 0;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  border-top-color: var(--accent-primary);
  border-right-color: var(--accent-secondary);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--text-secondary);
  animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {

  0%,
  100% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }
}

/* Error Message */
.error-box {
  display: none;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.4;
  margin-top: 1rem;
}

/* Model Information Card (Hidden initially) */
.result-card {
  display: none;
  flex-direction: column;
  gap: 1.75rem;
  animation: slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.model-header {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.model-image-container {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: #1e293b;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.model-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-smooth);
}

.model-image-container:hover .model-image {
  transform: scale(1.06);
}

.model-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.model-title {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.model-profile {
  font-size: 0.85rem;
  color: var(--accent-secondary);
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  align-self: flex-start;
  font-weight: 500;
}

/* Grid for Statistics */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.stat-item {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: var(--transition-smooth);
}

.stat-item:hover {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-details {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Slider / Rate Customizer Block */
.calculator-controls {
  border-top: 1px solid var(--card-border);
  padding-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.controls-title {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.slider-label {
  color: var(--text-secondary);
}

/* Slider text box inputs & containers */
.slider-input-container {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.35rem;
  transition: var(--transition-smooth);
}

.slider-input-container:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.currency-prefix,
.currency-suffix {
  font-family: var(--font-title);
  color: var(--accent-primary);
  font-weight: 700;
  font-size: 0.85rem;
  user-select: none;
}

.slider-number-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.875rem;
  width: 48px;
  outline: none;
  padding: 0;
  margin: 0;
  text-align: right;
  -moz-appearance: textfield;
}

.slider-number-input::-webkit-outer-spin-button,
.slider-number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.custom-range {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 9999px;
  background: #1e293b;
  outline: none;
  transition: var(--transition-smooth);
}

.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 3px solid var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 0 10px var(--accent-glow);
  transition: var(--transition-smooth);
}

.custom-range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  background: var(--accent-primary);
  border-color: var(--text-primary);
}

/* Filament Color Swatches */
.filament-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.filament-section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.filament-section-title {
  font-family: var(--font-title);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filament-section-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.filament-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* Print Plates Breakdown */
.plates-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.plates-section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.plates-section-title {
  font-family: var(--font-title);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.plates-section-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.plates-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.plate-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  transition: var(--transition-smooth);
}

.plate-row:hover {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(255, 255, 255, 0.12);
}

.plate-thumbnail {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--card-border);
  background: #1e293b;
  flex-shrink: 0;
}

.plate-thumbnail-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--card-border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Color Selector Popover */
.color-picker-popover {
  position: absolute;
  background: #1e293b;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  padding: 0.75rem;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  z-index: 2000;
  width: 170px;
  animation: popover-fade-in 0.15s ease-out;
}

@keyframes popover-fade-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.color-preset-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.color-preset-btn:hover {
  transform: scale(1.15);
  border-color: var(--text-primary);
}

.plate-info {
  flex: 1;
  min-width: 0;
}

.plate-name {
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plate-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.plate-filaments {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.filament-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem 0.375rem 0.5rem;
  border-radius: 9999px;
  border: 1.5px solid var(--card-border);
  background: rgba(15, 23, 42, 0.5);
  cursor: pointer;
  transition: var(--transition-smooth);
  user-select: none;
}

.filament-pill:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.75);
}

.filament-pill.is-gold {
  border-color: rgba(234, 179, 8, 0.6);
  background: rgba(234, 179, 8, 0.08);
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.1);
}

.filament-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding: 0;
  cursor: pointer;
  background: none;
}

.filament-swatch::-webkit-color-swatch-wrapper {
  padding: 0;
}

.filament-swatch::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.filament-swatch::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.filament-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.filament-type {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
}

.filament-weight {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.filament-gold-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #eab308;
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
  letter-spacing: 0.04em;
  margin-left: 0.15rem;
}

/* Cost Calculation Result Card */
.cost-result-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(59, 130, 246, 0.08) 100%);
  border: 1px dashed rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.05);
}

.cost-label {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.final-cost {
  font-family: var(--font-title);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent-primary);
  text-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
  flex-shrink: 0;
}

/* Calculation breakdown — shown inside the settings modal */
.cost-formula-breakdown {
  display: none;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-style: italic;
}

.cost-formula-breakdown.has-data {
  display: block;
}

/* Cost & Share Section */
.cost-share-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--card-border);
}

/* Share Button — inline action */
.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: auto;
  padding: 0.75rem 1.25rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-title);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  letter-spacing: 0.01em;
}

.share-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.1);
  transform: translateY(-1px);
}

.share-btn:active {
  transform: translateY(0);
}

.share-btn.copied {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.06);
}

/* ── App Header ─────────────────────────────────────────────────────────── */
.app-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  overflow: hidden;
  padding: 0 0.25rem;
}

.header-main {
  flex: 0 1 auto;
  min-width: 0;
  text-align: left;
  overflow: hidden;
}

.header-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

/* Header Buttons */
.header-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: var(--transition-smooth);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  text-decoration: none;
  flex-shrink: 0;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  border-color: var(--accent-secondary);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
  transform: translateY(-1px);
}

#settings-toggle:hover {
  transform: rotate(45deg);
}

#history-link:hover {
  transform: translateY(-2px);
}

/* Settings Modal Drawer */
.settings-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.settings-modal-content {
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.05);
  animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.settings-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
}

.settings-modal-header h2 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 2rem;
  font-weight: 300;
  cursor: pointer;
  line-height: 1;
  transition: var(--transition-smooth);
}

.close-btn:hover {
  color: #ef4444;
}

/* Footer credit */
.footer-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 1rem;
}

.footer-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.footer-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* ── Responsive Breakpoints ──────────────────────────────────────────────── */

/* Tablet / Mid-size (≤ 680px) */
@media (max-width: 680px) {
  body {
    padding: 1.25rem 0.75rem;
    align-items: flex-start;
  }

  .container {
    gap: 1.25rem;
  }

  h1 {
    font-size: 1.9rem;
  }

  .card {
    padding: 1.5rem;
  }

  .settings-modal-content {
    max-width: 100%;
    padding: 1.5rem 1.25rem;
  }
}

/* Mobile (≤ 480px) */
@media (max-width: 480px) {
  body {
    padding: 1rem 0.5rem;
  }

  /* On mobile: header takes full width, actions float top-right absolutely */
  .app-header {
    position: relative;
    display: block;
  }

  /* Hide the centering spacer on mobile */
  .app-header::before {
    display: none;
  }

  .header-main {
    width: 100%;
    padding-right: 90px; /* leave room for 2 action buttons */
  }

  .header-actions {
    position: absolute;
    top: 0;
    right: 0;
    flex: none;
    min-width: unset;
  }

  h1 {
    font-size: 1.6rem;
    letter-spacing: -0.02em;
  }

  .subtitle {
    font-size: 0.8rem;
  }

  .card {
    padding: 1.25rem 1rem;
    border-radius: 16px;
  }

  /* Header — buttons shrink on mobile */
  .header-btn {
    width: 34px;
    height: 34px;
  }

  /* URL Input: on mobile qty stepper stays inline (no stacking needed) */
  .url-input-container {
    border-radius: 14px;
  }

  .url-field-wrapper {
    width: 100%;
  }

  .qty-btn {
    width: 30px;
  }

  .qty-selector .qty-input {
    width: 28px;
  }

  /* Model header */
  .model-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
  }

  .model-image-container {
    width: 140px;
    height: 140px;
  }

  .model-meta {
    width: 100%;
    align-items: center;
  }

  .model-title-container {
    justify-content: center;
  }

  .model-creator-badge {
    align-self: center;
  }

  .model-stats-row {
    justify-content: center;
  }

  /* Plate rows: stack thumb on top */
  .plate-row {
    flex-wrap: wrap;
    gap: 0.625rem;
    padding: 0.75rem;
  }

  .plate-thumbnail,
  .plate-thumbnail-placeholder {
    width: 100%;
    height: 120px;
    border-radius: 10px;
  }

  .plate-info {
    width: 100%;
  }

  .plate-filaments {
    width: 100%;
    flex-wrap: wrap;
  }

  /* Filament sections */
  .filament-section-header,
  .plates-section-header {
    flex-direction: column;
    gap: 0.15rem;
  }

  .filament-list {
    gap: 0.5rem;
  }

  /* Cost box */
  .cost-result-box {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
    padding: 1.25rem 1rem;
  }

  .final-cost {
    font-size: 2rem;
  }

  /* Share button */
  .share-btn {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }

  /* Settings modal: full-screen on small devices */
  .settings-modal {
    padding: 0;
    align-items: flex-end;
  }

  .settings-modal-content {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.5rem 1.25rem 2rem;
    animation: modal-slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  @keyframes modal-slide-up {
    from {
      opacity: 0;
      transform: translateY(30px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* History items */
  .history-item {
    padding: 0.6rem 0.75rem;
  }

  .history-item-thumb {
    width: 40px;
    height: 40px;
  }

  /* Cost formula */
  .cost-formula-breakdown {
    font-size: 0.75rem;
  }
}

/* ── Quantity Selector (inside unified url-input-container) ────────────── */
.qty-selector {
  display: flex;
  align-items: center;
  background: transparent;
  border: none;
  border-radius: 0;
  height: auto;
  transition: var(--transition-smooth);
  flex-shrink: 0;
  width: auto;
  overflow: visible;
  padding: 0 0.125rem;
}

.qty-selector:focus-within {
  box-shadow: none;
  background: transparent;
}

.qty-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 600;
  width: 34px;
  height: 100%;
  min-height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  user-select: none;
  border-radius: 0;
}

.qty-btn:hover {
  color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.08);
}

.qty-selector .qty-input {
  width: 36px;
  background: transparent;
  border: none;
  padding: 0;
  height: 100%;
  color: var(--text-primary);
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
}

.qty-selector .qty-input::-webkit-outer-spin-button,
.qty-selector .qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qty-selector .qty-input:focus {
  outline: none;
  box-shadow: none;
}

/* Qty label pill shown above the qty selector */
.qty-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  text-align: center;
  display: block;
  margin-bottom: 1px;
}

/* Bulk Discount Tip — inline, no border */
.bulk-discount-tip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  margin-top: 0;
}

.tip-icon {
  font-size: 0.8rem;
  opacity: 0.7;
}

.tip-text {
  font-size: 0.775rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-style: italic;
}

/* Cost Result Container & Savings Badge */
.cost-result-box-container {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: auto;
}

.savings-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #10b981;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.4rem 0.9rem;
  border-radius: 9999px;
  align-self: flex-end;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.05);
  animation: pulse-savings 2.5s infinite;
}

@keyframes pulse-savings {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.2);
  }

  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Extra Hardware Styling */
.hardware-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.hardware-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.hardware-title {
  font-family: var(--font-title);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hardware-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hardware-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  border: 1.5px solid rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.06);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  user-select: none;
}

.hardware-icon {
  font-size: 1rem;
}

.hardware-cost-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
  margin-left: 0.15rem;
}

.cost-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.1rem;
  font-style: italic;
}

/* New CSS for Refresh Button & Recent History */
.model-title-container {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.refresh-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.refresh-btn:hover {
  color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  transform: rotate(60deg) scale(1.08);
}

.refresh-btn:active {
  transform: scale(0.95);
}

.refresh-btn.spinning svg {
  animation: spin 1s linear infinite;
}

.history-card {
  padding: 1.5rem;
  margin-top: -0.5rem;
}

.history-card::before {
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

.history-title {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.history-title::before {
  content: '🕒';
  font-size: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.history-item:hover {
  background: rgba(15, 23, 42, 0.75);
  border-color: rgba(16, 185, 129, 0.4);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.05);
}

.history-item-thumb {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--card-border);
  background: #1e293b;
  flex-shrink: 0;
}

.history-item-details {
  flex: 1;
  min-width: 0;
}

.history-item-name {
  font-family: var(--font-body);
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

/* History Page Specific Styles */
.history-page-header {
  margin-bottom: 2rem;
  text-align: center;
}

.history-page-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-page-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  transition: var(--transition-smooth);
}

.history-page-item:hover {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(16, 185, 129, 0.25);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.05);
}

.history-page-item-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--card-border);
  background: #1e293b;
  flex-shrink: 0;
}

.history-page-item-info {
  flex: 1;
  min-width: 0;
}

.history-page-item-name {
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.history-page-item-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.history-page-item-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.history-page-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
}

.history-page-btn.load-btn:hover {
  color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
}

.history-page-btn.delete-btn {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.15);
}

.history-page-btn.delete-btn:hover {
  color: #ffffff;
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.4);
}

.no-history-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-style: italic;
  font-size: 0.9rem;
}

.back-btn-container {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

/* Creator Badge and Stats Styling */
.model-creator-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  align-self: flex-start;
  text-decoration: none;
  transition: var(--transition-smooth);
  margin-top: 0.25rem;
}

.model-creator-badge:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
}

.creator-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.model-stats-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.model-stats-row .stat-item {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.model-stats-row .stat-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.model-stats-row .stat-val {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.license-badge {
  font-size: 0.68rem;
  color: var(--accent-secondary);
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.18);
  padding: 0.125rem 0.45rem;
  border-radius: 4px;
  font-weight: 500;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ams-warning-badge {
  font-size: 0.68rem;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.18);
  padding: 0.125rem 0.45rem;
  border-radius: 4px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.rating-badge {
  font-size: 0.68rem;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.18);
  padding: 0.125rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
@media (max-width: 600px) {
  .cost-share-wrapper {
    flex-direction: column;
    align-items: stretch;
  }
  .share-btn {
    width: 100%;
  }
}

/* ── Light Mode Theme Overrides ─────────────────────────────────────────── */
[data-theme="light"] {
  --bg-color: #f1f5f9;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(0, 0, 0, 0.1);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-glow: rgba(16, 185, 129, 0.15);
}

[data-theme="light"] body::before,
[data-theme="light"] body::after {
  opacity: 0.25;
}

[data-theme="light"] h1 {
  background: linear-gradient(135deg, #0f172a 40%, var(--accent-secondary) 70%, var(--accent-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .url-input-container {
  background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .stat-item,
[data-theme="light"] .plate-row,
[data-theme="light"] .history-page-item,
[data-theme="light"] .filament-pill,
[data-theme="light"] .cost-share-wrapper {
  background: rgba(255, 255, 255, 0.6);
}

[data-theme="light"] .stat-item:hover,
[data-theme="light"] .plate-row:hover,
[data-theme="light"] .history-page-item:hover,
[data-theme="light"] .filament-pill:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .model-image-container,
[data-theme="light"] .plate-thumbnail,
[data-theme="light"] .color-picker-popover,
[data-theme="light"] .custom-range {
  background: #e2e8f0;
}

[data-theme="light"] .slider-input-container {
  background: rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .settings-modal-content {
  background: rgba(241, 245, 249, 0.95);
}

[data-theme="light"] .cost-result-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);
}

[data-theme="light"] .cost-formula-breakdown {
  background: rgba(16, 185, 129, 0.1);
}

[data-theme="light"] .header-btn,
[data-theme="light"] .share-btn,
[data-theme="light"] .history-page-btn {
  background: rgba(255, 255, 255, 0.6);
}

[data-theme="light"] .header-btn:hover,
[data-theme="light"] .share-btn:hover {
  background: rgba(255, 255, 255, 0.9);
}

/* Theme Toggle Button Logic */
#theme-toggle .sun-icon { display: none; }
#theme-toggle .moon-icon { display: block; }
[data-theme="light"] #theme-toggle .sun-icon { display: block; }
[data-theme="light"] #theme-toggle .moon-icon { display: none; }

/* ── Wide Container Layout for Directory/Leaderboard ─────────────────────── */
.container.wide-layout {
  max-width: 1000px;
}

/* ── Footer Logo & Directory Links Layout ─────────────────────────────────── */
.app-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.footer-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

.footer-logo-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.footer-nav-links {
  display: flex;
  gap: 1.25rem;
}

.footer-nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.footer-nav-links a:hover {
  color: var(--accent-primary);
}

.footer-bottom-credit {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Directory Search & Filters ────────────────────────────────────────── */
.directory-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 0.5rem;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.filter-select {
  padding: 0.75rem 1.5rem 0.75rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  min-width: 160px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

/* ── Product Grid & Cards ──────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

.product-card {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: var(--transition-smooth);
  cursor: pointer;
  height: 100%;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.4);
  border-color: rgba(16, 185, 129, 0.3);
}

.product-image-wrapper {
  width: 100%;
  aspect-ratio: 4/3;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition-smooth);
}

.product-card:hover .product-image {
  transform: scale(1.05);
}

.estimate-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(16, 185, 129, 0.95);
  color: #ffffff;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font-title);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  backdrop-filter: blur(4px);
  z-index: 2;
}

.product-info {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.product-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.8em;
}

.product-creator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.creator-avatar-img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
}

.creator-name-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.product-specs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.product-spec-tag {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.product-spec-tag svg {
  color: var(--text-muted);
}

/* ── Leaderboard Split Layout ────────────────────────────────────────────── */
.leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
  width: 100%;
}

@media (max-width: 768px) {
  .leaderboard-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
}

.leaderboard-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.leaderboard-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.leaderboard-title-row svg {
  color: var(--accent-primary);
}

.leaderboard-title-row h2 {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  padding: 0.75rem 1rem;
  transition: var(--transition-smooth);
  cursor: pointer;
}

.leaderboard-item:hover {
  transform: translateX(4px);
  border-color: rgba(16, 185, 129, 0.2);
}

.leaderboard-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 800;
  font-family: var(--font-title);
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.leaderboard-item:nth-child(1) .leaderboard-rank {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #0b0f19;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.leaderboard-item:nth-child(2) .leaderboard-rank {
  background: linear-gradient(135deg, #cbd5e1, #64748b);
  color: #0b0f19;
  box-shadow: 0 0 10px rgba(203, 213, 225, 0.3);
}

.leaderboard-item:nth-child(3) .leaderboard-rank {
  background: linear-gradient(135deg, #b45309, #78350f);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(180, 83, 9, 0.3);
}

.leaderboard-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
}

.leaderboard-item-details {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.leaderboard-item-name {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-item-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
}

.leaderboard-count-badge {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-primary);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: auto;
  white-space: nowrap;
}

/* Light Mode Overrides for Directory & Leaderboard */
[data-theme="light"] .search-input {
  background: rgba(255, 255, 255, 0.95);
}
[data-theme="light"] .filter-select {
  background-color: rgba(255, 255, 255, 0.95);
}
[data-theme="light"] .product-spec-tag {
  background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] .leaderboard-rank {
  background: rgba(0, 0, 0, 0.05);
}
[data-theme="light"] .leaderboard-count-badge {
  background: rgba(16, 185, 129, 0.08);
}

/* ── Responsive Overrides for Directory & Leaderboard ────────────────────── */
@media (max-width: 560px) {
  .directory-controls {
    flex-wrap: nowrap;
    gap: 0.5rem;
  }
  .search-wrapper {
    min-width: 0;
  }
  .filter-select {
    width: auto;
    max-width: 140px;
    padding: 0.75rem 1.25rem 0.75rem 0.5rem;
    font-size: 0.8rem;
    background-position: right 0.4rem center;
  }
  .footer-main-row {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
  }
  .footer-nav-links {
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
  }
}

@media (max-width: 600px) {
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .product-card {
    border-radius: 12px;
  }

  .product-info {
    padding: 0.75rem;
  }

  .product-title {
    font-size: 0.9rem;
    height: 2.6em; /* fits 2 lines */
    margin-bottom: 0.35rem;
  }

  .product-creator {
    margin-bottom: 0.5rem;
    gap: 0.3rem;
  }

  .creator-name-text {
    font-size: 0.75rem;
  }

  .creator-avatar-img {
    width: 14px;
    height: 14px;
  }

  .product-specs {
    gap: 0.35rem;
  }

  .product-spec-tag {
    padding: 0.15rem 0.35rem;
    font-size: 0.7rem;
    border-radius: 4px;
    gap: 0.15rem;
  }

  .estimate-badge {
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.25rem 0.45rem;
    font-size: 0.75rem;
    border-radius: 4px;
  }
}

/* ── Tab Layout & Buttons ────────────────────────────────────────────────── */
.tab-container {
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--card-border);
}

.tab-header {
  display: flex;
  gap: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* ── Upload Zone ─────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--card-border);
  border-radius: var(--radius-md);
  padding: 2.25rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.01);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent-primary);
  background: rgba(16, 185, 129, 0.04);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.05);
}

.upload-zone:hover .upload-icon, .upload-zone.dragover .upload-icon {
  color: var(--accent-primary) !important;
  transform: translateY(-2px);
}

.upload-icon {
  transition: var(--transition-smooth);
}

/* ── File Details Card & Stats Grid ──────────────────────────────────────── */
.file-details-card {
  animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.file-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.remove-file-btn:hover {
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.1) !important;
  transform: scale(1.1);
}

.file-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.file-stat-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: var(--transition-smooth);
}

.file-stat-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(59, 130, 246, 0.3);
}

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

.file-stat-value {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

/* Light theme overrides for Upload Zone */
[data-theme="light"] .upload-zone {
  background: rgba(0, 0, 0, 0.01);
}

[data-theme="light"] .upload-zone:hover, [data-theme="light"] .upload-zone.dragover {
  background: rgba(16, 185, 129, 0.06);
}

[data-theme="light"] .file-stat-item {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .file-stat-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

@media (max-width: 480px) {
  .file-stats-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

