/* ============================================================
   幕狼星枢 · Mulang Starhub
   单屏 AI 模型星图 · 视觉系统
   ============================================================ */

/* Display face is embedded in css/font.css (data URI) so the page keeps its
   typography over file:// too; numerals fall back to the system mono stack. */

:root {
  /* ink scale — never pure black */
  --ink-0: #05070f;
  --ink-1: #080c18;
  --ink-2: #0d1324;
  --ink-3: #151c33;

  --line: rgba(255, 255, 255, .085);
  --line-2: rgba(255, 255, 255, .16);
  --glass: rgba(255, 255, 255, .038);
  --glass-2: rgba(255, 255, 255, .062);

  --text: #e9eef8;
  --text-2: #aab6cf;
  --text-3: #6f7d99;

  --accent: #4fe3c1;
  --accent-dim: rgba(79, 227, 193, .16);
  --accent-soft: rgba(79, 227, 193, .38);
  --amber: #f2a65a;

  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-soft: cubic-bezier(.34, 1.12, .64, 1);

  --font: 'Outfit', 'PingFang SC', 'HarmonyOS Sans SC', 'Microsoft YaHei', 'Source Han Sans SC', 'Noto Sans SC', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  --r-lg: 20px;
  --r-md: 13px;
  --r-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--ink-0);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- stage layers ---------- */

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}
#stage.is-dragging { cursor: grabbing; }

