/* WaiShiHui — design system
   暖纸底 + 墨黑 + 朱砂红；五行色用于干支点缀 */

:root {
    color-scheme: light dark;

    --paper: #fbfaf8;
    --paper-2: #ffffff;
    --paper-3: #f4f2ee;
    --ink: #15181c;
    --ink-2: #3d454e;
    --muted: #6d7580;
    --line: #e6e3dd;
    --line-2: #d6d2ca;
    --accent: #b8352b;
    --accent-soft: #fdf1ef;
    --accent-ink: #8f2820;

    --elem-wood: #2f7d55;
    --elem-fire: #c2410c;
    --elem-earth: #a16207;
    --elem-metal: #a16207;
    --elem-water: #1d4ed8;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(20, 24, 28, .05);
    --shadow: 0 1px 2px rgba(20, 24, 28, .04), 0 12px 32px -18px rgba(20, 24, 28, .28);
    --shadow-lg: 0 2px 4px rgba(20, 24, 28, .05), 0 28px 60px -28px rgba(20, 24, 28, .35);

    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #0f1114;
        --paper-2: #171a1e;
        --paper-3: #1e2227;
        --ink: #eceae6;
        --ink-2: #c3c7cc;
        --muted: #8d949c;
        --line: #262a30;
        --line-2: #343a41;
        --accent: #ef6a5a;
        --accent-soft: #2a1715;
        --accent-ink: #f7a99d;
        --elem-wood: #4ec98a;
        --elem-fire: #fb923c;
        --elem-earth: #d9a441;
        --elem-metal: #d9a441;
        --elem-water: #7aa2f7;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 16px 40px -20px rgba(0, 0, 0, .8);
        --shadow-lg: 0 2px 6px rgba(0, 0, 0, .45), 0 30px 70px -30px rgba(0, 0, 0, .9);
    }
}

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

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

body {
    margin: 0;
    background:
        radial-gradient(1100px 520px at 50% -12%, rgba(184, 53, 43, .07), transparent 62%),
        var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

::selection { background: rgba(184, 53, 43, .18); }

/* ---------- layout ---------- */
.wrap {
    width: 100%;
    max-width: 980px;
    margin: 0 auto;
    padding: 0 20px 72px;
}

.skip {
    position: absolute;
    left: -9999px;
}
.skip:focus {
    left: 12px;
    top: 12px;
    z-index: 20;
    background: var(--paper-2);
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

/* ---------- top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
    background: color-mix(in srgb, var(--paper) 82%, transparent);
    border-bottom: 1px solid var(--line);
}

/* 老浏览器不支持 color-mix()：先给实色回退，再叠加半透明 */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
    .topbar { background: var(--paper); }
    .alert, .callout { border-color: var(--line-2); }
    input:hover, select:hover,
    .animals li:hover { border-color: var(--accent); }
    :focus-visible { outline-offset: 3px; }
}

.topbar .inner {
    max-width: 980px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--ink);
    text-decoration: none;
}

.brand .seal {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: linear-gradient(150deg, var(--accent), #7d1f18);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: grid;
    place-items: center;
    box-shadow: 0 2px 8px -2px rgba(184, 53, 43, .7);
}

.topnav {
    display: flex;
    gap: 22px;
    font-size: 14px;
}
.topnav a {
    color: var(--muted);
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: color .18s, border-color .18s;
}
.topnav a:hover, .topnav a[aria-current] {
    color: var(--ink);
    border-bottom-color: var(--accent);
}

/* ---------- hero ---------- */
.hero {
    padding: 56px 0 34px;
    text-align: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    background: var(--paper-2);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: .02em;
}
.badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(184, 53, 43, .14);
}

.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2.1rem, 5.6vw, 3.4rem);
    line-height: 1.1;
    font-weight: 600;
    letter-spacing: -.02em;
    margin: 18px 0 0;
}

.hero h1 em {
    font-style: italic;
    color: var(--accent);
}

