:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f7f7f7;
  --panel-strong: #efefef;
  --line: #e7e7e7;
  --ink: #141414;
  --muted: #6a6a6a;
  --soft: #9b9b9b;
  --black: #141414;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.skill-page {
  min-height: 100vh;
  padding: 54px clamp(18px, 5vw, 72px) 80px;
}

.skill-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 0 auto 44px;
  max-width: 1180px;
}

.skill-header h1 {
  margin: 0 0 28px;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
}

.top-switch {
  display: inline-flex;
  gap: 0;
  padding: 4px;
  border-radius: 10px;
  background: #f3f3f3;
}

.top-switch button {
  display: inline-flex;
  height: 38px;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #555;
  font-size: 20px;
}

.top-switch button.active {
  background: #fff;
  color: #101010;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tab-icon {
  color: #111;
  font-size: 20px;
}

.skill-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 74px;
}

.search-box {
  display: flex;
  width: min(300px, 30vw);
  height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #aaa;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: #222;
}

.search-box input::placeholder {
  color: #aaa;
}

.create-button {
  display: inline-flex;
  height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: #141414;
  color: #fff;
  font-size: 18px;
}

.create-button span {
  font-size: 30px;
  line-height: 1;
}

.create-menu {
  position: absolute;
  top: 58px;
  right: 0;
  z-index: 6;
  width: 300px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.create-menu button {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.create-menu button:hover {
  background: #f5f5f5;
}

.create-menu strong,
.create-menu small {
  display: block;
}

.create-menu strong {
  font-size: 16px;
}

.create-menu small {
  margin-top: 3px;
  color: var(--soft);
  font-size: 13px;
}

.skill-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 24px;
  max-width: 1180px;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.category-tabs button {
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #4e4e4e;
  font-size: 19px;
}

.category-tabs button.active {
  background: #f2f2f2;
  color: #111;
}

#skillSortSelect {
  height: 42px;
  border: 0;
  background: transparent;
  color: #555;
  outline: 0;
  font-size: 17px;
}

.skill-grid {
  display: grid;
  max-width: 1180px;
  margin: 0 auto;
  grid-template-columns: repeat(3, minmax(230px, 1fr));
  gap: 18px;
}

.skill-card {
  min-height: 168px;
  padding: 24px 24px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  text-align: left;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.skill-card:hover {
  border-color: #d4d4d4;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.07);
  transform: translateY(-2px);
}

.skill-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}

.skill-card-badges span {
  max-width: 100%;
  overflow: hidden;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f3f3;
  color: #5f5f5f;
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-card h2 {
  overflow: hidden;
  margin: 0 0 14px;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skill-card p {
  display: -webkit-box;
  min-height: 58px;
  margin: 0 0 18px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: #5d5d5d;
  font-size: 18px;
  line-height: 1.6;
}

.skill-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #aaa;
  font-size: 16px;
}

.skill-card-agent {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  max-width: 1180px;
  margin: 50px auto 0;
  padding: 42px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

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

.skill-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.68);
}

.skill-modal {
  position: relative;
  width: min(1180px, calc(100vw - 48px));
  display: flex;
  min-height: 0;
  max-height: calc(100vh - 64px);
  flex-direction: column;
  overflow: hidden;
  padding: 48px 30px 24px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.18);
}

.modal-close {
  position: absolute;
  top: 26px;
  right: 28px;
  border: 0;
  background: transparent;
  color: #666;
  font-size: 36px;
  line-height: 1;
}

.skill-modal h2 {
  margin: 0 42px 12px 0;
  font-size: 22px;
  font-weight: 500;
}

.skill-modal-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  color: #666;
  font-size: 18px;
}

.skill-modal-meta span:nth-child(2) {
  width: 1px;
  height: 18px;
  background: #ddd;
}

.skill-modal p {
  margin: 0;
  max-width: 920px;
  color: #555;
  font-size: 17px;
  line-height: 1.65;
}

.skill-modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.skill-modal-tags span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #f2f2f2;
  color: #666;
  font-size: 13px;
}

.skill-modal .skill-install-note {
  margin: 12px 0 0;
  max-width: none;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 10px;
  padding: 10px 12px;
  background: #effaf5;
  color: #0f5f58;
  font-size: 14px;
  line-height: 1.6;
}

.skill-package-preview {
  min-height: 0;
  margin-top: 14px;
  margin-bottom: 16px;
  border: 1px solid #e7e7e7;
  border-radius: 14px;
  overflow: hidden;
  background: #fafafa;
}

.skill-package-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #e7e7e7;
  padding: 10px 14px;
  color: #202020;
}

.skill-package-head span {
  color: #777;
  font-size: 13px;
}

.skill-package-body {
  display: grid;
  height: clamp(180px, 32vh, 280px);
  min-height: 0;
  grid-template-columns: 240px minmax(0, 1fr);
}

.skill-file-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  border-right: 1px solid #e7e7e7;
  padding: 10px;
  background: #fff;
}

.skill-file-list button {
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  background: transparent;
  color: #333;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  text-align: left;
}

.skill-file-list button.active,
.skill-file-list button:hover {
  background: #f0f0f0;
}

.skill-file-content {
  margin: 0;
  overflow: auto;
  padding: 18px;
  background: #fbfbfb;
  color: #222;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.modal-primary {
  display: flex;
  height: 50px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 10px;
  background: #141414;
  color: #fff;
  font-size: 18px;
}

.modal-primary:disabled {
  cursor: default;
  opacity: 0.76;
}

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

  .skill-header {
    flex-direction: column;
  }

  .skill-actions {
    width: 100%;
    margin-top: 0;
  }

  .search-box {
    width: 100%;
  }
}

@media (max-width: 760px) {
  .skill-page {
    padding: 24px 14px 50px;
  }

  .skill-grid {
    grid-template-columns: 1fr;
  }

  .skill-actions {
    flex-wrap: wrap;
  }

  .create-button {
    width: 100%;
    justify-content: center;
  }

  .create-menu {
    right: auto;
    left: 0;
    width: min(320px, calc(100vw - 28px));
  }
}
