* {
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
margin: 0;
padding: 0;
}

html, body {
    background: #111;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    height: 100%;
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
}

/* ===================== TOPBAR ===================== */

.topbar {
    height: 52px;
    min-height: 52px;
    background: #1c1c1e;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    border-bottom: 1px solid #2c2c2e;
    z-index: 10;
    flex-shrink: 0;
}

.topbar-brand {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.limit-pill {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #2c2c2e;
    border-radius: 20px;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: 600;
}

.limit-icon {
    font-size: 14px;
}

/* ===================== ICON BUTTON ===================== */

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: #2c2c2e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.icon-btn:active {
    background: #3a3a3c;
}

/* ===================== LANG DROPDOWN ===================== */

.lang-dropdown {
    position: relative;
}

.lang-btn {
    height: 38px;
    padding: 0 10px;
    border-radius: 12px;
    border: none;
    background: #2c2c2e;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-size: 18px;
}

.lang-arrow {
    font-size: 11px;
    color: #a1a1aa;
}

.lang-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #2c2c2e;
    border-radius: 14px;
    overflow: hidden;
    min-width: 150px;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.08);
}

.lang-menu.open {
    display: block;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s;
}

.lang-option:hover {
    background: rgba(255,255,255,0.08);
}

.lang-option.active {
    color: #0a84ff;
    font-weight: 600;
}

.lang-flag {
    font-size: 20px;
}

/* ===================== MAIN ===================== */

.main {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* ===================== CANVAS ===================== */

.canvas-wrap {
    position: relative;
    flex: 1;
    overflow: hidden;
    background: #f2f2f7;
}

#canvas {
display: block;
width: 100%;
height: 100%;
touch-action: none;
}

/* ===================== FLOATING ELEMENTS ===================== */

