*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0f14;
  --surface:   #161921;
  --surface2:  #1e2130;
  --border:    #252836;
  --accent:    #e8943a;
  --accent-dim:#7a4a1a;
  --text:      #c8ccd8;
  --text-muted:#5a5f75;
  --text-dim:  #8a8fa8;
  --success:   #4ade80;
  --danger:    #f87171;
  --radius:    6px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: "Courier New", Courier, monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

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

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px 4px 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.avatar-img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.logout-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}
.logout-link:hover { color: var(--danger); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--accent); color: #0d0f14; border-color: var(--accent); }
.btn-primary:hover { background: #f0a855; }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: rgba(248,113,113,0.1); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.search-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
}

.search-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input-wrap { flex: 1; position: relative; min-width: 200px; }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

input[type="text"], textarea, select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}

#searchInput { padding-left: 36px; }
input[type="text"]:focus { border-color: var(--accent); }
input[type="text"]::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: none; min-height: 70px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
textarea:focus { border-color: var(--accent); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; margin: 0; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; min-height: 30px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-corner { background: transparent; }
textarea::-webkit-scrollbar-track { margin: 2px 0; }

.tag-filters { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.tag-filter {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
}
.tag-filter:hover { border-color: var(--accent); color: var(--accent); }
.tag-filter.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.tag-count { opacity: 0.6; font-size: 10px; }

.content { padding: 24px; }

.content-header {
  max-width: 1200px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.result-count { color: var(--text-muted); font-size: 13px; }

.sort-select {
  width: auto;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  padding: 5px 10px;
  cursor: pointer;
}

.package-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}

.package-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.package-card:hover { border-color: var(--accent); background: var(--surface2); }

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

.card-name { font-size: 15px; font-weight: 600; color: var(--text); }

.version-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags { display: flex; gap: 5px; flex-wrap: wrap; }

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.card-author { display: flex; align-items: center; gap: 5px; }

.card-shortcuts {
  display: flex;
  gap: 6px;
  padding-top: 2px;
}

.shortcut-btn {
  padding: 3px 10px;
  font-size: 11px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.shortcut-btn:hover { border-color: var(--accent); color: var(--accent); }

.avatar-initials {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: flex-end;
}
.detail-overlay.open { display: flex; }

.detail-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  width: 420px;
  height: 100vh;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideIn 0.2s ease;
}

.detail-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface2);
}

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.detail-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  align-self: flex-end;
  padding: 4px;
  line-height: 1;
}
.detail-close:hover { color: var(--text); }

.detail-name { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.detail-desc { font-size: 14px; color: var(--text-dim); line-height: 1.6; }

.detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 13px;
}
.meta-label { color: var(--text-muted); }
.meta-value { color: var(--text); font-variant-numeric: tabular-nums; }

.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.detail-actions .btn { flex: 1; justify-content: center; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px;
  width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-title { font-size: 17px; font-weight: 700; color: var(--text); }

.form-group { display: flex; flex-direction: column; gap: 5px; }

label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone:hover { border-color: var(--accent); background: var(--surface2); color: var(--text-dim); }
.drop-zone .drop-icon { font-size: 24px; margin-bottom: 6px; }

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

.cli-command-block {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.cli-command-block code {
  flex: 1;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  color: var(--accent);
  word-break: break-all;
}

.cli-command-block .btn {
  flex-shrink: 0;
}

.error-msg {
  background: rgba(248,113,113,0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  padding: 8px 12px;
  font-size: 13px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.meta-thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.meta-thumb:hover {
  border-color: var(--accent);
  transform: scale(1.03);
}

.history-entry {
  border-left: 2px solid var(--border);
  padding: 8px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-entry:hover { border-left-color: var(--accent); }

.history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-download {
  margin-left: auto;
  padding: 2px 8px;
}

.history-notes {
  font-size: 12px;
  color: var(--text-dim);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--surface2);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.stars { display: flex; gap: 2px; }
.star {
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.1s, transform 0.1s;
  user-select: none;
}
.star.star-filled { color: var(--accent); }
.star:hover, .star.user-rated { color: var(--accent); }
.star:hover { transform: scale(1.2); }

.card-size {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
}

.card-downloads {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.card-rating {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 1px;
}
.card-rating-filled { color: var(--accent); }
.card-rating-empty { color: var(--text-muted); opacity: 0.4; }
.card-rating-count { color: var(--text-muted); font-size: 11px; margin-left: 4px; }

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.readme-content { font-size: 13px; line-height: 1.7; color: var(--text-dim); }
.readme-content h1, .readme-content h2, .readme-content h3, .readme-content h4 { color: var(--text); margin: 12px 0 6px; font-weight: 600; }
.readme-content h1 { font-size: 16px; }
.readme-content h2 { font-size: 15px; }
.readme-content h3, .readme-content h4 { font-size: 13px; }
.readme-content p { margin: 0 0 8px; }
.readme-content ul { padding-left: 18px; margin: 0 0 8px; }
.readme-content li { margin-bottom: 3px; }
.readme-content code { font-family: "Courier New", monospace; font-size: 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 3px; padding: 1px 5px; color: var(--accent); }
.readme-content a { color: var(--accent); text-decoration: none; }
.readme-content a:hover { text-decoration: underline; }

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.lightbox-close:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.lightbox-nav:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.lightbox-nav-prev { left: 20px; }
.lightbox-nav-next { right: 20px; }

.file-tree { font-size: 12px; font-family: "Courier New", monospace; line-height: 1.6; }
.tree-dir {
  color: var(--accent);
  padding: 3px 0;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tree-dir:hover { color: #f0a855; }
.tree-arrow { font-size: 9px; color: var(--text-muted); width: 10px; flex-shrink: 0; }
.tree-file { color: var(--text-muted); padding: 2px 0; display: flex; justify-content: space-between; align-items: center; }
.tree-file:hover { color: var(--text); }
.tree-file:hover .tree-size { opacity: 1; color: var(--text-dim); }
.tree-size { color: var(--text-muted); font-size: 11px; flex-shrink: 0; margin-left: 8px; opacity: 0.6; transition: opacity 0.15s; }
.tree-children { border-left: 1px solid var(--border); margin-left: 5px; padding-left: 8px; }

.updated-badge {
  font-size: 10px;
  color: var(--success);
  font-weight: 600;
  vertical-align: middle;
  margin-left: 4px;
}

.pager {
  max-width: 1200px;
  margin: 20px auto 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.pager-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.pager-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.pager-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.pager-ellipsis { color: var(--text-muted); padding: 0 2px; }

.settings-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.settings-tab {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.settings-tab:hover { color: var(--text-dim); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.settings-panel { display: flex; flex-direction: column; gap: 14px; }

.type-checkboxes { display: flex; gap: 14px; flex-wrap: wrap; }
.type-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
}
.type-checkbox input { width: auto; accent-color: var(--accent); cursor: pointer; }

.type-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.loading { color: var(--text-muted); padding: 60px; text-align: center; grid-column: 1/-1; }

.empty { text-align: center; padding: 80px 24px; color: var(--text-muted); grid-column: 1/-1; }
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty h3 { font-size: 16px; color: var(--text-dim); margin-bottom: 6px; }
