:root {
    --primary-color: #6366f1;
    --accent-color: #a855f7;
    --bg-dark: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --ipv4-color: #6366f1;
    --ipv6-color: #a855f7;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body {
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    color: var(--text-main);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

/* 装饰背景 */
.bg-glow {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    overflow: hidden; z-index: -1;
    pointer-events: none;
}
.bg-glow::before {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: var(--primary-color);
    filter: blur(150px);
    opacity: 0.15;
    top: 10%; left: 10%;
    animation: float 20s ease-in-out infinite;
}
.bg-glow::after {
    content: '';
    position: absolute;
    width: 300px; height: 300px;
    background: var(--accent-color);
    filter: blur(100px);
    opacity: 0.1;
    bottom: 20%; right: 15%;
    animation: float 15s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0px, 0px); }
    33% { transform: translate(30px, -30px); }
    66% { transform: translate(-20px, 20px); }
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    animation: fadeInUp 0.8s ease-out;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.header h1 {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 800;
    margin-bottom: 0.8rem;
    background: linear-gradient(to right, var(--text-main), var(--text-dim));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.header p {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--text-dim);
    font-weight: 300;
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .main-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 32px 64px -12px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.2);
}

.card-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-dim);
}

.card-title i {
    font-size: 1rem;
}

.card-title.ipv4 {
    color: var(--ipv4-color);
}

.card-title.ipv6 {
    color: var(--ipv6-color);
}

.ip-display {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    word-break: break-all;
    line-height: 1.2;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
    letter-spacing: -0.02em;
}

/* IPv6 特殊样式 - 统一使用长地址格式 */
.ipv6-address {
    font-size: clamp(1.2rem, 4vw, 2.2rem);
    line-height: 1.4;
    letter-spacing: 0.02em;
}

.ipv6-long {
    font-size: clamp(1rem, 3.5vw, 2rem);
    letter-spacing: 0.01em;
    line-height: 1.5;
}

.location-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    color: var(--text-dim);
    margin-top: 1rem;
    padding: 0.8rem 1.2rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border-left: 3px solid var(--primary-color);
}

.location-info::before {
    content: '📍';
    font-size: 1.1rem;
}

/* 检测来源标识 */
.detection-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-color);
    font-weight: 600;
    margin-left: 12px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    backdrop-filter: blur(4px);
}

.detection-badge.ipv6-direct {
    background: rgba(168, 85, 247, 0.2);
    color: var(--accent-color);
    border-color: rgba(168, 85, 247, 0.3);
}

.detection-badge::before {
    content: '🔍';
    font-size: 0.8rem;
}

.no-ip {
    color: var(--text-dim);
    font-style: italic;
    font-weight: 400;
    opacity: 0.7;
}

.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Search Card */
.search-card {
    grid-column: 1 / -1;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.search-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
}

.search-card h2 {
    font-size: 1.8rem;
    margin-bottom: 0.8rem;
    color: var(--text-main);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-card h2 i {
    color: var(--primary-color);
    font-size: 1.6rem;
}

.search-card p {
    color: var(--text-dim);
    margin-bottom: 2rem;
    font-size: 1.05rem;
}

.search-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 280px;
    padding: 1rem 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    font-size: 1rem;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    backdrop-filter: blur(4px);
}

.search-input::placeholder {
    color: var(--text-dim);
    opacity: 0.7;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: rgba(255, 255, 255, 0.08);
}

.search-btn {
    padding: 1rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.search-btn:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.search-btn:active {
    transform: translateY(0);
}

.search-btn i {
    font-size: 0.9rem;
}

/* Query Result */
.query-result {
    margin-top: 2rem;
    padding: 2rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(4px);
}

.query-result.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.query-result h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.query-result h3 i {
    font-size: 1rem;
}

.query-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.query-detail-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    transition: all 0.3s ease;
    border-left: 3px solid var(--primary-color);
}

.query-detail-item:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.06);
}

.query-detail-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.query-detail-value {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
}

/* API Info */
.api-section {
    grid-column: 1 / -1;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.api-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
}

.api-section h3 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}

.api-section h3 i {
    color: var(--primary-color);
    font-size: 1.6rem;
}

.api-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.api-item {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.api-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    background: var(--primary-color);
}

.api-item:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.api-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.8rem;
    font-weight: 600;
}

.api-url {
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
    font-size: 0.9rem;
    color: var(--primary-color);
    word-break: break-all;
    font-weight: 500;
}

/* Ad Slots */
.ad-section {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.ad-slot {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(4px);
    border-radius: 16px;
    padding: 2rem;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: var(--text-dim);
    font-size: 0.9rem;
    text-align: center;
    transition: all 0.3s ease;
}

.ad-slot:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.ad-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}

.ad-slot a {
    display: block;
    width: 100%;
    height: 100%;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 3rem;
    padding: 2rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: var(--text-main);
}

/* Copy Button */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 12px;
    backdrop-filter: blur(4px);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.copy-btn.copied {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #22c55e;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }

    .header h1 {
        font-size: 2.5rem;
    }

    .card, .search-card, .api-section {
        padding: 2rem;
    }

    .ip-display {
        font-size: 1.8rem;
    }

    .ipv6-long {
        font-size: 1.2rem;
        line-height: 1.6;
        padding: 1rem;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }

    .search-form {
        flex-direction: column;
    }

    .search-input, .search-btn {
        width: 100%;
        min-width: auto;
    }

    .ad-section {
        grid-template-columns: 1fr;
    }

    .copy-btn {
        margin-left: 0;
        margin-top: 12px;
        display: block;
        width: fit-content;
    }
}
