.sort-external-top-bar {
    position: fixed;
    z-index: 10005 !important;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 90%;
    max-width: 400px;
    height: var(--modal-bar-height);
    padding: 0 12px;
    border-radius: 18px;
    background: var(--popup-bg);
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    border: 1px solid var(--glass-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), var(--glass-inner-highlight);
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transform: translateY(34px) scale(0.94) translateZ(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0s, opacity 0.18s ease 0s;
    user-select: none;
    -webkit-user-select: none;
}

.sort-external-top-bar.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1) translateZ(0);
    transition: transform 0.44s cubic-bezier(0.34, 1.38, 0.64, 1) 0.06s, opacity 0.24s ease 0.06s;
}

.sort-path-segment {
    flex: 1;
    min-width: 0;
    height: 58px;
    position: relative;
    display: block;
    background: transparent;
    border: none;
    border-radius: 12px;
    padding: 0 6px;
    cursor: default;
    outline: none !important;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    box-sizing: border-box;
    transform: scale(1) translateZ(0);
    transform-origin: center center;
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transition: background-color 0.18s ease, transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sort-path-segment.is-clickable,
.sort-path-segment.has-value {
    cursor: pointer;
}

.sort-path-segment.is-clickable:active,
.sort-path-segment.has-value:active {
    transform: scale(0.94) translateZ(0) !important;
    transition: transform 0.04s ease-out !important;
}

@media (hover: hover) {

    .sort-path-segment.is-clickable:hover,
    .sort-path-segment.has-value:hover {
        background: rgba(150, 150, 150, 0.14);
    }
}

.sort-path-title {
    position: absolute;
    left: 6px;
    right: 6px;
    top: 50%;
    height: 1.25em;
    margin-top: -0.625em;
    display: block;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    transform: translate3d(0, 0, 0) scale(1);
    transform-origin: center center;
    transition: transform 0.34s cubic-bezier(0.34, 1.45, 0.64, 1), color 0.22s ease, opacity 0.22s ease;
    pointer-events: none;
}

.sort-path-segment.is-current .sort-path-title {
    color: var(--primary);
}

.sort-path-segment.has-value .sort-path-title {
    transform: translate3d(0, -11px, 0) scale(0.76);
    opacity: 0.85;
}

.sort-path-value {
    position: absolute;
    left: 6px;
    right: 6px;
    top: 50%;
    height: 1.25em;
    margin-top: -0.625em;
    display: block;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    opacity: 0;
    transform: translate3d(0, 14px, 0) scale(0.92);
    transform-origin: center center;
    transition: opacity 0.26s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.34s cubic-bezier(0.34, 1.45, 0.64, 1), color 0.22s ease;
    pointer-events: none;
}

.sort-path-segment.has-value .sort-path-value {
    opacity: 1;
    transform: translate3d(0, 10px, 0) scale(1);
}

.sort-path-segment.has-value.is-current .sort-path-value {
    color: var(--primary);
}

.sort-external-bottom-bar {
    position: fixed;
    z-index: 10005 !important;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 90%;
    max-width: 400px;
    height: var(--modal-bar-height);
    padding: 0 10px;
    border-radius: 18px;
    background: var(--popup-bg);
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    border: 1px solid var(--glass-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), var(--glass-inner-highlight);
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-34px) scale(0.94) translateZ(0);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0s, opacity 0.18s ease 0s;
    user-select: none;
    -webkit-user-select: none;
}

.sort-external-bottom-bar.active {
    display: flex;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1) translateZ(0);
    transition: transform 0.44s cubic-bezier(0.34, 1.38, 0.64, 1) 0.06s, opacity 0.24s ease 0.06s;
}

.sort-external-bottom-bar .btn-primary {
    flex: 1;
    height: 52px;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

#sort-modal {
    z-index: 10003 !important;
    display: none;
    flex-direction: column;
    width: 90%;
    max-width: 400px;
    height: min(536px, calc(100vh - 2 * (var(--modal-bar-height) + 24px)));
    max-height: min(536px, calc(100vh - 2 * (var(--modal-bar-height) + 24px)));
    padding: 28px 24px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2), var(--glass-inner-highlight);
    box-sizing: border-box;
    background: var(--popup-bg);
    backdrop-filter: blur(var(--blur-val));
    -webkit-backdrop-filter: blur(var(--blur-val));
    border: 1px solid var(--glass-border);
    pointer-events: none;
    text-align: left;
    position: fixed;
    top: 50%;
    left: 50%;
    opacity: 0;
    transform: translate(-50%, calc(-50% + 16px)) scale(0.95);
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0.04s, transform 0.22s cubic-bezier(0.4, 0, 0.2, 1) 0.04s;
}

#sort-modal.active {
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
    transition: opacity 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) 0s, transform 0.42s cubic-bezier(0.34, 1.38, 0.64, 1) 0s;
}

.sort-carousel-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: calc(100% + 48px);
    height: 100%;
    min-height: 0;
    margin-left: -24px;
    margin-right: -24px;
    padding-left: 24px;
    padding-right: 24px;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

.sort-carousel {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 100%;
    min-height: 0;
    gap: 32px;
    touch-action: pan-y;
    will-change: transform;
    transition: transform 0.48s cubic-bezier(0.34, 1.45, 0.64, 1);
    user-select: none;
    -webkit-user-select: none;
}

