:root {
  --bg: #0a0e18;
  --bg-2: #111727;
  --panel: rgba(20, 26, 42, 0.92);
  --panel-solid: #141a2a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eaf0;
  --muted: #8f97ab;
  --faint: #5d667c;
  --gold: #f5c451;
  --gold-2: #ffdf8a;
  --gold-deep: #c98a1b;
  --gap: #9b86ff;
  --ok: #6fd3a5;
  --bad: #ff8a80;
  --radius: 14px;
  --font: "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 380px at 50% 52%, rgba(245, 196, 81, 0.09), transparent 70%),
    linear-gradient(180deg, #070a12 0%, var(--bg) 45%, #0d1220 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }

.hidden { display: none !important; }

/* top bar */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 10, 18, 0.7);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 12px; white-space: nowrap; }
.logo {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 4px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 60%, var(--gold-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.slogan { color: var(--muted); font-size: 13px; letter-spacing: 2px; }

.tabs { display: flex; gap: 4px; background: rgba(255,255,255,0.04); padding: 4px; border-radius: 10px; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 14px; border-radius: 7px; font-size: 14px;
}
.tab.active { background: rgba(245, 196, 81, 0.14); color: var(--gold-2); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.mastery { width: 170px; margin-right: 6px; }
.mastery-row { display: flex; align-items: baseline; justify-content: space-between; }
.mastery-pct { font-size: 18px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.mastery-row small { color: var(--muted); font-size: 12px; }
.mastery-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,0.08); margin-top: 4px; overflow: hidden; }
.mastery-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-deep), var(--gold-2)); transition: width .8s ease; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  transition: background .2s, border-color .2s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #241900; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: rgba(255,255,255,0.04); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: rgba(255,255,255,0.08); }
.btn.link { background: none; border: 0; color: var(--muted); padding: 6px 4px; }
.btn.link:hover { color: var(--text); }
.btn.block { width: 100%; }

/* map view */
main { height: calc(100% - 64px); position: relative; }
.view { position: absolute; inset: 0; }
.map-wrap { position: absolute; inset: 0; padding: 12px 24px 44px 24px; }
#map { width: 100%; height: 100%; display: block; overflow: visible; }

#map .node { cursor: pointer; outline: none; }
#map .node:focus-visible .core { stroke: #fff; stroke-width: 3; }
#map .node:hover .core { filter: brightness(1.25); }
#map .node.next .ring-next {
  transform-box: fill-box; transform-origin: center;
  animation: pulse 2.2s ease-out infinite;
}
#map .node.just-lit .burst {
  transform-box: fill-box; transform-origin: center;
  animation: burst 1.3s ease-out forwards;
}
#map .node.just-lit .core { animation: litpop .9s ease-out; transform-box: fill-box; transform-origin: center; }
#map .node.probing .core { stroke: #fff; stroke-width: 3; }
#map .edge { transition: stroke .6s, opacity .6s; }

