/* ==========================================================================
   SparkyDraw - Modern Vanilla CSS
   ========================================================================== */
:root {
    --font-family: 'Fredoka', 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --bg-canvas: #ffffff;
    /* Dock / Toolbar Design System */
    --dock-bg: rgba(26, 28, 38, 0.92);
    --dock-border: rgba(255, 255, 255, 0.12);
    --dock-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.35), 0 4px 10px rgba(0, 0, 0, 0.2);
    --text-main: #ffffff;
    --text-muted: #a0a6be;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --accent-pink: #ec4899;
    --accent-spark: #fbbf24;
    --radius-slot: 5px;
    /* Explicit requirement: 5px rounded borders */
    --radius-dock: 16px;
    --radius-pill: 9999px;
    --slot-shadow: 0 2px 5px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.2);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Mobile Safe Area Insets */
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
}
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
[hidden] {
    display: none !important;
}
html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f1f3f7;
    font-family: var(--font-family);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    overscroll-behavior: none;
}
button {
    touch-action: manipulation;
}
/* ==========================================================================
   Canvas Area
   ========================================================================== */
.canvas-container {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-canvas);
    overflow: hidden;
    cursor: crosshair;
    z-index: 1;
}
#drawingCanvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    touch-action: none;
}
/* Interactive Brush Cursor Follower */
.brush-cursor {
    position: fixed;
    pointer-events: none;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 1.5px solid rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.05s ease-out;
}
.brush-cursor.active {
    opacity: 1;
}
/* ==========================================================================
   Top Toolbar (Windows Remote Desktop Bar Style)
   ========================================================================== */
.top-toolbar {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    padding: 0 14px 0 10px;
    background: var(--dock-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--dock-border);
    border-radius: var(--radius-pill);
    box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.15);
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-wrap: nowrap;
    max-width: calc(100vw - 20px);
}
.top-toolbar:hover {
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.45);
}
.top-toolbar-drag-handle {
    display: flex;
    align-items: center;
    cursor: default;
}
.app-logo {
    display: flex;
    align-items: center;
    gap: 6px;
}
.spark-icon {
    width: 20px;
    height: 20px;
    color: var(--accent-spark);
    fill: var(--accent-spark);
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.6));
    animation: pulse-spark 2.5s infinite ease-in-out;
}
@keyframes pulse-spark {
    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.12) rotate(6deg);
    }
}
.app-title {
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: linear-gradient(135deg, #ffffff 40%, #fbbf24 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding-right: 4px;
}
.top-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-wrap: nowrap;
}
.toolbar-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.18);
    margin: 0 2px;
}
.btn-tool {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    height: 32px;
    border: none;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-label {
    white-space: nowrap;
    display: inline-block;
}
.btn-tool:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}
.btn-tool:active {
    transform: translateY(1px);
}
.btn-tool:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    transform: none;
}
.btn-lang {
    gap: 6px;
    padding: 5px 8px;
}
.lang-flag-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 14px;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
}
.lang-flag-current .flag-svg {
    width: 20px;
    height: 14px;
    display: block;
}
.chevron-icon {
    transition: transform var(--transition-fast);
    opacity: 0.75;
}
.btn-lang[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
}
.btn-save {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    height: 32px;
    border: none;
    border-radius: var(--radius-pill);
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-save:hover {
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}
.btn-save:active {
    transform: translateY(1px);
}
/* ==========================================================================
   Left Dock Toolbar (Ubuntu Dock Style)
   ========================================================================== */
.left-dock {
    position: fixed;
    top: 64px;
    left: 12px;
    bottom: 12px;
    width: 66px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    background: var(--dock-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--dock-border);
    border-radius: var(--radius-dock);
    box-shadow: var(--dock-shadow);
    padding: 8px 4px;
    overflow: hidden;
    transition: width var(--transition-fast), transform var(--transition-fast);
}
.dock-colors-scroll {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    /* Hide default scrollbar */
    padding: 2px 0;
    scroll-behavior: smooth;
}
.dock-colors-scroll::-webkit-scrollbar {
    display: none;
}
.dock-pinned-tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 2px;
}
.dock-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.dock-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 5px;
    font-weight: 700;
    text-align: center;
}
.dock-divider {
    width: 40px;
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    margin: 3px 0;
    flex-shrink: 0;
}
/* Color Slots Grid */
.color-slots-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    width: 100%;
}
/* Explicit requirement: 5px rounded borders with slight shadow so they stand out */
.color-slot {
    position: relative;
    width: 42px;
    height: 38px;
    border-radius: var(--radius-slot);
    /* 5px */
    box-shadow: var(--slot-shadow);
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform var(--transition-bounce), box-shadow var(--transition-fast), border-color var(--transition-fast);
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.color-slot:hover {
    transform: scale(1.12);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    z-index: 2;
}
.color-slot:active {
    transform: scale(0.96);
}
.color-slot.active {
    transform: scale(1.14);
    border-color: #ffffff;
    box-shadow: 0 0 0 2px var(--primary), 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 3;
}
/* Visual active dot indicator inside slot */
.color-slot.active::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.3);
}
/* White color slot outline so it's clearly visible */
.color-slot[data-color="#ffffff"],
.color-slot[data-color="#fff"],
.color-slot[data-color="#FFFFFF"] {
    border: 1.5px solid rgba(255, 255, 255, 0.4);
}
/* Edit pencil badge indicator to hint customizeability */
.slot-edit-indicator {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 13px;
    height: 13px;
    background: #1e1e24;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 8px;
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}
.color-slot:hover .slot-edit-indicator,
.color-slot.active .slot-edit-indicator {
    opacity: 0.85;
}
/* ==========================================================================
   Brush Slot Button (Ubuntu Dock)
   ========================================================================== */
