:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --bg: #07111c;
  --panel: #091827;
  --ink: #e9f2f7;
  --muted: #6e8498;
  --line: rgba(136, 179, 203, 0.14);
  --accent: #49d7c6;
  --warm: #e2936f;
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--ink); }
button { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  grid-template-rows: 72px minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.topbar {
  z-index: 5;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 15, 25, 0.9);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-symbol {
  position: relative;
  display: block;
  width: 39px;
  height: 39px;
  border: 1px solid rgba(73, 215, 198, 0.44);
  border-radius: 50%;
  box-shadow: inset 0 0 20px rgba(73, 215, 198, 0.07), 0 0 22px rgba(73, 215, 198, 0.05);
}
.brand-symbol::before {
  content: "";
  position: absolute;
  inset: 7px 10px 6px 9px;
  border: 1px solid var(--accent);
  border-left-color: transparent;
  border-radius: 56% 44% 54% 46%;
  transform: rotate(-12deg);
}
.brand-symbol i { position: absolute; width: 1px; height: 7px; background: var(--accent); opacity: 0.72; }
.brand-symbol i:nth-child(1) { top: -4px; left: 19px; }
.brand-symbol i:nth-child(2) { right: -2px; top: 16px; transform: rotate(90deg); }
.brand-symbol i:nth-child(3) { bottom: -4px; left: 19px; }
.brand p { margin: 0; color: var(--accent); font-size: 8px; letter-spacing: 0.25em; }
.brand h1 { margin: 3px 0 0; font-size: 18px; font-weight: 650; letter-spacing: 0.08em; }
.source-badge { display: flex; align-items: center; gap: 8px; color: #8ba0b2; font-size: 10px; letter-spacing: 0.1em; }
.source-badge span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 11px var(--accent); }

.panel {
  z-index: 4;
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 19px;
  padding: 21px 21px 18px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(9, 24, 39, 0.98), rgba(6, 18, 30, 0.98));
  box-shadow: 24px 0 70px rgba(0, 0, 0, 0.22);
}
.section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-title b { color: var(--accent); font-size: 8px; font-weight: 500; letter-spacing: 0.15em; }
.section-title h2 { margin: 0; color: #b9cad7; font-size: 10px; font-weight: 600; letter-spacing: 0.14em; }

.scope-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scope-switch button,
.sex-switch button,
.variant-grid button,
.material-list button,
.panel-actions button {
  border: 1px solid var(--line);
  color: #879bad;
  background: rgba(255, 255, 255, 0.022);
  cursor: pointer;
  transition: 160ms ease;
}
.scope-switch button:hover,
.sex-switch button:hover,
.variant-grid button:hover,
.material-list button:hover,
.panel-actions button:hover { border-color: rgba(73, 215, 198, 0.42); transform: translateY(-1px); }
.scope-switch button {
  display: grid;
  grid-template-columns: 31px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  min-height: 62px;
  padding: 9px;
  border-radius: 10px;
  text-align: left;
}
.scope-switch button.active,
.sex-switch button.active,
.variant-grid button.active,
.material-list button.active {
  border-color: rgba(73, 215, 198, 0.56);
  color: #e9fffb;
  background: linear-gradient(135deg, rgba(73, 215, 198, 0.15), rgba(73, 215, 198, 0.035));
  box-shadow: inset 0 0 0 1px rgba(73, 215, 198, 0.04);
}
.scope-switch strong { font-size: 11px; font-weight: 600; }
.scope-switch small { grid-column: 2; color: #607588; font-size: 8px; }
.scope-glyph { grid-row: 1 / 3; width: 25px; height: 29px; border: 1px solid #557386; border-radius: 50% 43% 55% 45%; }
.scope-glyph.overview { width: 27px; height: 18px; border-radius: 4px; box-shadow: inset 7px 0 rgba(73, 215, 198, 0.09), inset -7px 0 rgba(73, 215, 198, 0.09); }
.active .scope-glyph { border-color: var(--accent); }

#variantControls.disabled { opacity: 0.34; pointer-events: none; }
.sex-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 8px; }
.sex-switch button { height: 34px; border-radius: 8px; font-size: 10px; }
.variant-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.variant-grid button { height: 30px; border-radius: 7px; font-size: 9px; font-variant-numeric: tabular-nums; }

.material-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.material-list button { min-width: 0; padding: 8px 5px 7px; border-radius: 9px; text-align: center; }
.material-list strong { display: block; margin-top: 5px; overflow: hidden; font-size: 9px; font-weight: 600; white-space: nowrap; }
.material-list small { display: none; }
.swatch { display: block; width: 24px; height: 15px; margin: 0 auto; border-radius: 50%; box-shadow: inset -5px -3px 8px rgba(0, 0, 0, 0.3), inset 4px 3px 7px rgba(255, 255, 255, 0.25); }
.swatch.skin { background: #c68768; }
.swatch.porcelain { background: #c8d7d9; }
.swatch.wire { border: 1px solid #49d7c6; background: repeating-linear-gradient(45deg, transparent 0 3px, #49d7c6 4px); box-shadow: none; }

.model-info dl { margin: 0; border-top: 1px solid var(--line); }
.model-info dl div { display: flex; justify-content: space-between; padding: 7px 2px; border-bottom: 1px solid rgba(136, 179, 203, 0.075); }
.model-info dt { color: #5c7286; font-size: 9px; }
.model-info dd { margin: 0; color: #b9cad7; font-size: 9px; font-variant-numeric: tabular-nums; }
.model-info dd.ready { color: var(--accent); }

.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; }
.panel-actions button { height: 40px; border-radius: 9px; font-size: 10px; }
.panel-actions .accent { border-color: rgba(73, 215, 198, 0.42); color: #dffffa; background: rgba(73, 215, 198, 0.1); }
.panel-actions span { margin-right: 5px; color: var(--accent); font-size: 8px; letter-spacing: -2px; }

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 57% 47%, rgba(32, 78, 91, 0.3), transparent 38%),
    linear-gradient(135deg, #07121e, #06101a 58%, #081725);
}
.stage::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(rgba(95, 141, 163, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(95, 141, 163, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 58% 50%, black, transparent 73%);
}
#modelCanvas { display: block; width: 100%; height: 100%; outline: 0; }
.stage-heading { position: absolute; z-index: 2; top: 27px; left: 28px; pointer-events: none; }
.stage-heading p { margin: 0 0 5px; color: var(--accent); font-size: 8px; letter-spacing: 0.19em; }
.stage-heading h2 { margin: 0; color: #dfeaf1; font-size: 14px; font-weight: 540; letter-spacing: 0.09em; }
.precision-badge { position: absolute; z-index: 2; top: 27px; right: 28px; display: flex; align-items: center; gap: 7px; color: #6d8396; font-size: 8px; letter-spacing: 0.16em; pointer-events: none; }
.precision-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 11px var(--accent); }
.measure-line { position: absolute; z-index: 2; top: 24%; right: 27px; bottom: 22%; display: flex; flex-direction: column; align-items: center; color: #455d70; font-size: 7px; letter-spacing: 0.13em; pointer-events: none; }
.measure-line i { flex: 1; width: 1px; margin: 8px 0; background: linear-gradient(transparent, rgba(73, 215, 198, 0.45), transparent); }
.measure-line span { writing-mode: vertical-rl; }
.interaction-hint { position: absolute; z-index: 2; right: 27px; bottom: 22px; display: flex; align-items: center; gap: 7px; color: #526b7e; font-size: 8px; letter-spacing: 0.07em; pointer-events: none; }
.mouse, .wheel { display: inline-block; width: 10px; height: 14px; margin-left: 10px; border: 1px solid #577184; border-radius: 5px; }
.mouse::after, .wheel::after { content: ""; display: block; width: 1px; height: 4px; margin: 2px auto; background: var(--accent); }

.loading-overlay { position: absolute; z-index: 8; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(6, 16, 26, 0.94); backdrop-filter: blur(12px); transition: opacity 360ms ease, visibility 360ms ease; }
.loading-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.ear-loader { position: relative; width: 58px; height: 70px; margin-bottom: 18px; border: 1px solid rgba(73, 215, 198, 0.45); border-left-color: transparent; border-radius: 54% 46% 58% 42%; animation: breathe 1.5s ease-in-out infinite; }
.ear-loader::before { content: ""; position: absolute; inset: 13px 12px 14px 17px; border: 1px solid rgba(73, 215, 198, 0.65); border-bottom-color: transparent; border-radius: 55%; }
.ear-loader span { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.ear-loader span:nth-child(1) { top: 5px; left: 34px; }
.ear-loader span:nth-child(2) { top: 31px; right: 6px; opacity: 0.62; }
.ear-loader span:nth-child(3) { bottom: 6px; left: 17px; opacity: 0.35; }
.loading-overlay p { margin: 0 0 13px; color: #d5e3eb; font-size: 12px; letter-spacing: 0.11em; }
.loading-overlay small { margin-top: 9px; color: #587084; font-size: 8px; }
.progress { width: min(270px, 52vw); height: 2px; overflow: hidden; background: rgba(141, 181, 203, 0.13); }
.progress i { display: block; width: 2%; height: 100%; background: linear-gradient(90deg, #2e817d, var(--accent)); box-shadow: 0 0 10px var(--accent); transition: width 160ms ease; }
@keyframes breathe { 50% { transform: scale(1.05); filter: drop-shadow(0 0 9px rgba(73, 215, 198, 0.27)); } }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 62px minmax(0, 1fr) 186px; }
  .topbar { padding: 0 17px; }
  .source-badge { display: none; }
  .brand h1 { font-size: 15px; }
  .panel { grid-row: 3; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 15px; border-top: 1px solid var(--line); border-right: 0; }
  .panel > section:nth-child(3), .model-info { display: none; }
  .panel-actions { margin: 24px 0 0; align-self: start; }
  .stage { grid-row: 2; }
  .stage-heading { top: 17px; left: 17px; }
  .precision-badge { top: 18px; right: 17px; }
  .measure-line { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