.hero .lede {
    max-width: 620px;
    margin: 16px auto 0;
    color: var(--ink-2);
    font-size: clamp(1rem, 2.2vw, 1.12rem);
}

/* ---------- cards ---------- */
.card {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
    margin-bottom: 22px;
    position: relative;
    overflow: hidden;
}

.card.accent::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #d98a3a 45%, transparent);
}

.card > h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -.01em;
    margin: 0 0 4px;
}

.card > h2 + .sub {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 14.5px;
}

/* ---------- form ---------- */
.fieldset {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    color: var(--muted);
}

label > span.hint-inline {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--muted);
}

input, select {
    font: inherit;
    font-size: 15px;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    padding: 11px 12px;
    width: 100%;
    transition: border-color .16s, box-shadow .16s, background .16s;
}

input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }

input:hover, select:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line-2)); }

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--paper-2);
    box-shadow: 0 0 0 3px rgba(184, 53, 43, .13);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%236d7580' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.btn {
    font: inherit;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 12px 26px;
    cursor: pointer;
    transition: transform .14s, box-shadow .18s, background .18s;
}

.btn-primary {
    background: linear-gradient(160deg, var(--accent), #91241b);
    color: #fff;
    box-shadow: 0 8px 22px -10px rgba(184, 53, 43, .85), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -10px rgba(184, 53, 43, .95); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
    background: transparent;
    border-color: var(--line-2);
    color: var(--ink-2);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.form-note {
    margin: 16px 0 0;
    font-size: 13.5px;
    color: var(--muted);
    max-width: 62ch;
}

/* ---------- error ---------- */
.alert {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
    border-left: 3px solid var(--accent);
    color: var(--accent-ink);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 14.5px;
    margin-bottom: 20px;
}
.alert svg { flex: none; margin-top: 2px; }

/* ---------- result hero ---------- */
.result-head {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.result-head img {
    width: 84px;
    height: 84px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: var(--paper-3);
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}

.result-head .who h2 {
    font-family: var(--font-display);
    font-size: clamp(1.9rem, 5vw, 2.6rem);
    line-height: 1.05;
    font-weight: 600;
    letter-spacing: -.02em;
    margin: 0;
}

.result-head .who .sub-line {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14.5px;
}
.result-head .who .sub-line b { color: var(--ink-2); font-weight: 600; }

/* ---------- definition grid ---------- */
.specs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    margin: 22px 0 0;
}

.specs .cell {
    background: var(--paper-2);
    padding: 16px 18px;
}

.specs dt {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}

.specs dd {
    margin: 0;
    font-size: 16.5px;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.specs dd small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }

/* ---------- pillars ---------- */
.pillars {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 6px;
}

.pillar {
    position: relative;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 10px 14px;
    text-align: center;
    overflow: hidden;
}
.pillar::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 3px;
    background: var(--pillar-hue, var(--line-2));
    opacity: .85;
}
.pillar .lab {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
}
.pillar .en {
    font-family: var(--font-display);
    font-size: 1.22rem;
    font-weight: 600;
    letter-spacing: -.01em;
    margin: 6px 0 2px;
    line-height: 1.2;
}
.pillar .cn {
    font-size: 13px;
    color: var(--muted);
    letter-spacing: .18em;
}
.pillar .tag {
    display: inline-block;
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--pillar-hue, var(--muted));
    font-weight: 600;
    letter-spacing: .03em;
}

/* ---------- callout ---------- */
.callout {
    margin-top: 22px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px;
    background: linear-gradient(180deg, var(--accent-soft), transparent 160%);
    border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
    border-radius: var(--radius);
    padding: 18px 20px;
}
.callout .mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
}
.callout h3 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .01em;
    color: var(--accent-ink);
}
.callout p { margin: 0; font-size: 14.5px; color: var(--ink-2); }
.callout strong { color: var(--ink); }

