.calculator-container {
    width: 90%;
    max-width: 700px;
    margin: 0 auto 20px auto;
    display: flex;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    height: 500px;
    max-height: 500px;
    position: relative;
}

.calculator {
    width: 60%;
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.history-panel {
    width: 40%;
    background: #f8f9fa;
    padding: 15px;
    border-left: 1px solid #eaeaea;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    height: 100%;
}

.calc-display {
    background: #f8f9fa;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 15px;
    text-align: right;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.calc-input {
    font-size: 18px;
    color: #666;
    min-height: 18px;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calc-result {
    font-size: 28px;
    font-weight: bold;
    color: #333;
    min-height: 35px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    flex: 1;
    min-height: 0;
}

.calc-btn {
    padding: 12px 8px;
    border: 1px solid #ccc;
    background: white;
    font-size: 18px;
    cursor: pointer;
    border-radius: 3px;
    font-weight: bold;
    transition: all 0.2s ease;
    min-height: 50px;
}

.calc-btn:hover {
    background: #f5f5f5;
}

.calc-btn:active {
    transform: scale(0.98);
}

.calc-number {
    background: white;
    color: #333;
}

.calc-operator {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
}

.calc-equals {
    background: #46b450;
    color: white;
    border-color: #46b450;
}

.calc-clear {
    background: #dc3232;
    color: white;
    border-color: #dc3232;
}

.calc-function {
    background: #72777c;
    color: white;
    border-color: #72777c;
}

.calc-memory {
    background: #ffb900;
    color: #333;
    border-color: #ffb900;
}

.history-panel h3 {
    margin: 0 0 15px 0;
    color: #333;
    padding-bottom: 10px;
    border-bottom: 2px solid #0073aa;
    font-size: 16px;
    flex-shrink: 0;
}

.history-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-right: 5px;
    max-height: calc(100% - 80px);
}

.history-item {
    padding: 12px;
    margin-bottom: 10px;
    background: white;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 3px solid #0073aa;
    flex-shrink: 0;
    position: relative;
}

.history-expression {
    font-size: 12px;
    color: #666;
    margin-bottom: 3px;
    word-break: break-all;
}

.history-result {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    word-break: break-all;
    margin-bottom: 8px;
}

.history-comment {
    font-size: 11px;
    color: #555;
    font-style: italic;
    background: #f0f8ff;
    padding: 6px 8px;
    border-radius: 3px;
    border-left: 2px solid #0073aa;
    margin-top: 5px;
}

.history-actions-item {
    display: flex;
    gap: 5px;
    margin-top: 8px;
}

.comment-btn {
    background: #0073aa;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s ease;
}

.comment-btn:hover {
    background: #005a87;
}

.history-actions {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    flex-shrink: 0;
}

.history-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.download-btn {
    background: #46b450;
    color: white;
}

.download-btn:hover {
    background: #3a9542;
}

.clear-history-btn {
    background: #72777c;
    color: white;
}

.clear-history-btn:hover {
    background: #595c60;
}

/* Comment Modal */
.comment-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.comment-modal.active {
    display: flex;
}

.comment-modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
}

.comment-modal-header {
    background: #0073aa;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.comment-modal-header h4 {
    margin: 0;
    font-size: 16px;
}

.comment-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comment-modal-body {
    padding: 20px;
}

.calculation-preview {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 1px solid #eaeaea;
}

.calculation-preview .history-expression {
    font-size: 12px;
    color: #666;
    margin-bottom: 2px;
}

.calculation-preview .history-result {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    margin-bottom: 0;
}

.comment-input {
    width: 100%;
    height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
}

.comment-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.1);
}

.comment-modal-actions {
    display: flex;
    gap: 10px;
    padding: 0 20px 20px;
}

.comment-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: background 0.2s ease;
}

.comment-cancel {
    background: #72777c;
    color: white;
}

.comment-cancel:hover {
    background: #595c60;
}

.comment-save {
    background: #46b450;
    color: white;
}

.comment-save:hover {
    background: #3a9542;
}

/* Download Modal */
.download-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.download-modal.active {
    display: flex;
}

.download-modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    overflow: hidden;
}

.download-modal-header {
    background: #46b450;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.download-modal-header h4 {
    margin: 0;
    font-size: 16px;
}

.download-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.download-modal-body {
    padding: 20px;
}

.download-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.download-option-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 15px;
    border: 2px solid #eaeaea;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
}

.download-option-btn:hover {
    border-color: #0073aa;
    background: #f8f9fa;
}

.download-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

.download-text {
    font-weight: bold;
    color: #333;
    margin-bottom: 2px;
}

.download-desc {
    font-size: 12px;
    color: #666;
}

/* Custom scrollbar for history */
.history-content::-webkit-scrollbar {
    width: 6px;
}

.history-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.history-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.history-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Mobile responsiveness */
@media (max-width: 500px) {
    .calculator-container {
        flex-direction: column;
        height: auto;
        max-height: none;
        padding: 15px;
    }
    
    .calculator, .history-panel {
        width: 100%;
        height: auto;
        min-height: 400px;
    }
    
    .history-panel {
        border-left: none;
        border-top: 1px solid #eaeaea;
        min-height: 300px;
    }
    
    .calc-buttons {
        min-height: 400px;
    }
    
    .history-content {
        max-height: 200px;
        min-height: 200px;
    }
    
    .comment-modal-content,
    .download-modal-content {
        width: 95%;
        margin: 20px;
    }
}