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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: var(--bg-primary);
    text-decoration: none;
}

.skip-link:focus {
    left: 0;
}

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252540;
    --accent: #00d4ff;
    --accent-dim: #0099bb;
    --text-primary: #f0f0f0;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --success: #10b981;
    --success-bg: #064e3b;
    --warning: #f59e0b;
    --warning-bg: #78350f;
    --error: #ef4444;
    --error-bg: #7f1d1d;
    --family: #ec4899;
    --family-bg: #831843;
    --security: #8b5cf6;
    --security-bg: #4c1d95;
    --privacy: #06b6d4;
    --privacy-bg: #164e63;
    --unfiltered: #84cc16;
    --unfiltered-bg: #365314;
    --border: #374151;
    --radius: 8px;
    --radius-sm: 4px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.header .subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Navigation */
.nav-tabs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.nav-tab {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nav-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent-dim);
}

.nav-tab.active {
    background: var(--accent);
    color: var(--bg-primary);
    border-color: var(--accent);
}

/* Controls Row */
.controls-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 200px;
}

.control-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.control-group select,
.control-group input {
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
}

.control-group select:focus,
.control-group input:focus {
    border-color: var(--accent-dim);
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

/* Query Form */
.query-form {
    margin-bottom: 1.5rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.input-row input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    outline: none;
}

.input-row input[type="text"]:focus {
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.input-row input[type="text"]::placeholder {
    color: var(--text-muted);
}

.input-row select {
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
}

.input-row select:focus {
    box-shadow: 0 0 0 2px var(--accent-dim);
}

.input-row button {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: var(--bg-primary);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
}

.input-row button:hover {
    background: var(--accent-dim);
}

.input-row button:active {
    transform: scale(0.98);
}

.input-row button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Status Messages */
.status {
    display: none;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.status.loading {
    display: flex;
    background: var(--bg-secondary);
    color: var(--accent);
    border: 1px solid var(--border);
}

.status.error {
    display: flex;
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid var(--error);
}

.status .spinner {
    display: none;
}

.status.loading .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent-dim);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Server Grid */
.server-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.server-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.server-card:hover {
    border-color: var(--accent-dim);
}

.server-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

.server-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.server-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.server-provider {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.server-description {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.server-badges {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

/* Category Badges */
.badge {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

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

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

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

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

.badge.protocol {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge.dnssec {
    background: var(--success-bg);
    color: var(--success);
}

.badge.planned {
    background: var(--warning-bg);
    color: var(--warning);
}

/* Protocol Icons */
.protocol-badges {
    display: flex;
    gap: 0.25rem;
}

.protocol-badge {
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.protocol-badge.available {
    color: var(--accent);
    border-color: var(--accent-dim);
}

/* Server Selection */
.server-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.server-select input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Results Table */
#results-section {
    margin-bottom: 1.5rem;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 1rem;
}

.results-table th,
.results-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.results-table th {
    background: var(--bg-tertiary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.results-table td {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table .server-name-cell {
    font-weight: 500;
}

.results-table .response-cell {
    font-family: "SF Mono", Monaco, monospace;
    font-size: 0.8125rem;
}

.results-table .latency-cell {
    text-align: right;
    color: var(--text-secondary);
}

.results-table .status-cell {
    text-align: center;
}

.results-table .empty-state {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 1.5rem 1rem;
}

.results-table .pending-cell {
    color: var(--text-muted);
}

.results-table .dnssec-cell {
    text-align: center;
}

.dnssec-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

.dnssec-badge.validated {
    background: var(--success-bg);
    color: var(--success);
}

.dnssec-badge.unsigned {
    color: var(--text-muted);
}

.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.875rem;
}

.status-icon.success {
    background: var(--success-bg);
    color: var(--success);
}

.status-icon.error {
    background: var(--error-bg);
    color: var(--error);
}

.status-icon.loading {
    border: 2px solid var(--accent-dim);
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

/* Node Sets */
.node-set-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.node-set-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}

.node-set-header:hover {
    background: var(--bg-tertiary);
}

.node-set-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.node-set-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.node-set-description {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.node-set-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.node-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.expand-icon {
    color: var(--text-muted);
    transition: transform 0.2s;
}

.node-set-card.expanded .expand-icon {
    transform: rotate(180deg);
}

.node-list {
    display: none;
    padding: 0 1rem 1rem;
}

.node-set-card.expanded .node-list {
    display: block;
}

.node-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.node-item {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.node-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.node-region {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.node-status {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.node-status.enabled {
    color: var(--success);
}

.node-status.disabled {
    color: var(--warning);
}

/* Aspirational Notice */
.aspirational-notice {
    background: var(--warning-bg);
    border: 1px solid var(--warning);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.aspirational-notice .icon {
    font-size: 1.25rem;
}

.aspirational-notice .text {
    font-size: 0.875rem;
    color: var(--warning);
}

/* Footer */
.footer {
    margin-top: 2rem;
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.footer p {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

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

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

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1.5rem 1rem;
    }

    .controls-row {
        flex-direction: column;
    }

    .control-group {
        min-width: 100%;
    }

    .input-row {
        flex-wrap: wrap;
    }

    .input-row input[type="text"] {
        width: 100%;
    }

    .input-row select,
    .input-row button {
        flex: 1;
    }

    .server-grid {
        grid-template-columns: 1fr;
    }

    .node-grid {
        grid-template-columns: 1fr;
    }

    .results-table {
        font-size: 0.8125rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.5rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.server-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@supports not selector(:focus-visible) {
    a:focus,
    button:focus,
    input:focus,
    select:focus,
    .server-card:focus {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
}