/* slow-drifting nebula wash, pure CSS, GPU friendly */
.sky {
  position: fixed;
  inset: -20%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(38% 34% at 22% 26%, rgba(59, 130, 246, .10), transparent 62%),
    radial-gradient(34% 30% at 78% 30%, rgba(79, 227, 193, .08), transparent 64%),
    radial-gradient(46% 40% at 62% 84%, rgba(139, 92, 246, .08), transparent 66%),
    radial-gradient(30% 28% at 12% 82%, rgba(242, 166, 90, .045), transparent 66%);
  filter: blur(38px) saturate(120%);
  animation: drift 46s var(--ease-out) infinite alternate;
  will-change: transform;
}
@keyframes drift {
  0%   { transform: translate3d(-1.5%, -1%, 0) scale(1.04) rotate(-1deg); }
  100% { transform: translate3d(2%, 1.8%, 0) scale(1.13) rotate(2deg); }
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(120% 92% at 50% 48%, transparent 42%, rgba(5, 7, 15, .62) 100%),
    linear-gradient(to bottom, rgba(5, 7, 15, .72) 0%, transparent 22%, transparent 74%, rgba(5, 7, 15, .82) 100%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: .05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- shared glass ---------- */

.hud, .rail, .card, .dockwrap {
  position: fixed;
  z-index: 6;
}

.hud-tl { top: clamp(14px, 2.4vh, 30px); left: clamp(14px, 2vw, 34px); }
.hud-tr { top: clamp(14px, 2.4vh, 30px); right: clamp(14px, 2vw, 34px); display: flex; align-items: center; gap: 10px; }

.brand { display: flex; align-items: flex-start; gap: 13px; }

.brand-mark {
  width: 42px; height: 42px;
  color: var(--accent);
  flex: none;
  margin-top: 2px;
  filter: drop-shadow(0 0 14px rgba(79, 227, 193, .38));
  animation: spin 64s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.brand-txt h1 {
  margin: 0;
  font-size: clamp(19px, 2vw, 25px);
  font-weight: 650;
  letter-spacing: -.028em;
  line-height: 1.08;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand-txt h1 .dot { color: var(--accent); font-weight: 400; }
.brand-txt h1 em {
  font-style: normal;
  font-size: .58em;
  font-weight: 500;
  letter-spacing: .17em;
  color: var(--text-3);
  text-transform: uppercase;
}
.brand-txt p {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: .012em;
  font-variant-numeric: tabular-nums;
}

.stats {
  display: flex;
  gap: 24px;
  margin: 17px 0 0 55px;
}
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat b {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 560;
  letter-spacing: -.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat span { font-size: 10.5px; color: var(--text-3); letter-spacing: .06em; }

/* ---------- search + controls ---------- */

/* 返回首页 —— 与搜索框共用同一套胶囊语言，排在它左边 */
.back-home {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px 0 11px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 12px 30px -18px rgba(0, 0, 0, .9);
  color: var(--text-2);
  font-size: 13px;
  letter-spacing: .01em;
  text-decoration: none;
  white-space: nowrap;
  transition: color .22s, border-color .22s, background .22s, transform .12s var(--ease-soft);
}
.back-home svg {
  width: 16px;
  height: 16px;
  flex: none;
  transition: transform .24s var(--ease-out);
}
.back-home:hover {
  color: var(--accent);
  border-color: var(--accent-soft);
  background: var(--glass-2);
}
.back-home:hover svg { transform: translateX(-2.5px); }
.back-home:active { transform: scale(.97); }

.search {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 9px 0 12px;
  min-width: 208px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 12px 30px -18px rgba(0, 0, 0, .9);
  transition: border-color .28s var(--ease-out), background .28s var(--ease-out), min-width .34s var(--ease-out);
}
.search:focus-within {
  border-color: var(--accent-soft);
  background: var(--glass-2);
  min-width: 264px;
}
.search svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.search:focus-within svg { color: var(--accent); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd, .dh-r kbd, .dock-item kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1.5px 5px;
  background: rgba(255, 255, 255, .04);
  line-height: 1.2;
}
.dh-r kbd { padding: 1px 4px; }

.ctl { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
  color: var(--text-2);
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s, transform .12s var(--ease-soft);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent-soft); background: var(--glass-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .i-play { display: none; }
.icon-btn[aria-pressed="true"] .i-pause { display: none; }
.icon-btn[aria-pressed="true"] .i-play { display: block; }

:where(button, input, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- left category rail ---------- */

.rail {
  left: clamp(14px, 2vw, 34px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px;
  border-radius: var(--r-lg);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 20px 44px -26px rgba(0, 0, 0, .95);
}
.chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 12px 6px 9px;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, color .2s;
}
.chip i {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex: none;
  background: currentColor;
  opacity: .55;
  transition: opacity .2s, box-shadow .2s;
}
.chip b {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.chip:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--accent-dim);
  color: var(--text);
}
.chip[aria-pressed="true"] i { opacity: 1; box-shadow: 0 0 10px 1px currentColor; }
.chip[aria-pressed="true"] b { color: var(--accent); }

/* ---------- model detail card ---------- */

.card {
  left: 0;
  top: 0;
  width: 322px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: rgba(10, 14, 28, .78);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 28px 60px -30px rgba(0, 0, 0, .98);
  padding: 13px 15px;
  opacity: 0;
  transform: translate3d(-9999px, -9999px, 0);
  transition: opacity .26s var(--ease-out);
  pointer-events: none;
  contain: layout style paint;
  will-change: transform;
}
.card.on { opacity: 1; }
.card-body { display: flex; flex-direction: column; gap: 11px; }
.card-body[hidden] { display: none; }
.cb-head { display: flex; align-items: flex-start; gap: 11px; }
.cb-icon {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 11px;
  background-color: rgba(255, 255, 255, .05);
  background-repeat: no-repeat;
  image-rendering: -webkit-optimize-contrast;
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
}
.cb-id { min-width: 0; }
.cb-name {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.cb-vendor {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 7px;
}
.tag {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .07em;
  padding: 1.5px 6px;
  border-radius: 999px;
  border: 1px solid currentColor;
  opacity: .9;
  text-transform: uppercase;
}
.cb-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.cb-cell { background: rgba(255, 255, 255, .028); padding: 7px 10px; }
.cb-cell span { display: block; font-size: 10px; color: var(--text-3); letter-spacing: .05em; }
.cb-cell b {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 520;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cb-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  color: var(--text-3);
}
.cb-path {
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.lockbadge { color: var(--accent); display: inline-flex; align-items: center; gap: 5px; flex: none; }

/* ---------- bottom dock ---------- */

.dockwrap {
  left: 50%;
  bottom: clamp(12px, 2.2vh, 26px);
  transform: translateX(-50%);
  width: min(880px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
}
.dock-head {
  width: 100%;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0 4px;
  font-size: 10.5px;
  letter-spacing: .1em;
  color: var(--text-3);
  text-transform: uppercase;
}
.dh-r { display: flex; align-items: center; gap: 4px; letter-spacing: .02em; text-transform: none; }

.dock {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
  padding: 6px;
  border-radius: var(--r-lg);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(24px) saturate(155%);
  -webkit-backdrop-filter: blur(24px) saturate(155%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 26px 56px -30px rgba(0, 0, 0, .98);
}
.dock-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px 8px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: none;
  color: var(--text-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .22s var(--ease-out), color .22s, border-color .22s, transform .12s var(--ease-soft);
}
.dock-item:hover { background: rgba(255, 255, 255, .052); color: var(--text); }
.dock-item:active { transform: scale(.977); }
.dock-item .dn { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 560; letter-spacing: -.01em; }
.dock-item .dn svg { width: 15px; height: 15px; flex: none; opacity: .85; }
.dock-item .dd { font-size: 10px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-item .dc {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .04em;
  color: var(--text-3);
}
.dock-item[aria-selected="true"] {
  background: linear-gradient(180deg, rgba(79, 227, 193, .17), rgba(79, 227, 193, .05));
  border-color: var(--accent-soft);
  color: var(--text);
}
.dock-item[aria-selected="true"] .dd,
.dock-item[aria-selected="true"] .dc { color: rgba(79, 227, 193, .72); }
.dock-item[aria-selected="true"] .dn svg { color: var(--accent); opacity: 1; }

.dock-foot {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 5px;
  min-height: 17px;
}
.hint { margin: 0; font-size: 11px; color: var(--text-3); }
.sync {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pulse {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(79, 227, 193, .6);
  animation: pulse 2.6s var(--ease-out) infinite;
  flex: none;
}
.pulse.stale { background: var(--amber); box-shadow: none; animation: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(79, 227, 193, .55); }
  70%  { box-shadow: 0 0 0 7px rgba(79, 227, 193, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 227, 193, 0); }
}
.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  border-bottom: 1px solid rgba(79, 227, 193, .3);
  transition: border-color .2s, opacity .2s;
}
.link-btn:hover { border-color: var(--accent); }
.link-btn[disabled] { opacity: .45; cursor: progress; }

/* ---------- boot overlay ---------- */

.boot {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 50% at 50% 50%, #0a1020 0%, #05070f 70%);
  transition: opacity .7s var(--ease-out), visibility .7s;
}
.boot.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.boot-mark { width: 64px; height: 64px; color: var(--accent); }
.boot-spin { transform-origin: 30px 30px; animation: spin 1.25s linear infinite; }
.boot-inner p { margin: 0; font-size: 12.5px; color: var(--text-3); letter-spacing: .06em; }

/* ---------- error / empty ---------- */

.err {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 15;
  max-width: 420px;
  padding: 22px 24px;
  border-radius: var(--r-lg);
  border: 1px solid rgba(242, 166, 90, .34);
  background: rgba(10, 14, 28, .9);
  backdrop-filter: blur(20px);
  text-align: center;
}
.err h2 { margin: 0 0 7px; font-size: 16px; font-weight: 600; }
.err p { margin: 0 0 15px; font-size: 12.5px; color: var(--text-2); line-height: 1.65; }
.err code { font-family: var(--mono); font-size: 11.5px; color: var(--amber); }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .card { width: 274px; }
  .rail { padding: 6px; }
  .chip { padding: 5px 9px; font-size: 11.5px; gap: 7px; }
  .chip b { display: none; }
}

@media (max-width: 860px) {
  .stats { margin-left: 0; gap: 15px; }
  .stat b { font-size: 16px; }
  .brand-txt h1 .dot { display: none; }
  .brand-txt p { max-width: 52vw; }
  /* 窄屏和搜索框一起收成图标按钮，省出横向空间 */
  .back-home { width: 38px; padding: 0; justify-content: center; }
  .back-home span { display: none; }
  .hud-tr { gap: 7px; }
  .hud-tl, .hud-tr { top: 12px; }
  .hud-tl { left: 12px; }
  .hud-tr { right: 12px; }
  .rail {
    top: auto;
    left: 50%;
    bottom: 232px;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 2px;
    max-width: calc(100vw - 28px);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  .chip { padding: 6px 11px; font-size: 0; gap: 0; }
  .chip i { width: 8px; height: 8px; }
  .card { width: min(268px, 74vw); padding: 11px 12px; }
  .card .cb-icon { width: 34px; height: 34px; }
  .card .cb-name { font-size: 14px; }
  .dock { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dock-item .dd { display: none; }
  .dock-head { display: none; }
  .search { min-width: 0; width: 38px; padding: 0; justify-content: center; }
  .search input, .search kbd { display: none; }
  .search:focus-within { width: 190px; padding: 0 9px 0 12px; justify-content: flex-start; }
  .search:focus-within input { display: block; }
  .brand-txt h1 em { display: none; }
  .dock-foot .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sky, .brand-mark, .boot-spin, .pulse { animation: none !important; }
  * { transition-duration: .01ms !important; }
}
