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

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

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

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

.brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

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

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

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

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

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

h1 {
  margin: 6px 0 10px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.12;
}

.lead {
  color: #334155;
  font-size: 16px;
}

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

h2 {
  font-size: 19px;
}

.panel p {
  margin-top: 8px;
  color: #334155;
  font-size: 14px;
}

/* 1. 三条规则竞争 */
p {
  color: #64748b;
}

.note {
  color: #2563eb;
}

#target {
  color: #dc2626;
  font-weight: 600;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  color: #64748b;
  font-size: 12px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.dot.element {
  background: #64748b;
}

.dot.class {
  background: #2563eb;
}

.dot.id {
  background: #dc2626;
}

/* 2. 同优先级，后写赢 */
.order {
  padding: 6px 10px;
  border-radius: 6px;
  background: #f1f5f9;
}

.order {
  color: #1e40af;
}

.order.last {
  color: #166534;
  background: #f0fdf4;
}

/* 3. 继承 */
.inherit-box {
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  color: #7c3aed;
  font-family: Georgia, "Times New Roman", serif;
}

.inherit-box p {
  margin-top: 0;
  color: inherit;
  font-size: 16px;
}

.bordered {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 8px;
  border: 2px solid #7c3aed;
  border-radius: 6px;
  font-size: 13px;
}

/* 4. !important 例外 */
#override {
  color: #0f172a;
}

.override {
  color: #b45309 !important;
  font-weight: 600;
}

.fine {
  color: #64748b;
  font-size: 12px !important;
}

.site-footer {
  padding: 20px 24px 36px;
  color: #64748b;
  font-size: 12px;
  text-align: center;
}

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #f1f5f9;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}

@media (max-width: 640px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .page {
    width: min(100% - 28px, 820px);
    padding: 28px 0 48px;
  }

  .panel {
    padding: 18px;
  }
}
