/* Norwegian-Inspired Minimalist Design */
:root {
    /* Layout dimensions */
    --header-h: 64px;
    --footer-h: 64px;

    /* Cream paper theme colors */
    --light-bg-start: #faf7f0;
    --light-bg-end: #f5f0e8;
    --cream-shadow: rgba(139, 115, 85, 0.08);
    --cream-highlight: rgba(255, 248, 235, 0.6);
    --paper-texture: radial-gradient(circle at 20% 80%, rgba(139, 115, 85, 0.03) 0%, transparent 50%),
                     radial-gradient(circle at 80% 20%, rgba(139, 115, 85, 0.02) 0%, transparent 50%),
                     radial-gradient(circle at 40% 40%, rgba(139, 115, 85, 0.01) 0%, transparent 50%);

    /* Black paper theme colors */
    --dark-bg-start: #0f0f0f;
    --dark-bg-end: #1a1a1a;
    --black-shadow: rgba(255, 255, 255, 0.03);
    --black-highlight: rgba(0, 0, 0, 0.4);
    --black-paper-texture: radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.02) 0%, transparent 50%),
                           radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.015) 0%, transparent 50%),
                           radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.01) 0%, transparent 50%);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    background: linear-gradient(135deg, var(--light-bg-start) 0%, var(--light-bg-end) 100%),
                var(--paper-texture);
    background-attachment: fixed;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

body.light {
    background: linear-gradient(135deg, var(--light-bg-start) 0%, var(--light-bg-end) 100%),
                var(--paper-texture);
    background-attachment: fixed;
    color: #2d3748;
}

body.dark {
    background: linear-gradient(135deg, var(--dark-bg-start) 0%, var(--dark-bg-end) 100%),
                var(--black-paper-texture);
    background-attachment: fixed;
    color: #e2e8f0;
}

/* Top Bar - Minimal header with brand and theme */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    animation: slideDown 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark .top-bar {
    background: rgba(26, 32, 44, 0.9);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.top-controls label {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    margin-right: 8px;
}

body.dark .top-controls label {
    color: #94a3b8;
}

.top-controls select,
.top-controls input[type="number"],
.top-controls button {
    padding: 6px 12px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.9);
    color: #1e293b;
    transition: all 0.3s ease;
}

body.dark .top-controls select,
body.dark .top-controls input[type="number"],
body.dark .top-controls button {
    background: rgba(51, 65, 85, 0.9);
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.5);
}

/* Floating Toolbar */
.floating-toolbar {
    position: fixed;
    bottom: 100px;
    right: 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 20px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.15),
        0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.1);
    z-index: 999;
    max-width: 340px;
    min-width: 280px;
    contain: layout style;
    cursor: move;
    user-select: none;
    animation: toolbarSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-sizing: border-box;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
}