.sort-carousel.is-dragging {
    transition: none !important;
}

.sort-carousel-slide {
    flex: 0 0 100%;
    width: 100%;
    min-width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

.sort-column-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 4px;
    box-sizing: border-box;
    height: 100%;
}

/* 排序選框樣式（與選擇分類-標籤選框一致） */
.sort-modal-item {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    height: 70px;
    min-height: 70px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 12px;
    font-size: 16.5px;
    font-weight: 600;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-inner-highlight);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
    white-space: nowrap;
    outline: none !important;
    touch-action: pan-y;
    transform: translateZ(0);
}

.sort-modal-item:active {
    transform: scale(0.92) translateZ(0) !important;
    transition: transform 0.04s ease-out !important;
}

.sort-modal-item.is-drag-origin,
.category-modal-item.is-drag-origin {
    display: none !important;
}

.sort-modal-item.placeholder,
.category-modal-item.placeholder {
    z-index: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 70px !important;
    min-height: 70px !important;
    margin: 0 !important;
    padding: 12px 16px !important;
    border-radius: 12px !important;
    background: var(--input-bg) !important;
    border: 1px solid var(--glass-border) !important;
    opacity: 0.45 !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
    pointer-events: none !important;
    flex-shrink: 0 !important;
}

.sort-modal-item .item-icon.category-dot {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sort-modal-item .item-icon.category-dot .category-dot-circle {
    display: block;
    width: 4px;
    height: 4px;
    min-width: 4px;
    min-height: 4px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    opacity: 0.38;
    box-sizing: border-box;
    pointer-events: none;
    transform-origin: center center;
    transition: background-color 0.2s ease, opacity 0.2s ease, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sort-modal-item.active {
    background: var(--primary) !important;
    color: #FAF6EE !important;
    border-color: var(--primary) !important;
    box-shadow: var(--glass-inner-highlight) !important;
}

.sort-modal-item.active .item-icon.category-dot .category-dot-circle {
    background-color: #FAF6EE !important;
    opacity: 1 !important;
    box-shadow: none !important;
}

@media (hover: hover) {
    .sort-modal-item:hover:not(.active) {
        background: rgba(150, 150, 150, 0.15) !important;
        color: var(--text) !important;
        border-color: var(--glass-border) !important;
    }

    .sort-modal-item:hover:not(.active) .item-icon.category-dot .category-dot-circle {
        background-color: var(--primary);
        opacity: 1;
        box-shadow: 0 0 6px var(--primary);
        transform: scale(1.2);
    }
}

.sort-modal-item-text {
    flex: 1;
    min-width: 0;
    font-size: 16.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* 排序拖曳懸浮選框 */
.sort-drag-ghost {
    position: fixed;
    z-index: 10020 !important;
    pointer-events: none;
    box-sizing: border-box;
    height: 70px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 12px;
    font-size: 16.5px !important;
    font-weight: 600 !important;
    color: #FAF6EE !important;
    background: var(--primary) !important;
    border: 1px solid var(--primary) !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35), var(--glass-inner-highlight) !important;
    transform: none !important;
    white-space: nowrap;
    user-select: none;
    -webkit-user-select: none;
    will-change: left, top;
}

[data-theme="dark"] .sort-drag-ghost {
    background: var(--primary) !important;
    color: #FAF6EE !important;
    border: 1px solid var(--primary) !important;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5), var(--glass-inner-highlight) !important;
}

.sort-drag-ghost .item-icon.category-dot {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sort-drag-ghost .item-icon.category-dot .category-dot-circle {
    display: block;
    width: 4px;
    height: 4px;
    min-width: 4px;
    min-height: 4px;
    border-radius: 50%;
    background-color: #FAF6EE !important;
    opacity: 1 !important;
    box-shadow: none !important;
}

.sort-drag-ghost .sort-modal-item-text {
    flex: 1;
    min-width: 0;
    margin-left: 0;
    font-size: 16.5px !important;
    font-weight: 600 !important;
    color: #FAF6EE !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* 全畫面編輯器 */
#full-editor-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%);
    width: 90%;
    max-width: 400px;
    height: 75vh;
    min-height: 350px;
    max-height: 700px;
    border-radius: 24px;
    z-index: 3000;
    display: none;
    flex-direction: column;
    background: var(--popup-bg);
    border: 1px solid var(--glass-border);
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), var(--glass-inner-highlight);
    backdrop-filter: blur(var(--blur-val-sm));
    -webkit-backdrop-filter: blur(var(--blur-val-sm));
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    padding-bottom: 15px;
}

#full-editor-modal.active {
    transform: translate(-50%, -50%);
    opacity: 1;
}

[data-theme="dark"] #full-editor-modal {
    background: var(--popup-bg);
}

.full-editor-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 15px 0 15px;
    z-index: 3002;
}

#full-note-content {
    flex: 1;
    padding: 15px;
    font-size: 14pt;
    outline: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: transparent;
    border: none;
    color: var(--text);
    word-break: break-all;
    line-height: 1.6;
}

#full-note-content:empty:before {
    content: attr(placeholder);
    color: var(--text-secondary);
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.12s ease, color 0.12s ease;
}