@keyframes pulse {
  0% { transform: scale(1); opacity: .9; }
  100% { transform: scale(1.7); opacity: 0; }
}
@keyframes burst {
  0% { transform: scale(.8); opacity: 1; }
  100% { transform: scale(3.2); opacity: 0; }
}
@keyframes litpop {
  0% { transform: scale(1); }
  40% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.legend {
  position: absolute; left: 24px; bottom: 12px;
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  font-size: 12px; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.lit { background: radial-gradient(circle at 35% 35%, var(--gold-2), var(--gold) 55%, var(--gold-deep)); box-shadow: 0 0 8px rgba(245,196,81,.7); }
.dot.glimmer { border: 2px dashed var(--gold); background: rgba(245,196,81,.12); }
.dot.gap { border: 2px dotted var(--gap); background: rgba(155,134,255,.12); }
.dot.dark { background: #1d2333; border: 1.5px solid #3a4258; }
.dot.next { border: 2px solid #fff; background: transparent; }

/* next card */
.next-card {
  position: absolute; top: 16px; left: 24px; z-index: 3;
  width: 290px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.next-card h3 { margin: 0 0 4px; font-size: 14px; color: var(--gold-2); font-weight: 600; letter-spacing: 1px; }
.next-card p { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.next-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.next-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,.03);
  border-radius: 10px; padding: 8px 10px; text-align: left; font-size: 13.5px;
}
.next-item:hover { border-color: rgba(245,196,81,.4); background: rgba(245,196,81,.06); }
.next-item small { display: block; color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.next-item .dot { flex: none; }
.line-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.line-stat { background: rgba(255,255,255,.03); border-radius: 8px; padding: 6px 8px; }
.line-stat b { display: block; font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; }
.line-stat span { font-size: 11px; color: var(--faint); }
.report-mini { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.report-mini b { font-size: 13px; color: var(--text); }

/* drawer */
.drawer {
  position: fixed; top: 64px; right: 0; bottom: 0; z-index: 8;
  width: min(460px, 100%);
  background: var(--panel-solid);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(0,0,0,.45);
  transform: translateX(105%);
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto;
  padding: 22px 24px 40px;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; }
.drawer-head h2 { margin: 6px 0 0; font-family: var(--serif); font-size: 26px; letter-spacing: 1px; }
.drawer-close { margin-left: auto; border: 0; background: rgba(255,255,255,.06); width: 32px; height: 32px; border-radius: 8px; font-size: 18px; color: var(--muted); }
.tag { display: inline-block; font-size: 11.5px; padding: 3px 8px; border-radius: 6px; background: rgba(255,255,255,.06); color: var(--muted); margin-right: 6px; }
.tag.lit { background: rgba(245,196,81,.16); color: var(--gold-2); }
.tag.glimmer { background: rgba(245,196,81,.08); color: var(--gold); border: 1px dashed rgba(245,196,81,.5); }
.tag.gap { background: rgba(155,134,255,.12); color: #c3b6ff; }
.summary { color: #cfd3dd; line-height: 1.8; font-size: 15px; margin: 14px 0 18px; }
.section-title { font-size: 12px; color: var(--faint); letter-spacing: 1px; margin: 18px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: rgba(255,255,255,.03);
  border-radius: 999px; padding: 4px 10px 4px 8px; font-size: 12.5px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: rgba(255,255,255,.2); }
.chip .dot { width: 9px; height: 9px; }
.notice {
  font-size: 13px; line-height: 1.6; color: #d8cdfc;
  background: rgba(155,134,255,.08); border: 1px solid rgba(155,134,255,.25);
  border-radius: 10px; padding: 10px 12px; margin: 14px 0;
}
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.keypoints { margin: 0; padding-left: 18px; color: #cfd3dd; line-height: 1.8; font-size: 14px; }

.q-block { margin-top: 18px; }
.q-label { font-size: 12px; color: var(--gold); letter-spacing: 1px; margin-bottom: 6px; }
.q-prompt { font-size: 15px; line-height: 1.75; margin-bottom: 10px; }
textarea {
  width: 100%; min-height: 110px; resize: vertical;
  background: #0c111d; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; font-size: 14px; line-height: 1.7;
}
textarea:focus { outline: none; border-color: rgba(245,196,81,.5); }
.hint { font-size: 12px; color: var(--faint); margin-top: 6px; }

.result-head { display: flex; align-items: center; gap: 14px; margin: 18px 0 6px; }
.score-ring { width: 64px; height: 64px; flex: none; }
.result-head h3 { margin: 0; font-size: 18px; }
.result-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.feedback {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px;
  background: rgba(255,255,255,.02);
}
.feedback .fb-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); margin-bottom: 6px; }
.feedback .fb-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.feedback p { margin: 0; font-size: 13.5px; line-height: 1.7; color: #cfd3dd; }
.missing { margin: 8px 0 0; padding-left: 16px; font-size: 12.5px; color: #c3b6ff; line-height: 1.7; }

.card-learn {
  margin-top: 18px; border-radius: 12px; padding: 16px;
  background: linear-gradient(180deg, rgba(245,196,81,.07), rgba(245,196,81,.02));
  border: 1px solid rgba(245,196,81,.2);
}
.card-learn .one { font-family: var(--serif); font-size: 17px; line-height: 1.7; color: var(--gold-2); margin: 0 0 10px; }
.card-learn p { margin: 0 0 10px; font-size: 14px; line-height: 1.8; color: #d6d9e2; }
.card-learn .label { font-size: 12px; color: var(--gold); letter-spacing: 1px; margin: 12px 0 4px; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 18px 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(245,196,81,.2); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { color: var(--bad); font-size: 13px; margin-top: 10px; }

/* modal */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 12, .72); backdrop-filter: blur(4px);
  padding: 20px;
}
.modal.docked { background: transparent; backdrop-filter: none; justify-content: flex-start; align-items: flex-start; padding: 80px 24px 24px; pointer-events: none; }
.modal.docked .modal-card { pointer-events: auto; width: 400px; }
.modal-card {
  width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.intro { text-align: center; padding: 10px 6px; }
.intro .horizon-art { height: 90px; margin: 0 auto 10px; width: 260px; }
.intro h1 { font-family: var(--serif); font-size: 40px; letter-spacing: 8px; margin: 0; }
.intro h1 span { background: linear-gradient(180deg, var(--gold-2), var(--gold) 60%, var(--gold-deep)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.intro .tagline { color: var(--gold); letter-spacing: 4px; margin: 8px 0 22px; font-size: 14px; }
.intro p { color: #c5cad6; line-height: 1.9; font-size: 15px; margin: 0 0 10px; }
.intro .loop { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px 0 24px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.intro .loop b { color: var(--text); font-weight: 500; background: rgba(255,255,255,.05); border-radius: 8px; padding: 6px 10px; }
.intro .loop i { font-style: normal; color: var(--gold); }
.intro .actions { justify-content: center; }

.dx-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.dx-progress { height: 3px; background: rgba(255,255,255,.08); border-radius: 3px; margin: 10px 0 18px; overflow: hidden; }
.dx-progress i { display: block; height: 100%; background: var(--gold); transition: width .4s; }
.dx-q { font-size: 17px; line-height: 1.7; margin: 8px 0 16px; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.03);
  border-radius: 10px; padding: 11px 14px; font-size: 14.5px; line-height: 1.55;
  display: flex; gap: 10px;
}
.option:hover:not(:disabled) { border-color: rgba(245,196,81,.45); background: rgba(245,196,81,.05); }
.option .k { color: var(--faint); font-variant-numeric: tabular-nums; }
.option.unsure { color: var(--muted); border-style: dashed; }
.option.correct { border-color: var(--ok); background: rgba(111,211,165,.08); }
.option.wrong { border-color: var(--bad); background: rgba(255,138,128,.08); }
.option:disabled { cursor: default; }
.dx-why { margin-top: 14px; font-size: 13.5px; line-height: 1.7; color: #cfd3dd; background: rgba(255,255,255,.03); border-radius: 10px; padding: 12px; }
.dx-why b { display: block; margin-bottom: 4px; }
.dx-why b.ok { color: var(--ok); }
.dx-why b.no { color: #c3b6ff; }
.dx-infer { font-size: 12px; color: var(--faint); margin-top: 8px; }

.report h2 { font-family: var(--serif); font-size: 26px; margin: 4px 0 6px; color: var(--gold-2); letter-spacing: 1px; }
.report .stats { display: flex; gap: 10px; margin: 14px 0; }
.report .stat { flex: 1; background: rgba(255,255,255,.03); border-radius: 10px; padding: 10px; text-align: center; }
.report .stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.report .stat span { font-size: 12px; color: var(--muted); }
.report .block { margin: 14px 0; }
.report .block .label { font-size: 12px; letter-spacing: 1px; margin-bottom: 4px; }
.report .block p { margin: 0; line-height: 1.8; font-size: 14.5px; color: #d6d9e2; }
.label.gold { color: var(--gold); }
.label.violet { color: #c3b6ff; }
.label.white { color: #fff; }

/* horizon view */
#viewHorizon { overflow-y: auto; padding: 36px 40px 60px; }
.hz-head { max-width: 1080px; margin: 0 auto 28px; display: flex; align-items: flex-end; gap: 30px; flex-wrap: wrap; }
.hz-head h1 { font-family: var(--serif); font-size: 34px; margin: 0; letter-spacing: 4px; }
.hz-head p { color: var(--muted); margin: 8px 0 0; line-height: 1.7; }
.hz-total { margin-left: auto; text-align: right; }
.hz-total b { font-size: 40px; color: var(--gold); font-variant-numeric: tabular-nums; }
.hz-total span { display: block; color: var(--muted); font-size: 13px; }
.hz-grid { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.domain {
  border: 1px solid var(--line); border-radius: 16px; padding: 18px;
  background: rgba(255,255,255,.025);
  display: flex; flex-direction: column; gap: 10px; min-height: 230px;
}
.domain.active { border-color: rgba(245,196,81,.35); background: linear-gradient(180deg, rgba(245,196,81,.06), rgba(255,255,255,.02)); cursor: pointer; }
.domain.active:hover { border-color: rgba(245,196,81,.6); }
.domain h3 { margin: 0; font-size: 18px; }
.domain p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.domain .thumb { height: 120px; border-radius: 10px; background: rgba(0,0,0,.25); overflow: hidden; }
.domain .thumb svg { width: 100%; height: 100%; }
.domain.locked { opacity: .55; }
.domain.locked .thumb { display: flex; align-items: center; justify-content: center; color: var(--faint); font-size: 13px; letter-spacing: 2px; background: repeating-linear-gradient(135deg, rgba(255,255,255,.02) 0 10px, transparent 10px 20px); }
.domain .meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: auto; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: #1b2236; border: 1px solid rgba(245,196,81,.4); color: var(--gold-2);
  padding: 10px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .3s; z-index: 30;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.thumb-map .label, .thumb-map .bg-label, .thumb-map .bg-sub { display: none; }
#thumbMap .node .core { stroke-width: 6; }
#thumbMap .node.dark .core { fill: #2c3449; stroke: #4a5470; }
#thumbMap .edge { stroke-width: 4; }

@media (min-width: 1200px) {
  .map-wrap { padding-left: 330px; }
}

@media (max-width: 1199px) {
  body { overflow: auto; }
  main { height: auto; min-height: calc(100vh - 64px); }
  .view { position: relative; }
  #viewMap { display: flex; flex-direction: column; }
  .next-card { position: relative; top: 0; left: 0; width: auto; max-width: 640px; margin: 12px 16px; }
  .map-wrap { position: relative; padding: 0 8px; overflow-x: auto; }
  #map { min-width: 860px; height: auto; aspect-ratio: 4 / 3; }
  .legend { position: relative; left: 0; bottom: 0; padding: 4px 16px 16px; }
}

@media (max-width: 900px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 10px 16px; padding: 10px 14px; }
  .slogan { display: none; }
  .top-actions { width: 100%; margin-left: 0; }
  .mastery { flex: 1; }
  .drawer { top: 0; z-index: 25; }
  .modal.docked { padding: 12px; align-items: flex-end; }
  .modal.docked .modal-card { width: 100%; max-height: 62vh; }
  #viewHorizon { padding: 20px 16px 40px; }
}
