/* ============================================
   ACCESSIBILITY FEATURES STYLES
   ============================================ */

/* OpenDyslexic Font Loading */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/fonts/OpenDyslexic-Regular.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/fonts/OpenDyslexic-Regular.woff') format('woff');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'OpenDyslexic';
    src: url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/fonts/OpenDyslexic-Bold.woff2') format('woff2'),
         url('https://cdn.jsdelivr.net/npm/open-dyslexic@1.0.3/fonts/OpenDyslexic-Bold.woff') format('woff');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* Accessibility Modal Specific Styles */
.accessibility-modal {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Enable momentum scrolling on iOS */
}

.accessibility-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1rem 0;
    border-bottom: 2px solid #e2e8f0;
    background: #f8fafc;
}

.accessibility-tabs .tab-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #64748b;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.accessibility-tabs .tab-btn:hover {
    color: #4f46e5;
    background: #f1f5f9;
}

.accessibility-tabs .tab-btn.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
    background: white;
}

.accessibility-tabs .tab-btn:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

.accessibility-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Enable momentum scrolling on iOS */
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section h4 {
    font-size: 1.1rem;
    color: #1e293b;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.settings-section .form-group {
    margin-bottom: 1.5rem;
}

.settings-section label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.label-text {
    font-weight: 600;
    color: #334155;
    font-size: 0.95rem;
}

.label-hint {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: normal;
}

.settings-select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.settings-select:hover {
    border-color: #94a3b8;
}

.settings-select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.font-preview {
    display: block;
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-top: 0.5rem;
    font-size: 1.1rem;
    color: #334155;
}

/* Accessibility Preview Box */
.accessibility-preview {
    display: block;
    padding: 1.5rem;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    margin-top: 0.5rem;
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Enable momentum scrolling on iOS */
    transition: all 0.3s ease;
}

.accessibility-preview p {
    margin-bottom: 1rem;
    line-height: 1.5;
}

.accessibility-preview p:last-child {
    margin-bottom: 0;
}

.settings-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: #e2e8f0;
    border-radius: 4px;
    outline: none;
    transition: background 0.2s;
}

.settings-slider:hover {
    background: #cbd5e1;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #4f46e5;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-slider::-webkit-slider-thumb:hover {
    background: #4338ca;
    transform: scale(1.1);
}

.settings-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #4f46e5;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-slider::-moz-range-thumb:hover {
    background: #4338ca;
    transform: scale(1.1);
}

