/* ═══════════════════════════════════════════════════════════════
   MOBILE BOTTOM SHEET — Slide-up panel component
   Only active on mobile (< 768px). Desktop untouched.
   ═══════════════════════════════════════════════════════════════ */

/* ── Backdrop ─────────────────────────────────────────────────── */

.cm-sheet-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9500;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.cm-sheet-backdrop--open {
    opacity: 1;
    pointer-events: auto;
}

/* ── Sheet Panel ──────────────────────────────────────────────── */

.cm-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 85vh;
    background: var(--ui-panel, #1e1e2e);
    border-top: 1px solid var(--ui-panel-border, rgba(255, 255, 255, 0.08));
    border-radius: 16px 16px 0 0;
    z-index: 9501;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.cm-sheet-open {
    transform: translateY(0);
}

.cm-sheet-closing {
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

/* ── Drag Handle ──────────────────────────────────────────────── */

.cm-sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0 6px;
    cursor: grab;
    touch-action: none;
}

.cm-sheet-handle:active {
    cursor: grabbing;
}

.cm-sheet-handle-bar {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
}

/* ── Sheet Content ────────────────────────────────────────────── */

.cm-sheet-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0 16px 16px;
}

.cm-sheet-content::-webkit-scrollbar {
    width: 4px;
}
.cm-sheet-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}
.cm-sheet-content::-webkit-scrollbar-track {
    background: transparent;
}

/* ── Drawing Tools Grid (used inside sheet) ───────────────────── */

.cm-draw-sheet {
    padding: 8px 0;
}

.cm-draw-cat-hdr {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ui-muted, rgba(255, 255, 255, 0.35));
    padding: 10px 0 6px;
}

.cm-draw-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 4px 0 8px;
}

.cm-draw-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 4px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--ui-fg, #e0e0e0);
    font-size: 11px;
    cursor: pointer;
    transition: background 0.12s ease;
    min-height: 56px;
}

.cm-draw-item:hover,
.cm-draw-item:active {
    background: rgba(255, 255, 255, 0.06);
}

.cm-draw-item--active {
    background: rgba(38, 166, 154, 0.12);
    color: #26a69a;
}

.cm-draw-item--active .cm-draw-icon {
    color: #26a69a;
}

.cm-draw-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--ui-fg, #e0e0e0);
}

.cm-draw-icon svg,
.cm-draw-icon i {
    width: 20px;
    height: 20px;
}

.cm-draw-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}

/* ── More Features List (used inside sheet) ───────────────────── */

.cm-more-list {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

.cm-more-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 8px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--ui-fg, #e0e0e0);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s ease;
    width: 100%;
    text-align: left;
}

.cm-more-item:hover,
.cm-more-item:active {
    background: rgba(255, 255, 255, 0.06);
}

.cm-more-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
}

.cm-more-label {
    flex: 1;
}

.cm-more-arrow {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

/* ── Tablet: bottom sheet stays at bottom ── */
@media (min-width: 768px) {
    .cm-sheet {
        max-width: 500px;
        left: 50%;
        transform: translateX(-50%) translateY(100%);
    }
    .cm-sheet-open {
        transform: translateX(-50%) translateY(0);
    }
    .cm-sheet-closing {
        transform: translateX(-50%) translateY(100%);
    }
}

/* ── Light mode overrides ── */
@media (prefers-color-scheme: light) {
    .cm-sheet {
        background: #F3F4F6;
        border-top-color: rgba(0, 0, 0, 0.08);
    }
    .cm-sheet-handle-bar { background: rgba(0, 0, 0, 0.15); }
    .cm-draw-item { color: #1a1a2e; }
    .cm-draw-item:hover,
    .cm-draw-item:active { background: rgba(0, 0, 0, 0.04); }
    .cm-draw-item--active { background: rgba(38, 166, 154, 0.1); color: #26a69a; }
    .cm-draw-item--active .cm-draw-icon { color: #26a69a; }
    .cm-draw-cat-hdr { color: rgba(0, 0, 0, 0.4); }
    .cm-more-item { color: #1a1a2e; }
    .cm-more-item:hover,
    .cm-more-item:active { background: rgba(0, 0, 0, 0.04); }
    .cm-more-icon { color: rgba(0, 0, 0, 0.5); }
    .cm-more-arrow { color: rgba(0, 0, 0, 0.3); }
}

/* ── Touch targets ── */
@media (hover: none) and (pointer: coarse) {
    .cm-draw-item { min-height: 60px; padding: 14px 4px; }
    .cm-more-item { padding: 16px 8px; }
}
