:root {
  --bg: #0a0b10;
  --bg-card: #12131a;
  --bg-input: #181924;
  --bg-hover: #1e2030;
  --border: #2a2d3e;
  --border-focus: #00e88f;
  --text: #e4e6f0;
  --text-muted: #8b8fa3;
  --text-dim: #5c6078;
  --accent: #00e88f;
  --accent-dim: rgba(0, 232, 143, 0.12);
  --danger: #ff5470;
  --danger-dim: rgba(255, 84, 112, 0.12);
  --warn: #ffcc4d;
  --warn-dim: rgba(255, 204, 77, 0.12);
  --blue: #6c8aff;
  --blue-dim: rgba(108, 138, 255, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
}

.logo-icon {
  font-size: 18px;
}

.nav {
  display: flex;
  gap: 4px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active { color: var(--accent); background: var(--accent-dim); }

/* Main layout */
.main-wrap {
  display: flex;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 24px;
  gap: 24px;
}

.content {
  flex: 1;
  min-width: 0;
}

.view { display: block; }
.view.hidden { display: none; }

/* Sidebar */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.sidebar-widget h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.widget-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

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

.repo-item a {
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  word-break: break-word;
}

.repo-item a:hover { text-decoration: underline; }

.repo-stars {
  color: var(--warn);
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.pkg-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pkg-name {
  font-size: 13px;
  color: var(--text);
  font-family: var(--font-mono);
}

.pkg-version {
  font-size: 12px;
  color: var(--accent);
  font-family: var(--font-mono);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Generator */
.gen-header {
  margin-bottom: 24px;
}

.gen-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

.gen-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 14px 16px;
  resize: vertical;
  width: 100%;
  transition: border-color 0.15s;
}

textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.examples-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-ui);
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg-hover);
  color: var(--text);
}

.btn:hover { border-color: var(--text-muted); }

.btn.primary {
  background: var(--accent);
  color: #0a0b10;
  border-color: var(--accent);
}

.btn.primary:hover {
  background: #00cc7d;
  border-color: #00cc7d;
}

.btn.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn.ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.hidden { display: none !important; }

/* Error */
.error-box {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--danger);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* Result panel */
.result-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.result-title {
  font-size: 18px;
  font-weight: 700;
}

.result-actions {
  display: flex;
  gap: 8px;
}

.validation-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: 4px;
}

.validation-badge.pass {
  background: var(--accent-dim);
  color: var(--accent);
}

.validation-badge.fail {
  background: var(--danger-dim);
  color: var(--danger);
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content {
  display: none;
  padding: 0;
}

.tab-content.active { display: block; }

.code-block {
  padding: 16px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre;
  max-height: 500px;
  overflow-y: auto;
}

/* Validation detail */
.validation-detail {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.validation-detail summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.check-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.check-item {
  font-size: 12px;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-pass { color: var(--accent); }
.check-fail { color: var(--danger); }

/* Environment grid */
.env-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.env-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.env-card-title {
  font-size: 15px;
  font-weight: 600;
}

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

.env-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.env-card-date {
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.env-card-fork {
  font-size: 11px;
  color: var(--blue);
  font-family: var(--font-mono);
}

/* Pagination */
.pagination {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  justify-content: center;
}

.page-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-mono);
}

.page-btn:hover { color: var(--text); border-color: var(--text-muted); }
.page-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

/* Detail view */
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 16px;
}

.detail-back:hover { color: var(--text); }

.detail-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  animation: slideIn 0.2s ease;
  max-width: 320px;
}

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state h3 {
  font-size: 16px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

/* Spinner */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-spinner::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(10,11,16,0.3);
  border-top-color: #0a0b10;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 6px;
  vertical-align: middle;
}

/* Responsive */
@media (max-width: 900px) {
  .main-wrap {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-widget {
    flex: 1;
    min-width: 200px;
  }
  .env-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .topbar {
    gap: 16px;
    padding: 0 12px;
  }
  .main-wrap {
    padding: 16px;
  }
  .gen-header h1 {
    font-size: 20px;
  }
  .result-actions {
    flex-wrap: wrap;
  }
}
