/* AI answer highlighter: a restrained notebook-marker effect. */
.message-text .logicum-auto-highlight,
.side-message-bubble .logicum-auto-highlight {
    display: inline;
    padding: 0 0.08em !important;
    border-radius: 0.18em !important;
    color: inherit !important;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    text-decoration: none !important;
    border-bottom: 0 !important;
}

/* Use concrete values on the combined selector. Some of the global theme
   layers also style backgrounds with !important; a custom property alone can
   therefore resolve to the theme's white mark fallback. */
.message-text .logicum-auto-highlight.logicum-highlight-yellow,
.side-message-bubble .logicum-auto-highlight.logicum-highlight-yellow {
    background: rgba(250, 204, 21, 0.5) !important;
    background-color: rgba(250, 204, 21, 0.5) !important;
    box-shadow: inset 0 -0.44em rgba(250, 204, 21, 0.2) !important;
}

.message-text .logicum-auto-highlight.logicum-highlight-green,
.side-message-bubble .logicum-auto-highlight.logicum-highlight-green {
    background: rgba(134, 239, 172, 0.46) !important;
    background-color: rgba(134, 239, 172, 0.46) !important;
    box-shadow: inset 0 -0.44em rgba(134, 239, 172, 0.2) !important;
}

.message-text .logicum-auto-highlight.logicum-highlight-blue,
.side-message-bubble .logicum-auto-highlight.logicum-highlight-blue {
    background: rgba(147, 197, 253, 0.48) !important;
    background-color: rgba(147, 197, 253, 0.48) !important;
    box-shadow: inset 0 -0.44em rgba(147, 197, 253, 0.2) !important;
}

.message-text .logicum-auto-highlight.logicum-highlight-pink,
.side-message-bubble .logicum-auto-highlight.logicum-highlight-pink {
    background: rgba(249, 168, 212, 0.48) !important;
    background-color: rgba(249, 168, 212, 0.48) !important;
    box-shadow: inset 0 -0.44em rgba(249, 168, 212, 0.2) !important;
}

#settingsView .ai-highlight-toggle-row,
#settingsView .ai-highlight-color-row {
    align-items: center !important;
}

#settingsView .ai-highlight-toggle-row .ai-settings-row-left,
#settingsView .ai-highlight-color-row .ai-settings-row-left {
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

#settingsView .ai-highlight-toggle-row .ai-settings-row-value,
#settingsView .ai-highlight-color-row .ai-settings-row-value {
    max-width: 100% !important;
}

#settingsView .ai-highlight-color-row[hidden] {
    display: none !important;
}

.ai-toggle-control {
    position: relative;
    display: inline-flex;
    width: 42px;
    height: 24px;
    flex: 0 0 42px;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.ai-toggle-control input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.ai-toggle-track {
    display: flex;
    width: 42px;
    height: 24px;
    align-items: center;
    padding: 3px;
    box-sizing: border-box;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.13);
    transition: background-color 140ms ease;
}

.ai-toggle-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 140ms ease, background-color 140ms ease;
}

.ai-toggle-control input:checked + .ai-toggle-track {
    background: rgba(250, 204, 21, 0.62);
}

.ai-toggle-control input:checked + .ai-toggle-track .ai-toggle-thumb {
    transform: translateX(18px);
    background: #fff8cf;
}

.ai-toggle-control input:focus-visible + .ai-toggle-track {
    outline: 2px solid rgba(205, 210, 218, 0.42);
    outline-offset: 2px;
}

body.light-mode .ai-toggle-track {
    background: rgba(15, 23, 42, 0.14);
}

/* Keep the automatic-highlight control independent from the AI row layout. */
#settingsView .ai-highlight-toggle-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
}

#settingsView .ai-highlight-toggle-row .ai-settings-row-left {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

#settingsView .ai-highlight-toggle-row .ai-toggle-control {
    display: inline-flex !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 26px !important;
    min-height: 26px !important;
    flex: 0 0 44px !important;
    margin: 0 !important;
    align-items: center !important;
    justify-content: flex-start !important;
}

#settingsView .ai-highlight-toggle-row .ai-toggle-track {
    width: 44px !important;
    height: 26px !important;
    min-width: 44px !important;
    padding: 3px !important;
    border: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
}

#settingsView .ai-highlight-toggle-row .ai-toggle-thumb {
    width: 20px !important;
    height: 20px !important;
    flex: 0 0 20px !important;
    transform: translateX(0) !important;
}

#settingsView .ai-highlight-toggle-row .ai-toggle-control input:checked + .ai-toggle-track .ai-toggle-thumb {
    transform: translateX(18px) !important;
}

#settingsView .ai-highlight-toggle-row .ai-toggle-control input:disabled + .ai-toggle-track,
#settingsView .ai-highlight-toggle-row .ai-toggle-control input:not(:checked) + .ai-toggle-track {
    background: rgba(255, 255, 255, 0.12) !important;
}

/* Keep assistive labels available without rendering a second visible label. */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Unavailable color control remains visible as a quiet preview. */
#settingsView .ai-highlight-color-row.is-unavailable {
    opacity: 0.42 !important;
}

#settingsView .ai-highlight-color-row.is-unavailable .ai-settings-selector {
    cursor: not-allowed !important;
    filter: saturate(0.35) brightness(0.72) !important;
}

@media (prefers-reduced-motion: reduce) {
    .ai-toggle-track,
    .ai-toggle-thumb {
        transition: none !important;
    }
}
