* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --teal: #1a8aa0;
    --teal-dark: #136b7a;
    --teal-light: #2aadc7;
    --offwhite: #f5f3f0;
    --lightgray: #e0dbd5;
    --brown: #5c2518;
    --brown-dark: #3e1810;
    --brown-light: #7a3020;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--teal) 0%, var(--brown) 100%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    overflow: hidden;
}

.container {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.calculator {
    background: rgba(245, 243, 240, 0.15);
    backdrop-filter: blur(14px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(245, 243, 240, 0.25);
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    color: var(--offwhite);
    font-size: 24px;
    margin-bottom: 15px;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.5px;
}

.trust-meter {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--lightgray);
    font-size: 14px;
}

.trust-bar {
    flex: 1;
    height: 8px;
    background: rgba(224, 219, 213, 0.25);
    border-radius: 10px;
    overflow: hidden;
}

.trust-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--teal-light), var(--teal));
    transition: width 0.5s ease, background 0.5s ease;
}

.trust-fill.low {
    background: linear-gradient(90deg, var(--brown-light), var(--brown));
}

.display-container {
    position: relative;
    margin-bottom: 20px;
}

.display {
    background: rgba(92, 37, 24, 0.35);
    color: var(--offwhite);
    padding: 22px 15px;
    border-radius: 15px;
    text-align: right;
    font-size: 36px;
    min-height: 75px;
    word-wrap: break-word;
    word-break: break-all;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    border: 1px solid rgba(224, 219, 213, 0.15);
}

.display.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.loading-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--teal-light);
    width: 0;
    border-radius: 0 0 15px 15px;
    transition: width 0.1s linear;
}

.mode-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    color: var(--lightgray);
    font-size: 14px;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(224, 219, 213, 0.25);
    transition: 0.4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--offwhite);
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--teal);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.btn {
    background: rgba(245, 243, 240, 0.12);
    border: 1px solid rgba(245, 243, 240, 0.2);
    color: var(--offwhite);
    font-size: 24px;
    padding: 20px 5px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    position: relative;
}

.btn:hover {
    background: rgba(245, 243, 240, 0.22);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.25);
}

.btn:active {
    transform: translateY(0);
}

.btn.operator {
    background: rgba(26, 138, 160, 0.35);
    border-color: rgba(26, 138, 160, 0.5);
    font-weight: 600;
}

.btn.operator:hover {
    background: rgba(26, 138, 160, 0.55);
}

.btn.equals {
    background: linear-gradient(135deg, var(--teal), var(--teal-dark));
    border-color: var(--teal);
    grid-row: span 2;
    font-size: 32px;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(26, 138, 160, 0.4);
}

.btn.equals:hover {
    background: linear-gradient(135deg, var(--teal-light), var(--teal));
    box-shadow: 0 6px 20px rgba(26, 138, 160, 0.6);
}

.btn.zero {
    grid-column: span 2;
}

.btn.moving {
    animation: wiggle 0.3s ease;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-5deg); }
    75% { transform: rotate(5deg); }
}

.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--brown);
    color: var(--offwhite);
    padding: 15px 30px;
    border-radius: 10px;
    font-size: 16px;
    transition: bottom 0.3s ease;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--brown-light);
}

.toast.show {
    bottom: 30px;
}

@media (max-width: 480px) {
    .calculator { padding: 12px; border-radius: 16px; }
    .header h1 { font-size: 15px; }
    .btn { font-size: 18px; border-radius: 10px; }
    .display { font-size: 22px; border-radius: 10px; }
    .toggle-switch { width: 40px; height: 20px; }
    .slider:before { height: 14px; width: 14px; }
    input:checked + .slider:before { transform: translateX(20px); }
}

@media (max-width: 360px) {
    .header h1 { font-size: 13px; }
    .trust-meter { font-size: 10px; gap: 6px; }
    .btn { font-size: 15px; padding: 8px 4px; border-radius: 8px; }
    .display { font-size: 18px; min-height: 40px; padding: 8px 10px; }
    .buttons { gap: 4px; }
    .mode-toggle { font-size: 11px; }
}

@media (max-height: 600px) and (orientation: landscape) {
    .calculator { padding: 8px 14px; }
    .header { margin-bottom: 5px; }
    .header h1 { font-size: 13px; margin-bottom: 4px; }
    .display { font-size: 18px; min-height: 34px; padding: 6px 10px; }
    .display-container { margin-bottom: 6px; }
    .mode-toggle { margin-bottom: 6px; font-size: 11px; }
    .toggle-switch { width: 36px; height: 18px; }
    .slider:before { height: 12px; width: 12px; }
    input:checked + .slider:before { transform: translateX(18px); }
    .btn { padding: 6px 4px; font-size: 14px; border-radius: 8px; }
    .buttons { gap: 4px; }
    .trust-bar { height: 6px; }
}