body.dark .floating-toolbar {
    background: rgba(45, 55, 72, 0.95);
    border-color: rgba(148, 163, 184, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.toolbar-drag-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 20px;
    margin: -20px -20px 16px -20px;
    cursor: grab;
    border-radius: 16px 16px 0 0;
    background: rgba(148, 163, 184, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
}

.toolbar-drag-handle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(147, 197, 253, 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toolbar-drag-handle:hover {
    background: rgba(148, 163, 184, 0.08);
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toolbar-drag-handle:hover::before {
    opacity: 1;
}

.toolbar-drag-handle:active {
    cursor: grabbing;
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.drag-indicator {
    font-size: 12px;
    color: #64748b;
    user-select: none;
    pointer-events: none;
}

body.dark .drag-indicator {
    color: #94a3b8;
}

.toolbar-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0 4px;
}

/* Floating toolbar auto-hide states */
.floating-toolbar.active {
    opacity: 1;
    transform: scale(1);
}

.floating-toolbar:not(.active) {
    opacity: 0.7;
    transform: scale(0.95);
}

.floating-toolbar.dragging {
    opacity: 1 !important;
    transform: scale(1) !important;
}

/* Mini pill state for draw mode */
.floating-toolbar.mini {
    width: 140px;
    height: 48px;
    border-radius: 24px;
    padding: 8px 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(148, 163, 184, 0.15);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-toolbar.mini .toolbar-drag-handle {
    display: none;
}

.floating-toolbar.mini .toolbar-content {
    display: none;
}

.floating-toolbar.mini .mini-tools {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    height: 100%;
}

.floating-toolbar:not(.mini) .mini-tools {
    display: none;
}

.floating-toolbar.mini .mini-tools .tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.9);
    color: #374151;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

body.dark .floating-toolbar.mini .mini-tools .tool-btn {
    background: rgba(55, 65, 81, 0.9);
    color: #f3f4f6;
    border-color: rgba(255, 255, 255, 0.2);
}

.floating-toolbar.mini .mini-tools .tool-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.floating-toolbar.mini .mini-tools .tool-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Smooth transitions for auto-hide */
.floating-toolbar {
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

/* Subtle hover effect for better interactivity */
.floating-toolbar:hover {
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toolbarSlideIn {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

body.dark .toolbar {
    background: rgba(26, 32, 44, 0.85);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-right: 20px;
    padding: 8px 0;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

body.dark .logo {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.brand-name {
    font-size: 18px;
    font-weight: 600;
    color: #4a6188;
    letter-spacing: -0.01em;
    font-family: 'Inter', sans-serif;
}

body.dark .brand-name {
    color: #97bedf;
}

#infoBtn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    color: #64748b;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

body.dark #infoBtn {
    color: #94a3b8;
}

#infoBtn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    transform: scale(1.1);
}

body.dark #infoBtn:hover {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

#infoBtn:active {
    transform: scale(0.95);
}

/* Hamburger Menu Toggle */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    margin-left: auto;
    order: -1;
}

/* Collapse top-controls when toolbar is collapsed */
.top-bar.toolbar.collapsed .top-controls {
    display: none;
}



.control-group:nth-child(1) { animation-delay: 0.1s; }
.control-group:nth-child(2) { animation-delay: 0.2s; }
.control-group:nth-child(3) { animation-delay: 0.3s; }
.control-group:nth-child(4) { animation-delay: 0.4s; }
.control-group:nth-child(5) { animation-delay: 0.5s; }
.control-group:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.dark .control-group {
    background: rgba(45, 55, 72, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.control-group:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.dark .control-group:hover {
    background: rgba(45, 55, 72, 0.7);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

label {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

body.dark label {
    color: #94a3b8;
}

select, input[type="number"], button {
    padding: 10px 18px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.9);
    color: #1e293b;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}

body.dark select, body.dark input[type="number"], body.dark button {
    background: rgba(51, 65, 85, 0.9);
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

select:focus, input[type="number"]:focus, button:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

button {
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.025em;
    position: relative;
    overflow: hidden;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
}

.color-picker {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-picker:hover {
    border-color: #3b82f6;
    transform: scale(1.05);
}

.preset-colors {
    display: flex;
    gap: 10px;
}

.color-btn {
    width: 32px;
    height: 32px;
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-btn:hover {
    transform: scale(1.15);
    border-color: #3b82f6;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

#colorControls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto; /* Presets wrap, picker stays anchored */
    grid-auto-rows: auto;
    gap: 8px;
    align-items: start;
    flex-wrap: unset; /* Override flex wrap from base .control-group */
}

#colorControls label {
    grid-column: 1 / -1; /* Label on its own line */
}

#colorControls .preset-colors {
    grid-column: 1 / 2;
    display: flex;
    flex-wrap: wrap;          /* Wrap buttons to avoid overflow */
    gap: 8px;
    min-width: 0;             /* Allow flex container to shrink within grid */
    max-width: 100%;
}

#colorControls .color-picker {
    grid-column: 2 / 3;
    justify-self: end;        /* Anchor to the right of the row */
    flex: 0 0 auto;
}

@media (max-width: 380px) {
    #colorControls {
        grid-template-columns: 1fr; /* Stack on very small widths */
    }
    #colorControls .color-picker {
        grid-column: 1 / -1;
        justify-self: start;
        margin-left: 0;
    }
}

/* Subtle visual balance for color buttons within the preset list */
.preset-colors .color-btn {
    border-radius: 50%;       /* Softer shape to match toolbar rounding */
    box-shadow: none;         /* Keep minimal aesthetic */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.preset-colors .color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.preset-colors .color-btn:active {
    transform: scale(0.95);
}

.timer-text {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-weight: 600;
    font-size: 14px;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    padding: 6px 12px;
    border-radius: 8px;
    min-width: 100px;
    text-align: center;
    letter-spacing: 0.05em;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

body.dark .timer-text {
    color: #fca5a5;
    background: rgba(252, 165, 165, 0.1);
    border-color: rgba(252, 165, 165, 0.3);
}



.tool-toggle {
    display: flex;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

body.dark .tool-toggle {
    background: rgba(51, 65, 85, 0.5);
    border-color: rgba(148, 163, 184, 0.4);
}

.tool-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 14px;
    position: relative;
}

.tool-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 8px;
}

.tool-btn.active::before {
    opacity: 1;
}

.tool-btn.active {
    color: white;
    font-weight: 600;
}

.canvas-container, .text-container {
    position: absolute;
    top: 108px; /* Below the top bar (64px) + compact text toolbar (44px) */
    left: 0;
    right: 0;
    bottom: var(--footer-h);
    opacity: 1;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, var(--light-bg-start) 0%, var(--light-bg-end) 100%),
                var(--paper-texture);
    background-attachment: fixed;
}

body.dark .canvas-container, body.dark .text-container {
    background: linear-gradient(135deg, var(--dark-bg-start) 0%, var(--dark-bg-end) 100%),
                var(--black-paper-texture);
    background-attachment: fixed;
}

#textArea {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    padding: 48px 32px;
    font-size: 18px;
    line-height: 1.7;
    resize: none;
    background: transparent;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    color: inherit;
    caret-color: #3b82f6;
}

#textArea::placeholder {
    color: rgba(148, 163, 184, 0.6);
    font-style: italic;
}

/* dedup: definitions present later in file */

/* dedup: definitions present later in file */

/* Norwegian Aurora-inspired accent colors */
.norwegian-blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.norwegian-green { background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); }
.norwegian-purple { background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%); }

/* Subtle animations */
@keyframes gentle-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.1); }
    50% { box-shadow: 0 0 30px rgba(59, 130, 246, 0.2); }
}

