:root {
  --bg: #090d14;
  --bg-2: #0f1624;
  --card: rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover: rgba(255, 255, 255, 0.08);
  --accent: #63f29c;
  --accent-2: #6ec3ff;
  --text: #e9eef7;
  --muted: #8ca0bf;
  --danger: #f28c8c;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

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

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 20%, #10182a, #060a10 45%),
    radial-gradient(circle at 80% 10%, #0d1a30, #060a10 40%),
    linear-gradient(160deg, #0e1a2c, #060a10);
  color: var(--text);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.2rem;
  background: rgba(10, 15, 25, 0.85);
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 200;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.02em;
}

.search-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

#resultsInfo {
  font-size: 0.95rem;
  color: var(--muted);
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 10px;
}

.search-controls input,
.search-controls select {
  padding: 0.5rem 0.75rem;
  background: rgba(20, 26, 38, 0.9);
  color: var(--text);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
}

.search-controls select option {
  background: #0e1a2c;
  color: var(--text);
}

.search-controls input:focus,
.search-controls select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 242, 156, 0.12);
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

#searchInput {
  width: 100%;
  padding-right: 2.25rem;
}

.clear-btn {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  max-width: 28px;
  max-height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1;
  box-shadow: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.clear-btn:hover,
.clear-btn:active {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
  box-shadow: none;
  outline: none;
}

.search-controls button:not(.clear-btn) {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #05101e;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 30px rgba(99, 242, 156, 0.25);
}

.search-controls button:not(.clear-btn):hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 34px rgba(110, 195, 255, 0.35);
}

.search-controls button:not(.clear-btn):active {
  transform: translateY(0);
}

.settings {
  position: relative;
}

.profile-menu {
  margin-left: auto;
}

.settings-btn {
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.profile-btn {
  padding: 0.5rem 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  height: auto;
  min-height: 40px;
}

.profile-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

.settings-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(99, 242, 156, 0.2);
}

.settings-menu {
  position: absolute;
  right: 0;
  top: 110%;
  background: rgba(12, 18, 30, 0.95);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.35rem;
  padding: 0.5rem;
  min-width: 200px;
  z-index: 300;
}

.settings-menu button {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border 0.2s ease, background 0.2s ease;
}

.settings-menu button:hover {
  border-color: var(--accent);
  background: rgba(99, 242, 156, 0.12);
}

.settings-menu .logout-btn {
  border-color: rgba(242, 140, 140, 0.6);
  color: var(--danger);
}

.settings-menu .logout-btn:hover {
  background: rgba(242, 140, 140, 0.12);
  border-color: var(--danger);
}

.muted {
  color: var(--muted);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 20%, #10182a, #060a10 45%),
    radial-gradient(circle at 80% 10%, #0d1a30, #060a10 40%),
    linear-gradient(160deg, #0e1a2c, #060a10);
}

.login-card {
  background: rgba(12, 18, 30, 0.9);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  color: var(--text);
  min-width: 320px;
  display: grid;
  gap: 0.6rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.login-card label {
  font-weight: 600;
  color: var(--muted);
}

.login-card input {
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.login-card button {
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #05101e;
  cursor: pointer;
  font-weight: 700;
}

/* Tile Generator */
.tile-modal {
  width: 520px;
  max-width: 94vw;
  max-height: 90vh;
  overflow: auto;
}

.tile-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: 0.5rem;
}

.tile-preview {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
}

.tile-preview-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
}

.tile-preview-canvas {
  position: relative;
  min-height: 220px;
  height: auto;
  flex: 1 1 auto;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border-radius: 10px;
  overflow: hidden;
}

#tilePreviewCanvas {
  width: 100%;
  height: 100%;
  min-height: 220px;
  display: block;
}

#tilePreviewSpinner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
  background: rgba(6, 10, 16, 0.4);
}

