:root {
    --ap-navy: #010F1C;
    --ap-gold: #f0a500;
    --ap-bg: #ffffff;
    --ap-bd: #d1d5db;
    --ap-bd-light: #e5e7eb;
    --ap-text: #374151;
    --ap-text-dim: #9ca3af;
    --ap-text-dark: #010F1C;
    --ap-rad: 10px;
    --ap-tr: 0.2s ease;
}

#ap-toggle-btn {
    position: fixed;
    left: 15px;
    bottom: 15px;
    width: 48px;
    height: 48px;
    background: var(--ap-navy);
    border: 2px solid #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: #fff;
    cursor: pointer;
    box-shadow: none;
    z-index: 999999;
    transition: transform var(--ap-tr);
}

#ap-toggle-btn:hover {
    transform: scale(1.1);
}

#ap-toggle-btn i {
    transition: transform 0.6s ease;
}

#ap-toggle-btn:hover i {
    transform: rotate(180deg);
}

@keyframes apSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#ap-panel {
    position: fixed;
    bottom: -800px;
    left: 10px;
    width: 270px;
    background: var(--ap-bg);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    transition: bottom 0.4s cubic-bezier(.4,0,.2,1);
    z-index: 999999;
    overflow: hidden;
}

#ap-panel.open {
    bottom: 72px;
}

#ap-panel .ap-header {
    background: var(--ap-navy);
    color: #fff;
    padding: 0 16px;
    height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

#ap-panel .ap-header i {
    font-size: 14px;
    color: var(--ap-gold);
    opacity: .9;
}

#ap-close-btn:hover,
#ap-close-btn:focus,
#ap-close-btn:active {
    background: rgba(255,255,255,0.1) !important;
    color: rgba(255,255,255,0.8) !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

#ap-panel .ap-body {
    padding: 16px;
}

.ap-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ap-text-dim);
    margin: 14px 0 6px;
}

.ap-label:first-child {
    margin-top: 0;
}

.ap-divider {
    border: none;
    border-top: 1px solid var(--ap-bd-light);
    margin: 14px 0;
}

#ap-color-picker {
    width: 100%;
    height: 44px;
    padding: 2px;
    border: 1px solid var(--ap-bd);
    border-radius: var(--ap-rad);
    cursor: pointer;
    background: none;
    box-sizing: border-box;
}

#ap-color-picker:hover {
    border-color: var(--ap-navy);
}

#ap-hex-input {
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--ap-bd);
    border-radius: var(--ap-rad);
    font-size: 13px;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    margin-top: 8px;
    color: var(--ap-text-dark);
    background: #f9fafb;
    transition: border-color var(--ap-tr), box-shadow var(--ap-tr);
    box-sizing: border-box;
}

#ap-hex-input:focus {
    outline: none;
    border-color: var(--ap-gold);
    box-shadow: 0 0 0 3px rgba(240, 165, 0, .12);
    background: #fff;
}

#ap-font-select {
    width: 100%;
    height: 40px;
    padding: 0 32px 0 12px;
    border: 1px solid var(--ap-bd);
    border-radius: var(--ap-rad);
    font-size: 13px;
    color: var(--ap-text-dark);
    background-color: #f9fafb;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    transition: border-color var(--ap-tr), box-shadow var(--ap-tr);
    box-sizing: border-box;
}

#ap-font-select:hover {
    border-color: var(--ap-navy);
}

#ap-font-select:focus {
    outline: none;
    border-color: var(--ap-gold);
    box-shadow: 0 0 0 3px rgba(240, 165, 0, .12);
    background: #fff;
}

#ap-presets {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin: 8px 0 0;
}

.ap-preset {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid var(--ap-bg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ap-preset:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

.ap-preset.selected {
    border-color: var(--ap-gold);
}

.ap-preset.selected::after {
    content: "\2713";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    pointer-events: none;
}

.ap-tools {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.ap-btn {
    flex: 1;
    height: 36px;
    padding: 0 8px;
    background: linear-gradient(180deg, #fff 0%, #eaecef 100%);
    border: 1px solid #b0b7c3;
    border-bottom-color: #8d9099;
    border-radius: 8px;
    box-shadow: rgba(255,255,255,.7) 0 1px 0 inset, 0 1px 3px rgba(0,0,0,.08);
    color: #3a3a3a;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    user-select: none;
    transition: background var(--ap-tr), box-shadow var(--ap-tr);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    line-height: 1;
}

.ap-btn:hover {
    background: linear-gradient(180deg, #f5f7fa 0%, #e2e5e9 100%);
    color: #000;
    box-shadow: rgba(255,255,255,.7) 0 1px 0 inset, 0 2px 6px rgba(0,0,0,.12);
}

.ap-btn:active {
    background: linear-gradient(180deg, #e8eaed 0%, #d8dade 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,.1);
}

.ap-btn:focus {
    outline: none;
    border-color: var(--ap-gold);
    box-shadow: 0 0 0 3px rgba(240, 165, 0, .18);
}

#ap-random-btn {
    flex: 0 0 38px;
    font-size: 13px;
}

/* RTL */
[dir="rtl"] #ap-toggle-btn {
    left: auto;
    right: 15px;
}

[dir="rtl"] #ap-panel {
    left: auto;
    right: 10px;
}

[dir="rtl"] #ap-font-select {
    padding: 0 12px 0 32px;
    background-position: left 12px center;
}

/* Mobile */
@media (max-width: 480px) {
    #ap-panel {
        width: calc(100% - 20px);
        left: 10px;
    }

    [dir="rtl"] #ap-panel {
        right: 10px;
    }
}