.control-group:focus-within {
    animation: gentle-glow 2s ease-in-out infinite;
}

/* Tablet and Mobile Enhancements */
@media (max-width: 1024px) {
    /* Tablet adjustments */
    .floating-toolbar {
        max-width: 300px;
        padding: 14px;
        bottom: 110px;
    }

    .control-group {
        padding: 10px 16px;
        gap: 10px;
    }

    .mode-btn, .tool-btn {
        padding: 12px 16px;
        font-size: 14px;
    }
}

@media (max-width: 768px) {
    /* Mobile adjustments */
    /* Add active states for better touch feedback */
    button:active,
    .color-btn:active,
    .mode-btn:active,
    .tool-btn:active,
    .menu-toggle:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }

    /* Improve text area for mobile */
    #textArea {
        -webkit-appearance: none;
        border-radius: 8px;
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 32px 24px; /* Reduce padding on mobile */
    }

    /* Better spacing for mobile footer */
    .app-footer {
        padding: 16px;
    }

    .footer-content {
        padding: 8px 16px;
    }

    /* Ensure canvas touch scrolling is disabled */
    .canvas-container {
        touch-action: none;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Improve toolbar collapsed state */
    .toolbar.collapsed {
        padding: 12px 16px;
        justify-content: center;
    }

    .toolbar.collapsed .brand {
        margin-right: 0;
    }

    /* Mobile floating toolbar adjustments */
    .floating-toolbar {
        max-width: 280px;
        padding: 12px;
        bottom: calc(env(safe-area-inset-bottom) + 120px); /* Avoid gesture bar */
        right: 16px; /* Closer to edge on mobile */
        border-radius: 14px;
    }

    .floating-toolbar.mini {
        width: 100px; /* Smaller mini pill on mobile */
        height: 36px;
        padding: 6px;
        border-radius: 18px;
    }

    .floating-toolbar.mini .mini-tools .tool-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
        border-radius: 50%;
    }

    .toolbar-drag-handle {
        padding: 12px;
        margin: -12px -12px 8px -12px;
        min-height: 44px; /* Ensure touch target */
        border-radius: 12px 12px 0 0;
    }

    .drag-indicator {
        font-size: 14px;
    }

    /* Larger touch targets for mobile */
    .control-group {
        min-height: 48px;
        padding: 10px 14px;
        gap: 12px;
        border-radius: 10px;
    }

    .mode-btn, .tool-btn {
        min-height: 44px;
        padding: 12px 18px;
        font-size: 15px;
        border-radius: 8px;
    }

    .color-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        border-radius: 50%;
    }

    .color-picker {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }

    /* Stack color controls vertically on very small screens */
    #colorControls {
        flex-direction: column;
        align-items: stretch;
    }

    #colorControls .preset-colors {
        justify-content: center;
        flex-wrap: wrap;
        gap: 10px;
    }

    /* Adjust top bar for mobile */
    .top-bar {
        padding: 10px 16px;
    }

    .top-controls {
        gap: 12px;
    }

    .top-controls select,
    .top-controls input[type="number"],
    .top-controls button {
        padding: 8px 10px;
        font-size: 12px;
        border-radius: 6px;
    }

    /* Adjust fade notice for mobile */
    .fade-notice {
        bottom: 100px; /* Above mobile toolbar */
        right: 16px;
        left: 16px;
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 10px;
    }

    /* Improve toolbar content spacing on mobile */
    .toolbar-content {
        gap: 14px;
        padding: 0 2px;
    }
}

