:root {
  color-scheme: dark;
  --void: #02040d;
  --deep: #070b18;
  --panel: rgba(8, 13, 28, 0.82);
  --panel-strong: rgba(12, 18, 38, 0.94);
  --line: rgba(145, 224, 255, 0.18);
  --ink: #f6f8ff;
  --muted: #aeb8d8;
  --cyan: #56d8ff;
  --gold: #ffc86b;
  --pink: #ff7aa8;
  --green: #7cf2b0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 14%, rgba(86, 216, 255, 0.16), transparent 28%),
    radial-gradient(circle at 84% 6%, rgba(255, 200, 107, 0.12), transparent 24%),
    radial-gradient(circle at 54% 104%, rgba(255, 122, 168, 0.1), transparent 32%),
    linear-gradient(180deg, var(--deep), var(--void));
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(230px, 0.8fr) minmax(280px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px clamp(14px, 2.4vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(2, 4, 13, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  min-width: 0;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.logo-mark {
  position: relative;
  display: block;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background: #02040d;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 22px hsla(var(--mark-hue), 92%, 62%, 0.24);
}

.logo-mark::before {
  position: absolute;
  z-index: 2;
  content: "";
  background:
    radial-gradient(circle at 58% 56%, #fff 0 12%, transparent 13%),
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.38) 0 12%, transparent 13%),
    linear-gradient(145deg, hsl(var(--mark-hue), 92%, 70%), hsl(calc(var(--mark-hue) + 88), 88%, 55%));
}

.logo-mark::after {
  position: absolute;
  z-index: 1;
  content: "";
  border: 3px solid hsl(calc(var(--mark-hue) + 146), 86%, 74%);
  border-right-color: hsl(calc(var(--mark-hue) + 305), 92%, 72%);
  border-bottom-color: hsl(calc(var(--mark-hue) + 150), 88%, 76%);
  border-left-color: hsl(calc(var(--mark-hue) + 150), 88%, 76%);
  border-radius: 50%;
  transform: rotate(-18deg);
}

.mark-logmealpha::before {
  inset: 18% 22% 18% 22%;
  border-radius: 50%;
}

.mark-logmealpha::after {
  inset: 34% 5% 36%;
}

.mark-oldlogmealpha::before {
  inset: 17%;
  border-radius: 50%;
}

.mark-oldlogmealpha::after {
  inset: 35% 10% 35%;
  border-color: hsl(calc(var(--mark-hue) + 40), 78%, 82%);
}

.brand-logo {
  width: 44px;
  height: 44px;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-copy span,
.eyebrow,
.map-summary,
.project-title p,
.project-meta,
.signal-body p,
.signal-body dt,
.signal-body dd,
.project-nav-button small {
  color: var(--muted);
}

.search-box {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(86, 216, 255, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.search-icon {
  position: relative;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 2px solid var(--cyan);
  border-radius: 50%;
}

.search-icon::after {
  position: absolute;
  right: -6px;
  bottom: -4px;
  width: 7px;
  height: 2px;
  content: "";
  background: var(--cyan);
  border-radius: 999px;
  transform: rotate(45deg);
}

#searchInput {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

#searchInput::placeholder {
  color: rgba(174, 184, 216, 0.7);
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

select,
.ghost-button,
.open-project,
.signal-link {
  min-height: 40px;
  border: 1px solid rgba(86, 216, 255, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
}

select {
  padding: 0 34px 0 12px;
}

.ghost-button {
  padding: 0 14px;
  cursor: pointer;
}

.workspace {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 320px;
  gap: 16px;
  width: min(100%, 1840px);
  margin: 0 auto;
  padding: 16px clamp(12px, 1.8vw, 24px) 24px;
}

.panel,
.map-stage,
.project-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(16px);
}

.navigator,
.signal-panel {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 112px);
  overflow: auto;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid rgba(145, 224, 255, 0.13);
}

.panel-head h1,
.panel-head h2,
.project-title h2 {
  margin: 0;
}

.panel-head h1,
.panel-head h2 {
  font-size: 0.98rem;
}

.eyebrow {
  margin: 0 0 3px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.project-nav {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.project-nav-button {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.project-nav-button:hover,
.project-nav-button.is-active {
  border-color: rgba(86, 216, 255, 0.28);
  background: rgba(86, 216, 255, 0.08);
}

.nav-logo {
  width: 36px;
  height: 36px;
}

.project-nav-button span {
  display: grid;
  min-width: 0;
}

.project-nav-button strong,
.project-nav-button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-nav-button strong {
  font-size: 0.9rem;
}

.project-nav-button small {
  font-size: 0.74rem;
}

.map-stage {
  min-height: calc(100vh - 112px);
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    rgba(3, 6, 17, 0.7);
  background-size: 54px 54px;
}

.map-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 0.86rem;
}

.map-summary strong {
  color: var(--ink);
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 14px;
}

.project-card {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 16%, hsla(var(--project-hue), 90%, 62%, 0.13), transparent 32%),
    linear-gradient(180deg, rgba(12, 18, 38, 0.9), rgba(4, 7, 18, 0.86));
}

.project-card.is-large-graph {
  grid-column: span 2;
}

.project-card::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.5) 0 1px, transparent 1.5px);
  background-size: 48px 48px;
  opacity: 0.12;
}

.project-head,
.project-meta,
.subcluster-strip,
.folder-strip,
.orbit-space {
  position: relative;
  z-index: 1;
}

.project-head {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid rgba(145, 224, 255, 0.11);
}

.project-logo {
  width: 54px;
  height: 54px;
  box-shadow: 0 0 22px hsla(var(--project-hue), 90%, 62%, 0.24);
}

.project-title {
  min-width: 0;
}

.project-title h2 {
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-title p {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;
  font-size: 0.8rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.open-project,
.signal-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 14px 0;
  font-size: 0.78rem;
}

.subcluster-strip,
.folder-strip {
  display: flex;
  gap: 7px;
  overflow-x: auto;
}

.subcluster-strip {
  padding: 10px 14px 0;
}

.folder-strip {
  padding: 10px 14px 0;
}

.subcluster-chip,
.folder-chip {
  flex: 0 0 auto;
  max-width: 160px;
  min-height: 28px;
  overflow: hidden;
  padding: 0 10px;
  border: 1px solid rgba(145, 224, 255, 0.17);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subcluster-chip {
  border-color: hsla(var(--node-hue), 90%, 68%, 0.36);
  color: hsl(var(--node-hue), 90%, 78%);
  background: hsla(var(--node-hue), 90%, 52%, 0.08);
  font-weight: 800;
}

.folder-chip:hover,
.folder-chip.is-active,
.subcluster-chip:hover,
.subcluster-chip.is-active {
  border-color: hsla(var(--node-hue), 90%, 68%, 0.62);
  color: var(--ink);
}

.orbit-space {
  position: relative;
  height: 250px;
  margin: 12px;
  overflow: hidden;
  border: 1px solid rgba(145, 224, 255, 0.12);
  border-radius: 8px;
  background:
    radial-gradient(circle at center, hsla(var(--project-hue), 90%, 62%, 0.1), transparent 55%),
    rgba(0, 0, 0, 0.18);
}

.project-card.is-large-graph .orbit-space {
  height: 430px;
}

.orbit-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.folder-line {
  stroke: hsla(var(--line-hue), 90%, 70%, 0.18);
  stroke-width: 0.18;
}

.route-line {
  stroke: hsla(var(--line-hue), 90%, 74%, 0.38);
  stroke-width: 0.22;
}

.folder-node,
.file-star {
  position: absolute;
  transform: translate(-50%, -50%);
}

.folder-node {
  z-index: 4;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid hsla(var(--node-hue), 90%, 70%, 0.62);
  border-radius: 6px;
  background: rgba(12, 18, 38, 0.95);
  box-shadow: 0 0 16px hsla(var(--node-hue), 90%, 62%, 0.22);
  cursor: pointer;
}

.folder-node span {
  width: 8px;
  height: 6px;
  border-radius: 2px 2px 1px 1px;
  background: hsl(var(--node-hue), 90%, 70%);
}

.file-star {
  z-index: 5;
  width: 18px;
  height: 18px;
  color: hsl(var(--node-hue), 92%, 70%);
}

.file-star::before {
  position: absolute;
  inset: 50%;
  width: 7px;
  height: 7px;
  content: "";
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor, 0 0 25px hsla(var(--node-hue), 90%, 62%, 0.32);
  transform: translate(-50%, -50%);
  transition: transform 0.16s ease, filter 0.16s ease;
}

.file-star::after {
  position: absolute;
  inset: 50%;
  width: 15px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  opacity: 0.45;
  transform: translate(-50%, -50%) rotate(30deg);
}

.file-star.is-html::before {
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: var(--gold);
  clip-path: polygon(50% 0, 61% 36%, 98% 36%, 68% 58%, 80% 96%, 50% 73%, 20% 96%, 32% 58%, 2% 36%, 39% 36%);
}

.file-star.is-code::before,
.file-star.is-style::before {
  border-radius: 2px;
}

.file-star.is-image::before {
  border-radius: 2px;
  transform: translate(-50%, -50%) rotate(45deg);
}

.file-star:hover::before,
.file-star:focus-visible::before,
.file-star.is-selected::before {
  filter: brightness(1.25);
  transform: translate(-50%, -50%) scale(1.45);
}

.file-star.is-image:hover::before,
.file-star.is-image:focus-visible::before,
.file-star.is-image.is-selected::before {
  transform: translate(-50%, -50%) rotate(45deg) scale(1.45);
}

.signal-logo {
  width: 48px;
  height: 48px;
}

.signal-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.signal-body h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.15rem;
}

.signal-body p {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.signal-body dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.signal-body dl div {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(145, 224, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.signal-body dt {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.signal-body dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.signal-link {
  width: 100%;
  background: linear-gradient(135deg, rgba(86, 216, 255, 0.15), rgba(255, 200, 107, 0.1));
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .signal-panel {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar select,
  .toolbar button {
    flex: 1;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .navigator {
    position: static;
    max-height: none;
  }

  .project-nav {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }

  .project-card.is-large-graph {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  .map-grid {
    grid-template-columns: 1fr;
  }

  .project-head {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .project-logo {
    width: 46px;
    height: 46px;
  }

  .open-project {
    grid-column: 1 / -1;
  }

  .orbit-space {
    height: 230px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .file-star::before {
    animation: starPulse 3.8s ease-in-out infinite;
    animation-delay: var(--delay);
  }

  @keyframes starPulse {
    50% {
      opacity: 0.72;
    }
  }
}
