:root {
  /* 全局色彩与字体变量 */
  color-scheme: dark;
  --bg: #05070f;
  --panel: rgba(13, 18, 34, 0.72);
  --line: rgba(190, 220, 255, 0.18);
  --text: #f4f7fb;
  --muted: #a7b4c6;
  --cyan: #49d6ff;
  --violet: #b46cff;
  --blue: #4c8dff;
  --red: #ff6b8d;
  --yellow: #ffd166;
  --green: #68e08d;
  --orange: #ff9f45;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 24%, rgba(73, 214, 255, 0.16), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(255, 107, 141, 0.12), transparent 26%),
    radial-gradient(circle at 50% 92%, rgba(104, 224, 141, 0.10), transparent 32%),
    linear-gradient(135deg, #03040a 0%, #0b1020 48%, #060812 100%);
  color: var(--text);
}

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
  font-weight: 800;
}

.date-chip,
.quick-links button,
.node-actions button,
.editor button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  backdrop-filter: blur(14px);
}

.date-chip {
  border-radius: 999px;
  padding: 10px 14px;
  color: #d9e7ff;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 270px minmax(420px, 1fr) 330px;
  gap: 22px;
  align-items: stretch;
  min-height: calc(100vh - 148px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32), inset 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}

.hud {
  align-self: center;
  padding: 22px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(31, 51, 81, 0.22), rgba(12, 18, 37, 0.92) 48%),
    var(--panel);
}

.snapshot-list {
  display: grid;
  gap: 8px;
  margin: 18px 0 14px;
}

.snapshot-list section {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(146, 183, 226, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.snapshot-list section:last-child {
  padding-bottom: 12px;
}

.snapshot-list span {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
}

.snapshot-list strong {
  color: #f7fbff;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 650;
}

.hud-note {
  margin: 16px 0 0;
  border: 1px solid rgba(73, 214, 255, 0.18);
  border-left: 3px solid var(--cyan);
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  background: rgba(73, 214, 255, 0.055);
  color: #d9e7ff;
  font-size: 14px;
  line-height: 1.6;
}

.hud-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(146, 183, 226, 0.16);
}

.avatar {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(73, 214, 255, 0.16);
  box-shadow: 0 0 28px rgba(73, 214, 255, 0.35);
}

.hud h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.18;
}

.hud-intro {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

dl {
  display: grid;
  gap: 14px;
  margin: 20px 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

dt,
.muted {
  color: var(--muted);
}

dd {
  margin: 0;
  color: #ffffff;
  font-weight: 700;
}

.mini-meter span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.meter,
.mini-meter div {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
}

.meter i,
.mini-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  box-shadow: 0 0 18px rgba(73, 214, 255, 0.5);
}

.map {
  position: relative;
  min-height: 580px;
  height: calc(100vh - 148px);
  max-height: 760px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: radial-gradient(circle at center, rgba(73, 214, 255, 0.12), transparent 34%);
  overflow: hidden;
}

.map-head {
  position: absolute;
  top: 18px;
  left: 24px;
  right: 24px;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.map-title {
  margin-bottom: 5px;
  color: #e6f4ff;
  font-size: 20px;
  font-weight: 700;
}

.map-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.breadcrumbs button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #d9e7ff;
}

.orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid rgba(180, 215, 255, 0.12);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: drift 18s linear infinite;
}

.orbit-one {
  width: min(52vw, 520px);
  height: min(52vw, 520px);
}

.orbit-two {
  width: min(40vw, 400px);
  height: min(40vw, 400px);
  animation-duration: 24s;
  animation-direction: reverse;
}

.orbit-three {
  width: min(26vw, 260px);
  height: min(26vw, 260px);
  animation-duration: 14s;
}

.links,
.node-layer {
  position: absolute;
  inset: 0;
}

.links {
  z-index: 1;
}

.links span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--length);
  height: 1px;
  transform-origin: 0 50%;
  transform: rotate(var(--angle));
  background: linear-gradient(90deg, rgba(73, 214, 255, 0.58), transparent);
}

.node-layer {
  z-index: 2;
}

.node {
  --node: var(--cyan);
  position: absolute;
  top: var(--top);
  left: var(--left);
  display: grid;
  place-items: center;
  gap: 4px;
  width: var(--size);
  height: var(--size);
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--node);
  background: color-mix(in srgb, var(--node) 15%, rgba(8, 12, 26, 0.76));
  box-shadow: 0 0 26px color-mix(in srgb, var(--node) 46%, transparent);
  transform: translate(-50%, -50%);
  transition: top 260ms ease, left 260ms ease, transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.node:hover,
.node.active {
  transform: translate(-50%, -50%) scale(1.08);
  background: color-mix(in srgb, var(--node) 28%, rgba(8, 12, 26, 0.86));
  box-shadow: 0 0 38px color-mix(in srgb, var(--node) 72%, transparent);
}

.node.parent {
  opacity: 0.76;
  border-style: dashed;
}

.node.empty {
  opacity: 0.72;
}

.node span {
  font-size: clamp(18px, 2.1vw, 28px);
}

