:root {
  --bg: #050814;
  --bg-elevated: #080e1d;
  --surface: rgba(12, 20, 38, .95);
  --surface-strong: #0e1930;
  --surface-soft: rgba(18, 30, 54, .72);
  --line: rgba(118, 151, 201, .2);
  --line-strong: rgba(89, 218, 255, .4);
  --text: #e9f3ff;
  --muted: #8295b2;
  --muted-light: #61738f;
  --cyan: #42dcff;
  --cyan-strong: #0fc7f2;
  --cyan-soft: rgba(23, 197, 239, .12);
  --violet: #8577ff;
  --violet-soft: rgba(133, 119, 255, .13);
  --success: #7dffb2;
  --danger: #ff718f;
  --warning: #ffd073;
  --shadow: 0 24px 70px rgba(0, 0, 0, .32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -12%, rgba(66, 220, 255, .16), transparent 32rem),
    radial-gradient(circle at 92% 6%, rgba(133, 119, 255, .13), transparent 34rem),
    linear-gradient(145deg, #050814 0%, #070b17 48%, #050914 100%);
}
body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  opacity: .36;
  background-image:
    linear-gradient(rgba(77, 118, 171, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 118, 171, .08) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, #000, transparent 92%);
}

button, input, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
code, pre, .mono, .generated-url { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
::selection { color: #04101b; background: var(--cyan); }

.page { width: min(1880px, calc(100% - 32px)); margin: 0 auto; padding: 18px 0 22px; }
.page-header {
  display: grid;
  min-height: 70px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 17px;
  padding: 0 7px 16px;
}
.cube-logo { position: relative; width: 52px; height: 52px; filter: drop-shadow(0 0 16px rgba(66, 220, 255, .28)); }
.cube-logo span { position: absolute; display: block; }
.cube-logo .cube-top { inset: 0 4px auto; height: 25px; background: linear-gradient(135deg, #67ecff, #3c87ff); clip-path: polygon(50% 0, 100% 45%, 50% 100%, 0 45%); }
.cube-logo .cube-left { top: 20px; left: 4px; width: 23px; height: 31px; background: linear-gradient(180deg, #26c8ed, #1666b9); clip-path: polygon(0 0, 100% 42%, 100% 100%, 0 72%); }
.cube-logo .cube-right { top: 20px; right: 4px; width: 23px; height: 31px; background: linear-gradient(180deg, #665cff, #283b9b); clip-path: polygon(0 42%, 100% 0, 100% 72%, 0 100%); }
.cube-logo::after { position: absolute; inset: 21px 13px 12px; content: ""; background: #07101e; clip-path: polygon(50% 35%, 100% 0, 100% 43%, 50% 77%, 0 43%, 0 0); }
.title-eyebrow, .eyebrow, .panel-kicker, .kicker {
  margin: 0 0 4px;
  color: var(--cyan);
  font: 700 9px/1.2 "SFMono-Regular", Consolas, monospace;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.title-block h1, .title h1 { margin: 0 0 4px; font-size: clamp(23px, 2vw, 34px); line-height: 1.1; letter-spacing: -.035em; }
.title-block h1 span, .title h1 span { color: var(--cyan); }
.title-block > p:last-child, .title > p:last-child { margin: 0; color: var(--muted); font-size: 13px; }
.status-cluster, .header-actions { display: flex; align-items: center; gap: 12px; }

.button, .nav-link, .plan-nav {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  color: #cbdcf1;
  border: 1px solid rgba(118, 151, 201, .3);
  border-radius: 9px;
  background: rgba(16, 28, 50, .78);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color .18s ease, color .18s ease, background .18s ease, transform .18s ease;
}
.button:hover, .nav-link:hover, .plan-nav:hover { color: #fff; border-color: rgba(66, 220, 255, .55); background: rgba(28, 48, 79, .9); transform: translateY(-1px); }
.button:focus-visible, .nav-link:focus-visible, .plan-nav:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.button.primary { color: #02111b; border-color: var(--cyan); background: linear-gradient(135deg, #68e9ff, #22bde7); box-shadow: 0 0 20px rgba(66, 220, 255, .18); }
.button.primary:hover { color: #02111b; background: linear-gradient(135deg, #8ff0ff, #42d8ff); }
.button.violet, .button.send { color: #e4e0ff; border-color: rgba(133, 119, 255, .5); background: var(--violet-soft); }
.button.danger { color: #ffc4d0; border-color: rgba(255, 113, 143, .4); background: rgba(255, 113, 143, .08); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button .icon { font-size: 15px; line-height: 1; }

.text-button {
  min-height: 32px;
  padding: 0 11px;
  color: #bfefff;
  border: 1px solid rgba(66, 220, 255, .22);
  border-radius: 8px;
  background: rgba(66, 220, 255, .06);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.text-button:hover { border-color: rgba(66, 220, 255, .56); background: rgba(66, 220, 255, .12); transform: translateY(-1px); }
.text-button:disabled { cursor: not-allowed; opacity: .45; }

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: 0;
  background: rgba(4, 10, 23, .72);
  box-shadow: inset 0 1px 8px rgba(0, 0, 0, .18);
  font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input:hover { border-color: rgba(118, 151, 201, .38); }
.input:focus {
  border-color: var(--cyan);
  background: rgba(7, 17, 34, .92);
  box-shadow: 0 0 0 3px rgba(66, 220, 255, .1), inset 0 1px 8px rgba(0, 0, 0, .16);
}
.input::placeholder { color: #536581; }
textarea.input { padding: 9px 12px; line-height: 1.5; }
.search-wrap { position: relative; display: block; margin-bottom: 12px; }
.search-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  z-index: 1;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--cyan);
  line-height: 0;
  pointer-events: none;
}
.search-icon svg { display: block; width: 100%; height: 100%; }
.search-wrap .input { padding-left: 37px; }

.category-tree {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(3, 9, 20, .62);
  scrollbar-color: rgba(66, 220, 255, .36) rgba(8, 15, 30, .8);
  scrollbar-width: thin;
}
.category-state {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.major-group { border-bottom: 1px solid rgba(118, 151, 201, .1); }
.major-group:last-child { border-bottom: 0; }
.major-summary {
  display: grid;
  grid-template-columns: 16px 21px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 5px 13px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease;
}
.major-summary:hover { background: rgba(66, 220, 255, .055); }
.major-summary::-webkit-details-marker, .level2-summary::-webkit-details-marker { display: none; }
.major-summary::before, .level2-summary::before {
  content: "";
  transform: rotate(-45deg);
  border-bottom: 1.5px solid var(--cyan);
  border-left: 1.5px solid var(--cyan);
  transition: transform .15s ease;
}
.major-summary::before { width: 8px; height: 8px; }
details[open] > .major-summary::before, details[open] > .level2-summary::before { transform: rotate(-45deg) scale(-1); }
.major-name { overflow: hidden; font-size: 14px; font-weight: 750; }
.category-name-with-count { display: flex; min-width: 0; align-items: baseline; gap: 6px; white-space: nowrap; }
.category-name-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-keyword-count { flex: 0 0 auto; overflow: visible; color: #7185a3; font: 600 9px/1.2 "SFMono-Regular", Consolas, monospace; white-space: nowrap; }
.major-count {
  min-width: 28px;
  padding: 3px 7px;
  color: #8ea3c2;
  border: 1px solid rgba(118, 151, 201, .16);
  border-radius: 999px;
  background: rgba(118, 151, 201, .06);
  font: 10px/1.2 "SFMono-Regular", Consolas, monospace;
  text-align: center;
}
.category-checkbox {
  display: inline-grid;
  width: 20px;
  height: 20px;
  margin: 0;
  appearance: none;
  place-content: center;
  border: 1.5px solid #49617e;
  border-radius: 5px;
  background: #071120;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.level3-option .category-checkbox { width: 18px; height: 18px; flex: 0 0 auto; }
.category-checkbox:hover { border-color: var(--cyan); }
.category-checkbox:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.category-checkbox:checked, .category-checkbox:indeterminate {
  border-color: var(--cyan);
  background: linear-gradient(135deg, var(--cyan-strong), #388cff);
  box-shadow: 0 0 12px rgba(66, 220, 255, .28);
}
.category-checkbox:checked::after {
  width: 9px;
  height: 5px;
  content: "";
  transform: translateY(-1px) rotate(-45deg);
  border-bottom: 2px solid #04111c;
  border-left: 2px solid #04111c;
}
.category-checkbox:indeterminate::after { width: 9px; height: 2px; content: ""; border-radius: 2px; background: #04111c; }
.level2-list { padding: 0 10px 10px 31px; border-left: 1px solid rgba(66, 220, 255, .13); }
.level2-group { margin-top: 3px; border-radius: 8px; background: rgba(9, 20, 38, .42); }
.level2-summary {
  display: grid;
  grid-template-columns: 13px 19px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 39px;
  padding: 4px 9px;
  color: #cbd8e9;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.level2-summary::before { width: 7px; height: 7px; border-color: #8577ff; }
.level2-name { overflow: hidden; font-size: 13px; font-weight: 680; }
.level2-count { color: #7185a3; font: 10px/1.2 "SFMono-Regular", Consolas, monospace; }
.level3-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 9px; padding: 2px 8px 9px 31px; }
.level3-option {
  display: flex;
  min-width: 0;
  min-height: 34px;
  align-items: center;
  gap: 9px;
  padding: 4px 5px;
  color: #bdcbe0;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.level3-option:hover { color: #fff; background: rgba(133, 119, 255, .08); }
.level3-option > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-scope {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(66, 220, 255, .16);
  border-radius: 10px;
  background: rgba(66, 220, 255, .035);
}
.selected-scope-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; color: #c8d7ea; font-size: 12px; font-weight: 720; }
.selected-scope-heading code { color: var(--cyan); font-size: 10px; font-weight: 600; }
.selected-chips { display: flex; min-height: 28px; flex-wrap: wrap; align-content: flex-start; gap: 7px; overflow: visible; }
.selected-chips:empty::before { align-self: center; content: "尚未选择分类"; color: #536581; font-size: 11px; }
.selected-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  color: #bdefff;
  border: 1px solid rgba(66, 220, 255, .28);
  border-radius: 7px;
  background: rgba(66, 220, 255, .08);
  font-size: 11px;
  font-weight: 650;
}
.selected-chip button { padding: 0; color: var(--cyan); border: 0; background: transparent; font-size: 16px; line-height: 1; }
.selection-summary { margin: 9px 1px 0; color: var(--muted); font-size: 12px; }

.api-status {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  color: var(--success);
  border: 1px solid rgba(125, 255, 178, .36);
  border-radius: 999px;
  background: rgba(56, 193, 119, .08);
  box-shadow: inset 0 0 18px rgba(125, 255, 178, .04);
  font-size: 12px;
  font-weight: 700;
}
.api-status::before { width: 8px; height: 8px; content: ""; border-radius: 50%; background: var(--success); box-shadow: 0 0 11px rgba(125, 255, 178, .8); }

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(15, 25, 46, .97), rgba(8, 14, 29, .96));
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, .025);
}
.panel::before { position: absolute; top: 0; right: 0; left: 0; height: 1px; content: ""; background: linear-gradient(90deg, transparent, rgba(66, 220, 255, .5), rgba(133, 119, 255, .42), transparent); }

@media (max-width: 1180px) {
  .level3-list { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .level3-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .page { width: min(100% - 14px, 1880px); padding-top: 10px; }
  .page-header { grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
  .cube-logo { width: 45px; height: 45px; transform: scale(.85); transform-origin: left center; }
  .title-eyebrow, .eyebrow { font-size: 8px; }
  .title-block h1, .title h1 { font-size: 20px; }
  .title-block > p:last-child, .title > p:last-child { font-size: 11px; }
  .status-cluster, .header-actions { grid-column: 1 / -1; justify-content: flex-end; margin-top: -5px; }
  .nav-link, .plan-nav, .api-status { min-height: 32px; padding-inline: 11px; font-size: 11px; }
}

@media (max-width: 640px) {
  .level2-list { padding-left: 24px; }
  .level3-list { grid-template-columns: 1fr; padding-left: 27px; }
}
