:root {
  color-scheme: dark;
  --bg: #050910;
  --panel: rgba(7, 15, 26, .72);
  --line: rgba(141, 190, 214, .22);
  --text: #edf4f2;
  --muted: #8a9ba8;
  --cyan: #3ce5e5;
  --acid: #e8f45e;
  --orange: #f05b36;
}

@font-face {
  font-family: "Alimama ShuHeiTi";
  src: url("./fonts/AlimamaShuHeiTi-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; min-height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); font-family: Arial, Helvetica, sans-serif; }
button, a { font: inherit; }
button { color: inherit; }

.app { position: relative; min-height: 100svh; overflow: hidden; background: radial-gradient(circle at 58% 46%, #13283b 0, #09121e 29%, #050910 68%); }
.app::before { content: ""; position: absolute; inset: 0; opacity: .14; pointer-events: none; background-image: linear-gradient(rgba(67, 213, 220, .18) 1px, transparent 1px), linear-gradient(90deg, rgba(67, 213, 220, .18) 1px, transparent 1px); background-size: 52px 52px; mask-image: radial-gradient(circle at 58% 48%, black, transparent 70%); }
.app::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 140px rgba(0,0,0,.72); }

.topbar { position: absolute; z-index: 10; inset: 0 0 auto; height: 76px; padding: 0 clamp(22px, 3vw, 48px); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid var(--line); background: linear-gradient(rgba(4,9,16,.9), rgba(4,9,16,.35)); }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-weight: 800; letter-spacing: .15em; font-size: .78rem; }
.brand__mark { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--cyan); clip-path: polygon(20% 0, 100% 0, 100% 80%, 80% 100%, 0 100%, 0 20%); color: var(--cyan); }
.status { display: flex; align-items: center; gap: 9px; margin: 0; color: var(--muted); font-size: .72rem; letter-spacing: .1em; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: var(--acid); box-shadow: 0 0 12px var(--acid); }
.help-button { justify-self: end; border: 1px solid var(--line); border-radius: 999px; padding: 9px 15px; background: rgba(7,17,27,.55); cursor: pointer; font-size: .72rem; letter-spacing: .08em; }

.viewer { position: absolute; inset: 76px 16% 0 23%; }
#robot-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#robot-canvas:active { cursor: grabbing; }
.loading { position: absolute; z-index: 6; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; background: rgba(4,9,16,.72); color: var(--muted); letter-spacing: .12em; font-size: .75rem; transition: opacity .45s ease, visibility .45s ease; }
.loading.is-hidden { opacity: 0; visibility: hidden; }
.loading__ring { width: 54px; height: 54px; border: 1px solid var(--line); border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; }
.loading b { color: var(--text); }
.scanline { position: absolute; z-index: 3; left: 27%; right: 20%; top: 24%; height: 1px; opacity: .65; background: linear-gradient(90deg, transparent, var(--cyan), transparent); box-shadow: 0 0 17px var(--cyan); pointer-events: none; animation: scan 5s ease-in-out infinite; }
.drag-hint { position: absolute; z-index: 5; left: 58%; bottom: 31px; transform: translateX(-50%); color: var(--muted); font-size: .72rem; letter-spacing: .12em; pointer-events: none; }

.intro-panel { position: absolute; z-index: 5; left: clamp(22px, 3.6vw, 58px); top: 50%; width: min(300px, 24vw); transform: translateY(-44%); pointer-events: none; }
.kicker { margin: 0 0 16px; color: var(--cyan); font-size: .67rem; font-weight: 700; letter-spacing: .17em; }
h1 { margin: 0; font-family: "Alimama ShuHeiTi", "Microsoft YaHei", sans-serif; font-size: clamp(2rem, 3.1vw, 3.6rem); font-weight: 700; line-height: 1.08; letter-spacing: -.075em; white-space: nowrap; }
h1 em { color: var(--acid); font-style: normal; }
.intro-panel__body { width: min(320px, 100%); margin: 25px 0 0; color: var(--muted); font-size: .94rem; line-height: 1.65; }

.control-panel { position: absolute; z-index: 5; right: clamp(22px, 3vw, 48px); top: 50%; width: 238px; transform: translateY(-44%); padding: 18px; border: 1px solid var(--line); border-radius: 2px; background: var(--panel); backdrop-filter: blur(18px); box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.control-panel__head { display: flex; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .68rem; letter-spacing: .13em; }
.index { color: var(--cyan); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin: 15px 0; padding: 3px; background: rgba(255,255,255,.045); }
.segmented button { border: 0; padding: 9px 5px; color: var(--muted); background: transparent; cursor: pointer; font-size: .72rem; }
.segmented button.is-active { color: #061316; background: var(--cyan); }
.control-row { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 13px 2px; border: 0; border-top: 1px solid var(--line); background: transparent; cursor: pointer; font-size: .78rem; }
.control-row span { display: flex; align-items: center; gap: 10px; }
.control-row b { color: var(--cyan); font-size: .65rem; }
.control-icon { display: inline-block; width: 16px; height: 16px; border: 1px solid var(--muted); }
.control-icon--mesh { background: linear-gradient(45deg, transparent 45%, var(--muted) 46%, var(--muted) 54%, transparent 55%); }
.control-icon--orbit { border-radius: 50%; box-shadow: -3px 0 0 -2px var(--muted), 3px 0 0 -2px var(--muted); }
.control-icon--reset { border-radius: 50%; border-right-color: transparent; }
.control-icon--rail { width: 7px; border-color: var(--cyan); box-shadow: 5px 0 0 -1px var(--cyan); }
.control-icon--scan { width: 16px; height: 12px; border-color: var(--cyan); border-width: 1px 0; box-shadow: inset 0 5px 0 -4px var(--cyan); }

.pan-pad { position: absolute; z-index: 6; right: clamp(22px, 3vw, 48px); bottom: 34px; display: grid; grid-template-columns: repeat(3, 34px); grid-template-rows: repeat(3, 34px); gap: 4px; padding: 7px; border: 1px solid var(--line); background: rgba(7,15,26,.74); backdrop-filter: blur(14px); box-shadow: 0 18px 45px rgba(0,0,0,.32); }
.pan-key { border: 1px solid rgba(141,190,214,.28); color: var(--cyan); background: rgba(14,29,43,.78); cursor: pointer; font-size: .72rem; line-height: 1; transition: background .2s ease, border-color .2s ease, transform .2s ease; }
.pan-key:hover, .pan-key:focus-visible { border-color: var(--cyan); background: rgba(60,229,229,.18); outline: none; }
.pan-key:active { transform: scale(.92); }
.pan-key--up { grid-column: 2; grid-row: 1; }
.pan-key--left { grid-column: 1; grid-row: 2; }
.pan-key--center { grid-column: 2; grid-row: 2; color: var(--acid); }
.pan-key--right { grid-column: 3; grid-row: 2; }
.pan-key--down { grid-column: 2; grid-row: 3; }

.model-data { position: absolute; z-index: 5; left: clamp(22px, 3.6vw, 58px); bottom: 28px; display: flex; gap: 24px; color: var(--muted); font-size: .58rem; letter-spacing: .12em; }
.model-data b { color: var(--text); font-size: .78rem; }

dialog { width: min(430px, calc(100vw - 36px)); border: 1px solid var(--line); border-radius: 4px; padding: 28px; color: var(--text); background: #09131f; box-shadow: 0 30px 100px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(2,5,9,.72); backdrop-filter: blur(5px); }
dialog h2 { margin: 0; font-size: 2rem; }
dialog ul { margin: 22px 0 0; padding-left: 20px; color: var(--muted); line-height: 2; }
#help-close { position: absolute; right: 16px; top: 12px; border: 0; background: none; cursor: pointer; font-size: 1.6rem; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes scan { 0%,100% { transform: translateY(-16vh); opacity: 0; } 18%,82% { opacity: .7; } 50% { transform: translateY(47vh); } }

@media (max-width: 840px) {
  .topbar { height: 64px; grid-template-columns: 1fr auto; }
  .status { display: none; }
  .intro-panel { top: 90px; left: 20px; width: calc(100vw - 40px); transform: none; }
  .intro-panel h1 { font-size: clamp(2rem, 8vw, 3.1rem); letter-spacing: -.09em; }
  .intro-panel__body { display: none; }
  .control-panel { left: 14px; right: 14px; top: auto; bottom: 18px; width: auto; transform: none; padding: 11px; }
  .control-panel__head { display: none; }
  .segmented { margin: 0 0 8px; }
  .control-row { display: inline-flex; width: 19%; padding: 10px 4px; vertical-align: top; font-size: .7rem; }
  .control-row b, .control-icon { display: none; }
  .model-data, .drag-hint { display: none; }
  .pan-pad { right: 18px; bottom: 170px; transform: scale(.88); transform-origin: bottom right; }
  .viewer { inset: 64px 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
