/* GitHub Pulse: Professional minimal UI, GitHub-inspired light theme with dark mode */
:root{
  --bg:#f6f8fa;
  --surface:#ffffff;
  --surface-hover:#f6f8fa;
  --border:#d0d7de;
  --border-light:#eaeef2;
  --text:#1f2328;
  --text-secondary:#59636e;
  --text-muted:#818c98;
  --accent:#0969da;
  --accent-hover:#0550ae;
  --accent-bg:#ddf4ff;
  --success:#1a7f37;
  --success-bg:#dafbe1;
  --danger:#d1242f;
  --warning:#9a6700;
  --warning-bg:#fff8c5;
  --radius:8px;
  --radius-lg:12px;
  --shadow:0 1px 3px rgba(31,35,40,.06), 0 8px 24px rgba(31,35,40,.08);
  --shadow-lg:0 8px 32px rgba(31,35,40,.16);
  --skeleton:#eaeef2;
  --skeleton2:#f6f8fa;
  --overlay:rgba(31,35,40,.45);
}
[data-theme="dark"]{
  --bg:#0d1117;
  --surface:#161b22;
  --surface-hover:#1c2128;
  --border:#30363d;
  --border-light:#21262d;
  --text:#e6edf3;
  --text-secondary:#8b949e;
  --text-muted:#7d8590;
  --accent:#58a6ff;
  --accent-hover:#79b8ff;
  --accent-bg:rgba(88,166,255,.15);
  --success:#3fb950;
  --success-bg:rgba(63,185,80,.15);
  --danger:#f85149;
  --warning:#d29922;
  --warning-bg:rgba(210,153,34,.15);
  --shadow:0 1px 3px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg:0 8px 32px rgba(0,0,0,.5);
  --skeleton:#21262d;
  --skeleton2:#161b22;
  --overlay:rgba(1,4,9,.7);
}
*{margin:0;padding:0;box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  background:var(--bg);color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif;
  font-size:15px;line-height:1.55;-webkit-font-smoothing:antialiased;
}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}
button{font-family:inherit;cursor:pointer}
input,select{font-family:inherit}
.container{max-width:1200px;margin:0 auto;padding:0 20px}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

