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

:root {
    --accent:      #39C5BB;
    --accent-dark: #1FA69C;
    --accent-tint: #E6FAF8;
    --ink:      #14201f;
    --muted:    #8a9694;
    --border:   #e7edec;
    --bg:       #ffffff;
    --card-bg:  #ffffff;
    --hover-bg: #F7FCFB;
    --modal-bg: rgba(20, 32, 31, .45);
    --modal-panel: #ffffff;
    --shadow:   0 10px 30px -12px rgba(20, 32, 31, .12);
    --ease:     cubic-bezier(.22, .9, .32, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent:      #45D6CB;
        --accent-dark: #7CE8DF;
        --accent-tint: rgba(69, 214, 203, .14);
        --ink:      #eef5f4;
        --muted:    #93a19e;
        --border:   #223330;
        --bg:       #0f1615;
        --card-bg:  #131c1b;
        --hover-bg: #16211f;
        --modal-bg: rgba(0, 0, 0, .6);
        --modal-panel: #131c1b;
        --shadow:   0 10px 30px -12px rgba(0, 0, 0, .5);
    }
}

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

body {
    font-family: 'Nunito', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color .3s, color .3s;
}

a, button { -webkit-tap-highlight-color: transparent; }

/* ── Layout shell ── */
.page {
    max-width: 1600px;
    margin: 0 auto;
    padding: clamp(28px, 5vw, 56px) clamp(20px, 4vw, 48px) 56px;
}

/* ── Stagger fade-in (driven by --i custom property) ── */
.page > *, header > *, footer > * {
    opacity: 0;
    transform: translateY(14px);
    animation: up .55s var(--ease) forwards;
    animation-delay: calc(var(--i, 0) * 0.06s);
}

@keyframes up {
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .page > *, header > *, footer > * { animation: none; opacity: 1; transform: none; }
    html { scroll-behavior: auto; }
}

/* ── Header / top bar (hugs the top-left corner) ── */
.topbar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    margin-bottom: 8px;
    margin-right: auto;
    max-width: 460px;
}

.eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--accent-dark);
    margin-bottom: 14px;
}

.topbar h1 {
    font-family: 'Baloo 2', 'Noto Sans SC', sans-serif;
    font-size: clamp(1.6rem, 4vw, 2rem);
    font-weight: 700;
    margin-bottom: 10px;
}

.h1-sub { color: var(--muted); font-weight: 500; }

.subtitle {
    color: var(--muted);
    font-size: .95rem;
    max-width: 400px;
}

/* ── Rule & section label ── */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 36px 0 24px;
}

.label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 18px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 24px;
    border-radius: 12px;
    font-size: .95rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease);
}

.btn-primary {
    background-color: var(--accent);
    color: #ffffff !important;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    background-color: var(--accent-dark);
}

.btn-outline {
    background-color: transparent;
    color: var(--ink);
    border: 1px solid var(--border);
}

.btn-outline:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: transparent;
    background-color: var(--hover-bg);
}

/* ── Cards grid (auto-spreads with viewport width) ── */
.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: clamp(12px, 1.6vw, 20px);
    width: 100%;
}

.friend-card {
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px 20px;
    text-decoration: none;
    color: inherit;
    opacity: 0;
    transform: translateY(14px);
    animation: up .5s var(--ease) forwards;
    animation-delay: calc(var(--i, 0) * 0.05s);
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}

@media (prefers-reduced-motion: reduce) {
    .friend-card { animation: none; opacity: 1; transform: none; }
}

.friend-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: transparent;
}

.friend-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 16px;
    border: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--hover-bg);
}

.friend-info { overflow: hidden; }

.friend-name {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-slogan {
    font-size: .85rem;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: all .3s var(--ease);
}

.friend-card:hover .friend-slogan {
    -webkit-line-clamp: unset;
    display: block;
}

.loading, .error {
    text-align: center;
    color: var(--muted);
    grid-column: 1 / -1;
    padding: 40px 0;
}

/* ── 连通性状态点 ── */
.friend-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, .25);
    animation: pulse-green 2.5s ease-in-out infinite;
}

