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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #10b981;
    --background: #f9fafb;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 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);
}

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

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

header {
    text-align: center;
    padding: 40px 0 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 20px;
    margin-bottom: 40px;
    box-shadow: var(--shadow-lg);
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    margin-bottom: 20px;
}

.lang-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.lang-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

main {
    display: grid;
    gap: 30px;
}

.calculator-section {
    background: var(--surface);
    padding: 30px;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.fraction-input {
    display: flex;
    align-items: center;
}

.fraction {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.fraction input {
    width: 100px;
    padding: 12px;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 18px;
    transition: border-color 0.3s ease;
}

.fraction input:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

.operation-select {
    padding: 12px 20px;
    font-size: 24px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.operation-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.calculate-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    padding: 14px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.calculate-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.result-section {
    display: none;
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid var(--border);
}

.result-box {
    text-align: center;
    margin-bottom: 20px;
}

.result-box h3 {
    margin-bottom: 15px;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.result-display {
    display: inline-block;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.fraction-result {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    font-size: 28px;
    font-weight: bold;
}

.fraction-result .fraction-line {
    background: white;
    margin: 10px 0;
}

.additional-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.result-item {
    padding: 15px;
    background: var(--background);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

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

.tools-section {
    background: var(--surface);
    padding: 25px;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

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

.tool-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.tool-btn {
    padding: 12px 20px;
    background: var(--surface);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.converter-section {
    display: none;
    background: var(--surface);
    padding: 25px;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

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

.converter-input {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.converter-input input {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
}

.converter-input input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.convert-btn {
    padding: 12px 30px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.convert-btn:hover {
    background: #059669;
}

.converter-result {
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
}

.conversion-result div {
    padding: 8px 0;
    font-size: 16px;
}

.history-section {
    background: var(--surface);
    padding: 25px;
    border-radius: 16px;
    box-shadow: var(--shadow);
}

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

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    padding: 12px 15px;
    background: var(--background);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 15px;
    color: var(--text-secondary);
    border-left: 3px solid var(--primary-color);
}

footer {
    margin-top: 40px;
    padding: 30px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.instructions {
    margin-bottom: 20px;
}

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

.instructions ol {
    padding-left: 20px;
    color: var(--text-secondary);
}

.instructions li {
    margin-bottom: 8px;
}

.copyright {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .fraction input {
        width: 80px;
    }
    
    .tool-buttons {
        grid-template-columns: 1fr;
    }
    
    .converter-input {
        flex-direction: column;
    }
    
    .additional-results {
        grid-template-columns: 1fr;
    }
}