:root {
    --stv-primary: #3B3DE6;
    --stv-primary-dark: #2D2FB8;
    --stv-primary-light: #EEEEFF;
    --stv-bg: #F0F2F8;
    --stv-card: #FFFFFF;
    --stv-border: #E2E5F0;
    --stv-text: #1C1E2E;
    --stv-muted: #6B7280;
    --stv-shadow: 0 16px 56px rgba(20,22,70,0.18), 0 2px 10px rgba(20,22,70,0.08);
    --stv-radius: 16px;
    --stv-radius-btn: 10px;
    --stv-z: 99999;
    --stv-width: 360px;        /* wider panel */
}

/* ── Wrapper ─────────────────────────────────── */
#stv-acc-widget {
    position: fixed;
    z-index: var(--stv-z);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Positions ───────────────────────────────── */
#stv-acc-widget.pos-bottom-right { bottom: 28px; right: 28px; }
#stv-acc-widget.pos-bottom-left  { bottom: 28px; left: 28px; }
#stv-acc-widget.pos-top-right    { top: 28px; right: 28px; }
#stv-acc-widget.pos-top-left     { top: 28px; left: 28px; }
#stv-acc-widget.pos-middle-right { top: 50%; right: 28px; transform: translateY(-50%); }
#stv-acc-widget.pos-middle-left  { top: 50%; left: 28px; transform: translateY(-50%); }

/* ══════════════════════════════════════════════
   TRIGGER — square 52x52, 5px radius
   ══════════════════════════════════════════════ */
