:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --ink: #1f2522;
  --muted: #6b746f;
  --line: #dde4df;
  --brand: #1f7a5a;
  --brand-soft: #e8f3ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: 68px;
  gap: 24px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 245, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 176px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.nav {
  display: flex;
  gap: 18px;
  flex: 1;
  color: var(--muted);
}

.nav a:hover {
  color: var(--ink);
}

.button,
.search-panel button,
.plan a,
.plan button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  padding: 0 14px;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
}

.plain-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0 12px;
}

.plain-btn:hover {
  border-color: #b8c8bf;
  background: #f8faf8;
}

.plain-btn.danger {
  color: #b13333;
}

.plain-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.plain-btn:disabled:hover {
  border-color: var(--line);
  background: #fff;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 8px;
  padding: 0 13px;
}

.auth-actions .register-link {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.auth-actions .login-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.user-menu {
  position: relative;
}

.user-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  width: 40px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0;
}

.avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  object-fit: cover;
}

.user-dropdown {
  position: absolute;
  top: 48px;
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(31, 37, 34, 0.12);
  padding: 7px;
}

.user-dropdown[hidden] {
  display: none;
}

.user-dropdown a,
.user-dropdown button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0 10px;
  text-align: left;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
  background: #f1f4f1;
}

.user-dropdown .danger {
  color: #b13333;
}

main {
  max-width: 1180px;
  min-height: calc(100vh - 132px);
  margin: 0 auto;
  padding: 34px 24px 56px;
}

.hero {
  padding: 38px 0 28px;
}

.eyebrow,
.badge {
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

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

h1 {
  max-width: 800px;
  margin-bottom: 22px;
  font-size: 42px;
  line-height: 1.14;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
}

.muted,
.article-card p,
.track-card p,
.collection-card p,
.meta {
  color: var(--muted);
}

.search-panel {
  display: flex;
  width: min(780px, 100%);
  gap: 10px;
}

.search-panel input,
.search-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 15px;
}

.section {
  margin-top: 30px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

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

.track-grid {
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
}

.track-card,
.article-card,
.collection-card,
.training-card,
.side-panel,
.reader,
.plan {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.track-card {
  min-height: 104px;
  border-top: 3px solid var(--brand);
  padding: 13px 14px;
}

.track-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.track-card strong {
  font-size: 22px;
  line-height: 1;
}

.track-card p {
  display: -webkit-box;
  margin: 10px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 14px;
  line-height: 1.45;
}

.track-editor {
  display: grid;
  gap: 12px;
  margin: -2px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.track-editor[hidden] {
  display: none;
}

.track-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.track-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.track-option input {
  width: auto;
}

.track-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.article-card {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
}

.article-card h3 {
  margin: 8px 0 7px;
  font-size: 18px;
}

.article-card p {
  margin-bottom: 0;
}

.lock {
  align-self: start;
  color: var(--brand);
  font-weight: 800;
  white-space: nowrap;
}

.side-panel {
  padding: 18px;
}

.collection-card {
  padding: 18px;
}

.training-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.training-card {
  display: grid;
  gap: 18px;
  min-height: 190px;
  padding: 20px;
}

.training-card h3 {
  margin: 10px 0 8px;
}

.training-card p {
  color: var(--muted);
  line-height: 1.65;
}

.training-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: end;
}

.training-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf8;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
}

.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 22px;
}

.collection-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.reader {
  max-width: 820px;
  padding: 32px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumb a {
  color: var(--brand);
}

.breadcrumb span:last-child {
  color: var(--muted);
}

.reader h1 {
  font-size: 36px;
}

.reader-content {
  line-height: 1.85;
  white-space: pre-wrap;
}

.knowledge-save {
  display: grid;
  gap: 10px;
  margin: 18px 0 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  padding: 14px;
}

.knowledge-save p {
  margin: 6px 0 0;
}

.knowledge-save select,
.knowledge-save input,
.mini-form input,
.note-form input,
.note-form select,
.note-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.knowledge-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
}

.knowledge-panel,
.note-card,
.favorite-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.knowledge-main,
.mini-form,
.note-form,
.knowledge-list {
  display: grid;
  gap: 10px;
}

.knowledge-node-list {
  gap: 2px;
}

.knowledge-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.knowledge-panel-head h2 {
  margin-bottom: 0;
}

.knowledge-panel-head p {
  margin: 4px 0 0;
}

.note-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(31, 37, 34, 0.28);
  padding: 18px;
}

.note-modal[hidden] {
  display: none;
}

.note-editor {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(31, 37, 34, 0.18);
  padding: 18px;
}

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

.settings-shell {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 28px;
}

.settings-menu {
  display: grid;
  align-content: start;
  gap: 4px;
  border-right: 1px solid var(--line);
  padding: 10px 0;
}

.settings-menu button,
.settings-menu a {
  min-height: 38px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  padding: 0 16px;
}

.settings-menu .is-active {
  border-left-color: #1464ef;
  background: #edf2ff;
  color: #0f56d8;
}

.settings-content {
  max-width: 760px;
}

.settings-section {
  display: grid;
  gap: 24px;
}

.settings-section[hidden] {
  display: none;
}

