.a11y-widget {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
    display: none;
}

.a11y-widget.visible {
    display: block;
}

.a11y-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 0.5px solid rgba(255,255,255,0.25);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.06) 100%),
        linear-gradient(180deg, rgba(0,122,255,0.12) 0%, rgba(0,122,255,0.04) 100%);
    backdrop-filter: blur(40px) saturate(180%) brightness(1.08);
    -webkit-backdrop-filter: blur(40px) saturate(180%) brightness(1.08);
    color: #007aff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        inset 0 1px 0 0 rgba(255,255,255,0.35),
        inset 0 -0.5px 0 0 rgba(0,0,0,0.08),
        0 4px 20px -4px rgba(0,0,0,0.15),
        0 2px 8px -2px rgba(0,122,255,0.10);
    transition:
        transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.a11y-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,0.18) 0%, transparent 100%);
    border-radius: 50% 50% 0 0;
    pointer-events: none;
}

.a11y-toggle:hover {
    transform: scale(1.08);
    box-shadow:
        inset 0 1px 0 0 rgba(255,255,255,0.45),
        inset 0 -0.5px 0 0 rgba(0,0,0,0.06),
        0 6px 24px -4px rgba(0,0,0,0.18),
        0 2px 10px -2px rgba(0,122,255,0.15);
}

.a11y-toggle:active {
    transform: scale(0.94);
    transition-duration: 0.08s;
}

.a11y-toggle[aria-expanded="true"] {
    background:
        linear-gradient(180deg, rgba(0,122,255,0.25) 0%, rgba(0,122,255,0.10) 100%);
    color: #ffffff;
}

.a11y-panel {
    position: absolute;
    bottom: 58px;
    left: 0;
    width: 260px;
    border-radius: 20px;
    background:
        linear-gradient(180deg, rgba(248,250,252,0.88) 0%, rgba(242,244,248,0.84) 100%);
    backdrop-filter: blur(60px) saturate(200%) brightness(1.10) contrast(1.02);
    -webkit-backdrop-filter: blur(60px) saturate(200%) brightness(1.10) contrast(1.02);
    border: 0.5px solid rgba(255,255,255,0.50);
    box-shadow:
        inset 0 1px 0 0 rgba(255,255,255,0.70),
        inset 0 -1px 0 0 rgba(0,0,0,0.03),
        0 12px 48px -8px rgba(0,0,0,0.18),
        0 4px 16px -4px rgba(0,0,0,0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.96);
    transition:
        opacity 0.25s ease,
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        visibility 0.25s ease;
    overflow: hidden;
}

.a11y-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 8%;
    right: 8%;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        rgba(255,255,255,0.80),
        transparent);
    pointer-events: none;
    z-index: 1;
}

.a11y-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.a11y-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 0.5px solid rgba(0,0,0,0.06);
}

.a11y-panel-title {
    font-size: 15px;
    font-weight: 700;
    color: #1c1c1e;
    letter-spacing: -0.2px;
}

.a11y-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.06);
    color: #8e8e93;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.a11y-close:hover {
    background: rgba(0,0,0,0.12);
}

.a11y-options {
    padding: 8px 12px 12px;
}

.a11y-option {
    padding: 6px 0;
}

.a11y-option-label {
    font-size: 14px;
    font-weight: 500;
    color: #1c1c1e;
}

.a11y-size-controls {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.a11y-size-btn {
    flex: 1;
    padding: 8px 0;
    border-radius: 10px;
    border: 0.5px solid rgba(0,0,0,0.08);
    background:
        linear-gradient(180deg, rgba(255,255,255,0.70) 0%, rgba(255,255,255,0.40) 100%);
    box-shadow:
        inset 0 1px 0 0 rgba(255,255,255,0.80),
        0 1px 4px -1px rgba(0,0,0,0.06);
    font-size: 14px;
    font-weight: 600;
    color: #007aff;
    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-height: 40px;
}

.a11y-size-btn:hover {
    background:
        linear-gradient(180deg, rgba(0,122,255,0.12) 0%, rgba(0,122,255,0.04) 100%);
}

.a11y-size-btn:active {
    transform: scale(0.95);
    transition-duration: 0.06s;
}

.a11y-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 4px 0;
}