.brush-slot-btn {
    position: relative;
    width: 42px;
    height: 38px;
    border-radius: var(--radius-slot);
    /* 5px rounded borders */
    box-shadow: var(--slot-shadow);
    border: 2px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-bounce), box-shadow var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast);
    outline: none;
    flex-shrink: 0;
}
.brush-slot-btn:hover {
    transform: scale(1.12);
    background: rgba(255, 255, 255, 0.16);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    z-index: 2;
}
.brush-slot-btn:active {
    transform: scale(0.96);
}
.brush-slot-btn.active {
    transform: scale(1.14);
    border-color: var(--accent-spark);
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-spark);
    box-shadow: 0 0 0 2px var(--accent-spark), 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 3;
}
.brush-icon {
    width: 20px;
    height: 20px;
}
/* ==========================================================================
   Brush Sizes Popover
   ========================================================================== */
.brush-popover {
    width: 256px;
}
.brush-popover .popover-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.brush-size-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    padding: 2px 0;
}
.brush-size-btn {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--transition-bounce), background-color var(--transition-fast), border-color var(--transition-fast);
    outline: none;
}
.brush-size-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.08);
}
.brush-size-btn:active {
    transform: scale(0.95);
}
.brush-dot {
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}
.brush-size-btn.active {
    background: rgba(251, 191, 36, 0.22);
    border-color: var(--accent-spark);
}
.brush-size-btn.active::before {
    content: '';
    position: absolute;
    inset: 2px;
    border: 2px solid var(--accent-spark);
    border-radius: 8px;
    animation: pulse-ring 2s infinite ease-in-out;
}
/* Live brush size preview box */
.brush-size-preview-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.brush-preview-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}
.brush-preview-circle-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
}
.brush-preview-circle {
    border-radius: 50%;
    background-color: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.4);
    transition: width 0.12s ease, height 0.12s ease, background-color 0.12s ease;
}
.brush-preview-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-spark);
    font-family: 'Fredoka', cursive, sans-serif;
}
@keyframes pulse-ring {
    0%,
    100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}
/* ==========================================================================
   Reset Button (Below Brush Selector)
   ========================================================================== */
.dock-reset {
    margin-top: 0;
    padding: 2px 0;
    flex-shrink: 0;
}
.btn-dock-reset {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 52px;
    max-width: 56px;
    height: 44px;
    padding: 2px 2px;
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 10px;
    color: #fca5a5;
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
}
.btn-dock-reset:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
    color: #ffffff;
    transform: scale(1.05);
}
.btn-dock-reset:active {
    transform: scale(0.95);
}
.reset-text {
    font-size: clamp(7.5px, 0.9vw, 10px);
    font-weight: 700;
    letter-spacing: 0.1px;
    line-height: 1.1;
    max-width: 100%;
    padding: 0 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
}
/* ==========================================================================
   Color Picker Popover Flyout
   ========================================================================== */
