:root {
    --bg-primary: #f0f4ff;
    --bg-secondary: #ffffff;
    --bg-toolbar: rgba(255, 255, 255, 0.85);
    --text-primary: #1a1a2e;
    --text-secondary: #64748b;
    --border: rgba(99, 102, 241, 0.15);
    --border-focus: #6366f1;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.1);
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    --success: #22c55e;
    --shadow-sm: 0 1px 3px rgba(99, 102, 241, 0.08);
    --shadow-md: 0 4px 12px rgba(99, 102, 241, 0.12);
    --shadow-lg: 0 12px 32px rgba(99, 102, 241, 0.18);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 300ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --toolbar-height: 56px;
    --tools-height: 0px;
    --status-height: 0px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
    --bg-primary: #0c0f1a;
    --bg-secondary: #1a1f35;
    --bg-toolbar: rgba(26, 31, 53, 0.9);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: rgba(129, 140, 248, 0.2);
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-light: rgba(129, 140, 248, 0.15);
    --accent-gradient: linear-gradient(135deg, #818cf8 0%, #a78bfa 50%, #c084fc 100%);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(129, 140, 248, 0.35);
}

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

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
}

html, body {
    height: 100%;
    overflow: hidden;
}

/* Inner pages: override overflow and height for scrolling */
body.page,
body.page html {
    height: auto;
    overflow: auto;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background var(--transition), color var(--transition);
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    overscroll-behavior: none;
}

body.page {
    touch-action: auto;
    overscroll-behavior: auto;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* ── Toolbar ── */
#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-toolbar);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transition: all var(--transition);
    padding-top: var(--safe-top);
}

/* Inner pages: sticky toolbar */
body.page #toolbar {
    position: sticky;
}

.toolbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--toolbar-height);
    padding: 0 12px;
    gap: 8px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-icon {
    color: var(--accent);
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 0 8px rgba(99, 102, 241, 0.4));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.brand-name {
    font-weight: 800;
    font-size: 16px;
    white-space: nowrap;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

.tld {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
    justify-content: flex-end;
}

.toolbar-actions::-webkit-scrollbar {
    display: none;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--accent);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    overflow: hidden;
}

.toolbar-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition);
}

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

.toolbar-btn:hover {
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.toolbar-btn:active {
    transform: scale(0.95) translateY(0);
}

.toolbar-btn svg {
    position: relative;
    z-index: 1;
}

.toolbar-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.toolbar-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

.toolbar-btn:disabled::before {
    display: none;
}

.toolbar-btn.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.toolbar-btn.danger::before {
    background: var(--danger-gradient);
}

.toolbar-btn.danger:hover {
    color: white;
}

.toolbar-btn.new-page-btn {
    width: auto;
    padding: 0 14px;
    gap: 6px;
    background: var(--danger-gradient);
    color: white;
    font-weight: 600;
    font-size: 13px;
}

.toolbar-btn.new-page-btn::before {
    display: none;
}

.toolbar-btn.new-page-btn:hover {
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    transform: translateY(-2px);
}

.toolbar-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
    flex-shrink: 0;
}

/* ── Brush Size ── */
.size-control {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    background: var(--accent-light);
    border-radius: var(--radius-full);
    padding: 4px 12px;
}

#brush-size {
    width: 80px;
    height: 24px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    outline: none;
    cursor: pointer;
}

#brush-size::-webkit-slider-runnable-track {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
}

#brush-size::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-gradient);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: var(--shadow-md), 0 0 12px rgba(99, 102, 241, 0.4);
    margin-top: -8px;
    transition: transform var(--transition-bounce);
}

#brush-size::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#brush-size::-moz-range-track {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
}

#brush-size::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-gradient);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.size-display {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    min-width: 32px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ── Color Controls ── */
.color-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#color-picker {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    background: none;
    flex-shrink: 0;
    transition: all var(--transition);
}

#color-picker:hover {
    border-color: var(--accent);
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

#color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

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

.color-presets {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    background: var(--accent-light);
    border-radius: var(--radius-full);
    padding: 4px 8px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-bounce);
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.color-swatch:hover {
    transform: scale(1.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.color-swatch.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px white, 0 0 0 5px var(--accent), var(--shadow-glow);
    transform: scale(1.15);
}

/* ── Dropdown ── */
.dropdown {
    position: relative;
    flex-shrink: 0;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-toolbar);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    min-width: 180px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
    animation: dropdownIn 0.2s ease-out;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#board-menu {
    min-width: 200px;
}