@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .toolbar {
        padding: 12px 16px;
        gap: 12px;
    }

    .brand {
        margin-right: 12px;
    }

    .logo {
        font-size: 24px;
    }

    .brand-name {
        font-size: 16px;
    }

    .control-group {
        padding: 8px 12px;
        gap: 8px;
        min-height: 44px; /* Ensure touch targets meet minimum size */
    }

    .control-group label {
        font-size: 12px;
        min-width: fit-content;
    }

    /* Improve button sizing for touch */
    .control-group select,
    .control-group input[type="number"],
    .control-group button {
        min-height: 36px;
        padding: 8px 12px;
        font-size: 14px;
    }

    .mode-btn, .tool-btn {
        min-height: 40px;
        padding: 8px 16px;
        font-size: 14px;
    }

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

    .color-picker {
        width: 40px;
        height: 40px;
    }

    .canvas-container, .text-container {
        top: var(--header-h);
        padding: 16px;
        bottom: calc(env(safe-area-inset-bottom) + var(--footer-h));
        min-height: calc(100vh - var(--header-h) - var(--footer-h) - env(safe-area-inset-bottom));
        z-index: 0;
    }

    #textArea {
        padding: 16px;
        font-size: 16px;
        line-height: 1.6;
    }

    .fade-notice {
        bottom: calc(env(safe-area-inset-bottom) + 16px);
        right: 16px;
        left: 16px;
        text-align: center;
        font-size: 13px;
        padding: 10px 16px;
    }
}

/* Icon + Label helpers */
.icon { display: inline-flex; align-items: center; justify-content: center; }
.label { display: inline-block; }

@media (max-width: 768px) {
  .top-controls .label { display: none; }
}

@media (max-width: 480px) {
  .footer-links .label { display: none; }
}