.color-popover {
    position: fixed;
    z-index: 200;
    background: rgba(24, 26, 36, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.25);
    padding: 14px;
    width: 220px;
    transform-origin: left center;
    animation: popover-appear 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popover-appear {
    from {
        opacity: 0;
        transform: scale(0.92) translateX(-6px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}
.popover-arrow {
    position: absolute;
    width: 14px;
    height: 14px;
    background: rgba(24, 26, 36, 0.95);
    pointer-events: none;
}
.color-popover.arrow-left .popover-arrow,
.color-popover:not(.arrow-bottom) .popover-arrow {
    left: -7px;
    top: 24px;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    transform: rotate(45deg);
}
.color-popover.arrow-bottom .popover-arrow {
    bottom: -7px;
    left: 50%;
    top: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.16);
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    transform: translateX(-50%) rotate(45deg);
}
.popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.popover-title {
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
}
.popover-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color var(--transition-fast);
}
.popover-close:hover {
    color: #ffffff;
}
.popover-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.native-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: background var(--transition-fast);
}
.native-picker-wrapper:hover {
    background: rgba(255, 255, 255, 0.14);
}
.native-picker-wrapper input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.native-picker-preview {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}
.native-picker-label {
    color: #ffffff;
    font-size: 13px;
    font-weight: 600;
}
.quick-swatches {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.quick-swatch-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform var(--transition-fast);
}
.quick-swatch-item:hover {
    transform: scale(1.15);
    z-index: 2;
}
/* ==========================================================================
   Language Selector Popover Dropdown
   ========================================================================== */
.lang-popover {
    position: fixed;
    z-index: 200;
    background: rgba(24, 26, 36, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: 6px;
    min-width: 175px;
    animation: popover-in 0.15s ease-out;
}
.lang-popover-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.lang-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-main);
    font-family: var(--font-family);
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.lang-item:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateX(2px);
}
.lang-item.active {
    background: rgba(251, 191, 36, 0.18);
    color: var(--accent-spark);
}
.lang-flag-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 15px;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
}
.lang-flag-box .flag-svg {
    width: 22px;
    height: 15px;
    display: block;
}
.lang-names {
    display: flex;
    flex-direction: column;
    flex: 1;
    line-height: 1.2;
}
.lang-name-native {
    font-size: 13px;
    font-weight: 700;
}
.lang-name-en {
    font-size: 11px;
    color: var(--text-muted);
}
.lang-item.active .lang-name-en {
    color: rgba(251, 191, 36, 0.85);
}
.lang-check {
    width: 16px;
    height: 16px;
    color: var(--accent-spark);
    opacity: 0;
    flex-shrink: 0;
    transition: opacity var(--transition-fast);
}
.lang-item.active .lang-check {
    opacity: 1;
}
/* ==========================================================================
   Toast Notification
   ========================================================================== */
.toast-message {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 22, 30, 0.92);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 1000;
    animation: toast-in 0.25s ease-out;
}
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translate(-50%, 12px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}
/* ==========================================================================
   Confirm Dialog
   ========================================================================== */
.confirm-dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    animation: fade-in 0.15s ease-out;
}
.confirm-dialog-backdrop[hidden] {
    display: none !important;
}
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
.confirm-dialog {
    background: #1e202d;
    color: #ffffff;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    padding: 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
}
.dialog-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #ffffff;
}
.dialog-text {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 20px;
}
.dialog-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.btn-cancel {
    flex: 1;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.18);
}
.btn-confirm-clear {
    flex: 1;
    padding: 10px 16px;
    background: #ef4444;
    color: #ffffff;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transition: all var(--transition-fast);
}
.btn-confirm-clear:hover {
    background: #dc2626;
    box-shadow: 0 6px 16px rgba(239, 68, 68, 0.6);
}
/* ==========================================================================
   Help / About Modal
   ========================================================================== */
