:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f2937;
  --bg-glass: rgba(17, 24, 39, 0.85);
  --bg-glass-card: rgba(31, 41, 55, 0.65);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(0, 174, 66, 0.4);
  --border-glow: rgba(0, 229, 255, 0.3);

  --accent-bambu: #00ae42;
  --accent-bambu-hover: #00c84c;
  --accent-cyan: #00f0ff;
  --accent-purple: #8b5cf6;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --text-sub: #6b7280;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  --shadow-glow: 0 0 25px rgba(0, 174, 66, 0.25);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(0, 174, 66, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 25%, rgba(0, 240, 255, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-bambu);
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  background: rgba(11, 15, 25, 0.8);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #00ae42, #00f0ff);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 174, 66, 0.35);
  color: #0b0f19;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(0, 174, 66, 0.15);
  color: #00f59b;
  border: 1px solid rgba(0, 174, 66, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.nav-btn.primary {
  background: linear-gradient(135deg, #00ae42, #008a34);
  border: none;
  color: #fff;
  box-shadow: 0 4px 15px rgba(0, 174, 66, 0.3);
}

.nav-btn.primary:hover {
  background: linear-gradient(135deg, #00c84c, #00a33e);
  box-shadow: 0 6px 20px rgba(0, 174, 66, 0.45);
}

/* Hero Section */
.hero-section {
  text-align: center;
  padding: 56px 0 36px;
}

.hero-title {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 14px;
  background: linear-gradient(180deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-title span {
  background: linear-gradient(135deg, #00f0ff, #00ae42);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto 36px;
}

/* Search Box Container */
.search-container {
  max-width: 820px;
  margin: 0 auto;
}

.input-glow-wrapper {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 3px;
  background: linear-gradient(135deg, rgba(0, 174, 66, 0.4), rgba(0, 240, 255, 0.3), rgba(139, 92, 246, 0.3));
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.7);
  transition: all 0.3s ease;
}

.input-glow-wrapper:focus-within {
  background: linear-gradient(135deg, #00ae42, #00f0ff, #8b5cf6);
  box-shadow: 0 12px 50px -5px rgba(0, 174, 66, 0.35);
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border-radius: 15px;
  padding: 6px 8px 6px 18px;
  gap: 12px;
}

.search-icon {
  color: var(--text-sub);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.url-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.98rem;
  font-family: inherit;
  padding: 10px 0;
  min-width: 0;
}

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

.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-action-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-action-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.btn-paste {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-paste:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-submit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #00ae42, #008a34);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(0, 174, 66, 0.3);
  flex-shrink: 0;
}

.btn-submit:hover {
  background: linear-gradient(135deg, #00c84c, #00a33e);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 174, 66, 0.45);
}

.btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Quick Example Chips */
.quick-chips {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.chip-label {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.chip-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.chip-item:hover {
  background: rgba(0, 174, 66, 0.12);
  border-color: rgba(0, 174, 66, 0.4);
  color: #00f59b;
}

/* Loading Spinner */
.loading-box {
  display: none;
  text-align: center;
  padding: 60px 0;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-bambu);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* Model Result Card */
.model-result-card {
  display: none;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-top: 36px;
  box-shadow: var(--shadow-card);
  animation: fadeIn 0.4s ease;
}

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

.model-header-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border-color);
}

@media (max-width: 768px) {
  .model-header-grid {
    grid-template-columns: 1fr;
  }
}

.model-cover-wrap {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 4/3;
  background: #000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  border: 1px solid var(--border-color);
}

.model-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.model-cover-wrap:hover .model-cover-img {
  transform: scale(1.03);
}

.region-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 9px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  color: #00f59b;
  border: 1px solid rgba(0, 174, 66, 0.4);
}

.model-info-wrap {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.model-meta-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.model-id-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
}

.model-title-text {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 12px;
  color: #fff;
}

.author-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  margin-bottom: 16px;
  width: fit-content;
}

.author-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.author-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.stat-item b {
  color: var(--text-main);
}

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

.model-actions-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

.btn-open-mw {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  transition: all 0.2s;
}

.btn-open-mw:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

/* Profiles Section */
.profiles-section-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profiles-subtext {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.profiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.profile-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.profile-card:hover {
  border-color: rgba(0, 174, 66, 0.4);
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
}

.profile-card.selected {
  border-color: #00ae42;
  background: linear-gradient(180deg, rgba(0, 174, 66, 0.08) 0%, rgba(17, 24, 39, 0.95) 100%);
  box-shadow: 0 0 25px rgba(0, 174, 66, 0.2);
}

.selected-ribbon {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #00ae42;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.profile-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #fff;
  line-height: 1.35;
}

.profile-specs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.spec-item {
  display: flex;
  flex-direction: column;
}

.spec-label {
  font-size: 0.72rem;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spec-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Filaments Swatch List */
.filaments-wrap {
  margin-bottom: 18px;
}

.filaments-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.filaments-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filament-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 4px 9px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.btn-download-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: linear-gradient(135deg, #00ae42, #008a34);
  color: #fff;
  border: none;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0, 174, 66, 0.25);
}

.btn-download-profile:hover {
  background: linear-gradient(135deg, #00c84c, #00a33e);
  box-shadow: 0 6px 18px rgba(0, 174, 66, 0.4);
}

.btn-download-profile:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.secondary-slicer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-slicer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-slicer:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-sub);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
}

/* Tabs */
.modal-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  color: #00f59b;
  border-bottom-color: #00ae42;
}

.tab-content {
  display: none;
  padding: 20px 0;
}

.tab-content.active {
  display: block;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

.form-input, .form-textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-textarea {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  resize: vertical;
}

.form-input:focus, .form-textarea:focus {
  border-color: #00ae42;
}

.guide-box {
  background: rgba(0, 174, 66, 0.08);
  border: 1px solid rgba(0, 174, 66, 0.25);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 18px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #d1fae5;
}

.guide-box ol {
  margin-left: 20px;
  margin-top: 6px;
}

.guide-box li {
  margin-bottom: 4px;
}

/* History List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 480px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  gap: 14px;
}

.history-item:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.hist-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.hist-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  background: #000;
  flex-shrink: 0;
}

.hist-meta {
  min-width: 0;
}

.hist-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-sub {
  font-size: 0.75rem;
  color: var(--text-sub);
}

.hist-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-bambu);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  color: #fff;
  font-size: 0.88rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 420px;
  animation: slideIn 0.3s ease;
}

.toast.error {
  border-left-color: var(--accent-red);
}

.toast.warning {
  border-left-color: var(--accent-amber);
}

@keyframes slideIn {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 40px 0;
  color: var(--text-sub);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: 80px;
}
