:root {
  --primary: #6c5ce7;
  --primary-light: #a29bfe;
  --primary-dark: #5a4bd1;
  --brand-green: #00b894;
  --brand-red: #e74c3c;
  --bg: #fafbfc;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --surface: #ffffff;
}

.dark {
  --primary: #a29bfe;
  --primary-light: #6c5ce7;
  --primary-dark: #c4b5fd;
  --brand-green: #55efc4;
  --brand-red: #ff6b6b;
  --bg: #0f172a;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --border: #334155;
  --surface: #1e293b;
}

* { box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; margin: 0; }

.primary { color: var(--primary); }

.nav {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 32px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100;
}
.nav-logo { font-size: 20px; font-weight: 700; color: var(--primary); text-decoration: none; letter-spacing: -0.5px; }
.nav-tabs { display: flex; align-items: center; gap: 4px; }
.nav-tab {
  text-decoration: none; color: var(--text-muted); font-size: 13px; font-weight: 500;
  padding: 6px 14px; border-radius: 20px; transition: all 0.2s;
}
.nav-tab:hover { color: var(--text); background: rgba(108,92,231,0.05); }
.nav-tab.active { color: var(--primary); background: rgba(108,92,231,0.1); font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 14px; }
.nav-right a { text-decoration: none; color: var(--text-muted); font-size: 13px; font-weight: 500; transition: color 0.2s; }
.nav-right a:hover { color: var(--text); }

.gradient-bar { height: 3px; background: linear-gradient(to right, transparent, rgba(108,92,231,0.3), transparent); }

.container { max-width: 1200px; margin: 0 auto; padding: 32px 40px 80px; }

.page-section { display: none; }
.page-section.active { display: block; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 20px; border-radius: 4px; font-size: 13px; font-weight: 500;
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  transition: all 0.2s; text-decoration: none;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(108,92,231,0.25); }
.btn-primary:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 20px; border-radius: 4px; font-size: 13px; font-weight: 500;
  background: var(--surface); color: var(--primary); border: 1px solid var(--primary-light);
  cursor: pointer; transition: all 0.2s; text-decoration: none;
}
.btn-outline:hover { background: #f5f3ff; border-color: var(--primary); transform: translateY(-1px); }

.btn-sm {
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; transition: all 0.2s;
}
.btn-sm:hover { border-color: var(--primary); color: var(--primary); }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.skill-card {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; transition: all 0.2s; cursor: pointer; text-decoration: none; color: inherit;
}
.skill-card:hover { border-color: var(--primary-light); box-shadow: 0 2px 12px rgba(108,92,231,0.08); }

.skill-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.skill-card-name { font-size: 14px; font-weight: 600; }
.skill-card-namespace {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 10px; font-size: 11px; font-weight: 500;
  background: #dbeafe; color: #1d4ed8;
}
.skill-card-desc {
  font-size: 12px; line-height: 1.7; color: var(--text-muted);
  margin-bottom: 12px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.skill-card-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag-badge {
  display: inline-flex; align-items: center; padding: 2px 10px;
  border-radius: 12px; font-size: 11px; font-weight: 500;
  background: var(--primary); color: #fff;
}
.tag-version { font-size: 11px; color: var(--text-light); font-family: monospace; }
.tag-download { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-light); }

.skill-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid #f1f5f9;
}
.skill-card-author { font-size: 11px; color: var(--text-light); }
.skill-card-action { font-size: 11px; color: var(--text-light); display: flex; align-items: center; gap: 4px; }

.home-hero { text-align: true; padding: 56px 0 32px; }
.home-hero h1 {
  font-size: 42px; font-weight: 700; letter-spacing: -1px;
  background: linear-gradient(to bottom right, var(--primary), var(--primary-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.home-hero p { font-size: 17px; color: var(--text-muted); max-width: 560px; margin: 0 auto 28px; line-height: 1.8; }
.home-hero-btns { display: flex; justify-content: center; gap: 12px; }

.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 40px; }
.feature-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 28px; text-align: center; transition: all 0.2s;
}
.feature-card:hover { border-color: var(--primary-light); box-shadow: 0 4px 16px rgba(108,92,231,0.1); transform: translateY(-2px); }
.feature-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}