/* Welcome Modal */
.welcome-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.welcome-modal {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(148, 163, 184, 0.2);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

body.dark .welcome-modal {
    background: rgba(45, 55, 72, 0.95);
    border-color: rgba(148, 163, 184, 0.3);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 8px 32px rgba(0, 0, 0, 0.3);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.welcome-header {
    text-align: center;
    padding: 32px 32px 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

body.dark .welcome-header {
    border-bottom-color: rgba(148, 163, 184, 0.2);
}

.welcome-logo {
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 16px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.welcome-title {
    font-size: 24px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 8px 0;
    letter-spacing: -0.02em;
}

body.dark .welcome-title {
    color: #e2e8f0;
}

.welcome-subtitle {
    font-size: 16px;
    color: #64748b;
    margin: 0;
    font-weight: 400;
}

body.dark .welcome-subtitle {
    color: #94a3b8;
}

.welcome-content {
    padding: 24px 32px;
}

.welcome-section {
    margin-bottom: 32px;
}

.welcome-section:last-child {
    margin-bottom: 0;
}

.section-icon {
    font-size: 24px;
    margin-bottom: 12px;
    text-align: center;
}

.welcome-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 12px 0;
    text-align: center;
}

body.dark .welcome-section h3 {
    color: #e2e8f0;
}

.welcome-section p {
    font-size: 14px;
    line-height: 1.6;
    color: #4a5568;
    margin: 0;
    text-align: center;
}

body.dark .welcome-section p {
    color: #a0aec0;
}

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

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: rgba(148, 163, 184, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    transition: all 0.3s ease;
}

body.dark .feature-item {
    background: rgba(148, 163, 184, 0.1);
    border-color: rgba(148, 163, 184, 0.2);
}

.feature-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.dark .feature-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.feature-icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.feature-text strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 4px;
}

body.dark .feature-text strong {
    color: #e2e8f0;
}

.feature-text span {
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
}

body.dark .feature-text span {
    color: #94a3b8;
}

.tips-list {
    list-style: none;
    padding: 0;
    margin: 16px 0 0 0;
}

.tips-list li {
    font-size: 14px;
    color: #4a5568;
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
    line-height: 1.5;
}

body.dark .tips-list li {
    color: #a0aec0;
}

.tips-list li:before {
    content: "•";
    color: #667eea;
    font-weight: bold;
    position: absolute;
    left: 0;
}

.welcome-footer {
    padding: 24px 32px 32px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

body.dark .welcome-footer {
    border-top-color: rgba(148, 163, 184, 0.2);
}

.dont-show-again {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #64748b;
    cursor: pointer;
    user-select: none;
}

body.dark .dont-show-again {
    color: #94a3b8;
}

.dont-show-again input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #667eea;
}

.welcome-button {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.welcome-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.welcome-button:active {
    transform: translateY(0);
}

/* Mobile responsiveness for welcome modal */
@media (max-width: 768px) {
    .welcome-modal {
        width: 95%;
        margin: 20px;
        max-height: calc(100vh - 40px);
    }

    .welcome-header {
        padding: 24px 24px 20px;
    }

    .welcome-content {
        padding: 20px 24px;
    }

    .welcome-footer {
        padding: 20px 24px 24px;
        flex-direction: column;
        gap: 16px;
    }

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

    .feature-item {
        padding: 12px;
    }

    .welcome-logo {
        font-size: 40px;
    }

    .welcome-title {
        font-size: 20px;
    }
}

/* Text Formatting Toolbar - Modern Glassmorphism Design */
.text-toolbar {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(249, 250, 251, 0.95) 50%,
        rgba(243, 244, 246, 0.95) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(59, 130, 246, 0.1);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.08),
        0 1px 4px rgba(59, 130, 246, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    z-index: 998;
    animation: slideDownModern 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    height: 52px; /* Slightly taller for modern feel */
    position: relative;
    overflow: hidden;
}

.text-toolbar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(59, 130, 246, 0.02) 20%,
        rgba(147, 197, 253, 0.03) 50%,
        rgba(59, 130, 246, 0.02) 80%,
        transparent 100%);
    pointer-events: none;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes slideDownModern {
    from {
        transform: translateY(-120%);
        opacity: 0;
        filter: blur(8px);
    }
    to {
        transform: translateY(0);
        opacity: 1;
        filter: blur(0);
    }
}

@keyframes shimmer {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

body.dark .text-toolbar {
    background: rgba(26, 32, 44, 0.98);
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.text-toolbar .toolbar-content {
    display: grid;
    grid-template-columns: repeat(8, 1fr); /* 8 equal columns for 8 groups */
    gap: 4px; /* Minimal gap between groups */
    padding: 6px 8px; /* Minimal padding */
    height: 100%;
    width: 100%;
    align-items: center; /* Center items vertically */
}

.text-toolbar .toolbar-content::-webkit-scrollbar {
    display: none;
}

.format-group {
    display: flex;
    align-items: center;
    gap: 1px; /* Minimal gap between buttons */
    background: rgba(148, 163, 184, 0.03);
    border-radius: 4px;
    padding: 2px;
    border: 1px solid rgba(148, 163, 184, 0.08);
    position: relative;
}

.format-group:not(:last-child)::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 4px;
    bottom: 4px;
    width: 1px;
    background: rgba(148, 163, 184, 0.2);
}

body.dark .format-group {
    background: rgba(148, 163, 184, 0.08);
    border-color: rgba(148, 163, 184, 0.15);
}

body.dark .format-group:not(:last-child)::after {
    background: rgba(148, 163, 184, 0.3);
}

.format-btn {
    padding: 6px 8px; /* Smaller padding */
    border: none;
    background: transparent;
    color: #475569;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px; /* Smaller font */
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 28px; /* Smaller minimum width */
    height: 32px; /* Fixed height */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.format-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
        rgba(59, 130, 246, 0.1) 0%,
        rgba(147, 197, 253, 0.15) 50%,
        rgba(59, 130, 246, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.2s ease;
    border-radius: 6px;
}

body.dark .format-btn {
    color: #cbd5e1;
}

.format-btn:hover {
    background: linear-gradient(135deg,
        rgba(59, 130, 246, 0.08) 0%,
        rgba(147, 197, 253, 0.12) 50%,
        rgba(59, 130, 246, 0.08) 100%);
    color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.format-btn:hover::before {
    opacity: 1;
}

body.dark .format-btn:hover {
    background: linear-gradient(135deg,
        rgba(59, 130, 246, 0.15) 0%,
        rgba(147, 197, 253, 0.25) 50%,
        rgba(59, 130, 246, 0.15) 100%);
    color: #60a5fa;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.format-btn:active {
    transform: translateY(0) scale(0.98);
    transition: all 0.1s ease;
}

.format-btn.active {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow:
        0 2px 8px rgba(59, 130, 246, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: activePulse 2s ease-in-out infinite;
}

@keyframes activePulse {
    0%, 100% {
        box-shadow:
            0 2px 8px rgba(59, 130, 246, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    50% {
        box-shadow:
            0 4px 16px rgba(59, 130, 246, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
}

/* Color Preview Button */
.color-preview-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.color-preview-btn:hover .color-indicator {
    transform: scale(1.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark .color-indicator {
    border-color: rgba(0, 0, 0, 0.6);
}

.format-select {
    padding: 4px 8px; /* Smaller padding */
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.95);
    color: #1e293b;
    font-size: 12px; /* Smaller font */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    height: 28px; /* Fixed height */
    min-width: 60px;
}

body.dark .format-select {
    background: rgba(51, 65, 85, 0.95);
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.35);
}

.format-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.1);
}

/* ContentEditable Editor Styles */
#textEditor {
    width: 100%;
    min-height: calc(100vh - 140px);
    border: none;
    outline: none;
    padding: 48px 32px;
    font-size: 18px;
    line-height: 1.7;
    resize: none;
    background: transparent;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    color: inherit;
    caret-color: #3b82f6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#textEditor:empty::before {
    content: attr(placeholder);
    color: rgba(148, 163, 184, 0.6);
    font-style: italic;
    pointer-events: none;
}

#textEditor:focus {
    outline: none;
}

/* Rich text formatting styles */
#textEditor h1 {
    font-size: 2em;
    font-weight: 700;
    margin: 0.67em 0;
    line-height: 1.2;
}

#textEditor h2 {
    font-size: 1.5em;
    font-weight: 600;
    margin: 0.83em 0;
    line-height: 1.3;
}

#textEditor h3 {
    font-size: 1.17em;
    font-weight: 600;
    margin: 1em 0;
    line-height: 1.4;
}

#textEditor p {
    margin: 1em 0;
}

#textEditor ul, #textEditor ol {
    margin: 1em 0;
    padding-left: 2em;
}

#textEditor li {
    margin: 0.5em 0;
}