.small {
  font-size: 0.9rem;
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.form-grid input,
.form-grid select {
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(10, 12, 20, 0.85);
  color: var(--text);
}

.field-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border 0.2s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(99, 242, 156, 0.2);
}

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

.refresh-icon.spin {
  animation: spin 0.9s linear infinite;
}

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

.help-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 700;
  font-size: 0.75rem;
  align-items: center;
  justify-content: center;
  cursor: help;
  border: 1px solid var(--card-border);
}

.tile-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}

#tileGenSubmit {
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #05101e;
  cursor: pointer;
  font-weight: 700;
}

.tile-actions button#tileGenSubmit {
  display: none;
}

#tileExportBtn {
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #05101e;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(99, 242, 156, 0.25);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

#tileExportBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 34px rgba(110, 195, 255, 0.35);
}

#tileExportBtn:active {
  transform: translateY(0);
}

.export-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.export-link {
  text-decoration: underline;
  word-break: break-all;
}

.toggle {
  align-items: center;
  flex-direction: row;
  gap: 0.4rem;
}

main {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 1rem;
  min-height: calc(100vh - 68px);
  padding: 1rem 1.25rem 1.5rem;
}

.sidebar {
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 0.9rem;
  overflow-y: auto;
  position: sticky;
  top: 72px;
  align-self: start;
  background: var(--card);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.sidebar h2 {
  font-size: 1rem;
  margin: 1rem 0 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

#tagList,
#folderList {
  list-style: none;
  padding: 0;
  margin: 0;
}

#tagList li,
#folderList li {
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  border-radius: 10px;
  color: var(--text);
  border: 1px solid transparent;
  transition: background 0.2s ease, transform 0.15s ease, border 0.2s ease;
}

#tagList li:hover,
#folderList li:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--card-border);
  transform: translateX(2px);
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0.2rem 0 0.5rem;
  align-items: center;
}

.breadcrumb .seg {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.breadcrumb .crumb {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0.3rem 0.55rem;
  border-radius: 10px;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease;
}

.breadcrumb .crumb:hover {
  border-color: var(--accent);
  background: rgba(99, 242, 156, 0.12);
}

.breadcrumb .sep {
  color: var(--muted);
  font-size: 0.9rem;
}

.main-breadcrumb {
  padding: 0.35rem 0.4rem 0.4rem;
}

.folder-card .thumb {
  background: radial-gradient(circle at 25% 25%, rgba(255, 215, 140, 0.15), transparent 40%),
    radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.08), transparent 35%),
    #0c1424;
  display: grid;
  place-items: center;
}

.folder-card .folder-icon {
  width: 108px;
  height: 108px;
  color: #ffd782;
}

.parent-card .folder-icon {
  color: var(--accent);
}

.folder-card .folder-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar h2:first-child {
  margin-top: 0.5rem;
}

.sidebar h2 + h2 {
  margin-top: 1.2rem;
}

.section-title {
  cursor: pointer;
  user-select: none;
  justify-content: space-between;
}

.section-title .chevron {
  font-size: 0.9rem;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.section-title.collapsed .chevron {
  transform: rotate(-90deg);
}

.section-body {
  overflow: hidden;
  max-height: var(--section-max-height, 1200px);
  opacity: 1;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

.section-body.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

#savedSearchList {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: grid;
  gap: 0.35rem;
}

.saved-search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem;
  align-items: center;
}

.saved-search-btn {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.15s ease, background 0.2s ease;
}

.saved-search-btn:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.07);
  transform: translateX(2px);
}

.saved-search-delete {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--danger);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.saved-search-delete:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
}

.list-create {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.6rem 0 0.35rem;
}

.list-create input {
  padding: 0.45rem 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text);
}

.list-create button {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #05101e;
  cursor: pointer;
  font-weight: 600;
  width: 100%;
}

#listsList {
  list-style: none;
  padding: 0;
  margin: 0.25rem 0 0;
  display: grid;
  gap: 0.35rem;
}

