:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --ink: #eaf4ff;
  --muted: #8397ad;
  --line: rgba(164, 198, 225, 0.14);
  --panel: rgba(10, 24, 39, 0.92);
  --accent: #44d6c4;
  --accent-2: #ff9a75;
  --canvas: #06101c;
  background: var(--canvas);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
}

button { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 328px minmax(0, 1fr);
  grid-template-rows: 74px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 72% 42%, rgba(23, 72, 93, 0.26), transparent 42%),
    #06101c;
}

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

.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(68, 214, 196, 0.45);
  border-radius: 11px;
  background: rgba(68, 214, 196, 0.08);
  transform: rotate(45deg);
}
.brand-mark span {
  position: absolute;
  width: 16px;
  height: 1px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(68, 214, 196, 0.65);
}
.brand-mark span:nth-child(2) { transform: rotate(60deg); }
.brand-mark span:nth-child(3) { transform: rotate(-60deg); }
.brand-lockup h1 { margin: 2px 0 0; font-size: 18px; font-weight: 600; letter-spacing: 0.08em; }
.eyebrow { margin: 0; color: var(--accent); font-size: 9px; letter-spacing: 0.22em; }
.topbar-meta { display: flex; align-items: center; gap: 8px; color: #a7b9ca; font-size: 12px; letter-spacing: 0.08em; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

.control-panel {
  z-index: 4;
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 24px;
  padding: 24px 22px 20px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(10, 24, 39, 0.97), rgba(7, 18, 31, 0.96));
  box-shadow: 24px 0 70px rgba(0, 0, 0, 0.2);
}