.status-dot.offline {
    background-color: #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, .2);
}

.status-dot.http-only {
    background-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, .2);
}

.status-dot.pending {
    background-color: #9ca3af;
    animation: pulse-gray 1.2s ease-in-out infinite;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 2px rgba(34, 197, 94, .25); }
    50%       { box-shadow: 0 0 0 4px rgba(34, 197, 94, .1); }
}

@keyframes pulse-gray {
    0%, 100% { opacity: 1; }
    50%       { opacity: .4; }
}

@media (prefers-reduced-motion: reduce) {
    .status-dot.online, .status-dot.pending { animation: none; }
}

.status-label { font-size: .75rem; color: var(--muted); }

/* ── 站长置顶卡片 ── */
.owner-card {
    border-color: var(--accent) !important;
    background: linear-gradient(160deg, var(--accent-tint), var(--card-bg) 65%);
}

.owner-badge {
    display: inline-block;
    font-size: .65rem;
    font-weight: 700;
    color: var(--accent-dark);
    background-color: var(--accent-tint);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 5px;
    padding: 1px 5px;
    margin-right: 4px;
    vertical-align: middle;
    letter-spacing: .03em;
}

/* ── 页脚 ── */
footer {
    margin-top: 8px;
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
}

.footer-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.powered { margin-top: 6px; font-size: .82rem; color: #b7c0be; }

.heart { color: var(--accent); display: inline-block; animation: beat 1.4s ease infinite; }

@keyframes beat {
    0%, 100% { transform: scale(1); }
    30%       { transform: scale(1.25); }
    60%       { transform: scale(1); }
    80%       { transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
    .heart { animation: none; }
}

.disclaimer {
    margin-top: 14px;
    font-size: .78rem;
    color: var(--muted);
    opacity: .75;
    line-height: 1.8;
}

/* ── Site footer ── */
.site-footer {
    border-top: 1px solid var(--border);
    margin-top: 40px;
    padding-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(14px);
    animation: up .55s var(--ease) forwards;
    animation-delay: .66s;
}

@media (prefers-reduced-motion: reduce) {
    .site-footer { animation: none; opacity: 1; transform: none; }
}

.site-footer-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

.site-footer-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #99a3a1;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 8px;
    transition: color .2s, background .2s;
}

.site-footer-link:hover { color: var(--ink); background: var(--hover-bg); }
.site-footer-link svg { width: 13px; height: 13px; flex-shrink: 0; }

.site-footer-sep { font-size: 12px; color: #ccc; }

.powered a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    transition: color .2s;
}

.powered a:hover { color: var(--accent-dark); }

/* ── 弹窗 Modal ── */
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    inset: 0;
    background-color: var(--modal-bg);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .3s var(--ease);
}

.modal.show { display: flex; opacity: 1; }

.modal-content {
    background-color: var(--modal-panel);
    padding: 30px;
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    position: relative;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transform: translateY(-20px);
    transition: transform .3s var(--ease);
}

.modal.show .modal-content { transform: translateY(0); }

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    color: var(--muted);
    cursor: pointer;
}

.close-btn:hover { color: var(--ink); }

.modal-content h2 {
    font-family: 'Baloo 2', 'Noto Sans SC', sans-serif;
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.modal-content p {
    color: var(--muted);
    font-size: .95rem;
    margin-bottom: 24px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── 移动端适配 ── */
@media (max-width: 768px) {
    .friends-grid { grid-template-columns: 1fr; gap: 14px; }

    .footer-actions { flex-direction: column; gap: 12px; }
    .footer-actions .btn { width: 100%; max-width: 250px; }
}

@media (max-width: 560px) {
    .topbar { max-width: 100%; }
    .subtitle { max-width: 100%; }
}

@media (max-width: 380px) {
    .page { padding-left: 16px; padding-right: 16px; }
    hr { margin: 24px 0 18px; }
    .friend-card { padding: 16px; }
    .friend-avatar { width: 48px; height: 48px; margin-right: 12px; }
}
