:root {
    --bg-color: #0d0d0d;
    --card-bg: rgba(30, 30, 30, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-color: #007aff;
    --accent-hover: #0062cc;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --mono-font: 'JetBrains Mono', monospace;
    --ui-font: 'Inter', system-ui, -apple-system, sans-serif;
    --glass-blur: blur(12px);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--ui-font);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 50% -20%, #1a1a2e 0%, transparent 50%),
        radial-gradient(circle at -20% 50%, #0d0d0d 0%, transparent 50%);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
}

.glass-container {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 540px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 32px;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.drag-handle {
    display: none;
    height: 12px;
    width: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    margin: -4px auto 8px;
    cursor: grab;
    transition: background 0.2s;
}

.drag-handle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.compact .drag-handle {
    display: block;
}

/* Toggle Buttons */
.top-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.pip-toggle-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pip-toggle-btn.supported {
    display: flex;
}

.pip-toggle-btn .btn-text {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.pip-toggle-btn svg {
    width: 16px;
    height: 16px;
}

.pip-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: scale(1.02);
}

/* Main App UI Adjustments for PiP Mode */
.pip-mode-active header,
.pip-mode-active footer,
.pip-mode-active .saved-section {
    opacity: 0.4;
    pointer-events: none;
}

.pip-body {
    background: var(--bg-color) !important;
    margin: 0;
    padding: 10px !important;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.pip-body .glass-container {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    width: 100% !important;
    max-width: none !important;
}

.pip-body #copyButton {
    padding: 8px;
    font-size: 12px;
}

.pip-body #valueSlider {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 200px !important;
    height: 6px !important;
    background: rgba(255, 255, 255, 0.2) !important;
    border-radius: 3px !important;
    outline: none !important;
    margin: 15px 0 !important;
    cursor: pointer !important;
}

.pip-body #valueSlider::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 20px !important;
    height: 20px !important;
    background: #ffffff !important;
    border: 2px solid var(--accent-color) !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5) !important;
    cursor: ew-resize !important;
}

.pip-body #colorWheel {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5) !important;
}

.pip-body .wheel-section {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
}

.pip-body .slider-wrapper {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    width: 100% !important;
    align-items: center !important;
}

.pip-body .slider-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
}

header {
    text-align: center;
}

h1 {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.title-suffix {
    font-size: 18px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.wheel-section {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
}

.wheel-wrapper {
    position: relative;
    line-height: 0;
}

#colorWheel {
    border-radius: 50%;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(255, 255, 255, 0.05);
    cursor: crosshair;
    transition: transform 0.2s ease;
}

#colorWheel:hover {
    transform: scale(1.02);
}

.eye-dropper-btn {
    position: absolute;
    bottom: -10px;
    right: -10px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
    padding: 0;
}

.eye-dropper-btn.supported {
    display: flex;
}

.eye-dropper-btn svg {
    width: 20px;
    height: 20px;
}

.eye-dropper-btn:hover {
    transform: scale(1.1) rotate(-10deg);
    background: var(--accent-hover);
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.5);
}

.eye-dropper-btn:active {
    transform: scale(0.95);
}

.drop-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    border: 2px dashed rgba(255, 255, 255, 0.3);
}

.wheel-wrapper:hover .drop-hint {
    /* Optional: show hint on hover or only on dragover */
}

.slider-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.slider-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

input[type="range"]#valueSlider {
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    width: 20px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
}

/* Custom Thumb - note that slider-vertical often overrides custom thumbs in some browsers */
input[type="range"]#valueSlider::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    border: 2px solid var(--accent-color);
}

.controls-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.select-wrapper label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

select:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

#colorInfo {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.display-container {
    width: 100%;
    height: 80px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

#colorDisplay {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
}

.data-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

#colorInfo {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.harmonies-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 4px;
}

.harmony-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.harmony-swatch {
    width: 100%;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.harmony-swatch:hover {
    transform: scale(1.05);
}

.harmony-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-item {
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.data-item .label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.data-item .value {
    font-family: var(--mono-font);
    font-size: 13px;
    color: var(--text-primary);
}

#hexInput {
    background: transparent;
    border: none;
    color: var(--accent-color);
    font-family: var(--mono-font);
    font-size: 13px;
    text-align: right;
    width: 100px;
    outline: none;
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 12px;
}

button {
    font-family: var(--ui-font);
    font-weight: 600;
    font-size: 14px;
    padding: 14px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
}

.primary-button {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.2);
}

