/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --red:              #e53935;
  --red-dark:         #c62828;
  --red-light:        #ffebee;
  --bg:               #f2f3f5;
  --card:             #fff;
  --text:             #1a1a2e;
  --text-sub:         #666;
  --border:           #ebebeb;
  --shadow:           0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.05);
  --radius:           10px;
  --gold:             #f5a623;
  --silver:           #9e9e9e;
  --bronze:           #cd7f32;
  --form-accent:      #e53935;
  --form-accent-dark: #c62828;
}

/* ===== Base ===== */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.site-header {
  background: #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  height: 56px;
  gap: 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 800;
  color: var(--red);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--red);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
}

.header-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.header-nav a {
  color: #555;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 20px;
  transition: all .15s;
}

.header-nav a:hover {
  color: var(--red);
  background: var(--red-light);
}

.header-nav a.submit-btn {
  background: var(--red);
  color: #fff !important;
  border-radius: 6px;
  font-weight: 700;
  margin-left: 6px;
}
.header-nav a.submit-btn:hover {
  background: #c62828;
  color: #fff !important;
}

/* ===== Friend Links ===== */
.friend-links { background: #fff; border-top: 1px solid #f0f0f0; padding: 18px 0; }
.fl-title { font-size: 12px; font-weight: 700; color: #999; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.fl-list { display: flex; flex-wrap: wrap; gap: 8px; }
.fl-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; background: #f7f7f7; border: 1px solid #e8e8e8; border-radius: 20px; font-size: 12px; color: #555; text-decoration: none; transition: all .15s; }
.fl-item:hover { background: var(--red-light); border-color: var(--red); color: var(--red); text-decoration: none; }
.fl-item img { width: 14px; height: 14px; object-fit: contain; border-radius: 2px; }

/* ===== Page title bar ===== */
.page-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

.page-bar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-bar h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.page-bar .breadcrumb {
  font-size: 12px;
  color: var(--text-sub);
}

.page-bar .breadcrumb a {
  color: var(--red);
}

.page-bar .breadcrumb a:hover {
  text-decoration: underline;
}

/* ===== Main content ===== */
.main {
  padding: 20px 0 40px;
}

/* ===== Category Grid ===== */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 1200px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .cat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 580px)  { .cat-grid { grid-template-columns: 1fr; } }

/* ===== Category Card ===== */
.cat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s;
}

.cat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}

.cat-card-header {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: #fff;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-card-header h3 {
  font-size: 14px;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-count {
  font-size: 11px;
  opacity: .75;
  background: rgba(255,255,255,.2);
  padding: 2px 7px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* ===== Site List ===== */
.site-list {
  list-style: none;
  flex: 1;
}

.site-item {
  display: flex;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid #f7f7f7;
  gap: 7px;
  transition: background .1s;
}

.site-item:last-child { border-bottom: none; }
.site-item:hover { background: #fafafa; }

.site-rank {
  width: 18px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #ccc;
  flex-shrink: 0;
}
.site-rank.r1 { color: var(--gold); }
.site-rank.r2 { color: var(--silver); }
.site-rank.r3 { color: var(--bronze); }

.site-favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
  object-fit: contain;
}

.site-favicon-fallback {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.site-link {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .1s;
}

.site-link:hover { color: var(--red); }

.site-clicks {
  font-size: 11px;
  color: #fff;
  background: var(--red);
  padding: 1px 6px;
  border-radius: 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.site-clicks.hot {
  background: #ff6f00;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .7; }
}

/* ===== Card Footer ===== */
.card-footer {
  border-top: 1px solid var(--border);
  padding: 9px 16px;
  text-align: center;
}

.view-all {
  color: var(--red);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity .15s;
}

.view-all:hover { opacity: .75; }

/* ===== Full Category Page ===== */
.cat-full {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cat-full-header {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  padding: 20px 24px;
}

.cat-full-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.cat-full-header p {
  font-size: 13px;
  opacity: .8;
  margin-top: 4px;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}

.site-grid .site-item {
  border-right: 1px solid #f7f7f7;
  border-bottom: 1px solid #f7f7f7;
  padding: 10px 14px;
}

@media (max-width: 1000px) { .site-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .site-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px)  { .site-grid { grid-template-columns: 1fr; } }

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

/* ===== Mobile: 手机端头部只保留「提交网站」按钮 ===== */
@media (max-width: 767px) {
  .header-nav a:not(.submit-btn) { display: none; }
  .header-nav { margin-left: auto; }
}

/* ===== Back link ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--red);
  font-size: 13px;
  padding: 6px 0;
}

.back-link:hover { text-decoration: underline; }

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-sub);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}
