:root {
  --bg-0: #0a0f18;
  --bg-1: #182232;
  --bg-2: #273647;
  --panel: rgba(20, 28, 42, 0.82);
  --panel-2: rgba(13, 18, 30, 0.92);
  --panel-3: rgba(35, 44, 60, 0.72);
  --line: rgba(143, 179, 214, 0.28);
  --line-strong: rgba(222, 236, 255, 0.78);
  --text: #eef5ff;
  --muted: #9eabbc;
  --soft: #cbd6e4;
  --gold: #f2d27c;
  --blue: #87c7ff;
  --cyan: #9de9ff;
  --danger: #ff9aa7;
  --green: #a5efc2;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius: 18px;
  --font: "Segoe UI", "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(circle at 52% 34%, rgba(167, 205, 236, .28), transparent 24%),
    radial-gradient(circle at 18% 88%, rgba(68, 83, 105, .38), transparent 30%),
    linear-gradient(180deg, #182230 0%, #2b3a49 48%, #151d27 100%);
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("../img/bg-pattern.png");
  background-size: 760px 760px;
  opacity: .08;
  mix-blend-mode: screen;
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(1, 4, 9, .24), rgba(1, 4, 9, .08) 45%, rgba(1, 4, 9, .34)),
    radial-gradient(circle at 50% 62%, rgba(255,255,255,.14), transparent 14%);
  pointer-events: none;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.app-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr) 32px;
  background: linear-gradient(180deg, rgba(10,15,25,.15), rgba(2,4,8,.2));
}
.topbar, .statusbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  border-color: rgba(216, 229, 255, .12);
  background: linear-gradient(90deg, rgba(14, 19, 32, .92), rgba(16, 23, 38, .72));
  backdrop-filter: blur(16px);
}
.topbar {
  justify-content: space-between;
  gap: 18px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 8px 28px rgba(0,0,0,.16);
}
.nav-left, .nav-right, .top-tabs, .hero-actions, .repo-actions, .tree-actions, .benchmark-actions, .mini-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-left { min-width: 320px; }
.icon-btn, .close-btn, .tab-btn, .wide-btn, .primary-btn, .secondary-btn, .master-btn, .copy-btn {
  border: 1px solid rgba(255,255,255,.12);
  color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 8px 20px rgba(0,0,0,.12);
  transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}