.help-modal {
    background: #1e202d;
    color: #ffffff;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    padding: 24px;
    max-width: 620px;
    width: 100%;
    max-height: calc(100vh - 30px);
    overflow-y: auto;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: fade-in 0.15s ease-out;
}
.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.help-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}
.help-title {
    font-family: 'Fredoka', cursive, sans-serif;
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, #ffffff 40%, #fbbf24 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.help-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.help-intro {
    font-size: 15px;
    line-height: 1.55;
    color: #d1d5db;
}
.help-section {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 16px;
}
.help-section-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.help-icon-badge {
    font-size: 16px;
}
.help-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 0;
}
.help-list li {
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-muted);
    position: relative;
    padding-left: 16px;
}
.help-list li::before {
    content: '•';
    position: absolute;
    left: 2px;
    color: var(--accent-spark);
    font-weight: bold;
}
.help-list strong {
    color: #ffffff;
}
.help-list kbd,
.help-intro code,
.help-list code {
    background: rgba(255, 255, 255, 0.12);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: monospace;
    color: #ffffff;
}
.help-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 2px;
}
.help-footer .btn-got-it,
#btnGotIt {
    width: auto !important;
    min-width: fit-content;
    height: auto !important;
    min-height: 36px;
    padding: 8px 22px !important;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    border-radius: var(--radius-pill);
    box-sizing: border-box;
    flex-shrink: 0;
}
.help-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}
.help-badge {
    background: rgba(79, 70, 229, 0.3);
    border: 1px solid rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
}
.help-date {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}
/* --- Arabic RTL Support (Help / Info Modal ONLY) --- */
[lang="ar"] .help-modal {
    direction: rtl;
    text-align: right;
}
[lang="ar"] .help-list li {
    padding-left: 0;
    padding-right: 18px;
}
[lang="ar"] .help-list li::before {
    left: auto;
    right: 2px;
}
/* ==========================================================================
   Mobile & Tablet Responsive Adjustments
   ========================================================================== */
