/* =========================================================
   143TOOL - Color Picker Styles
   Version: 1.0.0
   ========================================================= */

.cp-card {
    padding: 24px;
    max-width: 700px;
    margin: 0 auto;
}

/* ---------- PREVIEW ---------- */
.cp-preview {
    width: 100%;
    height: 160px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .3s ease;
    background: #e91e63;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .08);
}

.cp-preview-inner {
    text-align: center;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, .3);
    transition: color .3s ease;
}

.cp-preview-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: .85;
    margin-bottom: 4px;
}

.cp-preview-hex {
    font-size: 32px;
    font-weight: 900;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 1px;
}

/* ---------- INPUT ROW ---------- */
.cp-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: stretch;
}

.cp-native-picker-wrap {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: border-color .2s ease, transform .15s ease;
    display: grid;
    place-items: center;
    background: var(--surface);
}

.cp-native-picker-wrap:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.cp-native-picker {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: 0;
}

.cp-native-picker-icon {
    font-size: 20px;
    pointer-events: none;
}

.cp-hex-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--body-bg);
    color: var(--text);
    font-size: 17px;
    font-weight: 800;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: .5px;
    text-transform: uppercase;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.cp-hex-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}

.cp-action-btn {
    width: 50px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-md);
    font-size: 20px;
    cursor: pointer;
    transition: all .15s ease;
    font-family: inherit;
}

.cp-action-btn:hover {
    border-color: var(--primary);
    background: color-mix(in srgb, var(--primary) 8%, var(--surface));
    transform: scale(1.05);
}

.cp-action-btn:active {
    transform: scale(.95);
}

/* ---------- FORMAT TABS ---------- */
.cp-formats-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 5px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}

.cp-format-tab {
    padding: 10px 8px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 13px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .18s ease;
    font-family: inherit;
}

.cp-format-tab:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.cp-format-tab.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    box-shadow: 0 4px 12px rgba(233, 30, 99, .22);
}

.cp-format-panel {
    display: none;
    margin-bottom: 18px;
}

.cp-format-panel.active {
    display: block;
    animation: cpFade .2s ease;
}

@keyframes cpFade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- SLIDERS ---------- */
.cp-slider-row {
    display: grid;
    grid-template-columns: 28px 1fr 68px;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.cp-slider-row label {
    font-size: 13px;
    font-weight: 800;
    color: var(--text);
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.cp-slider {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    cursor: pointer;
}

.cp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--text);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

.cp-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--text);
    cursor: pointer;
}