/* BUTTONS */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;border-radius:6px;font-size:14px;font-weight:500;padding:7px 14px;border:1px solid transparent;transition:background .15s,border-color .15s,color .15s;white-space:nowrap}
.btn-sm{padding:5px 12px;font-size:13px}
.btn-primary{background:var(--accent);color:#fff;border-color:rgba(31,35,40,.15)}
.btn-primary:hover{background:var(--accent-hover);text-decoration:none}
.btn-outline{background:var(--surface);color:var(--text);border-color:var(--border)}
.btn-outline:hover{background:var(--surface-hover);text-decoration:none}
.btn-ghost{background:transparent;color:var(--accent)}
.btn-ghost:hover{background:var(--accent-bg);text-decoration:none}
.icon-btn{background:var(--surface);border:1px solid var(--border);color:var(--text);width:34px;height:34px;border-radius:6px;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}
.icon-btn:hover{background:var(--surface-hover)}
.icon-link{color:var(--text);display:inline-flex;align-items:center;flex-shrink:0}
.icon-link:hover{color:var(--accent)}
[data-theme="dark"] .icon-sun{display:block}
[data-theme="dark"] .icon-moon{display:none}
.icon-sun{display:none}

/* HEADER */
.header{background:var(--surface);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:100}
.header-inner{display:flex;align-items:center;gap:18px;min-height:60px;padding-top:8px;padding-bottom:8px;flex-wrap:wrap}
.logo{display:flex;align-items:center;gap:9px;color:var(--text);flex-shrink:0}
.logo:hover{text-decoration:none}
.logo-mark{width:34px;height:34px;border-radius:8px;background:var(--text);color:var(--surface);display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}
.logo-text{font-size:17px;font-weight:600;letter-spacing:-.2px;white-space:nowrap}
.nav{display:flex;gap:2px;flex-shrink:0}
.nav-link{background:transparent;border:none;color:var(--text-secondary);padding:7px 11px;border-radius:6px;font-size:14px;font-weight:500;white-space:nowrap}
.nav-link:hover{color:var(--text);background:var(--surface-hover)}
.nav-link.active{color:var(--text);background:var(--bg);font-weight:600}
.badge{background:var(--bg);border:1px solid var(--border);color:var(--text-secondary);font-size:11px;font-weight:600;padding:1px 7px;border-radius:20px;margin-left:5px}
.nav-link.active .badge{background:var(--surface)}
.header-right{display:flex;align-items:center;gap:9px;margin-left:auto;min-width:0}
.search-wrap{position:relative}
.search-box{display:flex;align-items:center;background:var(--surface);border:1px solid var(--border);border-radius:6px;overflow:hidden;width:300px;max-width:38vw}
.search-box:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px rgba(9,105,218,.15)}
.search-icon{margin:0 4px 0 10px;color:var(--text-muted);flex-shrink:0}
.search-box input{flex:1;border:none;outline:none;font-size:14px;padding:7px 4px;min-width:0;color:var(--text);background:transparent}
.search-box input::placeholder{color:var(--text-muted)}
.search-box .btn{border-radius:0;border:none;align-self:stretch}
.recent-box{position:absolute;top:calc(100% + 6px);left:0;right:0;background:var(--surface);border:1px solid var(--border);border-radius:8px;box-shadow:var(--shadow-lg);z-index:120;padding:8px}
.recent-head{display:flex;justify-content:space-between;align-items:center;font-size:12px;color:var(--text-muted);padding:2px 6px 6px}
.recent-clear{background:none;border:none;color:var(--accent);font-size:12px;font-weight:500}
.recent-list{display:flex;flex-direction:column}
.recent-item{display:flex;align-items:center;gap:8px;padding:7px 8px;border-radius:6px;font-size:13.5px;color:var(--text);background:none;border:none;text-align:left;width:100%}
.recent-item:hover{background:var(--surface-hover)}
.recent-item svg{color:var(--text-muted);flex-shrink:0}
.rate-limit{font-size:12px;color:var(--text-muted);white-space:nowrap}
.menu-btn{display:none}
.mobile-nav{display:none;padding:8px 20px 12px;gap:4px;overflow-x:auto;border-top:1px solid var(--border-light)}
.mobile-nav .nav-link{border:1px solid var(--border-light);white-space:nowrap}