#board-menu::-webkit-scrollbar {
    width: 6px;
}

#board-menu::-webkit-scrollbar-track {
    background: transparent;
}

#board-menu::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu button {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
    touch-action: manipulation;
}

/* ── Site Navigation ── */
.site-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.site-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 600;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}

.site-nav a:hover {
    background: var(--accent-light);
    color: var(--accent-hover);
    transform: translateY(-1px);
}

.site-nav a.active {
    color: var(--accent);
    background: transparent;
}

.dropdown-menu a {
    display: block;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
}

.dropdown-menu a:hover {
    background: var(--accent-gradient);
    color: white;
}

.dropdown-menu button:hover,
.dropdown-menu button:active {
    background: var(--accent-gradient);
    color: white;
}

/* ── Board Menu ── */
.board-option {
    display: flex !important;
    align-items: center;
    gap: 10px;
}

.board-option::before {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 2px solid var(--border);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.board-option:hover::before {
    transform: scale(1.15);
}

.board-option[data-bg="#ffffff"]::before { background: #ffffff; }
.board-option[data-bg="#f8f9fa"]::before { background: #f8f9fa; }
.board-option[data-bg="#e9ecef"]::before { background: #e9ecef; }
.board-option[data-bg="#dee2e6"]::before { background: #dee2e6; }
.board-option[data-bg="#1a1a1a"]::before { background: #1a1a1a; }
.board-option[data-bg="#1a1a2e"]::before { background: #1a1a2e; }
.board-option[data-bg="#16213e"]::before { background: #16213e; }
.board-option[data-bg="#0f3460"]::before { background: #0f3460; }
.board-option[data-bg="#1b1b2f"]::before { background: #1b1b2f; }
.board-option[data-bg="#000000"]::before { background: #000000; }
.board-option[data-bg="#fdf6e3"]::before { background: #fdf6e3; }
.board-option[data-bg="#fff8e1"]::before { background: #fff8e1; }
.board-option[data-bg="#fff3e0"]::before { background: #fff3e0; }
.board-option[data-bg="#fce4ec"]::before { background: #fce4ec; }
.board-option[data-bg="#f3e5f5"]::before { background: #f3e5f5; }
.board-option[data-bg="#e8eaf6"]::before { background: #e8eaf6; }
.board-option[data-bg="#e3f2fd"]::before { background: #e3f2fd; }
.board-option[data-bg="#e0f7fa"]::before { background: #e0f7fa; }
.board-option[data-bg="#e8f5e9"]::before { background: #e8f5e9; }
.board-option[data-bg="#f1f8e9"]::before { background: #f1f8e9; }
.board-option[data-bg="#fffde7"]::before { background: #fffde7; }
.board-option[data-bg="#fff9c4"]::before { background: #fff9c4; }

.board-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 0;
}

.board-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
}

.board-custom label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.board-custom input[type="color"] {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    background: none;
    transition: all var(--transition);
}

.board-custom input[type="color"]:hover {
    border-color: var(--accent);
    transform: scale(1.05);
}

/* ── Tool Bar (Bottom) ── */
.toolbar-tools {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-toolbar);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(99, 102, 241, 0.12);
    padding-bottom: var(--safe-bottom);
}

.toolbar-tools-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 64px;
    padding: 0 8px;
    gap: 6px;
    position: relative;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    transition: all var(--transition);
    flex: 1;
    max-width: 76px;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.tool-btn svg {
    width: 24px;
    height: 24px;
    transition: all var(--transition);
}

.tool-btn:active {
    transform: scale(0.9);
}

.tool-btn.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.tool-btn.active svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.tool-label {
    display: block;
    line-height: 1;
}

/* ── Canvas ── */
#canvas-container {
    position: fixed;
    top: calc(var(--toolbar-height) + var(--safe-top));
    left: 0;
    right: 0;
    bottom: 64px;
    background: var(--bg-primary);
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(168, 85, 247, 0.03) 0%, transparent 50%);
}

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

#canvas-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-secondary);
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 32px;
}

#canvas-placeholder svg {
    width: 64px;
    height: 64px;
    opacity: 0.4;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.05); opacity: 0.6; }
}

#canvas-placeholder p {
    margin-top: 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

#canvas-placeholder.hidden {
    opacity: 0;
}

/* ── Status Bar ── */
.status-bar {
    display: none;
}

/* ── Cursor styles ── */
.cursor-pencil { cursor: crosshair; }
.cursor-brush { cursor: crosshair; }
.cursor-eraser { cursor: cell; }
.cursor-spray { cursor: crosshair; }
.cursor-paintbrush { cursor: crosshair; }
.cursor-marker { cursor: crosshair; }
.cursor-neon { cursor: crosshair; }

/* ── Focus visible ── */
:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

/* ── Tablet (768px+) ── */
@media (min-width: 768px) {
    :root {
        --toolbar-height: 60px;
    }

    .toolbar-top {
        padding: 0 16px;
        gap: 12px;
    }

    .toolbar-actions {
        gap: 8px;
    }

    .toolbar-btn {
        min-width: 42px;
        width: 42px;
        height: 42px;
    }

    .toolbar-divider {
        display: block;
    }

    .size-control {
        display: flex;
    }

    .color-presets {
        display: flex;
    }

    .brand-name {
        display: block;
    }

    .toolbar-tools {
        display: none;
    }

    #canvas-container {
        bottom: 0;
    }

    .status-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: var(--status-height);
        align-items: center;
        padding: 0 16px;
        gap: 12px;
        background: var(--bg-toolbar);
        backdrop-filter: blur(20px);
        border-top: 1px solid var(--border);
        font-size: 12px;
        font-weight: 500;
        color: var(--text-secondary);
        z-index: 100;
    }

    .status-divider {
        opacity: 0.3;
    }
}

/* ── Small tablets / large phones ── */
@media (min-width: 480px) and (max-width: 767px) {
    .tool-btn {
        flex-direction: row;
        gap: 6px;
        max-width: none;
        padding: 8px 16px;
    }

    .tool-label {
        font-size: 11px;
        text-transform: uppercase;
    }
}

/* ── Mobile (up to 479px) ── */
@media (max-width: 479px) {
    :root {
        --toolbar-height: 50px;
    }

    .brand-name {
        display: none;
    }

    .toolbar-top {
        padding: 0 8px;
        gap: 4px;
    }

    .toolbar-actions {
        gap: 4px;
    }

    .toolbar-btn {
        min-width: 36px;
        width: 36px;
        height: 36px;
        padding: 0 6px;
    }

    .toolbar-btn svg {
        width: 18px;
        height: 18px;
    }

    .toolbar-divider {
        display: none;
    }

    .size-control {
        display: none;
    }

    .color-presets {
        display: none;
    }

    #color-picker {
        width: 32px;
        height: 32px;
    }

    .toolbar-btn.new-page-btn {
        padding: 0 10px;
        gap: 4px;
    }

    .toolbar-btn.new-page-btn .tool-label {
        font-size: 12px;
    }

    .toolbar-tools-inner {
        height: 58px;
        padding: 0 4px;
        gap: 4px;
    }

    .tool-btn {
        padding: 6px 6px;
    }

    .tool-btn svg {
        width: 22px;
        height: 22px;
    }

    .tool-label {
        font-size: 9px;
    }

    #canvas-container {
        bottom: 58px;
    }

    #canvas-placeholder svg {
        width: 48px;
        height: 48px;
    }

    #canvas-placeholder p {
        font-size: 13px;
    }

    .dropdown-menu {
        position: fixed;
        top: auto;
        bottom: calc(58px + var(--safe-bottom));
        left: 8px;
        right: 8px;
        border-radius: var(--radius) var(--radius) 0 0;
        max-height: 50vh;
    }

    #board-menu {
        min-width: auto;
        left: 8px;
        right: 8px;
    }

    .tools-dropdown {
        position: fixed;
        bottom: calc(58px + var(--safe-bottom));
        left: 8px;
        right: 8px;
        width: auto;
        max-height: 60vh;
        border-radius: var(--radius) var(--radius) 0 0;
    }

    .tools-dropdown-actions {
        flex-direction: column;
    }

    .tool-action-btn {
        width: 100%;
    }
}

/* ── Very small phones ── */
@media (max-width: 360px) {
    .toolbar-btn {
        min-width: 32px;
        width: 32px;
        height: 32px;
    }

    .tool-btn {
        padding: 4px 4px;
    }

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

    .tool-label {
        font-size: 8px;
    }
}

/* ── Landscape mode ── */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --toolbar-height: 44px;
    }

    .toolbar-tools-inner {
        height: 48px;
    }

    .tool-btn {
        flex-direction: row;
        gap: 4px;
        padding: 4px 10px;
    }

    .tool-label {
        display: none;
    }

    #canvas-container {
        bottom: 48px;
    }
}

/* ── iPhone notch safe areas ── */
@supports (padding: env(safe-area-inset-top)) {
    #toolbar {
        padding-top: env(safe-area-inset-top);
    }

    .toolbar-tools {
        padding-bottom: env(safe-area-inset-bottom);
    }

    #canvas-container {
        top: calc(var(--toolbar-height) + env(safe-area-inset-top));
        bottom: calc(64px + env(safe-area-inset-bottom));
    }
}

/* ── Touch optimizations ── */
@media (pointer: coarse) {
    .toolbar-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .tool-btn {
        min-height: 48px;
    }

    .color-swatch {
        width: 28px;
        height: 28px;
    }

    .dropdown-menu button {
        padding: 16px 18px;
    }
}

/* ── Hover capable devices ── */
@media (hover: hover) {
    .toolbar-btn:hover {
        color: white;
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

    .tool-btn:hover {
        color: var(--accent);
        background: var(--accent-light);
    }

    .tool-btn.active:hover {
        background: var(--accent-gradient);
        color: white;
    }
}

/* ── Print ── */
@media print {
    #toolbar, .status-bar, .toolbar-tools { display: none !important; }
    #canvas-container {
        position: static;
        top: 0;
        bottom: 0;
    }
}

/* ── Dark mode scrollbar ── */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* ── SEO Content Section ── */
.seo-content {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-y: auto;
    z-index: 1000;
    padding: 24px 20px 40px;
    line-height: 1.8;
}

.seo-content h1 {
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 24px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.3;
    letter-spacing: -0.5px;
}

.seo-content h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 32px 0 14px;
    color: var(--accent);
}

