@charset "utf-8";

/* Make sure stickers are not clickable when not in edit mode */
.diary-paper:not(.edit-mode) .sticker-instance {
    pointer-events: none;
}

/* Post Actions Layout */
.post-actions {
    display: flex !important;
    justify-content: space-between !important;
    width: 100% !important;
    margin-top: 0;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
    align-items: center;
    position: relative;
    z-index: 20;
}

.actions-left {
    display: flex !important;
    flex: 1 !important;
    gap: 20px;
    align-items: center;
}

.actions-right {
    display: flex !important;
    align-items: center;
    margin-left: auto !important;
    justify-content: flex-end;
}
.action-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.6;
    transition: all 0.2s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-icon-btn img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.action-icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.action-icon-btn:active {
    transform: scale(0.9);
}

/* 뷰 모드 vs 편집 모드 버튼 노출 분기 */
/* View Mode (기본): 사진, 저장 숨김 */
.diary-paper:not(.edit-mode) .paper-photo-btn,
.diary-paper:not(.edit-mode) .paper-otomo-sticker-btn,
.diary-paper:not(.edit-mode) .paper-save-btn {
    display: none !important;
}

/* Edit Mode: 수정 숨김 */
.diary-paper.edit-mode .paper-edit-btn {
    display: none !important;
}

/* --- 스티커 인스턴스 --- */
.sticker-instance {
    position: absolute;
    cursor: grab;
    user-select: none;
}

.sticker-instance.selected {
    outline: 1.5px dashed var(--accent-color);
    outline-offset: 2px;
}

.resize-handle,
.rotate-handle,
.flip-handle,
.reset-handle {
    position: absolute;
    width: 26px;
    height: 26px;
    background-color: white;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.resize-handle {
    bottom: -10px;
    right: -10px;
    cursor: nwse-resize;
}

.rotate-handle {
    top: -10px;
    right: -10px;
    cursor: pointer;
}

.rotate-handle:active {
    cursor: pointer;
}

.flip-handle {
    top: -10px;
    left: -10px;
    cursor: pointer;
}

.reset-handle {
    bottom: -10px;
    left: -10px;
    cursor: pointer;
}

.resize-handle::after,
.rotate-handle::after,
.flip-handle::after,
.reset-handle::after {
    font-size: 14px;
    font-weight: bold;
    color: var(--accent-color);
    line-height: 1;
}

.resize-handle::after {
    content: "\2922";
}

.rotate-handle::after {
    content: "\21BB";
}

.flip-handle::after {
    content: "\21C4";
    font-size: 12px;
}

.reset-handle::after {
    content: "\21BA";
}

.sticker-instance.selected .resize-handle,
.sticker-instance.selected .rotate-handle,
.sticker-instance.selected .flip-handle,
.sticker-instance.selected .reset-handle {
    display: flex;
}

.sticker-instance[data-type="emoji"] {
    font-size: 35px;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.1));
    line-height: 1;
}

.sticker-instance[data-type="image"] {
    width: 120px;
    border-radius: 8px;
    border: 3px solid white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    height: auto;
}

.sticker-instance[data-type="image"] img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    pointer-events: none;
    border-radius: 5px;
}

.sticker-instance[data-type="custom-sticker"] {
    width: 100px;
    border: none;
    box-shadow: none;
    filter: none;
    height: auto;
}

.sticker-instance[data-type="custom-sticker"] img {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.sticker-instance[data-type="otomo"] {
    border: none;
    box-shadow: none;
    filter: none;
    height: auto;
    aspect-ratio: 1 / 1;
    overflow: visible;
}

.sticker-instance[data-type="otomo"] .sticker-content {
    position: absolute;
    display: block;
    inset: var(--otomo-scene-inset, -19.444%);
}

.sticker-instance[data-type="otomo"] .otomo-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.sticker-instance.dragging {
    cursor: grabbing;
    opacity: 0.9;
}

/* --- 플로팅 액션 버튼 (FAB) 영역 --- */
.fab-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.fab-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.fab {
    width: 50px;
    height: 50px;
    background: #15273f;
    /* 밤하늘 색상과 맞춰서 어색함 방지 */
    border: 3px solid #d4a373;
    /* 테두리를 버튼 컨테이너로 이동 */
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: all 0.3s;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    box-sizing: border-box;
    overflow: hidden;
    /* 이미지 탈출 방지 */
}

.fab img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 1;
    transition: transform 0.2s;
    display: block;
}

