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

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #dbeafe;
    --secondary-color: #10b981;
    --secondary-hover: #059669;
    --secondary-light: #d1fae5;
    --accent-color: #8b5cf6;
    --accent-light: #ede9fe;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --highlight-bg: #dbeafe;
    --highlight-text: #1e40af;
    --error-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 30px 20px;
    color: var(--text-primary);
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 35px;
    padding: 40px 30px;
    background: white;
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
    border-top: 4px solid var(--primary-color);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow-xl);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover::before {
    opacity: 1;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.card h2 {
    color: var(--text-primary);
    margin-bottom: 24px;
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-desc {
    color: var(--text-secondary);
    margin: -10px 0 20px 0;
    font-size: 0.9rem;
}

/* 快速输入区域 */
.quick-calc {
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
    border: 2px solid var(--primary-light);
}

.quick-input-row {
    display: grid;
    grid-template-columns: 1fr 200px auto;
    gap: 15px;
    align-items: end;
    margin-bottom: 20px;
}

.input-col {
    display: flex;
    flex-direction: column;
}

.input-col.small {
    min-width: 200px;
}

.input-col label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.input-col input {
    padding: 14px 18px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    font-family: 'Monaco', 'Courier New', monospace;
    box-shadow: var(--shadow-sm);
}

.input-col input:hover {
    border-color: var(--primary-color);
}

.input-col input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1), var(--shadow-md);
    transform: translateY(-2px);
}

.quick-examples {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 18px;
    background: linear-gradient(135deg, #f8fafc 0%, #f0f9ff 100%);
    border-radius: 12px;
    border: 2px dashed var(--primary-light);
}

.example-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.btn-example {
    padding: 8px 16px;
    background: white;
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Monaco', 'Courier New', monospace;
    color: var(--text-primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.btn-example:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-md);
}

.input-group {
    margin-bottom: 20px;
}

.input-group.inline {
    display: inline-block;
    margin-right: 15px;
    min-width: 200px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.input-group input[type="text"],
.input-group input[type="number"],
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: var(--card-bg);
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mask-input-group {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 10px;
}

.hint {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* 按钮样式 */
.btn-primary,
.btn-secondary {
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.btn-primary::before,
.btn-secondary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:hover::before,
.btn-secondary:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 24px -10px rgba(59, 130, 246, 0.5);
}

.btn-primary:active {
    transform: translateY(-1px);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-hover));
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 24px -10px rgba(16, 185, 129, 0.5);
}

.btn-secondary:active {
    transform: translateY(-1px);
}

.btn-toggle,
.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 8px 12px;
    transition: all 0.2s ease;
}

.btn-toggle:hover,
.btn-text:hover {
    background: var(--highlight-bg);
    border-radius: 6px;
}