.settings-slider:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.settings-slider:focus::-moz-range-thumb {
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.slider-markers {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
}

/* Color Presets */
.color-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.color-preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.color-preset-btn:hover {
    border-color: #94a3b8;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.color-preset-btn.active {
    border-color: #4f46e5;
    background: #f0f4ff;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.color-preset-btn:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

.preset-preview {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.color-preset-btn span {
    font-size: 0.85rem;
    color: #334155;
    font-weight: 500;
    text-align: center;
}

/* Custom Color Pickers */
.color-pickers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 0.5rem;
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-picker-group label {
    font-weight: 600;
    color: #334155;
    font-size: 0.9rem;
}

.color-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.color-input-wrapper input[type="color"] {
    width: 60px;
    height: 40px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

.color-input-wrapper input[type="text"] {
    flex: 1;
    padding: 0.5rem;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.color-input-wrapper input[type="text"]:focus {
    outline: none;
    border-color: #4f46e5;
}

/* Contrast Checker */
.contrast-checker {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 1rem;
}

.contrast-label {
    font-weight: 600;
    color: #334155;
}

.contrast-value {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1.1rem;
    color: #4f46e5;
}

.contrast-status {
    margin-left: auto;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.contrast-status.pass-aaa {
    background: #dcfce7;
    color: #166534;
}

.contrast-status.pass-aa {
    background: #fef3c7;
    color: #854d0e;
}

.contrast-status.fail {
    background: #fee2e2;
    color: #991b1b;
}

/* Checkbox Styles */
.checkbox-group {
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: #f8fafc;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-icon {
    width: 24px;
    height: 24px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    background: white;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-icon {
    background: #4f46e5;
    border-color: #4f46e5;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-icon::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.checkbox-label input[type="checkbox"]:focus + .checkbox-icon {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.checkbox-text {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Keyboard Shortcuts Info */
.shortcuts-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.shortcut-item kbd {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    box-shadow: 0 2px 0 #cbd5e1;
}

.shortcut-item span {
    color: #64748b;
    flex: 1;
}

/* ============================================
   ACCESSIBILITY APPLIED STYLES
   ============================================ */

/* Root variable overrides for accessibility */
:root {
    --a11y-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
    --a11y-font-size: 16px;
    --a11y-line-height: 1.5;
    --a11y-letter-spacing: 0px;
    --a11y-word-spacing: 0px;
    --a11y-text-color: #000000;
    --a11y-bg-color: #ffffff;
    --a11y-text-align: left;
    --a11y-max-width: 75ch;
    --a11y-editor-highlight-bg: rgba(255, 235, 59, 0.3);
    --a11y-editor-highlight-border: #f59e0b;
}

/* Content areas that should respect accessibility settings */
.a11y-content {
    font-family: var(--a11y-font-family) !important;
    font-size: var(--a11y-font-size) !important;
    line-height: var(--a11y-line-height) !important;
    letter-spacing: var(--a11y-letter-spacing) !important;
    word-spacing: var(--a11y-word-spacing) !important;
    color: var(--a11y-text-color) !important;
    background-color: var(--a11y-bg-color) !important;
    text-align: var(--a11y-text-align) !important;
    max-width: var(--a11y-max-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Apply to line display in practice mode */
#line-display.a11y-content p {
    font-family: var(--a11y-font-family) !important;
    font-size: var(--a11y-font-size) !important;
    line-height: var(--a11y-line-height) !important;
    letter-spacing: var(--a11y-letter-spacing) !important;
    word-spacing: var(--a11y-word-spacing) !important;
    font-weight: var(--a11y-font-weight) !important;
    color: var(--a11y-text-color) !important;
    background-color: var(--a11y-bg-color) !important;
    text-align: var(--a11y-text-align) !important;
    padding: 1.5rem;
    border-radius: 8px;
    transition: background-color 0.3s, color 0.3s;
}

/* Apply to library cards - card title with accessibility colors only */
.library-card.a11y-colors .card-title {
    color: var(--a11y-text-color) !important;
    background-color: var(--a11y-bg-color) !important;
    padding: 0.75rem !important;
    border-radius: 6px !important;
    display: block !important;
    margin: 0 !important;
}

/* Apply to card description with accessibility colors only */
.library-card.a11y-colors .description {
    color: var(--a11y-text-color) !important;
    background-color: var(--a11y-bg-color) !important;
    padding: 0.75rem !important;
    border-radius: 6px !important;
}

/* Apply text sizing/spacing when font settings are changed */
.library-card.a11y-typography .card-title {
    font-family: var(--a11y-font-family) !important;
    font-size: var(--a11y-font-size) !important;
    line-height: var(--a11y-line-height) !important;
    letter-spacing: var(--a11y-letter-spacing) !important;
    word-spacing: var(--a11y-word-spacing) !important;
    font-weight: var(--a11y-font-weight) !important;
}

.library-card.a11y-typography .description {
    font-family: var(--a11y-font-family) !important;
    font-size: var(--a11y-font-size) !important;
    line-height: var(--a11y-line-height) !important;
    letter-spacing: var(--a11y-letter-spacing) !important;
    word-spacing: var(--a11y-word-spacing) !important;
    font-weight: var(--a11y-font-weight) !important;
}

/* Apply to edit lines modal */
#editor-content.a11y-content {
    font-family: var(--a11y-font-family) !important;
    font-size: var(--a11y-font-size) !important;
    line-height: var(--a11y-line-height) !important;
    letter-spacing: var(--a11y-letter-spacing) !important;
    word-spacing: var(--a11y-word-spacing) !important;
    font-weight: var(--a11y-font-weight) !important;
    color: var(--a11y-text-color) !important;
    background-color: var(--a11y-bg-color) !important;
    padding: 1.5rem;
    border-radius: 8px;
}

/* Ensure text alignment in editor */
#editor-content.a11y-content div,
#editor-content.a11y-content br {
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    letter-spacing: inherit !important;
    word-spacing: inherit !important;
    color: inherit !important;
}

/* Focus Mode Styles - Blur everything EXCEPT the main text */
body.focus-mode-active #line-display {
    position: relative;
    z-index: 1;
}

body.focus-mode-active .practice-header,
body.focus-mode-active .stats,
body.focus-mode-active .controls,
body.focus-mode-active .navigation,
body.focus-mode-active #feedback,
body.focus-mode-active #line-navigation {
    opacity: 0.3;
    filter: blur(2px);
    transition: all 0.3s ease;
    pointer-events: none;
}

body.focus-mode-active #line-display {
    opacity: 1;
    filter: none;
    position: relative;
    z-index: 10;
}

/* Ensure line display text remains clear */
body.focus-mode-active #line-display p {
    opacity: 1;
    filter: none;
}

/* Current Line Highlighting */
#line-display p.current-line {
    background-color: rgba(79, 70, 229, 0.1);
    border-left: 4px solid #4f46e5;
    padding-left: calc(1.5rem - 4px);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.1);
}

/* Override for custom background colors */
body.a11y-custom-colors #line-display p.current-line {
    background-color: var(--a11y-highlight-bg, rgba(79, 70, 229, 0.1));
    border-left-color: var(--a11y-highlight-border, #4f46e5);
}

/* Reduce Motion */
body.reduce-motion * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* Larger Touch Targets */
body.large-controls button,
body.large-controls a,
body.large-controls input[type="button"],
body.large-controls input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1.5rem;
}

