:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #5f6875;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --soft: #f5f7ff;
  --panel: #ffffff;
  --subtle: #f3f4f6;
  --badge-bg: #e7edff;
  --badge-fg: #26344d;
  --quote-bg: #f9fafb;
  --accent-soft: #eaf0ff;
  --radius: 12px;
  --shadow: 0 2px 6px rgba(0, 0, 0, .06);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

.container {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

.muted {
  color: var(--muted);
}

.badge {
  display: inline-block;
  max-width: 100%;
  font-size: 12px;
  line-height: 1.35;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-fg);
  overflow-wrap: anywhere;
}

.tag {
  display: inline-block;
  max-width: 100%;
  margin-top: 6px;
  margin-right: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--subtle);
  color: var(--badge-fg);
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.btn {
  display: inline-block;
  max-width: 100%;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

.btn:hover {
  color: var(--accent-ink);
  text-decoration: none;
  filter: brightness(.98);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.head-in {
  display: block;
  min-height: 56px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.logo {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--fg);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  margin-top: 6px;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  overscroll-behavior-inline: contain;
}

.main-nav a {
  flex: 0 0 auto;
  color: var(--muted);
  white-space: nowrap;
  padding: 6px 8px;
  border-radius: 8px;
}

.main-nav a.active {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
}

.tools {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.search {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  min-width: 0;
}

.search input[type="search"],
.search input[type="text"] {
  width: clamp(120px, 18vw, 200px);
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
}

.search input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.langs {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
}

.langs a {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.langs a.on {
  color: var(--fg);
  font-weight: 700;
}

/* Main wrappers */
.main {
  min-width: 0;
  padding-top: 18px;
  padding-bottom: 40px;
}

.hero {
  margin-top: 12px;
  margin-bottom: 10px;
}

.hero h1,
.list-head h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.hero .topic {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--fg);
  overflow-wrap: anywhere;
}

.crumbs {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
  margin-top: 10px;
}

.card-grid > * {
  min-width: 0;
  grid-column: span 4;
}

@media (min-width: 1240px) {
  .card-grid > * {
    grid-column: span 3;
  }
}

@media (max-width: 860px) {
  .card-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .card-grid > * {
    grid-column: span 3;
  }
}

@media (max-width: 520px) {
  .card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .card-grid > * {
    grid-column: span 1;
  }
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card .cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 10px;
  background: var(--subtle);
}

.card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 22px;
}

.card .title {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card .title a {
  color: var(--fg);
}

.card .summary {
  margin: 0;
  color: var(--fg);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.card .tags {
  margin-top: 4px;
}

.card .meta {
  margin-top: auto;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

/* Promo card */
.promo-card {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
}

.promo-card .summary {
  color: var(--accent-ink);
}

.promo-card a {
  color: var(--accent-ink);
  text-decoration: underline;
}

.promo-card .btn {
  color: var(--accent-ink);
  background: rgba(255, 255, 255, .16);
  box-shadow: none;
}

/* Article */
.article {
  width: min(100%, 800px);
  margin: 0 auto;
}

.article .post-title {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.article .post-meta {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.conclusion {
  margin: 12px 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  box-shadow: var(--shadow);
}

.conclusion .summary {
  margin: 0 0 8px;
  color: var(--fg);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.conclusion .tags {
  margin-top: 6px;
}

.content {
  min-width: 0;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.content h2,
.content h3 {
  margin: 22px 0 10px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.content p {
  margin: 10px 0;
}

.content ul,
.content ol {
  padding-left: 1.2em;
}

.content blockquote {
  margin: 14px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--quote-bg);
}

.content table {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 14px 0 18px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  border-spacing: 0;
  background: var(--panel);
}

.content th,
.content td {
  min-width: 120px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.content th {
  background: var(--subtle);
  font-weight: 700;
}

.content tr:nth-child(even) td {
  background: var(--soft);
}

.content tr:last-child th,
.content tr:last-child td {
  border-bottom: 0;
}

.content thead th {
  color: var(--fg);
  background: var(--accent-soft);
}

.content tbody td + td,
.content thead th + th {
  border-left: 1px solid var(--line);
}

.source {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  overflow-wrap: anywhere;
}

.related {
  margin-top: 28px;
}

.related h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.related ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.related li {
  padding: 4px 0;
  overflow-wrap: anywhere;
}

/* Pagination */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  margin: 18px 0 6px;
  font-size: 14px;
}

.pager > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.pager .now {
  color: var(--muted);
  text-align: center;
}

/* Footer */
.site-footer {
  padding: 20px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  overflow-wrap: anywhere;
}

.site-footer .links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}

.site-footer .links a {
  color: var(--muted);
}

/* Bottom promo */
.promo-wide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  margin: 24px 0 0;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
}

.promo-wide p {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.promo-wide .btn {
  flex: 0 1 auto;
  background: rgba(255, 255, 255, .16);
}

/* Medium widths */
@media (max-width: 1100px) {
  .brand-row {
    gap: 16px;
  }

  .main-nav {
    margin-top: 6px;
  }

  .search input[type="search"],
  .search input[type="text"] {
    width: clamp(140px, 26vw, 220px);
  }
}

/* Mobile */
@media (max-width: 720px) {
  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand-row {
    align-items: flex-start;
    gap: 12px;
  }

  .logo {
    flex: 1 1 auto;
  }

  .tools {
    flex: 0 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px 10px;
  }

  .search {
    flex: 1 1 150px;
    min-width: 0;
  }

  .search input[type="search"],
  .search input[type="text"] {
    width: 100%;
    min-width: 0;
  }

  .langs {
    flex: 0 1 auto;
  }

  .hero h1,
  .list-head h1 {
    font-size: 24px;
  }

  .article .post-title {
    font-size: 24px;
  }

  .promo-wide {
    align-items: flex-start;
    flex-direction: column;
  }

  .promo-wide .btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .brand-row {
    display: block;
  }

  .logo {
    display: block;
    margin-bottom: 8px;
  }

  .tools {
    justify-content: flex-start;
  }

  .search {
    flex: 1 1 100%;
  }

  .langs {
    margin-left: 0;
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f14;
    --fg: #e5e7eb;
    --muted: #aeb7c4;
    --line: #263241;
    --soft: #0f172a;
    --panel: #0f1319;
    --subtle: #111827;
    --badge-bg: #172554;
    --badge-fg: #dbeafe;
    --quote-bg: #101722;
    --accent-soft: #172554;
    --shadow: none;
    color-scheme: dark;
  }

  .site-header {
    background: rgba(10, 12, 16, .9);
  }

  .search input[type="search"],
  .search input[type="text"] {
    background: var(--panel);
    color: var(--fg);
  }

  .main-nav a.active {
    color: #bfdbfe;
  }

  .card .title a {
    color: var(--fg);
  }

  .card .summary {
    color: var(--fg);
  }

  .content th {
    background: #0e1524;
  }

  .content tr:nth-child(even) td {
    background: #0d1220;
  }

  .content thead th {
    color: var(--fg);
    background: #172554;
  }

  .promo-card,
  .promo-wide {
    color: var(--accent-ink);
  }

  .promo-card .btn,
  .promo-wide .btn {
    color: var(--accent-ink);
  }
}
