/* ─── 디버그 메모 ─────────────────────────────────────── */

#debug-memo-toggle {
    position: fixed;
    bottom: 6rem;
    right: 1.5rem;
    z-index: 9998;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #1f2937;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    border: none;
}

#debug-memo-toggle:hover {
    transform: translateY(-2px);
    background: #111827;
}

#debug-memo-toggle.active {
    background: #ef4444;
}

.debug-memo-pin {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    z-index: 9997;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -50%);
    transition: transform 0.15s;
}

.debug-memo-pin:hover {
    transform: translate(-50%, -50%) scale(1.2);
}

.debug-memo-bubble {
    position: absolute;
    z-index: 10001;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    padding: 14px;
    min-width: 360px;
    max-width: 460px;
    transform: translate(12px, -12px);
    font-size: 13px;
    color: #1f2937;
}

.debug-memo-bubble .dm-meta {
    font-size: 11px;
    color: #6b7280;
    margin-bottom: 8px;
    word-break: break-all;
    line-height: 1.45;
}

.debug-memo-bubble .dm-meta strong {
    color: #374151;
}

.debug-memo-bubble textarea {
    width: 100%;
    min-height: 72px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    outline: none;
}

.debug-memo-bubble textarea:focus {
    border-color: #0052CC;
}

.debug-memo-bubble .dm-content {
    white-space: pre-wrap;
    word-break: break-word;
    padding: 4px 0 10px;
    line-height: 1.5;
}

.debug-memo-bubble .dm-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    justify-content: flex-end;
}

.debug-memo-bubble .dm-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s;
}

.debug-memo-bubble .dm-btn-primary {
    background: #0052CC;
    color: #fff;
}

.debug-memo-bubble .dm-btn-primary:hover {
    background: #0047b3;
}

.debug-memo-bubble .dm-btn-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.debug-memo-bubble .dm-btn-danger:hover {
    background: #fecaca;
}

.debug-memo-bubble .dm-btn-ghost {
    background: #f3f4f6;
    color: #374151;
}

.debug-memo-bubble .dm-btn-ghost:hover {
    background: #e5e7eb;
}

.debug-memo-highlight {
    outline: 2px dashed #ef4444 !important;
    outline-offset: 2px;
    background: rgba(239, 68, 68, 0.06) !important;
    cursor: crosshair !important;
}

/* ─── 드래그 ────────────────────────────────────────── */

.debug-memo-bubble .dm-drag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: -14px -14px 8px;
    padding: 8px 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 12px 12px 0 0;
    cursor: move;
    user-select: none;
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
    touch-action: none;
}

.debug-memo-bubble .dm-drag > span:first-child,
.debug-memo-bubble .dm-drag > span:first-child * {
    pointer-events: none;
}

.debug-memo-bubble .dm-drag-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    border-radius: 4px;
}

.debug-memo-bubble .dm-drag-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.debug-memo-bubble.dragging {
    opacity: 0.85;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
}

/* ─── 첨부파일 ──────────────────────────────────── */

.debug-memo-bubble.dm-dragover {
    outline: 2px dashed #0052CC;
    outline-offset: -2px;
    background: #eff6ff;
}

.debug-memo-bubble .dm-attach-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.debug-memo-bubble .dm-attach-item {
    position: relative;
    max-width: 100%;
}

.debug-memo-bubble .dm-attach-thumb {
    width: 68px;
    height: 68px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    display: block;
}

.debug-memo-bubble .dm-attach-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    text-decoration: none;
    color: #374151;
    font-size: 12px;
    max-width: 220px;
}

.debug-memo-bubble .dm-attach-file:hover {
    background: #e5e7eb;
}

.debug-memo-bubble .dm-attach-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.debug-memo-bubble .dm-attach-size {
    font-size: 10px;
    color: #9ca3af;
}

.debug-memo-bubble .dm-attach-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.debug-memo-bubble .dm-attach-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #e5e7eb;
}

.debug-memo-bubble .dm-attach-hint {
    font-size: 11px;
    color: #9ca3af;
}

/* ─── 목록 버튼/패널 ──────────────────────────────── */

#debug-memo-list-btn {
    position: fixed;
    bottom: 10.5rem;
    right: 1.5rem;
    z-index: 9998;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #374151;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    border: none;
    transition: transform 0.2s;
}

#debug-memo-list-btn.visible {
    display: flex;
}

#debug-memo-list-btn:hover {
    transform: translateY(-2px);
}

#debug-memo-list-btn .dm-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#debug-memo-list-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    max-width: 85vw;
    background: #fff;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

#debug-memo-list-panel.open {
    transform: translateX(0);
}

#debug-memo-list-panel .dm-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f9fafb;
}

#debug-memo-list-panel .dm-panel-title {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
}

#debug-memo-list-panel .dm-panel-close {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

#debug-memo-list-panel .dm-panel-close:hover {
    background: #e5e7eb;
}

#debug-memo-list-panel .dm-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

#debug-memo-list-panel .dm-item {
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

#debug-memo-list-panel .dm-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

#debug-memo-list-panel .dm-item-num {
    display: inline-flex;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
}