.fab:hover {
    transform: scale(1.05);
}

.fab:hover img {
    transform: rotate(-10deg);
}

/* --- FAB 서브 메뉴 --- */
.fab-menu {
    position: absolute;
    right: 70px;
    /* 메인 버튼 왼쪽에 위치 */
    display: flex;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(20px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-wrapper.open .fab-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.fab-menu-bottom {
    position: absolute;
    top: 62px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-12px) scale(0.96);
    transform-origin: top center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab-container > .fab-menu-bottom {
    z-index: 1;
}

.fab-wrapper.open ~ .fab-menu-bottom {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.fab-wrapper.open .fab {
    transform: rotate(45deg);
}

.fab-sub-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: white;
    border: 3px solid #d4a373;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
    padding: 0;
    overflow: hidden;
    /* 아이콘 이탈 방지 */
}

.fab-sub-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
    /* 7px -> 2px로 대폭 축소하여 아이콘 크기를 극대화 */
}

.fab-sub-btn:hover {
    transform: scale(1.1);
    background-color: #fdfdfd;
}

#fab-sub-pomodoro img {
    padding: 2px;
}

/* --- 꾸미기 툴바 --- */
#mobile-toolbar {
    background: white;
    border-radius: 25px 25px 0 0;
    padding: 7px 20px 10px 20px;
    /* 하단 패딩 20px -> 10px 축소 */
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 100;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 3px solid #15273f;
    border-bottom: none;
}

.toolbar-handle {
    width: 100%;
    height: 24px;
    /* 높이 30px -> 24px 축소 */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-bottom: 2px;
    padding-top: 2px;
    gap: 10px;
    color: #0B1026;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.toolbar-handle::before,
.toolbar-handle::after {
    content: "";
    height: 1.5px;
    width: 35px;
    background-color: #0B1026;
    border-radius: 2px;
}

#toolbar-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 24vh;
    overflow-y: auto;
    opacity: 1;
    transition: max-height 0.4s, opacity 0.3s;
}

#toolbar-content::-webkit-scrollbar {
    display: none;
}

#mobile-toolbar.collapsed #toolbar-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-bottom: 0;
}

.palette-wrap {
    display: grid;
    grid-template-columns: repeat(auto-fill, 52px);
    justify-content: space-between;
    gap: 10px 12px;
    /* 최소 가로 간격 12px 보장 */
    padding: 6px 8px;
    /* 양옆 여백 8px 추가하여 삭제 버튼 가림 방지 */
}

.sticker-origin {
    font-size: 32px;
    cursor: pointer;
    user-select: none;
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    background-color: var(--bg-color);
    position: relative;
}

.sticker-origin img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    border-radius: 8px;
}

.palette-add-btn {
    background: none !important;
    cursor: pointer;
    padding: 8px;
    /* 크기 조정을 위해 패딩 약간 축소 */
    border: none !important;
    box-shadow: none !important;
}

.palette-add-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 1;
    /* 이미지만 꽉 보이게 투명도 제거 */
}

.color-btn {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    position: relative;
    background-size: cover;
    background-position: center;
}

.delete-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background-color: #ff6b6b;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    cursor: pointer;
}

/* --- 사진 커스텀 컨텍스트 메뉴 애니메이션 --- */
@keyframes ctxMenuIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(-6px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.toolbar-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 5px;
}

.toolbar-title-row .toolbar-title {
    margin-bottom: 0;
}

.palette-clear-btn {
    background: none;
    border: none;
    color: rgba(255, 138, 128, 0.8);
    font-size: 11px;
    cursor: pointer;
    font-weight: bold;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.palette-clear-btn:hover {
    background: rgba(255, 138, 128, 0.1);
}

/* --- 위로 가기 버튼 --- */
.scroll-top-btn {
    position: absolute;
    bottom: 150px;
    /* 툴바 열림 영역을 피해서 배치 */
    right: 20px;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* 최상단에 오도록 z-index 상향 조정 */
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 0;
}

.scroll-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.scroll-top-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.2s;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    /* 배경이 없어도 잘 보이도록 이미지 자체에 그림자 부여 */
}

.scroll-top-btn:hover {
    transform: scale(1.1) translateY(0);
}

.scroll-top-btn:active {
    transform: scale(0.95);
}
