:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --panel: rgba(255,255,255,.035);
  --panel-strong: rgba(255,255,255,.065);
  --text: #e6edf3;
  --muted: #8b949e;
  --line: rgba(240,246,252,.12);
  --accent: #58a6ff;
  --accent-2: #2f81f7;
  --chip: rgba(88,166,255,.12);
  --shadow: 0 24px 80px rgba(0,0,0,.38);
  --card-shadow: 0 12px 36px rgba(0,0,0,.24);
  --link-bg: #273444;
  --link-bg-hover: #33465a;
}

html[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-soft: #ffffff;
  --panel: rgba(255,255,255,.82);
  --panel-strong: #ffffff;
  --text: #1f2328;
  --muted: #656d76;
  --line: rgba(31,35,40,.14);
  --accent: #0969da;
  --accent-2: #1f6feb;
  --chip: rgba(9,105,218,.10);
  --shadow: 0 24px 70px rgba(31,35,40,.14);
  --card-shadow: 0 14px 34px rgba(31,35,40,.10);
  --link-bg: #ffffff;
  --link-bg-hover: #f3f6f9;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 2%, rgba(47,129,247,.18), transparent 31%),
    radial-gradient(circle at 92% 8%, rgba(88,166,255,.10), transparent 28%),
    linear-gradient(180deg, var(--bg-soft) 0, var(--bg) 22rem);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; }

.page {
  width: min(1560px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 56px;
}

.topbar {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px 12px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--bg-soft) 78%, transparent);
  backdrop-filter: blur(18px);
  box-shadow: var(--card-shadow);
}

.category-menu-btn {
  min-width: 76px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--panel);
  font-weight: 750;
  letter-spacing: .02em;
  white-space: nowrap;
  cursor: pointer;
  transition: .2s ease;
}

.category-menu-btn:hover {
  transform: translateY(-1px);
  background: var(--panel-strong);
}

.category-menu-btn.active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.top-search {
  min-width: 0;
  width: 100%;
}

.search-wrap {
  position: relative;
  min-width: 0;
}

.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 18px;
  pointer-events: none;
}

.search {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 46px 0 43px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  color: var(--text);
  background: var(--bg-soft);
  font-size: 15px;
  line-height: 44px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.search::-webkit-search-cancel-button {
  display: none;
}

.search::placeholder {
  color: var(--muted);
  opacity: .9;
}

.search:focus {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent);
}

.search-clear {
  display: none;
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  transition: color .18s ease, background .18s ease;
}

.search-clear.visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-clear:hover,
.search-clear:focus-visible {
  color: var(--text);
  background: var(--panel);
  outline: none;
}

mark.search-hit {
  padding: 0 .08em;
  border-radius: 3px;
  color: inherit;
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--accent) 55%, transparent);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  justify-self: end;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  cursor: pointer;
  transition: .2s ease;
}
.icon-btn:hover { transform: translateY(-1px); background: var(--panel-strong); }

.submit-nav-btn {
  height: 40px;
  padding: 0 15px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  border-radius: 12px;
  color: #ffffff;
  background: var(--accent-2);
  font-size: 14px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

.submit-nav-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 22%, transparent);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.content.categories-open {
  grid-template-columns: 310px minmax(0, 1fr);
}

.sidebar {
  display: none;
  position: relative;
  top: auto;
  max-height: none;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  padding: 14px;
  scrollbar-width: thin;
}

.content.categories-open .sidebar {
  display: block;
}

.sidebar-title {
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .12em;
  font-weight: 800;
}

#categoryTree {
  display: none;
  margin-top: 8px;
}

#categoryTree.visible {
  display: block;
}

.all-btn,
.tree-filter {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: .18s ease;
}

.all-btn {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  margin-bottom: 6px;
}

.all-btn:hover,
.tree-filter:hover {
  color: var(--text);
  background: var(--panel);
}

.all-btn.active {
  color: var(--text);
  background: var(--panel-strong);
  border-color: var(--line);
}

.tree-node {
  position: relative;
}

.tree-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
}

.tree-filter {
  padding: 8px 8px;
}

.tree-filter.active {
  color: var(--text);
  background: var(--chip);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.tree-filter.active::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.tree-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-count {
  flex: 0 0 auto;
  min-width: 27px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* 第一层：完整的手风琴式大分类，不画目录线 */
.tree-node.depth-0 {
  margin: 7px 0;
}

.tree-node.depth-0 > .tree-row {
  min-height: 46px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel-strong) 75%, transparent);
}