#debug-memo-list-panel .dm-item-comp {
    font-size: 11px;
    color: #6b7280;
    font-weight: 600;
}

#debug-memo-list-panel .dm-item-text {
    font-size: 13px;
    color: #1f2937;
    margin-top: 6px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#debug-memo-list-panel .dm-empty {
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    padding: 40px 20px;
}

#debug-memo-list-panel .dm-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 14px 4px 6px;
    padding: 4px 6px;
    border-bottom: 1px solid #e5e7eb;
}

#debug-memo-list-panel .dm-group-head:first-child {
    margin-top: 0;
}

#debug-memo-list-panel .dm-group-head.here {
    border-bottom-color: #0052CC;
}

#debug-memo-list-panel .dm-group-url {
    font-size: 11px;
    font-weight: 700;
    color: #374151;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    word-break: break-all;
}

#debug-memo-list-panel .dm-group-head.here .dm-group-url {
    color: #0052CC;
}

#debug-memo-list-panel .dm-group-count {
    flex-shrink: 0;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    background: #ef4444;
    border-radius: 10px;
    padding: 2px 7px;
    min-width: 20px;
    text-align: center;
}

#debug-memo-list-panel .dm-item.resolved {
    background: #f9fafb;
    border-color: #e5e7eb;
    opacity: 0.75;
}

#debug-memo-list-panel .dm-item.resolved .dm-item-text {
    text-decoration: line-through;
    color: #6b7280;
}

#debug-memo-list-panel .dm-item-note {
    margin-top: 6px;
    padding-left: 4px;
    font-size: 11px;
    color: #10b981;
    font-weight: 600;
}

#debug-memo-list-panel .dm-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#debug-memo-list-panel .dm-item-header-left {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

#debug-memo-list-panel .dm-panel-dispatch,
#debug-memo-list-panel .dm-panel-terminal {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #111827;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

#debug-memo-list-panel .dm-panel-dispatch:hover,
#debug-memo-list-panel .dm-panel-terminal:hover {
    background: #000;
}

/* ─── 터미널 모달 ────────────────────────────────── */

#debug-memo-term-modal {
    position: fixed;
    inset: 0;
    z-index: 10020;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: dm-overlay-in 0.2s ease-out;
}

#debug-memo-term-modal .dm-term-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(3px);
}

#debug-memo-term-modal .dm-term-window {
    position: relative;
    width: 92vw;
    height: 86vh;
    max-width: 1400px;
    background: #0b1020;
    border-radius: 12px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#debug-memo-term-modal .dm-term-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #1f2937;
    color: #e5e7eb;
    border-bottom: 1px solid #374151;
}

#debug-memo-term-modal .dm-term-title {
    font-size: 13px;
    font-weight: 700;
    color: #f3f4f6;
}

#debug-memo-term-modal .dm-term-close,
#debug-memo-term-modal .dm-term-newtab {
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    line-height: 1;
}

#debug-memo-term-modal .dm-term-close:hover,
#debug-memo-term-modal .dm-term-newtab:hover {
    background: #374151;
    color: #fff;
}

#debug-memo-term-modal .dm-term-iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: #0b1020;
}

/* ─── 풀스크린 오버레이 ─────────────────────────── */

#debug-memo-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(3px);
    z-index: 10010;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: dm-overlay-in 0.2s ease-out;
}

@keyframes dm-overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.dm-overlay-card {
    background: #fff;
    border-radius: 16px;
    padding: 36px 44px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
    text-align: center;
    max-width: 420px;
}

.dm-overlay-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #e5e7eb;
    border-top-color: #0052CC;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: dm-spin 0.8s linear infinite;
}

@keyframes dm-spin {
    to { transform: rotate(360deg); }
}

.dm-overlay-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

.dm-overlay-progress {
    font-size: 14px;
    color: #0052CC;
    font-weight: 600;
    margin-bottom: 12px;
}

.dm-overlay-hint {
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
}

.debug-memo-bubble .dm-resolved-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #d1fae5;
    color: #065f46;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.debug-memo-bubble .dm-content.resolved {
    text-decoration: line-through;
    color: #6b7280;
}

/* ─── 모바일 (≤480px) 풀폭/터치 친화 ───────────────────── */
@media (max-width: 480px) {
    .debug-memo-bubble {
        min-width: 0;
        max-width: none;
        width: calc(100vw - 24px);
        left: 12px !important;
        right: 12px !important;
        padding: 12px;
        font-size: 14px;
    }
    .debug-memo-bubble .dm-btn {
        padding: 10px 12px;
        font-size: 13px;
    }
    .debug-memo-bubble textarea {
        min-height: 88px;
        font-size: 14px;          /* iOS Safari 자동 줌 방지 (≥16 이 더 안전) */
    }
    .debug-memo-bubble .dm-attach-row {
        flex-wrap: wrap;
    }
    .debug-memo-bubble .dm-attach-hint {
        flex-basis: 100%;
        font-size: 11px;
        opacity: 0.7;
    }
    #debug-memo-list-panel {
        width: 100vw;
        max-width: 100vw;
    }
    #debug-memo-toggle,
    #debug-memo-list-btn {
        width: 52px;
        height: 52px;
    }
}