/* --- Tablet / Intermediate Screens (Keep top toolbar on one line) --- */
@media (max-width: 1024px) and (min-width: 769px) {
    .top-toolbar {
        gap: 8px;
        padding: 0 10px 0 8px;
        white-space: nowrap;
        flex-wrap: nowrap;
    }
    .top-toolbar-actions {
        gap: 4px;
        white-space: nowrap;
        flex-wrap: nowrap;
    }
    .btn-tool {
        padding: 5px 8px;
        gap: 5px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .top-toolbar .btn-save {
        padding: 5px 10px;
        font-size: 12px;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .btn-label {
        white-space: nowrap;
    }
}
/* --- Mobile Portrait Mode (Dock shifts to bottom thumb-friendly bar) --- */
@media (max-width: 768px) and (orientation: portrait),
(max-width: 600px) {
    /* Compact Top Toolbar */
    .top-toolbar {
        top: max(6px, var(--sat));
        height: 38px;
        padding: 0 8px;
        max-width: calc(100vw - 12px);
        gap: 6px;
    }
    .top-toolbar-drag-handle {
        padding-right: 0;
    }
    .app-title {
        display: none;
    }
    .spark-icon {
        width: 18px;
        height: 18px;
    }
    .top-toolbar-actions {
        gap: 4px;
    }
    .btn-label {
        display: none !important;
    }
    .btn-tool {
        width: 32px;
        height: 30px;
        padding: 0;
        justify-content: center;
        border-radius: 8px;
    }
    .btn-tool svg {
        width: 16px;
        height: 16px;
    }
    .btn-lang {
        width: 32px;
        height: 30px;
        padding: 0;
        justify-content: center;
    }
    .btn-lang .chevron-icon {
        display: none;
    }
    .toolbar-divider {
        width: 1px;
        height: 18px;
        margin: 0 1px;
    }
    .top-toolbar .btn-save {
        width: 34px;
        height: 30px;
        padding: 0;
        justify-content: center;
        border-radius: 8px;
    }
    .top-toolbar .btn-save svg {
        width: 16px;
        height: 16px;
    }
    .top-toolbar .btn-save .btn-label {
        display: none !important;
    }
    /* Bottom horizontal floating dock: scroll colors, keep brush & reset pinned */
    .left-dock {
        top: auto;
        bottom: max(8px, var(--sab));
        left: max(8px, var(--sal));
        right: max(8px, var(--sar));
        width: auto;
        height: 52px;
        padding: 4px 8px;
        border-radius: 16px;
        flex-direction: row;
        align-items: center;
        gap: 4px;
    }
    .dock-section-title {
        display: none;
    }
    /* Scroll through colors only */
    .dock-colors-scroll {
        flex: 1 1 auto;
        min-width: 0;
        min-height: 0;
        height: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0 2px;
    }
    .dock-colors-scroll::-webkit-scrollbar {
        display: none;
    }
    .color-slots-grid {
        flex-direction: row;
        gap: 6px;
        width: auto;
        flex-shrink: 0;
        padding-bottom: 0;
    }
    .color-slot {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }
    /* Pinned tools: brush & reset always visible on the right */
    .dock-pinned-tools {
        display: flex;
        flex-direction: row;
        align-items: center;
        width: auto;
        height: 100%;
        flex-shrink: 0;
        margin-top: 0;
        margin-left: auto;
        padding-top: 0;
        gap: 4px;
    }
    .dock-divider {
        width: 1px;
        height: 26px;
        margin: 0 2px;
        flex-shrink: 0;
    }
    .brush-slot-btn {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }
    .dock-reset {
        margin-top: 0;
        padding: 0;
        flex-shrink: 0;
    }
    .btn-dock-reset {
        width: 36px;
        height: 32px;
        border-radius: 8px;
        padding: 0;
    }
    .reset-text {
        display: none;
    }
}
/* --- Mobile Landscape Mode (Compact Left Dock & Slim Top Bar) --- */
@media (orientation: landscape) and (max-height: 560px) {
    /* Compact Top Toolbar */
    .top-toolbar {
        top: max(4px, var(--sat));
        height: 30px;
        padding: 0 6px;
        max-width: calc(100vw - 12px);
        gap: 5px;
    }
    .top-toolbar-drag-handle {
        padding-right: 0;
    }
    .app-title {
        display: none;
    }
    .spark-icon {
        width: 15px;
        height: 15px;
    }
    .top-toolbar-actions {
        gap: 3px;
    }
    .btn-label {
        display: none !important;
    }
    .btn-tool {
        width: 28px;
        height: 24px;
        padding: 0;
        justify-content: center;
        border-radius: 6px;
    }
    .btn-tool svg {
        width: 14px;
        height: 14px;
    }
    .btn-lang {
        width: 28px;
        height: 24px;
        padding: 0;
        justify-content: center;
    }
    .btn-lang .chevron-icon {
        display: none;
    }
    .toolbar-divider {
        width: 1px;
        height: 16px;
        margin: 0 1px;
    }
    .top-toolbar .btn-save {
        width: 30px;
        height: 24px;
        padding: 0;
        justify-content: center;
        border-radius: 6px;
    }
    .top-toolbar .btn-save svg {
        width: 14px;
        height: 14px;
    }
    .top-toolbar .btn-save .btn-label {
        display: none !important;
    }
    /* Left dock: scroll colors vertically, keep brush & reset pinned at bottom */
    .left-dock {
        top: max(36px, var(--sat));
        bottom: max(6px, var(--sab));
        left: max(6px, var(--sal));
        width: 48px;
        padding: 4px 2px;
        border-radius: 12px;
        flex-direction: column;
    }
    .dock-section-title {
        display: none;
    }
    .dock-colors-scroll {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 2px 0;
    }
    .dock-colors-scroll::-webkit-scrollbar {
        display: none;
    }
    .color-slots-grid {
        flex-direction: column;
        gap: 4px;
        width: 100%;
        padding-bottom: 0;
    }
    .color-slot {
        width: 32px;
        height: 24px;
        flex-shrink: 0;
    }
    /* Pinned tools at bottom */
    .dock-pinned-tools {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        flex-shrink: 0;
        margin-top: auto;
        padding: 0;
        gap: 2px;
    }
    .dock-divider {
        width: 28px;
        height: 1px;
        margin: 2px 0;
        flex-shrink: 0;
    }
    .brush-slot-btn {
        width: 32px;
        height: 24px;
        flex-shrink: 0;
    }
    .dock-reset {
        margin-top: 0;
        padding: 0;
        flex-shrink: 0;
    }
    .btn-dock-reset {
        width: 34px;
        height: 24px;
        border-radius: 6px;
    }
    .reset-text {
        display: none;
    }
}