.tree-node.depth-0 > .tree-row:hover {
  border-color: color-mix(in srgb, var(--accent) 24%, var(--line));
  background: var(--panel-strong);
}

.tree-node.depth-0 > .tree-row > .tree-filter {
  min-height: 38px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  color: var(--text);
  font-weight: 720;
}

.tree-node.depth-0 > .tree-row > .tree-filter.active {
  color: var(--accent);
  background: var(--chip);
}

.tree-node.depth-0 > .tree-row > .tree-filter.active::before {
  display: none;
}

.tree-toggle,
.tree-spacer {
  position: relative;
  flex: 0 0 22px;
  width: 22px;
  height: 30px;
  margin: 0;
}

.tree-toggle {
  border: 0;
  border-radius: 7px;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transition: background .18s ease;
}

.tree-toggle:hover {
  background: var(--panel);
}

/* 统一使用简洁的加减号，不再使用圆形节点和粗分支 */
.tree-toggle > span::before,
.tree-toggle > span::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 14px;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: var(--muted);
  transition: opacity .18s ease, background .18s ease;
}

.tree-toggle > span::after {
  transform: rotate(90deg);
}

.tree-toggle.open > span::after {
  opacity: 0;
}

.tree-toggle:hover > span::before,
.tree-toggle:hover > span::after {
  background: var(--accent);
}

.tree-node.depth-0 > .tree-row > .tree-toggle {
  margin-left: 4px;
  background: var(--panel);
}

.tree-node.depth-0 > .tree-row > .tree-toggle.open {
  background: var(--chip);
}

/*
  第二至第四层：标准细线目录树。
  同级共享直线，仅在连接子项时做小圆角转弯。
*/
.tree-children {
  display: none;
  position: relative;
  margin-left: 17px;
  padding-left: 18px;
}

.tree-node.depth-0 > .tree-children {
  margin-top: 4px;
  margin-left: 18px;
  padding-left: 18px;
}

.tree-children.open {
  display: block;
}

.tree-children > .tree-node::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 0;
  height: 18px;
  width: 2px;
  background: color-mix(in srgb, var(--muted) 42%, transparent);
}

.tree-children > .tree-node:not(:last-child)::before {
  height: auto;
  bottom: 0;
}

.tree-children > .tree-node > .tree-row::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 8px;
  width: 12px;
  height: 11px;
  border-left: 2px solid color-mix(in srgb, var(--muted) 42%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--muted) 42%, transparent);
  border-bottom-left-radius: 8px;
  pointer-events: none;
}

.tree-children > .tree-node > .tree-row:has(.tree-filter.active)::before {
  border-left-color: var(--accent);
  border-bottom-color: var(--accent);
}

.tree-children > .tree-node > .tree-row > .tree-spacer {
  flex-basis: 18px;
  width: 18px;
}

.main-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  padding: 12px 14px 14px;
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 44px;
  margin-bottom: 8px;
  padding: 0 6px;
}

.active-path {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 13px;
  overflow-x: auto;
  scrollbar-width: none;
}

.active-path::-webkit-scrollbar {
  display: none;
}

.filter-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  white-space: nowrap;
}

.result-count {
  display: flex;
  align-items: center;
  min-height: 32px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.clear-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crumb {
  flex: 0 0 auto;
  border: 0;
  padding: 3px 2px;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}

.crumb:hover,
.crumb:focus-visible {
  color: var(--accent);
  background: var(--chip);
  outline: none;
}

.crumb.current {
  color: var(--text);
  font-weight: 700;
}

.crumb.current:hover,
.crumb.current:focus-visible {
  color: var(--accent);
}

.crumb-sep {
  flex: 0 0 auto;
  opacity: .45;
}

.clear-filter {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.clear-filter:hover {
  color: var(--text);
  background: var(--panel);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, var(--panel-strong), var(--panel));
  box-shadow: var(--card-shadow);
  overflow: hidden;
  position: relative;
  cursor: default;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  box-shadow: 0 16px 36px rgba(0,0,0,.08);
}

.card.selected {
  border-color: var(--accent);
  background:
    linear-gradient(
      145deg,
      color-mix(in srgb, var(--accent) 9%, var(--panel-strong)),
      color-mix(in srgb, var(--accent) 5%, var(--panel))
    );
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent),
    0 18px 40px rgba(0,0,0,.10);
}

.card.selected:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.card:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent),
    var(--card-shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.card h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.18;
  letter-spacing: -.03em;
}

