/* CSS-Reset nach W3C Best Practices */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Farbpalette - Professionell und angenehm für die Augen */
    --primary-bg: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    --display-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --calculator-bg: #ffffff;
    --shadow-dark: rgba(0, 0, 0, 0.25);
    --shadow-light: rgba(0, 0, 0, 0.1);
    
    /* Button-Farben */
    --btn-number: #f8f9fa;
    --btn-number-hover: #e9ecef;
    --btn-number-text: #212529;
    
    --btn-operator: #4a90e2;
    --btn-operator-hover: #357abd;
    --btn-operator-text: #ffffff;
    
    --btn-function: #6c757d;
    --btn-function-hover: #5a6268;
    --btn-function-text: #ffffff;
    
    --btn-scientific: #e8eaf6;
    --btn-scientific-hover: #c5cae9;
    --btn-scientific-text: #3f51b5;
    
    --btn-equals: #28a745;
    --btn-equals-hover: #218838;
    --btn-equals-text: #ffffff;
    
    --mode-toggle-bg: #e9ecef;
    --mode-toggle-active: #4a90e2;
    
    /* Display */
    --display-text: #e0e6ed;
    --display-text-secondary: rgba(224, 230, 237, 0.7);
    
    /* Transitions */
    --transition-speed: 0.2s;
    
    /* Border Radius */
    --border-radius-main: 24px;
    --border-radius-btn: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--primary-bg);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--btn-number-text);
}

.container {
    width: 100%;
    max-width: 650px;
}

.calculator {
    background: var(--calculator-bg);
    border-radius: var(--border-radius-main);
    box-shadow: 0 24px 48px var(--shadow-dark), 0 12px 24px var(--shadow-light);
    overflow: hidden;
}

/* Display */
.display {
    background: var(--display-bg);
    padding: 32px 24px;
    text-align: right;
    color: var(--display-text);
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-bottom: 2px solid rgba(74, 144, 226, 0.2);
}

.previous-operand {
    font-size: 18px;
    color: var(--display-text-secondary);
    min-height: 28px;
    word-wrap: break-word;
    word-break: break-all;
    font-weight: 400;
}

.current-operand {
    font-size: 42px;
    font-weight: 300;
    word-wrap: break-word;
    word-break: break-all;
    margin-top: 8px;
    letter-spacing: 1px;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 0;
    padding: 16px;
    background: var(--mode-toggle-bg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border-radius: var(--border-radius-btn);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mode-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.mode-btn.active {
    background: var(--mode-toggle-active);
    color: white;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.mode-btn:focus {
    outline: 2px solid var(--mode-toggle-active);
    outline-offset: 2px;
}

/* Buttons Container */
.buttons-container {
    padding: 16px;
    background: #f5f6fa;
}

/* Scientific Panel */
.scientific-panel {
    display: none;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 16px;
    padding: 16px;
    background: white;
    border-radius: var(--border-radius-btn);
    box-shadow: 0 2px 8px var(--shadow-light);
}

.scientific-panel.active {
    display: grid;
}

/* Main Buttons */
.main-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

/* Button Styles */
.btn {
    border: none;
    padding: 20px;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    border-radius: var(--border-radius-btn);
    box-shadow: 0 2px 4px var(--shadow-light);
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-light);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px var(--shadow-light);
}

.btn:focus {
    outline: 2px solid var(--btn-operator);
    outline-offset: 2px;
}

.btn sup {
    font-size: 0.7em;
    vertical-align: super;
}

/* Button Types */
.btn-number {
    background: var(--btn-number);
    color: var(--btn-number-text);
    font-size: 20px;
}

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

.btn-operator {
    background: var(--btn-operator);
    color: var(--btn-operator-text);
    font-size: 22px;
    font-weight: 600;
}

.btn-operator:hover {
    background: var(--btn-operator-hover);
}

.btn-function {
    background: var(--btn-function);
    color: var(--btn-function-text);
    font-weight: 600;
}

.btn-function:hover {
    background: var(--btn-function-hover);
}

.btn-scientific {
    background: var(--btn-scientific);
    color: var(--btn-scientific-text);
    font-size: 15px;
    padding: 16px 12px;
    font-weight: 600;
}

.btn-scientific:hover {
    background: var(--btn-scientific-hover);
}

.btn-equals {
    background: var(--btn-equals);
    color: var(--btn-equals-text);
    font-size: 24px;
    font-weight: 600;
}

.btn-equals:hover {
    background: var(--btn-equals-hover);
}

/* Ripple Effect */
.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        max-width: 100%;
    }
    
    .scientific-panel {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }
    
    .btn-scientific {
        padding: 14px 8px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .calculator {
        border-radius: 16px;
    }
    
    .display {
        padding: 24px 20px;
        min-height: 110px;
    }
    
    .current-operand {
        font-size: 32px;
    }
    
    .previous-operand {
        font-size: 16px;
    }
    
    .main-buttons {
        gap: 6px;
    }
    
    .btn {
        padding: 18px;
        font-size: 16px;
    }
    
    .btn-number {
        font-size: 18px;
    }
    
    .btn-operator {
        font-size: 20px;
    }
    
    .btn-equals {
        font-size: 22px;
    }
    
    .scientific-panel {
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
        padding: 12px;
    }
    
    .btn-scientific {
        padding: 12px 6px;
        font-size: 11px;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --calculator-bg: #1e1e1e;
        --btn-number: #2d2d2d;
        --btn-number-hover: #3d3d3d;
        --btn-number-text: #e0e0e0;
        --mode-toggle-bg: #2d2d2d;
    }
}
