/* --- Brightness adjuster tool --- */
.ba-tool {
    --ba-radius: 12px;
    --ba-radius-sm: 8px;
    --ba-gap: 1rem;
    --ba-panel-bg: var(--bs-body-bg, #fff);
    --ba-border: 1px solid var(--bs-border-color, #dee2e6);
    --ba-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: var(--ba-gap);
    margin-bottom: 2rem;
}

.ba-panel {
    background: var(--ba-panel-bg);
    border: var(--ba-border);
    border-radius: var(--ba-radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--ba-shadow);
}

/* Top row: Color + Method in one row to save space */
.ba-top-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-end;
}

.ba-top-color {
    flex: 1 1 200px;
    min-width: 0;
}

.ba-top-method {
    flex: 0 1 auto;
    min-width: 180px;
}

.ba-top-method .ba-select {
    width: 100%;
    min-width: 180px;
}

.ba-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
    margin-bottom: 0.5rem;
}

/* Color input row */
.ba-color-row {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
}

.ba-color-text {
    flex: 1;
    min-width: 0;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    border: var(--ba-border);
    border-radius: var(--ba-radius-sm);
    background: var(--ba-panel-bg);
}

.ba-color-text:focus {
    outline: none;
    border-color: var(--bs-primary, #0d6efd);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.ba-color-picker {
    width: 48px;
    min-width: 48px;
    height: 42px;
    padding: 4px;
    border: var(--ba-border);
    border-radius: var(--ba-radius-sm);
    cursor: pointer;
    background: var(--ba-panel-bg);
}

.ba-color-picker::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.ba-color-picker::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

/* Method select */
.ba-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 1rem;
    border: var(--ba-border);
    border-radius: var(--ba-radius-sm);
    background: var(--ba-panel-bg);
    cursor: pointer;
}

.ba-select:focus {
    outline: none;
    border-color: var(--bs-primary, #0d6efd);
}

/* Swatches */
.ba-swatches {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--ba-gap);
}

.ba-swatch-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.ba-swatch {
    width: 100%;
    aspect-ratio: 1;
    max-height: 180px;
    border-radius: var(--ba-radius);
    overflow: hidden;
    position: relative;
}

.ba-swatch-checkered {
    background-image:
        linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
        linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
        linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.ba-swatch-fill {
    position: absolute;
    inset: 0;
}

.ba-swatch-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted, #6c757d);
}

/* Slider */
.ba-slider-row {
    padding-bottom: 1.25rem;
}

.ba-slider-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.ba-brightness-value {
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--bs-body-color);
}

.ba-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to right, #1a1a1a 0%, #888 50%, #fff 100%);
    outline: none;
}

.ba-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bs-primary, #0d6efd);
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ba-range::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bs-primary, #0d6efd);
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ba-range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted, #6c757d);
}

.ba-range-labels span:nth-child(2) {
    font-weight: 600;
}

/* Actions */
.ba-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.ba-btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--ba-radius-sm);
    cursor: pointer;
    transition: background-color 0.2s, transform 0.15s;
}

.ba-btn:active {
    transform: scale(0.98);
}

.ba-btn-copy {
    background: var(--bs-primary, #0d6efd);
    color: #fff;
}

.ba-btn-copy:hover {
    filter: brightness(1.08);
}

.ba-btn-reset {
    background: var(--bs-secondary-bg, #e9ecef);
    color: var(--bs-body-color);
}

.ba-btn-reset:hover {
    background: var(--bs-tertiary-bg, #dee2e6);
}

/* Value blocks */
.ba-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--ba-gap);
}

.ba-values-block {
    background: var(--ba-panel-bg);
    border: var(--ba-border);
    border-radius: var(--ba-radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--ba-shadow);
}

.ba-values-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #6c757d);
    margin: 0 0 0.75rem 0;
}

.ba-value-item {
    font-size: 0.875rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.08));
}

.ba-value-item:last-child {
    border-bottom: none;
}

/* History */
.ba-history-panel {
    background: var(--ba-panel-bg);
    border: var(--ba-border);
    border-radius: var(--ba-radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--ba-shadow);
}

.ba-history-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted, #6c757d);
    margin: 0 0 0.75rem 0;
}

.ba-history-list {
    min-height: 48px;
}

.ba-history-empty {
    font-size: 0.875rem;
    color: var(--text-muted, #6c757d);
    margin: 0;
}

.ba-history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bs-secondary-bg, #f8f9fa);
    border-radius: var(--ba-radius-sm);
    cursor: pointer;
    transition: background-color 0.15s;
    list-style: none;
}

.ba-history-item:hover {
    background: var(--bs-tertiary-bg, #e9ecef);
}

.ba-history-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.ba-history-meta {
    font-size: 0.8125rem;
}

.ba-history-meta small {
    display: block;
    color: var(--text-muted, #6c757d);
}

/* Education */
.ba-edu {
    background: var(--ba-panel-bg);
    border: var(--ba-border);
    border-radius: var(--ba-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--ba-shadow);
}

.ba-edu-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.75rem 0;
}

.ba-edu-list {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-muted, #6c757d);
}

.ba-edu-list li {
    margin-bottom: 0.5rem;
}

.ba-edu-list li:last-child {
    margin-bottom: 0;
}

.ba-edu-list strong {
    color: var(--bs-body-color);
}

/* Toast */
.ba-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    padding: 0.75rem 1.25rem;
    background: var(--bs-dark, #212529);
    color: #fff;
    border-radius: var(--ba-radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.25s ease;
    z-index: 1050;
}

.ba-toast[data-visible] {
    transform: translateX(-50%) translateY(0);
}

/* Tablet and up */
@media (min-width: 576px) {
    .ba-tool {
        --ba-gap: 1.25rem;
    }

    .ba-swatch {
        max-height: 200px;
    }
}

@media (min-width: 768px) {
    .ba-top-row {
        align-items: flex-end;
    }

    .ba-top-color .ba-color-row {
        min-width: 200px;
    }
}