body.large-controls .nav-btn,
body.large-controls .record-btn {
    font-size: 1.1rem;
    padding: 1rem 2rem;
}

/* High Contrast Mode Additional Styles */
body.high-contrast-mode {
    --a11y-text-color: #ffffff;
    --a11y-bg-color: #000000;
}

body.high-contrast-mode button,
body.high-contrast-mode .btn {
    border: 2px solid currentColor;
}

/* Only apply high contrast to practice/reading content, not UI modals */
body.high-contrast-mode .modal-content {
    /* Keep all modals in default styling for UI clarity */
    background: white !important;
    color: #1e293b !important;
    border: 1px solid #cbd5e1 !important;
}

/* Exclude accessibility modal from high contrast and custom color settings */
body.high-contrast-mode .accessibility-modal,
body.a11y-custom-colors .accessibility-modal {
    background: white !important;
    color: #1e293b !important;
}

/* Exclude line edit modal from high contrast (except editor-content) */
body.high-contrast-mode #line-edit-modal .modal-content,
body.a11y-custom-colors #line-edit-modal .modal-content {
    background: white !important;
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
}

body.high-contrast-mode #line-edit-modal .modal-header,
body.a11y-custom-colors #line-edit-modal .modal-header,
body.high-contrast-mode #line-edit-modal .modal-body,
body.a11y-custom-colors #line-edit-modal .modal-body,
body.high-contrast-mode #line-edit-modal .modal-footer,
body.a11y-custom-colors #line-edit-modal .modal-footer {
    background: transparent !important;
    color: #1e293b !important;
}

body.high-contrast-mode #line-edit-modal h3,
body.a11y-custom-colors #line-edit-modal h3,
body.high-contrast-mode #line-edit-modal p,
body.a11y-custom-colors #line-edit-modal p,
body.high-contrast-mode #line-edit-modal .current-line-info,
body.a11y-custom-colors #line-edit-modal .current-line-info,
body.high-contrast-mode #line-edit-modal .edit-instructions,
body.a11y-custom-colors #line-edit-modal .edit-instructions {
    color: #1e293b !important;
}

/* But allow editor-content to use accessibility settings */
body.high-contrast-mode #line-edit-modal #editor-content,
body.a11y-custom-colors #line-edit-modal #editor-content {
    background: var(--a11y-bg-color) !important;
    color: var(--a11y-text-color) !important;
}

