:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --theme-primary: #3b82f6;
  --theme-secondary: #2563eb;
  --theme-accent: #60a5fa;
  --theme-glow: #1d4ed8;
  --theme-primary-rgb: 59, 130, 246;
  --theme-secondary-rgb: 37, 99, 235;
  --theme-accent-rgb: 96, 165, 250;
  --theme-glow-rgb: 29, 78, 216;
  --dash-bg: #070A10;
  --dash-sidebar: #000000;
  --dash-panel: rgba(255, 255, 255, .052);
  --dash-panel-strong: rgba(255, 255, 255, .072);
  --dash-line: rgba(255, 255, 255, .11);
  --dash-line-strong: rgba(var(--theme-primary-rgb), .42);
  --dash-ink: #f8fafc;
  --dash-muted: rgba(226, 232, 240, .72);
  --dash-soft: rgba(226, 232, 240, .54);
  --dash-radius: 18px;
  --dash-radius-sm: 14px;
  --field: rgba(255, 255, 255, .052);
  --tile-dark: #03060b;
  --on-primary: #ffffff;
  --primary: var(--theme-primary);
  background: var(--dash-bg);
  color: var(--dash-ink);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--dash-bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--dash-bg);
  color: var(--dash-ink);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

body.is-busy {
  cursor: progress;
  user-select: none;
}

.global-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 22px;
  border-bottom: 1px solid var(--dash-line);
  background: var(--dash-sidebar);
  color: var(--dash-ink);
  font-size: 12px;
  line-height: 1;
}

.brand-link {
  color: var(--dash-ink);
  font-weight: 700;
}

.global-nav nav {
  display: flex;
  gap: 18px;
  align-items: center;
}

.global-nav a {
  color: var(--dash-muted);
  transition: color .18s ease, background .18s ease;
}

.global-nav a:hover { color: var(--dash-ink); }
.global-nav a:active { transform: scale(.95); }

.sub-nav {
  position: sticky;
  top: 44px;
  z-index: 35;
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 22px;
  border-bottom: 1px solid var(--dash-line);
  background: rgba(7, 10, 16, .84);
  color: var(--dash-ink);
  backdrop-filter: saturate(180%) blur(20px);
}

.sub-nav strong {
  overflow: hidden;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-nav button {
  min-height: 34px;
  margin-top: 0;
  padding: 7px 14px;
  font-size: 12px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(310px, 360px) minmax(0, 1fr);
  min-height: calc(100vh - 96px);
  background: var(--dash-bg);
}

.drop-overlay {
  position: fixed;
  z-index: 50;
  display: grid;
  inset: 0;
  place-items: center;
  visibility: hidden;
  background: rgba(0, 0, 0, .72);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  backdrop-filter: blur(10px);
}

.drop-overlay.active {
  visibility: visible;
  opacity: 1;
}

.drop-overlay div,
.busy-card {
  width: min(420px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--dash-line-strong);
  border-radius: var(--dash-radius);
  background: rgba(7, 10, 16, .94);
  text-align: center;
}

.drop-overlay strong,
.drop-overlay span {
  display: block;
}

.drop-overlay strong {
  color: var(--dash-ink);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
}

.drop-overlay span {
  margin-top: 8px;
  color: var(--dash-muted);
  font-size: 13px;
}

.busy-overlay {
  position: fixed;
  z-index: 60;
  display: grid;
  inset: 0;
  place-items: center;
  background: rgba(0, 0, 0, .70);
  backdrop-filter: blur(10px);
  pointer-events: all;
}

.busy-overlay[hidden] { display: none; }

.busy-card {
  display: grid;
  width: min(300px, calc(100vw - 28px));
  place-items: center;
}

.busy-circle {
  --progress: 0deg;
  position: relative;
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--theme-primary) var(--progress), rgba(255, 255, 255, .10) 0deg);
}

.busy-circle::after {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--dash-bg);
  content: "";
}

.busy-circle span {
  position: relative;
  z-index: 1;
  color: var(--dash-ink);
  font-size: 24px;
  font-weight: 700;
}

.busy-card strong {
  margin-top: 14px;
  color: var(--dash-ink);
  font-size: 16px;
  font-weight: 700;
}

.busy-card > span {
  margin-top: 6px;
  color: var(--dash-muted);
  font-size: 12px;
  line-height: 1.4;
}

aside {
  height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 14px;
  border-right: 1px solid var(--dash-line);
  background: var(--dash-sidebar);
  scrollbar-color: rgba(var(--theme-primary-rgb), .55) rgba(255, 255, 255, .04);
}

aside > header,
aside section,
.picker,
.texdb-help {
  margin: 0 0 10px;
  padding: 13px;
  border: 1px solid var(--dash-line);
  border-radius: var(--dash-radius);
  background: var(--dash-panel);
  box-shadow: none;
}

aside > header {
  padding: 6px 2px 12px;
  border: 0;
  background: transparent;
}

header p,
.picker span,
.report,
dt {
  color: var(--dash-muted);
}

h1 {
  margin: 4px 0 6px;
  color: var(--dash-ink);
  font-size: 26px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.08;
}