.node strong {
  max-width: 82%;
  overflow: hidden;
  font-size: 14px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node em {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  min-width: 21px;
  height: 21px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.node.core strong {
  display: -webkit-box;
  font-size: 21px;
  line-height: 1.18;
  white-space: normal;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.node.core span {
  font-size: 36px;
}

.quick-links {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 5;
  display: flex;
  gap: 10px;
  transform: translateX(-50%);
}

.quick-links button,
.node-actions button,
.editor button {
  min-height: 40px;
  border-radius: 999px;
  padding: 0 16px;
}

.detail {
  align-self: center;
  padding: 20px;
}

.detail-top {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail h2 {
  margin-bottom: 0;
  font-size: 25px;
}

#detail-body {
  display: grid;
  gap: 14px;
  min-height: 260px;
  max-height: calc(100vh - 390px);
  overflow: auto;
  padding: 18px 4px 18px 0;
}

.archive-section {
  display: grid;
  gap: 8px;
}

.archive-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.archive-section p {
  margin-bottom: 0;
  color: #ffffff;
  font-size: 15px;
  line-height: 1.55;
}

.level-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stars {
  color: var(--yellow);
  font-size: 19px;
  letter-spacing: 0;
  text-shadow: 0 0 16px rgba(255, 209, 102, 0.45);
}

.chip-list,
.timeline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip-list li {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #eaf2ff;
}

.timeline-list {
  display: grid;
}

.timeline-list li {
  border-left: 1px solid rgba(73, 214, 255, 0.46);
  padding: 0 0 16px 14px;
}

.timeline-list strong {
  display: block;
  margin-bottom: 4px;
  color: #fff;
}

.timeline-list span {
  display: block;
  margin-bottom: 6px;
  color: var(--cyan);
  font-size: 13px;
}

.timeline-list p {
  margin: 0 0 10px;
  color: #dbe6f4;
  line-height: 1.5;
}

.reflection-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(73, 214, 255, 0.22);
  border-radius: 10px;
  background: rgba(73, 214, 255, 0.06);
}

.reflection-editor p,
.empty-copy {
  margin: 0;
  color: #dbe6f4;
  font-size: 14px;
  line-height: 1.6;
}

.reflection-editor textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: rgba(5, 10, 24, 0.5);
  color: #fff;
  font: inherit;
  line-height: 1.6;
  resize: vertical;
}

.reflection-editor button {
  border: 1px solid rgba(73, 214, 255, 0.48);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(73, 214, 255, 0.15);
  color: #f3fbff;
  cursor: pointer;
}

.reflection-history {
  margin-top: 20px;
}

.reflection-history h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: #f3f8ff;
}

.ai-analysis {
  border: 1px solid rgba(73, 214, 255, 0.28);
  border-radius: 8px;
  padding: 12px;
  background: rgba(73, 214, 255, 0.08);
}

.meta p {
  color: var(--muted);
  font-size: 13px;
}

.node-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.node-actions button:last-child {
  grid-column: 1 / -1;
}

.editor {
  width: min(560px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 14, 28, 0.96);
  color: var(--text);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.5);
}

.editor::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(6px);
}

.editor form {
  display: grid;
  gap: 14px;
}

.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  font-size: 24px;
}

.editor label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.editor input,
.editor textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  resize: vertical;
}

.editor menu {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 4px 0 0;
  padding: 0;
}

@keyframes drift {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

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

  .hud,
  .detail {
    align-self: stretch;
  }

  .hud {
    order: 2;
  }

  .detail {
    order: 3;
  }

  .map {
    height: auto;
    min-height: 620px;
  }
}

@media (max-width: 680px) {
  body {
    min-width: 0;
  }

  .shell {
    padding: max(16px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
  }

  .topbar,
  .map-head {
    display: grid;
    gap: 12px;
  }

  .topbar {
    align-items: start;
  }

  h1 {
    font-size: clamp(30px, 10vw, 40px);
    letter-spacing: -0.04em;
  }

  .date-chip {
    width: fit-content;
    padding: 8px 12px;
    font-size: 13px;
  }

  .workspace {
    gap: 14px;
    min-height: 0;
  }

  /* 手机上先保留最核心的星图，再依次展示状态和详细档案。 */
  .map {
    order: 1;
    min-height: 535px;
    height: min(76vh, 620px);
    max-height: none;
    border-radius: 14px;
  }

  .hud {
    order: 2;
    padding: 18px;
    border-radius: 14px;
  }

  .detail {
    order: 3;
    min-height: 0;
    border-radius: 14px;
  }

  .map-head {
    padding: 16px 16px 0;
  }

  .map-title {
    font-size: 19px;
  }

  .map-subtitle {
    max-width: 260px;
    font-size: 12px;
    line-height: 1.5;
  }

  .breadcrumbs {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: none;
  }

  .breadcrumbs::-webkit-scrollbar {
    display: none;
  }

  .node {
    --size: 94px !important;
  }

  .node.core {
    --size: 106px !important;
  }

  .node span {
    font-size: 25px;
  }

  .node strong {
    font-size: 13px;
  }

  .node em {
    right: 4px;
    bottom: 4px;
  }

  .orbit-one {
    width: min(82%, 390px);
    height: min(82%, 390px);
  }

  .orbit-two {
    width: min(64%, 300px);
    height: min(64%, 300px);
  }

  .orbit-three {
    width: min(45%, 215px);
    height: min(45%, 215px);
  }

  .breadcrumbs {
    justify-content: flex-start;
  }

  .quick-links {
    bottom: 14px;
    width: calc(100% - 24px);
    justify-content: center;
  }

  .quick-links button {
    min-width: 108px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .hud h2 {
    font-size: 24px;
  }

  .snapshot-list strong {
    font-size: 14px;
  }

  .detail-top,
  .node-actions {
    padding-left: 16px;
    padding-right: 16px;
  }

  #detail-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .reflection-editor {
    padding: 12px;
  }

  .node-actions {
    grid-template-columns: 1fr;
  }

  .node-actions button:last-child {
    grid-column: auto;
  }
}
