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

:root {
    --primary-color: #0052CC;
    --secondary-color: #5E6C84;
    --success-color: #00875A;
    --warning-color: #FF991F;
    --danger-color: #DE350B;
    --background: #FAFBFC;
    --surface: #FFFFFF;
    --text-primary: #172B4D;
    --text-secondary: #6B778C;
    --border: #DFE1E6;
    --shadow-sm: 0 1px 2px rgba(9, 30, 66, 0.08);
    --shadow-md: 0 4px 8px rgba(9, 30, 66, 0.12);
    --shadow-lg: 0 8px 16px rgba(9, 30, 66, 0.15);
    --radius-sm: 3px;
    --radius-md: 6px;
    --radius-lg: 12px;
}

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

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

header {
    background: var(--surface);
    padding: 40px 0;
    text-align: center;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.language-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.lang-btn {
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    font-weight: 500;
}

.lang-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.lang-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

main {
    padding: 40px 0;
}

.calculator-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.calculator-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.proportion-formula {
    margin-bottom: 24px;
}

.formula-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.fraction {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.fraction input {
    width: 100px;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1.125rem;
    text-align: center;
    transition: all 0.2s;
    background: var(--background);
}

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

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

.fraction-bar {
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    margin: 8px 0;
}

.equals {
    font-size: 2rem;
    color: var(--text-secondary);
    font-weight: 300;
}

.calculate-btn, .clear-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 12px;
}

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

.calculate-btn:hover {
    background: #0747A6;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.clear-btn {
    background: var(--background);
    color: var(--text-secondary);
    border: 2px solid var(--border);
}

.clear-btn:hover {
    border-color: var(--danger-color);
    color: var(--danger-color);
    transform: translateY(-1px);
}

.result-display {
    margin-top: 24px;
}

.result-box {
    padding: 20px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(0, 135, 90, 0.05) 0%, rgba(0, 135, 90, 0.1) 100%);
    border-left: 4px solid var(--success-color);
}

.result-box h3 {
    font-size: 1.125rem;
    margin-bottom: 12px;
    color: var(--success-color);
}

.solution {
    font-size: 1rem;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
    background: var(--background);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
}

.cross-multiply {
    color: var(--text-secondary);
    font-style: italic;
}

.error {
    padding: 16px;
    background: linear-gradient(135deg, rgba(222, 53, 11, 0.05) 0%, rgba(222, 53, 11, 0.1) 100%);
    border-left: 4px solid var(--danger-color);
    border-radius: var(--radius-md);
    color: var(--danger-color);
}

.visual-container {
    margin-top: 32px;
    padding: 24px;
    background: var(--background);
    border-radius: var(--radius-md);
}

.visual-container h3 {
    font-size: 1.125rem;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.proportion-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 32px;
    min-height: 250px;
}

.bar-group {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.bar {
    width: 60px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 8px;
    position: relative;
    transition: all 0.3s ease;
}

.bar:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.bar-label {
    position: absolute;
    bottom: -30px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.bar-divider {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin: 0 8px;
    align-self: center;
}

.equals-sign {
    font-size: 2rem;
    color: var(--text-secondary);
    align-self: center;
}

.multi-calc-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.base-ratio label,
.scale-values label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.ratio-input {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ratio-input input {
    width: 100px;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    text-align: center;
    background: var(--background);
}

.ratio-input span {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.scale-values input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    background: var(--background);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.result-card {
    padding: 16px;
    background: var(--background);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.result-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.ratio-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.125rem;
}

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

.ratio-display .value.highlight {
    color: var(--primary-color);
}

.ratio-display .separator {
    color: var(--text-secondary);
}

.info-section,
.examples-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
}

.info-section h2,
.examples-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.usage-list {
    list-style: none;
    padding-left: 0;
}

.usage-list li {
    padding: 12px 0;
    padding-left: 32px;
    position: relative;
    color: var(--text-secondary);
}

.usage-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
    font-size: 1.2rem;
}

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

.example-card {
    padding: 24px;
    background: var(--background);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.example-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.example-card h3 {
    font-size: 1.125rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.example-card p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.example-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.example-btn:hover {
    background: #0747A6;
    transform: translateY(-1px);
}

footer {
    text-align: center;
    padding: 32px 0;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    margin-top: 48px;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .formula-display {
        flex-direction: column;
    }
    
    .proportion-bars {
        flex-direction: column;
        align-items: center;
        gap: 24px;
    }
    
    .bar-group {
        flex-direction: row;
    }
    
    .equals-sign {
        transform: rotate(90deg);
        margin: 16px 0;
    }
    
    .calculator-section {
        padding: 20px;
    }
    
    .example-cards {
        grid-template-columns: 1fr;
    }
}