.a11y-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.a11y-switch {
    width: 44px;
    height: 26px;
    border-radius: 13px;
    background: rgba(0,0,0,0.10);
    border: 0.5px solid rgba(0,0,0,0.06);
    position: relative;
    transition: background 0.25s ease;
    flex-shrink: 0;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

.a11y-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow:
        0 2px 6px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.90);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.a11y-checkbox:checked + .a11y-switch {
    background: #007aff;
    border-color: rgba(0,100,220,0.30);
}

.a11y-checkbox:checked + .a11y-switch::after {
    transform: translateX(18px);
}

.a11y-checkbox:focus-visible + .a11y-switch {
    outline: 2px solid rgba(0,122,255,0.60);
    outline-offset: 2px;
}

.a11y-reset-all {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border-radius: 12px;
    border: 0.5px solid rgba(255,59,48,0.15);
    background:
        linear-gradient(180deg, rgba(255,59,48,0.08) 0%, rgba(255,59,48,0.02) 100%);
    box-shadow:
        inset 0 1px 0 0 rgba(255,255,255,0.50),
        0 1px 4px -1px rgba(0,0,0,0.04);
    font-size: 13px;
    font-weight: 600;
    color: #ff3b30;
    cursor: pointer;
    transition:
        background 0.2s ease,
        transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.a11y-reset-all:hover {
    background:
        linear-gradient(180deg, rgba(255,59,48,0.15) 0%, rgba(255,59,48,0.05) 100%);
}

.a11y-reset-all:active {
    transform: scale(0.97);
    transition-duration: 0.06s;
}

@media (max-width: 768px) {
    .a11y-widget {
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        left: 14px;
    }
}

@media (max-width: 575px) {
    .a11y-widget {
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        left: 14px;
    }

    .a11y-toggle {
        width: 44px;
        height: 44px;
    }

    .a11y-toggle svg {
        width: 20px;
        height: 20px;
    }

    .a11y-panel {
        width: calc(100vw - 28px);
        max-width: 280px;
        bottom: 54px;
    }
}

@media (max-width: 420px) {
    .a11y-widget {
        bottom: calc(66px + env(safe-area-inset-bottom, 0px));
        left: 12px;
    }

    .a11y-toggle {
        width: 40px;
        height: 40px;
    }

    .a11y-panel {
        width: calc(100vw - 24px);
        bottom: 50px;
        left: -2px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .a11y-toggle {
        min-width: 48px;
        min-height: 48px;
    }

    .a11y-size-btn {
        min-height: 44px;
    }

    .a11y-switch-row {
        min-height: 44px;
    }

    .a11y-toggle:hover {
        transform: none;
    }
}

html.a11y-high-contrast {
    filter: contrast(1.35);
}

html.a11y-high-contrast body {
    background: #000000 !important;
    color: #ffffff !important;
}

html.a11y-high-contrast a {
    color: #5ac8fa !important;
}

html.a11y-high-contrast .a11y-panel {
    background: rgba(30,30,30,0.95) !important;
    border-color: rgba(255,255,255,0.40) !important;
}

html.a11y-high-contrast .a11y-panel-title,
html.a11y-high-contrast .a11y-option-label {
    color: #ffffff !important;
}

html.a11y-high-contrast .a11y-size-btn {
    background: rgba(255,255,255,0.12) !important;
    border-color: rgba(255,255,255,0.30) !important;
    color: #5ac8fa !important;
}

html.a11y-high-contrast .a11y-close {
    background: rgba(255,255,255,0.15) !important;
    color: #ffffff !important;
}

html.a11y-reduce-motion,
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
}

html.a11y-readable-font body,
html.a11y-readable-font input,
html.a11y-readable-font select,
html.a11y-readable-font textarea,
html.a11y-readable-font button,
html.a11y-readable-font table,
html.a11y-readable-font th,
html.a11y-readable-font td {
    font-family: 'Verdana', 'Tahoma', Geneva, sans-serif !important;
    letter-spacing: 0.04em !important;
    word-spacing: 0.12em !important;
}

html.a11y-highlight-links a {
    outline: 2px solid #007aff !important;
    outline-offset: 2px !important;
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
}

html.a11y-highlight-links a:hover {
    background: rgba(0,122,255,0.12) !important;
}

@media (prefers-reduced-motion: reduce) {
    .a11y-panel,
    .a11y-toggle,
    .a11y-size-btn,
    .a11y-switch,
    .a11y-switch::after,
    .a11y-reset-all {
        transition: none !important;
    }
}