.stv-acc-trigger {
    display: -webkit-inline-flex;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 52px;
    height: 52px;
    padding: 5px;
    background: var(--stv-primary);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(59,61,230,0.38);
    transition: all 0.18s ease;
    outline: none;
    flex-shrink: 0;
}
.stv-acc-trigger:hover {
    background: var(--stv-primary-dark);
    transform: scale(1.06);
}
.stv-acc-trigger:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}
.stv-acc-trigger-icon {
    display: block !important;
    width: 26px !important;
    height: 26px !important;
    flex-shrink: 0;
    overflow: visible;
}
.stv-acc-trigger--with-label {
    width: auto;
    height: auto;
    padding: 12px 20px;
    border-radius: 5px;
    gap: 10px;
}
.stv-acc-trigger-label {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

/* ── Panel ───────────────────────────────────── */
.stv-acc-panel {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    width: var(--stv-width);
    max-height: 88vh;
    overflow: hidden;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    background: var(--stv-bg);
    border-radius: var(--stv-radius);
    box-shadow: var(--stv-shadow);
    border: 1px solid var(--stv-border);
    animation: stvSlideUp 0.2s cubic-bezier(.4,0,.2,1);
}
.stv-acc-panel[hidden] { display: none !important; }

@keyframes stvSlideUp {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ──────────────────────────────────── */
.stv-acc-header {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 16px 13px;
    background: var(--stv-primary);
    border-radius: var(--stv-radius) var(--stv-radius) 0 0;
    flex-shrink: 0;
}
.stv-acc-header-left {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
}
.stv-acc-header-left svg { display: block !important; flex-shrink: 0; }

.stv-acc-header-actions {
    display: -webkit-flex;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── Icon Buttons (reset/close) ──────────────── */
.stv-acc-icon-btn {
    display: -webkit-inline-flex !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    background: rgba(255,255,255,0.15) !important;
    border: 1.5px solid rgba(255,255,255,0.25) !important;
    border-radius: 7px !important;
    color: #fff !important;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0 !important;
    flex-shrink: 0;
    outline: none;
    box-sizing: border-box;
}
.stv-acc-icon-btn:hover { background: rgba(255,255,255,0.3) !important; }
.stv-acc-icon-btn:focus-visible { outline: 2px solid #fff !important; outline-offset: 1px; }
.stv-acc-icon-btn svg {
    display: block !important;
    width: 15px !important;
    height: 15px !important;
    overflow: visible;
    flex-shrink: 0;
    pointer-events: none;
}
.stv-acc-divider-v { width: 1px; height: 18px; background: rgba(255,255,255,0.25); margin: 0 2px; }

/* ── Content scroll area ─────────────────────── */
.stv-acc-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 11px;
    scrollbar-width: thin;
    scrollbar-color: rgba(59,61,230,0.25) transparent;
}
.stv-acc-content::-webkit-scrollbar { width: 4px; }
.stv-acc-content::-webkit-scrollbar-thumb { background: rgba(59,61,230,0.25); border-radius: 4px; }

/* ── Section ─────────────────────────────────── */
.stv-acc-section {
    background: var(--stv-card);
    border: 1px solid var(--stv-border);
    border-radius: 12px;
    padding: 14px 12px 12px;
    margin-bottom: 9px;
}
.stv-acc-section:last-child { margin-bottom: 0; }
.stv-acc-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--stv-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 10px;
}

/* ── Grid — 3 equal columns ──────────────────── */
.stv-acc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

/* ── Feature Button — equal height via flex ──── */
.stv-acc-feature {
    position: relative;
    background: var(--stv-bg);
    border: 1.5px solid var(--stv-border);
    border-radius: var(--stv-radius-btn);
    padding: 11px 9px 10px;
    display: -webkit-flex;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--stv-text);
    font-size: 11.5px;
    font-weight: 500;
    text-align: left;
    /* Equal height — all boxes same height in row */
    height: 100%;
    min-height: 72px;
    box-sizing: border-box;
    outline: none;
    line-height: 1.3;
    /* Ensure full grid cell fill */
    width: 100%;
}
.stv-acc-feature:hover {
    background: var(--stv-primary-light);
    border-color: var(--stv-primary);
    color: var(--stv-primary);
}
.stv-acc-feature:focus-visible { outline: 2px solid var(--stv-primary); outline-offset: 1px; }
.stv-acc-feature[aria-pressed="true"] {
    background: var(--stv-primary);
    border-color: var(--stv-primary);
    color: #fff;
    box-shadow: 0 3px 12px rgba(59,61,230,0.3);
}
.stv-acc-feature[aria-pressed="true"] .stv-acc-feat-icon { color: #fff !important; }
.stv-acc-feature[aria-pressed="true"]:hover { background: var(--stv-primary-dark); border-color: var(--stv-primary-dark); }
.stv-acc-feature[aria-pressed="true"]::after {
    content: '';
    position: absolute;
    top: 7px; right: 7px;
    width: 6px; height: 6px;
    background: rgba(255,255,255,0.65);
    border-radius: 50%;
}

/* Icon inside feature button */
.stv-acc-feat-icon {
    display: block !important;
    width: 22px !important;
    height: 22px !important;
    color: var(--stv-text);
    flex-shrink: 0;
    overflow: visible;
}
.stv-acc-feature span {
    display: block;
    word-break: break-word;
}

/* Text size slider dots */
.stv-acc-slider-mini { display: flex; gap: 4px; margin-top: 2px; }
.stv-acc-slider-mini .dot { width: 18px; height: 4px; border-radius: 2px; background: #D1D5DB; transition: background 0.2s; }
.stv-acc-slider-mini .dot.active { background: var(--stv-primary); }
.stv-acc-feature[aria-pressed="true"] .stv-acc-slider-mini .dot { background: rgba(255,255,255,0.3); }
.stv-acc-feature[aria-pressed="true"] .stv-acc-slider-mini .dot.active { background: rgba(255,255,255,0.9); }

/* ── Footer / credit bar ─────────────────────── */
.stv-acc-footer {
    padding: 11px 16px;
    text-align: center;
    font-size: 11px;
    background: var(--stv-primary);
    color: rgba(255,255,255,0.6);
    border-radius: 0 0 var(--stv-radius) var(--stv-radius);
    flex-shrink: 0;
    letter-spacing: 0.01em;
}
.stv-acc-footer strong { color: #fff; }

/* ============================================
   Accessibility Feature Styles applied to <html>
   ============================================ */
html.stv-line-height p, html.stv-line-height li, html.stv-line-height span { line-height: 2 !important; }
html.stv-text-align p, html.stv-text-align li { text-align: left !important; }
html.stv-readable-font,
html.stv-readable-font body,
html.stv-readable-font * { font-family: Arial, Helvetica, sans-serif !important; }
html.stv-dyslexia-font,
html.stv-dyslexia-font body,
html.stv-dyslexia-font * { font-family: 'Comic Sans MS', 'OpenDyslexic', cursive !important; letter-spacing: 0.05em !important; }
html.stv-contrast { filter: contrast(160%) brightness(1.05) !important; }
html.stv-grayscale { filter: grayscale(100%) !important; }
html.stv-hide-images img,
html.stv-hide-images figure,
html.stv-hide-images video,
html.stv-hide-images [style*="background-image"] { visibility: hidden !important; }
html.stv-pause-animations *,
html.stv-pause-animations *::before,
html.stv-pause-animations *::after { animation-play-state: paused !important; transition-duration: 0ms !important; }
html.stv-highlight-links a:not(#stv-acc-widget a) {
    outline: 2px solid var(--stv-primary) !important;
    outline-offset: 2px !important;
    background: rgba(59,61,230,0.08) !important;
    border-radius: 2px;
}
html.stv-outline-focus *:focus { outline: 3px solid #E85D00 !important; outline-offset: 3px !important; }
html.stv-cursor-big,
html.stv-cursor-big * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpolygon points='6,2 6,34 14,26 20,40 24,38 18,24 32,24' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 6 2, auto !important; }

/* Reading mask */
.stv-reading-mask-top, .stv-reading-mask-bottom {
    position: fixed;
    left: 0; right: 0;
    background: rgba(0,0,0,0.55);
    pointer-events: none;
    z-index: calc(var(--stv-z) - 1);
    display: none;
}
html.stv-reading-mask .stv-reading-mask-top,
html.stv-reading-mask .stv-reading-mask-bottom { display: block; }

/* Page structure tags */
.stv-structure-tag {
    display: inline-block !important;
    background: var(--stv-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    position: absolute;
    z-index: calc(var(--stv-z) - 2);
    pointer-events: none;
    font-family: monospace;
    top: 0; left: 0;
    transform: translateY(-100%);
    white-space: nowrap;
}

/* ── Mobile backdrop ─────────────────────────── */
.stv-acc-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: calc(var(--stv-z) - 1);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.stv-acc-backdrop.active { display: block; }

/* Mobile — panel width only, position handled by JS */
@media (max-width: 768px) {
    :root { --stv-width: calc(100vw - 24px); }
    .stv-acc-panel { width: var(--stv-width) !important; }
}

/* ── Mobile: panel becomes fixed, full-width bottom sheet ── */
@media (max-width: 520px) {
    /* Widget wrapper stays fixed at chosen corner */
    #stv-acc-widget {
        /* z-index already set */
    }

    /* Panel detaches from trigger — fixed bottom sheet */
    .stv-acc-panel {
        position: fixed !important;
        bottom: 0 !important;
        top: auto !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 80vh !important;
        border-radius: 20px 20px 0 0 !important;
        box-shadow: 0 -8px 40px rgba(20,22,70,0.22) !important;
        transform: none !important;
        overflow: hidden !important;
    }

    /* Scrollable inner content */
    .stv-acc-content {
        max-height: calc(80vh - 110px);
        overflow-y: auto;
    }

    /* 2-col grid on mobile */
    .stv-acc-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    /* Slightly taller buttons for touch targets */
    .stv-acc-feature {
        min-height: 70px !important;
        font-size: 12px !important;
    }

    /* Drag handle indicator */
    .stv-acc-panel::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255,255,255,0.4);
        border-radius: 2px;
        margin: 0 auto;
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
    }
}