.search-form { display: flex; align-items: stretch; margin-bottom: 16px; }
.search-input {
  border: 1px solid var(--border); border-right: 0; border-radius: 4px 0 0 4px;
  padding: 8px 14px; width: 100%; font-size: 13px; background: var(--bg); color: var(--text);
  outline: none; transition: border-color 0.2s; line-height: 1.4; box-sizing: border-box;
}
.search-input:focus { border-color: var(--primary-light); background: var(--surface); }
.search-btn {
  background: var(--primary); color: #fff; border: none;
  padding: 8px 24px; border-radius: 0 4px 4px 0; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.2s;
  white-space: nowrap; line-height: 1.4; box-sizing: border-box;
}
.search-btn:hover { background: var(--primary-dark); }

.filter-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.category-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-tab {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.2s; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-muted);
}
.cat-tab:hover { border-color: var(--primary-light); color: var(--text); }
.cat-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.sort-select {
  border: 1px solid var(--border); border-radius: 4px;
  padding: 6px 10px; font-size: 13px; color: var(--text-muted); background: var(--surface);
  cursor: pointer; outline: none;
}

.upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; border: 2px dashed var(--border); border-radius: 8px;
  transition: all 0.2s; cursor: pointer;
}
.upload-zone:hover { border-color: var(--primary-light); background: rgba(108,92,231,0.03); }
.upload-zone.dragover { border-color: var(--primary); background: rgba(108,92,231,0.08); }

.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.form-input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px; background: var(--surface); color: var(--text); outline: none;
  transition: border-color 0.2s;
}
.form-input.input-error { border-color: #e74c3c; background: rgba(231,76,60,0.05); }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,92,231,0.08); }
.form-select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px; background: var(--surface); color: var(--text); outline: none; cursor: pointer;
}

.form-box { background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 32px; }

.preview-box { background: rgba(0,184,148,0.05); border: 1px solid rgba(0,184,148,0.2); border-radius: 8px; padding: 16px; margin-bottom: 20px; }
.skill-fields { margin-bottom: 20px; }

.token-bar {
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 18px 22px; margin-bottom: 22px;
}
.token-display {
  flex: 1; padding: 8px 14px; background: var(--bg); border-radius: 4px;
  font-family: monospace; font-size: 13px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ns-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; transition: all 0.2s; cursor: pointer;
}
.ns-card:hover { border-color: var(--primary-light); box-shadow: 0 2px 8px rgba(108,92,231,0.08); }

.data-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; transition: all 0.2s;
}
.data-item:hover { border-color: var(--primary-light); box-shadow: 0 2px 8px rgba(108,92,231,0.08); }

