:root {
    --primary-color: #0052CC;
    --secondary-color: #42526E;
    --success-color: #00875A;
    --background-color: #FAFBFC;
    --surface-color: #FFFFFF;
    --border-color: #DFE1E6;
    --text-primary: #172B4D;
    --text-secondary: #6B778C;
    --shadow-sm: 0 1px 2px rgba(9, 30, 66, 0.25);
    --shadow-md: 0 4px 8px rgba(9, 30, 66, 0.15);
    --shadow-lg: 0 8px 16px rgba(9, 30, 66, 0.15);
    --radius: 4px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}

h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.language-selector {
    position: absolute;
    top: 0;
    right: 0;
}

.language-selector select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--surface-color);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.language-selector select:hover {
    border-color: var(--primary-color);
}

main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.input-section {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

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

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

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.1);
}

.subnet-input {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}

.subnet-input select {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--surface-color);
    font-size: 16px;
    cursor: pointer;
    transition: border-color 0.2s;
}

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

#calculate-btn {
    width: 100%;
    padding: 14px 24px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

#calculate-btn:hover {
    background-color: #0747A6;
}

#calculate-btn:active {
    transform: translateY(1px);
}

.results-section {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-section h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

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

.result-item {
    padding: 20px;
    background-color: var(--background-color);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.result-item .label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.result-item .value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.visualization {
    margin-top: 30px;
}

.visualization h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.address-range {
    margin-bottom: 30px;
}

.range-bar {
    height: 40px;
    background-color: var(--background-color);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    margin-bottom: 10px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.network-segment {
    background-color: #FF5630;
    width: 5%;
    transition: width 0.3s ease;
}

.host-segment {
    background-color: var(--success-color);
    flex: 1;
    transition: flex 0.3s ease;
}

.broadcast-segment {
    background-color: #FF5630;
    width: 5%;
    transition: width 0.3s ease;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary);
}

.binary-representation {
    background-color: var(--background-color);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.binary-representation h4 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.binary-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.binary-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 20px;
}

.binary-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.binary-value {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--surface-color);
    padding: 8px 12px;
    border-radius: var(--radius);
    overflow-x: auto;
    white-space: nowrap;
}

.info-section {
    background-color: var(--surface-color);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.info-section h2,
.info-section h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.info-section ol,
.info-section ul {
    margin-left: 30px;
    color: var(--text-secondary);
}

.info-section li {
    margin-bottom: 8px;
}

footer {
    text-align: center;
    margin-top: 60px;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .language-selector {
        position: static;
        margin-top: 15px;
    }
    
    .input-section,
    .results-section,
    .info-section {
        padding: 20px;
    }
    
    .subnet-input {
        grid-template-columns: 1fr;
    }
    
    .result-grid {
        grid-template-columns: 1fr;
    }
    
    .binary-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .binary-label {
        font-weight: 500;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #4C9AFF;
        --secondary-color: #97A0AF;
        --success-color: #57D9A3;
        --background-color: #091E42;
        --surface-color: #172B4D;
        --border-color: #344563;
        --text-primary: #FFFFFF;
        --text-secondary: #B3BAC5;
    }
    
    .range-bar {
        background-color: #253858;
    }
    
    .binary-value {
        background-color: #253858;
    }
}