/* Brand Color Extractor – mobile-first, sleek */

:root {
    --bce-bg: #f5f5f7;
    --bce-surface: #ffffff;
    --bce-surface-2: #fafafa;
    --bce-border: #e5e5e7;
    --bce-border-strong: #d1d1d6;
    --bce-text: #1d1d1f;
    --bce-muted: #6e6e73;
    --bce-accent: #0071e3;
    --bce-accent-hover: #0077ed;
    --bce-success: #34c759;
    --bce-radius: 12px;
    --bce-radius-sm: 8px;
    --bce-radius-lg: 16px;
    --bce-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --bce-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --bce-focus: 0 0 0 3px rgba(0, 113, 227, 0.25);
    --bce-touch: 44px;
}

/* Tool wrapper */
.bce-tool {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Upload block */
.bce-upload {
    background: var(--bce-surface);
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius-lg);
    box-shadow: var(--bce-shadow);
    padding: 1.25rem;
}

@media (min-width: 640px) {
    .bce-upload {
        padding: 1.5rem;
    }
}

.bce-dropzone {
    position: relative;
    min-height: 140px;
    padding: 1.5rem;
    border: 2px dashed var(--bce-border-strong);
    border-radius: var(--bce-radius);
    background: var(--bce-surface-2);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.bce-dropzone:hover,
.bce-dropzone:focus-visible {
    border-color: var(--bce-accent);
    background: rgba(0, 113, 227, 0.04);
    outline: none;
}

.bce-dropzone:focus-visible {
    box-shadow: var(--bce-focus);
}

.bce-dropzone.bce-dragover {
    border-color: var(--bce-accent);
    background: rgba(0, 113, 227, 0.08);
}

.bce-dropzone-icon {
    display: block;
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236e6e73'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.bce-dropzone-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--bce-text);
    margin: 0 0 0.25rem;
}

.bce-dropzone-hint {
    font-size: 0.875rem;
    color: var(--bce-muted);
    margin: 0;
}

.bce-file-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
}

.bce-url-row {
    margin-top: 1rem;
}

.bce-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--bce-muted);
    margin-bottom: 0.5rem;
}

.bce-url-wrap {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.bce-url-input {
    flex: 1;
    min-width: 0;
    min-height: var(--bce-touch);
    padding: 0 1rem;
    font-size: 1rem;
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius-sm);
    background: var(--bce-surface);
    color: var(--bce-text);
    transition: border-color 0.2s;
}

.bce-url-input::placeholder {
    color: var(--bce-muted);
}

.bce-url-input:hover {
    border-color: var(--bce-border-strong);
}

.bce-url-input:focus {
    border-color: var(--bce-accent);
    outline: none;
    box-shadow: var(--bce-focus);
}

.bce-btn {
    min-height: var(--bce-touch);
    padding: 0 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--bce-radius-sm);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.bce-btn:focus-visible {
    outline: none;
    box-shadow: var(--bce-focus);
}

.bce-btn-primary {
    background: var(--bce-accent);
    color: #fff;
}

.bce-btn-primary:hover {
    background: var(--bce-accent-hover);
}

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

.bce-samples {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--bce-border);
}

.bce-samples-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--bce-muted);
    margin-bottom: 0.5rem;
}

.bce-sample-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.bce-sample {
    min-height: 36px;
    padding: 0 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bce-text);
    background: var(--bce-surface-2);
    border: 1px solid var(--bce-border);
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.bce-sample:hover {
    border-color: var(--bce-border-strong);
    background: var(--bce-border);
}

.bce-sample:focus-visible {
    outline: none;
    box-shadow: var(--bce-focus);
}

/* Preview */
.bce-preview-wrap {
    background: var(--bce-surface);
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius-lg);
    box-shadow: var(--bce-shadow);
    padding: 1rem;
}

.bce-preview-inner {
    text-align: center;
}

.bce-preview-img {
    max-width: 100%;
    max-height: 280px;
    width: auto;
    height: auto;
    border-radius: var(--bce-radius-sm);
    object-fit: contain;
}

@media (min-width: 640px) {
    .bce-preview-img {
        max-height: 320px;
    }
}

/* Settings */
.bce-settings {
    background: var(--bce-surface);
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius-lg);
    box-shadow: var(--bce-shadow);
    padding: 1.25rem;
}

.bce-settings-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--bce-text);
    margin: 0 0 1rem;
}

.bce-settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
    .bce-settings-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.bce-setting {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bce-setting-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bce-text);
}

.bce-range {
    width: 100%;
    height: 8px;
    accent-color: var(--bce-accent);
}

.bce-select {
    min-height: var(--bce-touch);
    padding: 0 1rem;
    font-size: 1rem;
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius-sm);
    background: var(--bce-surface);
    color: var(--bce-text);
    cursor: pointer;
}

.bce-select:focus {
    border-color: var(--bce-accent);
    outline: none;
}