#copyButton {
    background: #007aff;
    /* Primary Action */
}

#saveButton {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.primary-button.success {
    background: #28a745 !important;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4) !important;
    transform: scale(1.05);
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 122, 255, 0.3);
    filter: brightness(1.1);
}

#saveButton:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.primary-button:active,
#saveButton:active {
    transform: translateY(0);
}

.secondary-button {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.secondary-button:hover {
    background: rgba(255, 255, 255, 0.12);
}

h3 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.clear-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

#clearSavedColors {
    background: transparent;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
}

#clearSavedColors:hover {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
    border-color: rgba(255, 59, 48, 0.3);
}

#savedColors {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 56px;
    position: relative;
    border: 1px solid var(--border-color);
}

.saved-color {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.saved-color:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

#savedColors.drag-over {
    background: rgba(0, 122, 255, 0.15);
    border-color: var(--accent-color);
    box-shadow: inset 0 0 15px rgba(0, 122, 255, 0.2);
}

.trash-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 59, 48, 0.05);
    border: 1px dashed rgba(255, 59, 48, 0.2);
    border-radius: 12px;
    padding: 12px;
    margin-top: 12px;
    color: #ff3b30;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.trash-zone.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

.trash-zone.drag-over {
    background: rgba(255, 59, 48, 0.15);
    border-style: solid;
    border-color: #ff3b30;
    box-shadow: 0 0 15px rgba(255, 59, 48, 0.2);
    transform: scale(1.02);
}

.trash-svg {
    width: 18px;
    height: 18px;
}

.trash-lid {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: 17px 7px;
}

.trash-zone.visible .trash-lid {
    transform: rotate(-35deg) translateY(-2px);
}

.trash-zone.drag-over .trash-lid {
    transform: rotate(-60deg) translateY(-4px);
}

.harmony-swatch,
#colorDisplay {
    cursor: grab;
}

.harmony-swatch:active,
#colorDisplay:active {
    cursor: grabbing;
}

.saved-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 16px;
}

footer {
    text-align: center;
    color: var(--text-secondary);
    font-size: 11px;
    border-top: 1px solid var(--border-color);
    padding-top: 24px;
    margin-top: 8px;
}

.tips-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.tip-item {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tip-item:hover {
    opacity: 1;
}

.tip-item svg {
    width: 14px;
    height: 14px;
    color: var(--accent-color);
}

.tip-item span {
    font-weight: 500;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    body {
        padding: 10px;
        align-items: flex-start;
    }

    .glass-container {
        padding: 24px 20px;
        gap: 24px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        min-height: 100vh;
    }

    h1 {
        font-size: 22px;
    }

    .title-suffix {
        font-size: 15px;
    }

    .subtitle {
        font-size: 11px;
    }

    .top-controls {
        position: static;
        margin-bottom: -10px;
        justify-content: flex-end;
    }

    .pip-toggle-btn {
        padding: 4px 10px;
        height: 32px;
    }

    .wheel-section {
        flex-direction: column;
        gap: 24px;
    }

    .wheel-wrapper {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    #colorWheel {
        max-width: 100%;
        height: auto !important;
    }

    .slider-wrapper {
        width: 100%;
        padding: 0 10px;
    }

    input[type="range"]#valueSlider {
        -webkit-appearance: none;
        appearance: none;
        width: 100%;
        height: 8px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 4px;
        writing-mode: horizontal-tb;
    }

    input[type="range"]#valueSlider::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 24px;
        height: 24px;
        background: #ffffff;
        border-radius: 50%;
        border: 2px solid var(--accent-color);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }

    .actions {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .harmonies-container {
        gap: 8px;
    }

    .info-card {
        padding: 10px;
    }

    .data-item {
        padding: 6px 8px;
    }

    .data-item .value {
        font-size: 12px;
    }

    .saved-color {
        width: 44px;
        height: 44px;
    }

    #savedColors {
        gap: 12px;
        padding: 16px;
    }

    .tips-container {
        font-size: 10px;
    }

    .tip-item {
        opacity: 0.9;
    }
}