/* Current line highlight in editor should contrast with accessibility colors */
body.high-contrast-mode #editor-content .current-line-highlight,
body.a11y-custom-colors #editor-content .current-line-highlight {
    background: var(--a11y-editor-highlight-bg, rgba(255, 235, 59, 0.3)) !important;
    border-left-color: var(--a11y-editor-highlight-border, #f59e0b) !important;
}

/* For high contrast mode specifically, use a more visible highlight */
body.high-contrast-mode #editor-content .current-line-highlight {
    background: rgba(255, 255, 0, 0.4) !important;
    border-left-color: #ffff00 !important;
}

/* Exclude security modals from high contrast and custom colors */
body.high-contrast-mode .security-modal,
body.a11y-custom-colors .security-modal {
    background: white !important;
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
}

body.high-contrast-mode .security-modal .modal-header,
body.a11y-custom-colors .security-modal .modal-header,
body.high-contrast-mode .security-modal .modal-body,
body.a11y-custom-colors .security-modal .modal-body,
body.high-contrast-mode .security-modal .modal-footer,
body.a11y-custom-colors .security-modal .modal-footer {
    background: transparent !important;
    color: #1e293b !important;
}

body.high-contrast-mode .security-modal h3,
body.a11y-custom-colors .security-modal h3,
body.high-contrast-mode .security-modal p,
body.a11y-custom-colors .security-modal p,
body.high-contrast-mode .security-modal label,
body.a11y-custom-colors .security-modal label,
body.high-contrast-mode .security-modal input,
body.a11y-custom-colors .security-modal input,
body.high-contrast-mode .security-modal .pin-display,
body.a11y-custom-colors .security-modal .pin-display {
    color: #1e293b !important;
}

body.high-contrast-mode .security-modal input {
    background: white !important;
    border-color: #cbd5e1 !important;
}

/* Hint "Hold to Reveal" revealed text should match main content colors with distinctive border */
body.high-contrast-mode .prompt-line.revealed,
body.a11y-custom-colors .prompt-line.revealed {
    background: var(--a11y-bg-color) !important;
    background-image: none !important;
    color: var(--a11y-text-color) !important;
    border: 4px solid var(--a11y-editor-highlight-border) !important;
    box-shadow: 0 0 0 2px var(--a11y-bg-color), 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    text-shadow: none !important;
}