/* INTRO */
.intro{background:var(--surface);border-bottom:1px solid var(--border);padding:30px 0 22px}
.intro-top{display:flex;justify-content:space-between;align-items:flex-start;gap:20px;flex-wrap:wrap}
.intro-text{flex:1;min-width:260px}
.intro h1{font-size:28px;font-weight:600;letter-spacing:-.4px;line-height:1.25}
.intro-sub{color:var(--text-secondary);font-size:15px;margin-top:6px}
.intro-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.live-indicator{display:inline-flex;align-items:center;gap:7px;font-size:13px;color:var(--success);font-weight:500;white-space:nowrap}
.live-dot{width:8px;height:8px;border-radius:50%;background:var(--success);animation:pulse 2s infinite;flex-shrink:0}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}
.auto-refresh{font-size:12.5px;color:var(--text-muted);white-space:nowrap}
.intro-stats{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-top:24px}
.stat{display:flex;flex-direction:column;min-width:0}
.stat-value{font-size:20px;font-weight:600;letter-spacing:-.3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.stat-label{font-size:12px;color:var(--text-muted)}

/* FILTERS */
.filters{padding:18px 0 4px}
.filters-inner{display:flex;flex-direction:column;gap:14px}
.filter-group{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.filter-main{justify-content:space-between}
.segmented{display:inline-flex;background:var(--border-light);border:1px solid var(--border-light);border-radius:8px;padding:3px;gap:2px;max-width:100%;overflow-x:auto;scrollbar-width:none}
.segmented::-webkit-scrollbar{display:none}
.seg-btn{background:transparent;border:none;color:var(--text-secondary);padding:6px 14px;border-radius:6px;font-size:13.5px;font-weight:500;white-space:nowrap}
.seg-btn:hover{color:var(--text)}
.seg-btn.active{background:var(--surface);color:var(--text);font-weight:600;box-shadow:0 1px 2px rgba(31,35,40,.1)}
.filter-selects{display:flex;gap:12px;flex-wrap:wrap;align-items:flex-end}
.select-wrap{display:flex;align-items:center;gap:8px}
.select-label{font-size:13px;color:var(--text-secondary);font-weight:500;white-space:nowrap}
.select{background:var(--surface);border:1px solid var(--border);color:var(--text);padding:7px 10px;border-radius:6px;font-size:13.5px;outline:none;cursor:pointer;max-width:180px}
.select:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(9,105,218,.15)}
.share-btn{align-self:center}
.filter-label{font-size:13px;color:var(--text-secondary);font-weight:500;white-space:nowrap}
.chips{display:flex;gap:7px;flex-wrap:wrap}
.chip{background:var(--surface);border:1px solid var(--border);color:var(--text-secondary);padding:6px 13px;border-radius:20px;font-size:13px;font-weight:500;transition:.15s}
.chip:hover{color:var(--text);border-color:var(--text-muted)}
.chip.active{background:var(--accent-bg);border-color:var(--accent);color:var(--accent);font-weight:600}
.search-info{color:var(--accent);font-weight:600;font-size:14px;word-break:break-word}

/* MAIN */
.main{padding:22px 20px 48px}
.section-head{display:flex;justify-content:space-between;align-items:flex-end;gap:16px;flex-wrap:wrap;margin-bottom:16px}
.section-head-text{min-width:0;flex:1}
.section-head h2{font-size:20px;font-weight:600;letter-spacing:-.3px}
.section-sub{color:var(--text-secondary);font-size:13.5px;margin-top:3px}
.result-count{color:var(--text-muted);font-size:13px;white-space:nowrap}
.status-bar{font-size:13.5px;color:var(--text-secondary);margin-bottom:14px;min-height:20px;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.status-bar.error{color:var(--danger)}
.status-bar.warn{color:var(--warning)}

/* REPO GRID AND CARDS: fixed distortion, equal heights, aligned actions */
.repo-grid{display:grid;grid-template-columns:repeat(1,1fr);gap:14px;align-items:stretch}
.repo-card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);padding:16px;display:flex;flex-direction:column;gap:9px;transition:border-color .15s,box-shadow .15s;cursor:pointer;height:100%;min-width:0}
.repo-card:hover{border-color:var(--accent);box-shadow:var(--shadow)}
.card-top{display:flex;align-items:flex-start;gap:10px;min-width:0}
.avatar{width:38px;height:38px;border-radius:6px;flex-shrink:0;background:var(--bg);object-fit:cover}
.card-title{flex:1;min-width:0}
.card-title a{font-size:15px;font-weight:600;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.card-owner{font-size:12.5px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}
.card-badges{display:flex;flex-direction:column;align-items:flex-end;gap:6px;flex-shrink:0}
.rank{font-size:11.5px;font-weight:600;color:var(--text-muted);background:var(--bg);border:1px solid var(--border-light);padding:2px 8px;border-radius:20px;line-height:1.4}
.pill-badge{font-size:10.5px;font-weight:700;letter-spacing:.3px;text-transform:uppercase;padding:2px 8px;border-radius:20px;line-height:1.4}
.pill-badge.new{background:var(--success-bg);color:var(--success)}
.pill-badge.active-badge{background:var(--accent-bg);color:var(--accent)}
.bookmark-btn{background:transparent;border:1px solid var(--border);color:var(--text-muted);width:32px;height:32px;border-radius:6px;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}
.bookmark-btn:hover{color:var(--text);background:var(--surface-hover)}
.bookmark-btn.saved{color:var(--accent);border-color:var(--accent);background:var(--accent-bg)}
.card-desc{color:var(--text-secondary);font-size:13.5px;flex:1;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;min-height:2.7em}
.topics{display:flex;gap:6px;flex-wrap:nowrap;overflow:hidden;min-height:22px;align-items:center}
.topic{background:var(--accent-bg);color:var(--accent);font-size:11.5px;font-weight:500;padding:2px 9px;border-radius:20px;white-space:nowrap;flex-shrink:0}
.topic-more{font-size:11.5px;color:var(--text-muted);white-space:nowrap}
.card-meta{display:flex;align-items:center;gap:12px;flex-wrap:wrap;font-size:13px;color:var(--text-secondary)}
.lang-dot{display:inline-block;width:11px;height:11px;border-radius:50%;margin-right:5px;vertical-align:-1px;flex-shrink:0}
.meta-item{display:inline-flex;align-items:center;gap:5px;white-space:nowrap}
.meta-item svg{color:var(--text-muted);flex-shrink:0}
.card-actions{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin-top:auto;padding-top:4px}
.action-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:7px 6px;border-radius:6px;font-size:13px;font-weight:500;border:1px solid var(--border);background:var(--surface);color:var(--text);min-width:0;white-space:nowrap;overflow:hidden}
.action-btn:hover{background:var(--surface-hover);text-decoration:none;border-color:var(--text-muted)}
.dev-card{text-align:center;align-items:center}
.dev-card .avatar{width:76px;height:76px;border-radius:50%}
.dev-card h3{font-size:16px}
.dev-card .muted{color:var(--text-muted);font-size:13px}
.dev-card .card-actions{width:100%}