.subscription-status {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.subscription-status span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.subscription-status strong {
  font-size: 24px;
}

.settings-card {
  max-width: none;
}

.profile-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 34px;
  align-items: start;
}

.avatar-editor {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.avatar-large {
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 34px;
  font-weight: 800;
  object-fit: cover;
}

.avatar-upload input {
  display: none;
}

img.avatar,
img.avatar-large {
  display: block;
}

.mini-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.mini-form button {
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  padding: 0 12px;
}

.two-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 10px;
}

.note-form textarea {
  min-height: 130px;
  resize: vertical;
}

.knowledge-tree {
  display: grid;
  gap: 2px;
}

.knowledge-tree-item {
  display: grid;
  gap: 2px;
}

.knowledge-tree-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 34px;
  border-radius: 7px;
  padding-left: calc(var(--depth, 0) * 16px);
}

.knowledge-tree-row:hover,
.knowledge-tree-item.is-open > .knowledge-tree-row {
  background: #f4f5f3;
}

.knowledge-tree-trigger {
  display: grid;
  grid-template-columns: 16px 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 0 6px;
  text-align: left;
}

.tree-caret {
  color: #8b928e;
  font-size: 18px;
  line-height: 1;
  text-align: center;
}

.tree-caret.is-empty {
  opacity: 0;
}

.tree-page-icon {
  width: 14px;
  height: 16px;
  border: 1px solid #9ba39e;
  border-radius: 3px;
  background: #fff;
}

.tree-title {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.knowledge-tree-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  opacity: 0.35;
  padding-right: 4px;
}

.knowledge-tree-row:hover .knowledge-tree-actions,
.knowledge-tree-actions:focus-within {
  opacity: 1;
}

.tree-action {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #69726d;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.tree-action:hover {
  background: #e8ece8;
  color: var(--ink);
}

.tree-action.danger:hover {
  color: #b13333;
}

.tree-action:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.tree-action:disabled:hover {
  background: transparent;
  color: #69726d;
}

.knowledge-tree-children {
  display: grid;
  gap: 2px;
}

.knowledge-tree-children[hidden] {
  display: none;
}

.knowledge-node {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.knowledge-node-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.knowledge-node-main strong {
  overflow-wrap: anywhere;
}

.knowledge-node-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.knowledge-node-actions .plain-btn {
  min-height: 30px;
  padding: 0 9px;
  font-size: 13px;
}

.knowledge-node-main span,
.note-card span,
.favorite-card span {
  color: var(--muted);
  font-size: 13px;
}

.note-card h3,
.favorite-card h3 {
  margin: 6px 0;
}

.note-card p,
.favorite-card p {
  color: var(--muted);
  white-space: pre-wrap;
}

.form-line {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.form-line span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.form-line input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.paywall {
  display: grid;
  gap: 10px;
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--brand-soft);
  padding: 18px;
}

.plans {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 760px;
}

.plan {
  padding: 22px;
}

.price {
  margin: 18px 0;
  font-size: 34px;
  font-weight: 900;
}

.footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  min-height: 64px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 22px;
}

@media (max-width: 860px) {
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    min-height: 0;
    padding: 12px 14px;
  }

  .nav {
    grid-column: 1 / -1;
    width: 100%;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

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

  .nav a {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    padding: 7px 12px;
    font-size: 14px;
  }

  .brand {
    min-width: 0;
  }

  .brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-area {
    justify-content: end;
  }

  .auth-actions a {
    min-height: 34px;
    padding: 0 11px;
    font-size: 14px;
  }

  main {
    padding: 18px 14px 38px;
  }

  h1 {
    font-size: 28px;
    line-height: 1.18;
  }

  h2 {
    font-size: 18px;
  }

  .hero {
    padding: 22px 0 14px;
  }

  .search-panel,
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .search-panel {
    gap: 8px;
  }

  .search-panel button {
    width: 100%;
  }

  .section {
    margin-top: 22px;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .track-grid,
  .article-layout,
  .collection-grid,
  .plans {
    grid-template-columns: 1fr;
  }

  .track-card {
    min-height: 0;
  }

  .article-card {
    display: grid;
    gap: 12px;
  }

  .lock {
    justify-self: start;
  }

  .reader {
    padding: 20px;
  }

  .reader h1 {
    font-size: 27px;
  }

  .knowledge-layout,
  .settings-grid,
  .settings-shell,
  .profile-editor,
  .two-inputs {
    grid-template-columns: 1fr;
  }

  .knowledge-node {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .knowledge-node-actions {
    justify-content: flex-start;
  }

  .knowledge-tree-trigger {
    grid-template-columns: 16px 16px minmax(0, 1fr);
  }

  .tree-count {
    display: none;
  }

  .knowledge-tree-actions {
    opacity: 1;
  }

  .settings-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
  }

  .settings-menu button,
  .settings-menu a {
    border-left: 0;
    border-radius: 8px;
    background: #fff;
  }

  .settings-menu .is-active {
    border-left: 0;
    background: #edf2ff;
  }

  .footer {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }

  .user-dropdown {
    right: 0;
    min-width: 168px;
  }
}
