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

:root {
  --bg:        #f7f7f5;
  --bg-card:   #ffffff;
  --border:    #e4e7ed;
  --border-2:  #eef0f4;
  --text:      #1a1a2e;
  --muted:     #6b7280;
  --subtle:    #8a94a6;
  --accent:    #1a1a2e;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 1px 3px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.1);
}

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

/* ── Intro (replaces the old hero) ─────────────────────────── */
.cl-intro {
  max-width: 1400px;
  margin: 0 auto;
  padding: 3rem 2rem 1.75rem;
}
.cl-kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 0.875rem;
}
.cl-h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.625rem;
}
.cl-sub {
  font-size: 0.9375rem;
  color: var(--muted);
  max-width: 460px;
  line-height: 1.6;
}

/* ── Header ────────────────────────────────────────────────── */
.cl-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 2rem; height: 60px;
}

.cl-header-logo {
  display: flex; align-items: center; gap: 0.625rem;
  font-size: 0.9375rem; font-weight: 700; color: var(--text);
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
  letter-spacing: -0.01em;
}
.cl-header-logo:hover { opacity: .75; }

.cl-header-divider {
  width: 1px; height: 20px; background: var(--border); flex-shrink: 0;
}

.cl-title {
  font-size: 0.9375rem; font-weight: 600; color: var(--text);
  flex-shrink: 0;
}

.cl-search-wrap {
  flex: 1; max-width: 380px; display: flex; align-items: center;
  gap: 0.5rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 0 0.875rem; height: 36px;
  transition: border-color .15s, box-shadow .15s;
}
.cl-search-wrap:focus-within {
  border-color: #16213e;
  box-shadow: 0 0 0 3px rgba(22,33,62,.1);
  background: white;
}
.cl-search-icon { color: var(--subtle); font-size: 0.8rem; }
.cl-search-wrap input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-size: 0.875rem; color: var(--text);
  font-family: inherit;
}
.cl-search-wrap input::placeholder { color: var(--subtle); }

.cl-header-actions { display: flex; gap: 0.625rem; align-items: center; margin-left: auto; }

.cl-btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 1rem; border-radius: 7px; font-size: 0.8125rem;
  font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  background: white; color: var(--text); text-decoration: none;
  transition: all .15s; white-space: nowrap; font-family: inherit;
}
.cl-btn:hover { background: var(--bg); border-color: #ccc; }
.cl-btn-primary {
  background: var(--text) !important; color: white !important;
  border-color: var(--text) !important;
}
.cl-btn-primary:hover { opacity: .85; }

/* ── Filter bar ─────────────────────────────────────────────── */
.cl-filter-bar {
  max-width: 1400px; margin: 0 auto;
  padding: 0.5rem 2rem 1.25rem;
  display: flex; align-items: center; gap: 1.5rem;
  flex-wrap: wrap;
}
.cl-filter-label {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--subtle); white-space: nowrap;
}
.cl-sort-select {
  border: 1px solid var(--border); border-radius: 7px; padding: 0.35rem 0.75rem;
  font-size: 0.8rem; font-weight: 500; font-family: inherit; cursor: pointer;
  background: white; color: var(--text); outline: none;
  transition: border-color .15s;
}
.cl-sort-select:hover { border-color: #bbb; }

/* ── Stats bar ──────────────────────────────────────────────── */
.cl-stats {
  display: flex; align-items: center; gap: 1.5rem;
  margin-left: auto;
  font-size: 0.75rem; color: var(--subtle);
}
.cl-stat { display: flex; align-items: center; gap: 0.375rem; }
.cl-stat i { font-size: 0.7rem; }

/* ── Main layout ────────────────────────────────────────────── */
.cl-page-body {
  max-width: 1400px; margin: 0 auto; padding: 0.5rem 2rem 2rem;
}
.cl-shared-section {
  max-width: 1400px; margin: 0 auto; padding: 1.5rem 2rem 5rem;
  border-top: 1px solid var(--border-2);
}
.cl-section-title {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--subtle); margin-bottom: 0.5rem;
  padding-top: 1.5rem;
}
.cl-section-note {
  font-size: 0.8125rem; color: var(--muted); margin-bottom: 1.25rem;
}

/* ── Skill grid ─────────────────────────────────────────────── */
.cl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* ── Skill cards ────────────────────────────────────────────── */
.cl-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.375rem;
  cursor: pointer; transition: border-color .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 0.625rem;
  position: relative;
  overflow: hidden;
}
.cl-card:hover {
  box-shadow: var(--shadow);
  border-color: #c8cdd6;
}