.icon-btn, .close-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 25px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.icon-btn:hover, .close-btn:hover, .tab-btn:hover, .wide-btn:hover, .primary-btn:hover, .secondary-btn:hover, .master-btn:hover, .copy-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(157, 233, 255, .54);
  background: linear-gradient(180deg, rgba(157,233,255,.16), rgba(255,255,255,.04));
}
.screen-title {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.screen-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
}
.top-tabs {
  padding: 4px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  background: rgba(0,0,0,.16);
}
.tab-btn {
  height: 32px;
  border-radius: 999px;
  padding: 0 14px;
  font-size: 12px;
  color: var(--soft);
  border-color: transparent;
  box-shadow: none;
}
.tab-btn.active {
  color: #101622;
  background: linear-gradient(180deg, #f8fbff, #a8c7e5);
  font-weight: 900;
}
.nav-right {
  min-width: 158px;
  justify-content: flex-end;
  font-weight: 900;
}
.coin {
  color: var(--gold);
  text-shadow: 0 0 12px rgba(242,210,124,.5);
}
.close-btn { font-size: 30px; color: #d7dbe4; }
.main-stage { min-height: 0; position: relative; overflow: hidden; }
.hidden { display: none !important; }

.codex-view {
  position: relative;
  height: 100%;
  overflow: hidden;
  padding: 62px 8vw 80px;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto;
  gap: 34px;
}
.sky-mist {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 54%, rgba(255,255,255,.19), transparent 13%),
    radial-gradient(circle at 50% 82%, rgba(20, 28, 40, .5), transparent 36%);
  pointer-events: none;
}
.hero-copy { position: relative; z-index: 1; max-width: 820px; }
.eyebrow, .section-label, .detail-kicker {
  display: inline-flex;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.hero-copy h1 {
  margin: 10px 0 12px;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.06;
  letter-spacing: -.03em;
  text-shadow: 0 16px 48px rgba(0,0,0,.34);
}
.hero-copy p {
  max-width: 720px;
  margin: 0 0 18px;
  color: var(--soft);
  font-size: 15px;
  line-height: 1.72;
}
.primary-btn, .secondary-btn {
  min-height: 42px;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 900;
}
.primary-btn { color: #111927; background: linear-gradient(180deg, #fff, #b8d4ef); }
.secondary-btn { background: rgba(11,16,28,.46); }
.domain-cards {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(9, minmax(106px, 1fr));
  align-items: center;
  gap: min(2.3vw, 30px);
}
.domain-card {
  position: relative;
  min-height: 350px;
  border: 0;
  border-radius: 34px 34px 42px 42px;
  color: #333d50;
  background:
    linear-gradient(180deg, rgba(255,255,255,.94), rgba(209,216,230,.92) 45%, rgba(160,170,190,.96)),
    radial-gradient(circle at 50% 20%, rgba(255,255,255,1), transparent 24%);
  box-shadow: 0 28px 64px rgba(0,0,0,.34), inset 0 0 0 1px rgba(255,255,255,.82), inset 0 -14px 30px rgba(76,83,105,.16);
  display: grid;
  grid-template-rows: 1fr auto auto auto;
  justify-items: center;
  padding: 24px 12px 22px;
  overflow: hidden;
  transform-origin: bottom center;
}
.domain-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px solid rgba(46,56,76,.34);
  border-radius: 27px 27px 34px 34px;
  clip-path: polygon(0 0,100% 0,100% 92%,50% 100%,0 92%);
}
.domain-card::after {
  content: "";
  position: absolute;
  width: 80%; height: 48%;
  top: 78px;
  border-radius: 50%;
  border: 1px solid rgba(47,56,76,.25);
  box-shadow: inset 0 0 0 18px rgba(60,72,94,.06);
}
.domain-card:hover { transform: translateY(-8px) scale(1.02); }
.domain-symbol {
  align-self: center;
  width: 88px; height: 88px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 54px;
  color: #4c5668;
  background: rgba(41,50,70,.11);
  box-shadow: 0 0 0 1px rgba(54,64,84,.22), inset 0 0 24px rgba(54,64,84,.1);
  z-index: 1;
}
.domain-name { z-index: 1; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.55); font-size: 20px; font-weight: 900; letter-spacing: .08em; }
.domain-en { z-index: 1; margin-top: 6px; color: rgba(245,248,255,.86); text-shadow: 0 2px 8px rgba(0,0,0,.5); font-size: 11px; text-transform: uppercase; }
.domain-count { z-index: 1; margin-top: 14px; min-width: 86px; padding: 6px 12px; border-radius: 999px; color: #f3f5ff; background: rgba(23,29,47,.74); font-weight: 900; }
.collection-footer {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 30px;
}
.progress-rail {
  width: min(680px, 70vw);
  display: grid; grid-template-columns: 100px 1fr 58px; align-items: center; gap: 12px;
  color: var(--soft); font-weight: 800;
}
.progress-track { height: 10px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; box-shadow: inset 0 1px 4px rgba(0,0,0,.35); }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold), #fff0b8); border-radius: 999px; transition: width .25s ease; }
.mini-stats span { color: var(--muted); font-size: 12px; }

.library-view {
  height: 100%; min-height: 0;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 380px;
  gap: 0;
}
.filter-rail, .detail-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  background: linear-gradient(180deg, rgba(17,23,36,.82), rgba(7,10,17,.88));
  border-color: rgba(255,255,255,.09);
}
.filter-rail { border-right: 1px solid rgba(255,255,255,.09); }
.detail-panel { border-left: 1px solid rgba(255,255,255,.09); }
.rail-card, .detail-block, .repo-card {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 16px 40px rgba(0,0,0,.12);
}
.rail-card { padding: 14px; margin-bottom: 12px; }
.search-wrap {
  display: flex; align-items: center; gap: 8px; min-height: 42px; margin-top: 9px;
  padding: 0 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px;
  background: rgba(0,0,0,.16); color: var(--cyan);
}
.search-wrap input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-wrap input::placeholder { color: rgba(203,214,228,.55); }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.filter-chip {
  min-height: 30px; border-radius: 999px; padding: 5px 10px; border: 1px solid rgba(255,255,255,.12);
  color: var(--soft); background: rgba(0,0,0,.16); font-size: 12px;
}
.filter-chip.active { color: #121827; background: linear-gradient(180deg, #fff, #bfd8ee); font-weight: 900; }
.wide-btn { min-height: 36px; border-radius: 12px; padding: 0 12px; font-size: 12px; font-weight: 800; }
.rail-card .wide-btn { width: 100%; margin-top: 8px; }
.node-section { min-width: 0; min-height: 0; padding: 18px; overflow: hidden; display: grid; grid-template-rows: auto 1fr; }
.section-header, .benchmark-head, .tree-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 14px;
}
h2 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.02em; }
.result-count { color: var(--muted); font-size: 12px; }
.node-grid { min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding-right: 8px; }
.node-entry {
  text-align: left; border: 1px solid rgba(255,255,255,.11); border-radius: 20px; color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,.09), rgba(255,255,255,.035));
  padding: 14px; min-height: 210px; display: grid; gap: 9px;
  box-shadow: 0 16px 36px rgba(0,0,0,.14), inset 0 1px 0 rgba(255,255,255,.08);
}
.node-entry:hover, .node-entry.selected { border-color: rgba(242,210,124,.7); transform: translateY(-2px); }
.node-entry.mastered { box-shadow: 0 0 0 1px rgba(165,239,194,.32), 0 16px 36px rgba(0,0,0,.14); }
.entry-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.entry-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.12); font-size: 24px; }
.entry-title { font-weight: 900; font-size: 15px; line-height: 1.25; }
.entry-purpose { margin: 0; color: var(--soft); font-size: 12px; line-height: 1.45; }
.entry-meta, .pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.small-pill, .pill {
  display: inline-flex; align-items: center; min-height: 24px; border: 1px solid rgba(255,255,255,.12); border-radius: 999px;
  padding: 3px 8px; color: var(--soft); background: rgba(0,0,0,.18); font-size: 11px;
}
.pill.gold { color: var(--gold); border-color: rgba(242,210,124,.35); }
.pill.danger { color: var(--danger); border-color: rgba(255,154,167,.3); }
.entry-repo, .entry-bench { color: var(--cyan); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-bench { color: var(--gold); }
.detail-topline { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.detail-panel h2 { margin: 10px 0; }
.detail-copy, .detail-block p { color: var(--soft); line-height: 1.6; font-size: 13px; }
.master-btn { border-radius: 999px; min-height: 32px; padding: 0 12px; font-size: 12px; }
.detail-block { padding: 13px; margin-top: 12px; }
.repo-card { padding: 12px; margin-top: 8px; }
.repo-card.benchmark { border-color: rgba(242,210,124,.2); background: linear-gradient(180deg, rgba(242,210,124,.09), rgba(255,255,255,.025)); }
.repo-name { color: #fff; font-weight: 900; margin-bottom: 5px; }
.repo-card p { margin: 0 0 10px; }
.repo-link { display: inline-flex; align-items: center; min-height: 34px; border-radius: 10px; padding: 0 12px; background: rgba(255,255,255,.12); text-decoration: none; font-size: 12px; font-weight: 900; }
.copy-btn { min-height: 34px; border-radius: 10px; padding: 0 10px; font-size: 12px; }
.benchmark-meta { margin: 0 0 10px; display: grid; gap: 8px; }
.benchmark-meta div { display: grid; gap: 2px; }
.benchmark-meta dt { color: var(--gold); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.benchmark-meta dd { margin: 0; color: var(--soft); font-size: 12px; line-height: 1.45; }
.split-block { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.link-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.link-chip { border: 1px solid rgba(255,255,255,.12); border-radius: 999px; padding: 5px 8px; background: rgba(0,0,0,.16); color: var(--soft); font-size: 11px; }
.link-chip:hover { color: #fff; border-color: rgba(157,233,255,.55); }
.empty { color: var(--muted); font-size: 12px; }

.benchmark-view, .tree-view { height: 100%; min-height: 0; padding: 18px; display: grid; grid-template-rows: auto auto minmax(0, 1fr); }
.benchmark-head p { margin: 6px 0 0; color: var(--soft); }
.benchmark-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.compact-search { max-width: 460px; flex: 1; margin-top: 0; }
.benchmark-toolbar select {
  min-height: 42px; border-radius: 14px; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.18); color: var(--text); padding: 0 12px;
}
.benchmark-toolbar option { background: #151d2a; }
.benchmark-table-wrap { min-height: 0; overflow: auto; border: 1px solid rgba(255,255,255,.1); border-radius: 20px; background: rgba(0,0,0,.14); }
.benchmark-table { width: 100%; border-collapse: collapse; min-width: 1050px; }
.benchmark-table th, .benchmark-table td { padding: 12px; border-bottom: 1px solid rgba(255,255,255,.08); vertical-align: top; font-size: 12px; line-height: 1.45; }
.benchmark-table th { position: sticky; top: 0; z-index: 1; background: rgba(22,30,44,.96); color: var(--gold); text-align: left; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
.benchmark-table tr:hover td { background: rgba(255,255,255,.04); }
.table-node { font-weight: 900; color: #fff; }
.table-link { color: var(--cyan); text-decoration: none; font-weight: 900; }
.table-link:hover { text-decoration: underline; }

.tree-view { grid-template-rows: auto minmax(0, 1fr); }
.tree-toolbar { margin-bottom: 12px; }
.tree-container { min-height: 0; overflow: hidden; border: 1px solid rgba(255,255,255,.1); border-radius: 20px; background: rgba(8,13,23,.58); cursor: grab; }
.tree-container.grabbing { cursor: grabbing; }
#techSvg { width: 100%; height: 100%; display: block; }
.svg-bg { fill: rgba(11,17,28,.6); }
.grid-line { stroke: rgba(180,210,240,.28); stroke-width: .7; }
.tech-link { fill: none; stroke: rgba(166, 218, 230, .55); stroke-width: 1.3; opacity: .56; marker-end: url(#arrow); }
.tech-link.highlight { stroke: var(--gold); stroke-width: 2.4; opacity: 1; filter: drop-shadow(0 0 4px rgba(242,210,124,.5)); }
.tech-link.muted { opacity: .12; }
.arrow { fill: rgba(166,218,230,.8); }
.node-group { cursor: pointer; }
.node-card { fill: url(#nodeSurface); stroke: rgba(255,255,255,.45); stroke-width: 1.2; filter: drop-shadow(0 16px 24px rgba(0,0,0,.3)); }
.node-group:hover .node-card, .node-group.selected .node-card { stroke: var(--gold); stroke-width: 2.4; }
.node-band { fill: rgba(48,60,82,.88); }
.node-glyph { fill: #394456; font-size: 25px; font-weight: 900; }
.node-title { fill: #263142; font-size: 13px; font-weight: 900; }
.node-sub { fill: #637189; font-size: 10px; font-weight: 700; }
.node-bench { fill: #806321; font-size: 9px; font-weight: 800; }
.node-id { fill: #eef4ff; font-size: 11px; font-weight: 900; }
.node-group.path-muted { opacity: .24; }

.statusbar {
  gap: 12px;
  padding: 0 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .05em;
}
#statusText { color: var(--soft); font-weight: 900; }

@media (max-width: 1260px) {
  body { overflow: auto; }
  .app-shell { position: static; min-height: 100vh; }
  .domain-cards { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
  .domain-card { min-height: 290px; }
  .library-view { grid-template-columns: 250px minmax(0,1fr); grid-template-rows: minmax(580px, 1fr) auto; }
  .detail-panel { grid-column: 1 / -1; border-left: 0; border-top: 1px solid rgba(255,255,255,.09); display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .detail-panel > .detail-block, .detail-panel > .detail-copy { margin-top: 0; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .app-shell { grid-template-rows: auto 1fr auto; }
  .topbar { flex-wrap: wrap; padding: 10px; }
  .nav-left { min-width: 0; width: 100%; }
  .top-tabs { order: 3; width: 100%; justify-content: space-between; overflow-x: auto; }
  .nav-right { margin-left: auto; }
  .codex-view { padding: 34px 18px 50px; }
  .domain-cards { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
  .domain-card { min-height: 250px; }
  .collection-footer { flex-direction: column; align-items: stretch; }
  .progress-rail { width: 100%; grid-template-columns: 84px 1fr 48px; }
  .library-view { grid-template-columns: 1fr; grid-template-rows: auto minmax(520px, 1fr) auto; }
  .filter-rail { display: none; }
  .filter-rail.open { display: block; }
  .detail-panel { grid-template-columns: 1fr; }
  .split-block { grid-template-columns: 1fr; }
  .benchmark-head, .section-header, .tree-toolbar, .benchmark-toolbar { align-items: flex-start; flex-direction: column; }
  .benchmark-actions, .tree-actions { width: 100%; }
  .wide-btn { flex: 1; }
}
