:root {
    --bg: #ffffff;
    --bg-surface: #f8f9fa;
    --bg-card: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #888;
    --border: #e2e8f0;
    --accent: #6c5ce7;
    --accent-hover: #5a4bd1;
    --shadow: rgba(0, 0, 0, 0.06);
    --code-bg: #f1f3f5;
    --badge-open-bg: #d4edda;
    --badge-open-text: #155724;
    --badge-restricted-bg: #fff3cd;
    --badge-restricted-text: #856404;
    --badge-restricted-border: rgba(133, 100, 4, 0.3);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d0d12;
        --bg-surface: #16161e;
        --bg-card: #1c1c28;
        --text: #e0e0e8;
        --text-secondary: #a0a0b0;
        --text-muted: #606070;
        --border: #2a2a3a;
        --accent: #a29bfe;
        --accent-hover: #8b82f8;
        --shadow: rgba(0, 0, 0, 0.25);
        --code-bg: #22222e;
        --badge-open-bg: #1a3a2a;
        --badge-open-text: #6fcf97;
        --badge-restricted-bg: #3a3020;
        --badge-restricted-text: #f2c94c;
        --badge-restricted-border: rgba(242, 201, 76, 0.3);
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
    color: var(--text);
    background: var(--bg);
    line-height: 1.65;
}

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

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Header */
header {
    margin-bottom: 2rem;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--text);
}

.header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.4;
}

.badge-open {
    background: var(--badge-open-bg);
    color: var(--badge-open-text);
}

.badge-restricted {
    background: var(--badge-restricted-bg);
    color: var(--badge-restricted-text);
}

.badge-muted {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

/* Description */
.description {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    background: var(--bg-surface);
    border-radius: 10px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

/* Notice */
.notice {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
}

.notice-restricted {
    background: var(--badge-restricted-bg);
    color: var(--badge-restricted-text);
    border: 1px solid var(--badge-restricted-border);
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
    box-shadow: 0 1px 3px var(--shadow);
}

.card h2 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin: 0 0 1rem;
}

.card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 1rem 0 0.25rem;
}

.card h3:first-of-type {
    margin-top: 0;
}

.card p {
    margin: 0.25rem 0 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.relay-url {
    display: block;
    background: var(--code-bg);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
    font-size: 0.85rem;
    word-break: break-all;
    color: var(--text);
    margin: 0.5rem 0;
}

/* Instance grid */
.instance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.instance-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
}

.instance-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.instance-favicon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
    flex-shrink: 0;
}

.instance-domain {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text);
    overflow-x: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.instance-domain:hover {
    color: var(--accent-hover);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-left: auto;
}

.status-ok {
    background: var(--badge-open-text);
}

.status-down {
    background: var(--badge-restricted-text);
}

.status-unknown {
    background: var(--text-muted);
}

.instance-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.instance-software {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow-x: hidden;
    text-overflow: ellipsis;
}

.badge-sm {
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
}

.instance-staff {
    font-size: 0.75rem;
    margin-top: 0.15rem;
}

.staff-link {
    color: var(--accent);
    font-size: 0.75rem;
}

.instance-joined {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 0;
}

/* Footer */
footer {
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.custom-footer {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.version-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.version-info a {
    color: var(--text-muted);
    text-decoration: underline;
}

.version-info a:hover {
    color: var(--accent);
    text-decoration: none;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 1.25rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

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

    .card {
        padding: 1.25rem;
    }
}