.seo-content p {
    margin-bottom: 18px;
    font-size: 16px;
    color: var(--text-secondary);
}

.seo-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

@media (min-width: 768px) {
    .seo-content {
        max-width: 800px;
        margin: 0 auto;
        padding: 48px 40px 80px;
    }

    .seo-content h1 {
        font-size: 42px;
    }

    .seo-content h2 {
        font-size: 26px;
    }

    .seo-content p {
        font-size: 18px;
    }
}

/* ── FAQ Section ── */
.faq-section {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-y: auto;
    z-index: 1000;
    padding: 24px 20px 40px;
    line-height: 1.8;
}

.faq-title {
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 32px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    letter-spacing: -0.5px;
}

.faq-list {
    max-width: 800px;
    margin: 0 auto;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
    background: var(--bg-secondary);
    overflow: hidden;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

.faq-item[open] {
    border-color: var(--accent);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.faq-question {
    padding: 18px 22px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    transition: all var(--transition);
    -webkit-user-select: none;
    user-select: none;
}

.faq-question::-webkit-details-marker {
    display: none;
}

.faq-question::after {
    content: '+';
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    border-radius: 50%;
    transition: all var(--transition);
}

.faq-item[open] .faq-question::after {
    content: '−';
    background: var(--accent-gradient);
    color: white;
    transform: rotate(180deg);
}

.faq-question:hover {
    background: var(--accent-light);
}

.faq-answer {
    padding: 0 22px 22px;
    color: var(--text-secondary);
    font-size: 15px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.faq-answer p {
    margin-bottom: 14px;
}

.faq-answer ol,
.faq-answer ul {
    margin: 14px 0;
    padding-left: 28px;
}

.faq-answer li {
    margin-bottom: 10px;
}

.faq-answer strong {
    color: var(--text-primary);
    font-weight: 600;
}

@media (min-width: 768px) {
    .faq-title {
        font-size: 42px;
    }

    .faq-question {
        font-size: 18px;
        padding: 22px 28px;
    }

    .faq-answer {
        padding: 0 28px 28px;
        font-size: 16px;
    }
}

/* ── Site Footer ── */
.site-footer {
    text-align: center;
    padding: 20px 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    margin-top: auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.footer-links a:hover {
    color: var(--accent);
    background: var(--accent-light);
}

.footer-links a.active {
    color: var(--accent);
    font-weight: 600;
}

.footer-copy {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* ── Inner Page Styles (pages with .page class) ── */
body.page main {
    max-width: 800px;
    margin: 0 auto;
    padding: 30px 20px 60px;
    line-height: 1.8;
    color: var(--text-primary);
}

body.page main h1 {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

body.page main h2 {
    font-size: 22px;
    margin: 32px 0 12px;
    color: var(--text-primary);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-light);
}

body.page main p {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 16px;
}

body.page main ul,
body.page main ol {
    margin: 16px 0;
    padding-left: 28px;
}

body.page main li {
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 16px;
}

body.page main strong {
    color: var(--text-primary);
    font-weight: 600;
}

body.page main a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition);
}

body.page main a:hover {
    border-bottom-color: var(--accent);
}

body.page .info-card {
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

body.page .info-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

body.page .info-card p {
    margin: 0;
    font-size: 15px;
}

/* ── Draw Now Button ── */
.toolbar-btn.draw-btn {
    text-decoration: none;
    font-size: 14px;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.toolbar-btn.draw-btn:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

/* ── Tools Dropdown ── */
.hamburger-btn {
    background: var(--accent-gradient) !important;
    color: #fff !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-md);
    min-width: 44px;
    min-height: 44px;
}

.hamburger-btn:hover {
    box-shadow: var(--shadow-glow) !important;
    transform: translateY(-1px);
}

.hamburger-btn:active {
    transform: scale(0.95) !important;
    box-shadow: var(--shadow-sm) !important;
}

.tools-dropdown {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    max-height: 480px;
    padding: 0;
    overflow: hidden;
    margin-bottom: 8px;
}

.tools-dropdown-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.tools-dropdown-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.tools-filter {
    margin-bottom: 10px;
}

.tools-filter input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
}

.tools-filter input:focus {
    border-color: var(--accent);
}

.tools-filter input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.tools-sort {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.sort-btn {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.sort-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.sort-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.tools-category-filter {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.cat-btn {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.cat-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.cat-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.tools-list {
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
}

.tools-list::-webkit-scrollbar {
    width: 4px;
}

.tools-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.tool-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
}

.tool-menu-item:hover {
    background: var(--accent-light);
}

.tool-menu-item.active-tool {
    background: var(--accent-light);
    border-left: 3px solid var(--accent);
}

.tool-menu-item.hidden {
    display: none;
}

.tool-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.tool-info {
    flex: 1;
    min-width: 0;
}

.tool-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.tool-desc {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.tag-draw { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.tag-paint { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.tag-effect { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.tag-edit { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.tools-dropdown-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.tools-dropdown-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.tool-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    touch-action: manipulation;
}

.tool-action-btn:hover {
    background: var(--accent-gradient);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.tool-action-btn:active {
    transform: scale(0.97);
}

.tools-count {
    font-size: 11px;
    color: var(--text-secondary);
}

.tools-dropdown-footer kbd {
    font-size: 10px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-family: inherit;
}

[data-theme="dark"] .tag-draw { background: rgba(96, 165, 250, 0.2); color: #60a5fa; }
[data-theme="dark"] .tag-paint { background: rgba(192, 132, 252, 0.2); color: #c084fc; }
[data-theme="dark"] .tag-effect { background: rgba(250, 204, 21, 0.2); color: #facc15; }
[data-theme="dark"] .tag-edit { background: rgba(248, 113, 113, 0.2); color: #f87171; }

/* ── Error Pages ── */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    text-align: center;
    padding: 40px 20px;
}

.error-code {
    font-size: 120px;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 16px;
    opacity: 0.85;
}

.error-page h1 {
    font-size: 28px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.error-page p {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 420px;
    margin-bottom: 32px;
    line-height: 1.6;
}

.error-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.error-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
}

.error-btn.primary {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.error-btn.primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.error-btn.secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.error-btn.secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

@media (max-width: 480px) {
    .error-code {
        font-size: 80px;
    }
    .error-page h1 {
        font-size: 22px;
    }
}

/* ── Inner page body override (allow scrolling) ── */
body:not(#drawing-canvas) ~ .site-footer,
body {
    overflow: auto;
    height: auto;
    touch-action: auto;
}

/* When canvas container doesn't exist, allow scroll */
#toolbar + main {
    overflow: visible;
    height: auto;
}