/* Color-coded slider tracks */
.cp-slider-red {
    background: linear-gradient(90deg, #000, #f00);
}
.cp-slider-green {
    background: linear-gradient(90deg, #000, #0f0);
}
.cp-slider-blue {
    background: linear-gradient(90deg, #000, #00f);
}
.cp-slider-hue {
    background: linear-gradient(90deg,
        #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.cp-slider-sat {
    background: linear-gradient(90deg, #888, #e91e63);
}
.cp-slider-light {
    background: linear-gradient(90deg, #000, #e91e63, #fff);
}

.cp-num-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--body-bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    transition: border-color .15s ease;
}

.cp-num-input:focus {
    border-color: var(--primary);
    outline: none;
}

.cp-num-input::-webkit-outer-spin-button,
.cp-num-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cp-num-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Format output */
.cp-format-output {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding: 12px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.cp-format-output code {
    flex: 1;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    word-break: break-all;
}

.cp-copy-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 15px;
    transition: all .15s ease;
    font-family: inherit;
}

.cp-copy-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 6%, transparent);
}

/* ---------- SECTIONS ---------- */
.cp-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.cp-section-title {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: .3px;
}

/* Harmony */
.cp-harmony-group {
    margin-bottom: 14px;
}

.cp-harmony-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.cp-harmony-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.cp-color-swatch {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all .15s ease;
    position: relative;
    overflow: hidden;
}

.cp-color-swatch:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}

.cp-color-swatch:active {
    transform: scale(.95);
}

.cp-swatch-label {
    position: absolute;
    inset: auto 0 0 0;
    padding: 2px 0;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    text-align: center;
    font-family: ui-monospace, monospace;
}

/* Shades row */
.cp-shades-row {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
}

.cp-shades-row .cp-color-swatch {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
}

/* ---------- CONTRAST ---------- */
.cp-contrast-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.cp-contrast-item {
    padding: 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.cp-contrast-sample {
    height: 80px;
    display: grid;
    place-items: center;
    font-size: 18px;
    font-weight: 800;
}

.cp-contrast-on-black {
    background: #000;
}

.cp-contrast-on-white {
    background: #fff;
    color: #000;
}

.cp-contrast-info {
    padding: 10px 14px;
}

.cp-contrast-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.cp-contrast-ratio {
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.cp-contrast-ratio.cp-pass {
    color: #10b981;
}

.cp-contrast-ratio.cp-fail {
    color: #ef4444;
}

/* ---------- CSS OUTPUT ---------- */
.cp-css-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.cp-css-tab {
    padding: 7px 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all .15s ease;
    font-family: inherit;
}

.cp-css-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cp-css-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    border-color: transparent;
}

.cp-css-output {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--body-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.cp-css-output pre {
    flex: 1;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---------- RECENT ---------- */
.cp-recent-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.cp-recent-row .cp-color-swatch {
    width: 42px;
    height: 42px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 620px) {
    .cp-card { padding: 16px; }
    .cp-preview { height: 120px; }
    .cp-preview-hex { font-size: 24px; }
    .cp-hex-input { font-size: 15px; }
    .cp-native-picker-wrap, .cp-action-btn { width: 44px; height: 44px; }
    .cp-formats-tabs { grid-template-columns: repeat(2, 1fr); }
    .cp-slider-row {
        grid-template-columns: 22px 1fr 60px;
        gap: 8px;
    }
    .cp-contrast-grid { grid-template-columns: 1fr; }
    .cp-color-swatch { width: 48px; height: 48px; }
    .cp-shades-row .cp-color-swatch { width: 40px; height: 40px; }
}

/* ---------- ARTICLE (SEO) ---------- */
.tool-article {
    max-width: 800px;
    margin: 60px auto 40px;
    padding: 30px 0;
    border-top: 1px solid var(--border);
}
.tool-article h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    margin: 36px 0 14px;
    line-height: 1.3;
    letter-spacing: -.4px;
}
.tool-article h2:first-child { margin-top: 0; }
.tool-article h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 24px 0 10px;
    line-height: 1.4;
}
.tool-article p {
    font-size: 16px;
    line-height: 1.75;
    color: var(--text-muted);
    margin: 0 0 16px;
}
.tool-article ul, .tool-article ol {
    padding-left: 22px;
    margin: 0 0 18px;
}
.tool-article li {
    font-size: 16px;
    line-height: 1.75;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.tool-article strong { color: var(--text); font-weight: 700; }
.tool-article a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}
.tool-article a:hover { color: var(--primary-hover); text-decoration: underline; }

@media (max-width: 620px) {
    .tool-article { padding: 20px 0; margin: 40px auto 20px; }
    .tool-article h2 { font-size: 20px; margin: 28px 0 12px; }
    .tool-article h3 { font-size: 16px; margin: 20px 0 8px; }
    .tool-article p, .tool-article li { font-size: 15px; line-height: 1.7; }
}

/* =========================================================
   MOBILE-FRIENDLY OVERRIDES
   Add this block at the END of the file
   ========================================================= */

/* ---------- Tablet (max-width: 768px) ---------- */
@media (max-width: 768px) {
    .cp-card {
        padding: 18px;
        max-width: 100%;
    }

    .cp-preview {
        height: 140px;
    }

    .cp-preview-hex {
        font-size: 28px;
    }

    /* Bigger touch targets for inputs */
    .cp-native-picker-wrap,
    .cp-action-btn {
        width: 48px;
        height: 48px;
    }

    .cp-hex-input {
        font-size: 16px;
        padding: 12px 14px;
    }

    /* Format tabs — 2x2 grid on tablets */
    .cp-formats-tabs {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .cp-format-tab {
        padding: 12px 10px;
        font-size: 14px;
        min-height: 44px;
    }

    /* Sliders — bigger thumb */
    .cp-slider-row {
        grid-template-columns: 26px 1fr 70px;
        gap: 10px;
        margin-bottom: 12px;
    }

    .cp-slider {
        height: 10px;
    }

    .cp-slider::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
    }

    .cp-slider::-moz-range-thumb {
        width: 26px;
        height: 26px;
    }

    .cp-num-input {
        padding: 10px 8px;
        font-size: 15px;
        min-height: 44px;
    }

    /* Swatches — bigger */
    .cp-color-swatch {
        width: 60px;
        height: 60px;
    }

    .cp-shades-row .cp-color-swatch {
        width: 52px;
        height: 52px;
    }

    /* Copy buttons — bigger */
    .cp-copy-btn {
        padding: 10px 14px;
        font-size: 16px;
        min-width: 44px;
        min-height: 44px;
    }

    .cp-css-tab {
        padding: 10px 16px;
        font-size: 13px;
        min-height: 44px;
    }

    .cp-format-output {
        padding: 14px 16px;
        flex-wrap: wrap;
    }

    .cp-format-output code {
        font-size: 14px;
        min-width: 0;
        word-break: break-all;
    }
}

/* ---------- Mobile (max-width: 620px) ---------- */
@media (max-width: 620px) {
    .cp-card {
        padding: 14px;
    }

    .cp-preview {
        height: 130px;
        border-radius: var(--radius-md);
    }

    .cp-preview-label {
        font-size: 11px;
    }

    .cp-preview-hex {
        font-size: 26px;
        letter-spacing: .5px;
    }

    /* Input row — stacked */
    .cp-input-row {
        gap: 6px;
        flex-wrap: wrap;
    }

    .cp-native-picker-wrap {
        width: 52px;
        height: 52px;
        flex-shrink: 0;
    }

    .cp-hex-input {
        flex: 1;
        min-width: 0;
        font-size: 16px;
        padding: 13px 14px;
        min-height: 52px;
    }

    .cp-action-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
        flex-shrink: 0;
    }

    /* Format tabs — single column, full width */
    .cp-formats-tabs {
        grid-template-columns: repeat(2, 1fr);
        gap: 5px;
        padding: 4px;
    }

    .cp-format-tab {
        padding: 13px 10px;
        font-size: 14px;
        font-weight: 800;
        min-height: 48px;
    }

    /* Sliders — very thumb-friendly */
    .cp-slider-row {
        grid-template-columns: 30px 1fr 76px;
        gap: 10px;
        margin-bottom: 14px;
        align-items: center;
    }

    .cp-slider-row label {
        font-size: 15px;
        font-weight: 900;
    }

    .cp-slider {
        height: 12px;
        border-radius: 999px;
    }

    .cp-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
        box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
    }

    .cp-slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }

    .cp-num-input {
        padding: 12px 6px;
        font-size: 15px;
        min-height: 48px;
        font-weight: 800;
    }

    /* Format output */
    .cp-format-output {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 10px;
        margin-top: 16px;
    }

    .cp-format-output code {
        font-size: 13px;
        flex: 1 1 100%;
        order: 1;
    }

    .cp-copy-btn {
        flex: 1 1 100%;
        order: 2;
        padding: 12px;
        font-size: 14px;
        font-weight: 700;
        min-height: 48px;
        background: color-mix(in srgb, var(--primary) 8%, var(--surface));
        color: var(--primary);
        border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
    }

    /* Sections */
    .cp-section {
        margin-top: 20px;
        padding-top: 16px;
    }

    .cp-section-title {
        font-size: 14px;
        margin-bottom: 12px;
    }

    /* Harmony swatches — bigger grid */
    .cp-harmony-row {
        gap: 10px;
    }

    .cp-color-swatch {
        width: 68px;
        height: 68px;
        border-radius: 12px;
    }

    .cp-swatch-label {
        font-size: 10px;
        padding: 3px 0;
    }

    /* Shades — horizontal scroll, bigger swatches */
    .cp-shades-row {
        gap: 6px;
        padding: 4px 0 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .cp-shades-row::-webkit-scrollbar {
        display: none;
    }

    .cp-shades-row .cp-color-swatch {
        width: 56px;
        height: 56px;
        flex-shrink: 0;
        border-radius: 10px;
    }

    /* Contrast grid — stacked */
    .cp-contrast-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .cp-contrast-sample {
        height: 90px;
        font-size: 20px;
    }

    .cp-contrast-ratio {
        font-size: 16px;
    }

    /* CSS tabs — wrap nicely */
    .cp-css-tabs {
        gap: 6px;
    }

    .cp-css-tab {
        flex: 1 1 calc(50% - 3px);
        padding: 11px 12px;
        font-size: 13px;
        min-height: 44px;
        font-weight: 700;
    }

    .cp-css-output {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 14px;
    }

    .cp-css-output pre {
        flex: 1 1 100%;
        font-size: 13px;
        order: 1;
    }

    .cp-css-output .cp-copy-btn {
        flex: 1 1 100%;
        order: 2;
        min-height: 44px;
    }

    /* Recent swatches */
    .cp-recent-row {
        gap: 8px;
    }

    .cp-recent-row .cp-color-swatch {
        width: 52px;
        height: 52px;
    }
}

/* ---------- Small phones (max-width: 380px) ---------- */
@media (max-width: 380px) {
    .cp-card {
        padding: 12px;
    }

    .cp-preview {
        height: 110px;
    }

    .cp-preview-hex {
        font-size: 22px;
    }

    .cp-hex-input {
        font-size: 15px;
        padding: 12px 12px;
    }

    .cp-native-picker-wrap,
    .cp-action-btn {
        width: 46px;
        height: 46px;
    }

    .cp-slider-row {
        grid-template-columns: 24px 1fr 64px;
        gap: 8px;
    }

    .cp-slider::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
    }

    .cp-color-swatch {
        width: 60px;
        height: 60px;
    }

    .cp-shades-row .cp-color-swatch {
        width: 50px;
        height: 50px;
    }

    .cp-section-title {
        font-size: 13px;
    }
}

