/* ==========================================================================
   azclient.top / Spatial Knowledge Cosmos & Multi-Window Blog
   60fps Interactive Graph / Split-Pane Reader / Native Touch Experience
   ========================================================================== */

:root {
  --bg: #07080b;
  --surface: #101218;
  --surface-2: #171b24;
  --surface-3: #222836;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  --ink: #f4f6fa;
  --ink-2: #c9d0dc;
  --muted: #828b9c;

  --c-hub: #f4f6fa;
  --c-work: #e5e7eb;
  --c-ai: #2ee59d;
  --c-sec: #f5a623;
  --c-eng: #60a5fa;

  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --r: 8px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

::selection {
  background: var(--c-ai);
  color: #062115;
}

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

button, input {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--c-ai);
  outline-offset: 2px;
}

/* ---------- Fullscreen Spatial Canvas ---------- */
.cosmos-stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  background: var(--bg);
}

#cosmosCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#cosmosCanvas.is-grabbing {
  cursor: grabbing;
}

#cosmosCanvas.is-hovering {
  cursor: pointer;
}

/* ---------- Floating Top HUD ---------- */
.hud-top {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--r);
  background: rgba(16, 18, 24, 0.88);
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.hud-brand span {
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
}

.mode-switch {
  display: inline-flex;
  background: rgba(16, 18, 24, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 3px;
  gap: 3px;
}

.mode-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 5px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  transition: background-color 180ms ease, color 180ms ease;
}

.mode-btn.is-active {
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}

.hud-btn {
  height: 44px;
  padding: 0 14px;
  border-radius: var(--r);
  background: rgba(16, 18, 24, 0.88);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms var(--ease);
}

.hud-btn:active {
  transform: scale(0.97);
}

.hud-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
}

.hud-btn.accent {
  background: var(--c-ai);
  border-color: var(--c-ai);
  color: #062115;
  font-weight: 600;
}

.hud-btn.accent:hover {
  background: #5bf0b3;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

/* ---------- Corner Hint ---------- */
.hud-hint {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: 300px;
  padding: 12px 15px;
  border-radius: var(--r);
  background: rgba(16, 18, 24, 0.82);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
  pointer-events: none;
  transition: opacity 240ms ease;
}

.hud-hint strong {
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--ink-2);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ---------- Floating Bottom Dock ---------- */
.hud-dock {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 10px;
  background: rgba(16, 18, 24, 0.92);
  border: 1px solid var(--line-strong);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  scrollbar-width: none;
}

.hud-dock::-webkit-scrollbar {
  display: none;
}

.dock-filter {
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 160ms ease, color 160ms ease;
}

.dock-filter:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.dock-filter.is-active {
  background: var(--surface-3);
  color: var(--ink);
  font-weight: 600;
}

.dock-sep {
  width: 1px;
  height: 20px;
  background: var(--line);
  flex-shrink: 0;
}

.dock-icon {
  height: 36px;
  padding: 0 11px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
}

.dock-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

/* ---------- Hover Node Preview Card ---------- */
.hover-card {
  position: fixed;
  z-index: 35;
  width: 280px;
  padding: 14px;
  border-radius: var(--r);
  background: rgba(16, 18, 24, 0.95);
  border: 1px solid var(--line-strong);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: opacity 150ms ease, transform 180ms var(--ease);
}

.hover-card.is-show {
  opacity: 1;
  transform: none;
}

.hover-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top center;
  border-radius: 5px;
  margin-bottom: 10px;
}

.hover-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.hover-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 6px;
}

.hover-desc {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* ---------- Multi-Window Slide-Over Reader Stack ---------- */
.reader-stack {
  position: fixed;
  top: 72px;
  right: 16px;
  bottom: 76px;
  z-index: 40;
  display: flex;
  gap: 12px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

.reader-win {
  width: min(560px, calc(100vw - 32px));
  height: 100%;
  background: rgba(14, 16, 22, 0.96);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.78);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  animation: win-in 320ms var(--ease) both;
}

@keyframes win-in {
  from {
    opacity: 0;
    transform: translateX(36px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.win-bar {
  flex-shrink: 0;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.win-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.win-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.win-tool {
  height: 32px;
  padding: 0 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12.5px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
}

.win-tool:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--ink);
}

.win-progress {
  height: 2px;
  background: transparent;
  width: 100%;
  flex-shrink: 0;
}

.win-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--c-ai);
  transition: width 80ms linear;
}

.win-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 26px 28px 40px;
  -webkit-overflow-scrolling: touch;
}

.win-h1 {
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 700;
  line-height: 1.24;
  letter-spacing: -0.025em;
  margin-bottom: 10px;
}

.win-sub {
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 20px;
}

.win-ext-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}

.pill-btn:hover {
  background: var(--surface-3);
}

