.accessibility-widget {
    position: fixed;
    left: 20px;
    bottom: 20px; /* Lowered from 80px */
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.accessibility-toggle {
    width: 60px; /* Slightly larger */
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff9800 0%, #f44336 100%); /* Striking Orange-Red Gradient */
    color: white;
    border: 3px solid white;
    box-shadow: 0 5px 25px rgba(255, 152, 0, 0.4), 0 0 15px rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
    0% { box-shadow: 0 5px 25px rgba(255, 152, 0, 0.4); }
    50% { box-shadow: 0 5px 35px rgba(255, 152, 0, 0.7), 0 0 20px rgba(255, 152, 0, 0.4); }
    100% { box-shadow: 0 5px 25px rgba(255, 152, 0, 0.4); }
}

.accessibility-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    background: linear-gradient(135deg, #f44336 0%, #ff9800 100%);
}

.accessibility-menu {
    position: absolute;
    bottom: 65px;
    left: 0;
    width: 350px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25);
    padding: 25px;
    display: none;
    flex-direction: column;
    gap: 15px;
    border: 2px solid #ff9800;
    animation: slideUp 0.3s ease-out;
    max-height: calc(100vh - 120px); /* Prevent cutting off at top */
    overflow-y: auto;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.accessibility-menu.active {
    display: flex;
}

.accessibility-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 12px;
    margin-bottom: 8px;
}

.accessibility-header h6 {
    margin: 0;
    font-weight: 800;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.accessibility-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.acc-btn {
    background: #fdfdfd;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px 5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #444;
    height: 100%;
}

.acc-btn i {
    font-size: 1.4rem;
    color: #ff9800; /* Striking Orange */
}

.acc-btn:hover {
    background: #fff5e6;
    border-color: #ff9800;
    transform: translateY(-2px);
}

.acc-btn.active {
    background: #ff9800; /* High Contrast Orange */
    color: white !important;
    border-color: #e68a00;
    box-shadow: 0 4px 10px rgba(255, 152, 0, 0.3);
}

.acc-btn.active i {
    color: white !important;
}

.acc-btn span {
    line-height: 1.2;
    display: block;
}

.acc-btn[data-acc="acc-tts"].active i {
    animation: ttsPulse 1.5s infinite;
}

@keyframes ttsPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Accessibility Features Implementations */
html.acc-grayscale {
    filter: grayscale(100%) !important;
}

html.acc-high-contrast {
    filter: contrast(150%) !important;
}

html.acc-high-contrast body {
    background-color: #000 !important;
    color: #fff !important;
}

html.acc-high-contrast * {
    border-color: #fff !important;
}

html.acc-negative {
    filter: invert(100%) hue-rotate(180deg) !important;
}

html.acc-underline-links a {
    text-decoration: underline !important;
    font-weight: bold !important;
}

html.acc-highlight-headers h1, 
html.acc-highlight-headers h2, 
html.acc-highlight-headers h3, 
html.acc-highlight-headers h4, 
html.acc-highlight-headers h5, 
html.acc-highlight-headers h6 {
    background-color: yellow !important;
    color: black !important;
    outline: 2px solid orange !important;
}

html.acc-readable-font {
    font-family: 'Arial', sans-serif !important;
}

html.acc-readable-font * {
    font-family: 'Arial', sans-serif !important;
}

html.acc-big-cursor {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 512 512'%3E%3Cpath fill='black' stroke='white' stroke-width='20' d='M100.28 24.19c-14.55 14.55-14.55 38.15 0 52.7l148.01 148c14.55 14.55 38.15 14.55 52.7 0 14.55-14.55 14.55-38.15 0-52.7l-148-148.01c-14.56-14.54-38.16-14.54-52.71.01z'/%3E%3C/svg%3E"), auto !important;
}

html.acc-stop-animations * {
    animation: none !important;
    transition: none !important;
}

html.acc-line-height, 
html.acc-line-height body,
html.acc-line-height p,
html.acc-line-height span,
html.acc-line-height div:not(.accessibility-widget *) {
    line-height: 2 !important;
}

html.acc-letter-spacing,
html.acc-letter-spacing body,
html.acc-letter-spacing * {
    letter-spacing: 0.12em !important;
}

/* Font Size Scales */
html.fs-lg body { font-size: 1.15rem !important; }
html.fs-xl body { font-size: 1.3rem !important; }
html.fs-xxl body { font-size: 1.5rem !important; }

@media (max-width: 768px) {
    .accessibility-widget {
        bottom: 80px; /* Above the bottom nav */
        left: 20px;
    }
    
    .accessibility-toggle {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

    .accessibility-menu {
        pointer-events: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 80vh; /* Don't cover entire screen */
        overflow-y: auto; /* Allow scrolling inside menu */
        border-radius: 20px 20px 0 0;
        padding-bottom: 80px; /* Leave space for bottom nav */
        -webkit-overflow-scrolling: touch;
    }

    .accessibility-widget.active {
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
    }

    .accessibility-widget.active .accessibility-toggle {
        display: none;
    }
}