/* SKELETON */
.skeleton{background:linear-gradient(90deg,var(--skeleton) 25%,var(--skeleton2) 50%,var(--skeleton) 75%);background-size:200% 100%;animation:shimmer 1.2s infinite;border-radius:var(--radius-lg);height:190px;border:1px solid var(--border-light)}
@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}

/* EMPTY */
.empty-state{text-align:center;padding:64px 20px;color:var(--text-muted)}
.empty-state svg{margin-bottom:14px}
.empty-state h3{font-size:18px;color:var(--text);margin-bottom:6px}
.empty-state p{margin-bottom:20px;font-size:14px}
.load-more-wrap{text-align:center;margin-top:28px}

/* MODAL */
.modal-overlay{position:fixed;inset:0;background:var(--overlay);z-index:200;display:flex;align-items:flex-start;justify-content:center;padding:24px 14px;overflow-y:auto}
.modal{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);max-width:800px;width:100%;padding:26px;position:relative;margin:auto;box-shadow:var(--shadow-lg);animation:slideUp .2s ease}
.modal-sm{max-width:460px}
@keyframes slideUp{from{opacity:0;transform:translateY(14px)}to{opacity:1;transform:none}}
.modal-close{position:absolute;top:14px;right:14px;background:var(--surface);border:1px solid var(--border);color:var(--text-secondary);width:32px;height:32px;border-radius:6px;display:inline-flex;align-items:center;justify-content:center;z-index:2}
.modal-close:hover{color:var(--text);background:var(--surface-hover)}
.modal h3{font-size:17px;margin-bottom:10px}
.muted-inline{color:var(--text-muted);font-weight:400;font-size:14px}
.modal-text{color:var(--text-secondary);font-size:13.5px;margin-bottom:10px}
.detail-head{display:flex;gap:14px;align-items:center;margin-bottom:14px;flex-wrap:wrap;padding-right:36px;min-width:0}
.detail-head .avatar{width:56px;height:56px;border-radius:8px}
.detail-head h2{font-size:20px;word-break:break-word;letter-spacing:-.3px}
.detail-meta-line{font-size:13px;color:var(--text-muted)}
.detail-stats{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin:16px 0}
.dstat{background:var(--bg);border:1px solid var(--border-light);border-radius:var(--radius);padding:12px;text-align:center;min-width:0}
.dstat b{display:block;font-size:19px;font-weight:600}
.dstat span{font-size:12px;color:var(--text-muted)}
.detail-actions{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0}
.detail-actions a,.detail-actions button{padding:8px 14px;border-radius:6px;font-size:13.5px;font-weight:500;border:1px solid var(--border);background:var(--surface);color:var(--text);display:inline-flex;align-items:center;gap:6px}
.detail-actions a:hover,.detail-actions button:hover{background:var(--surface-hover);text-decoration:none;border-color:var(--text-muted)}
.detail-actions .primary{background:var(--accent);border-color:var(--accent);color:#fff}
.detail-actions .primary:hover{background:var(--accent-hover)}
.section-label{font-size:13px;font-weight:600;display:block;margin:16px 0 8px}
.readme-box{background:var(--bg);border:1px solid var(--border-light);border-radius:var(--radius);padding:14px;font-size:13px;color:var(--text-secondary);max-height:280px;overflow-y:auto;white-space:pre-wrap;word-break:break-word}
.lang-bar{display:flex;height:9px;border-radius:6px;overflow:hidden;margin:6px 0}
.lang-bar div{height:100%}
.lang-legend{display:flex;gap:14px;flex-wrap:wrap;font-size:12.5px;color:var(--text-secondary)}
.contributors{display:flex;gap:7px;flex-wrap:wrap}
.contributors img{width:34px;height:34px;border-radius:50%;border:1px solid var(--border)}
.clone-line{font-size:13px;color:var(--text-secondary);word-break:break-all}
.clone-line code{background:var(--bg);border:1px solid var(--border-light);padding:2px 7px;border-radius:5px;font-size:12.5px}
.text-input{width:100%;background:var(--surface);border:1px solid var(--border);color:var(--text);padding:9px 11px;border-radius:6px;font-size:14px;margin:10px 0 14px;outline:none}
.text-input:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(9,105,218,.15)}
.modal-actions{display:flex;gap:8px;flex-wrap:wrap}