.card-open {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--bg-soft);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: .18s ease;
}

.card-open:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background: var(--chip);
  transform: translateY(-1px);
}

.card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 10px;
  row-gap: 6px;
  margin-top: 2px;
}

.primary-chip {
  max-width: 100%;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--accent);
  background: var(--chip);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: .18s ease;
}

.primary-chip:hover,
.primary-chip:focus-visible,
.primary-chip.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  outline: none;
}

.inline-tag {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  transition: color .18s ease;
}

.inline-tag:hover,
.inline-tag:focus-visible,
.inline-tag.active {
  color: var(--accent);
  outline: none;
}

.empty {
  display: none;
  padding: 54px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
}

.empty strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 16px;
}

.empty button {
  margin-top: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
}

.empty button:hover {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: var(--chip);
}

.footer {
  margin-top: 16px;
  padding: 18px 10px 4px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}


body.modal-open {
  overflow: hidden;
}

.submission-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: 24px;
  background: rgba(3, 7, 18, .68);
  backdrop-filter: blur(10px);
  overflow-y: auto;
}

.submission-overlay.open {
  display: grid;
  place-items: center;
}

.submission-dialog {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--bg-soft);
  box-shadow: 0 30px 100px rgba(0, 0, 0, .48);
}

.submission-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-soft) 94%, transparent);
  backdrop-filter: blur(16px);
}

.submission-title {
  margin: 0;
  font-size: 23px;
  line-height: 1.2;
  letter-spacing: -.03em;
}

.submission-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.modal-close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: var(--panel);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: .18s ease;
}

.modal-close:hover {
  color: var(--text);
  background: var(--panel-strong);
}

.submission-form {
  padding: 22px 24px 24px;
}