.float-coords {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(28,28,30,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
    letter-spacing: 0.2px;
}

.coords-sep {
    margin: 0 2px;
    color: #a1a1aa;
}

.float-btn {
    position: absolute;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: none;
    background: rgba(28,28,30,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.float-btn:active {
    background: rgba(58,58,60,0.9);
}

.float-center {
    top: 10px;
    right: 10px;
}

.status-toast {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(28,28,30,0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 12px;
    max-width: calc(100% - 24px);
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===================== BOTTOM PANEL ===================== */

.bottom-panel {
    background: #1c1c1e;
    border-top: 1px solid #2c2c2e;
    padding: 10px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

/* ===================== MODE SWITCH ===================== */

.mode-switch {
    display: flex;
    gap: 8px;
}

.mode-btn {
    flex: 1;
    height: 46px;
    border-radius: 14px;
    border: none;
    background: #2c2c2e;
    color: #a1a1aa;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mode-btn.active {
    background: #0a84ff;
    color: #fff;
}

.mode-btn svg {
    flex-shrink: 0;
}

/* ===================== PALETTE ===================== */

.palette {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.palette::-webkit-scrollbar {
    display: none;
}

.color-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 12px;
    border: 3px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
}

.color-btn.active {
    border-color: #fff;
    transform: scale(1.15);
}

/* ===================== DRAWER ===================== */

.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 50;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.drawer-overlay.open {
    display: block;
}

.drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1c1c1e;
    border-radius: 20px 20px 0 0;
    z-index: 51;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.drawer.open {
    transform: translateY(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.drawer-title {
    font-size: 17px;
    font-weight: 700;
}

.drawer-close {
    background: #2c2c2e;
}

.drawer-body {
    overflow-y: auto;
    padding: 12px 16px 32px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.drawer-section {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drawer-section:last-child {
    border-bottom: none;
}

.drawer-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.drawer-row {
    display: flex;
    gap: 8px;
}

.drawer-input {
    flex: 1;
    height: 44px;
    border: 1px solid rgba(255,255,255,0.1);
    background: #2c2c2e;
    color: #fff;
    border-radius: 12px;
    padding: 0 12px;
    font-size: 15px;
    min-width: 0;
}

.drawer-input.full-width {
    width: 100%;
}

.drawer-input:focus {
    outline: none;
    border-color: #0a84ff;
}

.drawer-btn {
    flex: 1;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: #2c2c2e;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 12px;
    transition: background 0.15s;
}

.drawer-btn:active {
    background: #3a3a3c;
}

.drawer-btn.full-width {
    width: 100%;
    flex: none;
}

.drawer-action-btn {
    height: 44px;
    padding: 0 18px;
    border-radius: 12px;
    border: none;
    background: #0a84ff;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.drawer-action-btn:active {
    background: #0070d8;
}

/* ===================== MODAL ===================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 60;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: #1c1c1e;
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
}

.modal-close {
    background: #2c2c2e;
}

.modal-body {
    overflow-y: auto;
    padding: 12px 16px 32px;
    flex: 1;
}

/* ===================== HISTORY ITEMS ===================== */

.history-item {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.history-item-coords {
    font-weight: 700;
    font-size: 14px;
}

.history-item-colors {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid rgba(255,255,255,0.15);
}

.history-item-meta {
    color: #a1a1aa;
    font-size: 12px;
}

.history-item-time {
    color: #6b7280;
    font-size: 11px;
}

.history-empty {
    text-align: center;
    color: #6b7280;
    padding: 32px 0;
    font-size: 14px;
}

/* ===================== DESKTOP ===================== */

@media (min-width: 768px) {
    .drawer {
        left: auto;
        right: 0;
        top: 0;
        bottom: 0;
        border-radius: 0;
        max-height: 100vh;
        width: 340px;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .drawer.open {
        transform: translateX(0);
    }

    .modal-overlay {
        align-items: center;
        padding: 20px;
    }

    .modal {
        border-radius: 20px;
        max-width: 520px;
        max-height: 80vh;
    }

    .bottom-panel {
        padding: 10px 16px 12px;
    }

    .mode-btn {
        height: 42px;
    }

    .color-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }
}

/* ===================== HISTORICAL MODE INDICATOR ===================== */

.historical-badge {
    display: none;
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 159, 10, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
}

.historical-badge.visible {
    display: block;
}
/* ===================== PALETTE WRAP ===================== */

.palette-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.palette-tools {
    display: flex;
    gap: 8px;
}

.tool-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: none;
    background: #2c2c2e;
    color: #a1a1aa;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.tool-btn:active {
    background: #3a3a3c;
}

.tool-btn.active {
    background: #ff9f0a;
    color: #fff;
}

/* ===================== COLOR PICKER MODAL ===================== */

.modal-color {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-color .modal-body {
    overflow-y: auto;
    flex: 1;
    padding-bottom: 24px;
}

.color-picker-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding-bottom: 16px;
}
.apply-color-btn {
    display: block;
    width: 100%;
    height: 52px;
    border-radius: 14px;
    border: none;
    background: #0a84ff;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 8px;
    flex-shrink: 0;
}

.apply-color-btn:active {
    background: #0070d8;
}
#color-picker-input {
width: 100%;
height: 60px;
border: none;
border-radius: 14px;
cursor: pointer;
padding: 4px;
background: #2c2c2e;
}

.color-preview-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-preview-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 2px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
    background: #ff0000;
}

.color-hex-display {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
    font-family: monospace;
}

.rgb-inputs {
    display: flex;
    gap: 8px;
}

.rgb-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rgb-field label {
    font-size: 11px;
    font-weight: 700;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.rgb-field input {
    text-align: center;
    padding: 0 4px;
}

.custom-palette-title {
    font-size: 12px;
    font-weight: 600;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.custom-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.custom-palette-swatch {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
}

.custom-palette-swatch:active {
    transform: scale(0.92);
}

.custom-palette-swatch.active {
    border-color: #fff;
    transform: scale(1.1);
}

/* ===================== LINE MODE ===================== */

.line-preview-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 159, 10, 0.8);
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 4;
}

/* ===================== EYEDROPPER MODE ===================== */

.eyedropper-active {
    cursor: crosshair !important;
}

/* ===================== OPTIMISTIC PIXEL ===================== */

.optimistic-indicator {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(52, 199, 89, 0.9);
    color: #fff;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 5;
}

.optimistic-indicator.visible {
    opacity: 1;
}
/* ===================== COLOR MODAL ===================== */

#color-modal-wrap {
display: none;
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.7);
z-index: 999;
align-items: flex-end;
justify-content: center;
}

#color-modal-wrap.open {
display: flex;
}

#color-modal-box {
background: #1c1c1e;
width: 100%;
max-width: 480px;
border-radius: 20px 20px 0 0;
max-height: 90vh;
display: flex;
flex-direction: column;
overflow: hidden;
}

#color-modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 16px 14px;
border-bottom: 1px solid rgba(255,255,255,0.08);
flex-shrink: 0;
font-size: 17px;
font-weight: 700;
color: #fff;
}

#color-modal-close-btn {
width: 30px;
height: 30px;
border-radius: 50%;
border: none;
background: #3a3a3c;
color: #fff;
font-size: 14px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
line-height: 1;
flex-shrink: 0;
}

#color-modal-close-btn:active {
background: #48484a;
}

#color-modal-content {
flex: 1;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
padding: 16px;
display: flex;
flex-direction: column;
gap: 14px;
}

