body {
    font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

header {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    margin: 0.5rem 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

#dark-mode-toggle {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    margin-top: 1rem;
}

#dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

section {
    background-color: white;
    margin-bottom: 2rem;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode section {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

h2 {
    color: #2196F3;
    border-bottom: 3px solid #2196F3;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

body.dark-mode h2 {
    color: #64b5f6;
}

#input-method {
    margin-bottom: 1rem;
}

#input-method label {
    margin-right: 1rem;
    font-weight: 600;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}

form > div {
    display: flex;
    align-items: center;
    width: 100%;
    background-color: #f9f9f9;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    transition: border-color 0.3s, background-color 0.3s;
}

body.dark-mode form > div {
    background-color: #2a2a2a;
    border-color: #444;
}

form > div:focus-within {
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

form label {
    min-width: 180px;
    margin-right: 1rem;
    font-weight: 600;
    color: #555;
}

body.dark-mode form label {
    color: #ccc;
}

form input, form select {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
    background-color: white;
    color: #333;
    transition: border-color 0.3s, box-shadow 0.3s;
}

body.dark-mode form input, body.dark-mode form select {
    background-color: #333;
    color: #e0e0e0;
    border-color: #555;
}

form input:focus, form select:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

form button {
    align-self: flex-start;
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0,0,0,0.15);
}

#results {
    background: linear-gradient(135deg, #e8f0ff, #d4e4ff);
}

body.dark-mode #results {
    background: linear-gradient(135deg, #0d47a1, #1565c0);
}

#sum-value, #actual-value, #error-value {
    font-weight: bold;
    color: #2196F3;
    font-size: 1.2rem;
}

body.dark-mode #sum-value, body.dark-mode #actual-value, body.dark-mode #error-value {
    color: #64b5f6;
}

#graph {
    border: 2px solid #ddd;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
    background-color: white;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

body.dark-mode #graph {
    border-color: #444;
    background-color: #1e1e1e;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th, td {
    border: 1px solid #ddd;
    padding: 0.75rem;
    text-align: center;
}

body.dark-mode th, body.dark-mode td {
    border-color: #444;
    color: #e0e0e0;
}

th {
    background-color: #f2f2f2;
    font-weight: 600;
}

body.dark-mode th {
    background-color: #333;
}

input[type="number"], input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1rem;
    background-color: #fff;
    color: #333;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

body.dark-mode input[type="number"], body.dark-mode input[type="text"] {
    background-color: #333;
    color: #e0e0e0;
    border-color: #555;
}

input[type="number"]:focus, input[type="text"]:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.remove-row {
    background-color: #f44336;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.remove-row:hover {
    background-color: #d32f2f;
}

#add-row {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 1rem;
    transition: background-color 0.3s;
}

#add-row:hover {
    background-color: #45a049;
}

.help {
    background-color: #2196F3;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-block;
    text-align: center;
    line-height: 24px;
    font-size: 14px;
    cursor: help;
    margin-left: 0.5rem;
    transition: transform 0.2s;
}

.help:hover {
    transform: scale(1.1);
}

.input-display {
    margin-top: 0.5rem;
    font-size: 1.2rem;
    font-weight: bold;
    color: #2196F3;
    min-height: 1.5rem;
}

body.dark-mode .input-display {
    color: #64b5f6;
}

details {
    margin-bottom: 1.5rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 1rem;
}

body.dark-mode details {
    border-color: #444;
}

details summary {
    cursor: pointer;
    font-weight: bold;
    color: #2196F3;
}

body.dark-mode details summary {
    color: #64b5f6;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 1rem;
    }
    
    section {
        padding: 1rem;
    }
    
    form > div {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    form label {
        min-width: auto;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }
    
    #graph {
        width: 100%;
        height: auto;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.5rem;
    }
    
    input[type="number"], input[type="text"] {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
}
