:root {
    --bg-color: #1a1d22;
    --display-bg-color: #22262e;
    --keypad-bg-color: #292d36;
    --key-bg-color: #363a43;
    --key-hover-bg-color: #41454e;
    --operator-key-bg-color: #3f7de8;
    --operator-key-hover-bg-color: #5891f0;
    --equals-key-bg-color: #28a745;
    --equals-key-hover-bg-color: #32c754;
    --text-color: #e0e0e0;
    --result-color: #a0a0a0;
    --font-family: 'Roboto', sans-serif;
}

html, body {
    min-height: 100%;
    margin: 0;
    background-color: var(--bg-color);
    font-family: var(--font-family);
    color: var(--text-color);
    padding: 20px 0;
}

.calculator-container {
    width: 100%;
    max-width: 360px;
    background-color: var(--keypad-bg-color);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

.main-content-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.sidebar-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.text-description, .description-container, .history-container {
    max-width: 700px;
    width: 90%;
    margin: 30px auto;
    padding: 20px;
    background-color: var(--keypad-bg-color);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

@media (min-width: 1000px) {
    .main-content-wrapper {
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 30px;
    }
    .calculator-container {
        margin: 0; /* Reset margin for flex layout */
    }
    .sidebar-wrapper {
        width: 400px;
        align-items: stretch;
    }
    .description-container, .history-container {
        width: auto; /* Let the flex container control the width */
        margin: 0; /* Reset margin */
    }
    .description-container {
        margin-bottom: 30px; /* Keep space between description and history */
    }
}

.text-description h2, .description-container h2, .history-container h2 {
    margin-top: 0;
    border-bottom: 1px solid var(--key-bg-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-weight: 400;
}

.description-container p {
    line-height: 1.6;
    color: var(--result-color);
}

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

#history-list .history-item {
    background-color: var(--key-bg-color);
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 1.1rem;
    word-wrap: break-word;
}

#history-list .history-item:hover {
    background-color: var(--key-hover-bg-color);
}


.calculator-header {
    text-align: center;
    margin-bottom: 20px;
}

.calculator-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 400;
}

.calculator-header p {
    margin: 5px 0 0;
    font-size: 0.8rem;
    color: var(--result-color);
}
.calculator-header p a {
    color: var(--operator-key-bg-color);
    text-decoration: none;
}
.calculator-header p a:hover {
    text-decoration: underline;
}

.display {
    background-color: var(--display-bg-color);
    padding: 20px;
    border-radius: 15px;
    text-align: right;
    margin-bottom: 20px;
    box-shadow: inset 0 5px 15px rgba(0, 0, 0, 0.2);
}

.display #expression {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 2.5rem;
    font-weight: 300;
    text-align: right;
    box-sizing: border-box;
    outline: none;
}

.display #expression::placeholder {
    color: #666;
}

.display #result {
    font-size: 1.2rem;
    color: var(--result-color);
    min-height: 20px;
    margin-top: 10px;
    font-weight: 300;
}

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

.actions {
    margin-top: 15px;
}

#copyUrlButton {
    width: 100%;
    background-color: var(--key-bg-color);
    font-size: 1.2rem;
}

.key {
    border: none;
    border-radius: 12px;
    padding: 20px;
    font-size: 1.5rem;
    font-weight: 400;
    cursor: pointer;
    background-color: var(--key-bg-color);
    color: var(--text-color);
    transition: background-color 0.2s, transform 0.1s;
    user-select: none;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.key:hover {
    background-color: var(--key-hover-bg-color);
}

.key:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.key-operator {
    background-color: var(--operator-key-bg-color);
    color: white;
}
.key-operator:hover {
    background-color: var(--operator-key-hover-bg-color);
}

.key-equals {
    background-color: var(--equals-key-bg-color);
    grid-column: span 2;
    color: white;
}
.key-equals:hover {
    background-color: var(--equals-key-hover-bg-color);
}

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

.calculator-footer {
    text-align: center;
    margin-top: 20px;
}
.calculator-footer p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--result-color);
}