#pc-color-picker {
display: block;
width: 100%;
height: 64px;
border: none;
border-radius: 14px;
cursor: pointer;
padding: 4px;
background: #2c2c2e;
-webkit-appearance: none;
appearance: none;
}

#pc-color-picker::-webkit-color-swatch-wrapper {
padding: 0;
border-radius: 10px;
overflow: hidden;
}

#pc-color-picker::-webkit-color-swatch {
border: none;
border-radius: 10px;
}

#pc-color-picker::-moz-color-swatch {
border: none;
border-radius: 10px;
}

#color-preview-row {
display: flex;
align-items: center;
gap: 14px;
}

#color-preview-box {
width: 52px;
height: 52px;
min-width: 52px;
border-radius: 14px;
border: 2px solid rgba(255,255,255,0.15);
background: #ff0000;
flex-shrink: 0;
}

#color-hex-display {
font-size: 24px;
font-weight: 700;
font-family: monospace;
color: #fff;
letter-spacing: 1px;
}

#color-rgb-row {
display: flex;
gap: 10px;
}

.color-rgb-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.color-rgb-field label {
    font-size: 11px;
    font-weight: 700;
    color: #a1a1aa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.color-rgb-field input {
    width: 100%;
    height: 46px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    background: #2c2c2e;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    padding: 0 4px;
    -moz-appearance: textfield;
}

.color-rgb-field input::-webkit-outer-spin-button,
.color-rgb-field input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.color-rgb-field input:focus {
    outline: none;
    border-color: #0a84ff;
}

#color-saved-title {
font-size: 12px;
font-weight: 600;
color: #a1a1aa;
text-transform: uppercase;
letter-spacing: 0.5px;
}

#pc-custom-palette {
display: flex;
flex-wrap: wrap;
gap: 8px;
min-height: 16px;
}

.custom-palette-swatch {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.custom-palette-swatch:active {
    transform: scale(0.9);
}

.custom-palette-swatch.active {
    border-color: #fff;
    transform: scale(1.1);
}

#color-modal-footer {
padding: 12px 16px 36px;
flex-shrink: 0;
border-top: 1px solid rgba(255,255,255,0.08);
background: #1c1c1e;
}

#pc-apply-color-btn {
display: block;
width: 100%;
height: 52px;
border-radius: 14px;
border: none;
background: #0a84ff;
color: #fff;
font-size: 16px;
font-weight: 700;
cursor: pointer;
letter-spacing: 0.2px;
-webkit-tap-highlight-color: transparent;
}

#pc-apply-color-btn:active {
background: #0070d8;
transform: scale(0.98);
}

/* ===================== ACTIVE CUSTOM COLOR ===================== */

.active-custom-color-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}

.active-custom-color-hex {
    font-size: 12px;
    font-weight: 600;
    font-family: monospace;
    color: #e5e7eb;
}

/* ===================== DESKTOP ===================== */

@media (min-width: 768px) {
    #color-modal-wrap {
    align-items: center;
    padding: 20px;
    }

    #color-modal-box {
    border-radius: 20px;
    max-height: 80vh;
    }
}