#textEditor blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 16px;
    margin: 1em 0;
    font-style: italic;
    color: rgba(148, 163, 184, 0.8);
}

#textEditor strong, #textEditor b {
    font-weight: 700;
}

#textEditor em, #textEditor i {
    font-style: italic;
}

#textEditor u {
    text-decoration: underline;
}

#textEditor s, #textEditor strike {
    text-decoration: line-through;
}

/* Mobile adjustments for text toolbar */
@media (max-width: 768px) {
    .text-toolbar {
        height: 44px; /* Even more compact on mobile */
    }

    .text-toolbar .toolbar-content {
        padding: 4px 12px; /* Reduced padding */
        gap: 6px; /* Tighter spacing */
    }

    .format-group {
        gap: 1px; /* Minimal gap */
        padding: 1px; /* Minimal padding */
    }

    .format-btn {
        padding: 4px 6px; /* Smaller padding */
        font-size: 12px; /* Smaller font */
        min-width: 28px; /* Smaller minimum width */
        height: 28px; /* Smaller height */
    }

    .format-select {
        padding: 4px 6px; /* Smaller padding */
        font-size: 11px; /* Smaller font */
        height: 28px; /* Smaller height */
        min-width: 50px; /* Smaller minimum width */
    }

    #textEditor {
        padding: 24px 16px; /* Reduced padding */
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: calc(100vh - 108px); /* Adjusted for smaller toolbar */
    }
}

