/* HEX to Pantone tool: mobile-first */
.h2p-tool {
    --h2p-bg: #ffffff;
    --h2p-surface: #f8fafc;
    --h2p-border: #e2e8f0;
    --h2p-text: #1e293b;
    --h2p-muted: #64748b;
    --h2p-accent: #7c3aed;
    --h2p-accent-hover: #6d28d9;
    --h2p-accent-on: #ffffff;
    --h2p-success: #059669;
    --h2p-radius: 12px;
    --h2p-radius-sm: 8px;
    background: var(--h2p-bg);
    border-radius: 16px;
    padding: 1.25rem;
    border: 1px solid var(--h2p-border);
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .h2p-tool {
        padding: 1.75rem;
    }
}

/* Input block */
.h2p-input-block {
    margin-bottom: 1.25rem;
}

.h2p-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--h2p-text);
    margin-bottom: 0.5rem;
}

.h2p-hex-row {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.h2p-swatch-wrap {
    position: relative;
    width: 52px;
    min-width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: var(--h2p-radius-sm);
}

.h2p-swatch {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: var(--h2p-radius-sm);
    border: 2px solid var(--h2p-border);
    transition: border-color 0.2s ease;
}

.h2p-color-picker {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: var(--h2p-radius-sm);
    cursor: pointer;
    opacity: 0;
    background: transparent;
}

.h2p-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.h2p-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: var(--h2p-radius-sm);
}

.h2p-hex-input {
    flex: 1;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    
    color: var(--h2p-text);
    background: var(--h2p-surface);
    border: 2px solid var(--h2p-border);
    border-radius: var(--h2p-radius-sm);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.h2p-hex-input::placeholder {
    color: var(--h2p-muted);
}

.h2p-hex-input:focus {
    border-color: var(--h2p-accent);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.h2p-hex-input.h2p-input-invalid {
    border-color: #f87171;
}

.h2p-hint {
    font-size: 0.75rem;
    color: var(--h2p-muted);
    margin-top: 0.375rem;
    margin-bottom: 0;
}

/* Controls */
.h2p-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 480px) {
    .h2p-controls {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
    }
}

.h2p-filters {
    flex: 1;
    min-width: 0;
}

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

.h2p-tolerance-label {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.h2p-tolerance-value {
    font-variant-numeric: tabular-nums;
    color: var(--h2p-text);
}

.h2p-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.h2p-pill {
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--h2p-muted);
    background: var(--h2p-surface);
    border: 1px solid var(--h2p-border);
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.h2p-pill:hover {
    color: var(--h2p-text);
    border-color: var(--h2p-muted);
}

.h2p-pill.h2p-pill-active {
    color: var(--h2p-accent-on);
    background: var(--h2p-accent);
    border-color: var(--h2p-accent);
}

.h2p-tolerance {
    flex: 0 0 auto;
    min-width: 140px;
}

.h2p-tolerance-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--h2p-border);
    border-radius: 3px;
    outline: none;
}

.h2p-tolerance-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--h2p-accent);
    cursor: pointer;
    border: 2px solid var(--h2p-bg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.h2p-tolerance-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--h2p-accent);
    cursor: pointer;
    border: 2px solid var(--h2p-bg);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Actions */
.h2p-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

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

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

.h2p-btn-primary {
    color: var(--h2p-bg);
    background: var(--h2p-accent);
}

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

.h2p-btn-secondary {
    color: var(--h2p-muted);
    background: var(--h2p-surface);
    border: 1px solid var(--h2p-border);
}

.h2p-btn-secondary:hover {
    color: var(--h2p-text);
    border-color: var(--h2p-muted);
}

/* Results */
.h2p-results {
    margin-top: 1rem;
}

.h2p-results[hidden] {
    display: none;
}

.h2p-compare {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 480px) {
    .h2p-compare {
        grid-template-columns: 1fr 1fr;
    }
}

.h2p-compare-card {
    background: var(--h2p-surface);
    border: 1px solid var(--h2p-border);
    border-radius: var(--h2p-radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.h2p-compare-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--h2p-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.h2p-compare-swatch {
    width: 100%;
    aspect-ratio: 1.6;
    max-height: 100px;
    border-radius: var(--h2p-radius-sm);
    border: 1px solid var(--h2p-border);
}

.h2p-compare-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
}

.h2p-compare-hex,
.h2p-compare-code {
    
    font-weight: 600;
    color: var(--h2p-text);
}

.h2p-compare-rgb,
.h2p-compare-accuracy {
    font-variant-numeric: tabular-nums;
    color: var(--h2p-muted);
}

.h2p-compare-accuracy {
    color: var(--h2p-success);
}

.h2p-matches-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.h2p-matches-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--h2p-text);
}

.h2p-copy-hint {
    font-size: 0.75rem;
    color: var(--h2p-muted);
    background: none;
    border: none;
    cursor: default;
    padding: 0;
}

.h2p-matches {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.h2p-match {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--h2p-surface);
    border: 1px solid var(--h2p-border);
    border-radius: var(--h2p-radius-sm);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.h2p-match:hover {
    border-color: var(--h2p-accent);
    background: rgba(124, 58, 237, 0.06);
}

.h2p-match-swatch {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: var(--h2p-radius-sm);
    border: 1px solid var(--h2p-border);
}

.h2p-match-info {
    flex: 1;
    min-width: 0;
}

.h2p-match-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--h2p-text);
    margin: 0 0 0.125rem 0;
}

.h2p-match-code {
    font-size: 0.8125rem;
    
    color: var(--h2p-accent);
}

.h2p-match-meta {
    font-size: 0.75rem;
    color: var(--h2p-muted);
}

.h2p-match-accuracy {
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--h2p-success);
    flex-shrink: 0;
}

/* Empty state */
.h2p-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--h2p-muted);
    font-size: 0.9375rem;
    border: 1px dashed var(--h2p-border);
    border-radius: var(--h2p-radius);
}

.h2p-empty p {
    margin: 0;
}

.h2p-empty strong {
    color: var(--h2p-text);
}

.h2p-results:not([hidden]) ~ .h2p-empty,
.h2p-empty.h2p-empty-hidden {
    display: none;
}

/* Toast */
.h2p-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: #ffffff;
    background: var(--h2p-success);
    border-radius: var(--h2p-radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transform: translateY(120%);
    transition: transform 0.3s ease;
}

.h2p-toast[hidden] {
    display: none;
}

.h2p-toast.h2p-toast-visible {
    transform: translateY(0);
}

.h2p-toast.h2p-toast-error {
    background: #f87171;
}

@media (min-width: 480px) {
    .h2p-toast {
        left: auto;
        right: 1.5rem;
        margin: 0;
    }
}