aside > header p:last-child {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

h2 {
  margin: 0 0 8px;
  color: var(--dash-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.25;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0;
  color: var(--theme-accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.picker {
  display: block;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}

.picker:hover {
  border-color: var(--dash-line-strong);
  background: rgba(var(--theme-primary-rgb), .10);
}

.picker strong,
.report strong {
  color: var(--dash-ink);
  font-size: 13px;
  font-weight: 700;
}

.picker span {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.35;
}

.texdb-help {
  color: var(--dash-muted);
  font-size: 12px;
  line-height: 1.4;
}

.texdb-help summary {
  color: var(--theme-primary);
  cursor: pointer;
  font-weight: 650;
}

.texdb-help p { margin: 7px 0; }

code {
  color: var(--dash-ink);
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: .9em;
}

.texdb-help code {
  display: block;
  margin: 4px 0;
}

input {
  display: block;
  max-width: 100%;
  margin-top: 8px;
  color: var(--dash-muted);
  font: inherit;
  font-size: 11px;
}

input::file-selector-button {
  min-height: 32px;
  margin-right: 8px;
  padding: 7px 12px;
  border: 1px solid rgba(var(--theme-primary-rgb), .48);
  border-radius: 9999px;
  background: transparent;
  color: var(--theme-primary);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

select {
  width: 100%;
  min-height: 38px;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid var(--dash-line);
  border-radius: var(--dash-radius-sm);
  background: var(--field);
  color: var(--dash-ink);
  font-size: 12px;
}

button {
  min-height: 38px;
  margin-top: 8px;
  padding: 9px 16px;
  border: 1px solid var(--theme-primary);
  border-radius: 9999px;
  background: var(--theme-primary);
  color: var(--on-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.05;
  cursor: pointer;
  box-shadow: none;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, color .18s ease;
}

button.secondary {
  background: transparent;
  color: var(--theme-primary);
}

button:hover {
  border-color: rgba(var(--theme-primary-rgb), .78);
}

button:active {
  transform: scale(.95);
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 0;
  border-color: rgba(var(--theme-primary-rgb), .68);
  box-shadow: 0 0 0 4px rgba(var(--theme-primary-rgb), .18);
}

select:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: .46;
}

#status,
.report {
  color: var(--dash-muted);
  font-size: 12px;
  line-height: 1.45;
}

.report ul {
  margin: 6px 0 0;
  padding-left: 17px;
}

dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
}

dd {
  margin: 0;
  color: var(--dash-ink);
}

.model-list {
  display: grid;
  gap: 7px;
  color: var(--dash-muted);
  font-size: 12px;
  line-height: 1.35;
}

.model-item {
  width: 100%;
  min-height: 34px;
  margin-top: 0;
  padding: 8px 12px;
  border: 1px solid var(--dash-line);
  border-radius: var(--dash-radius-sm);
  background: var(--field);
  color: var(--dash-ink);
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-item.active {
  border-color: var(--dash-line-strong);
  background: rgba(var(--theme-primary-rgb), .14);
  color: var(--theme-accent);
}

.textures {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.texture { min-width: 0; }

.texture canvas,
.texture img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid var(--dash-line);
  border-radius: 10px;
  background: rgba(0, 0, 0, .34);
  image-rendering: auto;
}

.texture small {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--dash-soft);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  position: relative;
  min-width: 0;
  min-height: calc(100vh - 96px);
  background: var(--tile-dark);
  color: var(--dash-ink);
}

#viewer {
  display: block;
  width: 100%;
  height: calc(100vh - 96px);
}

.help,
.drop-hint {
  position: absolute;
  padding: 7px 12px;
  border: 1px solid var(--dash-line);
  border-radius: 9999px;
  background: rgba(7, 10, 16, .78);
  color: var(--dash-muted);
  font-size: 11px;
  line-height: 1.2;
  backdrop-filter: blur(12px);
}

.help {
  right: 14px;
  bottom: 14px;
}

.drop-hint {
  top: 14px;
  left: 50%;
  color: var(--theme-accent);
  transform: translateX(-50%);
}

@media (max-width: 1068px) {
  .app-shell { grid-template-columns: 320px 1fr; }
  h1 { font-size: 23px; }
}

@media (max-width: 833px) {
  .global-nav {
    justify-content: center;
  }

  .global-nav nav { display: none; }

  .app-shell { grid-template-columns: 1fr; }

  aside {
    height: auto;
    max-height: 50vh;
    border-right: 0;
    border-bottom: 1px solid var(--dash-line);
  }

  main,
  #viewer {
    min-height: calc(50vh - 96px);
    height: calc(50vh - 96px);
  }
}

@media (max-width: 640px) {
  .global-nav,
  .sub-nav {
    padding-inline: 12px;
  }

  .sub-nav strong { font-size: 14px; }
  .sub-nav button { padding-inline: 12px; font-size: 11px; }
  aside { padding: 10px; }
  .textures { grid-template-columns: repeat(3, 1fr); }
  .help { display: none; }
}