/* Footer Styling */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
    z-index: 999;
}

body.dark .app-footer {
    background: rgba(26, 32, 44, 0.9);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.2);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    width: 100%;
    gap: 32px;
}

.footer-left {
    flex-shrink: 0;
    min-width: fit-content;
}

.footer-center {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
    max-width: none;
}

.footer-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: fit-content;
}

.footer-text {
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    letter-spacing: 0.025em;
}

body.dark .footer-text {
    color: #94a3b8;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.footer-links a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    background: rgba(148, 163, 184, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

body.dark .footer-links a {
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.2);
    border-color: rgba(148, 163, 184, 0.3);
}

.footer-links a:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #3b82f6;
    transform: translateY(-1px);
}

.footer-links svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 12px 16px;
    }

    .footer-links {
        justify-content: center;
        gap: 12px;
    }

    /* Reduce footer font sizes for mobile */
    .footer-text,
    .footer-links a,
    .space-fact-display,
    .footer-open-source {
        font-size: 12px;
    }

    .space-fact-icon {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .toolbar {
        padding: 8px 12px;
        gap: 8px;
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        justify-content: center;
        padding: 4px 8px;
    }

    .mode-toggle, .tool-toggle {
        width: 100%;
    }

    .mode-btn, .tool-btn {
        flex: 1;
        text-align: center;
    }

    .app-footer {
        padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
    }
}

/* Space Fact Notifications */

.brush-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 8px; /* default, updated via JS */
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(0,0,0,0.25);
  background: rgba(0,0,0,0.15); /* updated to current color in JS */
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5);
  opacity: 0;
  transition: opacity 120ms ease, width 120ms ease, height 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.brush-preview.visible {
    opacity: 1;
}

.brush-preview.pulse {
  animation: brushPulse 160ms ease-out;
}

@keyframes brushPulse {
  0% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.25); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

/* Canvas background variations */
.canvas-container.bg-grid {
  background-image: linear-gradient(135deg, var(--light-bg-start) 0%, var(--light-bg-end) 100%),
    linear-gradient(#fff, #fff);
}

body.dark .canvas-container.bg-grid {
  background-image: linear-gradient(135deg, var(--dark-bg-start) 0%, var(--dark-bg-end) 100%),
    linear-gradient(#1f2937, #1f2937);
}

.canvas-container.bg-grid::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px),
                    linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px);
  background-size: 16px 16px;
  pointer-events: none;
  z-index: 0;
}



#textArea {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    padding: 48px 32px;
    font-size: 18px;
    line-height: 1.7;
    resize: none;
    background: transparent;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    color: inherit;
    caret-color: #3b82f6;
}

#textArea::placeholder {
    color: rgba(148, 163, 184, 0.6);
    font-style: italic;
}

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

#canvas.pen-cursor {
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z" fill="black"/></svg>') 0 24, crosshair;
}

#canvas.eraser-cursor {
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M14.12 10.47L12 12.59l-2.13-2.12-1.41 1.41L10.59 14l-2.12 2.12 1.41 1.41L12 15.41l2.12 2.12 1.41-1.41L13.41 14l2.12-2.13z" fill="red"/><circle cx="12" cy="12" r="10" fill="none" stroke="red" stroke-width="2"/></svg>') 12 12, crosshair;
}

