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

body,
h1,
h2,
h3,
p {
  margin: 0;
}

body {
  background: #f8fafc;
  color: #0f172a;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}

.brand {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.site-header nav a {
  color: #64748b;
  font-size: 0.8125rem;
  text-decoration: none;
}

.site-header nav a:hover,
.site-header nav a:focus-visible {
  color: #2563eb;
}

.page {
  width: min(100% - 40px, 1080px);
  margin: 0 auto;
  padding: 40px 0 64px;
}

.eyebrow {
  color: #64748b;
  font-size: 0.6875rem;
  letter-spacing: 0.18em;
}

h1 {
  margin: 6px 0 10px;
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  line-height: 1.15;
}

.lead {
  max-width: 52ch;
  color: #334155;
  font-size: 1rem;
}

.panel {
  margin-top: 18px;
  padding: 24px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #ffffff;
}

h2 {
  font-size: 1.125rem;
}

.panel > p {
  margin-top: 6px;
  color: #334155;
  font-size: 0.875rem;
}

/* 关键：宿主元素成为容器 */
.card-host {
  container-type: inline-size;
  container-name: card;
}

/* 三种演示宽度 */
.sizes {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  padding-bottom: 8px;
  overflow-x: auto;
}

.w-200 { flex: 0 0 200px; }
.w-320 { flex: 0 0 320px; }
.w-480 { flex: 0 0 480px; }

/* 卡片默认：堆叠（窄容器） */
.card {
  display: grid;
  grid-template-areas:
    "art"
    "body"
    "link";
  gap: 0.75rem;
  padding: 0.875rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: #ffffff;
}

.card-art {
  display: grid;
  grid-area: art;
  place-items: center;
  height: 120px;
  border-radius: 0.5rem;
  color: #ffffff;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.75rem;
}

.art-a { background: linear-gradient(135deg, #2563eb, #7c3aed); }
.art-b { background: linear-gradient(135deg, #0ea5e9, #2563eb); }
.art-c { background: linear-gradient(135deg, #7c3aed, #db2777); }

.card-body {
  grid-area: body;
  min-width: 0;
}

.card-tag {
  color: #2563eb;
  font-size: 0.6875rem;
  font-family: ui-monospace, Menlo, monospace;
}

.card h3 {
  margin-top: 0.125rem;
  font-size: clamp(1rem, 5cqw, 1.5rem);
  line-height: 1.3;
}

.card-body > p:not(.card-tag):not(.card-stats) {
  margin-top: 0.25rem;
  color: #64748b;
  font-size: 0.8125rem;
}

.card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  color: #475569;
  font-size: 0.75rem;
}

.card-stats span {
  padding: 1px 8px;
  border-radius: 999px;
  background: #f1f5f9;
}

.card-link {
  display: inline-flex;
  grid-area: link;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 1px solid #bfdbfe;
  border-radius: 0.5rem;
  color: #1e40af;
  font-size: 0.8125rem;
  text-decoration: none;
}

/* 中等容器：左右布局 */
@container card (min-width: 300px) {
  .card {
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-areas:
      "art body"
      "art link";
    align-items: start;
  }

  .card-art {
    height: 100%;
    min-height: 96px;
  }

  .card-link {
    width: 100%;
  }
}

/* 宽容器：三列布局 */
@container card (min-width: 440px) {
  .card {
    grid-template-columns: 120px minmax(0, 1fr) auto;
    grid-template-areas: "art body link";
    align-items: center;
  }

  .card-art {
    height: 96px;
  }

  .card-link {
    width: auto;
  }
}

/* 真实布局 */
.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  margin-top: 14px;
}

.sidebar,
.main-col {
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 0.75rem;
  background: #f8fafc;
}

.sidebar h3,
.main-col h3 {
  font-size: 0.875rem;
  color: #64748b;
}

.sidebar .card-host,
.main-col .card-host {
  margin-top: 10px;
}

/* 容器单位 */
.unit-card {
  padding: clamp(0.75rem, 4cqw, 1.5rem);
}

.unit-card .card-body > p:not(.card-tag) {
  margin-top: 0.375rem;
}

.unit-card h3 {
  font-size: clamp(1rem, 5cqw, 1.5rem);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 20px 24px 36px;
  color: #64748b;
  font-size: 0.75rem;
}

@media (max-width: 760px) {
  .site-header {
    padding: 12px 18px;
  }

  .page {
    width: min(100% - 28px, 1080px);
    padding: 24px 0 44px;
  }

  .panel {
    padding: 16px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}