/* ---------- animal grid ---------- */
.animals {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.animals li {
    display: flex;
    flex-direction: column;
    padding: 16px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
    text-decoration: none;
    color: inherit;
    transition: transform .16s, box-shadow .2s, border-color .2s;
}
.animals li:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    box-shadow: var(--shadow);
}
.animals img {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    background: var(--paper-2);
}
.animals .nm {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.animals .nm .cn { font-size: 13px; color: var(--accent); font-family: var(--font-sans); }
.animals .sm {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.45;
    margin-top: 3px;
}

/* ---------- prose ---------- */
.prose p { color: var(--ink-2); }
.prose strong { color: var(--ink); }
.prose h2 { margin-top: 0; }

/* ---------- footer ---------- */
.footer {
    border-top: 1px solid var(--line);
    margin-top: 40px;
    padding: 26px 0 0;
    color: var(--muted);
    font-size: 13.5px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
    .hero { padding: 34px 0 24px; }
    .card { padding: 20px 18px; border-radius: 14px; }
    .pillars { grid-template-columns: repeat(2, 1fr); }
    .result-head img { width: 64px; height: 64px; }
    .topnav { gap: 14px; font-size: 13px; }
    .specs { grid-template-columns: 1fr; }
}

/* ---------- breadcrumbs ---------- */
.crumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--muted);
    padding: 18px 0 0;
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs strong { color: var(--ink); font-weight: 600; }
.crumbs span { opacity: .5; }

/* ---------- chips ---------- */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.chip {
    display: inline-block;
    min-width: 42px;
    text-align: center;
    padding: 7px 10px;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
    color: var(--ink-2);
    background: var(--paper);
    border: 1px solid var(--line-2);
    border-radius: 9px;
    text-decoration: none;
    transition: border-color .16s, color .16s, background .16s, transform .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.chip.on {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

/* ---------- element tally ---------- */
.sub-h {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    margin: 26px 0 12px;
}
.tally {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 9px;
}
.tally li {
    display: grid;
    grid-template-columns: 62px 1fr 96px;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}
.tally .t-name { color: var(--ink-2); font-weight: 600; }
.tally .t-track {
    height: 9px;
    border-radius: 999px;
    background: var(--paper-3);
    overflow: hidden;
}
.tally .t-track i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--bar, var(--line-2));
    transition: width .5s cubic-bezier(.2, .8, .2, 1);
}
.tally .t-num {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 14.5px;
    font-variant-numeric: tabular-nums;
}
table.grid th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 12px 9px;
    border-bottom: 1px solid var(--line-2);
    white-space: nowrap;
}
table.grid td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover { background: var(--paper-3); }
table.grid tr.on td { background: var(--accent-soft); font-weight: 600; }
table.grid .kind { font-style: normal; color: var(--muted); font-size: 12px; }

/* ---------- link cards ---------- */
.cards-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.link-card {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: transform .16s, box-shadow .2s, border-color .2s;
}
.link-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.link-card .rc-k {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--accent);
}
.link-card .rc-t {
    display: block;
    font-family: var(--font-display);
    font-size: 1.16rem;
    font-weight: 600;
    margin: 6px 0 4px;
    letter-spacing: -.01em;
}
.link-card .rc-d { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.related {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
}
.related .card { margin-bottom: 0; padding: 20px; }

/* ---------- misc ---------- */
.cn { letter-spacing: .06em; }
h1 .cn, .who .cn { font-size: .8em; color: var(--muted); }
.lede-inline {
    margin: 18px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--ink-2);
    font-size: 15px;
}
.result-head h1 {
    font-family: var(--font-display);
    font-size: clamp(1.9rem, 5vw, 2.6rem);
    line-height: 1.05;
    font-weight: 600;
    letter-spacing: -.02em;
    margin: 0;
}
.card > h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 4.4vw, 2.3rem); font-weight: 600; letter-spacing: -.02em; margin: 0 0 6px; }

@media (max-width: 640px) {
    .tally li { grid-template-columns: 54px 1fr 72px; font-size: 13px; }
    .crumbs { font-size: 12.5px; }
}

@media print {
    .topbar, .footer, form { display: none; }
    body { background: #fff; }
    .card { box-shadow: none; break-inside: avoid; }
}