.btn-text-large {
    background: linear-gradient(135deg, white 0%, #f0f9ff 100%);
    border: 3px dashed var(--primary-color);
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 20px 40px;
    border-radius: 16px;
    width: 100%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.btn-text-large:hover {
    border-style: solid;
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* 核心结果展示 */
.key-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.key-item {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    padding: 28px 24px;
    border-radius: 16px;
    border: 2px solid var(--primary-light);
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.key-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

.key-item:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 24px -10px rgba(59, 130, 246, 0.3);
    border-color: var(--primary-color);
}

.key-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.key-value {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 800;
    font-family: 'Monaco', 'Courier New', monospace;
    word-break: break-all;
    line-height: 1.4;
}

.key-value.highlight {
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.key-value.range {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 1rem;
}

.key-value .separator {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.detail-toggle {
    text-align: center;
    margin-bottom: 15px;
}

.detail-results {
    border-top: 2px solid var(--border-color);
    padding-top: 20px;
    margin-top: 10px;
}

.detail-grid {
    display: grid;
    gap: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--background) 0%, #f0f9ff 100%);
    border-radius: 10px;
    align-items: center;
    border-left: 3px solid var(--primary-light);
    transition: all 0.2s ease;
}

.detail-row:hover {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left-color: var(--primary-color);
    transform: translateX(4px);
}

.detail-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.detail-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 700;
    font-family: 'Monaco', 'Courier New', monospace;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.result-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--background);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    transition: all 0.2s ease;
}

.result-item:hover {
    background: #f1f5f9;
    transform: translateX(4px);
}

.result-item .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.result-item .value {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 600;
    word-break: break-all;
}

.result-item .value.highlight {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.result-item .value.binary {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.6;
}

/* 子网划分区域 */
.simple-controls {
    background: var(--background);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.control-row label {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.control-row input {
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    width: 150px;
    transition: all 0.3s ease;
}

.control-row input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.results-header h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    margin: 0;
}

.result-count {
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-hover));
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    animation: pulse 2s infinite;
}

.subnet-list {
    display: grid;
    gap: 15px;
}

.subnet-item {
    background: linear-gradient(135deg, #f0fdf4 0%, #d1fae5 100%);
    padding: 24px;
    border-radius: 12px;
    border-left: 5px solid var(--secondary-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.subnet-item:hover {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    transform: translateX(8px);
    box-shadow: var(--shadow-md);
    border-left-color: var(--secondary-hover);
}

.subnet-item h4 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 1.15rem;
    font-weight: 700;
}

.subnet-item-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.subnet-detail {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}

.subnet-detail .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.subnet-detail .value {
    color: var(--text-primary);
    font-weight: 600;
}

/* VLSM 区域 */
.vlsm-input {
    margin-bottom: 20px;
}

.vlsm-input label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.vlsm-input textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Monaco', 'Courier New', monospace;
    resize: vertical;
    transition: all 0.3s ease;
    margin-bottom: 12px;
}

.vlsm-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.vlsm-hint {
    background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
    border-left: 5px solid #fb923c;
    padding: 16px 20px;
    margin-bottom: 18px;
    border-radius: 10px;
    font-size: 0.95rem;
    color: #7c2d12;
    box-shadow: var(--shadow-sm);
    animation: slideInLeft 0.5s ease;
}

.vlsm-hint strong {
    color: #ea580c;
    font-weight: 700;
}

.advanced-tools-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 快速参考表 */
.reference-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reference-content {
    margin-top: 20px;
}

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

.ref-item {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 18px;
    border-radius: 12px;
    border-left: 4px solid var(--warning-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.ref-item:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
    transform: translateX(6px) scale(1.02);
    box-shadow: var(--shadow-md);
    border-left-color: #d97706;
}

.ref-cidr {
    font-size: 1.6rem;
    font-weight: 800;
    color: #d97706;
    font-family: 'Monaco', 'Courier New', monospace;
    margin-bottom: 10px;
}

.ref-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ref-info div:first-child {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-family: 'Monaco', 'Courier New', monospace;
}

.ref-hosts {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.advanced-toggle {
    margin-top: 10px;
}

footer {
    text-align: center;
    color: var(--text-secondary);
    padding: 30px 20px;
    margin-top: 50px;
    font-size: 0.95rem;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.card {
    animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }

header {
    animation: fadeIn 0.8s ease;
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        margin-bottom: 20px;
        padding: 20px 15px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .card {
        padding: 20px;
        border-radius: 12px;
    }
    
    .quick-input-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .input-col.small {
        max-width: 100%;
    }
    
    .key-results {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .key-value {
        font-size: 1.2rem;
    }
    
    .key-value.highlight {
        font-size: 1.6rem;
    }
    
    .reference-grid {
        grid-template-columns: 1fr;
    }
    
    .control-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-row input {
        width: 100%;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
}

/* 错误提示 */
.error {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 5px;
    display: none;
}

.error.show {
    display: block;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* 程序员风格扁平化覆盖：去渐变、弱化阴影与动画 */
header {
    background: #ffffff;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border-top: 1px solid var(--border-color);
}

header h1 {
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: inherit;
    background-clip: initial;
    color: var(--text-primary);
}

.card {
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    background: #ffffff;
    transition: none;
    animation: none;
}

.card::before {
    display: none;
}

.card:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.quick-calc {
    background: #ffffff;
    border: 1px solid var(--border-color);
}

.quick-examples {
    background: #f9fafb;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

.btn-primary,
.btn-secondary {
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: var(--primary-color);
}

.btn-secondary {
    background: var(--secondary-color);
}

.btn-primary::before,
.btn-secondary::before {
    display: none;
}

.btn-primary:hover,
.btn-secondary:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.btn-text-large {
    background: #ffffff;
    border: 1px dashed var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.btn-text-large:hover {
    background: #f9fafb;
    color: var(--primary-color);
    transform: none;
    box-shadow: var(--shadow-sm);
}

.key-item {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    box-shadow: none;
    transform: none;
}

.key-item::before {
    display: none;
}

.key-value.highlight {
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: inherit;
    background-clip: initial;
    color: var(--primary-color);
}

.detail-row {
    background: #f9fafb;
    border-left: 2px solid var(--border-color);
    transform: none;
}

.detail-row:hover {
    background: #f1f5f9;
    border-left-color: var(--primary-color);
    transform: none;
}

.subnet-item,
.ref-item {
    background: #f9fafb;
    border-left: 3px solid var(--border-color);
    box-shadow: none;
    transform: none;
}

.subnet-item:hover,
.ref-item:hover {
    background: #f1f5f9;
    border-left-color: var(--border-color);
}

.vlsm-hint {
    background: #fff7ed;
    border-left: 4px solid #fb923c;
    box-shadow: none;
    animation: none;
}

.result-count {
    background: var(--secondary-color);
    animation: none;
}

.card,
header {
    animation: none;
}