.section-title { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.section-subtitle { font-size: 14px; color: var(--text-muted); }

.tab-bar { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; transition: all 0.2s; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.table-container { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { padding: 8px 12px; text-align: left; color: var(--text-light); font-weight: 500; border-bottom: 1px solid var(--border); background: var(--surface); }
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }

.badge-required { color: var(--brand-red); }

/* Skill Detail Page */
.skill-detail-page {
  max-width: 900px;
}

.skill-detail-breadcrumb {
  margin-bottom: 24px;
}

.breadcrumb-link {
  color: var(--primary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s;
}

.breadcrumb-link:hover {
  opacity: 0.8;
}

.skill-detail-header {
  margin-bottom: 24px;
}

.skill-detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.skill-detail-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0;
}

.btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: var(--brand-red);
  border: 1px solid var(--brand-red);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-delete:hover {
  background: var(--brand-red);
  color: #fff;
}

.skill-detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.skill-category-select {
  padding: 3px 10px; border: 1px solid var(--border); border-radius: 12px;
  font-size: 11px; font-weight: 500; background: var(--primary); color: #fff;
  outline: none; cursor: pointer; appearance: none;
  -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='white'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  padding-right: 22px;
}
.skill-category-select:hover { background: var(--primary-dark); }

.skill-detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.skill-detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.skill-detail-section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.skill-detail-description {
  font-size: 15px;
  line-height: 1.8;
  color: var(--text-muted);
  margin: 0 0 16px 0;
}

.skill-detail-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.skill-detail-tag {
  background: rgba(108,92,231,0.1);
  color: var(--primary);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
}

.skill-detail-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.skill-detail-info-item {
  font-size: 13px;
  color: var(--text-light);
}

.skill-detail-content-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.skill-detail-code {
  padding: 20px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  line-height: 1.6;
  overflow-x: auto;
  max-height: 600px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.skill-detail-version-list {
  max-height: 300px;
  overflow-y: auto;
}

.skill-detail-version-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.skill-detail-version-item:last-child {
  border-bottom: none;
}

.version-number {
  font-family: monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.version-date {
  color: var(--text-light);
  font-size: 12px;
  margin-left: 8px;
}

.version-changelog {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
  margin-bottom: 0;
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.modal-content {
  background: var(--surface); border-radius: 12px; padding: 32px;
  max-width: 600px; width: 90%; max-height: 80vh; overflow-y: auto;
}

.toast {
  position: fixed; bottom: 20px; right: 20px; padding: 12px 24px;
  border-radius: 8px; font-size: 13px; font-weight: 500; z-index: 300;
  background: var(--primary); color: #fff; transform: translateY(100px);
  opacity: 0; transition: all 0.3s;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--brand-red); }
.toast.success { background: var(--brand-green); }

@media (max-width: 768px) {
  .container { padding: 16px 20px 40px; }
  .nav { padding: 0 16px; }
  .nav-tabs { display: none; }
  .feature-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
  .home-hero h1 { font-size: 28px; }
}

.animate-card-in {
  animation: cardIn 0.4s ease-out forwards;
  opacity: 0;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.fade-in { animation: fadeIn 0.3s ease-out; }

/* ===== Update Drawer ===== */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer {
  position: fixed; top: 0; right: 0; width: 480px; max-width: 100vw;
  height: 100vh; background: var(--surface); z-index: 201;
  transform: translateX(100%); transition: transform 0.32s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  box-shadow: -4px 0 40px rgba(0,0,0,0.13);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.drawer-title { font-size: 16px; font-weight: 600; }
.drawer-close {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 6px; border-radius: 6px; display: flex; transition: color 0.2s, background 0.2s;
}
.drawer-close:hover { color: var(--text); background: var(--border); }

.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 12px; flex-shrink: 0;
}

.upload-zone-sm { padding: 20px 16px; }
.upload-zone-sm p { margin: 0; }

.drawer-file-preview {
  margin-top: 8px; font-size: 12px; color: var(--text-muted);
  padding: 10px 12px; background: rgba(0,184,148,0.05);
  border: 1px solid rgba(0,184,148,0.25); border-radius: 6px;
  display: flex; align-items: center; gap: 6px;
}

/* Update button next to delete */
.btn-update {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 500;
  background: var(--primary); color: #fff; border: none; cursor: pointer; transition: all 0.2s;
}
.btn-update:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(108,92,231,0.25); }

/* Version history item header */
.version-item-header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

.form-textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px; background: var(--surface); color: var(--text); outline: none;
  transition: border-color 0.2s; resize: vertical; font-family: inherit; min-height: 160px; line-height: 1.6;
}
.form-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,92,231,0.08); }

/* ========== Password Gate ========== */
.password-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
}

.password-gate.hidden {
  display: none;
}

.password-gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(108,92,231,0.06);
}

.password-gate-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  display: block;
  margin-bottom: 28px;
  letter-spacing: -0.5px;
}

.password-gate-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}

.password-gate-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 24px;
  line-height: 1.5;
}

.password-error {
  font-size: 13px;
  color: var(--brand-red);
  margin: 8px 0 0;
  min-height: 18px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.4s ease;
}

.password-gate-fade-out {
  animation: fadeOut 0.25s ease forwards;
}

@keyframes fadeOut {
  to { opacity: 0; pointer-events: none; }
}