.list-pill {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.15s ease, background 0.2s ease;
}

.list-pill:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.07);
  transform: translateX(2px);
}

.list-pill.active {
  border-color: var(--accent);
  background: rgba(99, 242, 156, 0.12);
}

.list-count {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
  padding-left: 0.1rem;
}
.content {
  padding: 0.5rem;
  overflow-y: auto;
  position: relative;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.9rem;
}

.spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.75rem;
  background: linear-gradient(145deg, rgba(14, 22, 48, 0.8), rgba(6, 10, 16, 0.8));
  border: 1px solid var(--card-border);
  border-radius: 16px;
  color: var(--muted);
  z-index: 5;
}

.spinner.hidden {
  display: none;
}

.spinner-ring {
  width: 52px;
  height: 52px;
  border: 4px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

#loadMoreSentinel {
  width: 100%;
  height: 20px;
}

.scroll-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #05101e;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(99, 242, 156, 0.35);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 300;
}

.scroll-top.visible {
  display: inline-flex;
}

.scroll-top:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(110, 195, 255, 0.35);
}

.model-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  transition: transform 0.15s ease, border 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow);
}

.model-card:hover {
  border-color: rgba(99, 242, 156, 0.45);
  transform: translateY(-3px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.35);
}

.thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, #0e1630, #0a1222);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(110, 195, 255, 0.08), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(99, 242, 156, 0.1), transparent 35%);
  pointer-events: none;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.thumb img[data-loaded="true"] {
  display: block;
}

.thumb-placeholder {
  font-size: 0.9rem;
  color: var(--muted);
  padding: 0.5rem;
  text-align: center;
}

.thumb-placeholder.thumb-failed {
  color: var(--danger);
}

.fit-indicator {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  display: flex;
  gap: 0.25rem;
  z-index: 2;
}

.modal-fit {
  position: static;
  margin-top: -0.25rem;
  display: flex;
  gap: 0.35rem;
}

.fit-badge {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  border-radius: 4px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.fit-ok {
  border-color: rgba(99, 242, 156, 0.6);
  background: rgba(99, 242, 156, 0.25);
}

.fit-bad {
  border-color: rgba(242, 140, 140, 0.6);
  background: rgba(242, 140, 140, 0.15);
}

.model-name {
  font-weight: 600;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-path {
  font-size: 0.85rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#modelPath {
  color: var(--accent-2);
  text-decoration: none;
}

#modelPath:hover {
  text-decoration: underline;
}

.meta-line {
  margin: 0;
  display: flex;
  gap: 0.35rem;
  align-items: baseline;
}

.meta-label {
  color: var(--muted);
  font-weight: 600;
}

#modelDims {
  color: var(--muted);
  margin: 0;
}

.model-meta {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.model-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 0.78rem;
}

.tag-chip.tag-empty {
  color: var(--muted);
}

/* Modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 0.75rem;
}

.hidden {
  display: none !important;
}

.modal-content {
  background: rgba(12, 18, 30, 0.9);
  border-radius: 16px;
  padding: 0.9rem;
  width: 92vw;
  height: 82vh;
   max-height: 90vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.close-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.8rem;
  cursor: pointer;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  z-index: 5;
}

.viewer-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.9rem;
  height: 100%;
  min-height: 0;
}

.viewer-canvas-wrapper {
  background: radial-gradient(circle at 30% 30%, rgba(110, 195, 255, 0.12), transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(99, 242, 156, 0.1), transparent 45%),
    #05070c;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--card-border);
  min-height: 320px;
}

.viewer-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: linear-gradient(145deg, rgba(14, 22, 48, 0.65), rgba(6, 10, 16, 0.65));
  z-index: 2;
}

#stlCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viewer-info h2 {
  margin-top: 0;
}

.viewer-info {
  background: var(--card);
  border-radius: 14px;
  padding: 0.75rem;
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
}

.slicer-actions {
  margin-top: auto;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
}

.ghost-btn {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.45rem;
  text-align: center;
  min-height: 130px;
}

.ghost-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

.btn-icon {
  display: inline-flex;
  width: 64px;
  height: 64px;
  color: var(--accent);
  flex-shrink: 0;
}

.btn-icon svg {
  width: 100%;
  height: 100%;
}

.btn-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.25));
}

.ghost-btn span:last-child {
  font-weight: 600;
  line-height: 1.2;
}

.tag-editor input {
  width: 100%;
  margin: 0.25rem 0;
  padding: 0.45rem 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--text);
}

.tag-editor button {
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: #05101e;
  cursor: pointer;
  font-weight: 600;
}

.list-editor {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.estimate-block {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.estimate-btn {
  width: auto;
  align-self: flex-start;
  min-height: auto;
  padding: 0.5rem 0.9rem;
  flex-direction: row;
  gap: 0.35rem;
  font-size: 0.95rem;
  border-radius: 10px;
}

.estimate-result {
  font-size: 0.9rem;
  color: var(--muted);
}

.estimate-result .time-prusa {
  color: #ef7f1a;
  font-weight: 700;
}

.estimate-result .time-bambu {
  color: #5dd39e;
  font-weight: 700;
}

.related-block {
  margin-top: 0.75rem;
  display: grid;
  gap: 0.4rem;
}

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

.related-card {
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.4rem;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease, transform 0.15s ease;
  display: grid;
  gap: 0.3rem;
}

.related-card:hover {
  border-color: var(--accent);
  background: rgba(99, 242, 156, 0.08);
  transform: translateY(-1px);
}

.related-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
  display: grid;
  place-items: center;
}

.related-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.related-name {
  font-weight: 700;
  display: block;
}

.related-path {
  font-size: 0.85rem;
  color: var(--muted);
}

.related-reasons {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.list-toggle-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.list-toggle {
  padding: 0.45rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.list-toggle:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.list-toggle.in-list {
  background: rgba(99, 242, 156, 0.18);
  border-color: var(--accent);
  color: #041018;
  font-weight: 700;
}

@media (max-width: 980px) {
  main {
    grid-template-columns: 1fr;
    height: auto;
  }
  .sidebar {
    order: 2;
    position: static;
  }
  .content {
    order: 1;
  }
  .viewer-layout {
    grid-template-columns: 1fr;
  }
  .viewer-canvas-wrapper {
    min-height: 280px;
  }
  .viewer-info {
    max-height: none;
  }

  .search-controls {
    width: 100%;
    gap: 0.5rem;
  }

  .search-controls input,
  .search-controls select {
    flex: 1;
  }

  .search-controls button {
    width: auto;
  }

  #resultsInfo {
    order: -1;
    width: 100%;
    text-align: left;
  }

  .action-buttons {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

@media (max-width: 640px) {
  .search-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
    position: static;
  }

  .sidebar {
    position: static;
  }

  .search-controls button:not(.clear-btn) {
    width: 100%;
  }
  .settings {
    width: 100%;
  }
  .settings-menu {
    position: static;
    width: 100%;
  }

  .action-buttons {
    grid-template-columns: 1fr;
  }

  .model-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .thumb {
    aspect-ratio: 4 / 3;
  }

  .viewer-layout {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 96vw;
    height: 90vh;
    padding: 0.75rem;
  }
  .viewer-canvas-wrapper {
    min-height: 260px;
  }

  .viewer-info {
    padding: 0.65rem;
    max-height: none;
  }

  .action-buttons {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.4rem;
  }

  .ghost-btn {
    min-height: 110px;
    padding: 0.65rem 0.8rem;
    gap: 0.35rem;
  }

  .btn-icon {
    width: 44px;
    height: 44px;
  }

  .close-btn {
    top: 0.25rem;
    right: 0.25rem;
  }
}
