:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
  --header-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

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

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  flex-shrink: 0;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.logo-text { font-weight: 700; font-size: 17px; }

.search-form {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  max-width: 420px;
  margin-left: auto;
}

.search-form input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  min-width: 0;
}

.search-form button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
}

/* Main */
.main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px calc(24px + var(--safe-bottom));
}

/* Hero */
.hero {
  text-align: center;
  padding: 32px 16px 28px;
  background: linear-gradient(180deg, var(--primary-light) 0%, transparent 100%);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.hero h1 {
  font-size: clamp(22px, 5vw, 28px);
  margin-bottom: 8px;
  color: var(--text);
}

.hero > p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 14px;
}

.hero-search {
  display: flex;
  max-width: 520px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.hero-search input {
  flex: 1;
  border: none;
  padding: 14px 20px;
  font-size: 15px;
  outline: none;
  min-width: 0;
}

.hero-search button {
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Section */
.section { margin-bottom: 28px; }

.section-head { margin-bottom: 16px; }
.section-head h2 { font-size: 18px; font-weight: 700; }
.section-desc { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

/* Category grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.category-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  transition: box-shadow .2s, border-color .2s, transform .15s;
}

.category-card:hover {
  box-shadow: var(--shadow);
  border-color: #c7d2fe;
  transform: translateY(-1px);
}

.category-icon {
  width: 48px;
  height: 48px;
  background: var(--primary-light);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.category-info { flex: 1; min-width: 0; }
.category-info h3 { font-size: 16px; margin-bottom: 4px; }
.category-info p { font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.arrow { color: #cbd5e1; flex-shrink: 0; }

/* Hot list */
.hot-list { display: flex; flex-direction: column; gap: 8px; }

.hot-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text);
  transition: background .15s;
}

.hot-item:hover { background: var(--primary-light); }

.hot-badge {
  background: #fef3c7;
  color: #d97706;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.hot-body { flex: 1; min-width: 0; }
.hot-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hot-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* Sub grid */
.sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.sub-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  transition: box-shadow .2s, border-color .2s;
}

.sub-card:hover { box-shadow: var(--shadow); border-color: #c7d2fe; }
.sub-card h3 { font-size: 15px; margin-bottom: 6px; }
.sub-card p { font-size: 13px; color: var(--text-secondary); }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--primary); }

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding: 20px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.page-header.compact { display: block; }
.page-header-icon { font-size: 40px; line-height: 1; }
.page-header h1 { font-size: clamp(20px, 4vw, 24px); margin-bottom: 6px; }
.page-header p { color: var(--text-secondary); font-size: 14px; }

/* Article list */
.article-list { display: flex; flex-direction: column; gap: 10px; }

.article-item {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  color: var(--text);
  transition: background .15s, box-shadow .15s;
}

.article-item:hover { background: var(--primary-light); box-shadow: var(--shadow); }
.article-item-main h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.article-item-main p { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.article-item-meta { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: #94a3b8; }

/* Tags */
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--primary-light);
  color: var(--primary);
  margin-right: 6px;
  margin-bottom: 6px;
}

.tag.hot { background: #fef3c7; color: #d97706; }
.tag.outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.article-tags { margin-top: 8px; }

/* Article detail */
.article-detail {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-bottom: 24px;
}

.article-header h1 { font-size: clamp(20px, 4.5vw, 26px); line-height: 1.4; margin: 8px 0; }
.article-meta { display: flex; gap: 16px; font-size: 13px; color: var(--text-secondary); }

.article-cover { margin: 20px 0; border-radius: 12px; overflow: hidden; }
.article-cover img { width: 100%; }

.article-video {
  margin: 20px 0;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.article-video video { width: 100%; max-height: 480px; }

.article-content {
  margin-top: 20px;
  font-size: 15px;
  line-height: 1.8;
  word-break: break-word;
}

.article-content h2, .article-content h3 { margin: 1.2em 0 .6em; font-size: 1.1em; }
.article-content p { margin-bottom: 1em; }
.article-content ul, .article-content ol { margin: 0 0 1em 1.5em; }
.article-content li { margin-bottom: .4em; }
.article-content img { border-radius: 8px; margin: 12px 0; }
.article-content video { max-width: 100%; border-radius: 8px; margin: 12px 0; }
.article-content a { text-decoration: underline; }
.article-content blockquote {
  margin: 12px 0;
  padding: 10px 16px;
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
  color: var(--text-secondary);
}
.article-content pre,
.article-content .ql-code-block-container {
  background: #1e293b;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 14px;
  line-height: 1.6;
}
.article-content .ql-align-center { text-align: center; }
.article-content .ql-align-right { text-align: right; }
.article-content .ql-align-justify { text-align: justify; }
.article-content .ql-indent-1 { padding-left: 2em; }
.article-content .ql-indent-2 { padding-left: 4em; }
.article-content .ql-indent-3 { padding-left: 6em; }
.article-content .ql-indent-4 { padding-left: 8em; }
.article-content .ql-indent-5 { padding-left: 10em; }
.article-content .ql-indent-6 { padding-left: 12em; }
.article-content .ql-indent-7 { padding-left: 14em; }
.article-content .ql-indent-8 { padding-left: 16em; }

/* Related */
.related-list { display: flex; flex-direction: column; gap: 8px; }
.related-list a {
  display: block;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
}

.related-list a:hover { background: var(--primary-light); color: var(--primary); }

/* Empty / Button */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state.small { padding: 32px 20px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p { color: var(--text-secondary); margin-bottom: 16px; }

.btn {
  display: inline-block;
  padding: 10px 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}

/* Footer */
.footer {
  text-align: center;
  padding: 20px 16px calc(16px + var(--safe-bottom));
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* Mobile tweaks */
@media (max-width: 640px) {
  .logo-text { font-size: 15px; }
  .header-inner .search-form { display: none; }
  .hero { padding: 24px 12px 20px; }
  .category-grid { grid-template-columns: 1fr; }
  .sub-grid { grid-template-columns: 1fr 1fr; }
  .page-header { padding: 16px; }
  .article-detail { padding: 18px 14px; }
  .sub-grid .sub-card:last-child:nth-child(odd) { grid-column: span 2; }
}

@media (min-width: 641px) {
  .hero-search { display: none; }
}