.cl-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cl-card-saves {
  font-size: 0.7rem; color: var(--muted);
  background: var(--bg);
  padding: 0.175rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border-2);
  font-weight: 500;
}
.cl-card-name {
  font-size: 0.9375rem; font-weight: 600; color: var(--text);
  line-height: 1.35;
  display: flex; align-items: center; gap: 0.5rem;
}
.cl-card-icon {
  flex-shrink: 0;
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.cl-card-desc {
  font-size: 0.8125rem; color: var(--muted); line-height: 1.55;
  flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.cl-card-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.15rem; }
.cl-tag {
  font-size: 0.675rem; padding: 0.15rem 0.45rem;
  background: var(--bg); color: var(--muted); border-radius: 4px;
  border: 1px solid var(--border-2);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.cl-tag:hover { background: #eef0f4; color: var(--text); }
.cl-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 0.75rem; border-top: 1px solid var(--border-2);
  margin-top: 0.25rem;
}
.cl-card-author { font-size: 0.75rem; color: var(--subtle); }
.cl-card-popular {
  font-size: 0.65rem; font-weight: 600; color: #b8860b;
  background: rgba(184,134,11,.1);
  padding: 0.125rem 0.45rem;
  border-radius: 4px;
  border: 1px solid rgba(184,134,11,.2);
}

/* ── Skeleton ───────────────────────────────────────────────── */
.cl-skeleton {
  height: 200px; border-radius: var(--radius);
  background: linear-gradient(90deg,#f2f2f2 25%,#eaeaea 50%,#f2f2f2 75%);
  background-size: 200% 100%; animation: sk-shimmer 1.4s infinite;
}
@keyframes sk-shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── Empty / error state ─────────────────────────────────────── */
.cl-state {
  grid-column: 1/-1; padding: 4rem 2rem; text-align: center;
}
.cl-state h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.5rem; }
.cl-state p  { color: var(--muted); font-size: 0.875rem; }

/* ── Preview modal ──────────────────────────────────────────── */
.cl-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 500; display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.cl-modal {
  background: white; border-radius: var(--radius-lg); padding: 2rem;
  max-width: 600px; width: 100%; max-height: 90vh; overflow-y: auto;
  position: relative; box-shadow: var(--shadow-lg);
  animation: cl-modal-in .2s ease-out;
}
@keyframes cl-modal-in {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.cl-modal-close {
  position: absolute; top: 1rem; right: 1rem; width: 32px; height: 32px;
  border: none; background: var(--bg); border-radius: 50%; cursor: pointer;
  font-size: 1.125rem; display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: all .15s;
}
.cl-modal-close:hover { background: var(--border); color: var(--text); }
.cl-modal-badge {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--subtle); margin-bottom: 0.5rem;
}
.cl-modal-title {
  font-size: 1.5rem; font-weight: 700; margin-bottom: 0.625rem;
  letter-spacing: -0.01em;
  padding-right: 2rem;
}
.cl-modal-desc {
  color: var(--muted); font-size: 0.875rem; line-height: 1.65;
  margin-bottom: 1rem;
}
.cl-modal-meta {
  font-size: 0.8rem; color: var(--subtle); margin-bottom: 1.25rem;
  display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap;
}
.cl-modal-meta-sep { color: var(--border); }
.cl-prompt-label {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--subtle); margin-bottom: 0.5rem; display: block;
}
.cl-modal-prompt {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem; font-size: 0.8rem; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  max-height: 180px; overflow-y: auto; margin-bottom: 1rem; color: var(--text);
}
.cl-modal-tags { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-bottom: 1.25rem; }
.cl-modal-actions { display: flex; gap: 0.625rem; flex-wrap: wrap; }
.cl-modal-actions .cl-btn { flex: 1; justify-content: center; }
.cl-modal-actions .cl-btn-primary { flex: 2; }

/* ── Try-it panel ──────────────────────────────────────────── */
.cl-trysection {
  margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border-2);
}
.cl-trysection label {
  font-size: 0.8rem; font-weight: 600; margin-bottom: 0.5rem; display: block;
}
.cl-tryinput {
  width: 100%; padding: 0.75rem; border: 1px solid var(--border);
  border-radius: 8px; font-family: inherit; font-size: 0.875rem;
  resize: vertical; min-height: 80px; outline: none; transition: border .15s;
  background: var(--bg);
}
.cl-tryinput:focus { border-color: var(--text); box-shadow: 0 0 0 3px rgba(26,26,46,.08); }
.cl-run-btn {
  margin-top: 0.75rem; width: 100%; padding: 0.75rem;
  background: var(--text); color: white; border: none; border-radius: 8px;
  font-weight: 600; font-size: 0.875rem; cursor: pointer; font-family: inherit;
  transition: opacity .15s;
}
.cl-run-btn:hover { opacity: .9; }
.cl-run-btn:disabled { opacity: .5; cursor: not-allowed; }
.cl-output {
  margin-top: 1rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem; font-size: 0.875rem; line-height: 1.65;
  white-space: pre-wrap; color: var(--text);
}
.cl-run-counter { font-size: 0.75rem; color: var(--subtle); text-align: right; margin-top: 0.5rem; }