.bce-btn-extract {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
    background: var(--bce-accent);
    color: #fff;
    border-radius: var(--bce-radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.bce-btn-extract:hover {
    background: var(--bce-accent-hover);
}

.bce-btn-extract:focus-visible {
    outline: none;
    box-shadow: var(--bce-focus);
}

@media (min-width: 640px) {
    .bce-btn-extract {
        width: auto;
        padding: 0 2rem;
    }
}

/* Loading */
.bce-loading {
    text-align: center;
    padding: 2rem;
    background: var(--bce-surface-2);
    border-radius: var(--bce-radius-lg);
    border: 1px solid var(--bce-border);
}

.bce-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    border: 3px solid var(--bce-border);
    border-top-color: var(--bce-accent);
    border-radius: 50%;
    animation: bce-spin 0.8s linear infinite;
}

@keyframes bce-spin {
    to { transform: rotate(360deg); }
}

.bce-loading-text {
    font-size: 0.9375rem;
    color: var(--bce-muted);
    margin: 0;
}

/* Results */
.bce-results {
    background: var(--bce-surface);
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius-lg);
    box-shadow: var(--bce-shadow);
    padding: 1.25rem;
}

.bce-results-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--bce-text);
    margin: 0 0 1rem;
}

.bce-color-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (min-width: 480px) {
    .bce-color-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .bce-color-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }
}

.bce-color-card {
    text-align: center;
    padding: 1rem;
    background: var(--bce-surface-2);
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.bce-color-card:hover {
    border-color: var(--bce-accent);
    box-shadow: var(--bce-shadow);
}

.bce-color-card:focus-visible {
    outline: none;
    box-shadow: var(--bce-focus);
}

.bce-swatch {
    width: 56px;
    height: 56px;
    margin: 0 auto 0.75rem;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

@media (min-width: 640px) {
    .bce-swatch {
        width: 64px;
        height: 64px;
    }
}

.bce-color-hex {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--bce-text);
    margin-bottom: 0.25rem;
    word-break: break-all;
}

.bce-color-rgb {
    font-size: 0.75rem;
    color: var(--bce-muted);
    margin-bottom: 0.5rem;
}

.bce-color-bar {
    height: 6px;
    background: var(--bce-border);
    border-radius: 3px;
    overflow: hidden;
}

.bce-color-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.bce-color-pct {
    font-size: 0.6875rem;
    color: var(--bce-muted);
    margin-top: 0.25rem;
}

/* Analysis */
.bce-analysis {
    background: var(--bce-surface);
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius-lg);
    box-shadow: var(--bce-shadow);
    padding: 1.25rem;
}

.bce-analysis-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--bce-text);
    margin: 0 0 1rem;
}

.bce-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

@media (min-width: 640px) {
    .bce-metrics {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 900px) {
    .bce-metrics {
        grid-template-columns: repeat(6, 1fr);
    }
}

.bce-metric {
    padding: 1rem;
    background: var(--bce-surface-2);
    border-radius: var(--bce-radius-sm);
    text-align: center;
}

.bce-metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.bce-metric-label {
    font-size: 0.75rem;
    color: var(--bce-muted);
}

/* Palettes */
.bce-palettes {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bce-palette-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .bce-palette-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 900px) {
    .bce-palette-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.bce-palette-card {
    background: var(--bce-surface);
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius);
    box-shadow: var(--bce-shadow);
    padding: 1rem;
}

.bce-palette-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--bce-text);
    margin: 0 0 0.25rem;
}

.bce-palette-desc {
    font-size: 0.8125rem;
    color: var(--bce-muted);
    margin: 0 0 0.75rem;
}

.bce-strip {
    display: flex;
    height: 48px;
    border-radius: var(--bce-radius-sm);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.bce-strip-swatch {
    flex: 1;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s;
}

.bce-strip-swatch:hover {
    transform: scale(1.05);
    z-index: 1;
}

.bce-strip-swatch:focus-visible {
    outline: 2px solid var(--bce-accent);
    outline-offset: -2px;
    z-index: 1;
}

.bce-strip-hex {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.bce-strip-swatch:hover .bce-strip-hex,
.bce-strip-swatch:focus-visible .bce-strip-hex {
    opacity: 1;
}

/* Export */
.bce-export {
    background: var(--bce-surface);
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius-lg);
    box-shadow: var(--bce-shadow);
    padding: 1.25rem;
}

.bce-export-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--bce-text);
    margin: 0 0 0.25rem;
}

.bce-export-desc {
    font-size: 0.875rem;
    color: var(--bce-muted);
    margin: 0 0 1rem;
}

.bce-export-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.bce-export-btn {
    min-height: 40px;
    padding: 0 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bce-text);
    background: var(--bce-surface-2);
    border: 1px solid var(--bce-border);
    border-radius: var(--bce-radius-sm);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.bce-export-btn:hover {
    border-color: var(--bce-border-strong);
    background: var(--bce-border);
}

.bce-export-btn:focus-visible {
    outline: none;
    box-shadow: var(--bce-focus);
}

/* Toast */
.bce-toast {
    position: fixed;
    bottom: 1.5rem;
    left: 1rem;
    right: 1rem;
    max-width: 360px;
    margin: 0 auto;
    padding: 0.875rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #fff;
    background: var(--bce-success);
    border-radius: var(--bce-radius-sm);
    box-shadow: var(--bce-shadow-lg);
    z-index: 1000;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.bce-toast[data-show="true"] {
    transform: translateY(0);
    opacity: 1;
}

.bce-toast[data-type="error"] {
    background: #ff3b30;
}

@media (min-width: 640px) {
    .bce-toast {
        bottom: 1.5rem;
        left: auto;
        right: 1.5rem;
    }
}
