:root {
    --background-color: #f0f2f5;
    --text-color: #333;
    --container-bg: #fff;
    --primary-color: #1877f2;
    --secondary-color: #e4e6eb;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    transition: background-color 0.3s, color 0.3s;
}

body.dark-mode {
    --background-color: #18191a;
    --text-color: #e4e6eb;
    --container-bg: #242526;
    --primary-color: #2d88ff;
    --secondary-color: #3a3b3c;
}

.container {
    text-align: center;
    background-color: var(--container-bg);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    position: relative;
}

.theme-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
}

#theme-toggle {
    display: none;
}

#theme-toggle + label {
    display: inline-block;
    width: 50px;
    height: 25px;
    border-radius: 25px;
    background-color: var(--secondary-color);
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s;
}

#theme-toggle + label::before {
    content: '';
    display: block;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    background-color: #fff;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

#theme-toggle:checked + label {
    background-color: var(--primary-color);
}

#theme-toggle:checked + label::before {
    transform: translateX(25px);
}


.calculator {
    width: 100%;
    max-width: 320px;
}

.display {
    background-color: var(--secondary-color);
    padding: 25px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 36px;
    font-weight: bold;
    text-align: right;
    color: var(--text-color);
    min-height: 60px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.btn {
    background-color: var(--secondary-color);
    color: var(--text-color);
    border: none;
    padding: 20px;
    font-size: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
}

.btn:hover {
    filter: brightness(0.9);
    transform: scale(0.98);
}

.btn:active {
    transform: scale(0.95);
}

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

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

.btn-clear {
    background-color: #ff6b6b;
    color: #fff;
}

.btn-delete {
    background-color: #ffa500;
    color: #fff;
}

.btn-equals {
    background-color: #28a745;
    color: #fff;
    grid-column: span 2;
}

.btn-zero {
    grid-column: span 2;
}
