.draw-modal {
    position: fixed;
    inset: 0;
    z-index: 3400;
    background: transparent;
}

.draw-modal.hidden {
    display: none;
}

body.draw-modal-open {
    overflow: hidden;
}

.draw-sheet {
    position: fixed;
    top: var(--draw-top, 0px);
    left: var(--draw-left, 0px);
    width: var(--draw-width, 100vw);
    height: var(--draw-height, 100vh);
    pointer-events: none;
    background: transparent;
    border: 0;
    box-shadow: none;
    max-height: none;
    padding: 0;
}

.draw-stage {
    position: absolute;
    inset: 0;
    background: transparent;
    border: 0;
    padding: 0;
}

#drawCanvas {
    width: 100%;
    height: 100%;
    display: block;
    background: transparent;
    border: 0;
    border-radius: 0;
    touch-action: none;
    pointer-events: auto;
}

.draw-header,
.draw-toolbar,
.draw-footer {
    position: absolute;
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    z-index: 2;
}

.draw-header {
    top: max(12px, env(safe-area-inset-top));
    justify-content: space-between;
}

.draw-toolbar {
    bottom: calc(72px + env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
}

.draw-footer {
    bottom: max(12px, env(safe-area-inset-bottom));
    justify-content: space-between;
}

.draw-header-copy,
.draw-tool-row,
.draw-size-row,
.draw-color-row,
.draw-footer-copy {
    pointer-events: auto;
}

.draw-header-copy {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.draw-header-copy strong {
    color: #f8fafc;
    font-size: 0.95rem;
}

.draw-header-copy p,
.draw-footer-copy {
    color: #cbd5e1;
    font-size: 0.78rem;
}

.draw-icon-btn,
.draw-tool-btn,
.draw-size-btn,
.draw-send-btn {
    pointer-events: auto;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.72);
    color: #f8fafc;
    transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.draw-icon-btn,
.draw-send-btn,
.draw-tool-btn,
.draw-size-btn {
    min-height: 42px;
    border-radius: 999px;
    cursor: pointer;
}

.draw-icon-btn {
    width: 42px;
    justify-content: center;
    flex: 0 0 auto;
}

.draw-tool-row,
.draw-size-row,
.draw-color-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.draw-tool-btn,
.draw-size-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    font-size: 0.83rem;
    font-weight: 600;
}

.draw-tool-btn.active,
.draw-size-btn.active,
.draw-send-btn {
    background: rgba(37, 99, 235, 0.9);
    border-color: rgba(147, 197, 253, 0.45);
}

.draw-color-btn {
    pointer-events: auto;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 3px solid transparent;
    background: var(--draw-swatch, #ffffff);
    cursor: pointer;
}

.draw-color-btn.active {
    border-color: #ffffff;
}

.draw-send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 18px;
    font-weight: 700;
}

body.theme-light .draw-header-copy,
body.theme-light .draw-icon-btn,
body.theme-light .draw-tool-btn,
body.theme-light .draw-size-btn,
body.theme-light .draw-send-btn,
body.theme-light .draw-footer-copy {
    background-image: none !important;
    box-shadow: none !important;
}

body.theme-light .draw-header-copy {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(148, 163, 184, 0.26);
}

body.theme-light .draw-header-copy strong {
    color: #0f172a;
}

body.theme-light .draw-header-copy p,
body.theme-light .draw-footer-copy {
    color: #475569;
}

body.theme-light .draw-icon-btn,
body.theme-light .draw-tool-btn,
body.theme-light .draw-size-btn {
    background: rgba(255, 255, 255, 0.94);
    color: #0f172a;
    border-color: rgba(148, 163, 184, 0.26);
}

body.theme-light .draw-tool-btn.active,
body.theme-light .draw-size-btn.active,
body.theme-light .draw-send-btn {
    background: #2563eb;
    color: #ffffff;
}

@media (max-width: 640px) {
    .draw-header,
    .draw-toolbar,
    .draw-footer {
        left: 10px;
        right: 10px;
    }

    .draw-header {
        top: max(10px, env(safe-area-inset-top));
    }

    .draw-toolbar {
        bottom: calc(78px + env(safe-area-inset-bottom));
    }

    .draw-footer {
        flex-direction: column;
        align-items: stretch;
        bottom: max(10px, env(safe-area-inset-bottom));
    }

    .draw-send-btn {
        width: 100%;
    }
}