.pill-btn.accent {
  background: var(--c-ai);
  border-color: var(--c-ai);
  color: #062115;
  font-weight: 600;
}

.win-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* Reader Prose */
.win-prose {
  font-size: 16px;
  line-height: 1.78;
  color: var(--ink-2);
}

.win-prose h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin: 30px 0 12px;
}

.win-prose h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin: 22px 0 10px;
}

.win-prose p {
  margin: 14px 0;
}

.win-prose ul, .win-prose ol {
  margin: 14px 0 14px 20px;
}

.win-prose li {
  margin: 6px 0;
}

.win-prose a {
  color: var(--c-ai);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.win-prose blockquote,
.win-prose .callout {
  margin: 18px 0;
  padding: 14px 18px;
  background: var(--surface-2);
  border-left: 3px solid var(--c-ai);
  border-radius: 4px;
  color: var(--ink);
}

.win-prose code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink);
}

.win-prose pre {
  position: relative;
  margin: 18px 0;
  padding: 16px;
  background: #08090d;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  color: #dce3ee;
}

.win-prose pre code {
  background: none;
  padding: 0;
}

.win-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
}

.win-prose th, .win-prose td {
  border: 1px solid var(--line-strong);
  padding: 8px 10px;
  text-align: left;
}

.win-prose th {
  background: var(--surface-2);
  color: var(--ink);
}

.win-figure {
  margin: 18px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.win-figure img {
  width: 100%;
  display: block;
}

.copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 28px;
  padding: 0 9px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 12px;
}

.copy-code:hover {
  background: var(--c-ai);
  color: #062115;
}

/* Connected Graph Neighbors inside Reader */
.related-box {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.related-head {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.related-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rel-chip {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.rel-chip:hover {
  background: var(--surface-3);
  border-color: var(--line-strong);
}

/* ---------- Classic Directory View Overlay ---------- */
.dir-view {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: var(--bg);
  overflow-y: auto;
  padding: 92px 24px 104px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 260ms ease, transform 280ms var(--ease);
}

.dir-view.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.dir-wrap {
  max-width: 920px;
  margin: 0 auto;
}

.dir-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.dir-sub {
  color: var(--muted);
  margin-bottom: 28px;
}

.dir-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dir-item {
  width: 100%;
  text-align: left;
  padding: 18px 20px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms var(--ease);
}

.dir-item:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  transform: translateX(4px);
}

.dir-item-title {
  font-size: 16.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dir-item-desc {
  font-size: 13.5px;
  color: var(--muted);
}

.dir-item-meta {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Command Search Modal ---------- */
.cmd-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(4, 5, 8, 0.76);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.cmd-mask.is-open {
  opacity: 1;
  pointer-events: auto;
}

.cmd-box {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  transform: scale(0.97) translateY(-8px);
  transition: transform 200ms var(--ease);
}

.cmd-mask.is-open .cmd-box {
  transform: none;
}

.cmd-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.cmd-head input {
  flex: 1;
  font-size: 15.5px;
  outline: none;
}

.cmd-results {
  max-height: 52vh;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmd-row {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  font-size: 14.5px;
  color: var(--ink-2);
}

.cmd-row.is-sel,
.cmd-row:hover {
  background: var(--c-ai);
  color: #062115;
}

.cmd-row span:last-child {
  font-size: 12px;
  opacity: 0.72;
  white-space: nowrap;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translate(-50%, -10px);
  z-index: 95;
  padding: 10px 18px;
  border-radius: 6px;
  background: var(--c-ai);
  color: #062115;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 200ms var(--ease);
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Mobile Native Adaptation (<= 760px) ---------- */
.hud-brand,
.mode-btn,
.hud-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 760px) {
  .hud-top {
    top: 10px;
    left: 10px;
    right: 10px;
    gap: 6px;
  }

  .hud-brand {
    height: 40px;
    padding: 0 11px;
    font-size: 14px;
  }

  .hud-brand span,
  .hud-btn .kbd,
  .hud-btn .hide-sm,
  .mode-btn .hide-sm,
  .hud-hint,
  .hover-card {
    display: none;
  }

  .mode-btn {
    height: 32px;
    padding: 0 11px;
    font-size: 13px;
  }

  .hud-btn {
    height: 40px;
    padding: 0 11px;
    font-size: 13px;
  }

  .hud-dock {
    bottom: 12px;
    padding: 4px;
  }

  /* Bottom Sheet Reader on Phone */
  .reader-stack {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    height: 86dvh;
    max-width: 100vw;
    gap: 0;
  }

  .reader-win {
    width: 100vw;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    animation: sheet-up 300ms var(--ease) both;
  }

  @keyframes sheet-up {
    from { transform: translateY(100%); }
    to { transform: none; }
  }

  .win-scroll {
    padding: 20px 18px 36px;
  }

  .dir-item {
    flex-direction: column;
    gap: 6px;
  }
}
