/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
    --aw-accent:        #1d4ed8;
    --aw-icon-color:    #ffffff;
    --aw-btn-size:      48px;
    --aw-bg:            #ffffff;
    --aw-text:          #1f2937;
    --aw-border:        #e5e7eb;
    --aw-muted:         #6b7280;
    --aw-radius:        12px;
    --aw-z:             999998;
    --aw-trigger-top:       auto;
    --aw-trigger-bottom:    20px;
    --aw-trigger-right:     20px;
    --aw-trigger-left:      auto;
    --aw-trigger-transform: none;
    --aw-panel-top:         auto;
    --aw-panel-bottom:      80px;
    --aw-panel-right:       20px;
    --aw-panel-left:        auto;
    --aw-panel-transform:   none;
}

/* ── Trigger button ────────────────────────────────────────────────────────── */
#aw-trigger {
    position: fixed;
    top: var(--aw-trigger-top);
    bottom: var(--aw-trigger-bottom);
    right: var(--aw-trigger-right);
    left: var(--aw-trigger-left);
    transform: var(--aw-trigger-transform);
    z-index: var(--aw-z);
    width: var(--aw-btn-size);
    height: var(--aw-btn-size);
    border-radius: 50%;
    background: var(--aw-accent);
    color: var(--aw-icon-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,.2);
    transition: transform .2s, box-shadow .2s;
    padding: 0;
    font-family: inherit;
    overflow: hidden;
}

/* Force icon color on any inline SVG (overrides Illustrator class-based fills) */
#aw-trigger svg path,
#aw-trigger svg circle,
#aw-trigger svg ellipse,
#aw-trigger svg polygon,
#aw-trigger svg polyline,
#aw-trigger svg line,
#aw-trigger svg rect {
    fill: currentColor;
}

#aw-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
}

#aw-trigger:focus-visible {
    outline: 3px solid var(--aw-accent);
    outline-offset: 3px;
}

/* ── Panel ─────────────────────────────────────────────────────────────────── */
#aw-panel {
    position: fixed;
    top: var(--aw-panel-top);
    bottom: var(--aw-panel-bottom);
    right: var(--aw-panel-right);
    left: var(--aw-panel-left);
    transform: var(--aw-panel-transform);
    z-index: var(--aw-z);
    width: 280px;
    background: var(--aw-bg);
    border: 1px solid var(--aw-border);
    border-radius: var(--aw-radius);
    box-shadow: 0 8px 30px rgba(0,0,0,.15);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    color: var(--aw-text);
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity .18s, transform .18s;
}

#aw-panel[hidden] {
    display: none;
}

/* ── Panel header ──────────────────────────────────────────────────────────── */
.aw-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--aw-border);
    background: var(--aw-accent);
    color: #fff;
}

.aw-panel__title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .3px;
}

.aw-panel__close {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
}

.aw-panel__close:hover {
    color: #fff;
}

/* ── Panel body ────────────────────────────────────────────────────────────── */
.aw-panel__body {
    padding: 12px 0;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

/* ── Section ───────────────────────────────────────────────────────────────── */
.aw-section {
    padding: 8px 16px;
}

.aw-section + .aw-section {
    border-top: 1px solid var(--aw-border);
    margin-top: 4px;
    padding-top: 12px;
}

.aw-section__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--aw-muted);
    margin-bottom: 8px;
}

/* ── Font size controls ────────────────────────────────────────────────────── */
.aw-font-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.aw-font-btn {
    flex: 1;
    padding: 7px 4px;
    border: 1px solid var(--aw-border);
    border-radius: 6px;
    background: #f9fafb;
    cursor: pointer;
    font-family: inherit;
    color: var(--aw-text);
    text-align: center;
    transition: background .15s, border-color .15s, color .15s;
    line-height: 1;
}

.aw-font-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.aw-font-btn.is-active {
    background: var(--aw-accent);
    border-color: var(--aw-accent);
    color: #fff;
}

/* ── Toggle rows ───────────────────────────────────────────────────────────── */
.aw-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 0;
    gap: 12px;
}

.aw-toggle-row + .aw-toggle-row {
    border-top: 1px solid #f3f4f6;
}

.aw-toggle-row__label {
    font-size: 13px;
    color: var(--aw-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.aw-toggle-row__label svg {
    color: var(--aw-muted);
    flex-shrink: 0;
}

/* Toggle switch */
.aw-switch {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    cursor: pointer;
}

.aw-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.aw-switch__track {
    display: block;
    width: 38px;
    height: 22px;
    border-radius: 22px;
    background: #d1d5db;
    transition: background .2s;
    position: relative;
}

.aw-switch__track::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.aw-switch input:checked + .aw-switch__track {
    background: var(--aw-accent);
}

.aw-switch input:checked + .aw-switch__track::after {
    transform: translateX(16px);
}

.aw-switch input:focus-visible + .aw-switch__track {
    outline: 2px solid var(--aw-accent);
    outline-offset: 2px;
}

/* ── Reset button ──────────────────────────────────────────────────────────── */
.aw-reset-btn {
    display: block;
    width: calc(100% - 32px);
    margin: 8px 16px 4px;
    padding: 8px;
    border: 1px solid var(--aw-border);
    border-radius: 6px;
    background: #f9fafb;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    color: var(--aw-muted);
    text-align: center;
    transition: background .15s, color .15s;
}

.aw-reset-btn:hover {
    background: #f3f4f6;
    color: var(--aw-text);
}

/* ══════════════════════════════════════════════════════════════════════════════
   Accessibility modifier classes (applied to <html>)
══════════════════════════════════════════════════════════════════════════════ */

/* Font size */
html.aw-font-1 { font-size: 110% !important; }
html.aw-font-2 { font-size: 125% !important; }
html.aw-font-3 { font-size: 150% !important; }

/* High contrast */
html.aw-contrast,
html.aw-contrast body {
    background: #000 !important;
    color: #fff !important;
}

html.aw-contrast a { color: #ffff00 !important; }

html.aw-contrast button:not(#aw-trigger):not(#aw-panel button),
html.aw-contrast input,
html.aw-contrast textarea,
html.aw-contrast select {
    background: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}

html.aw-contrast img:not(#aw-trigger img):not(#aw-panel img) {
    filter: contrast(120%) brightness(90%);
}

/* Grayscale — applied to body children to preserve position:fixed on widget */
html.aw-grayscale body > *:not(#aw-panel):not(#aw-trigger):not(#aw-mask) {
    filter: grayscale(1) !important;
}

/* Link highlighting */
html.aw-links a {
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 3px !important;
    outline: 1px dashed currentColor !important;
    outline-offset: 2px !important;
}

/* Dyslexia font — loaded dynamically */
html.aw-dyslexia,
html.aw-dyslexia * {
    font-family: 'OpenDyslexic', sans-serif !important;
}

/* Stop animations */
html.aw-no-anim *,
html.aw-no-anim *::before,
html.aw-no-anim *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

/* Focus highlight */
html.aw-focus *:focus {
    outline: 3px solid #f59e0b !important;
    outline-offset: 3px !important;
}

/* ── Reading mask ──────────────────────────────────────────────────────────── */
#aw-mask {
    position: fixed;
    inset: 0;
    z-index: calc(var(--aw-z) - 1);
    pointer-events: none;
    background: rgba(0,0,0,.5);
}