.fade-notice {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #2d3748;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

body.dark .fade-notice {
    background: rgba(45, 55, 72, 0.95);
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.fade-notice.visible {
    opacity: 1;
    transform: translateY(-4px);
}

/* Norwegian Aurora-inspired accent colors */
.norwegian-blue { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.norwegian-green { background: linear-gradient(135deg, #48bb78 0%, #38a169 100%); }
.norwegian-purple { background: linear-gradient(135deg, #9f7aea 0%, #805ad5 100%); }

/* Subtle animations */
@keyframes gentle-glow {
    0%, 100% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.1); }
    50% { box-shadow: 0 0 30px rgba(59, 130, 246, 0.2); }
}

.control-group:focus-within {
    animation: gentle-glow 2s ease-in-out infinite;
}

/* Mobile touch enhancements */
@media (max-width: 768px) {
    /* Add active states for better touch feedback */
    button:active,
    .color-btn:active,
    .mode-btn:active,
    .tool-btn:active,
    .menu-toggle:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }

    /* Improve text area for mobile */
    #textArea {
        -webkit-appearance: none;
        border-radius: 8px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Better spacing for mobile footer */
    .app-footer {
        padding: 16px;
    }

    .footer-content {
        padding: 8px 16px;
    }

    /* Ensure canvas touch scrolling is disabled */
    .canvas-container {
        touch-action: none;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }

    /* Improve toolbar collapsed state */
    .toolbar.collapsed {
        padding: 12px 16px;
        justify-content: center;
    }

    .toolbar.collapsed .brand {
        margin-right: 0;
    }

    /* Mobile floating toolbar adjustments */
    .floating-toolbar {
        max-width: 280px;
        padding: 12px;
        bottom: 120px; /* Higher on mobile to avoid footer */
    }

    .toolbar-drag-handle {
        padding: 12px;
        margin: -12px -12px 8px -12px;
        min-height: 44px; /* Ensure touch target */
    }

    .drag-indicator {
        font-size: 14px;
    }

    /* Larger touch targets for mobile */
    .control-group {
        min-height: 48px;
        padding: 10px 14px;
    }

    .mode-btn, .tool-btn {
        min-height: 44px;
        padding: 12px 18px;
        font-size: 15px;
    }

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

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



/* Footer Styling */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
    z-index: 999;
}

body.dark .app-footer {
    background: rgba(26, 32, 44, 0.9);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.2);
}

.footer-left {
    flex-shrink: 0;
    min-width: fit-content;
}

.footer-center {
    flex: 1;
    display: flex;
    justify-content: center;
    min-width: 0;
    max-width: none;
}

.footer-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 20px;
    min-width: fit-content;
}

.footer-open-source {
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    letter-spacing: 0.025em;
}

body.dark .footer-open-source {
    color: #94a3b8;
}

.space-fact-display {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    transition: all 0.3s ease;
    max-width: 100%;
}

body.dark .space-fact-display {
    color: #e2e8f0;
}

.space-fact-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.space-fact-text {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: none;
    transition: all 0.3s ease;
    line-height: 1.4;
}

.footer-text {
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    letter-spacing: 0.025em;
}

body.dark .footer-text {
    color: #94a3b8;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.footer-links a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    background: rgba(148, 163, 184, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

body.dark .footer-links a {
    color: #cbd5e1;
    background: rgba(148, 163, 184, 0.2);
    border-color: rgba(148, 163, 184, 0.3);
}

.footer-links a:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #3b82f6;
    transform: translateY(-1px);
}

.footer-links svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
        padding: 16px 20px;
    }

    .footer-links {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .toolbar {
        padding: 8px 12px;
        gap: 8px;
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        justify-content: center;
        padding: 4px 8px;
    }

    .mode-toggle, .tool-toggle {
        width: 100%;
    }

    .mode-btn, .tool-btn {
        flex: 1;
        text-align: center;
    }

    .app-footer {
        position: relative;
        margin-top: 20px;
    }
}