.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-heading > span { color: var(--accent); font-size: 9px; font-variant-numeric: tabular-nums; letter-spacing: 0.18em; }
.section-heading h2 { margin: 0; color: #cbd9e6; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; }

.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented-control button,
.mode-grid button,
.panel-actions button {
  border: 1px solid var(--line);
  color: #a7b7c8;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}
.segmented-control button:hover,
.mode-grid button:hover,
.panel-actions button:hover { transform: translateY(-1px); border-color: rgba(68, 214, 196, 0.38); }
.segmented-control button {
  display: flex;
  min-height: 58px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  text-align: left;
}
.segmented-control button.active,
.mode-grid button.active {
  border-color: rgba(68, 214, 196, 0.58);
  color: #e8fffb;
  background: linear-gradient(135deg, rgba(68, 214, 196, 0.16), rgba(68, 214, 196, 0.05));
  box-shadow: inset 0 0 0 1px rgba(68, 214, 196, 0.05), 0 8px 26px rgba(0, 0, 0, 0.14);
}
.button-kicker { color: #668096; font-size: 8px; letter-spacing: 0.12em; }
.active .button-kicker { color: var(--accent); }

.mode-grid { display: grid; gap: 7px; }
.mode-grid button {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 11px;
  min-height: 54px;
  padding: 8px 10px;
  border-radius: 10px;
  text-align: left;
}
.mode-grid strong { display: block; margin-bottom: 2px; font-size: 12px; font-weight: 600; }
.mode-grid small { display: block; color: #61768b; font-size: 9px; }
.mode-icon {
  position: relative;
  display: block;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(121, 159, 185, 0.25);
  border-radius: 8px;
  background: rgba(8, 20, 34, 0.7);
}
.mode-icon::before,
.mode-icon::after { content: ""; position: absolute; inset: 7px; border: 1px solid #668096; border-radius: 50%; }
.mode-icon::after { inset: 10px 6px 6px 10px; border-color: var(--accent); border-radius: 35% 65% 55% 45%; }
.mode-icon.bone::before { inset: 6px 13px; border-radius: 5px; transform: rotate(35deg); }
.mode-icon.bone::after { inset: 12px 5px; border-radius: 5px; transform: rotate(-35deg); }
.mode-icon.body::before { inset: 5px 9px 4px; border-radius: 50% 50% 40% 40%; }
.mode-icon.body::after { inset: 7px 12px 17px; }
.mode-icon.layered::before { inset: 7px; border-radius: 4px; transform: rotate(45deg); }
.mode-icon.layered::after { inset: 10px; border-radius: 3px; transform: rotate(45deg); }

.model-data { min-height: 0; }
.model-data dl { margin: 0; border-top: 1px solid var(--line); }
.model-data dl div { display: flex; justify-content: space-between; padding: 8px 2px; border-bottom: 1px solid rgba(164, 198, 225, 0.08); }
.model-data dt { color: #62778b; font-size: 10px; }
.model-data dd { margin: 0; color: #c6d5e3; font-size: 10px; font-variant-numeric: tabular-nums; }
.model-data dd.ready { color: var(--accent); }
.structure-stats { margin: 9px 2px 0; color: #5f7489; font-size: 9px; line-height: 1.6; }

.panel-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: auto; }
.panel-actions button { min-height: 42px; border-radius: 10px; font-size: 11px; }
.panel-actions .primary-action { border-color: rgba(68, 214, 196, 0.44); color: #dffffa; background: rgba(68, 214, 196, 0.12); }
.pause-icon { margin-right: 5px; color: var(--accent); font-size: 9px; letter-spacing: -2px; }

.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.stage::before {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(95, 140, 166, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(95, 140, 166, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}
#modelCanvas { display: block; width: 100%; height: 100%; outline: none; }
.viewport-caption {
  position: absolute;
  z-index: 2;
  top: 24px;
  left: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #8499ad;
  font-size: 10px;
  letter-spacing: 0.1em;
  pointer-events: none;
}
.viewport-caption > span:first-child { color: #d4e2ef; }
.divider { width: 22px; height: 1px; background: var(--accent); opacity: 0.55; }

.orientation-cue {
  position: absolute;
  z-index: 2;
  top: 27px;
  right: 28px;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(147, 181, 204, 0.16);
  border-radius: 50%;
  color: #63798e;
  font-size: 8px;
  pointer-events: none;
}
.orientation-cue::before,
.orientation-cue::after { content: ""; position: absolute; background: rgba(117, 151, 175, 0.26); }
.orientation-cue::before { top: 8px; bottom: 8px; left: 28px; width: 1px; }
.orientation-cue::after { top: 28px; right: 8px; left: 8px; height: 1px; transform: rotate(-25deg); }
.orientation-cue span { position: absolute; }
.axis-y { top: 4px; left: 27px; color: var(--accent); }
.axis-x { right: 4px; bottom: 16px; color: #ff8c70; }
.axis-z { bottom: 7px; left: 7px; color: #73a8ff; }

.interaction-hint {
  position: absolute;
  z-index: 2;
  right: 26px;
  bottom: 22px;
  display: flex;
  gap: 18px;
  color: #596f83;
  font-size: 9px;
  letter-spacing: 0.06em;
  pointer-events: none;
}
.interaction-hint span { display: flex; align-items: center; gap: 6px; }
.mouse-icon, .wheel-icon { display: inline-block; width: 10px; height: 14px; border: 1px solid #577084; border-radius: 5px; }
.mouse-icon::after { content: ""; display: block; width: 1px; height: 4px; margin: 2px auto; background: var(--accent); }
.wheel-icon::after { content: ""; display: block; width: 2px; height: 4px; margin: 2px auto; border-radius: 2px; background: #7f95a8; }

.loading-overlay {
  position: absolute;
  z-index: 8;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(6, 16, 28, 0.93);
  backdrop-filter: blur(12px);
  transition: opacity 400ms ease, visibility 400ms ease;
}
.loading-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-orbit { position: relative; width: 64px; height: 64px; margin-bottom: 18px; animation: orbit 4s linear infinite; }
.loader-orbit::before { content: ""; position: absolute; inset: 7px; border: 1px solid rgba(68, 214, 196, 0.34); border-radius: 50%; }
.loader-orbit span { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 16px var(--accent); }
.loader-orbit span:nth-child(1) { top: 1px; left: 28px; }
.loader-orbit span:nth-child(2) { right: 5px; bottom: 10px; opacity: 0.6; }
.loader-orbit span:nth-child(3) { bottom: 10px; left: 5px; opacity: 0.35; }
.loading-overlay p { margin: 0 0 14px; color: #d9e7f3; font-size: 13px; letter-spacing: 0.12em; }
.progress-track { width: min(280px, 55vw); height: 2px; overflow: hidden; background: rgba(139, 172, 196, 0.14); }
.progress-track span { display: block; width: 2%; height: 100%; background: linear-gradient(90deg, #2c8e8b, var(--accent)); box-shadow: 0 0 12px var(--accent); transition: width 180ms ease; }
.loading-overlay small { margin-top: 10px; color: #5e7488; font-size: 9px; }
@keyframes orbit { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 64px minmax(0, 1fr) 190px; }
  .topbar { padding: 0 18px; }
  .topbar-meta { display: none; }
  .control-panel {
    grid-row: 3;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    border-right: 0;
  }
  .control-panel section:nth-child(2), .model-data { display: none; }
  .panel-actions { margin: 25px 0 0; align-self: start; }
  .stage { grid-row: 2; }
  .brand-lockup h1 { font-size: 15px; }
  .viewport-caption { top: 16px; left: 17px; }
  .orientation-cue { top: 16px; right: 16px; }
  .interaction-hint { right: 16px; bottom: 14px; }
}

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