/* ── Flag modal ─────────────────────────────────────────────── */
.cl-flag-modal .cl-modal { max-width: 420px; }
.cl-flag-modal textarea {
  width: 100%; padding: 0.75rem; border: 1px solid var(--border);
  border-radius: 8px; font-family: inherit; font-size: 0.875rem;
  resize: vertical; min-height: 80px; outline: none; margin-top: 0.75rem;
  background: var(--bg);
}
.cl-flag-modal textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(26,26,46,.08);
}

/* ── Toast ──────────────────────────────────────────────────── */
.cl-toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; padding: 0.75rem 1.5rem;
  border-radius: 8px; font-size: 0.875rem; font-weight: 500; z-index: 9999;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
  white-space: nowrap; box-shadow: var(--shadow-lg);
}
.cl-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Login gate ─────────────────────────────────────────────── */
.cl-login-gate {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.75rem; padding: 2rem; text-align: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); margin-top: 1rem;
}
.cl-login-gate h4 { font-size: 1rem; font-weight: 600; }
.cl-login-gate p  { font-size: 0.875rem; color: var(--muted); }

/* ── Pagination ─────────────────────────────────────────────── */
.cl-pagination {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 2.5rem;
}
.cl-page-btn {
  padding: 0.5rem 1rem; border: 1px solid var(--border); border-radius: 7px;
  background: white; color: var(--text); cursor: pointer; font-size: 0.875rem;
  font-family: inherit; transition: all .15s;
}
.cl-page-btn:hover { background: var(--bg); border-color: #ccc; }
.cl-page-btn.active {
  background: var(--text); color: white; border-color: var(--text);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cl-intro { padding: 2rem 1rem 1.25rem; }
  .cl-h1 { font-size: 1.875rem; }
  .cl-header { padding: 0 1rem; gap: 0.75rem; overflow: hidden; }
  .cl-header-logo svg { max-width: 32px; height: auto; }
  .cl-search-wrap { min-width: 0; }
  .cl-title { display: none; }
  .cl-filter-bar { padding: 0.5rem 1rem 1rem; }
  .cl-stats { display: none; }
  .cl-page-body { padding: 0.5rem 1rem 2rem; }
  .cl-shared-section { padding: 1.5rem 1rem 4rem; }
  .cl-grid { grid-template-columns: 1fr; }
  .cl-modal { padding: 1.5rem; margin: 0.5rem; }

  .cl-search-wrap { flex: 1; max-width: 100%; width: auto; }
  .cl-header-actions { display: none; }
  .cl-filter-bar { flex-wrap: nowrap; gap: 0.5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .cl-filter-bar::-webkit-scrollbar { display: none; }
  .cl-filter-bar > div:first-child > div { display: flex; align-items: center; gap: 0.375rem; }
  .cl-sort-select { min-height: 44px; font-size: 0.75rem; }
  .cl-btn { min-height: 44px; }
  .cl-filter-label { font-size: 0.65rem; margin-bottom: 0; display: inline-flex; }
}

/* -- Logged-in header links + mobile menu -- */
.cl-header { position: relative; }
.cl-hamburger {
  display: none; margin-left: auto; flex-shrink: 0;
  width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 7px;
  background: white; color: var(--text); font-size: 1rem; cursor: pointer;
}
.cl-mobile-menu {
  position: absolute; top: 100%; right: 1rem; z-index: 60;
  background: white; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.12);
  flex-direction: column; min-width: 180px; overflow: hidden;
}
.cl-mobile-link {
  display: block; padding: 0.75rem 1rem; font-size: 0.875rem; font-weight: 500;
  color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-2);
}
.cl-mobile-link:last-child { border-bottom: none; }
.cl-mobile-link:hover { background: var(--bg); }
@media (max-width: 768px) {
  .cl-header { overflow: visible; }
  .cl-hamburger { display: inline-flex; align-items: center; justify-content: center; }
}