/* ---------- Landscape phones: short height ---------- */
@media (max-height: 500px) and (orientation: landscape) {
    .cp-preview {
        height: 90px;
    }
    .cp-preview-hex {
        font-size: 22px;
    }
}

/* ---------- Touch device enhancements ---------- */
@media (hover: none) and (pointer: coarse) {
    /* Bigger thumb hit areas */
    .cp-slider::-webkit-slider-thumb {
        width: 26px;
        height: 26px;
    }

    .cp-slider::-moz-range-thumb {
        width: 26px;
        height: 26px;
    }

    /* Prevent zoom-on-focus for inputs (iOS) */
    .cp-hex-input,
    .cp-num-input {
        font-size: 16px;  /* must be 16px+ to prevent iOS auto-zoom */
    }

    /* Larger touch target for swatches */
    .cp-color-swatch {
        min-width: 56px;
        min-height: 56px;
    }

    /* Copy buttons easy to tap */
    .cp-copy-btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Smooth scroll for shades row */
    .cp-shades-row {
        scroll-snap-type: x proximity;
    }

    .cp-shades-row .cp-color-swatch {
        scroll-snap-align: start;
    }
}

/* ---------- Prevent iOS tap highlight ---------- */
.cp-color-swatch,
.cp-action-btn,
.cp-copy-btn,
.cp-format-tab,
.cp-css-tab {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ---------- Prevent iOS auto-zoom on inputs ---------- */
@media (max-width: 768px) {
    .cp-hex-input,
    .cp-num-input {
        font-size: 16px !important;
    }
}