.submission-honeypot {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.form-field {
  min-width: 0;
}

.form-field.full {
  grid-column: 1 / -1;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.required {
  color: #f85149;
}

.field-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.form-input,
.form-textarea,
.tag-entry {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: var(--panel);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.form-input {
  height: 44px;
  padding: 0 13px;
}

.form-textarea {
  min-height: 96px;
  padding: 12px 13px;
  resize: vertical;
  line-height: 1.6;
}

.form-input:focus,
.form-textarea:focus,
.tag-entry:focus {
  border-color: var(--accent);
  background: var(--bg-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.category-picker {
  display: grid;
  gap: 12px;
}

.category-mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.category-mode-btn {
  min-height: 38px;
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}

.category-mode-btn:hover {
  color: var(--text);
  background: var(--bg-soft);
}

.category-mode-btn.active {
  color: var(--text);
  background: var(--panel-strong);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
}

.category-mode-panel {
  display: none;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
}

.category-mode-panel.active {
  display: block;
}

.category-panel-title {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 14px;
  font-weight: 760;
}

.category-panel-note {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.category-level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.category-level-field {
  min-width: 0;
}

.category-level-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
}

.category-select,
.category-new-input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: var(--bg-soft);
  font-size: 13px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.category-select:focus,
.category-new-input:focus {
  border-color: var(--accent);
  background: var(--panel-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.category-select:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.category-new-input:disabled {
  cursor: not-allowed;
  opacity: .48;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
}

.existing-category-custom {
  display: none;
  width: 100%;
  height: 40px;
  margin-top: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: var(--bg-soft);
  font-size: 13px;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.existing-category-custom.visible {
  display: block;
}

.existing-category-custom:focus {
  border-color: var(--accent);
  background: var(--panel-strong);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.category-preview-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 11px;
  border: 1px dashed var(--line);
  border-radius: 11px;
  background: var(--bg-soft);
}

.category-preview-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

.category-preview-path {
  min-width: 0;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 680;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.category-preview-path.is-empty {
  color: var(--muted);
  font-weight: 500;
}

.new-category-part {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.new-category-mark {
  padding: 1px 5px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  font-size: 9.5px;
  font-weight: 750;
  vertical-align: middle;
}

.category-add-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.category-add-btn {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: #ffffff;
  background: var(--accent-2);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition: filter .18s ease, transform .18s ease, opacity .18s ease;
}

.category-add-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.category-add-btn:disabled {
  cursor: not-allowed;
  opacity: .42;
}

.selected-category-box {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
}

.selected-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.selected-category-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.selected-category-count {
  color: var(--muted);
  font-size: 11.5px;
}

.selected-category-list {
  display: grid;
  gap: 8px;
}

.selected-category-empty {
  padding: 13px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.selected-category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-soft);
}

.selected-category-type {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--chip);
  font-size: 10px;
  font-weight: 750;
}

.selected-category-path {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.selected-category-remove {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  transition: color .18s ease, background .18s ease;
}

.selected-category-remove:hover {
  color: #f85149;
  background: color-mix(in srgb, #f85149 10%, transparent);
}

.category-error {
  display: none;
  margin: 8px 0 0;
  color: #f85149;
  font-size: 11.5px;
}

.category-error.visible {
  display: block;
}

.tag-editor {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
}

.tag-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
}

.submission-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--chip);
  font-size: 12px;
  font-weight: 650;
}

.submission-tag-chip button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
  line-height: 1;
}

.submission-tag-chip button:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.tag-entry {
  height: 38px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  font-size: 13px;
}

.tag-entry:focus {
  border-color: var(--accent);
  background: var(--bg-soft);
}

.submission-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.submission-server-error {
  display: none;
  margin: 18px 0 0;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, #d73a49 32%, var(--line));
  border-radius: 10px;
  color: #b4232f;
  background: color-mix(in srgb, #d73a49 7%, var(--panel));
  font-size: 13px;
  line-height: 1.55;
}

.submission-server-error.visible {
  display: block;
}

.form-cancel,
.form-submit {
  min-width: 92px;
  height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 750;
}

.form-cancel {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel);
}

.form-submit {
  border: 1px solid var(--accent);
  color: #ffffff;
  background: var(--accent-2);
}

.form-submit:hover {
  filter: brightness(1.08);
}

.form-submit:disabled {
  cursor: wait;
  filter: none;
  opacity: 0.68;
}

.submission-success {
  display: none;
  padding: 44px 28px 38px;
  text-align: center;
}

.submission-success.visible {
  display: block;
}

.success-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 50%;
  color: #ffffff;
  background: #238636;
  font-size: 24px;
  font-weight: 900;
}

.submission-success h3 {
  margin: 0;
  font-size: 22px;
}

.submission-success p {
  max-width: 440px;
  margin: 10px auto 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.submission-success strong {
  color: var(--text);
  letter-spacing: 0.06em;
}

.success-close {
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
  font-weight: 700;
}

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

@media (max-width: 930px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .content { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    max-height: 430px;
  }
}

@media (max-width: 720px) {
  .filter-bar {
    align-items: flex-start;
    gap: 10px;
  }

  .filter-actions {
    gap: 7px;
  }

  .result-count {
    font-size: 12px;
  }

  .clear-filter {
    padding: 6px 8px;
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  .page { width: min(100% - 16px, 1560px); padding-top: 8px; }

  .submission-overlay {
    padding: 8px;
    align-items: end;
  }

  .submission-dialog {
    width: 100%;
    max-height: calc(100vh - 16px);
    border-radius: 20px 20px 14px 14px;
  }

  .submission-header {
    padding: 18px 16px 15px;
  }

  .submission-form {
    padding: 17px 16px 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .form-field.full {
    grid-column: auto;
  }

  .category-level-grid {
    grid-template-columns: 1fr;
  }

  .category-preview-box {
    flex-direction: column;
    gap: 2px;
  }

  .selected-category-item {
    align-items: flex-start;
  }

  .submission-actions {
    position: sticky;
    bottom: 0;
    margin: 20px -16px -18px;
    padding: 14px 16px 18px;
    background: color-mix(in srgb, var(--bg-soft) 95%, transparent);
    backdrop-filter: blur(12px);
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 16px;
  }

  .category-menu-btn {
    min-width: 64px;
    height: 40px;
    padding: 0 12px;
    justify-self: start;
  }

  .top-search {
    min-width: 0;
    width: 100%;
  }

  .top-actions {
    justify-self: end;
  }

  .submit-nav-btn {
    height: 40px;
    padding: 0 11px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
  }

  .search {
    min-width: 0;
    height: 40px;
    padding-left: 37px;
    padding-right: 10px;
    font-size: 14px;
    line-height: 40px;
  }

  .search-wrap::before {
    left: 12px;
    font-size: 16px;
  }

  .grid { grid-template-columns: 1fr; }
  .result-count { padding-left: 4px; }
  .main-panel { padding: 10px; border-radius: 18px; }
  .card { padding: 14px; border-radius: 16px; }
  .card h2 { font-size: 18px; }
  .card p { font-size: 13px; }
}

@media (max-width: 430px) {
  .topbar {
    gap: 6px;
    padding: 8px;
  }

  .category-menu-btn {
    min-width: 58px;
    padding: 0 10px;
    font-size: 14px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .search {
    height: 38px;
    padding-left: 33px;
    font-size: 13px;
    line-height: 38px;
  }

  .search-wrap::before {
    left: 10px;
    font-size: 15px;
  }
}

/* 单列资源目录改版 */
.page {
  width: min(1440px, calc(100% - 36px));
  padding-top: 12px;
}

.topbar {
  z-index: 4;
  grid-template-columns: 248px minmax(320px, 640px) minmax(24px, 1fr) auto;
  gap: 24px;
  min-height: 64px;
  padding: 8px 0 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 42px;
  color: var(--text);
  font-size: 17px;
  font-weight: 760;
  letter-spacing: -.02em;
}

.brand-mark {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 8px;
  background: var(--chip);
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
}

.brand-mark::before { left: 6px; top: 6px; }
.brand-mark::after { right: 6px; bottom: 6px; opacity: .66; }

.category-menu-btn { display: none; }

.top-search {
  grid-column: 2;
  width: min(100%, 640px);
}

.search {
  height: 42px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  line-height: 42px;
}

.top-actions {
  grid-column: 4;
}

.submit-nav-btn,
.icon-btn {
  height: 38px;
  border-radius: 10px;
}

.submit-nav-btn {
  color: var(--text);
  border-color: var(--line);
  background: var(--panel-strong);
  box-shadow: none;
}

.submit-nav-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
  background: var(--chip);
  box-shadow: none;
}

.content,
.content.categories-open {
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 24px;
  margin-top: 18px;
}

.sidebar,
.content.categories-open .sidebar {
  display: block;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 0 18px 16px 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
}

.sidebar-title {
  height: 34px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .06em;
}

#categoryTree,
#categoryTree.visible {
  display: block;
}

.all-btn {
  min-height: 42px;
  margin-bottom: 8px;
  border-radius: 9px;
}

.all-btn.active {
  color: var(--accent);
  border-color: transparent;
  background: var(--chip);
}

.tree-node.depth-0 {
  margin: 3px 0;
}

.tree-node.depth-0 > .tree-row,
.tree-node.depth-0 > .tree-row:hover {
  min-height: 42px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
}

.tree-node.depth-0 > .tree-row:hover {
  background: var(--panel);
}

.main-panel {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.filter-bar {
  min-height: 46px;
  margin-bottom: 10px;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--line);
}

.grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
}

.card {
  display: grid;
  grid-template-columns: minmax(175px, .85fr) minmax(230px, 1.45fr) minmax(220px, 1fr) 38px;
  align-items: center;
  gap: 16px;
  min-height: 82px;
  padding: 12px 14px 12px 18px;
  border: 1px solid color-mix(in srgb, var(--line) 84%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-strong) 70%, transparent);
  box-shadow: none;
  overflow: visible;
  transition: border-color .18s ease, background .18s ease;
}

.card:hover {
  transform: none;
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  background: color-mix(in srgb, var(--panel-strong) 96%, transparent);
  box-shadow: none;
}

.card.selected,
.card.selected:hover {
  transform: none;
  border-color: color-mix(in srgb, var(--accent) 62%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--panel-strong));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 10%, transparent);
}

.card:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.card-header { display: contents; }

.card h2 {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card p {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  -webkit-line-clamp: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-line {
  grid-column: 3;
  grid-row: 1;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 9px;
  margin: 0;
  overflow: visible;
}

.primary-chip {
  max-width: 120px;
  padding: 4px 8px;
  overflow: hidden;
  border-radius: 7px;
  font-size: 11px;
  text-overflow: ellipsis;
}

.inline-tag {
  flex: 0 0 auto;
  font-size: 11px;
}

.card-open {
  grid-column: 4;
  grid-row: 1;
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 18px;
  font-weight: 500;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}

.card:hover .card-open,
.card-open:hover {
  color: var(--accent);
  border-color: transparent;
  background: var(--chip);
  transform: translateX(2px);
}

@media (max-width: 1120px) and (min-width: 931px) {
  .card {
    grid-template-columns: minmax(145px, .8fr) minmax(180px, 1.25fr) minmax(155px, .9fr) 36px;
    gap: 12px;
  }

}

@media (max-width: 930px) {
  .page { width: min(100% - 24px, 1440px); }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px 0 12px;
  }

  .brand-area { display: none; }

  .category-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    grid-column: 1;
    min-width: 68px;
    height: 40px;
    border-radius: 10px;
  }

  .top-search {
    grid-column: 2;
    width: 100%;
  }

  .top-actions { grid-column: 3; }

  .content,
  .content.categories-open {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .sidebar {
    display: none;
    position: static;
    max-height: 430px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-soft);
  }

  .content.categories-open .sidebar { display: block; }
}

@media (max-width: 720px) {
  .card {
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 7px 12px;
    min-height: 108px;
    padding: 13px 12px 12px 14px;
  }

  .card h2 { grid-column: 1; grid-row: 1; font-size: 16px; }
  .card-open { grid-column: 2; grid-row: 1; }

  .card p {
    grid-column: 1 / -1;
    grid-row: 2;
    white-space: normal;
  }

  .meta-line {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .filter-bar { align-items: center; }
}

@media (max-width: 520px) {
  .page { width: min(100% - 16px, 1440px); }

  .topbar { gap: 7px; }

  .category-menu-btn {
    min-width: 44px;
    width: 44px;
    padding: 0;
    font-size: 0;
  }

  .category-menu-btn::before {
    content: "☰";
    font-size: 17px;
  }

  .submit-nav-btn {
    width: 40px;
    padding: 0;
    font-size: 0;
  }

  .submit-nav-btn::before {
    content: "+";
    font-size: 20px;
    font-weight: 500;
  }

  .top-actions { gap: 5px; }
  .search { padding-right: 34px; }
}

/* Live resources, favorites and duplicate checking */
.favorites-toggle,
.sort-control {
  display: inline-flex;
  align-items: center;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel-strong) 70%, transparent);
  font-size: 12px;
}

.favorites-toggle {
  gap: 6px;
  padding: 0 9px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}

.favorites-toggle:hover,
.favorites-toggle.active {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: var(--chip);
}

.favorites-total {
  display: inline-grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  font-size: 10px;
  font-weight: 750;
}

.sort-control {
  gap: 6px;
  padding-left: 9px;
}

.sort-select {
  height: 30px;
  padding: 0 24px 0 3px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.sort-select option {
  color: var(--text);
  background: var(--panel);
}

.resource-data-status {
  margin: -2px 4px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.resource-data-status:empty { display: none; }
.resource-data-status[data-tone="error"] { color: #f85149; }
.resource-data-status[data-tone="warning"] { color: #d29922; }

.card {
  grid-template-columns: minmax(175px, .82fr) minmax(230px, 1.4fr) minmax(220px, 1fr) 102px;
}

.card-actions {
  grid-column: 4;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 0;
}

.favorite-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 51px;
  height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  transition: color .18s ease, background .18s ease;
}

.favorite-star { font-size: 16px; line-height: 1; }

.favorite-btn:hover,
.favorite-btn.active {
  color: #d29922;
  background: color-mix(in srgb, #d29922 12%, transparent);
}

.favorite-btn:disabled { cursor: wait; opacity: .55; }

.card-open {
  grid-column: auto;
  grid-row: auto;
  width: 34px;
  min-width: 34px;
  height: 34px;
}

.duplicate-check.full {
  grid-column: 1 / -1;
}

.duplicate-check {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel-strong) 74%, transparent);
}

.duplicate-check[hidden] { display: none; }

.duplicate-check[data-tone="checking"] {
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.duplicate-check[data-tone="none"] {
  border-color: color-mix(in srgb, #3fb950 42%, var(--line));
}

.duplicate-check[data-tone="possible"],
.duplicate-check[data-tone="unavailable"] {
  border-color: color-mix(in srgb, #d29922 48%, var(--line));
}

.duplicate-check[data-tone="exact"] {
  border-color: color-mix(in srgb, #f85149 52%, var(--line));
}

.duplicate-check-summary {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

.duplicate-match-list {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.duplicate-match {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.duplicate-match div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.duplicate-match strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duplicate-match span { font-size: 11px; }

.duplicate-match a {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}

@media (max-width: 1120px) and (min-width: 931px) {
  .card {
    grid-template-columns: minmax(135px, .75fr) minmax(170px, 1.15fr) minmax(145px, .9fr) 96px;
  }

  .filter-actions { gap: 6px; }
  .result-count { display: none; }
}

@media (max-width: 720px) {
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .card { grid-template-columns: minmax(0, 1fr) 98px; }
  .card-actions { grid-column: 2; grid-row: 1; }
}

@media (max-width: 520px) {
  .sort-control > span { display: none; }
  .sort-control { padding-left: 3px; }
  .result-count { width: 100%; min-height: 20px; }
}