/* TOAST, BACK TO TOP, FOOTER */
.toast{position:fixed;bottom:22px;left:50%;transform:translateX(-50%) translateY(70px);background:var(--text);color:var(--surface);padding:11px 20px;border-radius:8px;font-size:13.5px;z-index:300;transition:.25s;box-shadow:var(--shadow-lg);max-width:90vw;text-align:center;opacity:0}
.toast.show{transform:translateX(-50%) translateY(0);opacity:1}
.back-top{position:fixed;right:20px;bottom:20px;width:42px;height:42px;border-radius:50%;background:var(--surface);border:1px solid var(--border);color:var(--text);box-shadow:var(--shadow);display:none;align-items:center;justify-content:center;z-index:150}
.back-top.show{display:inline-flex}
.back-top:hover{background:var(--surface-hover)}
.footer{border-top:1px solid var(--border);background:var(--surface);padding:22px 0;margin-top:20px}
.footer-inner{display:flex;justify-content:space-between;gap:14px;flex-wrap:wrap;font-size:13px;color:var(--text-muted)}
.footer-links{display:flex;gap:16px}

/* RESPONSIVE */
@media (min-width:640px){
  .repo-grid{grid-template-columns:repeat(2,1fr)}
  .detail-stats{grid-template-columns:repeat(4,1fr)}
}
@media (min-width:1000px){
  .repo-grid{grid-template-columns:repeat(3,1fr)}
}
@media (max-width:1150px){
  .nav{display:none}
  .menu-btn{display:inline-flex}
  .mobile-nav.open{display:flex}
  .rate-limit{display:none}
  .search-box{width:240px;max-width:32vw}
}
@media (max-width:760px){
  .header-inner{gap:10px}
  .header-right{flex-basis:100%;margin-left:0;order:3}
  .search-wrap{flex:1;min-width:0}
  .search-box{width:100%;max-width:none}
  .recent-box{position:fixed;left:14px;right:14px;top:118px}
  .intro{padding:22px 0 18px}
  .intro h1{font-size:23px}
  .intro-stats{grid-template-columns:repeat(2,1fr);gap:14px}
  .main{padding:16px 14px 36px}
  .repo-card{padding:15px}
  .modal{padding:20px}
  .detail-head h2{font-size:17px}
  .filter-main{flex-direction:column;align-items:stretch}
  .segmented{width:100%}
  .filter-selects{width:100%}
  .select-wrap{flex:1;min-width:0}
  .select{flex:1;min-width:0;max-width:none}
  .share-btn{width:100%}
  .card-actions{grid-template-columns:1fr 1fr 1fr}
  .container{padding:0 14px}
}
@media (max-width:420px){
  .card-actions{grid-template-columns:1fr 1fr}
  .card-actions .action-btn:last-child{grid-column:span 2}
  .logo-text{font-size:16px}
  .intro-actions{gap:8px}
}
