* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #fff;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 100%;
    max-width: 900px;
}

header img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #00adb5;
    padding: 5px;
}

main {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

#calculator {
    flex: 3;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#display {
    width: 100%;
    height: 100px;
    margin-bottom: 20px;
    text-align: right;
    font-size: 2.5rem;
    padding: 0 20px;
    border: none;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    outline: none;
    overflow: hidden;
    text-overflow: ellipsis;
}

#buttons {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
}

#buttons button {
    height: 60px;
    border: none;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

#buttons button:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#buttons button:active {
    transform: translateY(0);
}

/* Number buttons */
#buttons button:not(.operator):not(.equal-button) {
    background: linear-gradient(145deg, #2d4059, #222831);
}

#buttons button:not(.operator):not(.equal-button):hover {
    background: linear-gradient(145deg, #374f6e, #2a2f38);
}

/* Operator buttons */
#buttons button.operator {
    background: linear-gradient(145deg, #00adb5, #0097a7);
    font-size: 1.1rem;
}

#buttons button.operator:hover {
    background: linear-gradient(145deg, #00c4cc, #00a8b5);
}

/* Equal button */
#buttons button.equal-button {
    background: linear-gradient(145deg, #ff5722, #e64a19);
    grid-column: span 2;
}

#buttons button.equal-button:hover {
    background: linear-gradient(145deg, #ff7043, #f4511e);
}

/* History section */
#history {
    flex: 2;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-height: 550px;
    display: flex;
    flex-direction: column;
}

#history h6 {
    text-align: center;
    margin-bottom: 15px;
    color: #00adb5;
    font-size: 1.3rem;
    border-bottom: 2px solid #00adb5;
    padding-bottom: 8px;
}

.history {
    flex: 1;
    overflow-y: auto;
    padding-right: 5px;
}

.history-item {
    background: rgba(255, 255, 255, 0.08);
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 10px;
    border-left: 3px solid #00adb5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.history-left {
    flex: 1;
    margin-right: 10px;
}

.history-right {
    display: flex;
    gap: 5px;
}

.history-item .expression,
.history-item .result {
    display: block;
    cursor: text;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background 0.2s;
    min-height: 24px;
}

.history-item .expression:hover,
.history-item .result:hover {
    background: rgba(255, 255, 255, 0.1);
}

.history-item .expression {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-item .result {
    font-size: 1rem;
    color: #fff;
    font-weight: bold;
}

.use-btn, .delete-btn {
    background: rgba(0, 173, 181, 0.2);
    border: 1px solid #00adb5;
    color: #00adb5;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.use-btn:hover {
    background: #00adb5;
    color: white;
}

.delete-btn {
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid #f44336;
    color: #f44336;
}

.delete-btn:hover {
    background: #f44336;
    color: white;
}

footer {
    margin-top: 30px;
    text-align: center;
    padding: 20px;
    color: #aaa;
    font-size: 0.9rem;
    width: 100%;
    max-width: 900px;
}

footer p {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #00adb5;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0097a7;
}

/* Responsive design */
@media (max-width: 950px) {
    main {
        flex-direction: column;
    }
    
    #buttons {
        grid-template-columns: repeat(7, 1fr);
    }
}

@media (max-width: 650px) {
    #buttons {
        grid-template-columns: repeat(7, 1fr);
    }
    
    #buttons button {
        height: 55px;
        font-size: 1.1rem;
    }
    
    #display {
        height: 80px;
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    #buttons {
        grid-template-columns: repeat(7, 1fr);
    }
    
    #buttons button {
        height: 50px;
        font-size: 1rem;
    }
    
    #display {
        height: 70px;
        font-size: 1.8rem;
    }
    
    .history-item {
        flex-direction: column;
        align-items: stretch;
    }
    
    .history-right {
        margin-top: 10px;
        justify-content: flex-end;
    }
}