/* Hint popup in Recite mode results should match main content colors with distinctive border */
body.high-contrast-mode .hint-info,
body.a11y-custom-colors .hint-info,
body.high-contrast-mode .recite-prompt-result .hint-info,
body.a11y-custom-colors .recite-prompt-result .hint-info,
body.high-contrast-mode .comparison-result.recite-prompt-result .hint-info,
body.a11y-custom-colors .comparison-result.recite-prompt-result .hint-info {
    background: var(--a11y-bg-color) !important;
    background-image: none !important;
    color: var(--a11y-text-color) !important;
    border: 4px solid var(--a11y-editor-highlight-border) !important;
    box-shadow: 0 0 0 2px var(--a11y-bg-color), 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

/* General modal protection - all modals should use default styling except content areas */
body.high-contrast-mode .modal h3,
body.a11y-custom-colors .modal h3,
body.high-contrast-mode .modal h4,
body.a11y-custom-colors .modal h4,
body.high-contrast-mode .modal p,
body.a11y-custom-colors .modal p,
body.high-contrast-mode .modal label,
body.a11y-custom-colors .modal label,
body.high-contrast-mode .modal input:not(#editor-content input),
body.a11y-custom-colors .modal input:not(#editor-content input),
body.high-contrast-mode .modal select,
body.a11y-custom-colors .modal select,
body.high-contrast-mode .modal textarea,
body.a11y-custom-colors .modal textarea,
body.high-contrast-mode .modal button,
body.a11y-custom-colors .modal button,
body.high-contrast-mode .modal .modal-header,
body.a11y-custom-colors .modal .modal-header,
body.high-contrast-mode .modal .modal-body,
body.a11y-custom-colors .modal .modal-body,
body.high-contrast-mode .modal .modal-footer,
body.a11y-custom-colors .modal .modal-footer {
    color: #1e293b !important;
    background: transparent !important;
}

body.high-contrast-mode .modal input:not(#editor-content input),
body.a11y-custom-colors .modal input:not(#editor-content input),
body.high-contrast-mode .modal select,
body.a11y-custom-colors .modal select,
body.high-contrast-mode .modal textarea,
body.a11y-custom-colors .modal textarea {
    background: white !important;
    border-color: #cbd5e1 !important;
    color: #1e293b !important;
}

.accessibility-modal .modal-content {
    background: white !important;
    color: #1e293b !important;
}

.accessibility-modal .accessibility-body {
    background: white !important;
    color: #1e293b !important;
}

.accessibility-tabs {
    background: #f8fafc !important;
    border-bottom-color: #e2e8f0 !important;
}

.accessibility-tabs .tab-btn {
    color: #64748b !important;
    background: transparent !important;
}

.accessibility-tabs .tab-btn:hover {
    color: #4f46e5 !important;
    background: #f1f5f9 !important;
}

.accessibility-tabs .tab-btn.active {
    color: #4f46e5 !important;
    background: white !important;
}

.accessibility-modal .label-text {
    color: #334155 !important;
}

.accessibility-modal .label-hint {
    color: #64748b !important;
}

.accessibility-modal .settings-select {
    background: white !important;
    color: #1e293b !important;
    border-color: #cbd5e1 !important;
}

.accessibility-modal .font-preview {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: #334155 !important;
}

.accessibility-modal .settings-section h4 {
    color: #1e293b !important;
    border-bottom-color: #e2e8f0 !important;
}

.accessibility-modal .color-preset-btn {
    background: white !important;
    border-color: #e2e8f0 !important;
}

.accessibility-modal .color-preset-btn span {
    color: #334155 !important;
}

.accessibility-modal .color-picker-group label {
    color: #334155 !important;
}

.accessibility-modal .contrast-checker {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

.accessibility-modal .contrast-label {
    color: #334155 !important;
}

.accessibility-modal .contrast-value {
    color: #4f46e5 !important;
}

.accessibility-modal .shortcut-item {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
}

.accessibility-modal .shortcut-item span {
    color: #64748b !important;
}

.accessibility-modal .shortcut-item kbd {
    background: #ffffff !important;
    border-color: #cbd5e1 !important;
    color: #334155 !important;
}

/* Allow preview boxes to show user's selected colors */
.accessibility-modal .accessibility-preview {
    /* Preview boxes should reflect user settings, not modal defaults */
    background: inherit !important;
    color: inherit !important;
    border-color: #cbd5e1 !important;
}

.accessibility-modal .accessibility-preview p {
    /* Allow preview text to inherit user settings */
    color: inherit !important;
    background: inherit !important;
    font-family: inherit !important;
    font-size: inherit !important;
    line-height: inherit !important;
    letter-spacing: inherit !important;
    word-spacing: inherit !important;
    text-align: inherit !important;
    max-width: inherit !important;
}

/* Ensure proper contrast for interactive elements */
body.a11y-custom-colors button:focus,
body.a11y-custom-colors a:focus,
body.a11y-custom-colors input:focus,
body.a11y-custom-colors select:focus,
body.a11y-custom-colors textarea:focus {
    outline: 3px solid var(--a11y-text-color);
    outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .accessibility-modal {
        max-width: 95vw;
    }

    .color-presets {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    }

    .accessibility-tabs {
        flex-direction: column;
    }

    .accessibility-tabs .tab-btn {
        border-bottom: none;
        border-left: 3px solid transparent;
    }

    .accessibility-tabs .tab-btn.active {
        border-left-color: #4f46e5;
        border-bottom-color: transparent;
    }
}

/* Print styles - ensure accessibility settings don't interfere */
@media print {
    .a11y-content {
        font-size: 12pt !important;
        color: black !important;
        background: white !important;
    }

    body.focus-mode-active #line-display p {
        opacity: 1 !important;
        filter: none !important;
    }
}
